From a0482856992899cdb6c7dc150119ac3cced694b3 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Thu, 15 Jul 2021 11:32:03 +0200 Subject: [PATCH 1/5] Bulk remap, compiles --- build.gradle | 2 +- .../com/simibubi/create/AllBlockPartials.java | 4 +- .../java/com/simibubi/create/AllBlocks.java | 262 ++-- .../com/simibubi/create/AllEntityTypes.java | 2 +- .../java/com/simibubi/create/AllFluids.java | 16 +- .../java/com/simibubi/create/AllItems.java | 32 +- .../java/com/simibubi/create/AllKeys.java | 8 +- .../com/simibubi/create/AllParticleTypes.java | 2 +- .../com/simibubi/create/AllRecipeTypes.java | 2 +- .../java/com/simibubi/create/AllShapes.java | 12 +- .../com/simibubi/create/AllSoundEvents.java | 94 +- .../simibubi/create/AllSpecialTextures.java | 2 +- .../com/simibubi/create/AllSpriteShifts.java | 4 +- .../java/com/simibubi/create/AllTags.java | 26 +- .../com/simibubi/create/CreateClient.java | 22 +- .../compat/dynamictrees/DynamicTree.java | 4 +- .../create/compat/jei/ConversionRecipe.java | 2 +- .../simibubi/create/compat/jei/CreateJEI.java | 10 +- .../create/compat/jei/DoubleItemIcon.java | 14 +- .../compat/jei/GhostIngredientHandler.java | 10 +- .../compat/jei/ScreenResourceWrapper.java | 2 +- .../compat/jei/category/BasinCategory.java | 12 +- .../jei/category/BlockCuttingCategory.java | 8 +- .../jei/category/CreateRecipeCategory.java | 6 +- .../compat/jei/category/CrushingCategory.java | 2 +- .../jei/category/DeployingCategory.java | 8 +- .../jei/category/FanBlastingCategory.java | 4 +- .../jei/category/FanSmokingCategory.java | 2 +- .../jei/category/FanWashingCategory.java | 6 +- .../jei/category/ItemDrainCategory.java | 10 +- .../category/MechanicalCraftingCategory.java | 42 +- .../compat/jei/category/MillingCategory.java | 2 +- .../MysteriousItemConversionCategory.java | 2 +- .../compat/jei/category/PackingCategory.java | 4 +- .../jei/category/PolishingCategory.java | 4 +- .../compat/jei/category/PressingCategory.java | 2 +- .../category/ProcessingViaFanCategory.java | 16 +- .../compat/jei/category/SawingCategory.java | 2 +- .../category/SequencedAssemblyCategory.java | 36 +- .../compat/jei/category/SpoutCategory.java | 12 +- .../animations/AnimatedBlazeBurner.java | 8 +- .../category/animations/AnimatedCrafter.java | 4 +- .../animations/AnimatedCrushingWheels.java | 8 +- .../category/animations/AnimatedDeployer.java | 16 +- .../animations/AnimatedItemDrain.java | 12 +- .../category/animations/AnimatedKinetics.java | 2 +- .../animations/AnimatedMillstone.java | 4 +- .../category/animations/AnimatedMixer.java | 8 +- .../category/animations/AnimatedPress.java | 8 +- .../jei/category/animations/AnimatedSaw.java | 10 +- .../category/animations/AnimatedSpout.java | 20 +- .../SequencedAssemblySubCategory.java | 18 +- .../create/content/CreateItemGroup.java | 2 +- .../content/contraptions/KineticDebugger.java | 24 +- .../content/contraptions/KineticNetwork.java | 14 +- .../contraptions/RotationPropagator.java | 98 +- .../contraptions/TorquePropagator.java | 2 +- .../base/BackHalfShaftInstance.java | 2 +- .../contraptions/base/CasingBlock.java | 4 +- .../base/DirectionalAxisKineticBlock.java | 28 +- .../base/DirectionalKineticBlock.java | 28 +- .../base/GeneratingKineticTileEntity.java | 18 +- .../contraptions/base/HalfShaftInstance.java | 2 +- .../base/HorizontalAxisKineticBlock.java | 24 +- .../base/HorizontalHalfShaftInstance.java | 2 +- .../base/HorizontalKineticBlock.java | 24 +- .../content/contraptions/base/IRotate.java | 6 +- .../contraptions/base/KineticBlock.java | 20 +- .../contraptions/base/KineticData.java | 2 +- .../base/KineticEffectHandler.java | 18 +- .../contraptions/base/KineticTileEntity.java | 75 +- .../base/KineticTileEntityRenderer.java | 12 +- .../base/KineticTileInstance.java | 2 +- .../base/RotatedPillarKineticBlock.java | 36 +- .../contraptions/base/RotatingData.java | 6 +- .../components/AssemblyOperatorBlockItem.java | 20 +- .../components/actors/ActorData.java | 12 +- .../components/actors/AttachedActorBlock.java | 30 +- .../actors/BellMovementBehaviour.java | 4 +- .../BlockBreakingKineticTileEntity.java | 50 +- .../BlockBreakingMovementBehaviour.java | 42 +- .../actors/CampfireMovementBehaviour.java | 16 +- .../components/actors/DrillActorInstance.java | 4 +- .../components/actors/DrillBlock.java | 20 +- .../components/actors/DrillInstance.java | 2 +- .../actors/DrillMovementBehaviour.java | 6 +- .../components/actors/DrillRenderer.java | 8 +- .../components/actors/DrillTileEntity.java | 2 +- .../actors/HarvesterActorInstance.java | 4 +- .../components/actors/HarvesterBlock.java | 2 + .../actors/HarvesterMovementBehaviour.java | 38 +- .../components/actors/HarvesterRenderer.java | 8 +- .../actors/HarvesterTileEntity.java | 2 +- .../components/actors/PloughBlock.java | 2 + .../actors/PloughMovementBehaviour.java | 24 +- .../PortableFluidInterfaceTileEntity.java | 2 + .../actors/PortableStorageInterfaceBlock.java | 10 +- .../PortableStorageInterfaceMovement.java | 30 +- .../PortableStorageInterfaceRenderer.java | 8 +- .../PortableStorageInterfaceTileEntity.java | 12 +- .../actors/SawMovementBehaviour.java | 14 +- .../components/actors/SeatBlock.java | 52 +- .../components/actors/SeatEntity.java | 34 +- .../actors/SeatMovementBehaviour.java | 12 +- .../dispenser/ContraptionBlockSource.java | 18 +- .../dispenser/DispenserMovementBehaviour.java | 16 +- .../dispenser/DropperMovementBehaviour.java | 8 +- .../IMovedDispenseItemBehaviour.java | 40 +- .../MovedDefaultDispenseItemBehaviour.java | 20 +- .../MovedOptionalDispenseBehaviour.java | 2 +- .../MovedProjectileDispenserBehaviour.java | 10 +- .../actors/dispenser/SimplePos.java | 6 +- .../components/clock/CuckooClockBlock.java | 16 +- .../components/clock/CuckooClockRenderer.java | 14 +- .../clock/CuckooClockTileEntity.java | 48 +- .../crafter/ConnectedInputHandler.java | 54 +- .../crafter/CrafterCTBehaviour.java | 10 +- .../components/crafter/CrafterHelper.java | 2 +- .../crafter/MechanicalCrafterBlock.java | 86 +- .../crafter/MechanicalCrafterInstance.java | 2 +- .../crafter/MechanicalCrafterRenderer.java | 52 +- .../crafter/MechanicalCrafterTileEntity.java | 92 +- .../crafter/MechanicalCraftingInventory.java | 4 +- .../crafter/MechanicalCraftingRecipe.java | 12 +- .../components/crafter/RecipeGridHandler.java | 34 +- .../components/crank/HandCrankBlock.java | 38 +- .../components/crank/HandCrankInstance.java | 4 +- .../components/crank/HandCrankRenderer.java | 6 +- .../components/crank/HandCrankTileEntity.java | 8 +- .../components/crank/ValveHandleBlock.java | 22 +- .../components/crusher/CrushingRecipe.java | 2 +- .../crusher/CrushingWheelBlock.java | 68 +- .../crusher/CrushingWheelControllerBlock.java | 48 +- .../CrushingWheelControllerTileEntity.java | 76 +- .../crusher/CrushingWheelTileEntity.java | 10 +- .../deployer/BeltDeployerCallbacks.java | 18 +- .../deployer/DeployerActorInstance.java | 6 +- .../deployer/DeployerApplicationRecipe.java | 12 +- .../components/deployer/DeployerBlock.java | 40 +- .../deployer/DeployerFakePlayer.java | 24 +- .../deployer/DeployerFilterSlot.java | 4 +- .../components/deployer/DeployerHandler.java | 158 +- .../components/deployer/DeployerInstance.java | 14 +- .../deployer/DeployerItemHandler.java | 10 +- .../deployer/DeployerMovementBehaviour.java | 48 +- .../components/deployer/DeployerRenderer.java | 46 +- .../deployer/DeployerTileEntity.java | 118 +- .../components/fan/AirCurrent.java | 108 +- .../components/fan/AirCurrentSound.java | 22 +- .../components/fan/EncasedFanBlock.java | 40 +- .../components/fan/EncasedFanRenderer.java | 12 +- .../components/fan/EncasedFanTileEntity.java | 30 +- .../components/fan/FanInstance.java | 6 +- .../components/fan/NozzleBlock.java | 20 +- .../components/fan/NozzleTileEntity.java | 44 +- .../components/fan/SplashingRecipe.java | 2 +- .../components/flywheel/FlyWheelInstance.java | 30 +- .../components/flywheel/FlywheelBlock.java | 42 +- .../flywheel/FlywheelGenerator.java | 6 +- .../components/flywheel/FlywheelRenderer.java | 16 +- .../flywheel/FlywheelTileEntity.java | 6 +- .../flywheel/engine/EngineBlock.java | 24 +- .../flywheel/engine/EngineInstance.java | 2 +- .../flywheel/engine/EngineRenderer.java | 8 +- .../flywheel/engine/EngineTileEntity.java | 26 +- .../flywheel/engine/FurnaceEngineBlock.java | 8 +- .../engine/FurnaceEngineTileEntity.java | 4 +- .../components/millstone/MillingRecipe.java | 2 +- .../components/millstone/MillstoneBlock.java | 24 +- .../millstone/MillstoneTileEntity.java | 30 +- .../mixer/MechanicalMixerBlock.java | 9 +- .../mixer/MechanicalMixerRenderer.java | 12 +- .../mixer/MechanicalMixerTileEntity.java | 28 +- .../components/mixer/MixerInstance.java | 2 +- .../components/motor/CreativeMotorBlock.java | 14 +- .../motor/CreativeMotorGenerator.java | 8 +- .../motor/CreativeMotorTileEntity.java | 4 +- .../press/BeltPressingCallbacks.java | 2 +- .../press/MechanicalPressBlock.java | 14 +- .../press/MechanicalPressRenderer.java | 12 +- .../press/MechanicalPressTileEntity.java | 80 +- .../components/press/PressInstance.java | 2 +- .../components/press/PressingRecipe.java | 2 +- .../components/saw/CuttingRecipe.java | 2 +- .../contraptions/components/saw/SawBlock.java | 40 +- .../components/saw/SawFilterSlot.java | 6 +- .../components/saw/SawGenerator.java | 8 +- .../components/saw/SawInstance.java | 6 +- .../components/saw/SawRenderer.java | 44 +- .../components/saw/SawTileEntity.java | 100 +- .../AbstractContraptionEntity.java | 180 +-- .../structureMovement/AssemblyException.java | 6 +- .../BlockMovementChecks.java | 82 +- .../structureMovement/Contraption.java | 224 +-- .../ContraptionCollider.java | 186 +-- .../ContraptionEntityRenderer.java | 2 +- .../structureMovement/ContraptionHandler.java | 8 +- .../ContraptionHandlerClient.java | 24 +- .../structureMovement/ContraptionLighter.java | 4 +- .../structureMovement/ContraptionWorld.java | 6 +- .../ControlledContraptionEntity.java | 28 +- .../DirectionalExtenderScrollOptionSlot.java | 4 +- .../IDisplayAssemblyExceptions.java | 4 +- .../MountedFluidStorage.java | 2 +- .../structureMovement/MountedStorage.java | 22 +- .../structureMovement/MovementBehaviour.java | 6 +- .../structureMovement/MovementContext.java | 2 +- .../NonStationaryLighter.java | 4 +- .../OrientedContraptionEntity.java | 144 +- .../OrientedContraptionEntityRenderer.java | 2 +- .../structureMovement/StructureTransform.java | 106 +- .../TranslatingContraption.java | 2 +- .../bearing/BearingBlock.java | 10 +- .../bearing/BearingContraption.java | 8 +- .../bearing/BearingInstance.java | 14 +- .../bearing/BearingRenderer.java | 8 +- .../bearing/ClockworkBearingBlock.java | 16 +- .../bearing/ClockworkBearingTileEntity.java | 82 +- .../bearing/ClockworkContraption.java | 14 +- .../bearing/IBearingTileEntity.java | 2 +- .../bearing/MechanicalBearingBlock.java | 12 +- .../bearing/MechanicalBearingTileEntity.java | 64 +- .../structureMovement/bearing/SailBlock.java | 56 +- .../bearing/StabilizedBearingInstance.java | 8 +- .../StabilizedBearingMovementBehaviour.java | 14 +- .../bearing/StabilizedContraption.java | 6 +- .../bearing/WindmillBearingBlock.java | 12 +- .../bearing/WindmillBearingTileEntity.java | 2 +- .../chassis/AbstractChassisBlock.java | 50 +- .../chassis/ChassisRangeDisplay.java | 26 +- .../chassis/ChassisTileEntity.java | 58 +- .../chassis/LinearChassisBlock.java | 50 +- .../chassis/RadialChassisBlock.java | 12 +- .../chassis/StickerBlock.java | 80 +- .../chassis/StickerInstance.java | 8 +- .../chassis/StickerRenderer.java | 12 +- .../chassis/StickerTileEntity.java | 16 +- .../gantry/GantryCarriageBlock.java | 50 +- .../gantry/GantryCarriageInstance.java | 14 +- .../gantry/GantryCarriageRenderer.java | 18 +- .../gantry/GantryCarriageTileEntity.java | 46 +- .../gantry/GantryContraption.java | 6 +- .../gantry/GantryContraptionEntity.java | 54 +- .../glue/GlueEffectPacket.java | 8 +- .../structureMovement/glue/GlueInstance.java | 20 +- .../glue/SuperGlueEntity.java | 164 +-- .../glue/SuperGlueHandler.java | 34 +- .../structureMovement/glue/SuperGlueItem.java | 32 +- .../glue/SuperGlueRenderer.java | 36 +- .../mounted/CartAssembleRailType.java | 2 +- .../mounted/CartAssemblerBlock.java | 112 +- .../mounted/CartAssemblerBlockItem.java | 34 +- .../mounted/CartAssemblerTileEntity.java | 66 +- .../ItemHandlerModifiableFromIInventory.java | 10 +- .../mounted/MinecartContraptionItem.java | 92 +- .../mounted/MountedContraption.java | 16 +- .../piston/LinearActuatorTileEntity.java | 36 +- .../piston/MechanicalPistonBlock.java | 90 +- .../piston/MechanicalPistonGenerator.java | 12 +- .../piston/MechanicalPistonHeadBlock.java | 44 +- .../piston/MechanicalPistonTileEntity.java | 50 +- .../piston/PistonContraption.java | 64 +- .../piston/PistonExtensionPoleBlock.java | 70 +- .../piston/PistonLighter.java | 2 +- .../pulley/AbstractPulleyInstance.java | 14 +- .../pulley/AbstractPulleyRenderer.java | 18 +- .../structureMovement/pulley/PulleyBlock.java | 64 +- .../pulley/PulleyLighter.java | 4 +- .../pulley/PulleyRenderer.java | 4 +- .../pulley/PulleyTileEntity.java | 84 +- .../render/ActorInstance.java | 2 +- .../render/ContraptionMatrices.java | 30 +- .../render/ContraptionRenderDispatcher.java | 58 +- .../render/ContraptionWorldHolder.java | 2 +- .../render/RenderedContraption.java | 24 +- .../sync/ClientMotionPacket.java | 8 +- .../sync/ContraptionFluidPacket.java | 2 +- .../sync/ContraptionInteractionPacket.java | 14 +- .../sync/ContraptionSeatMappingPacket.java | 6 +- .../sync/LimbSwingUpdatePacket.java | 8 +- .../train/CouplingCreationPacket.java | 6 +- .../train/CouplingHandler.java | 16 +- .../train/CouplingHandlerClient.java | 8 +- .../train/CouplingPhysics.java | 32 +- .../train/CouplingRenderer.java | 66 +- .../train/MinecartCouplingItem.java | 10 +- .../train/MinecartSim2020.java | 56 +- .../CapabilityMinecartController.java | 26 +- .../train/capability/MinecartController.java | 56 +- .../MinecartControllerUpdatePacket.java | 10 +- .../tracks/ControllerRailBlock.java | 116 +- .../tracks/ControllerRailGenerator.java | 4 +- .../tracks/ReinforcedRailBlock.java | 46 +- .../components/turntable/TurntableBlock.java | 38 +- .../turntable/TurntableHandler.java | 14 +- .../waterwheel/WaterWheelBlock.java | 72 +- .../waterwheel/WaterWheelTileEntity.java | 10 +- .../contraptions/fluids/FlowSource.java | 2 +- .../fluids/FluidBottleItemHook.java | 10 +- .../content/contraptions/fluids/FluidFX.java | 16 +- .../contraptions/fluids/FluidPropagator.java | 32 +- .../contraptions/fluids/FluidReactions.java | 28 +- .../fluids/FluidTransportBehaviour.java | 12 +- .../contraptions/fluids/OpenEndedPipe.java | 68 +- .../fluids/PipeAttachmentModel.java | 10 +- .../contraptions/fluids/PipeConnection.java | 22 +- .../contraptions/fluids/PumpBlock.java | 64 +- .../contraptions/fluids/PumpCogInstance.java | 2 +- .../contraptions/fluids/PumpRenderer.java | 8 +- .../contraptions/fluids/PumpTileEntity.java | 50 +- .../contraptions/fluids/VirtualFluid.java | 16 +- .../fluids/actors/FillingBySpout.java | 10 +- .../fluids/actors/FillingRecipe.java | 2 +- .../fluids/actors/FluidDrainingBehaviour.java | 42 +- .../fluids/actors/FluidFillingBehaviour.java | 78 +- .../actors/FluidManipulationBehaviour.java | 32 +- .../fluids/actors/FluidSplashPacket.java | 2 +- .../fluids/actors/GenericItemFilling.java | 10 +- .../fluids/actors/HosePulleyBlock.java | 38 +- .../fluids/actors/HosePulleyFluidHandler.java | 2 + .../fluids/actors/HosePulleyRenderer.java | 4 +- .../fluids/actors/HosePulleyTileEntity.java | 24 +- .../fluids/actors/ItemDrainBlock.java | 22 +- .../fluids/actors/ItemDrainItemHandler.java | 2 +- .../fluids/actors/ItemDrainRenderer.java | 36 +- .../fluids/actors/ItemDrainTileEntity.java | 48 +- .../fluids/actors/SpoutBlock.java | 8 +- .../fluids/actors/SpoutRenderer.java | 12 +- .../fluids/actors/SpoutTileEntity.java | 40 +- .../fluids/particle/BasinFluidParticle.java | 52 +- .../fluids/particle/FluidParticleData.java | 10 +- .../fluids/particle/FluidStackParticle.java | 60 +- .../fluids/pipes/AxisPipeBlock.java | 48 +- .../fluids/pipes/BracketBlock.java | 16 +- .../fluids/pipes/BracketBlockItem.java | 22 +- .../fluids/pipes/BracketGenerator.java | 6 +- .../fluids/pipes/EncasedPipeBlock.java | 56 +- .../fluids/pipes/FluidPipeBlock.java | 104 +- .../fluids/pipes/FluidPipeTileEntity.java | 6 +- .../fluids/pipes/FluidValveBlock.java | 36 +- .../fluids/pipes/FluidValveInstance.java | 2 +- .../fluids/pipes/FluidValveRenderer.java | 6 +- .../fluids/pipes/FluidValveTileEntity.java | 10 +- .../fluids/pipes/GlassFluidPipeBlock.java | 30 +- .../fluids/pipes/SmartFluidPipeBlock.java | 52 +- .../fluids/pipes/SmartFluidPipeGenerator.java | 6 +- .../pipes/SmartFluidPipeTileEntity.java | 12 +- .../fluids/pipes/StraightPipeTileEntity.java | 6 +- .../TransparentStraightPipeRenderer.java | 4 +- .../fluids/potion/PotionFluid.java | 15 +- .../fluids/potion/PotionFluidHandler.java | 44 +- .../recipe/PotionMixingRecipeManager.java | 14 +- .../tank/CreativeFluidTankTileEntity.java | 2 + .../fluids/tank/FluidTankBlock.java | 78 +- .../tank/FluidTankConnectivityHandler.java | 54 +- .../fluids/tank/FluidTankGenerator.java | 8 +- .../fluids/tank/FluidTankItem.java | 42 +- .../fluids/tank/FluidTankModel.java | 6 +- .../fluids/tank/FluidTankRenderer.java | 6 +- .../fluids/tank/FluidTankTileEntity.java | 78 +- .../goggles/GoggleConfigScreen.java | 34 +- .../goggles/GoggleOverlayRenderer.java | 36 +- .../contraptions/goggles/GogglesItem.java | 16 +- .../goggles/IHaveGoggleInformation.java | 22 +- .../itemAssembly/SequencedAssemblyItem.java | 6 +- .../itemAssembly/SequencedAssemblyRecipe.java | 28 +- .../SequencedAssemblyRecipeBuilder.java | 14 +- .../SequencedAssemblyRecipeSerializer.java | 24 +- .../itemAssembly/SequencedRecipe.java | 8 +- .../particle/AirFlowParticle.java | 120 +- .../particle/AirFlowParticleData.java | 10 +- .../contraptions/particle/AirParticle.java | 54 +- .../particle/AirParticleData.java | 10 +- .../contraptions/particle/CubeParticle.java | 54 +- .../particle/CubeParticleData.java | 10 +- .../contraptions/particle/HeaterParticle.java | 68 +- .../particle/HeaterParticleData.java | 10 +- .../particle/ICustomParticleData.java | 4 +- .../ICustomParticleDataWithSprite.java | 4 +- .../particle/RotationIndicatorParticle.java | 38 +- .../RotationIndicatorParticleData.java | 10 +- .../contraptions/processing/BasinBlock.java | 58 +- .../processing/BasinGenerator.java | 4 +- .../processing/BasinMovementBehaviour.java | 8 +- .../processing/BasinOperatingTileEntity.java | 12 +- .../contraptions/processing/BasinRecipe.java | 16 +- .../processing/BasinRenderer.java | 32 +- .../processing/BasinTileEntity.java | 98 +- .../processing/EmptyingByBasin.java | 4 +- .../processing/EmptyingRecipe.java | 2 +- .../processing/InWorldProcessing.java | 64 +- .../processing/ProcessingOutput.java | 16 +- .../processing/ProcessingRecipe.java | 10 +- .../processing/ProcessingRecipeBuilder.java | 22 +- .../ProcessingRecipeSerializer.java | 28 +- .../processing/burner/BlazeBurnerBlock.java | 100 +- .../burner/BlazeBurnerBlockItem.java | 64 +- .../processing/burner/BlazeBurnerHandler.java | 32 +- .../burner/BlazeBurnerRenderer.java | 4 +- .../burner/BlazeBurnerTileEntity.java | 24 +- .../burner/LitBlazeBurnerBlock.java | 50 +- .../relays/advanced/GantryShaftBlock.java | 118 +- .../advanced/GantryShaftTileEntity.java | 32 +- .../relays/advanced/SpeedControllerBlock.java | 24 +- .../advanced/SpeedControllerRenderer.java | 12 +- .../advanced/SpeedControllerTileEntity.java | 12 +- .../ConfigureSequencedGearshiftPacket.java | 4 +- .../sequencer/SequencedGearshiftBlock.java | 48 +- .../SequencedGearshiftGenerator.java | 6 +- .../sequencer/SequencedGearshiftScreen.java | 10 +- .../SequencedGearshiftTileEntity.java | 12 +- .../contraptions/relays/belt/BeltBlock.java | 160 ++- .../contraptions/relays/belt/BeltData.java | 20 +- .../relays/belt/BeltGenerator.java | 22 +- .../contraptions/relays/belt/BeltHelper.java | 24 +- .../relays/belt/BeltInstance.java | 16 +- .../contraptions/relays/belt/BeltModel.java | 6 +- .../contraptions/relays/belt/BeltPart.java | 2 +- .../relays/belt/BeltRenderer.java | 66 +- .../contraptions/relays/belt/BeltShapes.java | 62 +- .../contraptions/relays/belt/BeltSlope.java | 2 +- .../relays/belt/BeltTileEntity.java | 120 +- .../belt/item/BeltConnectorHandler.java | 28 +- .../relays/belt/item/BeltConnectorItem.java | 84 +- .../BeltCrusherInteractionHandler.java | 8 +- .../BeltFunnelInteractionHandler.java | 14 +- .../relays/belt/transport/BeltInventory.java | 38 +- .../belt/transport/BeltMovementHandler.java | 70 +- .../BeltTunnelInteractionHandler.java | 34 +- .../transport/ItemHandlerBeltSegment.java | 4 +- .../belt/transport/TransportedItemStack.java | 6 +- .../relays/elementary/AbstractShaftBlock.java | 44 +- .../BracketedKineticBlockModel.java | 4 +- .../BracketedTileEntityBehaviour.java | 10 +- .../relays/elementary/CogWheelBlock.java | 34 +- .../relays/elementary/CogwheelBlockItem.java | 104 +- .../relays/elementary/ShaftBlock.java | 18 +- .../elementary/SimpleKineticTileEntity.java | 8 +- .../encased/AbstractEncasedShaftBlock.java | 18 +- .../relays/encased/AdjustablePulleyBlock.java | 26 +- .../encased/AdjustablePulleyTileEntity.java | 8 +- .../relays/encased/ClutchBlock.java | 10 +- .../relays/encased/ClutchTileEntity.java | 2 +- .../DirectionalShaftHalvesTileEntity.java | 4 +- .../relays/encased/EncasedBeltBlock.java | 80 +- .../relays/encased/EncasedBeltGenerator.java | 16 +- .../relays/encased/EncasedShaftBlock.java | 8 +- .../relays/encased/GearshiftBlock.java | 28 +- .../relays/encased/SplitShaftRenderer.java | 8 +- .../contraptions/relays/gauge/GaugeBlock.java | 58 +- .../relays/gauge/GaugeInstance.java | 12 +- .../relays/gauge/GaugeRenderer.java | 10 +- .../relays/gauge/GaugeTileEntity.java | 6 +- .../relays/gauge/SpeedGaugeTileEntity.java | 8 +- .../relays/gauge/StressGaugeTileEntity.java | 24 +- .../relays/gearbox/GearboxBlock.java | 18 +- .../relays/gearbox/GearboxInstance.java | 10 +- .../relays/gearbox/GearboxRenderer.java | 14 +- .../relays/gearbox/GearshiftTileEntity.java | 2 +- .../relays/gearbox/VerticalGearboxItem.java | 22 +- .../contraptions/wrench/IWrenchable.java | 60 +- .../wrench/IWrenchableWithBracket.java | 12 +- .../contraptions/wrench/WrenchItem.java | 28 +- .../wrench/WrenchItemRenderer.java | 2 +- .../content/curiosities/BuildersTeaItem.java | 26 +- .../curiosities/ChromaticCompoundColor.java | 2 +- .../curiosities/ChromaticCompoundItem.java | 36 +- .../content/curiosities/CombustibleItem.java | 2 + .../curiosities/NoGravMagicalDohickyItem.java | 14 +- .../curiosities/RefinedRadianceItem.java | 6 +- .../content/curiosities/ShadowSteelItem.java | 6 +- .../curiosities/TreeFertilizerItem.java | 54 +- .../curiosities/armor/AllArmorMaterials.java | 14 +- .../curiosities/armor/BackTankUtil.java | 8 +- .../armor/CapacityEnchantment.java | 2 + .../curiosities/armor/CopperArmorItem.java | 6 +- .../armor/CopperBacktankArmorLayer.java | 32 +- .../armor/CopperBacktankBlock.java | 68 +- .../curiosities/armor/CopperBacktankItem.java | 12 +- .../armor/CopperBacktankRenderer.java | 6 +- .../armor/CopperBacktankTileEntity.java | 20 +- .../curiosities/armor/DivingBootsItem.java | 18 +- .../curiosities/armor/DivingHelmetItem.java | 18 +- .../curiosities/bell/AbstractBellBlock.java | 28 +- .../curiosities/bell/BasicParticleData.java | 10 +- .../curiosities/bell/BellRenderer.java | 10 +- .../bell/CustomRotationParticle.java | 40 +- .../curiosities/bell/HauntedBellBlock.java | 4 +- .../bell/HauntedBellMovementBehaviour.java | 2 +- .../curiosities/bell/HauntedBellPulser.java | 6 +- .../bell/HauntedBellTileEntity.java | 16 +- .../curiosities/bell/PeculiarBellBlock.java | 24 +- .../curiosities/bell/SoulBaseParticle.java | 20 +- .../curiosities/bell/SoulParticle.java | 36 +- .../curiosities/bell/SoulPulseEffect.java | 18 +- .../symmetry/SymmetryEffectPacket.java | 2 +- .../curiosities/symmetry/SymmetryHandler.java | 70 +- .../symmetry/SymmetryWandItem.java | 94 +- .../symmetry/SymmetryWandScreen.java | 18 +- .../client/SymmetryWandItemRenderer.java | 2 +- .../symmetry/mirror/CrossPlaneMirror.java | 2 +- .../symmetry/mirror/EmptyMirror.java | 2 +- .../symmetry/mirror/PlaneMirror.java | 2 +- .../symmetry/mirror/SymmetryMirror.java | 14 +- .../BlueprintAssignCompleteRecipePacket.java | 8 +- .../curiosities/tools/BlueprintContainer.java | 28 +- .../curiosities/tools/BlueprintEntity.java | 213 +-- .../curiosities/tools/BlueprintItem.java | 40 +- .../tools/BlueprintOverlayRenderer.java | 38 +- .../curiosities/tools/BlueprintRenderer.java | 72 +- .../curiosities/tools/BlueprintScreen.java | 50 +- .../tools/ExtendoGripInteractionPacket.java | 12 +- .../curiosities/tools/ExtendoGripItem.java | 66 +- .../tools/ExtendoGripItemRenderer.java | 16 +- .../tools/ExtendoGripRenderHandler.java | 34 +- .../curiosities/tools/SandPaperItem.java | 58 +- .../tools/SandPaperItemRenderer.java | 30 +- .../tools/SandPaperPolishingRecipe.java | 6 +- .../curiosities/weapons/PotatoCannonItem.java | 82 +- .../weapons/PotatoCannonItemRenderer.java | 14 +- .../weapons/PotatoCannonPacket.java | 4 +- .../weapons/PotatoCannonProjectileTypes.java | 72 +- .../weapons/PotatoCannonRenderHandler.java | 4 +- .../weapons/PotatoProjectileEntity.java | 118 +- .../weapons/PotatoProjectileRenderMode.java | 10 +- .../weapons/PotatoProjectileRenderer.java | 10 +- .../weapons/PotatoRecoveryEnchantment.java | 2 + .../weapons/ProperProjectileEntity.java | 8 +- .../curiosities/zapper/ShootGadgetPacket.java | 4 +- .../zapper/ShootableGadgetItemMethods.java | 24 +- .../zapper/ShootableGadgetRenderHandler.java | 42 +- .../zapper/ZapperInteractionHandler.java | 46 +- .../curiosities/zapper/ZapperItem.java | 66 +- .../zapper/ZapperItemRenderer.java | 12 +- .../content/curiosities/zapper/ZapperLog.java | 2 +- .../zapper/ZapperRenderHandler.java | 6 +- .../curiosities/zapper/ZapperScreen.java | 14 +- .../zapper/terrainzapper/CuboidBrush.java | 8 +- .../zapper/terrainzapper/CylinderBrush.java | 6 +- .../zapper/terrainzapper/DynamicBrush.java | 18 +- .../zapper/terrainzapper/FlattenTool.java | 24 +- .../zapper/terrainzapper/ShapedBrush.java | 2 +- .../zapper/terrainzapper/SphereBrush.java | 4 +- .../zapper/terrainzapper/TerrainTools.java | 12 +- .../zapper/terrainzapper/WorldshaperItem.java | 10 +- .../WorldshaperItemRenderer.java | 8 +- .../WorldshaperRenderHandler.java | 18 +- .../terrainzapper/WorldshaperScreen.java | 14 +- .../logistics/RedstoneLinkNetworkHandler.java | 4 +- .../content/logistics/block/FlapData.java | 2 +- .../block/belts/tunnel/BeltTunnelBlock.java | 108 +- .../belts/tunnel/BeltTunnelInstance.java | 6 +- .../block/belts/tunnel/BeltTunnelItem.java | 20 +- .../belts/tunnel/BeltTunnelRenderer.java | 12 +- .../block/belts/tunnel/BeltTunnelShapes.java | 19 +- .../belts/tunnel/BeltTunnelTileEntity.java | 30 +- .../block/belts/tunnel/BrassTunnelBlock.java | 18 +- .../belts/tunnel/BrassTunnelCTBehaviour.java | 4 +- .../belts/tunnel/BrassTunnelTileEntity.java | 108 +- .../block/chute/AbstractChuteBlock.java | 50 +- .../logistics/block/chute/ChuteBlock.java | 78 +- .../logistics/block/chute/ChuteGenerator.java | 6 +- .../logistics/block/chute/ChuteItem.java | 32 +- .../logistics/block/chute/ChuteRenderer.java | 10 +- .../logistics/block/chute/ChuteShapes.java | 20 +- .../block/chute/ChuteTileEntity.java | 176 +-- .../block/chute/SmartChuteBlock.java | 30 +- .../block/chute/SmartChuteTileEntity.java | 6 +- .../logistics/block/depot/DepotBehaviour.java | 22 +- .../logistics/block/depot/DepotBlock.java | 16 +- .../logistics/block/depot/DepotRenderer.java | 38 +- .../logistics/block/depot/EjectorBlock.java | 44 +- .../block/depot/EjectorElytraPacket.java | 6 +- .../block/depot/EjectorInstance.java | 2 +- .../logistics/block/depot/EjectorItem.java | 22 +- .../block/depot/EjectorPlacementPacket.java | 12 +- .../block/depot/EjectorRenderer.java | 22 +- .../block/depot/EjectorTargetHandler.java | 58 +- .../block/depot/EjectorTileEntity.java | 116 +- .../logistics/block/depot/EntityLauncher.java | 4 +- .../block/depot/SharedDepotBlockMethods.java | 22 +- .../block/diodes/AbstractDiodeBlock.java | 4 +- .../block/diodes/AbstractDiodeGenerator.java | 2 +- .../AdjustablePulseRepeaterTileEntity.java | 10 +- .../block/diodes/AdjustableRepeaterBlock.java | 22 +- .../diodes/AdjustableRepeaterGenerator.java | 2 +- .../diodes/AdjustableRepeaterScrollSlot.java | 2 +- .../diodes/AdjustableRepeaterTileEntity.java | 12 +- .../block/diodes/PoweredLatchBlock.java | 62 +- .../block/diodes/PoweredLatchGenerator.java | 2 +- .../block/diodes/PulseRepeaterBlock.java | 32 +- .../block/diodes/PulseRepeaterGenerator.java | 2 +- .../block/diodes/ToggleLatchBlock.java | 42 +- .../block/diodes/ToggleLatchGenerator.java | 2 +- .../AbstractDirectionalFunnelBlock.java | 12 +- .../block/funnel/AbstractFunnelBlock.java | 40 +- .../funnel/AbstractHorizontalFunnelBlock.java | 12 +- .../block/funnel/AndesiteFunnelBlock.java | 6 +- .../block/funnel/BeltFunnelBlock.java | 78 +- .../block/funnel/BeltFunnelGenerator.java | 8 +- .../block/funnel/BrassFunnelBlock.java | 6 +- .../logistics/block/funnel/FunnelBlock.java | 56 +- .../funnel/FunnelFilterSlotPositioning.java | 8 +- .../block/funnel/FunnelGenerator.java | 12 +- .../block/funnel/FunnelInstance.java | 6 +- .../logistics/block/funnel/FunnelItem.java | 16 +- .../block/funnel/FunnelMovementBehaviour.java | 24 +- .../block/funnel/FunnelRenderer.java | 12 +- .../block/funnel/FunnelTileEntity.java | 56 +- .../inventories/AdjustableCrateBlock.java | 38 +- .../inventories/AdjustableCrateContainer.java | 20 +- .../inventories/AdjustableCrateScreen.java | 42 +- .../AdjustableCrateTileEntity.java | 14 +- .../block/inventories/CrateBlock.java | 54 +- .../block/inventories/CrateTileEntity.java | 6 +- .../block/inventories/CreativeCrateBlock.java | 4 +- .../inventories/CreativeCrateTileEntity.java | 10 +- .../block/mechanicalArm/ArmAngleTarget.java | 12 +- .../block/mechanicalArm/ArmBlock.java | 28 +- .../block/mechanicalArm/ArmInstance.java | 18 +- .../mechanicalArm/ArmInteractionPoint.java | 62 +- .../ArmInteractionPointHandler.java | 36 +- .../block/mechanicalArm/ArmItem.java | 18 +- .../mechanicalArm/ArmPlacementPacket.java | 10 +- .../block/mechanicalArm/ArmRenderer.java | 24 +- .../block/mechanicalArm/ArmTileEntity.java | 84 +- .../block/redstone/AnalogLeverBlock.java | 48 +- .../block/redstone/AnalogLeverInstance.java | 4 +- .../block/redstone/AnalogLeverRenderer.java | 10 +- .../block/redstone/AnalogLeverTileEntity.java | 6 +- .../redstone/ContactMovementBehaviour.java | 14 +- .../block/redstone/ContentObserverBlock.java | 50 +- .../redstone/ContentObserverTileEntity.java | 16 +- .../redstone/FilteredDetectorFilterSlot.java | 2 +- .../block/redstone/NixieTubeBlock.java | 76 +- .../block/redstone/NixieTubeGenerator.java | 4 +- .../block/redstone/NixieTubeRenderer.java | 48 +- .../block/redstone/NixieTubeTileEntity.java | 12 +- .../block/redstone/RedstoneContactBlock.java | 58 +- .../block/redstone/RedstoneLinkBlock.java | 82 +- .../redstone/RedstoneLinkFrequencySlot.java | 4 +- .../block/redstone/RedstoneLinkGenerator.java | 10 +- .../redstone/RedstoneLinkTileEntity.java | 18 +- .../block/redstone/StockpileSwitchBlock.java | 46 +- .../block/redstone/StockpileSwitchScreen.java | 18 +- .../redstone/StockpileSwitchTileEntity.java | 22 +- .../logistics/item/CardboardBoxItem.java | 26 +- .../item/LecternControllerBlock.java | 38 +- .../item/LecternControllerRenderer.java | 8 +- .../item/LecternControllerTileEntity.java | 56 +- .../item/LinkedControllerBindPacket.java | 2 +- .../item/LinkedControllerClientHandler.java | 66 +- .../item/LinkedControllerContainer.java | 34 +- .../item/LinkedControllerInputPacket.java | 6 +- .../logistics/item/LinkedControllerItem.java | 50 +- .../item/LinkedControllerItemRenderer.java | 22 +- .../item/LinkedControllerPacketBase.java | 6 +- .../item/LinkedControllerScreen.java | 44 +- .../item/filter/AbstractFilterContainer.java | 12 +- .../item/filter/AbstractFilterScreen.java | 26 +- .../item/filter/AttributeFilterContainer.java | 26 +- .../item/filter/AttributeFilterScreen.java | 92 +- .../logistics/item/filter/FilterItem.java | 38 +- .../logistics/item/filter/FilterScreen.java | 30 +- .../item/filter/FilterScreenPacket.java | 14 +- .../logistics/item/filter/ItemAttribute.java | 24 +- .../item/filter/attribute/ColorAttribute.java | 4 +- .../filter/attribute/EnchantAttribute.java | 4 +- .../attribute/FluidContentsAttribute.java | 2 +- .../filter/attribute/ItemNameAttribute.java | 2 +- .../attribute/ShulkerFillLevelAttribute.java | 4 +- .../AstralSorceryAmuletAttribute.java | 4 +- .../logistics/packet/FunnelFlapPacket.java | 2 +- .../logistics/packet/TunnelFlapPacket.java | 6 +- .../content/palettes/AllPaletteBlocks.java | 16 +- .../content/palettes/ConnectedGlassBlock.java | 6 +- .../palettes/ConnectedGlassPaneBlock.java | 6 +- .../content/palettes/GlassPaneBlock.java | 2 + .../content/palettes/PaletteBlockPartial.java | 8 +- .../content/palettes/PaletteBlockPattern.java | 30 +- .../content/palettes/PalettesItemGroup.java | 2 +- .../palettes/PalettesVariantEntry.java | 2 +- .../create/content/palettes/PavedBlock.java | 16 +- .../palettes/StandardFoliageColorHandler.java | 2 +- .../create/content/palettes/WindowBlock.java | 8 +- .../schematics/ClientSchematicLoader.java | 8 +- .../content/schematics/ItemRequirement.java | 16 +- .../content/schematics/MaterialChecklist.java | 26 +- .../content/schematics/SchematicPrinter.java | 60 +- .../schematics/SchematicProcessor.java | 4 +- .../content/schematics/SchematicWorld.java | 60 +- .../schematics/ServerSchematicLoader.java | 18 +- .../schematics/block/LaunchedItem.java | 18 +- .../schematics/block/SchematicTableBlock.java | 24 +- .../block/SchematicTableContainer.java | 26 +- .../block/SchematicTableScreen.java | 46 +- .../block/SchematicTableTileEntity.java | 20 +- .../schematics/block/SchematicannonBlock.java | 12 +- .../block/SchematicannonContainer.java | 26 +- .../block/SchematicannonInstance.java | 4 +- .../block/SchematicannonInventory.java | 6 +- .../block/SchematicannonRenderer.java | 52 +- .../block/SchematicannonScreen.java | 70 +- .../block/SchematicannonTileEntity.java | 89 +- .../client/SchematicAndQuillHandler.java | 60 +- .../client/SchematicEditScreen.java | 44 +- .../schematics/client/SchematicHandler.java | 36 +- .../client/SchematicHotbarSlotOverlay.java | 8 +- .../client/SchematicPromptScreen.java | 16 +- .../schematics/client/SchematicRenderer.java | 28 +- .../client/SchematicTransformation.java | 12 +- .../schematics/client/tools/DeployTool.java | 10 +- .../schematics/client/tools/FlipTool.java | 16 +- .../schematics/client/tools/MoveTool.java | 4 +- .../schematics/client/tools/RotateTool.java | 2 +- .../client/tools/SchematicToolBase.java | 22 +- .../filtering/SchematicInstances.java | 2 +- .../item/SchematicAndQuillItem.java | 2 + .../schematics/item/SchematicItem.java | 28 +- .../packet/ConfigureSchematicannonPacket.java | 8 +- .../packet/InstantSchematicPacket.java | 6 +- .../packet/SchematicPlacePacket.java | 12 +- .../packet/SchematicSyncPacket.java | 12 +- .../packet/SchematicUploadPacket.java | 8 +- .../simibubi/create/events/ClientEvents.java | 44 +- .../simibubi/create/events/CommonEvents.java | 10 +- .../simibubi/create/events/InputEvents.java | 8 +- .../create/foundation/BreakProgressHook.java | 4 +- .../advancement/AllAdvancements.java | 470 +++--- .../foundation/advancement/AllTriggers.java | 4 +- .../advancement/CriterionTriggerBase.java | 12 +- .../foundation/advancement/SimpleTrigger.java | 4 +- .../StringSerializableTrigger.java | 8 +- .../simibubi/create/foundation/block/ITE.java | 2 +- .../foundation/block/ItemUseOverrides.java | 4 +- .../block/ProperDirectionalBlock.java | 16 +- .../foundation/block/connected/CTModel.java | 12 +- .../block/connected/CTSpriteShiftEntry.java | 4 +- .../connected/ConnectedTextureBehaviour.java | 10 +- .../block/render/ColoredVertexModel.java | 2 +- .../foundation/block/render/QuadHelper.java | 4 +- .../block/render/SpriteShiftEntry.java | 2 +- .../collision/ContinuousOBBCollider.java | 12 +- .../foundation/collision/OrientedBB.java | 6 +- .../foundation/command/AllCommands.java | 2 +- .../create/foundation/command/ChunkUtil.java | 28 +- .../foundation/command/ChunkUtilCommand.java | 30 +- .../command/ClearBufferCacheCommand.java | 4 +- .../foundation/command/CloneCommand.java | 64 +- .../foundation/command/ConfigCommand.java | 16 +- .../command/ConfigureConfigCommand.java | 8 +- .../foundation/command/CouplingCommand.java | 32 +- .../command/FabulousWarningCommand.java | 2 +- .../command/FixLightingCommand.java | 4 +- .../foundation/command/FlySpeedCommand.java | 12 +- .../foundation/command/GlueCommand.java | 8 +- .../foundation/command/HighlightCommand.java | 24 +- .../foundation/command/HighlightPacket.java | 12 +- .../foundation/command/KillTPSCommand.java | 24 +- .../command/OverlayConfigCommand.java | 6 +- .../foundation/command/PonderCommand.java | 14 +- .../ReplaceInCommandBlocksCommand.java | 18 +- .../command/SConfigureConfigPacket.java | 36 +- .../create/foundation/config/CClient.java | 6 + .../foundation/config/CCuriosities.java | 2 + .../create/foundation/config/CFluids.java | 2 + .../create/foundation/config/CKinetics.java | 6 + .../create/foundation/config/CLogistics.java | 2 + .../create/foundation/config/CRecipes.java | 3 + .../create/foundation/config/CSchematics.java | 4 + .../create/foundation/config/CServer.java | 3 + .../create/foundation/config/CWorldGen.java | 2 + .../config/ui/BaseConfigScreen.java | 12 +- .../config/ui/CConfigureConfigPacket.java | 14 +- .../foundation/config/ui/ConfigScreen.java | 34 +- .../config/ui/ConfigScreenList.java | 38 +- .../foundation/config/ui/ConfigTextField.java | 6 +- .../config/ui/OpenCreateMenuButton.java | 8 +- .../config/ui/SubMenuConfigScreen.java | 20 +- .../config/ui/entries/EnumEntry.java | 2 +- .../config/ui/entries/NumberEntry.java | 20 +- .../config/ui/entries/ValueEntry.java | 8 +- .../create/foundation/data/AssetLookup.java | 6 +- .../create/foundation/data/BlockStateGen.java | 70 +- .../foundation/data/BuilderTransformers.java | 42 +- .../data/DirectionalAxisBlockStateGen.java | 10 +- .../create/foundation/data/LangMerger.java | 8 +- .../create/foundation/data/NamedTag.java | 6 +- .../foundation/data/SharedProperties.java | 2 +- .../foundation/data/SpecialBlockStateGen.java | 2 +- .../create/foundation/data/WindowGen.java | 52 +- .../data/recipe/CompactingRecipeGen.java | 2 + .../data/recipe/CreateRecipeProvider.java | 2 +- .../data/recipe/CrushingRecipeGen.java | 3 + .../data/recipe/CuttingRecipeGen.java | 3 + .../data/recipe/EmptyingRecipeGen.java | 2 + .../data/recipe/FillingRecipeGen.java | 2 + .../MechanicalCraftingRecipeBuilder.java | 16 +- .../recipe/MechanicalCraftingRecipeGen.java | 21 +- .../data/recipe/MillingRecipeGen.java | 2 + .../data/recipe/MixingRecipeGen.java | 3 + .../data/recipe/PolishingRecipeGen.java | 2 + .../data/recipe/PressingRecipeGen.java | 5 +- .../data/recipe/ProcessingRecipeGen.java | 8 +- .../recipe/SequencedAssemblyRecipeGen.java | 3 + .../data/recipe/StandardRecipeGen.java | 1268 +++++++++-------- .../data/recipe/WashingRecipeGen.java | 4 +- .../foundation/fluid/CombinedTankWrapper.java | 2 + .../create/foundation/fluid/FluidHelper.java | 26 +- .../foundation/fluid/FluidIngredient.java | 26 +- .../foundation/fluid/FluidRenderer.java | 48 +- .../gui/AbstractSimiContainerScreen.java | 50 +- .../foundation/gui/AbstractSimiScreen.java | 12 +- .../create/foundation/gui/AllGuiTextures.java | 4 +- .../create/foundation/gui/AllIcons.java | 14 +- .../create/foundation/gui/BoxElement.java | 8 +- .../foundation/gui/ClearContainerPacket.java | 4 +- .../gui/CombinedStencilElement.java | 8 +- .../foundation/gui/ConfirmationScreen.java | 46 +- .../gui/CustomLightingSettings.java | 14 +- .../foundation/gui/GhostItemContainer.java | 34 +- .../foundation/gui/GhostItemSubmitPacket.java | 10 +- .../create/foundation/gui/GuiGameElement.java | 82 +- .../foundation/gui/ILightingSettings.java | 4 +- .../create/foundation/gui/ScreenOpener.java | 8 +- .../create/foundation/gui/StencilElement.java | 6 +- .../foundation/gui/TextStencilElement.java | 14 +- .../foundation/gui/ToolSelectionScreen.java | 40 +- .../create/foundation/gui/UIRenderHelper.java | 78 +- .../gui/mainMenu/CreateMainMenuScreen.java | 48 +- .../gui/widgets/AbstractSimiWidget.java | 6 +- .../foundation/gui/widgets/BoxWidget.java | 8 +- .../foundation/gui/widgets/ElementWidget.java | 4 +- .../foundation/gui/widgets/IconButton.java | 6 +- .../create/foundation/gui/widgets/Label.java | 16 +- .../foundation/gui/widgets/ScrollInput.java | 8 +- .../gui/widgets/SelectionScrollInput.java | 12 +- .../foundation/item/CreateItemGroupBase.java | 10 +- .../foundation/item/HiddenIngredientItem.java | 8 +- .../foundation/item/ItemDescription.java | 40 +- .../create/foundation/item/ItemHelper.java | 14 +- .../foundation/item/SmartInventory.java | 6 +- .../item/TagDependentIngredientItem.java | 12 +- .../create/foundation/item/TooltipHelper.java | 46 +- .../item/render/CustomRenderedItemModel.java | 4 +- .../CustomRenderedItemModelRenderer.java | 8 +- .../item/render/PartialItemModelRenderer.java | 14 +- .../foundation/mixin/BreakProgressMixin.java | 4 +- .../EntityContraptionInteractionMixin.java | 38 +- .../mixin/FixNormalScalingMixin.java | 2 + .../mixin/HeavyBootsOnPlayerMixin.java | 2 +- .../mixin/ModelDataRefreshMixin.java | 4 +- .../foundation/mixin/WindowResizeMixin.java | 2 +- .../foundation/networking/AllPackets.java | 2 +- .../networking/ISyncPersistentData.java | 10 +- .../foundation/networking/NbtPacket.java | 10 +- .../TileEntityConfigurationPacket.java | 8 +- .../networking/TileEntityDataPacket.java | 4 +- .../ponder/NavigatableSimiScreen.java | 50 +- .../foundation/ponder/PonderProgressBar.java | 32 +- .../foundation/ponder/PonderRegistry.java | 6 +- .../create/foundation/ponder/PonderScene.java | 36 +- .../ponder/PonderTooltipHandler.java | 30 +- .../create/foundation/ponder/PonderUI.java | 216 +-- .../create/foundation/ponder/PonderWorld.java | 94 +- .../ponder/PonderWorldParticles.java | 18 +- .../foundation/ponder/SceneBuilder.java | 34 +- .../foundation/ponder/SceneBuildingUtil.java | 12 +- .../create/foundation/ponder/Selection.java | 12 +- .../foundation/ponder/content/ArmScenes.java | 50 +- .../ponder/content/BearingScenes.java | 60 +- .../foundation/ponder/content/BeltScenes.java | 46 +- .../ponder/content/CartAssemblerScenes.java | 52 +- .../ponder/content/ChainDriveScenes.java | 30 +- .../ponder/content/ChassisScenes.java | 34 +- .../ponder/content/ChuteScenes.java | 14 +- .../ponder/content/CrafterScenes.java | 6 +- .../ponder/content/DebugScenes.java | 22 +- .../ponder/content/DeployerScenes.java | 52 +- .../ponder/content/EjectorScenes.java | 6 +- .../foundation/ponder/content/FanScenes.java | 26 +- .../ponder/content/FunnelScenes.java | 44 +- .../ponder/content/GantryScenes.java | 4 +- .../ponder/content/KineticsScenes.java | 58 +- .../ponder/content/MechanicalDrillScenes.java | 4 +- .../ponder/content/MechanicalSawScenes.java | 34 +- .../ponder/content/MovementActorScenes.java | 24 +- .../ponder/content/PistonScenes.java | 42 +- .../ponder/content/PonderChapter.java | 8 +- .../ponder/content/PonderIndexScreen.java | 22 +- .../foundation/ponder/content/PonderTag.java | 8 +- .../ponder/content/PonderTagIndexScreen.java | 42 +- .../ponder/content/PonderTagScreen.java | 48 +- .../ponder/content/ProcessingScenes.java | 76 +- .../ponder/content/PulleyScenes.java | 4 +- .../ponder/content/RedstoneScenes.java | 44 +- .../ponder/content/TunnelScenes.java | 18 +- .../fluid/FluidMovementActorScenes.java | 2 +- .../ponder/content/fluid/FluidTankScenes.java | 4 +- .../content/fluid/HosePulleyScenes.java | 36 +- .../ponder/content/fluid/PipeScenes.java | 76 +- .../ponder/content/fluid/PumpScenes.java | 66 +- .../ponder/content/fluid/SpoutScenes.java | 8 +- .../ponder/elements/AnimatedSceneElement.java | 12 +- .../ponder/elements/InputWindowElement.java | 12 +- .../ponder/elements/MinecartElement.java | 48 +- .../ponder/elements/ParrotElement.java | 98 +- .../ponder/elements/TextWindowElement.java | 16 +- .../ponder/elements/WorldSectionElement.java | 66 +- .../AnimateTileEntityInstruction.java | 2 +- .../EmitParticlesInstruction.java | 2 +- .../FadeIntoSceneInstruction.java | 2 +- .../FadeOutOfSceneInstruction.java | 2 +- .../instructions/HideAllInstruction.java | 2 +- .../HighlightValueBoxInstruction.java | 2 +- .../ReplaceBlocksInstruction.java | 6 +- .../TileEntityDataInstruction.java | 8 +- .../foundation/ponder/ui/ChapterLabel.java | 2 +- .../foundation/ponder/ui/PonderButton.java | 2 +- .../foundation/render/PartialBufferer.java | 2 +- .../foundation/render/ShadowRenderHelper.java | 34 +- .../foundation/render/SuperByteBuffer.java | 102 +- .../render/SuperByteBufferCache.java | 14 +- .../render/TileEntityRenderHelper.java | 14 +- .../foundation/renderState/RenderTypes.java | 112 +- .../renderState/SuperRenderTypeBuffer.java | 42 +- .../foundation/sound/ContinuousSound.java | 8 +- .../foundation/sound/RepeatingSound.java | 4 +- .../create/foundation/sound/SoundScape.java | 6 +- .../create/foundation/sound/SoundScapes.java | 8 +- .../tileEntity/SmartTileEntity.java | 24 +- .../tileEntity/SyncedTileEntity.java | 26 +- .../tileEntity/TileEntityBehaviour.java | 8 +- .../tileEntity/behaviour/ValueBox.java | 40 +- .../behaviour/ValueBoxRenderer.java | 6 +- .../behaviour/ValueBoxTransform.java | 8 +- .../belt/BeltProcessingBehaviour.java | 4 +- .../belt/DirectBeltInputBehaviour.java | 10 +- .../TransportedItemStackHandlerBehaviour.java | 2 +- .../EdgeInteractionHandler.java | 24 +- .../EdgeInteractionRenderer.java | 18 +- .../filtering/FilteringBehaviour.java | 14 +- .../filtering/FilteringCountUpdatePacket.java | 2 +- .../behaviour/filtering/FilteringHandler.java | 34 +- .../filtering/FilteringRenderer.java | 28 +- .../filtering/SidedFilteringBehaviour.java | 6 +- .../fluid/SmartFluidTankBehaviour.java | 10 +- .../inventory/InvManipulationBehaviour.java | 18 +- .../behaviour/linked/LinkBehaviour.java | 26 +- .../behaviour/linked/LinkHandler.java | 8 +- .../behaviour/linked/LinkRenderer.java | 16 +- .../scrollvalue/ScrollValueBehaviour.java | 6 +- .../scrollvalue/ScrollValueHandler.java | 14 +- .../scrollvalue/ScrollValueRenderer.java | 18 +- .../ColoredOverlayTileEntityRenderer.java | 4 +- .../renderer/SafeTileEntityRenderer.java | 2 +- .../utility/AbstractBlockBreakQueue.java | 2 +- .../foundation/utility/AngleHelper.java | 4 +- .../utility/AnimationTickHolder.java | 4 +- .../create/foundation/utility/BlockFace.java | 2 +- .../foundation/utility/BlockHelper.java | 158 +- .../foundation/utility/ColorHandlers.java | 4 +- .../create/foundation/utility/Debug.java | 12 +- .../foundation/utility/DirectionHelper.java | 2 +- .../foundation/utility/EmptyNamedTag.java | 4 +- .../create/foundation/utility/FontHelper.java | 16 +- .../utility/ISimpleReloadListener.java | 2 +- .../create/foundation/utility/Iterate.java | 6 +- .../create/foundation/utility/Lang.java | 2 +- .../foundation/utility/MatrixStacker.java | 30 +- .../create/foundation/utility/NBTHelper.java | 14 +- .../foundation/utility/NBTProcessors.java | 6 +- .../create/foundation/utility/Pointing.java | 2 +- .../foundation/utility/RaycastHelper.java | 8 +- .../utility/ServerSpeedProvider.java | 4 +- .../create/foundation/utility/TreeCutter.java | 32 +- .../create/foundation/utility/VecHelper.java | 74 +- .../foundation/utility/VoxelShaper.java | 10 +- .../foundation/utility/WorldHelper.java | 6 +- .../utility/animation/LerpedFloat.java | 6 +- .../utility/ghost/GhostBlockParams.java | 2 +- .../utility/ghost/GhostBlockRenderer.java | 48 +- .../utility/outliner/AABBOutline.java | 6 +- .../utility/outliner/BlockClusterOutline.java | 26 +- .../utility/outliner/ChasingAABBOutline.java | 4 +- .../foundation/utility/outliner/Outline.java | 36 +- .../utility/placement/IPlacementHelper.java | 10 +- .../utility/placement/PlacementHelpers.java | 52 +- .../utility/placement/PlacementOffset.java | 20 +- .../utility/placement/util/PoleHelper.java | 10 +- .../utility/recipe/RecipeConditions.java | 2 +- .../PlacementSimulationServerWorld.java | 14 +- .../PlacementSimulationWorld.java | 24 +- .../utility/worldWrappers/RayTraceWorld.java | 4 +- .../worldWrappers/WrappedChunkProvider.java | 10 +- .../worldWrappers/WrappedClientWorld.java | 42 +- .../worldWrappers/WrappedServerWorld.java | 56 +- .../utility/worldWrappers/WrappedWorld.java | 82 +- .../worldWrappers/chunk/EmptierChunk.java | 28 +- .../worldWrappers/chunk/WrappedChunk.java | 52 +- .../chunk/WrappedChunkSection.java | 4 +- .../foundation/worldgen/AllWorldFeatures.java | 2 +- .../worldgen/ConfigDrivenDecorator.java | 2 +- .../worldgen/ConfigDrivenFeatureEntry.java | 11 +- .../worldgen/ConfigDrivenOreFeature.java | 10 +- .../ConfigDrivenOreFeatureConfig.java | 2 +- .../foundation/worldgen/OxidizingBlock.java | 34 +- 1007 files changed, 13314 insertions(+), 12817 deletions(-) diff --git a/build.gradle b/build.gradle index ced646afd..c2d1456ad 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ archivesBaseName = 'create' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' minecraft { - mappings channel: 'snapshot', version: '20200920-mixed-1.16.3' + mappings channel: 'official', version: "${minecraft_version}" accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') runs { diff --git a/src/main/java/com/simibubi/create/AllBlockPartials.java b/src/main/java/com/simibubi/create/AllBlockPartials.java index 0eff8e238..8fb10077e 100644 --- a/src/main/java/com/simibubi/create/AllBlockPartials.java +++ b/src/main/java/com/simibubi/create/AllBlockPartials.java @@ -127,14 +127,14 @@ public class AllBlockPartials { Map map = new HashMap<>(); for (Direction d : Iterate.directions) { String asId = Lang.asId(type.name()); - map.put(d, get("fluid_pipe/" + asId + "/" + Lang.asId(d.getString()))); + map.put(d, get("fluid_pipe/" + asId + "/" + Lang.asId(d.getSerializedName()))); } PIPE_ATTACHMENTS.put(type, map); } for (BlazeBurnerBlock.HeatLevel heat : BlazeBurnerBlock.HeatLevel.values()) { if (heat == BlazeBurnerBlock.HeatLevel.NONE) continue; - BLAZES.put(heat, get("blaze_burner/blaze/" + heat.getString())); + BLAZES.put(heat, get("blaze_burner/blaze/" + heat.getSerializedName())); } } diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 8f1d0d508..df9bbf1c6 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -221,14 +221,14 @@ public class AllBlocks { .initialProperties(() -> Blocks.DISPENSER) .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), AssetLookup.partialBaseModel(ctx, prov))) .loot((lt, block) -> { - Builder builder = LootTable.builder(); - IBuilder survivesExplosion = SurvivesExplosion.builder(); - lt.registerLootTable(block, builder.addLootPool(LootPool.builder() - .acceptCondition(survivesExplosion) - .rolls(ConstantRange.of(1)) - .addEntry(ItemLootEntry.builder(AllBlocks.SCHEMATICANNON.get().asItem()) - .acceptFunction(CopyNbt.func_215881_a(CopyNbt.Source.BLOCK_ENTITY) - .func_216056_a("Options", "BlockEntityTag.Options"))))); + Builder builder = LootTable.lootTable(); + IBuilder survivesExplosion = SurvivesExplosion.survivesExplosion(); + lt.add(block, builder.withPool(LootPool.lootPool() + .when(survivesExplosion) + .setRolls(ConstantRange.exactly(1)) + .add(ItemLootEntry.lootTableItem(AllBlocks.SCHEMATICANNON.get().asItem()) + .apply(CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY) + .copy("Options", "BlockEntityTag.Options"))))); }) .item() .transform(customItemModel()) @@ -289,11 +289,11 @@ public class AllBlocks { public static final BlockEntry GEARBOX = REGISTRATE.block("gearbox", GearboxBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .transform(StressConfigDefaults.setNoImpact()) .onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(AllSpriteShifts.ANDESITE_CASING))) .onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, AllSpriteShifts.ANDESITE_CASING, - (s, f) -> f.getAxis() == s.get(GearboxBlock.AXIS)))) + (s, f) -> f.getAxis() == s.getValue(GearboxBlock.AXIS)))) .blockstate((c, p) -> axisBlock(c, p, $ -> AssetLookup.partialBaseModel(c, p), true)) .item() .transform(customItemModel()) @@ -301,7 +301,7 @@ public class AllBlocks { public static final BlockEntry CLUTCH = REGISTRATE.block("clutch", ClutchBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .transform(StressConfigDefaults.setNoImpact()) .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) .item() @@ -310,7 +310,7 @@ public class AllBlocks { public static final BlockEntry GEARSHIFT = REGISTRATE.block("gearshift", GearshiftBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .transform(StressConfigDefaults.setNoImpact()) .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) .item() @@ -320,7 +320,7 @@ public class AllBlocks { public static final BlockEntry ENCASED_CHAIN_DRIVE = REGISTRATE.block("encased_chain_drive", EncasedBeltBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .transform(StressConfigDefaults.setNoImpact()) .blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> p.models() .getExistingFile(p.modLoc("block/" + c.getName() + "/" + suffix))).generate(c, p)) @@ -331,10 +331,10 @@ public class AllBlocks { public static final BlockEntry ADJUSTABLE_CHAIN_GEARSHIFT = REGISTRATE.block("adjustable_chain_gearshift", AdjustablePulleyBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .transform(StressConfigDefaults.setNoImpact()) .blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> { - String powered = state.get(AdjustablePulleyBlock.POWERED) ? "_powered" : ""; + String powered = state.getValue(AdjustablePulleyBlock.POWERED) ? "_powered" : ""; return p.models() .withExistingParent(c.getName() + "_" + suffix + powered, p.modLoc("block/encased_chain_drive/" + suffix)) @@ -347,9 +347,9 @@ public class AllBlocks { .register(); public static final BlockEntry BELT = REGISTRATE.block("belt", BeltBlock::new) - .initialProperties(SharedProperties.beltMaterial, MaterialColor.GRAY) - .properties(p -> p.sound(SoundType.CLOTH)) - .properties(p -> p.hardnessAndResistance(0.8F)) + .initialProperties(SharedProperties.beltMaterial, MaterialColor.COLOR_GRAY) + .properties(p -> p.sound(SoundType.WOOL)) + .properties(p -> p.strength(0.8F)) .blockstate(new BeltGenerator()::generate) .transform(StressConfigDefaults.setImpact(1.0)) .onRegister(CreateRegistrate.blockModel(() -> BeltModel::new)) @@ -368,9 +368,9 @@ public class AllBlocks { public static final BlockEntry WATER_WHEEL = REGISTRATE.block("water_wheel", WaterWheelBlock::new) .initialProperties(SharedProperties::wooden) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.directionalBlockProviderIgnoresWaterlogged(false)) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .transform(StressConfigDefaults.setCapacity(16.0)) .simpleItem() .register(); @@ -378,7 +378,7 @@ public class AllBlocks { public static final BlockEntry ENCASED_FAN = REGISTRATE.block("encased_fan", EncasedFanBlock::new) .initialProperties(SharedProperties::stone) .blockstate(BlockStateGen.directionalBlockProvider(true)) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .transform(StressConfigDefaults.setCapacity(16.0)) .transform(StressConfigDefaults.setImpact(2.0)) .item() @@ -389,7 +389,7 @@ public class AllBlocks { .initialProperties(SharedProperties::stone) .tag(AllBlockTags.BRITTLE.tag) .blockstate(BlockStateGen.directionalBlockProvider(true)) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item() .transform(customItemModel()) .register(); @@ -434,9 +434,9 @@ public class AllBlocks { public static final BlockEntry CRUSHING_WHEEL = REGISTRATE.block("crushing_wheel", CrushingWheelBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.axisBlockProvider(false)) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .transform(StressConfigDefaults.setImpact(8.0)) .simpleItem() .register(); @@ -454,7 +454,7 @@ public class AllBlocks { public static final BlockEntry MECHANICAL_PRESS = REGISTRATE.block("mechanical_press", MechanicalPressBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.horizontalBlockProvider(true)) .transform(StressConfigDefaults.setImpact(8.0)) .item(AssemblyOperatorBlockItem::new) @@ -464,9 +464,9 @@ public class AllBlocks { public static final BlockEntry MECHANICAL_MIXER = REGISTRATE.block("mechanical_mixer", MechanicalMixerBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p))) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .transform(StressConfigDefaults.setImpact(4.0)) .item(AssemblyOperatorBlockItem::new) .transform(customItemModel()) @@ -474,7 +474,7 @@ public class AllBlocks { public static final BlockEntry BASIN = REGISTRATE.block("basin", BasinBlock::new) .initialProperties(SharedProperties::stone) - .properties(p -> p.sound(SoundType.NETHERITE)) + .properties(p -> p.sound(SoundType.NETHERITE_BLOCK)) .blockstate(new BasinGenerator()::generate) .onRegister(addMovementBehaviour(new BasinMovementBehaviour())) .item() @@ -484,10 +484,10 @@ public class AllBlocks { public static final BlockEntry BLAZE_BURNER = REGISTRATE.block("blaze_burner", BlazeBurnerBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(p -> p.luminance($ -> 12)) - .addLayer(() -> RenderType::getCutoutMipped) + .properties(p -> p.lightLevel($ -> 12)) + .addLayer(() -> RenderType::cutoutMipped) .tag(AllBlockTags.FAN_TRANSPARENT.tag, AllBlockTags.FAN_HEATERS.tag) - .loot((lt, block) -> lt.registerLootTable(block, BlazeBurnerBlock.buildLootTable())) + .loot((lt, block) -> lt.add(block, BlazeBurnerBlock.buildLootTable())) .blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p))) .item(BlazeBurnerBlockItem::withBlaze) .model(AssetLookup.customBlockItemModel("blaze_burner", "block_with_blaze")) @@ -497,14 +497,14 @@ public class AllBlocks { public static final BlockEntry LIT_BLAZE_BURNER = REGISTRATE.block("lit_blaze_burner", LitBlazeBurnerBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(p -> p.luminance(LitBlazeBurnerBlock::getLight)) - .addLayer(() -> RenderType::getCutoutMipped) + .properties(p -> p.lightLevel(LitBlazeBurnerBlock::getLight)) + .addLayer(() -> RenderType::cutoutMipped) .tag(AllBlockTags.FAN_TRANSPARENT.tag, AllBlockTags.FAN_HEATERS.tag) - .loot((lt, block) -> lt.registerDropping(block, AllItems.EMPTY_BLAZE_BURNER.get())) + .loot((lt, block) -> lt.dropOther(block, AllItems.EMPTY_BLAZE_BURNER.get())) .blockstate((c, p) -> p.getVariantBuilder(c.get()).forAllStates(state -> ConfiguredModel.builder() .modelFile(p.models().getExistingFile(p.modLoc( - "block/blaze_burner/" + (state.get(LitBlazeBurnerBlock.FLAME_TYPE) == LitBlazeBurnerBlock.FlameType.SOUL ? "block_with_soul_fire" : "block_with_fire") + "block/blaze_burner/" + (state.getValue(LitBlazeBurnerBlock.FLAME_TYPE) == LitBlazeBurnerBlock.FlameType.SOUL ? "block_with_soul_fire" : "block_with_fire") ))) .build())) .register(); @@ -519,7 +519,7 @@ public class AllBlocks { public static final BlockEntry WEIGHTED_EJECTOR = REGISTRATE.block("weighted_ejector", EjectorBlock::new) .initialProperties(SharedProperties::stone) - .properties(Block.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate((c, p) -> p.horizontalBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p), 180)) .transform(StressConfigDefaults.setImpact(2.0)) .item(EjectorItem::new) @@ -528,8 +528,8 @@ public class AllBlocks { public static final BlockEntry CHUTE = REGISTRATE.block("chute", ChuteBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(p -> p.sound(SoundType.NETHERITE)) - .addLayer(() -> RenderType::getCutoutMipped) + .properties(p -> p.sound(SoundType.NETHERITE_BLOCK)) + .addLayer(() -> RenderType::cutoutMipped) .blockstate(new ChuteGenerator()::generate) .item(ChuteItem::new) .transform(customItemModel("_", "block")) @@ -537,7 +537,7 @@ public class AllBlocks { public static final BlockEntry SMART_CHUTE = REGISTRATE.block("smart_chute", SmartChuteBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(p -> p.sound(SoundType.NETHERITE)) + .properties(p -> p.sound(SoundType.NETHERITE_BLOCK)) .blockstate((c, p) -> BlockStateGen.simpleBlock(c, p, AssetLookup.forPowered(c, p))) .item() .transform(customItemModel("_", "block")) @@ -584,23 +584,23 @@ public class AllBlocks { public static final BlockEntry ENCASED_FLUID_PIPE = REGISTRATE.block("encased_fluid_pipe", EncasedPipeBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(Block.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.encasedPipe()) .onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(AllSpriteShifts.COPPER_CASING))) .onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, AllSpriteShifts.COPPER_CASING, - (s, f) -> !s.get(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(f))))) + (s, f) -> !s.getValue(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(f))))) .onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::new)) - .loot((p, b) -> p.registerDropping(b, FLUID_PIPE.get())) + .loot((p, b) -> p.dropOther(b, FLUID_PIPE.get())) .register(); public static final BlockEntry GLASS_FLUID_PIPE = REGISTRATE.block("glass_fluid_pipe", GlassFluidPipeBlock::new) .initialProperties(SharedProperties::softMetal) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, s -> p.models() - .getExistingFile(p.modLoc("block/fluid_pipe/window" + (s.get(GlassFluidPipeBlock.ALT) ? "_alt" : ""))))) + .getExistingFile(p.modLoc("block/fluid_pipe/window" + (s.getValue(GlassFluidPipeBlock.ALT) ? "_alt" : ""))))) .onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::new)) - .loot((p, b) -> p.registerDropping(b, FLUID_PIPE.get())) + .loot((p, b) -> p.dropOther(b, FLUID_PIPE.get())) .register(); public static final BlockEntry MECHANICAL_PUMP = REGISTRATE.block("mechanical_pump", PumpBlock::new) @@ -625,7 +625,7 @@ public class AllBlocks { .initialProperties(SharedProperties::softMetal) .blockstate((c, p) -> BlockStateGen.directionalAxisBlock(c, p, (state, vertical) -> AssetLookup.partialBaseModel(c, p, vertical ? "vertical" : "horizontal", - state.get(FluidValveBlock.ENABLED) ? "open" : "closed"))) + state.getValue(FluidValveBlock.ENABLED) ? "open" : "closed"))) .onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::new)) .item() .transform(customItemModel()) @@ -637,25 +637,25 @@ public class AllBlocks { .register(); public static final DyedBlockList DYED_VALVE_HANDLES = new DyedBlockList<>(colour -> { - String colourName = colour.getString(); + String colourName = colour.getSerializedName(); return REGISTRATE.block(colourName + "_valve_handle", ValveHandleBlock::dyed) .transform(BuilderTransformers.valveHandle(colour)) - .recipe((c, p) -> ShapedRecipeBuilder.shapedRecipe(c.get()) - .patternLine("#") - .patternLine("-") - .key('#', DyeHelper.getTagOfDye(colour)) - .key('-', AllItemTags.VALVE_HANDLES.tag) - .addCriterion("has_valve", RegistrateRecipeProvider.hasItem(AllItemTags.VALVE_HANDLES.tag)) - .build(p, Create.asResource("crafting/kinetics/" + c.getName() + "_from_other_valve_handle"))) + .recipe((c, p) -> ShapedRecipeBuilder.shaped(c.get()) + .pattern("#") + .pattern("-") + .define('#', DyeHelper.getTagOfDye(colour)) + .define('-', AllItemTags.VALVE_HANDLES.tag) + .unlockedBy("has_valve", RegistrateRecipeProvider.hasItem(AllItemTags.VALVE_HANDLES.tag)) + .save(p, Create.asResource("crafting/kinetics/" + c.getName() + "_from_other_valve_handle"))) .register(); }); public static final BlockEntry FLUID_TANK = REGISTRATE.block("fluid_tank", FluidTankBlock::regular) .initialProperties(SharedProperties::softMetal) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(new FluidTankGenerator()::generate) .onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::standard)) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item(FluidTankItem::new) .model(AssetLookup.customBlockItemModel("_", "block_single_window")) .build() @@ -665,10 +665,10 @@ public class AllBlocks { REGISTRATE.block("creative_fluid_tank", FluidTankBlock::creative) .initialProperties(SharedProperties::softMetal) .tag(AllBlockTags.SAFE_NBT.tag) - .properties(Block.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(new FluidTankGenerator("creative_")::generate) .onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::creative)) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item(FluidTankItem::new) .properties(p -> p.rarity(Rarity.EPIC)) .model((c, p) -> p.withExistingParent(c.getName(), p.modLoc("block/fluid_tank/block_single_window")) @@ -688,7 +688,7 @@ public class AllBlocks { public static final BlockEntry ITEM_DRAIN = REGISTRATE.block("item_drain", ItemDrainBlock::new) .initialProperties(SharedProperties::softMetal) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .blockstate((c, p) -> p.simpleBlock(c.get(), AssetLookup.standardModel(c, p))) .simpleItem() .register(); @@ -696,7 +696,7 @@ public class AllBlocks { public static final BlockEntry SPOUT = REGISTRATE.block("spout", SpoutBlock::new) .initialProperties(SharedProperties::softMetal) .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), AssetLookup.partialBaseModel(ctx, prov))) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item(AssemblyOperatorBlockItem::new) .transform(customItemModel()) .register(); @@ -734,16 +734,16 @@ public class AllBlocks { public static final BlockEntry MECHANICAL_PISTON_HEAD = REGISTRATE.block("mechanical_piston_head", MechanicalPistonHeadBlock::new) .initialProperties(() -> Blocks.PISTON_HEAD) - .loot((p, b) -> p.registerDropping(b, PISTON_EXTENSION_POLE.get())) + .loot((p, b) -> p.dropOther(b, PISTON_EXTENSION_POLE.get())) .blockstate((c, p) -> BlockStateGen.directionalBlockIgnoresWaterlogged(c, p, state -> p.models() - .getExistingFile(p.modLoc("block/mechanical_piston/" + state.get(MechanicalPistonHeadBlock.TYPE) - .getString() + "/head")))) + .getExistingFile(p.modLoc("block/mechanical_piston/" + state.getValue(MechanicalPistonHeadBlock.TYPE) + .getSerializedName() + "/head")))) .register(); public static final BlockEntry GANTRY_CARRIAGE = REGISTRATE.block("gantry_carriage", GantryCarriageBlock::new) .initialProperties(SharedProperties::stone) - .properties(Block.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.directionalAxisBlockProvider()) .item() .transform(customItemModel()) @@ -753,11 +753,11 @@ public class AllBlocks { REGISTRATE.block("gantry_shaft", GantryShaftBlock::new) .initialProperties(SharedProperties::stone) .blockstate((c, p) -> p.directionalBlock(c.get(), s -> { - boolean isPowered = s.get(GantryShaftBlock.POWERED); - boolean isFlipped = s.get(GantryShaftBlock.FACING) + boolean isPowered = s.getValue(GantryShaftBlock.POWERED); + boolean isFlipped = s.getValue(GantryShaftBlock.FACING) .getAxisDirection() == AxisDirection.NEGATIVE; - String partName = s.get(GantryShaftBlock.PART) - .getString(); + String partName = s.getValue(GantryShaftBlock.PART) + .getSerializedName(); String flipped = isFlipped ? "_flipped" : ""; String powered = isPowered ? "_powered" : ""; ModelFile existing = AssetLookup.partialBaseModel(c, p, partName); @@ -804,9 +804,9 @@ public class AllBlocks { .register(); public static final BlockEntry ROPE = REGISTRATE.block("rope", PulleyBlock.RopeBlock::new) - .initialProperties(SharedProperties.beltMaterial, MaterialColor.BROWN) + .initialProperties(SharedProperties.beltMaterial, MaterialColor.COLOR_BROWN) .tag(AllBlockTags.BRITTLE.tag) - .properties(p -> p.sound(SoundType.CLOTH)) + .properties(p -> p.sound(SoundType.WOOL)) .blockstate((c, p) -> p.simpleBlock(c.get(), p.models() .getExistingFile(p.modLoc("block/rope_pulley/" + c.getName())))) .register(); @@ -822,9 +822,9 @@ public class AllBlocks { public static final BlockEntry CART_ASSEMBLER = REGISTRATE.block("cart_assembler", CartAssemblerBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.cartAssembler()) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .tag(BlockTags.RAILS, AllBlockTags.SAFE_NBT.tag) .item(CartAssemblerBlockItem::new) .transform(customItemModel()) @@ -833,9 +833,9 @@ public class AllBlocks { public static final BlockEntry REINFORCED_RAIL = REGISTRATE.block("reinforced_rail", ReinforcedRailBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.reinforcedRail()) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .tag(BlockTags.RAILS) .item() .model((c, p) -> p.blockItem(() -> c.getEntry() @@ -847,7 +847,7 @@ public class AllBlocks { REGISTRATE.block("controller_rail", ControllerRailBlock::new) .initialProperties(() -> Blocks.POWERED_RAIL) .blockstate(new ControllerRailGenerator()::generate) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .color(() -> ColorHandlers::getRedstonePower) .tag(BlockTags.RAILS) .item() @@ -896,8 +896,8 @@ public class AllBlocks { public static final BlockEntry STICKER = REGISTRATE.block("sticker", StickerBlock::new) .initialProperties(SharedProperties::stone) - .properties(Block.Properties::nonOpaque) - .addLayer(() -> RenderType::getCutoutMipped) + .properties(AbstractBlock.Properties::noOcclusion) + .addLayer(() -> RenderType::cutoutMipped) .blockstate((c, p) -> p.directionalBlock(c.get(), AssetLookup.forPowered(c, p))) .item() .transform(customItemModel()) @@ -917,7 +917,7 @@ public class AllBlocks { .blockstate(new SawGenerator()::generate) .transform(StressConfigDefaults.setImpact(4.0)) .onRegister(addMovementBehaviour(new SawMovementBehaviour())) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item() .transform(customItemModel()) .register(); @@ -954,7 +954,7 @@ public class AllBlocks { .initialProperties(SharedProperties::stone) .onRegister(addMovementBehaviour(new HarvesterMovementBehaviour())) .blockstate(BlockStateGen.horizontalBlockProvider(true)) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item() .transform(customItemModel()) .register(); @@ -968,7 +968,7 @@ public class AllBlocks { .register(); public static final DyedBlockList SEATS = new DyedBlockList<>(colour -> { - String colourName = colour.getString(); + String colourName = colour.getSerializedName(); SeatMovementBehaviour movementBehaviour = new SeatMovementBehaviour(); return REGISTRATE.block(colourName + "_seat", p -> new SeatBlock(p, colour == DyeColor.RED)) .initialProperties(SharedProperties::wooden) @@ -980,20 +980,20 @@ public class AllBlocks { .texture("2", p.modLoc("block/seat/side_" + colourName))); }) .recipe((c, p) -> { - ShapedRecipeBuilder.shapedRecipe(c.get()) - .patternLine("#") - .patternLine("-") - .key('#', DyeHelper.getWoolOfDye(colour)) - .key('-', ItemTags.WOODEN_SLABS) - .addCriterion("has_wool", RegistrateRecipeProvider.hasItem(ItemTags.WOOL)) - .build(p, Create.asResource("crafting/kinetics/" + c.getName())); - ShapedRecipeBuilder.shapedRecipe(c.get()) - .patternLine("#") - .patternLine("-") - .key('#', DyeHelper.getTagOfDye(colour)) - .key('-', AllItemTags.SEATS.tag) - .addCriterion("has_seat", RegistrateRecipeProvider.hasItem(AllItemTags.SEATS.tag)) - .build(p, Create.asResource("crafting/kinetics/" + c.getName() + "_from_other_seat")); + ShapedRecipeBuilder.shaped(c.get()) + .pattern("#") + .pattern("-") + .define('#', DyeHelper.getWoolOfDye(colour)) + .define('-', ItemTags.WOODEN_SLABS) + .unlockedBy("has_wool", RegistrateRecipeProvider.hasItem(ItemTags.WOOL)) + .save(p, Create.asResource("crafting/kinetics/" + c.getName())); + ShapedRecipeBuilder.shaped(c.get()) + .pattern("#") + .pattern("-") + .define('#', DyeHelper.getTagOfDye(colour)) + .define('-', AllItemTags.SEATS.tag) + .unlockedBy("has_seat", RegistrateRecipeProvider.hasItem(AllItemTags.SEATS.tag)) + .save(p, Create.asResource("crafting/kinetics/" + c.getName() + "_from_other_seat")); }) .onRegisterAfter(Item.class, v -> TooltipHelper.referTo(v, "block.create.seat")) .tag(AllBlockTags.SEATS.tag) @@ -1005,7 +1005,7 @@ public class AllBlocks { public static final BlockEntry SAIL_FRAME = REGISTRATE.block("sail_frame", p -> SailBlock.frame(p)) .initialProperties(SharedProperties::wooden) - .properties(Block.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.directionalBlockProvider(false)) .tag(AllBlockTags.WINDMILL_SAILS.tag) .tag(AllBlockTags.FAN_TRANSPARENT.tag) @@ -1014,7 +1014,7 @@ public class AllBlocks { public static final BlockEntry SAIL = REGISTRATE.block("white_sail", p -> SailBlock.withCanvas(p)) .initialProperties(SharedProperties::wooden) - .properties(Block.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.directionalBlockProvider(false)) .tag(AllBlockTags.WINDMILL_SAILS.tag) .simpleItem() @@ -1024,16 +1024,16 @@ public class AllBlocks { if (colour == DyeColor.WHITE) { return SAIL; } - String colourName = colour.getString(); + String colourName = colour.getSerializedName(); return REGISTRATE.block(colourName + "_sail", p -> SailBlock.withCanvas(p)) - .properties(Block.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .initialProperties(SharedProperties::wooden) .blockstate((c, p) -> p.directionalBlock(c.get(), p.models() .withExistingParent(colourName + "_sail", p.modLoc("block/white_sail")) .texture("0", p.modLoc("block/sail/canvas_" + colourName)))) .tag(AllBlockTags.WINDMILL_SAILS.tag) .tag(AllBlockTags.SAILS.tag) - .loot((p, b) -> p.registerDropping(b, SAIL.get())) + .loot((p, b) -> p.dropOther(b, SAIL.get())) .register(); }); @@ -1058,18 +1058,18 @@ public class AllBlocks { public static final BlockEntry REFINED_RADIANCE_CASING = REGISTRATE.block("refined_radiance_casing", CasingBlock::new) .transform(BuilderTransformers.casing(AllSpriteShifts.REFINED_RADIANCE_CASING)) - .properties(p -> p.luminance($ -> 12)) + .properties(p -> p.lightLevel($ -> 12)) .lang("Radiant Casing") .register(); public static final BlockEntry MECHANICAL_CRAFTER = REGISTRATE.block("mechanical_crafter", MechanicalCrafterBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate(BlockStateGen.horizontalBlockProvider(true)) .transform(StressConfigDefaults.setImpact(2.0)) .onRegister(CreateRegistrate.connectedTextures(new CrafterCTBehaviour())) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item() .transform(customItemModel()) .register(); @@ -1078,7 +1078,7 @@ public class AllBlocks { REGISTRATE.block("sequenced_gearshift", SequencedGearshiftBlock::new) .initialProperties(SharedProperties::stone) .tag(AllBlockTags.SAFE_NBT.tag) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .transform(StressConfigDefaults.setNoImpact()) .blockstate(new SequencedGearshiftGenerator()::generate) .item() @@ -1087,7 +1087,7 @@ public class AllBlocks { public static final BlockEntry FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(AbstractBlock.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .transform(StressConfigDefaults.setNoImpact()) .blockstate(new FlywheelGenerator()::generate) .item() @@ -1125,7 +1125,7 @@ public class AllBlocks { .blockstate((c, p) -> p.getVariantBuilder(c.get()) .forAllStates(s -> ConfiguredModel.builder() .modelFile(AssetLookup.partialBaseModel(c, p)) - .rotationX(s.get(ArmBlock.CEILING) ? 180 : 0) + .rotationX(s.getValue(ArmBlock.CEILING) ? 180 : 0) .build())) .transform(StressConfigDefaults.setImpact(2.0)) .item(ArmItem::new) @@ -1148,7 +1148,7 @@ public class AllBlocks { .initialProperties(SharedProperties::stone) .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(new BeltFunnelGenerator("andesite", new ResourceLocation("block/polished_andesite"))::generate) - .loot((p, b) -> p.registerDropping(b, ANDESITE_FUNNEL.get())) + .loot((p, b) -> p.dropOther(b, ANDESITE_FUNNEL.get())) .register(); public static final BlockEntry BRASS_FUNNEL = @@ -1167,7 +1167,7 @@ public class AllBlocks { .initialProperties(SharedProperties::softMetal) .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(new BeltFunnelGenerator("brass", Create.asResource("block/brass_block"))::generate) - .loot((p, b) -> p.registerDropping(b, BRASS_FUNNEL.get())) + .loot((p, b) -> p.dropOther(b, BRASS_FUNNEL.get())) .register(); public static final BlockEntry ANDESITE_TUNNEL = @@ -1211,9 +1211,9 @@ public class AllBlocks { public static final BlockEntry ORANGE_NIXIE_TUBE = REGISTRATE.block("nixie_tube", p -> new NixieTubeBlock(p, DyeColor.ORANGE)) .initialProperties(SharedProperties::softMetal) - .properties(p -> p.luminance($ -> 5)) + .properties(p -> p.lightLevel($ -> 5)) .blockstate(new NixieTubeGenerator()::generate) - .addLayer(() -> RenderType::getTranslucent) + .addLayer(() -> RenderType::translucent) .item() .transform(customItemModel()) .register(); @@ -1221,13 +1221,13 @@ public class AllBlocks { public static final DyedBlockList NIXIE_TUBES = new DyedBlockList<>(colour -> { if (colour == DyeColor.ORANGE) return ORANGE_NIXIE_TUBE; - String colourName = colour.getString(); + String colourName = colour.getSerializedName(); return REGISTRATE.block(colourName + "_nixie_tube", p -> new NixieTubeBlock(p, colour)) .initialProperties(SharedProperties::softMetal) - .properties(p -> p.luminance($ -> 5)) + .properties(p -> p.lightLevel($ -> 5)) .blockstate(new NixieTubeGenerator()::generate) - .loot((p, b) -> p.registerDropping(b, ORANGE_NIXIE_TUBE.get())) - .addLayer(() -> RenderType::getTranslucent) + .loot((p, b) -> p.dropOther(b, ORANGE_NIXIE_TUBE.get())) + .addLayer(() -> RenderType::translucent) .register(); }); @@ -1236,7 +1236,7 @@ public class AllBlocks { .initialProperties(SharedProperties::wooden) .tag(AllBlockTags.BRITTLE.tag, AllBlockTags.SAFE_NBT.tag) .blockstate(new RedstoneLinkGenerator()::generate) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item() .transform(customItemModel("_", "transmitter")) .register(); @@ -1255,7 +1255,7 @@ public class AllBlocks { REGISTRATE.block("pulse_repeater", PulseRepeaterBlock::new) .initialProperties(() -> Blocks.REPEATER) .blockstate(new PulseRepeaterGenerator()::generate) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item() .transform(customItemModel("diodes", "pulse_repeater")) .register(); @@ -1275,7 +1275,7 @@ public class AllBlocks { .initialProperties(() -> Blocks.REPEATER) .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(new AdjustableRepeaterGenerator()::generate) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item() .model(AbstractDiodeGenerator.diodeItemModel(true)) .build() @@ -1285,7 +1285,7 @@ public class AllBlocks { REGISTRATE.block("powered_latch", PoweredLatchBlock::new) .initialProperties(() -> Blocks.REPEATER) .blockstate(new PoweredLatchGenerator()::generate) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .simpleItem() .register(); @@ -1293,7 +1293,7 @@ public class AllBlocks { REGISTRATE.block("powered_toggle_latch", ToggleLatchBlock::new) .initialProperties(() -> Blocks.REPEATER) .blockstate(new ToggleLatchGenerator()::generate) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .item() .transform(customItemModel("diodes", "latch_off")) .register(); @@ -1303,7 +1303,7 @@ public class AllBlocks { .initialProperties(() -> Blocks.LECTERN) .blockstate((c,p) -> p.horizontalBlock(c.get(), p.models() .getExistingFile(p.mcLoc("block/lectern")))) - .loot((lt, block) -> lt.registerDropping(block, Blocks.LECTERN)) + .loot((lt, block) -> lt.dropOther(block, Blocks.LECTERN)) .register(); @@ -1317,20 +1317,20 @@ public class AllBlocks { REGISTRATE.block("copper_backtank", CopperBacktankBlock::new) .initialProperties(SharedProperties::softMetal) .blockstate((c, p) -> p.horizontalBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p))) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .transform(StressConfigDefaults.setImpact(4.0)) .loot((lt, block) -> { - Builder builder = LootTable.builder(); - IBuilder survivesExplosion = SurvivesExplosion.builder(); - lt.registerLootTable(block, builder.addLootPool(LootPool.builder() - .acceptCondition(survivesExplosion) - .rolls(ConstantRange.of(1)) - .addEntry(ItemLootEntry.builder(AllItems.COPPER_BACKTANK.get()) - .acceptFunction(CopyName.builder(CopyName.Source.BLOCK_ENTITY)) - .acceptFunction(CopyNbt.func_215881_a(CopyNbt.Source.BLOCK_ENTITY) - .func_216056_a("Air", "Air")) - .acceptFunction(CopyNbt.func_215881_a(CopyNbt.Source.BLOCK_ENTITY) - .func_216056_a("Enchantments", "Enchantments"))))); + Builder builder = LootTable.lootTable(); + IBuilder survivesExplosion = SurvivesExplosion.survivesExplosion(); + lt.add(block, builder.withPool(LootPool.lootPool() + .when(survivesExplosion) + .setRolls(ConstantRange.exactly(1)) + .add(ItemLootEntry.lootTableItem(AllItems.COPPER_BACKTANK.get()) + .apply(CopyName.copyName(CopyName.Source.BLOCK_ENTITY)) + .apply(CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY) + .copy("Air", "Air")) + .apply(CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY) + .copy("Enchantments", "Enchantments"))))); }) .register(); diff --git a/src/main/java/com/simibubi/create/AllEntityTypes.java b/src/main/java/com/simibubi/create/AllEntityTypes.java index 0b763e565..c67800ab2 100644 --- a/src/main/java/com/simibubi/create/AllEntityTypes.java +++ b/src/main/java/com/simibubi/create/AllEntityTypes.java @@ -72,7 +72,7 @@ public class AllEntityTypes { .properties(propertyBuilder) .properties(b -> { if (immuneToFire) - b.immuneToFire(); + b.fireImmune(); }) .renderer(renderer); } diff --git a/src/main/java/com/simibubi/create/AllFluids.java b/src/main/java/com/simibubi/create/AllFluids.java index 12a881022..d2b208839 100644 --- a/src/main/java/com/simibubi/create/AllFluids.java +++ b/src/main/java/com/simibubi/create/AllFluids.java @@ -23,6 +23,8 @@ import net.minecraftforge.common.Tags; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.ForgeFlowingFluid; +import net.minecraftforge.fluids.FluidAttributes.Builder; + public class AllFluids { private static final CreateRegistrate REGISTRATE = Create.registrate(); @@ -53,7 +55,7 @@ public class AllFluids { .explosionResistance(100f)) .tag(AllFluidTags.HONEY.tag) .bucket() - .properties(p -> p.maxStackSize(1)) + .properties(p -> p.stacksTo(1)) .build() .register(); @@ -68,7 +70,7 @@ public class AllFluids { .slopeFindDistance(3) .explosionResistance(100f)) .bucket() - .properties(p -> p.maxStackSize(1)) + .properties(p -> p.stacksTo(1)) .build() .register(); @@ -82,18 +84,18 @@ public class AllFluids { @OnlyIn(Dist.CLIENT) private static void makeTranslucent(FluidEntry entry) { ForgeFlowingFluid fluid = entry.get(); - RenderTypeLookup.setRenderLayer(fluid, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(fluid.getStillFluid(), RenderType.getTranslucent()); + RenderTypeLookup.setRenderLayer(fluid, RenderType.translucent()); + RenderTypeLookup.setRenderLayer(fluid.getSource(), RenderType.translucent()); } @Nullable public static BlockState getLavaInteraction(FluidState fluidState) { - Fluid fluid = fluidState.getFluid(); - if (fluid.isEquivalentTo(HONEY.get())) + Fluid fluid = fluidState.getType(); + if (fluid.isSame(HONEY.get())) return fluidState.isSource() ? AllPaletteBlocks.LIMESTONE.getDefaultState() : AllPaletteBlocks.LIMESTONE_VARIANTS.registeredBlocks.get(0) .getDefaultState(); - if (fluid.isEquivalentTo(CHOCOLATE.get())) + if (fluid.isSame(CHOCOLATE.get())) return fluidState.isSource() ? AllPaletteBlocks.SCORIA.getDefaultState() : AllPaletteBlocks.SCORIA_VARIANTS.registeredBlocks.get(0) .getDefaultState(); diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 8e7c0bea4..37ed1b9d6 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -108,33 +108,33 @@ public class AllItems { .register(); public static final ItemEntry BAR_OF_CHOCOLATE = REGISTRATE.item("bar_of_chocolate", Item::new) - .properties(p -> p.food(new Food.Builder().hunger(6) - .saturation(0.3F) + .properties(p -> p.food(new Food.Builder().nutrition(6) + .saturationMod(0.3F) .build())) .lang("Bar of Chocolate") .register(); public static final ItemEntry SWEET_ROLL = REGISTRATE.item("sweet_roll", Item::new) - .properties(p -> p.food(new Food.Builder().hunger(6) - .saturation(0.8F) + .properties(p -> p.food(new Food.Builder().nutrition(6) + .saturationMod(0.8F) .build())) .register(); public static final ItemEntry CHOCOLATE_BERRIES = REGISTRATE.item("chocolate_glazed_berries", Item::new) - .properties(p -> p.food(new Food.Builder().hunger(7) - .saturation(0.8F) + .properties(p -> p.food(new Food.Builder().nutrition(7) + .saturationMod(0.8F) .build())) .register(); public static final ItemEntry HONEYED_APPLE = REGISTRATE.item("honeyed_apple", Item::new) - .properties(p -> p.food(new Food.Builder().hunger(8) - .saturation(0.8F) + .properties(p -> p.food(new Food.Builder().nutrition(8) + .saturationMod(0.8F) .build())) .register(); public static final ItemEntry BUILDERS_TEA = REGISTRATE.item("builders_tea", BuildersTeaItem::new) .tag(AllItemTags.UPRIGHT_ON_BELT.tag) - .properties(p -> p.maxStackSize(16)) + .properties(p -> p.stacksTo(16)) .lang("Builder's Tea") .register(); @@ -203,7 +203,7 @@ public class AllItems { .register(); public static final ItemEntry GOGGLES = REGISTRATE.item("goggles", GogglesItem::new) - .properties(p -> p.maxStackSize(1)) + .properties(p -> p.stacksTo(1)) .onRegister(CreateRegistrate.itemModel(() -> GogglesModel::new)) .lang("Engineer's Goggles") .register(); @@ -229,7 +229,7 @@ public class AllItems { .register(); public static final ItemEntry WRENCH = REGISTRATE.item("wrench", WrenchItem::new) - .properties(p -> p.maxStackSize(1)) + .properties(p -> p.stacksTo(1)) .transform(CreateRegistrate.customRenderedItem(() -> WrenchModel::new)) .model(AssetLookup.itemModelWithPartials()) .register(); @@ -254,14 +254,14 @@ public class AllItems { public static final ItemEntry LINKED_CONTROLLER = REGISTRATE.item("linked_controller", LinkedControllerItem::new) - .properties(p -> p.maxStackSize(1)) + .properties(p -> p.stacksTo(1)) .transform(CreateRegistrate.customRenderedItem(() -> LinkedControllerModel::new)) .model(AssetLookup.itemModelWithPartials()) .register(); public static final ItemEntry POTATO_CANNON = REGISTRATE.item("potato_cannon", PotatoCannonItem::new) - .properties(p -> p.maxStackSize(1)) + .properties(p -> p.stacksTo(1)) .transform(CreateRegistrate.customRenderedItem(() -> PotatoCannonModel::new)) .model(AssetLookup.itemModelWithPartials()) .register(); @@ -325,16 +325,16 @@ public class AllItems { } public static final ItemEntry EMPTY_SCHEMATIC = REGISTRATE.item("empty_schematic", Item::new) - .properties(p -> p.maxStackSize(1)) + .properties(p -> p.stacksTo(1)) .register(); public static final ItemEntry SCHEMATIC_AND_QUILL = REGISTRATE.item("schematic_and_quill", SchematicAndQuillItem::new) - .properties(p -> p.maxStackSize(1)) + .properties(p -> p.stacksTo(1)) .register(); public static final ItemEntry SCHEMATIC = REGISTRATE.item("schematic", SchematicItem::new) - .properties(p -> p.maxStackSize(1)) + .properties(p -> p.stacksTo(1)) .register(); // Shortcuts diff --git a/src/main/java/com/simibubi/create/AllKeys.java b/src/main/java/com/simibubi/create/AllKeys.java index 3877f1026..6253094c1 100644 --- a/src/main/java/com/simibubi/create/AllKeys.java +++ b/src/main/java/com/simibubi/create/AllKeys.java @@ -42,24 +42,24 @@ public enum AllKeys { public boolean isPressed() { if (!modifiable) return isKeyDown(key); - return keybind.isKeyDown(); + return keybind.isDown(); } public String getBoundKey() { - return keybind.getBoundKeyLocalizedText() + return keybind.getTranslatedKeyMessage() .getString() .toUpperCase(); } public int getBoundCode() { return keybind.getKey() - .getKeyCode(); + .getValue(); } public static boolean isKeyDown(int key) { return GLFW.glfwGetKey(Minecraft.getInstance() .getWindow() - .getHandle(), key) != 0; + .getWindow(), key) != 0; } public static boolean ctrlDown() { diff --git a/src/main/java/com/simibubi/create/AllParticleTypes.java b/src/main/java/com/simibubi/create/AllParticleTypes.java index a7cd1df79..d2ceade86 100644 --- a/src/main/java/com/simibubi/create/AllParticleTypes.java +++ b/src/main/java/com/simibubi/create/AllParticleTypes.java @@ -54,7 +54,7 @@ public enum AllParticleTypes { @OnlyIn(Dist.CLIENT) public static void registerFactories(ParticleFactoryRegisterEvent event) { - ParticleManager particles = Minecraft.getInstance().particles; + ParticleManager particles = Minecraft.getInstance().particleEngine; for (AllParticleTypes particle : values()) particle.entry.registerFactory(particles); } diff --git a/src/main/java/com/simibubi/create/AllRecipeTypes.java b/src/main/java/com/simibubi/create/AllRecipeTypes.java index d3731470c..d88471657 100644 --- a/src/main/java/com/simibubi/create/AllRecipeTypes.java +++ b/src/main/java/com/simibubi/create/AllRecipeTypes.java @@ -101,6 +101,6 @@ public enum AllRecipeTypes { public > Optional find(C inv, World world) { return world.getRecipeManager() - .getRecipe(getType(), inv, world); + .getRecipeFor(getType(), inv, world); } } diff --git a/src/main/java/com/simibubi/create/AllShapes.java b/src/main/java/com/simibubi/create/AllShapes.java index af45533cf..234676ad0 100644 --- a/src/main/java/com/simibubi/create/AllShapes.java +++ b/src/main/java/com/simibubi/create/AllShapes.java @@ -123,9 +123,9 @@ public class AllShapes { // Internally Shared Shapes private static final VoxelShape - PISTON_HEAD = Blocks.PISTON_HEAD.getDefaultState() - .with(DirectionalBlock.FACING, UP) - .with(PistonHeadBlock.SHORT, true) + PISTON_HEAD = Blocks.PISTON_HEAD.defaultBlockState() + .setValue(DirectionalBlock.FACING, UP) + .setValue(PistonHeadBlock.SHORT, true) .getShape(null, null), PISTON_EXTENDED = shape(CASING_12PX.get(UP)).add(FOUR_VOXEL_POLE.get(Axis.Y)) .build(), @@ -159,7 +159,7 @@ public class AllShapes { HEATER_BLOCK_SPECIAL_COLLISION_SHAPE = shape(0, 0, 0, 16, 4, 16).build(), CRUSHING_WHEEL_COLLISION_SHAPE = cuboid(0, 0, 0, 16, 16, 16), SEAT = cuboid(0, 0, 0, 16, 8, 16), SEAT_COLLISION = cuboid(0, 0, 0, 16, 6, 16), - MECHANICAL_PROCESSOR_SHAPE = shape(VoxelShapes.fullCube()).erase(4, 0, 4, 12, 16, 12) + MECHANICAL_PROCESSOR_SHAPE = shape(VoxelShapes.block()).erase(4, 0, 4, 12, 16, 12) .build(), TURNTABLE_SHAPE = shape(1, 4, 1, 15, 8, 15).add(5, 0, 5, 11, 4, 11) .build(), @@ -237,7 +237,7 @@ public class AllShapes { } private static VoxelShape cuboid(double x1, double y1, double z1, double x2, double y2, double z2) { - return Block.makeCuboidShape(x1, y1, z1, x2, y2, z2); + return Block.box(x1, y1, z1, x2, y2, z2); } public static class Builder { @@ -258,7 +258,7 @@ public class AllShapes { public Builder erase(double x1, double y1, double z1, double x2, double y2, double z2) { this.shape = - VoxelShapes.combineAndSimplify(shape, cuboid(x1, y1, z1, x2, y2, z2), IBooleanFunction.ONLY_FIRST); + VoxelShapes.join(shape, cuboid(x1, y1, z1, x2, y2, z2), IBooleanFunction.ONLY_FIRST); return this; } diff --git a/src/main/java/com/simibubi/create/AllSoundEvents.java b/src/main/java/com/simibubi/create/AllSoundEvents.java index 8b2f07adf..062ceb94a 100644 --- a/src/main/java/com/simibubi/create/AllSoundEvents.java +++ b/src/main/java/com/simibubi/create/AllSoundEvents.java @@ -37,78 +37,78 @@ public class AllSoundEvents { public static final SoundEntry SCHEMATICANNON_LAUNCH_BLOCK = create("schematicannon_launch_block").subtitle("Schematicannon fires") - .playExisting(SoundEvents.ENTITY_GENERIC_EXPLODE, .1f, 1.1f) + .playExisting(SoundEvents.GENERIC_EXPLODE, .1f, 1.1f) .category(SoundCategory.BLOCKS) .build(), SCHEMATICANNON_FINISH = create("schematicannon_finish").subtitle("Schematicannon dings") - .playExisting(SoundEvents.BLOCK_NOTE_BLOCK_BELL, 1, .7f) + .playExisting(SoundEvents.NOTE_BLOCK_BELL, 1, .7f) .category(SoundCategory.BLOCKS) .build(), DEPOT_SLIDE = create("depot_slide").subtitle("Item slides") - .playExisting(SoundEvents.BLOCK_SAND_BREAK, .125f, 1.5f) + .playExisting(SoundEvents.SAND_BREAK, .125f, 1.5f) .category(SoundCategory.BLOCKS) .build(), DEPOT_PLOP = create("depot_plop").subtitle("Item lands") - .playExisting(SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, .25f, 1.25f) + .playExisting(SoundEvents.ITEM_FRAME_ADD_ITEM, .25f, 1.25f) .category(SoundCategory.BLOCKS) .build(), FUNNEL_FLAP = create("funnel_flap").subtitle("Funnel Flaps") - .playExisting(SoundEvents.ENTITY_ITEM_FRAME_ROTATE_ITEM, .125f, 1.5f) - .playExisting(SoundEvents.BLOCK_WOOL_BREAK, .0425f, .75f) + .playExisting(SoundEvents.ITEM_FRAME_ROTATE_ITEM, .125f, 1.5f) + .playExisting(SoundEvents.WOOL_BREAK, .0425f, .75f) .category(SoundCategory.BLOCKS) .build(), SLIME_ADDED = create("slime_added").subtitle("Slime squishes") - .playExisting(SoundEvents.BLOCK_SLIME_BLOCK_PLACE) + .playExisting(SoundEvents.SLIME_BLOCK_PLACE) .category(SoundCategory.BLOCKS) .build(), MECHANICAL_PRESS_ACTIVATION = create("mechanical_press_activation").subtitle("Mechanical Press clangs") - .playExisting(SoundEvents.BLOCK_ANVIL_LAND, .125f, 1f) - .playExisting(SoundEvents.ENTITY_ITEM_BREAK, .5f, 1f) + .playExisting(SoundEvents.ANVIL_LAND, .125f, 1f) + .playExisting(SoundEvents.ITEM_BREAK, .5f, 1f) .category(SoundCategory.BLOCKS) .build(), MECHANICAL_PRESS_ACTIVATION_ON_BELT = create("mechanical_press_activation_belt").subtitle("Mechanical Press bonks") - .playExisting(SoundEvents.BLOCK_WOOL_HIT, .75f, 1f) - .playExisting(SoundEvents.ENTITY_ITEM_BREAK, .15f, .75f) + .playExisting(SoundEvents.WOOL_HIT, .75f, 1f) + .playExisting(SoundEvents.ITEM_BREAK, .15f, .75f) .category(SoundCategory.BLOCKS) .build(), MIXING = create("mixing").subtitle("Mixing Noises") - .playExisting(SoundEvents.BLOCK_GILDED_BLACKSTONE_BREAK, .125f, .5f) - .playExisting(SoundEvents.BLOCK_NETHERRACK_BREAK, .125f, .5f) + .playExisting(SoundEvents.GILDED_BLACKSTONE_BREAK, .125f, .5f) + .playExisting(SoundEvents.NETHERRACK_BREAK, .125f, .5f) .category(SoundCategory.BLOCKS) .build(), CRANKING = create("cranking").subtitle("Hand Crank turns") - .playExisting(SoundEvents.BLOCK_WOOD_PLACE, .075f, .5f) - .playExisting(SoundEvents.BLOCK_WOODEN_BUTTON_CLICK_OFF, .025f, .5f) + .playExisting(SoundEvents.WOOD_PLACE, .075f, .5f) + .playExisting(SoundEvents.WOODEN_BUTTON_CLICK_OFF, .025f, .5f) .category(SoundCategory.BLOCKS) .build(), WORLDSHAPER_PLACE = create("worldshaper_place").subtitle("Worldshaper zaps") - .playExisting(SoundEvents.BLOCK_NOTE_BLOCK_BASEDRUM) + .playExisting(SoundEvents.NOTE_BLOCK_BASEDRUM) .category(SoundCategory.PLAYERS) .build(), SCROLL_VALUE = create("scroll_value").subtitle("Scroll-input clicks") - .playExisting(SoundEvents.BLOCK_NOTE_BLOCK_HAT, .124f, 1f) + .playExisting(SoundEvents.NOTE_BLOCK_HAT, .124f, 1f) .category(SoundCategory.PLAYERS) .build(), CONFIRM = create("confirm").subtitle("Affirmative ding") - .playExisting(SoundEvents.BLOCK_NOTE_BLOCK_BELL, 0.5f, 0.8f) + .playExisting(SoundEvents.NOTE_BLOCK_BELL, 0.5f, 0.8f) .category(SoundCategory.PLAYERS) .build(), DENY = create("deny").subtitle("Declining boop") - .playExisting(SoundEvents.BLOCK_NOTE_BLOCK_BASS, 1f, 0.5f) + .playExisting(SoundEvents.NOTE_BLOCK_BASS, 1f, 0.5f) .category(SoundCategory.PLAYERS) .build(), @@ -121,46 +121,46 @@ public class AllSoundEvents { .build(), POTATO_HIT = create("potato_hit").subtitle("Vegetable impacts") - .playExisting(SoundEvents.ENTITY_ITEM_FRAME_BREAK, .75f, .75f) - .playExisting(SoundEvents.BLOCK_WEEPING_VINES_BREAK, .75f, 1.25f) + .playExisting(SoundEvents.ITEM_FRAME_BREAK, .75f, .75f) + .playExisting(SoundEvents.WEEPING_VINES_BREAK, .75f, 1.25f) .category(SoundCategory.PLAYERS) .build(), CONTRAPTION_ASSEMBLE = create("contraption_assemble").subtitle("Contraption moves") - .playExisting(SoundEvents.BLOCK_WOODEN_TRAPDOOR_OPEN, .5f, .5f) - .playExisting(SoundEvents.BLOCK_CHEST_OPEN, .045f, .74f) + .playExisting(SoundEvents.WOODEN_TRAPDOOR_OPEN, .5f, .5f) + .playExisting(SoundEvents.CHEST_OPEN, .045f, .74f) .category(SoundCategory.BLOCKS) .build(), CONTRAPTION_DISASSEMBLE = create("contraption_disassemble").subtitle("Contraption stops") - .playExisting(SoundEvents.BLOCK_IRON_TRAPDOOR_CLOSE, .35f, .75f) + .playExisting(SoundEvents.IRON_TRAPDOOR_CLOSE, .35f, .75f) .category(SoundCategory.BLOCKS) .build(), WRENCH_ROTATE = create("wrench_rotate").subtitle("Wrench used") - .playExisting(SoundEvents.BLOCK_WOODEN_TRAPDOOR_CLOSE, .25f, 1.25f) + .playExisting(SoundEvents.WOODEN_TRAPDOOR_CLOSE, .25f, 1.25f) .category(SoundCategory.BLOCKS) .build(), WRENCH_REMOVE = create("wrench_remove").subtitle("Component breaks") - .playExisting(SoundEvents.ENTITY_ITEM_PICKUP, .25f, .75f) - .playExisting(SoundEvents.BLOCK_NETHERITE_BLOCK_HIT, .25f, .75f) + .playExisting(SoundEvents.ITEM_PICKUP, .25f, .75f) + .playExisting(SoundEvents.NETHERITE_BLOCK_HIT, .25f, .75f) .category(SoundCategory.BLOCKS) .build(), CRAFTER_CLICK = create("crafter_click").subtitle("Crafter clicks") - .playExisting(SoundEvents.BLOCK_NETHERITE_BLOCK_HIT, .25f, 1) - .playExisting(SoundEvents.BLOCK_WOODEN_TRAPDOOR_OPEN, .125f, 1) + .playExisting(SoundEvents.NETHERITE_BLOCK_HIT, .25f, 1) + .playExisting(SoundEvents.WOODEN_TRAPDOOR_OPEN, .125f, 1) .category(SoundCategory.BLOCKS) .build(), CRAFTER_CRAFT = create("crafter_craft").subtitle("Crafter crafts") - .playExisting(SoundEvents.ENTITY_ITEM_BREAK, .125f, .75f) + .playExisting(SoundEvents.ITEM_BREAK, .125f, .75f) .category(SoundCategory.BLOCKS) .build(), COPPER_ARMOR_EQUIP = create("copper_armor_equip").subtitle("Diving equipment clinks") - .playExisting(SoundEvents.ITEM_ARMOR_EQUIP_GOLD, 1f, 1f) + .playExisting(SoundEvents.ARMOR_EQUIP_GOLD, 1f, 1f) .category(SoundCategory.PLAYERS) .build(), @@ -170,22 +170,22 @@ public class AllSoundEvents { .build(), CONTROLLER_CLICK = create("controller_click").subtitle("Controller clicks") - .playExisting(SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, .35f, 1f) + .playExisting(SoundEvents.ITEM_FRAME_ADD_ITEM, .35f, 1f) .category(SoundCategory.BLOCKS) .build(), CONTROLLER_PUT = create("controller_put").subtitle("Controller thumps") - .playExisting(SoundEvents.ITEM_BOOK_PUT, 1f, 1f) + .playExisting(SoundEvents.BOOK_PUT, 1f, 1f) .category(SoundCategory.BLOCKS) .build(), CONTROLLER_TAKE = create("controller_take").subtitle("Lectern empties") - .playExisting(SoundEvents.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1f, 1f) + .playExisting(SoundEvents.ITEM_FRAME_REMOVE_ITEM, 1f, 1f) .category(SoundCategory.BLOCKS) .build(), SAW_ACTIVATE_WOOD = create("saw_activate_wood").subtitle("Mechanical Saw activates") - .playExisting(SoundEvents.ENTITY_BOAT_PADDLE_LAND, .75f, 1.5f) + .playExisting(SoundEvents.BOAT_PADDLE_LAND, .75f, 1.5f) .category(SoundCategory.BLOCKS) .build(), @@ -195,27 +195,27 @@ public class AllSoundEvents { .build(), BLAZE_MUNCH = create("blaze_munch").subtitle("Blaze Burner munches") - .playExisting(SoundEvents.ENTITY_GENERIC_EAT, .5f, 1f) + .playExisting(SoundEvents.GENERIC_EAT, .5f, 1f) .category(SoundCategory.BLOCKS) .build(), CRUSHING_1 = create("crushing_1").subtitle("Crushing noises") - .playExisting(SoundEvents.BLOCK_NETHERRACK_HIT) + .playExisting(SoundEvents.NETHERRACK_HIT) .category(SoundCategory.BLOCKS) .build(), CRUSHING_2 = create("crushing_2").noSubtitle() - .playExisting(SoundEvents.BLOCK_GRAVEL_PLACE) + .playExisting(SoundEvents.GRAVEL_PLACE) .category(SoundCategory.BLOCKS) .build(), CRUSHING_3 = create("crushing_3").noSubtitle() - .playExisting(SoundEvents.BLOCK_NETHERITE_BLOCK_BREAK) + .playExisting(SoundEvents.NETHERITE_BLOCK_BREAK) .category(SoundCategory.BLOCKS) .build(), PECULIAR_BELL_USE = create("peculiar_bell_use").subtitle("Peculiar Bell tolls") - .playExisting(SoundEvents.BLOCK_BELL_USE) + .playExisting(SoundEvents.BELL_BLOCK) .category(SoundCategory.BLOCKS) .build(), @@ -273,7 +273,7 @@ public class AllSoundEvents { } @Override - public void act(DirectoryCache cache) throws IOException { + public void run(DirectoryCache cache) throws IOException { generate(generator.getOutputFolder(), cache); } @@ -409,7 +409,7 @@ public class AllSoundEvents { public void playFrom(Entity entity, float volume, float pitch) { if (!entity.isSilent()) - play(entity.world, null, entity.getBlockPos(), volume, pitch); + play(entity.level, null, entity.blockPosition(), volume, pitch); } public void play(World world, PlayerEntity entity, BlockPos pos, float volume, float pitch) { @@ -417,7 +417,7 @@ public class AllSoundEvents { } public void play(World world, PlayerEntity entity, Vector3d pos, float volume, float pitch) { - play(world, entity, pos.getX(), pos.getY(), pos.getZ(), volume, pitch); + play(world, entity, pos.x(), pos.y(), pos.z(), volume, pitch); } public abstract void play(World world, PlayerEntity entity, double x, double y, double z, float volume, float pitch); @@ -427,7 +427,7 @@ public class AllSoundEvents { } public void playAt(World world, Vector3d pos, float volume, float pitch, boolean fade) { - playAt(world, pos.getX(), pos.getY(), pos.getZ(), volume, pitch, fade); + playAt(world, pos.x(), pos.y(), pos.z(), volume, pitch, fade); } public abstract void playAt(World world, double x, double y, double z, float volume, float pitch, boolean fade); @@ -480,7 +480,7 @@ public class AllSoundEvents { JsonArray list = new JsonArray(); JsonObject s = new JsonObject(); s.addProperty("name", pair.getFirst() - .getName() + .getLocation() .toString()); s.addProperty("type", "event"); list.add(s); @@ -504,7 +504,7 @@ public class AllSoundEvents { public void playAt(World world, double x, double y, double z, float volume, float pitch, boolean fade) { for (Pair> pair : compiledEvents) { Couple volPitch = pair.getSecond(); - world.playSound(x, y, z, pair.getFirst(), category, volPitch.getFirst() * volume, + world.playLocalSound(x, y, z, pair.getFirst(), category, volPitch.getFirst() * volume, volPitch.getSecond() * pitch, fade); } } @@ -551,7 +551,7 @@ public class AllSoundEvents { @Override public void playAt(World world, double x, double y, double z, float volume, float pitch, boolean fade) { - world.playSound(x, y, z, event, category, volume, pitch, fade); + world.playLocalSound(x, y, z, event, category, volume, pitch, fade); } } diff --git a/src/main/java/com/simibubi/create/AllSpecialTextures.java b/src/main/java/com/simibubi/create/AllSpecialTextures.java index 786dde9be..3f0826421 100644 --- a/src/main/java/com/simibubi/create/AllSpecialTextures.java +++ b/src/main/java/com/simibubi/create/AllSpecialTextures.java @@ -24,7 +24,7 @@ public enum AllSpecialTextures { public void bind() { Minecraft.getInstance() .getTextureManager() - .bindTexture(location); + .bind(location); } public ResourceLocation getLocation() { diff --git a/src/main/java/com/simibubi/create/AllSpriteShifts.java b/src/main/java/com/simibubi/create/AllSpriteShifts.java index e2c943f9f..94ba43b41 100644 --- a/src/main/java/com/simibubi/create/AllSpriteShifts.java +++ b/src/main/java/com/simibubi/create/AllSpriteShifts.java @@ -83,7 +83,7 @@ public class AllSpriteShifts { WoodType.CRIMSON, WoodType.WARPED }; Arrays.stream(supportedWoodTypes) - .forEach(woodType -> WOODEN_WINDOWS.put(woodType, vertical("palettes/" + woodType.getName() + "_window"))); + .forEach(woodType -> WOODEN_WINDOWS.put(woodType, vertical("palettes/" + woodType.name() + "_window"))); for (PaletteStoneVariants paletteStoneVariants : PaletteStoneVariants.values()) { String variantName = Lang.asId(paletteStoneVariants.name()); @@ -98,7 +98,7 @@ public class AllSpriteShifts { } for (DyeColor color : DyeColor.values()) { - String id = color.getString(); + String id = color.getSerializedName(); DYED_BELTS.put(color, SpriteShifter.get("block/belt", "block/belt/" + id + "_scroll")); DYED_OFFSET_BELTS.put(color, SpriteShifter.get("block/belt_offset", "block/belt/" + id + "_scroll")); DYED_DIAGONAL_BELTS.put(color, diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index 2fa0b7294..a3542f906 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -41,15 +41,15 @@ public class AllTags { } public static ITag.INamedTag forgeBlockTag(String name) { - return forgeTag(BlockTags::makeWrapperTag, name); + return forgeTag(BlockTags::bind, name); } public static ITag.INamedTag forgeItemTag(String name) { - return forgeTag(ItemTags::makeWrapperTag, name); + return forgeTag(ItemTags::bind, name); } public static ITag.INamedTag forgeFluidTag(String name) { - return forgeTag(FluidTags::makeWrapperTag, name); + return forgeTag(FluidTags::bind, name); } public static ITag.INamedTag forgeTag(Function> wrapperFactory, String name) { @@ -95,9 +95,9 @@ public class AllTags { } private AllItemTags(NameSpace namespace, String path) { - tag = ItemTags.makeWrapperTag( + tag = ItemTags.bind( new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name())).toString()); - REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.getOrCreateTagBuilder(tag)); + REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.tag(tag)); } public boolean matches(ItemStack stack) { @@ -105,12 +105,12 @@ public class AllTags { } public void add(Item... values) { - REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.getOrCreateTagBuilder(tag) + REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.tag(tag) .add(values)); } public void includeIn(AllItemTags parent) { - REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.getOrCreateTagBuilder(parent.tag) + REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.tag(parent.tag) .addTag(tag)); } } @@ -137,7 +137,7 @@ public class AllTags { } public boolean matches(Fluid fluid) { - return fluid != null && fluid.isIn(tag); + return fluid != null && fluid.is(tag); } static void loadClass() {} @@ -173,8 +173,8 @@ public class AllTags { new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name())); if (ModList.get() .isLoaded(namespace.id)) { - tag = BlockTags.makeWrapperTag(id.toString()); - REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getOrCreateTagBuilder(tag)); + tag = BlockTags.bind(id.toString()); + REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.tag(tag)); } else { tag = new EmptyNamedTag<>(id); } @@ -186,17 +186,17 @@ public class AllTags { } public void includeIn(AllBlockTags parent) { - REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getOrCreateTagBuilder(parent.tag) + REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.tag(parent.tag) .addTag(tag)); } public void includeAll(ITag.INamedTag child) { - REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getOrCreateTagBuilder(tag) + REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.tag(tag) .addTag(child)); } public void add(Block... values) { - REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getOrCreateTagBuilder(tag) + REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.tag(tag) .add(values)); } } diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 275c67b7d..f4aa5f356 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -110,7 +110,7 @@ public class CreateClient { IResourceManager resourceManager = Minecraft.getInstance() .getResourceManager(); if (resourceManager instanceof IReloadableResourceManager) - ((IReloadableResourceManager) resourceManager).addReloadListener(new ResourceReloadHandler()); + ((IReloadableResourceManager) resourceManager).registerReloadListener(new ResourceReloadHandler()); event.enqueueWork(() -> { CopperBacktankArmorLayer.register(); @@ -119,8 +119,8 @@ public class CreateClient { public static void onTextureStitch(TextureStitchEvent.Pre event) { if (!event.getMap() - .getId() - .equals(PlayerContainer.BLOCK_ATLAS_TEXTURE)) + .location() + .equals(PlayerContainer.BLOCK_ATLAS)) return; SpriteShifter.getAllTargetSprites() .forEach(event::addSprite); @@ -151,10 +151,10 @@ public class CreateClient { protected static List getAllBlockStateModelLocations(Block block) { List models = new ArrayList<>(); - block.getStateContainer() - .getValidStates() + block.getStateDefinition() + .getPossibleStates() .forEach(state -> { - models.add(getBlockModelLocation(block, BlockModelShapes.getPropertyMapString(state.getValues()))); + models.add(getBlockModelLocation(block, BlockModelShapes.statePropertiesToString(state.getValues()))); }); return models; } @@ -210,21 +210,21 @@ public class CreateClient { if (mc.player == null) return; - if (mc.gameSettings.graphicsMode != GraphicsFanciness.FABULOUS) + if (mc.options.graphicsMode != GraphicsFanciness.FABULOUS) return; if (AllConfigs.CLIENT.ignoreFabulousWarning.get()) return; - IFormattableTextComponent text = TextComponentUtils.bracketed(new StringTextComponent("WARN")) - .formatted(TextFormatting.GOLD) + IFormattableTextComponent text = TextComponentUtils.wrapInSquareBrackets(new StringTextComponent("WARN")) + .withStyle(TextFormatting.GOLD) .append(new StringTextComponent( " Some of Create's visual features will not be available while Fabulous graphics are enabled!")) - .styled(style -> style + .withStyle(style -> style .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/create dismissFabulousWarning")) .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent("Click here to disable this warning")))); - mc.ingameGUI.addChatMessage(ChatType.CHAT, text, mc.player.getUniqueID()); + mc.gui.handleChat(ChatType.CHAT, text, mc.player.getUUID()); } } diff --git a/src/main/java/com/simibubi/create/compat/dynamictrees/DynamicTree.java b/src/main/java/com/simibubi/create/compat/dynamictrees/DynamicTree.java index fa6463858..2238c7d76 100644 --- a/src/main/java/com/simibubi/create/compat/dynamictrees/DynamicTree.java +++ b/src/main/java/com/simibubi/create/compat/dynamictrees/DynamicTree.java @@ -35,13 +35,13 @@ public class DynamicTree extends AbstractBlockBreakQueue { return; // Play and render block break sound and particles - world.playEvent(null, 2001, startCutPos, Block.getStateId(world.getBlockState(startCutPos))); + world.levelEvent(null, 2001, startCutPos, Block.getId(world.getBlockState(startCutPos))); // Actually breaks the tree BranchDestructionData data = start.destroyBranchFromNode(world, startCutPos, Direction.DOWN, false, playerEntity); // Feed all the tree drops to drop bi-consumer - data.leavesDrops.forEach(stackPos -> drop.accept(stackPos.pos.add(startCutPos), stackPos.stack)); + data.leavesDrops.forEach(stackPos -> drop.accept(stackPos.pos.offset(startCutPos), stackPos.stack)); start.getLogDrops(world, startCutPos, data.species, data.woodVolume).forEach(stack -> drop.accept(startCutPos, stack)); } diff --git a/src/main/java/com/simibubi/create/compat/jei/ConversionRecipe.java b/src/main/java/com/simibubi/create/compat/jei/ConversionRecipe.java index c6d46653b..a59c356e1 100644 --- a/src/main/java/com/simibubi/create/compat/jei/ConversionRecipe.java +++ b/src/main/java/com/simibubi/create/compat/jei/ConversionRecipe.java @@ -25,7 +25,7 @@ public class ConversionRecipe extends ProcessingRecipe { public static ConversionRecipe create(ItemStack from, ItemStack to) { ResourceLocation recipeId = Create.asResource("conversion_" + counter++); return new ProcessingRecipeBuilder<>(ConversionRecipe::new, recipeId) - .withItemIngredients(Ingredient.fromStacks(from)) + .withItemIngredients(Ingredient.of(from)) .withSingleItemOutput(to) .build(); } diff --git a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java index 498db0bc8..76b994322 100644 --- a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java +++ b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java @@ -127,7 +127,7 @@ public class CreateJEI implements IModPlugin { .build(), autoShapeless = register("automatic_shapeless", MixingCategory::autoShapeless) - .recipes(r -> r.getSerializer() == IRecipeSerializer.CRAFTING_SHAPELESS && r.getIngredients() + .recipes(r -> r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE && r.getIngredients() .size() > 1 && !MechanicalPressTileEntity.canCompress(r.getIngredients()), BasinRecipe::convertShapeless) .catalyst(AllBlocks.MECHANICAL_MIXER::get) @@ -153,7 +153,7 @@ public class CreateJEI implements IModPlugin { woodCutting = register("wood_cutting", () -> new BlockCuttingCategory(Items.OAK_STAIRS)) .recipeList(() -> CondensedBlockCuttingRecipe - .condenseRecipes(findRecipesByType(SawTileEntity.woodcuttingRecipeType.getValue()))) + .condenseRecipes(findRecipesByType(SawTileEntity.woodcuttingRecipeType.get()))) .catalyst(AllBlocks.MECHANICAL_SAW::get) .enableWhenBool(c -> c.allowWoodcuttingOnSaw.get() && ModList.get() .isLoaded("druidcraft")) @@ -202,7 +202,7 @@ public class CreateJEI implements IModPlugin { .build(), autoShaped = register("automatic_shaped", MechanicalCraftingCategory::new) - .recipes(r -> r.getSerializer() == IRecipeSerializer.CRAFTING_SHAPELESS && r.getIngredients() + .recipes(r -> r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE && r.getIngredients() .size() == 1) .recipes( r -> (r.getType() == IRecipeType.CRAFTING && r.getType() != AllRecipeTypes.MECHANICAL_CRAFTING.type) @@ -359,7 +359,7 @@ public class CreateJEI implements IModPlugin { } public static List> findRecipes(Predicate> predicate) { - return Minecraft.getInstance().world.getRecipeManager() + return Minecraft.getInstance().level.getRecipeManager() .getRecipes() .stream() .filter(predicate) @@ -396,7 +396,7 @@ public class CreateJEI implements IModPlugin { public static boolean doInputsMatch(IRecipe recipe1, IRecipe recipe2) { ItemStack[] matchingStacks = recipe1.getIngredients() .get(0) - .getMatchingStacks(); + .getItems(); if (matchingStacks.length == 0) return true; if (recipe2.getIngredients() diff --git a/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java b/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java index 9abd1c945..84ae49721 100644 --- a/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java +++ b/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java @@ -39,26 +39,26 @@ public class DoubleItemIcon implements IDrawable { secondaryStack = secondarySupplier.get(); } - RenderHelper.enable(); + RenderHelper.turnBackOn(); RenderSystem.color4f(1, 1, 1, 1); RenderSystem.enableDepthTest(); - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 0); - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(1, 1, 0); GuiGameElement.of(primaryStack) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(10, 10, 100); matrixStack.scale(.5f, .5f, .5f); GuiGameElement.of(secondaryStack) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); - matrixStack.pop(); + matrixStack.popPose(); RenderSystem.enableBlend(); } diff --git a/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java b/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java index 7a1644dda..90646791f 100644 --- a/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java +++ b/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java @@ -17,6 +17,8 @@ import net.minecraft.client.renderer.Rectangle2d; import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; +import mezz.jei.api.gui.handlers.IGhostIngredientHandler.Target; + @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class GhostIngredientHandler> @@ -28,7 +30,7 @@ public class GhostIngredientHandler> boolean isAttributeFilter = gui instanceof AttributeFilterScreen; if (ingredient instanceof ItemStack) { - for (int i = 36; i < gui.getContainer().inventorySlots.size(); i++) { + for (int i = 36; i < gui.getMenu().slots.size(); i++) { targets.add(new GhostTarget<>(gui, i - 36, isAttributeFilter)); // Only accept items in 1st slot. 2nd is used for functionality, don't wanna override that one @@ -61,8 +63,8 @@ public class GhostIngredientHandler> this.gui = gui; this.slotIndex = slotIndex; this.isAttributeFilter = isAttributeFilter; - Slot slot = gui.getContainer().inventorySlots.get(slotIndex + 36); - this.area = new Rectangle2d(gui.getGuiLeft() + slot.xPos, gui.getGuiTop() + slot.yPos, 16, 16); + Slot slot = gui.getMenu().slots.get(slotIndex + 36); + this.area = new Rectangle2d(gui.getGuiLeft() + slot.x, gui.getGuiTop() + slot.y, 16, 16); } @Override @@ -74,7 +76,7 @@ public class GhostIngredientHandler> public void accept(I ingredient) { ItemStack stack = ((ItemStack) ingredient).copy(); stack.setCount(1); - gui.getContainer().ghostInventory.setStackInSlot(slotIndex, stack); + gui.getMenu().ghostInventory.setStackInSlot(slotIndex, stack); if (isAttributeFilter) return; diff --git a/src/main/java/com/simibubi/create/compat/jei/ScreenResourceWrapper.java b/src/main/java/com/simibubi/create/compat/jei/ScreenResourceWrapper.java index 67e7ce970..a4f2989c5 100644 --- a/src/main/java/com/simibubi/create/compat/jei/ScreenResourceWrapper.java +++ b/src/main/java/com/simibubi/create/compat/jei/ScreenResourceWrapper.java @@ -27,7 +27,7 @@ public class ScreenResourceWrapper implements IDrawable { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { resource.bind(); - AbstractGui.drawTexture(matrixStack, xOffset, yOffset, 0, resource.startX, resource.startY, resource.width, + AbstractGui.blit(matrixStack, xOffset, yOffset, 0, resource.startX, resource.startY, resource.width, resource.height, 256, 256); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/BasinCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/BasinCategory.java index 32526f37f..60bd73223 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/BasinCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/BasinCategory.java @@ -51,9 +51,9 @@ public class BasinCategory extends CreateRecipeCategory { HeatCondition requiredHeat = recipe.getRequiredHeat(); if (!requiredHeat.testBlazeBurner(HeatLevel.NONE)) - itemIngredients.add(Ingredient.fromItems(AllBlocks.BLAZE_BURNER.get())); + itemIngredients.add(Ingredient.of(AllBlocks.BLAZE_BURNER.get())); if (!requiredHeat.testBlazeBurner(HeatLevel.KINDLED)) - itemIngredients.add(Ingredient.fromItems(AllItems.BLAZE_CAKE.get())); + itemIngredients.add(Ingredient.of(AllItems.BLAZE_CAKE.get())); ingredients.setInputIngredients(itemIngredients); ingredients.setInputLists(VanillaTypes.FLUID, recipe.getFluidIngredients() @@ -62,7 +62,7 @@ public class BasinCategory extends CreateRecipeCategory { .collect(Collectors.toList())); if (!recipe.getRollableResults() .isEmpty()) - ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput()); + ingredients.setOutput(VanillaTypes.ITEM, recipe.getResultItem()); if (!recipe.getFluidResults() .isEmpty()) ingredients.setOutputs(VanillaTypes.FLUID, recipe.getFluidResults()); @@ -97,7 +97,7 @@ public class BasinCategory extends CreateRecipeCategory { Ingredient ingredient = pair.getFirst(); MutableInt amount = pair.getSecond(); - for (ItemStack itemStack : ingredient.getMatchingStacks()) { + for (ItemStack itemStack : ingredient.getItems()) { ItemStack stack = itemStack.copy(); stack.setCount(amount.getValue()); stacks.add(stack); @@ -117,7 +117,7 @@ public class BasinCategory extends CreateRecipeCategory { if (!itemOutput.isEmpty()) { itemStacks.init(i, false, 141, 50 + yOffset); - itemStacks.set(i, recipe.getRecipeOutput() + itemStacks.set(i, recipe.getResultItem() .getStack()); yOffset -= 19; } @@ -165,7 +165,7 @@ public class BasinCategory extends CreateRecipeCategory { AllGuiTextures heatBar = noHeat ? AllGuiTextures.JEI_NO_HEAT_BAR : AllGuiTextures.JEI_HEAT_BAR; heatBar.draw(matrixStack, 4, 80); - Minecraft.getInstance().fontRenderer.draw(matrixStack, Lang.translate(requiredHeat.getTranslationKey()), 9, + Minecraft.getInstance().font.draw(matrixStack, Lang.translate(requiredHeat.getTranslationKey()), 9, 86, requiredHeat.getColor()); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/BlockCuttingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/BlockCuttingCategory.java index 2d1cfe9b7..95dd72956 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/BlockCuttingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/BlockCuttingCategory.java @@ -45,7 +45,7 @@ public class BlockCuttingCategory extends CreateRecipeCategory> results = recipe.getCondensedOutputs(); for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) { @@ -110,19 +110,19 @@ public class BlockCuttingCategory extends CreateRecipeCategory> implements IRec float chance = output.getChance(); if (chance != 1) tooltip.add(1, Lang.translate("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100)) - .formatted(TextFormatting.GOLD)); + .withStyle(TextFormatting.GOLD)); }); } @@ -138,7 +138,7 @@ public abstract class CreateRecipeCategory> implements IRec return; if (fluid.getFluid() - .isEquivalentTo(AllFluids.POTION.get())) { + .isSame(AllFluids.POTION.get())) { ITextComponent name = fluid.getDisplayName(); if (tooltip.isEmpty()) tooltip.add(0, name); @@ -152,7 +152,7 @@ public abstract class CreateRecipeCategory> implements IRec } int amount = amounts.get(index != -1 ? 0 : slotIndex); - ITextComponent text = (Lang.translate("generic.unit.millibuckets", amount)).formatted(TextFormatting.GOLD); + ITextComponent text = (Lang.translate("generic.unit.millibuckets", amount)).withStyle(TextFormatting.GOLD); if (tooltip.isEmpty()) tooltip.add(0, text); else { diff --git a/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java index 6d8fab965..794b43cfd 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java @@ -41,7 +41,7 @@ public class CrushingCategory extends CreateRecipeCategory results = recipe.getRollableResults(); int size = results.size(); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/DeployingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/DeployingCategory.java index d3d6c6d3e..ce0a0748b 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/DeployingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/DeployingCategory.java @@ -39,7 +39,7 @@ public class DeployingCategory extends CreateRecipeCategory @Override public void renderAttachedBlock(MatrixStack matrixStack) { - GuiGameElement.of(Blocks.FIRE.getDefaultState()) + GuiGameElement.of(Blocks.FIRE.defaultBlockState()) .scale(24) .atLocal(0, 0, 2) .render(matrixStack); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/FanWashingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/FanWashingCategory.java index d6bb5a96d..939071a61 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/FanWashingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/FanWashingCategory.java @@ -40,7 +40,7 @@ public class FanWashingCategory extends ProcessingViaFanCategory results = recipe.getRollableResults(); boolean single = results.size() == 1; @@ -86,14 +86,14 @@ public class FanWashingCategory extends ProcessingViaFanCategory { .forEach(stack -> { if (stack.getItem() instanceof PotionItem) { FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack); - Ingredient potion = Ingredient.fromStacks(stack); + Ingredient potion = Ingredient.of(stack); recipes.add(new ProcessingRecipeBuilder<>(EmptyingRecipe::new, Create.asResource("potions")) .withItemIngredients(potion) .withFluidOutputs(fluidFromPotionItem) @@ -71,7 +71,7 @@ public class ItemDrainCategory extends CreateRecipeCategory { if (extracted.isEmpty()) return; - Ingredient ingredient = Ingredient.fromStacks(stack); + Ingredient ingredient = Ingredient.of(stack); ResourceLocation itemName = stack.getItem() .getRegistryName(); ResourceLocation fluidName = extracted.getFluid() @@ -99,7 +99,7 @@ public class ItemDrainCategory extends CreateRecipeCategory { if (!recipe.getRollableResults() .isEmpty()) - ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput()); + ingredients.setOutput(VanillaTypes.ITEM, recipe.getResultItem()); if (!recipe.getFluidResults() .isEmpty()) ingredients.setOutputs(VanillaTypes.FLUID, recipe.getFluidResults()); @@ -112,14 +112,14 @@ public class ItemDrainCategory extends CreateRecipeCategory { FluidStack fluidOutput = recipe.getResultingFluid(); List matchingIngredients = Arrays.asList(recipe.getIngredients() .get(0) - .getMatchingStacks()); + .getItems()); fluidStacks.init(0, true, 132, 8); fluidStacks.set(0, withImprovedVisibility(fluidOutput)); itemStacks.init(0, true, 26, 7); itemStacks.set(0, matchingIngredients); itemStacks.init(1, false, 131, 26); - itemStacks.set(1, recipe.getRecipeOutput()); + itemStacks.set(1, recipe.getResultItem()); addFluidTooltip(fluidStacks, Collections.emptyList(), ImmutableList.of(fluidOutput)); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java index 86febc77d..545184839 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java @@ -41,7 +41,7 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory recipeIngredients = recipe.getIngredients(); itemStacks.init(0, false, 133, 80); - itemStacks.set(0, recipe.getRecipeOutput() + itemStacks.set(0, recipe.getResultItem() .getStack()); int x = getXPadding(recipe); @@ -66,7 +66,7 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory list = new ArrayList<>(); TranslationTextComponent crash = new TranslationTextComponent("jei.tooltip.error.crash"); - list.add(crash.formatted(TextFormatting.RED)); + list.add(crash.withStyle(TextFormatting.RED)); return list; } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/MillingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/MillingCategory.java index ddd53ff55..fda2f0e9b 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/MillingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/MillingCategory.java @@ -41,7 +41,7 @@ public class MillingCategory extends CreateRecipeCategory results = recipe.getRollableResults(); boolean single = results.size() == 1; diff --git a/src/main/java/com/simibubi/create/compat/jei/category/MysteriousItemConversionCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/MysteriousItemConversionCategory.java index 079191032..86332537c 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/MysteriousItemConversionCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/MysteriousItemConversionCategory.java @@ -47,7 +47,7 @@ public class MysteriousItemConversionCategory extends CreateRecipeCategory results = recipe.getRollableResults(); itemStacks.init(0, true, 26, 16); - itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks())); + itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getItems())); itemStacks.init(1, false, 131, 16); itemStacks.set(1, results.get(0).getStack()); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/PackingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/PackingCategory.java index 2dcdce197..1e44ef274 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/PackingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/PackingCategory.java @@ -55,12 +55,12 @@ public class PackingCategory extends BasinCategory { while (i < size) { Ingredient ingredient = ingredients2.get(i); itemStacks.init(i, true, (rows == 2 ? 26 : 17) + (i % rows) * 19, 50 - (i / rows) * 19); - itemStacks.set(i, Arrays.asList(ingredient.getMatchingStacks())); + itemStacks.set(i, Arrays.asList(ingredient.getItems())); i++; } itemStacks.init(i, false, 141, 50); - itemStacks.set(i, recipe.getRecipeOutput()); + itemStacks.set(i, recipe.getResultItem()); } @Override diff --git a/src/main/java/com/simibubi/create/compat/jei/category/PolishingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/PolishingCategory.java index 99a5cbaf0..e3e2a461d 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/PolishingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/PolishingCategory.java @@ -47,7 +47,7 @@ public class PolishingCategory extends CreateRecipeCategory ingredients = recipe.getIngredients(); ItemStack[] matchingStacks = ingredients.get(0) - .getMatchingStacks(); + .getItems(); if (matchingStacks.length == 0) return; diff --git a/src/main/java/com/simibubi/create/compat/jei/category/PressingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/PressingCategory.java index fbd9d0656..ac32b8c5c 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/PressingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/PressingCategory.java @@ -41,7 +41,7 @@ public class PressingCategory extends CreateRecipeCategory { itemStacks.init(0, true, 26, 50); itemStacks.set(0, Arrays.asList(recipe.getIngredients() .get(0) - .getMatchingStacks())); + .getItems())); List results = recipe.getRollableResults(); for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) { diff --git a/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java index ace3e71e2..b8c27e694 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java @@ -35,12 +35,12 @@ public abstract class ProcessingViaFanCategory> extends Cre @Override public void setIngredients(T recipe, IIngredients ingredients) { ingredients.setInputIngredients(recipe.getIngredients()); - ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput()); + ingredients.setOutput(VanillaTypes.ITEM, recipe.getResultItem()); } public static Supplier getFan(String name) { return () -> AllBlocks.ENCASED_FAN.asStack() - .setDisplayName(Lang.translate("recipe." + name + ".fan").styled(style -> style.withItalic(false))); + .setHoverName(Lang.translate("recipe." + name + ".fan").withStyle(style -> style.withItalic(false))); } @Override @@ -49,10 +49,10 @@ public abstract class ProcessingViaFanCategory> extends Cre itemStacks.init(0, true, 20, 47); itemStacks.set(0, Arrays.asList(recipe.getIngredients() .get(0) - .getMatchingStacks())); + .getItems())); itemStacks.init(1, false, 139, 47); - itemStacks.set(1, recipe.getRecipeOutput()); + itemStacks.set(1, recipe.getResultItem()); } protected void renderWidgets(MatrixStack matrixStack, T recipe, double mouseX, double mouseY) { @@ -69,10 +69,10 @@ public abstract class ProcessingViaFanCategory> extends Cre return; renderWidgets(matrixStack, recipe, mouseX, mouseY); - matrixStack.push(); + matrixStack.pushPose(); translateFan(matrixStack); - matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-12.5f)); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees(-12.5f)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 24; GuiGameElement.of(AllBlockPartials.ENCASED_FAN_INNER) @@ -89,7 +89,7 @@ public abstract class ProcessingViaFanCategory> extends Cre .render(matrixStack); renderAttachedBlock(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); } protected void translateFan(MatrixStack matrixStack) { diff --git a/src/main/java/com/simibubi/create/compat/jei/category/SawingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/SawingCategory.java index 61f88da28..83a6275e4 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/SawingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/SawingCategory.java @@ -41,7 +41,7 @@ public class SawingCategory extends CreateRecipeCategory { itemStacks.init(0, true, 43, 4); itemStacks.set(0, Arrays.asList(recipe.getIngredients() .get(0) - .getMatchingStacks())); + .getItems())); List results = recipe.getRollableResults(); for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) { diff --git a/src/main/java/com/simibubi/create/compat/jei/category/SequencedAssemblyCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/SequencedAssemblyCategory.java index a15d9b477..74a81570f 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/SequencedAssemblyCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/SequencedAssemblyCategory.java @@ -58,7 +58,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory 1) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(15, 9, 0); RenderSystem.color4f(.65f, .65f, .65f, 1); AllIcons.I_REFRESH.draw(matrixStack, 50 + xOffset, 75); RenderSystem.color4f(1, 1, 1, 1); ITextComponent repeat = new StringTextComponent("x" + recipe.getLoops()); font.draw(matrixStack, repeat, 66 + xOffset, 80, 0x888888); - matrixStack.pop(); + matrixStack.popPose(); } - matrixStack.pop(); + matrixStack.popPose(); int width = 0; int margin = 3; @@ -162,18 +162,18 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory> sequence = recipe.getSequence(); for (int i = 0; i < sequence.size(); i++) { SequencedRecipe sequencedRecipe = sequence.get(i); SequencedAssemblySubCategory subCategory = getSubCategory(sequencedRecipe); int subWidth = subCategory.getWidth(); StringTextComponent component = new StringTextComponent("" + romans[Math.min(i, 6)]); - font.draw(matrixStack, component, font.getWidth(component) / -2 + subWidth / 2, 2, 0x888888); + font.draw(matrixStack, component, font.width(component) / -2 + subWidth / 2, 2, 0x888888); subCategory.draw(sequencedRecipe, matrixStack, mouseX, mouseY, i); matrixStack.translate(subWidth + margin, 0, 0); } - matrixStack.pop(); + matrixStack.popPose(); } @Override @@ -194,7 +194,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory getAllItemIngredients(SequencedAssemblyRecipe recipe) { List assemblyIngredients = new ArrayList<>(); assemblyIngredients.add(recipe.getIngredient()); - assemblyIngredients.add(Ingredient.fromStacks(recipe.getTransitionalItem())); + assemblyIngredients.add(Ingredient.of(recipe.getTransitionalItem())); recipe.addAdditionalIngredientsAndMachines(assemblyIngredients); return assemblyIngredients; } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java index 0c965b5c6..dd9f16238 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java @@ -52,7 +52,7 @@ public class SpoutCategory extends CreateRecipeCategory { .forEach(stack -> { if (stack.getItem() instanceof PotionItem) { FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack); - Ingredient bottle = Ingredient.fromItems(Items.GLASS_BOTTLE); + Ingredient bottle = Ingredient.of(Items.GLASS_BOTTLE); recipes.add(new ProcessingRecipeBuilder<>(FillingRecipe::new, Create.asResource("potions")) .withItemIngredients(bottle) .withFluidIngredients(FluidIngredient.fromFluidStack(fluidFromPotionItem)) @@ -78,12 +78,12 @@ public class SpoutCategory extends CreateRecipeCategory { fluidCopy.setAmount(1000); fhi.fill(fluidCopy, FluidAction.EXECUTE); ItemStack container = fhi.getContainer(); - if (container.isItemEqual(copy)) + if (container.sameItem(copy)) return; if (container.isEmpty()) return; - Ingredient bucket = Ingredient.fromStacks(stack); + Ingredient bucket = Ingredient.of(stack); ResourceLocation itemName = stack.getItem() .getRegistryName(); ResourceLocation fluidName = fluidCopy.getFluid() @@ -117,7 +117,7 @@ public class SpoutCategory extends CreateRecipeCategory { if (!recipe.getRollableResults() .isEmpty()) - ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput()); + ingredients.setOutput(VanillaTypes.ITEM, recipe.getResultItem()); if (!recipe.getFluidResults() .isEmpty()) ingredients.setOutputs(VanillaTypes.FLUID, recipe.getFluidResults()); @@ -130,14 +130,14 @@ public class SpoutCategory extends CreateRecipeCategory { FluidIngredient fluidIngredient = recipe.getRequiredFluid(); List matchingIngredients = Arrays.asList(recipe.getIngredients() .get(0) - .getMatchingStacks()); + .getItems()); fluidStacks.init(0, true, 27, 32); fluidStacks.set(0, withImprovedVisibility(fluidIngredient.getMatchingFluidStacks())); itemStacks.init(0, true, 26, 50); itemStacks.set(0, matchingIngredients); itemStacks.init(1, false, 131, 50); - itemStacks.set(1, recipe.getRecipeOutput()); + itemStacks.set(1, recipe.getResultItem()); addFluidTooltip(fluidStacks, ImmutableList.of(fluidIngredient), Collections.emptyList()); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java index 6757ced6d..7a0bcd91d 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java @@ -20,10 +20,10 @@ public class AnimatedBlazeBurner extends AnimatedKinetics { } public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 200); - matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f)); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 23; defaultBlockElement(AllBlocks.BLAZE_BURNER.getDefaultState()) @@ -39,7 +39,7 @@ public class AnimatedBlazeBurner extends AnimatedKinetics { .scale(scale) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java index 525558289..2fc1b195d 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java @@ -9,7 +9,7 @@ public class AnimatedCrafter extends AnimatedKinetics { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 0); AllGuiTextures.JEI_SHADOW.draw(matrixStack, -16, 13); @@ -29,7 +29,7 @@ public class AnimatedCrafter extends AnimatedKinetics { .scale(scale) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrushingWheels.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrushingWheels.java index eecc33882..d4f0f7e7f 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrushingWheels.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrushingWheels.java @@ -11,13 +11,13 @@ import net.minecraft.util.math.vector.Vector3f; public class AnimatedCrushingWheels extends AnimatedKinetics { private final BlockState wheel = AllBlocks.CRUSHING_WHEEL.getDefaultState() - .with(BlockStateProperties.AXIS, Axis.X); + .setValue(BlockStateProperties.AXIS, Axis.X); @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 100); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-22.5f)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(-22.5f)); int scale = 22; defaultBlockElement(wheel) @@ -31,7 +31,7 @@ public class AnimatedCrushingWheels extends AnimatedKinetics { .scale(scale) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedDeployer.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedDeployer.java index 8e5faedab..a1fe3e741 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedDeployer.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedDeployer.java @@ -14,10 +14,10 @@ public class AnimatedDeployer extends AnimatedKinetics { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 100); - matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f)); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 20; defaultBlockElement(shaft(Axis.Z)) @@ -26,15 +26,15 @@ public class AnimatedDeployer extends AnimatedKinetics { .render(matrixStack); defaultBlockElement(AllBlocks.DEPLOYER.getDefaultState() - .with(DeployerBlock.FACING, Direction.DOWN) - .with(DeployerBlock.AXIS_ALONG_FIRST_COORDINATE, false)) + .setValue(DeployerBlock.FACING, Direction.DOWN) + .setValue(DeployerBlock.AXIS_ALONG_FIRST_COORDINATE, false)) .scale(scale) .render(matrixStack); float cycle = (AnimationTickHolder.getRenderTime() - offset * 8) % 30; float offset = cycle < 10 ? cycle / 10f : cycle < 20 ? (20 - cycle) / 10f : 0; - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(0, offset * 17, 0); defaultBlockElement(AllBlockPartials.DEPLOYER_POLE) @@ -46,14 +46,14 @@ public class AnimatedDeployer extends AnimatedKinetics { .scale(scale) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); defaultBlockElement(AllBlocks.DEPOT.getDefaultState()) .atLocal(0, 2, 0) .scale(scale) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java index 7bb1e0126..1b792cdbb 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java @@ -21,10 +21,10 @@ public class AnimatedItemDrain extends AnimatedKinetics { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 100); - matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f)); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 20; defaultBlockElement(AllBlocks.ITEM_DRAIN.getDefaultState()) @@ -32,14 +32,14 @@ public class AnimatedItemDrain extends AnimatedKinetics { .render(matrixStack); Impl buffer = IRenderTypeBuffer.immediate(Tessellator.getInstance() - .getBuffer()); + .getBuilder()); MatrixStack ms = new MatrixStack(); ms.scale(scale, -scale, scale); float from = 2/16f; float to = 1f - from; FluidRenderer.renderTiledFluidBB(fluid, from, from, from, to, 3/4f, to, buffer, ms, 0xF000F0, false); - buffer.draw(); + buffer.endBatch(); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java index a07c37fd8..d41bdccec 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java @@ -27,7 +27,7 @@ public abstract class AnimatedKinetics implements IDrawable { } protected BlockState shaft(Axis axis) { - return AllBlocks.SHAFT.getDefaultState().with(BlockStateProperties.AXIS, axis); + return AllBlocks.SHAFT.getDefaultState().setValue(BlockStateProperties.AXIS, axis); } protected PartialModel cogwheel() { diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java index 147d9b2c4..8bd4827bf 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java @@ -9,7 +9,7 @@ public class AnimatedMillstone extends AnimatedKinetics { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 0); AllGuiTextures.JEI_SHADOW.draw(matrixStack, -16, 13); matrixStack.translate(-2, 18, 0); @@ -25,7 +25,7 @@ public class AnimatedMillstone extends AnimatedKinetics { .scale(scale) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMixer.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMixer.java index 05f9b806e..ec24775ef 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMixer.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMixer.java @@ -12,10 +12,10 @@ public class AnimatedMixer extends AnimatedKinetics { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 200); - matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f)); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 23; defaultBlockElement(cogwheel()) @@ -47,7 +47,7 @@ public class AnimatedMixer extends AnimatedKinetics { .scale(scale) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java index 7f1b7dca0..98414e0da 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java @@ -18,10 +18,10 @@ public class AnimatedPress extends AnimatedKinetics { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 100); - matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f)); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = basin ? 20 : 24; defaultBlockElement(shaft(Axis.Z)) @@ -44,7 +44,7 @@ public class AnimatedPress extends AnimatedKinetics { .scale(scale) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); } private float getAnimatedHeadOffset() { diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java index 1b051efd3..a2f17a740 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java @@ -13,12 +13,12 @@ public class AnimatedSaw extends AnimatedKinetics { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 0); matrixStack.translate(0, 0, 200); matrixStack.translate(2, 22, 0); - matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f)); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f + 90)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f + 90)); int scale = 25; defaultBlockElement(shaft(Axis.X)) @@ -27,7 +27,7 @@ public class AnimatedSaw extends AnimatedKinetics { .render(matrixStack); defaultBlockElement(AllBlocks.MECHANICAL_SAW.getDefaultState() - .with(SawBlock.FACING, Direction.UP)) + .setValue(SawBlock.FACING, Direction.UP)) .rotateBlock(0, 0, 0) .scale(scale) .render(matrixStack); @@ -37,7 +37,7 @@ public class AnimatedSaw extends AnimatedKinetics { .scale(scale) .render(matrixStack); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java index 6d812aab3..94ee2df86 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java @@ -26,10 +26,10 @@ public class AnimatedSpout extends AnimatedKinetics { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 100); - matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f)); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 20; defaultBlockElement(AllBlocks.SPOUT.getDefaultState()) @@ -40,7 +40,7 @@ public class AnimatedSpout extends AnimatedKinetics { float squeeze = cycle < 20 ? MathHelper.sin((float) (cycle / 20f * Math.PI)) : 0; squeeze *= 20; - matrixStack.push(); + matrixStack.pushPose(); defaultBlockElement(AllBlockPartials.SPOUT_TOP) .scale(scale) @@ -55,7 +55,7 @@ public class AnimatedSpout extends AnimatedKinetics { .render(matrixStack); matrixStack.translate(0, -3 * squeeze / 32f, 0); - matrixStack.pop(); + matrixStack.popPose(); defaultBlockElement(AllBlocks.DEPOT.getDefaultState()) .atLocal(0, 2, 0) @@ -63,13 +63,13 @@ public class AnimatedSpout extends AnimatedKinetics { .render(matrixStack); Impl buffer = IRenderTypeBuffer.immediate(Tessellator.getInstance() - .getBuffer()); - matrixStack.push(); + .getBuilder()); + matrixStack.pushPose(); matrixStack.scale(16, -16, 16); float from = 2/16f; float to = 1f - from; FluidRenderer.renderTiledFluidBB(fluids.get(0), from, from, from, to, to, to, buffer, matrixStack, 0xF000F0, false); - matrixStack.pop(); + matrixStack.popPose(); float width = 1 / 128f * squeeze; matrixStack.translate(scale / 2f, scale * 1.5f, scale / 2f); @@ -77,9 +77,9 @@ public class AnimatedSpout extends AnimatedKinetics { matrixStack.translate(-width / 2, 0, -width / 2); FluidRenderer.renderTiledFluidBB(fluids.get(0), 0, -0.001f, 0, width, 2.001f, width, buffer, matrixStack, 0xF000F0, false); - buffer.draw(); + buffer.endBatch(); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/sequencedAssembly/SequencedAssemblySubCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/sequencedAssembly/SequencedAssemblySubCategory.java index 00f2784cb..99810a1e1 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/sequencedAssembly/SequencedAssemblySubCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/sequencedAssembly/SequencedAssemblySubCategory.java @@ -51,11 +51,11 @@ public abstract class SequencedAssemblySubCategory { @Override public void draw(SequencedRecipe recipe, MatrixStack ms, double mouseX, double mouseY, int index) { press.offset = index; - ms.push(); + ms.pushPose(); ms.translate(-5, 50, 0); ms.scale(.6f, .6f, .6f); press.draw(ms, getWidth() / 2, 0); - ms.pop(); + ms.popPose(); } } @@ -86,7 +86,7 @@ public abstract class SequencedAssemblySubCategory { public void draw(SequencedRecipe recipe, MatrixStack ms, double mouseX, double mouseY, int index) { spout.offset = index; AllGuiTextures.JEI_SLOT.draw(ms, 3, 14); - ms.push(); + ms.pushPose(); ms.translate(-7, 50, 0); ms.scale(.75f, .75f, .75f); spout.withFluids(recipe.getRecipe() @@ -94,7 +94,7 @@ public abstract class SequencedAssemblySubCategory { .get(0) .getMatchingFluidStacks()) .draw(ms, getWidth() / 2, 0); - ms.pop(); + ms.popPose(); } } @@ -114,18 +114,18 @@ public abstract class SequencedAssemblySubCategory { itemStacks.set(index, Arrays.asList(recipe.getRecipe() .getIngredients() .get(1) - .getMatchingStacks())); + .getItems())); return 1; } @Override public void draw(SequencedRecipe recipe, MatrixStack ms, double mouseX, double mouseY, int index) { deployer.offset = index; - ms.push(); + ms.pushPose(); ms.translate(-7, 50, 0); ms.scale(.75f, .75f, .75f); deployer.draw(ms, getWidth() / 2, 0); - ms.pop(); + ms.popPose(); AllGuiTextures.JEI_SLOT.draw(ms, 3, 14); } @@ -142,11 +142,11 @@ public abstract class SequencedAssemblySubCategory { @Override public void draw(SequencedRecipe recipe, MatrixStack ms, double mouseX, double mouseY, int index) { - ms.push(); + ms.pushPose(); ms.translate(0, 51.5f, 0); ms.scale(.6f, .6f, .6f); saw.draw(ms, getWidth() / 2, 30); - ms.pop(); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/CreateItemGroup.java b/src/main/java/com/simibubi/create/content/CreateItemGroup.java index e773d83b5..b36ce6945 100644 --- a/src/main/java/com/simibubi/create/content/CreateItemGroup.java +++ b/src/main/java/com/simibubi/create/content/CreateItemGroup.java @@ -19,7 +19,7 @@ public class CreateItemGroup extends CreateItemGroupBase { } @Override - public ItemStack createIcon() { + public ItemStack makeIcon() { return AllBlocks.COGWHEEL.asStack(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java b/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java index 6876dd717..0a3fa7cbd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java +++ b/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java @@ -37,23 +37,23 @@ public class KineticDebugger { if (te == null) return; - World world = Minecraft.getInstance().world; - BlockPos toOutline = te.hasSource() ? te.source : te.getPos(); + World world = Minecraft.getInstance().level; + BlockPos toOutline = te.hasSource() ? te.source : te.getBlockPos(); BlockState state = te.getBlockState(); VoxelShape shape = world.getBlockState(toOutline) - .getRenderShape(world, toOutline); + .getBlockSupportShape(world, toOutline); if (te.getTheoreticalSpeed() != 0 && !shape.isEmpty()) - CreateClient.OUTLINER.chaseAABB("kineticSource", shape.getBoundingBox() - .offset(toOutline)) + CreateClient.OUTLINER.chaseAABB("kineticSource", shape.bounds() + .move(toOutline)) .lineWidth(1 / 16f) .colored(te.hasSource() ? ColorHelper.colorFromLong(te.network) : 0xffcc00); if (state.getBlock() instanceof IRotate) { Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state); - Vector3d vec = Vector3d.of(Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis) - .getDirectionVec()); - Vector3d center = VecHelper.getCenterOf(te.getPos()); + Vector3d vec = Vector3d.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, axis) + .getNormal()); + Vector3d center = VecHelper.getCenterOf(te.getBlockPos()); CreateClient.OUTLINER.showLine("rotationAxis", center.add(vec), center.subtract(vec)) .lineWidth(1 / 16f); } @@ -61,12 +61,12 @@ public class KineticDebugger { } public static boolean isActive() { - return Minecraft.getInstance().gameSettings.showDebugInfo && AllConfigs.CLIENT.rainbowDebug.get(); + return Minecraft.getInstance().options.renderDebug && AllConfigs.CLIENT.rainbowDebug.get(); } public static KineticTileEntity getSelectedTE() { - RayTraceResult obj = Minecraft.getInstance().objectMouseOver; - ClientWorld world = Minecraft.getInstance().world; + RayTraceResult obj = Minecraft.getInstance().hitResult; + ClientWorld world = Minecraft.getInstance().level; if (obj == null) return null; if (world == null) @@ -75,7 +75,7 @@ public class KineticDebugger { return null; BlockRayTraceResult ray = (BlockRayTraceResult) obj; - TileEntity te = world.getTileEntity(ray.getPos()); + TileEntity te = world.getBlockEntity(ray.getBlockPos()); if (!(te instanceof KineticTileEntity)) return null; diff --git a/src/main/java/com/simibubi/create/content/contraptions/KineticNetwork.java b/src/main/java/com/simibubi/create/content/contraptions/KineticNetwork.java index bbbe8e585..af9076cb6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/KineticNetwork.java +++ b/src/main/java/com/simibubi/create/content/contraptions/KineticNetwork.java @@ -89,7 +89,7 @@ public class KineticNetwork { te.updateFromNetwork(0, 0, 0); if (members.isEmpty()) { - TorquePropagator.networks.get(te.getWorld()) + TorquePropagator.networks.get(te.getLevel()) .remove(this.id); return; } @@ -109,9 +109,9 @@ public class KineticNetwork { boolean wasOverStressed = te.isOverStressed(); te.updateFromNetwork(currentCapacity, currentStress, getSize()); if (!wasOverStressed && te.isOverStressed() && te.getTheoreticalSpeed() != 0) { - AllTriggers.triggerForNearbyPlayers(AllTriggers.OVERSTRESSED, te.getWorld(), te.getPos(), 4); + AllTriggers.triggerForNearbyPlayers(AllTriggers.OVERSTRESSED, te.getLevel(), te.getBlockPos(), 4); if (containsFlywheel) - AllTriggers.triggerForNearbyPlayers(AllTriggers.OVERSTRESS_FLYWHEEL, te.getWorld(), te.getPos(), 4); + AllTriggers.triggerForNearbyPlayers(AllTriggers.OVERSTRESS_FLYWHEEL, te.getLevel(), te.getBlockPos(), 4); } } @@ -147,8 +147,8 @@ public class KineticNetwork { for (Iterator iterator = sources.keySet() .iterator(); iterator.hasNext();) { KineticTileEntity te = iterator.next(); - if (te.getWorld() - .getTileEntity(te.getPos()) != te) { + if (te.getLevel() + .getBlockEntity(te.getBlockPos()) != te) { iterator.remove(); continue; } @@ -164,8 +164,8 @@ public class KineticNetwork { for (Iterator iterator = members.keySet() .iterator(); iterator.hasNext();) { KineticTileEntity te = iterator.next(); - if (te.getWorld() - .getTileEntity(te.getPos()) != te) { + if (te.getLevel() + .getBlockEntity(te.getBlockPos()) != te) { iterator.remove(); continue; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java b/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java index faa8c2046..c12e8a081 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java @@ -51,20 +51,20 @@ public class RotationPropagator { final IRotate definitionFrom = (IRotate) fromBlock; final IRotate definitionTo = (IRotate) toBlock; - final BlockPos diff = to.getPos() - .subtract(from.getPos()); - final Direction direction = Direction.getFacingFromVector(diff.getX(), diff.getY(), diff.getZ()); - final World world = from.getWorld(); + final BlockPos diff = to.getBlockPos() + .subtract(from.getBlockPos()); + final Direction direction = Direction.getNearest(diff.getX(), diff.getY(), diff.getZ()); + final World world = from.getLevel(); boolean alignedAxes = true; for (Axis axis : Axis.values()) if (axis != direction.getAxis()) - if (axis.getCoordinate(diff.getX(), diff.getY(), diff.getZ()) != 0) + if (axis.choose(diff.getX(), diff.getY(), diff.getZ()) != 0) alignedAxes = false; boolean connectedByAxis = - alignedAxes && definitionFrom.hasShaftTowards(world, from.getPos(), stateFrom, direction) - && definitionTo.hasShaftTowards(world, to.getPos(), stateTo, direction.getOpposite()); + alignedAxes && definitionFrom.hasShaftTowards(world, from.getBlockPos(), stateFrom, direction) + && definitionTo.hasShaftTowards(world, to.getBlockPos(), stateTo, direction.getOpposite()); boolean connectedByGears = ICogWheel.isSmallCog(stateFrom) && ICogWheel.isSmallCog(stateTo); @@ -89,10 +89,10 @@ public class RotationPropagator { // Large Gear <-> Large Gear if (isLargeToLargeGear(stateFrom, stateTo, diff)) { - Axis sourceAxis = stateFrom.get(AXIS); - Axis targetAxis = stateTo.get(AXIS); - int sourceAxisDiff = sourceAxis.getCoordinate(diff.getX(), diff.getY(), diff.getZ()); - int targetAxisDiff = targetAxis.getCoordinate(diff.getX(), diff.getY(), diff.getZ()); + Axis sourceAxis = stateFrom.getValue(AXIS); + Axis targetAxis = stateTo.getValue(AXIS); + int sourceAxisDiff = sourceAxis.choose(diff.getX(), diff.getY(), diff.getZ()); + int targetAxisDiff = targetAxis.choose(diff.getX(), diff.getY(), diff.getZ()); return sourceAxisDiff > 0 ^ targetAxisDiff > 0 ? -1 : 1; } @@ -107,7 +107,7 @@ public class RotationPropagator { // Gear <-> Gear if (connectedByGears) { - if (diff.manhattanDistance(BlockPos.ZERO) != 1) + if (diff.distManhattan(BlockPos.ZERO) != 1) return 0; if (ICogWheel.isLargeCog(stateTo)) return 0; @@ -125,11 +125,11 @@ public class RotationPropagator { final BlockState stateTo = to.getBlockState(); // Rotation Speed Controller <-> Large Gear - if (isLargeCogToSpeedController(stateFrom, stateTo, to.getPos() - .subtract(from.getPos()))) + if (isLargeCogToSpeedController(stateFrom, stateTo, to.getBlockPos() + .subtract(from.getBlockPos()))) return SpeedControllerTileEntity.getConveyedSpeed(from, to, true); - if (isLargeCogToSpeedController(stateTo, stateFrom, from.getPos() - .subtract(to.getPos()))) + if (isLargeCogToSpeedController(stateTo, stateFrom, from.getBlockPos() + .subtract(to.getBlockPos()))) return SpeedControllerTileEntity.getConveyedSpeed(to, from, false); float rotationSpeedModifier = getRotationSpeedModifier(from, to); @@ -139,12 +139,12 @@ public class RotationPropagator { private static boolean isLargeToLargeGear(BlockState from, BlockState to, BlockPos diff) { if (!ICogWheel.isLargeCog(from) || !ICogWheel.isLargeCog(to)) return false; - Axis fromAxis = from.get(AXIS); - Axis toAxis = to.get(AXIS); + Axis fromAxis = from.getValue(AXIS); + Axis toAxis = to.getValue(AXIS); if (fromAxis == toAxis) return false; for (Axis axis : Axis.values()) { - int axisDiff = axis.getCoordinate(diff.getX(), diff.getY(), diff.getZ()); + int axisDiff = axis.choose(diff.getX(), diff.getY(), diff.getZ()); if (axis == fromAxis || axis == toAxis) { if (axisDiff == 0) return false; @@ -171,15 +171,15 @@ public class RotationPropagator { } private static boolean isLargeToSmallCog(BlockState from, BlockState to, IRotate defTo, BlockPos diff) { - Axis axisFrom = from.get(AXIS); + Axis axisFrom = from.getValue(AXIS); if (axisFrom != defTo.getRotationAxis(to)) return false; - if (axisFrom.getCoordinate(diff.getX(), diff.getY(), diff.getZ()) != 0) + if (axisFrom.choose(diff.getX(), diff.getY(), diff.getZ()) != 0) return false; for (Axis axis : Axis.values()) { if (axis == axisFrom) continue; - if (Math.abs(axis.getCoordinate(diff.getX(), diff.getY(), diff.getZ())) != 1) + if (Math.abs(axis.choose(diff.getX(), diff.getY(), diff.getZ())) != 1) return false; } return true; @@ -188,12 +188,12 @@ public class RotationPropagator { private static boolean isLargeCogToSpeedController(BlockState from, BlockState to, BlockPos diff) { if (!ICogWheel.isLargeCog(from) || !AllBlocks.ROTATION_SPEED_CONTROLLER.has(to)) return false; - if (!diff.equals(BlockPos.ZERO.down())) + if (!diff.equals(BlockPos.ZERO.below())) return false; - Axis axis = from.get(CogWheelBlock.AXIS); + Axis axis = from.getValue(CogWheelBlock.AXIS); if (axis.isVertical()) return false; - if (to.get(SpeedControllerBlock.HORIZONTAL_AXIS) == axis) + if (to.getValue(SpeedControllerBlock.HORIZONTAL_AXIS) == axis) return false; return true; } @@ -205,9 +205,9 @@ public class RotationPropagator { * @param pos */ public static void handleAdded(World worldIn, BlockPos pos, KineticTileEntity addedTE) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - if (!worldIn.isBlockPresent(pos)) + if (!worldIn.isLoaded(pos)) return; propagateNewSource(addedTE); } @@ -218,8 +218,8 @@ public class RotationPropagator { * @param currentTE */ private static void propagateNewSource(KineticTileEntity currentTE) { - BlockPos pos = currentTE.getPos(); - World world = currentTE.getWorld(); + BlockPos pos = currentTE.getBlockPos(); + World world = currentTE.getLevel(); for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) { float speedOfCurrent = currentTE.getTheoreticalSpeed(); @@ -251,7 +251,7 @@ public class RotationPropagator { // Neighbour faster, overpower the incoming tree if (Math.abs(oppositeSpeed) > Math.abs(speedOfCurrent)) { float prevSpeed = currentTE.getSpeed(); - currentTE.setSource(neighbourTE.getPos()); + currentTE.setSource(neighbourTE.getBlockPos()); currentTE.setSpeed(getConveyedSpeed(neighbourTE, currentTE)); currentTE.onSpeedChanged(prevSpeed); currentTE.sendData(); @@ -271,11 +271,11 @@ public class RotationPropagator { continue; } - if (currentTE.hasSource() && currentTE.source.equals(neighbourTE.getPos())) + if (currentTE.hasSource() && currentTE.source.equals(neighbourTE.getBlockPos())) currentTE.removeSource(); float prevSpeed = neighbourTE.getSpeed(); - neighbourTE.setSource(currentTE.getPos()); + neighbourTE.setSource(currentTE.getBlockPos()); neighbourTE.setSpeed(getConveyedSpeed(currentTE, neighbourTE)); neighbourTE.onSpeedChanged(prevSpeed); neighbourTE.sendData(); @@ -289,7 +289,7 @@ public class RotationPropagator { float prevSpeed = neighbourTE.getSpeed(); neighbourTE.setSpeed(newSpeed); - neighbourTE.setSource(currentTE.getPos()); + neighbourTE.setSource(currentTE.getBlockPos()); neighbourTE.onSpeedChanged(prevSpeed); neighbourTE.sendData(); propagateNewSource(neighbourTE); @@ -305,7 +305,7 @@ public class RotationPropagator { * @param removedTE */ public static void handleRemoved(World worldIn, BlockPos pos, KineticTileEntity removedTE) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; if (removedTE == null) return; @@ -316,7 +316,7 @@ public class RotationPropagator { BlockState neighbourState = worldIn.getBlockState(neighbourPos); if (!(neighbourState.getBlock() instanceof IRotate)) continue; - TileEntity tileEntity = worldIn.getTileEntity(neighbourPos); + TileEntity tileEntity = worldIn.getBlockEntity(neighbourPos); if (!(tileEntity instanceof KineticTileEntity)) continue; @@ -336,16 +336,16 @@ public class RotationPropagator { * @param updateTE */ private static void propagateMissingSource(KineticTileEntity updateTE) { - final World world = updateTE.getWorld(); + final World world = updateTE.getLevel(); List potentialNewSources = new LinkedList<>(); List frontier = new LinkedList<>(); - frontier.add(updateTE.getPos()); + frontier.add(updateTE.getBlockPos()); BlockPos missingSource = updateTE.hasSource() ? updateTE.source : null; while (!frontier.isEmpty()) { final BlockPos pos = frontier.remove(0); - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (!(tileEntity instanceof KineticTileEntity)) continue; final KineticTileEntity currentTE = (KineticTileEntity) tileEntity; @@ -354,7 +354,7 @@ public class RotationPropagator { currentTE.sendData(); for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) { - if (neighbourTE.getPos() + if (neighbourTE.getBlockPos() .equals(missingSource)) continue; if (!neighbourTE.hasSource()) @@ -368,7 +368,7 @@ public class RotationPropagator { if (neighbourTE.isSource()) potentialNewSources.add(neighbourTE); - frontier.add(neighbourTE.getPos()); + frontier.add(neighbourTE.getBlockPos()); } } @@ -381,14 +381,14 @@ public class RotationPropagator { } private static KineticTileEntity findConnectedNeighbour(KineticTileEntity currentTE, BlockPos neighbourPos) { - BlockState neighbourState = currentTE.getWorld() + BlockState neighbourState = currentTE.getLevel() .getBlockState(neighbourPos); if (!(neighbourState.getBlock() instanceof IRotate)) return null; if (!neighbourState.hasTileEntity()) return null; - TileEntity neighbourTE = currentTE.getWorld() - .getTileEntity(neighbourPos); + TileEntity neighbourTE = currentTE.getLevel() + .getBlockEntity(neighbourPos); if (!(neighbourTE instanceof KineticTileEntity)) return null; KineticTileEntity neighbourKTE = (KineticTileEntity) neighbourTE; @@ -403,8 +403,8 @@ public class RotationPropagator { public static boolean isConnected(KineticTileEntity from, KineticTileEntity to) { final BlockState stateFrom = from.getBlockState(); final BlockState stateTo = to.getBlockState(); - return isLargeCogToSpeedController(stateFrom, stateTo, to.getPos() - .subtract(from.getPos())) || getRotationSpeedModifier(from, to) != 0 + return isLargeCogToSpeedController(stateFrom, stateTo, to.getBlockPos() + .subtract(from.getBlockPos())) || getRotationSpeedModifier(from, to) != 0 || from.isCustomConnection(to, stateFrom, stateTo); } @@ -423,13 +423,13 @@ public class RotationPropagator { private static List getPotentialNeighbourLocations(KineticTileEntity te) { List neighbours = new LinkedList<>(); - if (!te.getWorld() - .isAreaLoaded(te.getPos(), 1)) + if (!te.getLevel() + .isAreaLoaded(te.getBlockPos(), 1)) return neighbours; for (Direction facing : Iterate.directions) - neighbours.add(te.getPos() - .offset(facing)); + neighbours.add(te.getBlockPos() + .relative(facing)); BlockState blockState = te.getBlockState(); if (!(blockState.getBlock() instanceof IRotate)) diff --git a/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java b/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java index 3d169a6ef..72b8fd57c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java @@ -26,7 +26,7 @@ public class TorquePropagator { public KineticNetwork getOrCreateNetworkFor(KineticTileEntity te) { Long id = te.network; KineticNetwork network; - Map map = networks.get(te.getWorld()); + Map map = networks.get(te.getLevel()); if (id == null) return null; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/BackHalfShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/BackHalfShaftInstance.java index 592db77bf..02570c895 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/BackHalfShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/BackHalfShaftInstance.java @@ -12,6 +12,6 @@ public class BackHalfShaftInstance extends HalfShaftInstance { @Override protected Direction getShaftDirection() { - return tile.getBlockState().get(BlockStateProperties.FACING).getOpposite(); + return tile.getBlockState().getValue(BlockStateProperties.FACING).getOpposite(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/CasingBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/CasingBlock.java index 75fb9c3d3..b58a1fffd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/CasingBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/CasingBlock.java @@ -11,6 +11,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraftforge.common.ToolType; +import net.minecraft.block.AbstractBlock.Properties; + public class CasingBlock extends Block implements IWrenchable { public CasingBlock(Properties p_i48440_1_) { @@ -29,7 +31,7 @@ public class CasingBlock extends Block implements IWrenchable { @Override public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) { - for (ToolType toolType : player.getHeldItemMainhand().getToolTypes()) { + for (ToolType toolType : player.getMainHandItem().getToolTypes()) { if (isToolEffective(state, toolType)) return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalAxisKineticBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalAxisKineticBlock.java index e3e4bc013..5795ff7b2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalAxisKineticBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalAxisKineticBlock.java @@ -15,6 +15,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBlock { public static final BooleanProperty AXIS_ALONG_FIRST_COORDINATE = BooleanProperty.create("axis_along_first"); @@ -24,30 +26,30 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(AXIS_ALONG_FIRST_COORDINATE); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } protected Direction getFacingForPlacement(BlockItemUseContext context) { Direction facing = context.getNearestLookingDirection() .getOpposite(); if (context.getPlayer() != null && context.getPlayer() - .isSneaking()) + .isShiftKeyDown()) facing = facing.getOpposite(); return facing; } protected boolean getAxisAlignmentForPlacement(BlockItemUseContext context) { - return context.getPlacementHorizontalFacing() + return context.getHorizontalDirection() .getAxis() == Axis.X; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Direction facing = getFacingForPlacement(context); - BlockPos pos = context.getPos(); - World world = context.getWorld(); + BlockPos pos = context.getClickedPos(); + World world = context.getLevel(); boolean alongFirst = false; Axis faceAxis = facing.getAxis(); @@ -70,7 +72,7 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc for (Direction side : Iterate.horizontalDirections) { if (!prefersConnectionTo(world, pos, side, true) - && !prefersConnectionTo(world, pos, side.rotateY(), false)) + && !prefersConnectionTo(world, pos, side.getClockWise(), false)) continue; if (prefferedSide != null && prefferedSide.getAxis() != side.getAxis()) { prefferedSide = null; @@ -83,15 +85,15 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc alongFirst = prefferedSide.getAxis() == Axis.X; } - return this.getDefaultState() - .with(FACING, facing) - .with(AXIS_ALONG_FIRST_COORDINATE, alongFirst); + return this.defaultBlockState() + .setValue(FACING, facing) + .setValue(AXIS_ALONG_FIRST_COORDINATE, alongFirst); } protected boolean prefersConnectionTo(IWorldReader reader, BlockPos pos, Direction facing, boolean shaftAxis) { if (!shaftAxis) return false; - BlockPos neighbourPos = pos.offset(facing); + BlockPos neighbourPos = pos.relative(facing); BlockState blockState = reader.getBlockState(neighbourPos); Block block = blockState.getBlock(); return block instanceof IRotate @@ -100,9 +102,9 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc @Override public Axis getRotationAxis(BlockState state) { - Axis pistonAxis = state.get(FACING) + Axis pistonAxis = state.getValue(FACING) .getAxis(); - boolean alongFirst = state.get(AXIS_ALONG_FIRST_COORDINATE); + boolean alongFirst = state.getValue(AXIS_ALONG_FIRST_COORDINATE); if (pistonAxis == Axis.X) return alongFirst ? Axis.Y : Axis.Z; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalKineticBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalKineticBlock.java index d6b43ef65..745948fa6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalKineticBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/DirectionalKineticBlock.java @@ -12,6 +12,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class DirectionalKineticBlock extends KineticBlock { public static final DirectionProperty FACING = BlockStateProperties.FACING; @@ -21,20 +23,20 @@ public abstract class DirectionalKineticBlock extends KineticBlock { } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(FACING); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } public Direction getPreferredFacing(BlockItemUseContext context) { Direction prefferedSide = null; for (Direction side : Iterate.directions) { - BlockState blockState = context.getWorld() - .getBlockState(context.getPos() - .offset(side)); + BlockState blockState = context.getLevel() + .getBlockState(context.getClickedPos() + .relative(side)); if (blockState.getBlock() instanceof IRotate) { - if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), context.getPos() - .offset(side), blockState, side.getOpposite())) + if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getLevel(), context.getClickedPos() + .relative(side), blockState, side.getOpposite())) if (prefferedSide != null && prefferedSide.getAxis() != side.getAxis()) { prefferedSide = null; break; @@ -50,22 +52,22 @@ public abstract class DirectionalKineticBlock extends KineticBlock { public BlockState getStateForPlacement(BlockItemUseContext context) { Direction preferred = getPreferredFacing(context); if (preferred == null || (context.getPlayer() != null && context.getPlayer() - .isSneaking())) { + .isShiftKeyDown())) { Direction nearestLookingDirection = context.getNearestLookingDirection(); - return getDefaultState().with(FACING, context.getPlayer() != null && context.getPlayer() - .isSneaking() ? nearestLookingDirection : nearestLookingDirection.getOpposite()); + return defaultBlockState().setValue(FACING, context.getPlayer() != null && context.getPlayer() + .isShiftKeyDown() ? nearestLookingDirection : nearestLookingDirection.getOpposite()); } - return getDefaultState().with(FACING, preferred.getOpposite()); + return defaultBlockState().setValue(FACING, preferred.getOpposite()); } @Override public BlockState rotate(BlockState state, Rotation rot) { - return state.with(FACING, rot.rotate(state.get(FACING))); + return state.setValue(FACING, rot.rotate(state.getValue(FACING))); } @Override public BlockState mirror(BlockState state, Mirror mirrorIn) { - return state.rotate(mirrorIn.toRotation(state.get(FACING))); + return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java index 916b8fe27..b96f34fff 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java @@ -36,7 +36,7 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { @Override public void setSource(BlockPos source) { super.setSource(source); - TileEntity tileEntity = world.getTileEntity(source); + TileEntity tileEntity = level.getBlockEntity(source); if (!(tileEntity instanceof KineticTileEntity)) return; KineticTileEntity sourceTe = (KineticTileEntity) tileEntity; @@ -59,8 +59,8 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { float stressBase = calculateAddedStressCapacity(); if (stressBase != 0 && IRotate.StressImpact.isEnabled()) { - tooltip.add(componentSpacing.copy().append(Lang.translate("gui.goggles.generator_stats"))); - tooltip.add(componentSpacing.copy().append(Lang.translate("tooltip.capacityProvided").formatted(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.goggles.generator_stats"))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("tooltip.capacityProvided").withStyle(TextFormatting.GRAY))); float speed = getTheoreticalSpeed(); if (speed != getGeneratedSpeed() && speed != 0) @@ -70,12 +70,12 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { float stressTotal = stressBase * speed; tooltip.add( - componentSpacing.copy() + componentSpacing.plainCopy() .append(new StringTextComponent(" " + IHaveGoggleInformation.format(stressTotal)) .append(Lang.translate("generic.unit.stress")) - .formatted(TextFormatting.AQUA)) + .withStyle(TextFormatting.AQUA)) .append(" ") - .append(Lang.translate("gui.goggles.at_current_speed").formatted(TextFormatting.DARK_GRAY))); + .append(Lang.translate("gui.goggles.at_current_speed").withStyle(TextFormatting.DARK_GRAY))); added = true; } @@ -87,7 +87,7 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { float speed = getGeneratedSpeed(); float prevSpeed = this.speed; - if (world.isRemote) + if (level.isClientSide) return; if (prevSpeed != speed) { @@ -141,7 +141,7 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { // Staying below Overpowered speed if (Math.abs(prevSpeed) >= Math.abs(speed)) { if (Math.signum(prevSpeed) != Math.signum(speed)) - world.destroyBlock(pos, true); + level.destroyBlock(worldPosition, true); return; } @@ -161,6 +161,6 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { } public Long createNetworkId() { - return pos.toLong(); + return worldPosition.asLong(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/HalfShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/HalfShaftInstance.java index cd06bf1a4..65b8920ba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/HalfShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/HalfShaftInstance.java @@ -19,6 +19,6 @@ public class HalfShaftInstance extends SingleRotatingInstance { } protected Direction getShaftDirection() { - return blockState.get(BlockStateProperties.FACING); + return blockState.getValue(BlockStateProperties.FACING); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalAxisKineticBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalAxisKineticBlock.java index 659d87bc6..c627f5e15 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalAxisKineticBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalAxisKineticBlock.java @@ -16,6 +16,8 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorldReader; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class HorizontalAxisKineticBlock extends KineticBlock { public static final Property HORIZONTAL_AXIS = BlockStateProperties.HORIZONTAL_AXIS; @@ -25,25 +27,25 @@ public abstract class HorizontalAxisKineticBlock extends KineticBlock { } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(HORIZONTAL_AXIS); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Axis preferredAxis = getPreferredHorizontalAxis(context); if (preferredAxis != null) - return this.getDefaultState().with(HORIZONTAL_AXIS, preferredAxis); - return this.getDefaultState().with(HORIZONTAL_AXIS, context.getPlacementHorizontalFacing().rotateY().getAxis()); + return this.defaultBlockState().setValue(HORIZONTAL_AXIS, preferredAxis); + return this.defaultBlockState().setValue(HORIZONTAL_AXIS, context.getHorizontalDirection().getClockWise().getAxis()); } public static Axis getPreferredHorizontalAxis(BlockItemUseContext context) { Direction prefferedSide = null; for (Direction side : Iterate.horizontalDirections) { - BlockState blockState = context.getWorld().getBlockState(context.getPos().offset(side)); + BlockState blockState = context.getLevel().getBlockState(context.getClickedPos().relative(side)); if (blockState.getBlock() instanceof IRotate) { - if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), context.getPos().offset(side), + if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getLevel(), context.getClickedPos().relative(side), blockState, side.getOpposite())) if (prefferedSide != null && prefferedSide.getAxis() != side.getAxis()) { prefferedSide = null; @@ -58,19 +60,19 @@ public abstract class HorizontalAxisKineticBlock extends KineticBlock { @Override public Axis getRotationAxis(BlockState state) { - return state.get(HORIZONTAL_AXIS); + return state.getValue(HORIZONTAL_AXIS); } @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face.getAxis() == state.get(HORIZONTAL_AXIS); + return face.getAxis() == state.getValue(HORIZONTAL_AXIS); } @Override public BlockState rotate(BlockState state, Rotation rot) { - Axis axis = state.get(HORIZONTAL_AXIS); - return state.with(HORIZONTAL_AXIS, - rot.rotate(Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis)).getAxis()); + Axis axis = state.getValue(HORIZONTAL_AXIS); + return state.setValue(HORIZONTAL_AXIS, + rot.rotate(Direction.get(AxisDirection.POSITIVE, axis)).getAxis()); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalHalfShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalHalfShaftInstance.java index c7298995f..eafd86c5d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalHalfShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalHalfShaftInstance.java @@ -13,6 +13,6 @@ public class HorizontalHalfShaftInstance extends HalfShaftInstance { @Override protected Direction getShaftDirection() { - return blockState.get(BlockStateProperties.HORIZONTAL_FACING).getOpposite(); + return blockState.getValue(BlockStateProperties.HORIZONTAL_FACING).getOpposite(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalKineticBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalKineticBlock.java index e763f9f03..c4b47d01a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalKineticBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalKineticBlock.java @@ -12,6 +12,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class HorizontalKineticBlock extends KineticBlock { public static final Property HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING; @@ -21,27 +23,27 @@ public abstract class HorizontalKineticBlock extends KineticBlock { } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(HORIZONTAL_FACING); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return this.getDefaultState() - .with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing() + return this.defaultBlockState() + .setValue(HORIZONTAL_FACING, context.getHorizontalDirection() .getOpposite()); } public Direction getPreferredHorizontalFacing(BlockItemUseContext context) { Direction prefferedSide = null; for (Direction side : Iterate.horizontalDirections) { - BlockState blockState = context.getWorld() - .getBlockState(context.getPos() - .offset(side)); + BlockState blockState = context.getLevel() + .getBlockState(context.getClickedPos() + .relative(side)); if (blockState.getBlock() instanceof IRotate) { - if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), context.getPos() - .offset(side), blockState, side.getOpposite())) + if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getLevel(), context.getClickedPos() + .relative(side), blockState, side.getOpposite())) if (prefferedSide != null && prefferedSide.getAxis() != side.getAxis()) { prefferedSide = null; break; @@ -55,12 +57,12 @@ public abstract class HorizontalKineticBlock extends KineticBlock { @Override public BlockState rotate(BlockState state, Rotation rot) { - return state.with(HORIZONTAL_FACING, rot.rotate(state.get(HORIZONTAL_FACING))); + return state.setValue(HORIZONTAL_FACING, rot.rotate(state.getValue(HORIZONTAL_FACING))); } @Override public BlockState mirror(BlockState state, Mirror mirrorIn) { - return state.rotate(mirrorIn.toRotation(state.get(HORIZONTAL_FACING))); + return state.rotate(mirrorIn.getRotation(state.getValue(HORIZONTAL_FACING))); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/IRotate.java b/src/main/java/com/simibubi/create/content/contraptions/base/IRotate.java index 958290270..2f2540eb7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/IRotate.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/IRotate.java @@ -72,9 +72,9 @@ public interface IRotate extends IWrenchable { level.append(" (" + IHaveGoggleInformation.format(Math.abs(speed))).append(Lang.translate("generic.unit.rpm")).append(") "); if (overstressed) - level.formatted(TextFormatting.DARK_GRAY, TextFormatting.STRIKETHROUGH); + level.withStyle(TextFormatting.DARK_GRAY, TextFormatting.STRIKETHROUGH); else - level.formatted(speedLevel.getTextColor()); + level.withStyle(speedLevel.getTextColor()); return level; } @@ -115,7 +115,7 @@ public interface IRotate extends IWrenchable { level.append(String.format(" (%s%%) ", (int) (stressPercent * 100))); - return level.formatted(color); + return level.withStyle(color); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticBlock.java index 01e8db956..351ece5f8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticBlock.java @@ -16,6 +16,8 @@ import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class KineticBlock extends Block implements IRotate { protected static final Palette color = Palette.Red; @@ -31,7 +33,7 @@ public abstract class KineticBlock extends Block implements IRotate { @Override public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) { - for (ToolType toolType : player.getHeldItemMainhand() + for (ToolType toolType : player.getMainHandItem() .getToolTypes()) { if (isToolEffective(state, toolType)) return true; @@ -45,13 +47,13 @@ public abstract class KineticBlock extends Block implements IRotate { } @Override - public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { // onBlockAdded is useless for init, as sometimes the TE gets re-instantiated // however, if a block change occurs that does not change kinetic connections, // we can prevent a major re-propagation here - TileEntity tileEntity = worldIn.getTileEntity(pos); + TileEntity tileEntity = worldIn.getBlockEntity(pos); if (tileEntity instanceof KineticTileEntity) { KineticTileEntity kineticTileEntity = (KineticTileEntity) tileEntity; kineticTileEntity.preventSpeedUpdate = 0; @@ -87,11 +89,11 @@ public abstract class KineticBlock extends Block implements IRotate { public abstract TileEntity createTileEntity(BlockState state, IBlockReader world); @Override - public void updateDiagonalNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) { - if (worldIn.isRemote()) + public void updateIndirectNeighbourShapes(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) { + if (worldIn.isClientSide()) return; - TileEntity tileEntity = worldIn.getTileEntity(pos); + TileEntity tileEntity = worldIn.getBlockEntity(pos); if (!(tileEntity instanceof KineticTileEntity)) return; KineticTileEntity kte = (KineticTileEntity) tileEntity; @@ -108,11 +110,11 @@ public abstract class KineticBlock extends Block implements IRotate { } @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { - if (worldIn.isRemote) + public void setPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { + if (worldIn.isClientSide) return; - TileEntity tileEntity = worldIn.getTileEntity(pos); + TileEntity tileEntity = worldIn.getBlockEntity(pos); if (!(tileEntity instanceof KineticTileEntity)) return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java index 6eb292670..2976a4cfd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java @@ -24,7 +24,7 @@ public class KineticData extends BasicData { } public KineticData setPosition(Vector3f pos) { - return setPosition(pos.getX(), pos.getY(), pos.getZ()); + return setPosition(pos.x(), pos.y(), pos.z()); } public KineticData setPosition(float x, float y, float z) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticEffectHandler.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticEffectHandler.java index 9e9d70c0b..6709d540e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticEffectHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticEffectHandler.java @@ -29,9 +29,9 @@ public class KineticEffectHandler { } public void tick() { - World world = kte.getWorld(); + World world = kte.getLevel(); - if (world.isRemote) { + if (world.isClientSide) { if (overStressedTime > 0) if (--overStressedTime == 0) if (kte.isOverStressed()) { @@ -59,15 +59,15 @@ public class KineticEffectHandler { } public void spawnEffect(IParticleData particle, float maxMotion, int amount) { - World world = kte.getWorld(); + World world = kte.getLevel(); if (world == null) return; - if (!world.isRemote) + if (!world.isClientSide) return; - Random r = world.rand; + Random r = world.random; for (int i = 0; i < amount; i++) { Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, r, maxMotion); - Vector3d position = VecHelper.getCenterOf(kte.getPos()); + Vector3d position = VecHelper.getCenterOf(kte.getBlockPos()); world.addParticle(particle, position.x, position.y, position.z, motion.x, motion.y, motion.z); } } @@ -87,8 +87,8 @@ public class KineticEffectHandler { float radius2 = kb.getParticleTargetRadius(); Axis axis = kb.getRotationAxis(state); - BlockPos pos = kte.getPos(); - World world = kte.getWorld(); + BlockPos pos = kte.getBlockPos(); + World world = kte.getLevel(); if (axis == null) return; if (world == null) @@ -105,7 +105,7 @@ public class KineticEffectHandler { AllTriggers.triggerForNearbyPlayers(AllTriggers.ROTATION, world, pos, 5); RotationIndicatorParticleData particleData = new RotationIndicatorParticleData(color, particleSpeed, radius1, radius2, 10, axisChar); - ((ServerWorld) world).spawnParticle(particleData, vec.x, vec.y, vec.z, 20, 0, 0, 0, 1); + ((ServerWorld) world).sendParticles(particleData, vec.x, vec.y, vec.z, 20, 0, 0, 0, 1); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java index 6878a5167..ec172249f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java @@ -78,7 +78,7 @@ public abstract class KineticTileEntity extends SmartTileEntity @Override public void initialize() { - if (hasNetwork() && !world.isRemote) { + if (hasNetwork() && !level.isClientSide) { KineticNetwork network = getOrCreateNetwork(); if (!network.initialized) network.initFromTE(capacity, stress, networkSize); @@ -90,13 +90,13 @@ public abstract class KineticTileEntity extends SmartTileEntity @Override public void tick() { - if (!world.isRemote && needsSpeedUpdate()) + if (!level.isClientSide && needsSpeedUpdate()) attachKinetics(); super.tick(); effects.tick(); - if (world.isRemote) { + if (level.isClientSide) { cachedBoundingBox = null; // cache the bounding box for every frame between ticks DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> this.tickAudio()); return; @@ -124,10 +124,10 @@ public abstract class KineticTileEntity extends SmartTileEntity return; } - if (!world.isBlockPresent(source)) + if (!level.isLoaded(source)) return; - TileEntity tileEntity = world.getTileEntity(source); + TileEntity tileEntity = level.getBlockEntity(source); KineticTileEntity sourceTe = tileEntity instanceof KineticTileEntity ? (KineticTileEntity) tileEntity : null; if (sourceTe == null || sourceTe.speed == 0) { @@ -184,13 +184,13 @@ public abstract class KineticTileEntity extends SmartTileEntity } @Override - public void remove() { - if (!world.isRemote) { + public void setRemoved() { + if (!level.isClientSide) { if (hasNetwork()) getOrCreateNetwork().remove(this); detachKinetics(); } - super.remove(); + super.setRemoved(); } @Override @@ -289,10 +289,10 @@ public abstract class KineticTileEntity extends SmartTileEntity public void setSource(BlockPos source) { this.source = source; - if (world == null || world.isRemote) + if (level == null || level.isClientSide) return; - TileEntity tileEntity = world.getTileEntity(source); + TileEntity tileEntity = level.getBlockEntity(source); if (!(tileEntity instanceof KineticTileEntity)) { removeSource(); return; @@ -339,11 +339,11 @@ public abstract class KineticTileEntity extends SmartTileEntity public void attachKinetics() { updateSpeed = false; - RotationPropagator.handleAdded(world, pos, this); + RotationPropagator.handleAdded(level, worldPosition, this); } public void detachKinetics() { - RotationPropagator.handleRemoved(world, pos, this); + RotationPropagator.handleRemoved(level, worldPosition, this); } public boolean isSpeedRequirementFulfilled() { @@ -362,17 +362,17 @@ public abstract class KineticTileEntity extends SmartTileEntity } public static void switchToBlockState(World world, BlockPos pos, BlockState state) { - if (world.isRemote) + if (world.isClientSide) return; - TileEntity tileEntityIn = world.getTileEntity(pos); + TileEntity tileEntityIn = world.getBlockEntity(pos); BlockState currentState = world.getBlockState(pos); boolean isKinetic = tileEntityIn instanceof KineticTileEntity; if (currentState == state) return; if (tileEntityIn == null || !isKinetic) { - world.setBlockState(pos, state, 3); + world.setBlock(pos, state, 3); return; } @@ -386,7 +386,7 @@ public abstract class KineticTileEntity extends SmartTileEntity tileEntity.removeSource(); } - world.setBlockState(pos, state, 3); + world.setBlock(pos, state, 3); } @Override @@ -397,27 +397,27 @@ public abstract class KineticTileEntity extends SmartTileEntity boolean notFastEnough = !isSpeedRequirementFulfilled() && getSpeed() != 0; if (overStressed && AllConfigs.CLIENT.enableOverstressedTooltip.get()) { - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.stressometer.overstressed") - .formatted(GOLD))); + .withStyle(GOLD))); ITextComponent hint = Lang.translate("gui.contraptions.network_overstressed"); List cutString = TooltipHelper.cutTextComponent(hint, GRAY, TextFormatting.WHITE); for (int i = 0; i < cutString.size(); i++) - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(cutString.get(i))); return true; } if (notFastEnough) { - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.speedRequirement") - .formatted(GOLD))); + .withStyle(GOLD))); ITextComponent hint = - Lang.translate("gui.contraptions.not_fast_enough", I18n.format(getBlockState().getBlock() - .getTranslationKey())); + Lang.translate("gui.contraptions.not_fast_enough", I18n.get(getBlockState().getBlock() + .getDescriptionId())); List cutString = TooltipHelper.cutTextComponent(hint, GRAY, TextFormatting.WHITE); for (int i = 0; i < cutString.size(); i++) - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(cutString.get(i))); return true; } @@ -431,21 +431,21 @@ public abstract class KineticTileEntity extends SmartTileEntity float stressAtBase = calculateStressApplied(); if (calculateStressApplied() != 0 && StressImpact.isEnabled()) { - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.goggles.kinetic_stats"))); - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.stressImpact") - .formatted(TextFormatting.GRAY))); + .withStyle(TextFormatting.GRAY))); float stressTotal = stressAtBase * Math.abs(getTheoreticalSpeed()); - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(new StringTextComponent(" " + IHaveGoggleInformation.format(stressTotal)) .append(Lang.translate("generic.unit.stress")) .append(" ") - .formatted(TextFormatting.AQUA)) + .withStyle(TextFormatting.AQUA)) .append(Lang.translate("gui.goggles.at_current_speed") - .formatted(TextFormatting.DARK_GRAY))); + .withStyle(TextFormatting.DARK_GRAY))); added = true; } @@ -526,13 +526,13 @@ public abstract class KineticTileEntity extends SmartTileEntity return neighbours; Axis axis = block.getRotationAxis(state); - BlockPos.getAllInBox(new BlockPos(-1, -1, -1), new BlockPos(1, 1, 1)) + BlockPos.betweenClosedStream(new BlockPos(-1, -1, -1), new BlockPos(1, 1, 1)) .forEach(offset -> { - if (axis.getCoordinate(offset.getX(), offset.getY(), offset.getZ()) != 0) + if (axis.choose(offset.getX(), offset.getY(), offset.getZ()) != 0) return; - if (offset.distanceSq(0, 0, 0, false) != BlockPos.ZERO.distanceSq(1, 1, 0, false)) + if (offset.distSqr(0, 0, 0, false) != BlockPos.ZERO.distSqr(1, 1, 0, false)) return; - neighbours.add(pos.add(offset)); + neighbours.add(worldPosition.offset(offset)); }); return neighbours; } @@ -560,7 +560,7 @@ public abstract class KineticTileEntity extends SmartTileEntity @Override public void requestModelDataUpdate() { super.requestModelDataUpdate(); - if (!this.removed) + if (!this.remove) DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); } @@ -586,15 +586,16 @@ public abstract class KineticTileEntity extends SmartTileEntity float pitch = MathHelper.clamp((componentSpeed / 256f) + .45f, .85f, 1f); if (isNoisy()) - SoundScapes.play(AmbienceGroup.KINETIC, pos, pitch); + SoundScapes.play(AmbienceGroup.KINETIC, worldPosition, pitch); Block block = getBlockState().getBlock(); if (ICogWheel.isSmallCog(block) || ICogWheel.isLargeCog(block) || block instanceof GearboxBlock) - SoundScapes.play(AmbienceGroup.COG, pos, pitch); + SoundScapes.play(AmbienceGroup.COG, worldPosition, pitch); } protected boolean isNoisy() { return true; } + } 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 213c8f91d..91dc9f7ee 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 @@ -39,9 +39,9 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer extends T public static BlockState shaft(Direction.Axis axis) { return AllBlocks.SHAFT.getDefaultState() - .with(ShaftBlock.AXIS, axis); + .setValue(ShaftBlock.AXIS, axis); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatedPillarKineticBlock.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatedPillarKineticBlock.java index 75c45893c..beb855895 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatedPillarKineticBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatedPillarKineticBlock.java @@ -12,14 +12,16 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.Rotation; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class RotatedPillarKineticBlock extends KineticBlock { public static final EnumProperty AXIS = BlockStateProperties.AXIS; public RotatedPillarKineticBlock(Properties properties) { super(properties); - this.setDefaultState(this.getDefaultState() - .with(AXIS, Direction.Axis.Y)); + this.registerDefaultState(this.defaultBlockState() + .setValue(AXIS, Direction.Axis.Y)); } @Override @@ -27,11 +29,11 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock { switch (rot) { case COUNTERCLOCKWISE_90: case CLOCKWISE_90: - switch (state.get(AXIS)) { + switch (state.getValue(AXIS)) { case X: - return state.with(AXIS, Direction.Axis.Z); + return state.setValue(AXIS, Direction.Axis.Z); case Z: - return state.with(AXIS, Direction.Axis.X); + return state.setValue(AXIS, Direction.Axis.X); default: return state; } @@ -43,12 +45,12 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock { public static Axis getPreferredAxis(BlockItemUseContext context) { Axis prefferedAxis = null; for (Direction side : Iterate.directions) { - BlockState blockState = context.getWorld() - .getBlockState(context.getPos() - .offset(side)); + BlockState blockState = context.getLevel() + .getBlockState(context.getClickedPos() + .relative(side)); if (blockState.getBlock() instanceof IRotate) { - if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), context.getPos() - .offset(side), blockState, side.getOpposite())) + if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getLevel(), context.getClickedPos() + .relative(side), blockState, side.getOpposite())) if (prefferedAxis != null && prefferedAxis != side.getAxis()) { prefferedAxis = null; break; @@ -61,7 +63,7 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock { } @Override - protected void fillStateContainer(StateContainer.Builder builder) { + protected void createBlockStateDefinition(StateContainer.Builder builder) { builder.add(AXIS); } @@ -69,12 +71,12 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock { public BlockState getStateForPlacement(BlockItemUseContext context) { Axis preferredAxis = getPreferredAxis(context); if (preferredAxis != null && (context.getPlayer() == null || !context.getPlayer() - .isSneaking())) - return this.getDefaultState() - .with(AXIS, preferredAxis); - return this.getDefaultState() - .with(AXIS, preferredAxis != null && context.getPlayer() - .isSneaking() ? context.getFace() + .isShiftKeyDown())) + return this.defaultBlockState() + .setValue(AXIS, preferredAxis); + return this.defaultBlockState() + .setValue(AXIS, preferredAxis != null && context.getPlayer() + .isShiftKeyDown() ? context.getClickedFace() .getAxis() : context.getNearestLookingDirection() .getAxis()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java index 443168be0..b155b5fba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java @@ -16,13 +16,13 @@ public class RotatingData extends KineticData { } public RotatingData setRotationAxis(Direction.Axis axis) { - Direction orientation = Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis); - setRotationAxis(orientation.getUnitVector()); + Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis); + setRotationAxis(orientation.step()); return this; } public RotatingData setRotationAxis(Vector3f axis) { - setRotationAxis(axis.getX(), axis.getY(), axis.getZ()); + setRotationAxis(axis.x(), axis.y(), axis.z()); return this; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/AssemblyOperatorBlockItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/AssemblyOperatorBlockItem.java index fcba185b0..ea2eedcec 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/AssemblyOperatorBlockItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/AssemblyOperatorBlockItem.java @@ -12,6 +12,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.item.Item.Properties; + public class AssemblyOperatorBlockItem extends BlockItem { public AssemblyOperatorBlockItem(Block block, Properties builder) { @@ -19,15 +21,15 @@ public class AssemblyOperatorBlockItem extends BlockItem { } @Override - public ActionResultType tryPlace(BlockItemUseContext context) { - BlockPos placedOnPos = context.getPos() - .offset(context.getFace() + public ActionResultType place(BlockItemUseContext context) { + BlockPos placedOnPos = context.getClickedPos() + .relative(context.getClickedFace() .getOpposite()); - BlockState placedOnState = context.getWorld() + BlockState placedOnState = context.getLevel() .getBlockState(placedOnPos); if (operatesOn(placedOnState)) { - if (context.getWorld() - .getBlockState(placedOnPos.up(2)) + if (context.getLevel() + .getBlockState(placedOnPos.above(2)) .getMaterial() .isReplaceable()) context = adjustContext(context, placedOnPos); @@ -35,12 +37,12 @@ public class AssemblyOperatorBlockItem extends BlockItem { return ActionResultType.FAIL; } - return super.tryPlace(context); + return super.place(context); } protected BlockItemUseContext adjustContext(BlockItemUseContext context, BlockPos placedOnPos) { - BlockPos up = placedOnPos.up(2); - return new AssemblyOperatorUseContext(context.getWorld(), context.getPlayer(), context.getHand(), context.getItem(), new BlockRayTraceResult(new Vector3d((double)up.getX() + 0.5D + (double) Direction.UP.getXOffset() * 0.5D, (double)up.getY() + 0.5D + (double) Direction.UP.getYOffset() * 0.5D, (double)up.getZ() + 0.5D + (double) Direction.UP.getZOffset() * 0.5D), Direction.UP, up, false)); + BlockPos up = placedOnPos.above(2); + return new AssemblyOperatorUseContext(context.getLevel(), context.getPlayer(), context.getHand(), context.getItemInHand(), new BlockRayTraceResult(new Vector3d((double)up.getX() + 0.5D + (double) Direction.UP.getStepX() * 0.5D, (double)up.getY() + 0.5D + (double) Direction.UP.getStepY() * 0.5D, (double)up.getZ() + 0.5D + (double) Direction.UP.getStepZ() * 0.5D), Direction.UP, up, false)); } protected boolean operatesOn(BlockState placedOnState) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java index dd8c01e8e..cc3e6535c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java @@ -66,7 +66,7 @@ public class ActorData extends InstanceData { } public ActorData setRotationAxis(Vector3f axis) { - setRotationAxis(axis.getX(), axis.getY(), axis.getZ()); + setRotationAxis(axis.x(), axis.y(), axis.z()); return this; } @@ -79,7 +79,7 @@ public class ActorData extends InstanceData { } public ActorData setRotationCenter(Vector3f axis) { - setRotationCenter(axis.getX(), axis.getY(), axis.getZ()); + setRotationCenter(axis.x(), axis.y(), axis.z()); return this; } @@ -92,10 +92,10 @@ public class ActorData extends InstanceData { } public ActorData setLocalRotation(Quaternion q) { - this.qX = q.getX(); - this.qY = q.getY(); - this.qZ = q.getZ(); - this.qW = q.getW(); + this.qX = q.i(); + this.qY = q.j(); + this.qZ = q.k(); + this.qW = q.r(); markDirty(); return this; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/AttachedActorBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/AttachedActorBlock.java index c9ea4bac8..3ad9dfa6d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/AttachedActorBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/AttachedActorBlock.java @@ -22,6 +22,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public abstract class AttachedActorBlock extends HorizontalBlock implements IWrenchable { @@ -37,41 +39,41 @@ public abstract class AttachedActorBlock extends HorizontalBlock implements IWre @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - Direction direction = state.get(HORIZONTAL_FACING); + Direction direction = state.getValue(FACING); return AllShapes.HARVESTER_BASE.get(direction); } @Override - protected void fillStateContainer(Builder builder) { - builder.add(HORIZONTAL_FACING); - super.fillStateContainer(builder); + protected void createBlockStateDefinition(Builder builder) { + builder.add(FACING); + super.createBlockStateDefinition(builder); } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - Direction direction = state.get(HORIZONTAL_FACING); - BlockPos offset = pos.offset(direction.getOpposite()); + public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + Direction direction = state.getValue(FACING); + BlockPos offset = pos.relative(direction.getOpposite()); return BlockHelper.hasBlockSolidSide(worldIn.getBlockState(offset), worldIn, offset, direction); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Direction facing; - if (context.getFace().getAxis().isVertical()) - facing = context.getPlacementHorizontalFacing().getOpposite(); + if (context.getClickedFace().getAxis().isVertical()) + facing = context.getHorizontalDirection().getOpposite(); else { BlockState blockState = - context.getWorld().getBlockState(context.getPos().offset(context.getFace().getOpposite())); + context.getLevel().getBlockState(context.getClickedPos().relative(context.getClickedFace().getOpposite())); if (blockState.getBlock() instanceof AttachedActorBlock) - facing = blockState.get(HORIZONTAL_FACING); + facing = blockState.getValue(FACING); else - facing = context.getFace(); + facing = context.getClickedFace(); } - return getDefaultState().with(HORIZONTAL_FACING, facing); + return defaultBlockState().setValue(FACING, facing); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/BellMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/BellMovementBehaviour.java index 10ab639cd..b635039d8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/BellMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/BellMovementBehaviour.java @@ -20,7 +20,7 @@ public class BellMovementBehaviour extends MovementBehaviour { @Override public void onSpeedChanged(MovementContext context, Vector3d oldMotion, Vector3d motion) { - double dotProduct = oldMotion.dotProduct(motion); + double dotProduct = oldMotion.dot(motion); if (dotProduct <= 0 && (context.relativeMotion.length() != 0) || context.firstMovement) playSound(context); @@ -41,7 +41,7 @@ public class BellMovementBehaviour extends MovementBehaviour { ((AbstractBellBlock) block).playSound(world, pos); } else { // Vanilla bell sound - world.playSound(null, pos, SoundEvents.BLOCK_BELL_USE, + world.playSound(null, pos, SoundEvents.BELL_BLOCK, SoundCategory.BLOCKS, 2f, 1f); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/BlockBreakingKineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/BlockBreakingKineticTileEntity.java index a74d1a200..a9b11e083 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/BlockBreakingKineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/BlockBreakingKineticTileEntity.java @@ -77,17 +77,17 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity { } @Override - public void remove() { - if (!world.isRemote && destroyProgress != 0) - world.sendBlockBreakProgress(breakerId, breakingPos, -1); - super.remove(); + public void setRemoved() { + if (!level.isClientSide && destroyProgress != 0) + level.destroyBlockProgress(breakerId, breakingPos, -1); + super.setRemoved(); } @Override public void tick() { super.tick(); - if (world.isRemote) + if (level.isClientSide) return; if (!shouldRun()) return; @@ -101,31 +101,31 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity { if (ticksUntilNextProgress-- > 0) return; - BlockState stateToBreak = world.getBlockState(breakingPos); - float blockHardness = stateToBreak.getBlockHardness(world, breakingPos); + BlockState stateToBreak = level.getBlockState(breakingPos); + float blockHardness = stateToBreak.getDestroySpeed(level, breakingPos); if (!canBreak(stateToBreak, blockHardness)) { if (destroyProgress != 0) { destroyProgress = 0; - world.sendBlockBreakProgress(breakerId, breakingPos, -1); + level.destroyBlockProgress(breakerId, breakingPos, -1); } return; } float breakSpeed = getBreakSpeed(); destroyProgress += MathHelper.clamp((int) (breakSpeed / blockHardness), 1, 10 - destroyProgress); - world.playSound(null, pos, stateToBreak.getSoundType().getHitSound(), SoundCategory.NEUTRAL, .25f, 1); + level.playSound(null, worldPosition, stateToBreak.getSoundType().getHitSound(), SoundCategory.NEUTRAL, .25f, 1); if (destroyProgress >= 10) { onBlockBroken(stateToBreak); destroyProgress = 0; ticksUntilNextProgress = -1; - world.sendBlockBreakProgress(breakerId, breakingPos, -1); + level.destroyBlockProgress(breakerId, breakingPos, -1); return; } ticksUntilNextProgress = (int) (blockHardness / breakSpeed); - world.sendBlockBreakProgress(breakerId, breakingPos, (int) destroyProgress); + level.destroyBlockProgress(breakerId, breakingPos, (int) destroyProgress); } public boolean canBreak(BlockState stateToBreak, float blockHardness) { @@ -138,23 +138,23 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity { } public void onBlockBroken(BlockState stateToBreak) { - FluidState FluidState = world.getFluidState(breakingPos); - world.playEvent(2001, breakingPos, Block.getStateId(stateToBreak)); - TileEntity tileentity = stateToBreak.hasTileEntity() ? world.getTileEntity(breakingPos) : null; - Vector3d vec = VecHelper.offsetRandomly(VecHelper.getCenterOf(breakingPos), world.rand, .125f); + FluidState FluidState = level.getFluidState(breakingPos); + level.levelEvent(2001, breakingPos, Block.getId(stateToBreak)); + TileEntity tileentity = stateToBreak.hasTileEntity() ? level.getBlockEntity(breakingPos) : null; + Vector3d vec = VecHelper.offsetRandomly(VecHelper.getCenterOf(breakingPos), level.random, .125f); - Block.getDrops(stateToBreak, (ServerWorld) world, breakingPos, tileentity).forEach((stack) -> { - if (!stack.isEmpty() && world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS) - && !world.restoringBlockSnapshots) { - ItemEntity itementity = new ItemEntity(world, vec.x, vec.y, vec.z, stack); - itementity.setDefaultPickupDelay(); - itementity.setMotion(Vector3d.ZERO); - world.addEntity(itementity); + Block.getDrops(stateToBreak, (ServerWorld) level, breakingPos, tileentity).forEach((stack) -> { + if (!stack.isEmpty() && level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) + && !level.restoringBlockSnapshots) { + ItemEntity itementity = new ItemEntity(level, vec.x, vec.y, vec.z, stack); + itementity.setDefaultPickUpDelay(); + itementity.setDeltaMovement(Vector3d.ZERO); + level.addFreshEntity(itementity); } }); - if (world instanceof ServerWorld) - stateToBreak.spawnAdditionalDrops((ServerWorld) world, breakingPos, ItemStack.EMPTY); - world.setBlockState(breakingPos, FluidState.getBlockState(), 3); + if (level instanceof ServerWorld) + stateToBreak.spawnAfterBreak((ServerWorld) level, breakingPos, ItemStack.EMPTY); + level.setBlock(breakingPos, FluidState.createLegacyBlock(), 3); } protected float getBreakSpeed() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/BlockBreakingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/BlockBreakingMovementBehaviour.java index 419a5a577..b23ce8153 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/BlockBreakingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/BlockBreakingMovementBehaviour.java @@ -25,7 +25,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { @Override public void startMoving(MovementContext context) { - if (context.world.isRemote) + if (context.world.isClientSide) return; context.data.putInt("BreakerId", -BlockBreakingKineticTileEntity.NEXT_BREAKER_ID.incrementAndGet()); } @@ -35,9 +35,9 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { World world = context.world; BlockState stateVisited = world.getBlockState(pos); - if (!stateVisited.isNormalCube(world, pos)) + if (!stateVisited.isRedstoneConductor(world, pos)) damageEntities(context, pos, world); - if (world.isRemote) + if (world.isClientSide) return; if (!canBreak(world, pos, stateVisited)) return; @@ -50,29 +50,29 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { DamageSource damageSource = getDamageSource(); if (damageSource == null && !throwsEntities()) return; - Entities: for (Entity entity : world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos))) { + Entities: for (Entity entity : world.getEntitiesOfClass(Entity.class, new AxisAlignedBB(pos))) { if (entity instanceof ItemEntity) continue; if (entity instanceof AbstractContraptionEntity) continue; if (entity instanceof AbstractMinecartEntity) - for (Entity passenger : entity.getRecursivePassengers()) + for (Entity passenger : entity.getIndirectPassengers()) if (passenger instanceof AbstractContraptionEntity && ((AbstractContraptionEntity) passenger).getContraption() == context.contraption) continue Entities; - if (damageSource != null && !world.isRemote) { + if (damageSource != null && !world.isClientSide) { float damage = (float) MathHelper.clamp(6 * Math.pow(context.relativeMotion.length(), 0.4) + 1, 2, 10); - entity.attackEntityFrom(damageSource, damage); + entity.hurt(damageSource, damage); } - if (throwsEntities() && (world.isRemote == (entity instanceof PlayerEntity))) { + if (throwsEntities() && (world.isClientSide == (entity instanceof PlayerEntity))) { Vector3d motionBoost = context.motion.add(0, context.motion.length() / 4f, 0); int maxBoost = 4; if (motionBoost.length() > maxBoost) { motionBoost = motionBoost.subtract(motionBoost.normalize().scale(motionBoost.length() - maxBoost)); } - entity.setMotion(entity.getMotion().add(motionBoost)); - entity.velocityChanged = true; + entity.setDeltaMovement(entity.getDeltaMovement().add(motionBoost)); + entity.hurtMarked = true; } } } @@ -88,7 +88,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { @Override public void stopMoving(MovementContext context) { CompoundNBT data = context.data; - if (context.world.isRemote) + if (context.world.isClientSide) return; if (!data.contains("BreakingPos")) return; @@ -102,7 +102,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { data.remove("BreakingPos"); context.stall = false; - world.sendBlockBreakProgress(id, breakingPos, -1); + world.destroyBlockProgress(id, breakingPos, -1); } @Override @@ -129,7 +129,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { public void tickBreaker(MovementContext context) { CompoundNBT data = context.data; - if (context.world.isRemote) + if (context.world.isClientSide) return; if (!data.contains("BreakingPos")) return; @@ -149,7 +149,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { int destroyProgress = data.getInt("Progress"); int id = data.getInt("BreakerId"); BlockState stateToBreak = world.getBlockState(breakingPos); - float blockHardness = stateToBreak.getBlockHardness(world, breakingPos); + float blockHardness = stateToBreak.getDestroySpeed(world, breakingPos); if (!canBreak(world, breakingPos, stateToBreak)) { if (destroyProgress != 0) { @@ -157,7 +157,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { data.remove("Progress"); data.remove("TicksUntilNextProgress"); data.remove("BreakingPos"); - world.sendBlockBreakProgress(id, breakingPos, -1); + world.destroyBlockProgress(id, breakingPos, -1); } context.stall = false; return; @@ -168,14 +168,14 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { world.playSound(null, breakingPos, stateToBreak.getSoundType().getHitSound(), SoundCategory.NEUTRAL, .25f, 1); if (destroyProgress >= 10) { - world.sendBlockBreakProgress(id, breakingPos, -1); + world.destroyBlockProgress(id, breakingPos, -1); // break falling blocks from top to bottom BlockPos ogPos = breakingPos; - BlockState stateAbove = world.getBlockState(breakingPos.up()); + BlockState stateAbove = world.getBlockState(breakingPos.above()); while (stateAbove.getBlock() instanceof FallingBlock) { - breakingPos = breakingPos.up(); - stateAbove = world.getBlockState(breakingPos.up()); + breakingPos = breakingPos.above(); + stateAbove = world.getBlockState(breakingPos.above()); } stateToBreak = world.getBlockState(breakingPos); @@ -191,7 +191,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { } ticksUntilNextProgress = (int) (blockHardness / breakSpeed); - world.sendBlockBreakProgress(id, breakingPos, (int) destroyProgress); + world.destroyBlockProgress(id, breakingPos, (int) destroyProgress); data.putInt("TicksUntilNextProgress", ticksUntilNextProgress); data.putInt("Progress", destroyProgress); } @@ -201,7 +201,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { } public boolean canBreak(World world, BlockPos breakingPos, BlockState state) { - float blockHardness = state.getBlockHardness(world, breakingPos); + float blockHardness = state.getDestroySpeed(world, breakingPos); return BlockBreakingKineticTileEntity.isBreakable(state, blockHardness); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/CampfireMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/CampfireMovementBehaviour.java index e27cffee5..39ac14bce 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/CampfireMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/CampfireMovementBehaviour.java @@ -16,20 +16,20 @@ public class CampfireMovementBehaviour extends MovementBehaviour { @Override public void tick(MovementContext context) { - if (context.world == null || !context.world.isRemote || context.position == null - || !context.state.get(CampfireBlock.LIT)) + if (context.world == null || !context.world.isClientSide || context.position == null + || !context.state.getValue(CampfireBlock.LIT)) return; // Mostly copied from CampfireBlock and CampfireTileEntity - Random random = context.world.rand; + Random random = context.world.random; if (random.nextFloat() < 0.11F) { for (int i = 0; i < random.nextInt(2) + 2; ++i) { - context.world.addOptionalParticle( - context.state.get(CampfireBlock.SIGNAL_FIRE) ? ParticleTypes.CAMPFIRE_SIGNAL_SMOKE + context.world.addAlwaysVisibleParticle( + context.state.getValue(CampfireBlock.SIGNAL_FIRE) ? ParticleTypes.CAMPFIRE_SIGNAL_SMOKE : ParticleTypes.CAMPFIRE_COSY_SMOKE, - true, context.position.getX() + random.nextDouble() / (random.nextBoolean() ? 3D : -3D), - context.position.getY() + random.nextDouble() + random.nextDouble(), - context.position.getZ() + random.nextDouble() / (random.nextBoolean() ? 3D : -3D), 0.0D, 0.07D, + true, context.position.x() + random.nextDouble() / (random.nextBoolean() ? 3D : -3D), + context.position.y() + random.nextDouble() + random.nextDouble(), + context.position.z() + random.nextDouble() / (random.nextBoolean() ? 3D : -3D), 0.0D, 0.07D, 0.0D); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java index 316d7eed2..c1458d1e4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java @@ -26,7 +26,7 @@ public class DrillActorInstance extends ActorInstance { BlockState state = context.state; - facing = state.get(DrillBlock.FACING); + facing = state.getValue(DrillBlock.FACING); Direction.Axis axis = facing.getAxis(); float eulerX = AngleHelper.verticalAngle(facing); @@ -35,7 +35,7 @@ public class DrillActorInstance extends ActorInstance { if (axis == Direction.Axis.Y) eulerY = 0; else - eulerY = facing.getHorizontalAngle() + ((axis == Direction.Axis.X) ? 180 : 0); + eulerY = facing.toYRot() + ((axis == Direction.Axis.X) ? 180 : 0); drillHead = instanceMaterial.getModel(AllBlockPartials.DRILL_HEAD, state).createInstance(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillBlock.java index b7c9d029a..65efab837 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillBlock.java @@ -27,10 +27,12 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class DrillBlock extends DirectionalKineticBlock implements ITE { - public static DamageSource damageSourceDrill = new DamageSource("create.mechanical_drill").setDamageBypassesArmor(); + public static DamageSource damageSourceDrill = new DamageSource("create.mechanical_drill").bypassArmor(); public DrillBlock(Properties properties) { super(properties); @@ -42,15 +44,15 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE { if (te.getSpeed() == 0) return; - entityIn.attackEntityFrom(damageSourceDrill, (float) getDamage(te.getSpeed())); + entityIn.hurt(damageSourceDrill, (float) getDamage(te.getSpeed())); }); } @@ -61,7 +63,7 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE getModel() { BlockState referenceState = tile.getBlockState(); - Direction facing = referenceState.get(FACING); + Direction facing = referenceState.getValue(FACING); return getRotatingMaterial().getModel(AllBlockPartials.DRILL_HEAD, referenceState, facing); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java index cda9e9a75..ad88f0c32 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java @@ -23,14 +23,14 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour { @Override public boolean isActive(MovementContext context) { - return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.get(DrillBlock.FACING) + return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(DrillBlock.FACING) .getOpposite()); } @Override public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.of(context.state.get(DrillBlock.FACING) - .getDirectionVec()).scale(.65f); + return Vector3d.atLowerCornerOf(context.state.getValue(DrillBlock.FACING) + .getNormal()).scale(.65f); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java index df1e668d9..af8bd9be0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java @@ -36,7 +36,7 @@ public class DrillRenderer extends KineticTileEntityRenderer { ContraptionMatrices matrices, IRenderTypeBuffer buffer) { BlockState state = context.state; SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.DRILL_HEAD, state); - Direction facing = state.get(DrillBlock.FACING); + Direction facing = state.getValue(DrillBlock.FACING); float speed = (float) (context.contraption.stalled || !VecHelper.isVecPointingTowards(context.relativeMotion, facing @@ -45,7 +45,7 @@ public class DrillRenderer extends KineticTileEntityRenderer { float angle = (float) (((time * speed) % 360)); MatrixStack m = matrices.contraptionStack; - m.push(); + m.pushPose(); MatrixStacker.of(m) .centre() .rotateY(AngleHelper.horizontalAngle(facing)) @@ -57,9 +57,9 @@ public class DrillRenderer extends KineticTileEntityRenderer { .transform(m) .light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) - .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getSolid())); + .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.solid())); - m.pop(); + m.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillTileEntity.java index 065d18491..6c124890e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillTileEntity.java @@ -11,7 +11,7 @@ public class DrillTileEntity extends BlockBreakingKineticTileEntity { @Override protected BlockPos getBreakingPos() { - return getPos().offset(getBlockState().get(DrillBlock.FACING)); + return getBlockPos().relative(getBlockState().getValue(DrillBlock.FACING)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java index fafd7c7e2..e3b7235ea 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java @@ -40,11 +40,11 @@ public class HarvesterActorInstance extends ActorInstance { BlockState state = context.state; - facing = state.get(HORIZONTAL_FACING); + facing = state.getValue(HORIZONTAL_FACING); harvester = instanceMaterial.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance(); - horizontalAngle = facing.getHorizontalAngle() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0); + horizontalAngle = facing.toYRot() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0); harvester.setBlockLight(localBlockLight()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterBlock.java index 8f6182917..978928e91 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterBlock.java @@ -6,6 +6,8 @@ import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockReader; +import net.minecraft.block.AbstractBlock.Properties; + public class HarvesterBlock extends AttachedActorBlock { public HarvesterBlock(Properties p_i48377_1_) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java index 0aed0b128..fdb268f4e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.actors; -import static net.minecraft.block.HorizontalBlock.HORIZONTAL_FACING; +import static net.minecraft.block.HorizontalBlock.FACING; import javax.annotation.Nullable; @@ -38,7 +38,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { @Override public boolean isActive(MovementContext context) { - return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.get(HORIZONTAL_FACING) + return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(FACING) .getOpposite()); } @@ -62,8 +62,8 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { @Override public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.of(context.state.get(HORIZONTAL_FACING) - .getDirectionVec()) + return Vector3d.atLowerCornerOf(context.state.getValue(FACING) + .getNormal()) .scale(.45); } @@ -73,7 +73,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { BlockState stateVisited = world.getBlockState(pos); boolean notCropButCuttable = false; - if (world.isRemote) + if (world.isClientSide) return; if (!isValidCrop(world, pos, stateVisited)) { @@ -86,14 +86,14 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { MutableBoolean seedSubtracted = new MutableBoolean(notCropButCuttable); BlockState state = stateVisited; BlockHelper.destroyBlock(world, pos, 1, stack -> { - if (!seedSubtracted.getValue() && stack.isItemEqual(new ItemStack(state.getBlock()))) { + if (!seedSubtracted.getValue() && stack.sameItem(new ItemStack(state.getBlock()))) { stack.shrink(1); seedSubtracted.setTrue(); } dropItem(context, stack); }); - world.setBlockState(pos, cutCrop(world, pos, stateVisited)); + world.setBlockAndUpdate(pos, cutCrop(world, pos, stateVisited)); } private boolean isValidCrop(World world, BlockPos pos, BlockState state) { @@ -109,10 +109,10 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { if (!(property instanceof IntegerProperty)) continue; if (!property.getName() - .equals(BlockStateProperties.AGE_0_1.getName())) + .equals(BlockStateProperties.AGE_1.getName())) continue; - if (((IntegerProperty) property).getAllowedValues() - .size() - 1 != state.get((IntegerProperty) property) + if (((IntegerProperty) property).getPossibleValues() + .size() - 1 != state.getValue((IntegerProperty) property) .intValue()) continue; return true; @@ -139,7 +139,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { if (!(property instanceof IntegerProperty)) continue; if (!property.getName() - .equals(BlockStateProperties.AGE_0_1.getName())) + .equals(BlockStateProperties.AGE_1.getName())) continue; return false; } @@ -155,17 +155,17 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { Block block = state.getBlock(); if (block instanceof CropsBlock) { CropsBlock crop = (CropsBlock) block; - return crop.withAge(0); + return crop.getStateForAge(0); } if (block == Blocks.SWEET_BERRY_BUSH) { - return state.with(BlockStateProperties.AGE_0_3, Integer.valueOf(1)); + return state.setValue(BlockStateProperties.AGE_3, Integer.valueOf(1)); } if (block == Blocks.SUGAR_CANE || block == Blocks.KELP) { if (state.getFluidState() .isEmpty()) - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); return state.getFluidState() - .getBlockState(); + .createLegacyBlock(); } if (state.getCollisionShape(world, pos) .isEmpty() || block instanceof CocoaBlock) { @@ -173,17 +173,17 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { if (!(property instanceof IntegerProperty)) continue; if (!property.getName() - .equals(BlockStateProperties.AGE_0_1.getName())) + .equals(BlockStateProperties.AGE_1.getName())) continue; - return state.with((IntegerProperty) property, Integer.valueOf(0)); + return state.setValue((IntegerProperty) property, Integer.valueOf(0)); } } if (state.getFluidState() .isEmpty()) - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); return state.getFluidState() - .getBlockState(); + .createLegacyBlock(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java index 652e42e85..79eee6a0a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java @@ -35,16 +35,16 @@ public class HarvesterRenderer extends SafeTileEntityRenderer dropItem(context, s)); @@ -108,7 +108,7 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour { private PloughFakePlayer getPlayer(MovementContext context) { if (!(context.temporaryData instanceof PloughFakePlayer) && context.world != null) { PloughFakePlayer player = new PloughFakePlayer((ServerWorld) context.world); - player.setHeldItem(Hand.MAIN_HAND, new ItemStack(Items.DIAMOND_HOE)); + player.setItemInHand(Hand.MAIN_HAND, new ItemStack(Items.DIAMOND_HOE)); context.temporaryData = player; } return (PloughFakePlayer) context.temporaryData; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableFluidInterfaceTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableFluidInterfaceTileEntity.java index 1559bd22d..51de4cc00 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableFluidInterfaceTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableFluidInterfaceTileEntity.java @@ -10,6 +10,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.templates.FluidTank; +import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; + public class PortableFluidInterfaceTileEntity extends PortableStorageInterfaceTileEntity { protected LazyOptional capability; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceBlock.java index 7afae49c4..41263760d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceBlock.java @@ -18,6 +18,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class PortableStorageInterfaceBlock extends ProperDirectionalBlock @@ -57,22 +59,22 @@ public class PortableStorageInterfaceBlock extends ProperDirectionalBlock @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return getDefaultState().with(FACING, context.getNearestLookingDirection() + return defaultBlockState().setValue(FACING, context.getNearestLookingDirection() .getOpposite()); } @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return AllShapes.PORTABLE_STORAGE_INTERFACE.get(state.get(FACING)); + return AllShapes.PORTABLE_STORAGE_INTERFACE.get(state.getValue(FACING)); } @Override - public boolean hasComparatorInputOverride(BlockState state) { + public boolean hasAnalogOutputSignal(BlockState state) { return true; } @Override - public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { return getTileEntityOptional(worldIn, pos).map(te -> te.isConnected() ? 15 : 0) .orElse(0); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceMovement.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceMovement.java index 6bd6b8f13..c0d2a2a19 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceMovement.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceMovement.java @@ -26,8 +26,8 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { @Override public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.of(context.state.get(PortableStorageInterfaceBlock.FACING) - .getDirectionVec()).scale(1.85f); + return Vector3d.atLowerCornerOf(context.state.getValue(PortableStorageInterfaceBlock.FACING) + .getNormal()).scale(1.85f); } @Override @@ -55,13 +55,13 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { if (psi == null) return false; - if ((psi.isTransferring() || psi.isPowered()) && !context.world.isRemote) + if ((psi.isTransferring() || psi.isPowered()) && !context.world.isClientSide) return false; - context.data.put(_workingPos_, NBTUtil.writeBlockPos(psi.getPos())); - if (!context.world.isRemote) { - Vector3d diff = VecHelper.getCenterOf(psi.getPos()) + context.data.put(_workingPos_, NBTUtil.writeBlockPos(psi.getBlockPos())); + if (!context.world.isClientSide) { + Vector3d diff = VecHelper.getCenterOf(psi.getBlockPos()) .subtract(context.position); - diff = VecHelper.project(diff, Vector3d.of(currentFacing.getDirectionVec())); + diff = VecHelper.project(diff, Vector3d.atLowerCornerOf(currentFacing.getNormal())); float distance = (float) (diff.length() + 1.85f - 1); psi.startTransferringTo(context.contraption, distance); } else { @@ -72,7 +72,7 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { @Override public void tick(MovementContext context) { - if (context.world.isRemote) { + if (context.world.isClientSide) { boolean stalled = context.contraption.stalled; if (stalled && !context.data.contains(_workingPos_)) { BlockPos pos = new BlockPos(context.position); @@ -117,7 +117,7 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { Direction facing) { for (int i = 0; i < 2; i++) { PortableStorageInterfaceTileEntity interfaceAt = - getStationaryInterfaceAt(world, pos.offset(facing, i), state, facing); + getStationaryInterfaceAt(world, pos.relative(facing, i), state, facing); if (interfaceAt == null) continue; return interfaceAt; @@ -127,23 +127,23 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { private PortableStorageInterfaceTileEntity getStationaryInterfaceAt(World world, BlockPos pos, BlockState state, Direction facing) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (!(te instanceof PortableStorageInterfaceTileEntity)) return null; BlockState blockState = world.getBlockState(pos); if (blockState.getBlock() != state.getBlock()) return null; - if (blockState.get(PortableStorageInterfaceBlock.FACING) != facing.getOpposite()) + if (blockState.getValue(PortableStorageInterfaceBlock.FACING) != facing.getOpposite()) return null; return (PortableStorageInterfaceTileEntity) te; } private Optional getCurrentFacingIfValid(MovementContext context) { - Vector3d directionVec = Vector3d.of(context.state.get(PortableStorageInterfaceBlock.FACING) - .getDirectionVec()); + Vector3d directionVec = Vector3d.atLowerCornerOf(context.state.getValue(PortableStorageInterfaceBlock.FACING) + .getNormal()); directionVec = context.rotation.apply(directionVec); - Direction facingFromVector = Direction.getFacingFromVector(directionVec.x, directionVec.y, directionVec.z); - if (directionVec.distanceTo(Vector3d.of(facingFromVector.getDirectionVec())) > 1 / 2f) + Direction facingFromVector = Direction.getNearest(directionVec.x, directionVec.y, directionVec.z); + if (directionVec.distanceTo(Vector3d.atLowerCornerOf(facingFromVector.getNormal())) > 1 / 2f) return Optional.empty(); return Optional.of(facingFromVector); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java index 287b2314f..edf462cb4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java @@ -37,7 +37,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer sbb.light(light) .renderInto(ms, vb)); } @@ -46,7 +46,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer dynamicTree = TreeCutter.findDynamicTree(brokenState.getBlock(), pos); @@ -80,8 +80,8 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { Vector3d dropPos = VecHelper.getCenterOf(pos); float distance = (float) dropPos.distanceTo(context.position); ItemEntity entity = new ItemEntity(world, dropPos.x, dropPos.y, dropPos.z, remainder); - entity.setMotion(context.relativeMotion.scale(distance / 20f)); - world.addEntity(entity); + entity.setDeltaMovement(context.relativeMotion.scale(distance / 20f)); + world.addFreshEntity(entity); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatBlock.java index bd2f0001c..048ee7125 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatBlock.java @@ -33,6 +33,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class SeatBlock extends Block { @@ -45,28 +47,28 @@ public class SeatBlock extends Block { } @Override - public void fillItemGroup(ItemGroup group, NonNullList p_149666_2_) { - if (group != ItemGroup.SEARCH && !inCreativeTab) + public void fillItemCategory(ItemGroup group, NonNullList p_149666_2_) { + if (group != ItemGroup.TAB_SEARCH && !inCreativeTab) return; - super.fillItemGroup(group, p_149666_2_); + super.fillItemCategory(group, p_149666_2_); } @Override - public void onFallenUpon(World p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { - super.onFallenUpon(p_180658_1_, p_180658_2_, p_180658_3_, p_180658_4_ * 0.5F); + public void fallOn(World p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { + super.fallOn(p_180658_1_, p_180658_2_, p_180658_3_, p_180658_4_ * 0.5F); } @Override - public void onLanded(IBlockReader reader, Entity entity) { - BlockPos pos = entity.getBlockPos(); - if (entity instanceof PlayerEntity || !(entity instanceof LivingEntity) || !canBePickedUp(entity) || isSeatOccupied(entity.world, pos)) { - Blocks.PINK_BED.onLanded(reader, entity); + public void updateEntityAfterFallOn(IBlockReader reader, Entity entity) { + BlockPos pos = entity.blockPosition(); + if (entity instanceof PlayerEntity || !(entity instanceof LivingEntity) || !canBePickedUp(entity) || isSeatOccupied(entity.level, pos)) { + Blocks.PINK_BED.updateEntityAfterFallOn(reader, entity); return; } if (reader.getBlockState(pos) .getBlock() != this) return; - sitDown(entity.world, pos, entity); + sitDown(entity.level, pos, entity); } @Override @@ -88,46 +90,46 @@ public class SeatBlock extends Block { } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult p_225533_6_) { - if (player.isSneaking()) + if (player.isShiftKeyDown()) return ActionResultType.PASS; - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); for (DyeColor color : DyeColor.values()) { if (!heldItem.getItem() - .isIn(DyeHelper.getTagOfDye(color))) + .is(DyeHelper.getTagOfDye(color))) continue; - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; BlockState newState = AllBlocks.SEATS.get(color).getDefaultState(); if (newState != state) - world.setBlockState(pos, newState); + world.setBlockAndUpdate(pos, newState); return ActionResultType.SUCCESS; } - List seats = world.getEntitiesWithinAABB(SeatEntity.class, new AxisAlignedBB(pos)); + List seats = world.getEntitiesOfClass(SeatEntity.class, new AxisAlignedBB(pos)); if (!seats.isEmpty()) { SeatEntity seatEntity = seats.get(0); List passengers = seatEntity.getPassengers(); if (!passengers.isEmpty() && passengers.get(0) instanceof PlayerEntity) return ActionResultType.PASS; - if (!world.isRemote) { - seatEntity.removePassengers(); + if (!world.isClientSide) { + seatEntity.ejectPassengers(); player.startRiding(seatEntity); } return ActionResultType.SUCCESS; } - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; sitDown(world, pos, player); return ActionResultType.SUCCESS; } public static boolean isSeatOccupied(World world, BlockPos pos) { - return !world.getEntitiesWithinAABB(SeatEntity.class, new AxisAlignedBB(pos)) + return !world.getEntitiesOfClass(SeatEntity.class, new AxisAlignedBB(pos)) .isEmpty(); } @@ -136,16 +138,16 @@ public class SeatBlock extends Block { } public static void sitDown(World world, BlockPos pos, Entity entity) { - if (world.isRemote) + if (world.isClientSide) return; SeatEntity seat = new SeatEntity(world, pos); - seat.setPos(pos.getX() + .5f, pos.getY(), pos.getZ() + .5f); - world.addEntity(seat); + seat.setPosRaw(pos.getX() + .5f, pos.getY(), pos.getZ() + .5f); + world.addFreshEntity(seat); entity.startRiding(seat, true); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatEntity.java index b5dea8fcd..9777aedd8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatEntity.java @@ -27,13 +27,13 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData { public SeatEntity(World world, BlockPos pos) { this(AllEntityTypes.SEAT.get(), world); - noClip = true; + noPhysics = true; } public static EntityType.Builder build(EntityType.Builder builder) { @SuppressWarnings("unchecked") EntityType.Builder entityBuilder = (EntityType.Builder) builder; - return entityBuilder.size(0.25f, 0.35f); + return entityBuilder.sized(0.25f, 0.35f); } @Override @@ -42,29 +42,29 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData { } @Override - public void setPos(double x, double y, double z) { - super.setPos(x, y, z); + public void setPosRaw(double x, double y, double z) { + super.setPosRaw(x, y, z); AxisAlignedBB bb = getBoundingBox(); Vector3d diff = new Vector3d(x, y, z).subtract(bb.getCenter()); - setBoundingBox(bb.offset(diff)); + setBoundingBox(bb.move(diff)); } @Override - public void setMotion(Vector3d p_213317_1_) {} + public void setDeltaMovement(Vector3d p_213317_1_) {} @Override public void tick() { - if (world.isRemote) + if (level.isClientSide) return; - boolean blockPresent = world.getBlockState(getBlockPos()) + boolean blockPresent = level.getBlockState(blockPosition()) .getBlock() instanceof SeatBlock; - if (isBeingRidden() && blockPresent) + if (isVehicle() && blockPresent) return; this.remove(); } @Override - protected boolean canBeRidden(Entity entity) { + protected boolean canRide(Entity entity) { // Fake Players (tested with deployers) have a BUNCH of weird issues, don't let them ride seats return !(entity instanceof FakePlayer); } @@ -72,21 +72,21 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData { @Override protected void removePassenger(Entity entity) { super.removePassenger(entity); - Vector3d pos = entity.getPositionVec(); - entity.setPosition(pos.x, pos.y + 0.85f, pos.z); + Vector3d pos = entity.position(); + entity.setPos(pos.x, pos.y + 0.85f, pos.z); } @Override - protected void registerData() {} + protected void defineSynchedData() {} @Override - protected void readAdditional(CompoundNBT p_70037_1_) {} + protected void readAdditionalSaveData(CompoundNBT p_70037_1_) {} @Override - protected void writeAdditional(CompoundNBT p_213281_1_) {} + protected void addAdditionalSaveData(CompoundNBT p_213281_1_) {} @Override - public IPacket createSpawnPacket() { + public IPacket getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @@ -102,7 +102,7 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData { } @Override - public ResourceLocation getEntityTexture(SeatEntity p_110775_1_) { + public ResourceLocation getTextureLocation(SeatEntity p_110775_1_) { return null; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatMovementBehaviour.java index e2143baf2..84776eb68 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SeatMovementBehaviour.java @@ -40,8 +40,8 @@ public class SeatMovementBehaviour extends MovementBehaviour { Map seatMapping = context.contraption.getSeatMapping(); BlockState blockState = context.world.getBlockState(pos); - boolean slab = blockState.getBlock() instanceof SlabBlock && blockState.get(SlabBlock.TYPE) == SlabType.BOTTOM; - boolean solid = blockState.isSolid() || slab; + boolean slab = blockState.getBlock() instanceof SlabBlock && blockState.getValue(SlabBlock.TYPE) == SlabType.BOTTOM; + boolean solid = blockState.canOcclude() || slab; // Occupied if (seatMapping.containsValue(index)) { @@ -53,7 +53,7 @@ public class SeatMovementBehaviour extends MovementBehaviour { continue; for (Entity entity : contraptionEntity.getPassengers()) { if (!entry.getKey() - .equals(entity.getUniqueID())) + .equals(entity.getUUID())) continue; toDismount = entity; } @@ -62,7 +62,7 @@ public class SeatMovementBehaviour extends MovementBehaviour { toDismount.stopRiding(); Vector3d position = VecHelper.getCenterOf(pos) .add(0, slab ? .5f : 1f, 0); - toDismount.setPositionAndUpdate(position.x, position.y, position.z); + toDismount.teleportTo(position.x, position.y, position.z); toDismount.getPersistentData() .remove("ContraptionDismountLocation"); } @@ -72,8 +72,8 @@ public class SeatMovementBehaviour extends MovementBehaviour { if (solid) return; - List nearbyEntities = context.world.getEntitiesWithinAABB(Entity.class, - new AxisAlignedBB(pos).shrink(1 / 16f), SeatBlock::canBePickedUp); + List nearbyEntities = context.world.getEntitiesOfClass(Entity.class, + new AxisAlignedBB(pos).deflate(1 / 16f), SeatBlock::canBePickedUp); if (!nearbyEntities.isEmpty()) contraptionEntity.addSittingPassenger(nearbyEntities.get(0), index); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/ContraptionBlockSource.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/ContraptionBlockSource.java index 57bfc9449..d7660c434 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/ContraptionBlockSource.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/ContraptionBlockSource.java @@ -31,42 +31,42 @@ public class ContraptionBlockSource implements IBlockSource { } @Override - public double getX() { + public double x() { return (double)this.pos.getX() + 0.5D; } @Override - public double getY() { + public double y() { return (double)this.pos.getY() + 0.5D; } @Override - public double getZ() { + public double z() { return (double)this.pos.getZ() + 0.5D; } @Override - public BlockPos getBlockPos() { + public BlockPos getPos() { return pos; } @Override public BlockState getBlockState() { - if(context.state.contains(BlockStateProperties.FACING) && overrideFacing != null) - return context.state.with(BlockStateProperties.FACING, overrideFacing); + if(context.state.hasProperty(BlockStateProperties.FACING) && overrideFacing != null) + return context.state.setValue(BlockStateProperties.FACING, overrideFacing); return context.state; } @Override @Nullable - public T getBlockTileEntity() { + public T getEntity() { return null; } @Override @Nullable - public ServerWorld getWorld() { + public ServerWorld getLevel() { MinecraftServer server = context.world.getServer(); - return server != null ? server.getWorld(context.world.getRegistryKey()) : null; + return server != null ? server.getLevel(context.world.dimension()) : null; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java index 39837a67f..70b70d49c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java @@ -19,6 +19,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.block.AbstractBlock; + public class DispenserMovementBehaviour extends DropperMovementBehaviour { private static final HashMap MOVED_DISPENSE_ITEM_BEHAVIOURS = new HashMap<>(); private static final HashMap MOVED_PROJECTILE_DISPENSE_BEHAVIOURS = new HashMap<>(); @@ -42,7 +44,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { DispenseItemLocation location = getDispenseLocation(context); if (location.isEmpty()) { - context.world.playEvent(1001, pos, 0); + context.world.levelEvent(1001, pos, 0); } else { ItemStack itemstack = getItemStackAt(location, context); // Special dispense item behaviour for moving contraptions @@ -59,7 +61,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { return; } - IDispenseItemBehavior idispenseitembehavior = BEHAVIOUR_LOOKUP.getBehavior(itemstack); + IDispenseItemBehavior idispenseitembehavior = BEHAVIOUR_LOOKUP.getDispenseMethod(itemstack); if (idispenseitembehavior instanceof ProjectileDispenseBehavior) { // Projectile behaviours can be converted most of the time IMovedDispenseItemBehaviour iMovedDispenseItemBehaviour = MovedProjectileDispenserBehaviour.of((ProjectileDispenseBehavior) idispenseitembehavior); setItemStackAt(location, iMovedDispenseItemBehaviour.dispense(itemstack, context, pos), context); @@ -67,10 +69,10 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { return; } - Vector3d facingVec = Vector3d.of(context.state.get(DispenserBlock.FACING).getDirectionVec()); + Vector3d facingVec = Vector3d.atLowerCornerOf(context.state.getValue(DispenserBlock.FACING).getNormal()); facingVec = context.rotation.apply(facingVec); facingVec.normalize(); - Direction clostestFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z); + Direction clostestFacing = Direction.getNearest(facingVec.x, facingVec.y, facingVec.z); ContraptionBlockSource blockSource = new ContraptionBlockSource(context, pos, clostestFacing); if (idispenseitembehavior.getClass() != DefaultDispenseItemBehavior.class) { // There is a dispense item behaviour registered for the vanilla dispenser @@ -89,11 +91,11 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { @MethodsReturnNonnullByDefault private static class DispenserLookup extends DispenserBlock { protected DispenserLookup() { - super(Block.Properties.from(Blocks.DISPENSER)); + super(AbstractBlock.Properties.copy(Blocks.DISPENSER)); } - public IDispenseItemBehavior getBehavior(ItemStack itemStack) { - return super.getBehavior(itemStack); + public IDispenseItemBehavior getDispenseMethod(ItemStack itemStack) { + return super.getDispenseMethod(itemStack); } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DropperMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DropperMovementBehaviour.java index 27aa13c60..e9771be43 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DropperMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DropperMovementBehaviour.java @@ -21,7 +21,7 @@ public class DropperMovementBehaviour extends MovementBehaviour { protected void activate(MovementContext context, BlockPos pos) { DispenseItemLocation location = getDispenseLocation(context); if (location.isEmpty()) { - context.world.playEvent(1001, pos, 0); + context.world.levelEvent(1001, pos, 0); } else { setItemStackAt(location, defaultBehaviour.dispense(getItemStackAt(location, context), context, pos), context); } @@ -29,7 +29,7 @@ public class DropperMovementBehaviour extends MovementBehaviour { @Override public void visitNewPosition(MovementContext context, BlockPos pos) { - if (context.world.isRemote) + if (context.world.isClientSide) return; collectItems(context); activate(context, pos); @@ -37,7 +37,7 @@ public class DropperMovementBehaviour extends MovementBehaviour { private void collectItems(MovementContext context) { getStacks(context).stream().filter(itemStack -> !itemStack.isEmpty() && itemStack.getItem() != Items.AIR && itemStack.getMaxStackSize() > itemStack.getCount()).forEach(itemStack -> itemStack.grow( - ItemHelper.extract(context.contraption.inventory, itemStack::isItemEqual, ItemHelper.ExtractionCountMode.UPTO, itemStack.getMaxStackSize() - itemStack.getCount(), false).getCount())); + ItemHelper.extract(context.contraption.inventory, itemStack::sameItem, ItemHelper.ExtractionCountMode.UPTO, itemStack.getMaxStackSize() - itemStack.getCount(), false).getCount())); } private void updateTemporaryData(MovementContext context) { @@ -62,7 +62,7 @@ public class DropperMovementBehaviour extends MovementBehaviour { if (testStack == null || testStack.isEmpty()) continue; if (testStack.getMaxStackSize() == 1) { - location = new DispenseItemLocation(false, ItemHelper.findFirstMatchingSlotIndex(context.contraption.inventory, testStack::isItemEqual)); + location = new DispenseItemLocation(false, ItemHelper.findFirstMatchingSlotIndex(context.contraption.inventory, testStack::sameItem)); if (!getItemStackAt(location, context).isEmpty()) useable.add(location); } else if (testStack.getCount() >= 2) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/IMovedDispenseItemBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/IMovedDispenseItemBehaviour.java index c70c6b899..bfb7e7e9f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/IMovedDispenseItemBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/IMovedDispenseItemBehaviour.java @@ -47,17 +47,17 @@ public interface IMovedDispenseItemBehaviour { if (context.world instanceof ServerWorld) { EntityType entityType = ((SpawnEggItem) itemStack.getItem()).getType(itemStack.getTag()); Entity spawnedEntity = entityType.spawn((ServerWorld) context.world, itemStack, null, - pos.add(facing.x + .7, facing.y + .7, facing.z + .7), SpawnReason.DISPENSER, facing.y < .5, + pos.offset(facing.x + .7, facing.y + .7, facing.z + .7), SpawnReason.DISPENSER, facing.y < .5, false); if (spawnedEntity != null) - spawnedEntity.setMotion(context.motion.scale(2)); + spawnedEntity.setDeltaMovement(context.motion.scale(2)); } itemStack.shrink(1); return itemStack; } }; - for (SpawnEggItem spawneggitem : SpawnEggItem.getEggs()) + for (SpawnEggItem spawneggitem : SpawnEggItem.eggs()) DispenserMovementBehaviour.registerMovedDispenseItemBehaviour(spawneggitem, spawnEggDispenseBehaviour); } @@ -92,10 +92,10 @@ public interface IMovedDispenseItemBehaviour { double y = pos.getY() + facing.y * .7 + .5; double z = pos.getZ() + facing.z * .7 + .5; TNTEntity tntentity = new TNTEntity(context.world, x, y, z, null); - tntentity.addVelocity(context.motion.x, context.motion.y, context.motion.z); - context.world.addEntity(tntentity); + tntentity.push(context.motion.x, context.motion.y, context.motion.z); + context.world.addFreshEntity(tntentity); context.world.playSound(null, tntentity.getX(), tntentity.getY(), tntentity.getZ(), - SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); + SoundEvents.TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); itemStack.shrink(1); return itemStack; } @@ -112,14 +112,14 @@ public interface IMovedDispenseItemBehaviour { FireworkRocketEntity fireworkrocketentity = new FireworkRocketEntity(context.world, itemStack, x, y, z, true); fireworkrocketentity.shoot(facing.x, facing.y, facing.z, 0.5F, 1.0F); - context.world.addEntity(fireworkrocketentity); + context.world.addFreshEntity(fireworkrocketentity); itemStack.shrink(1); return itemStack; } @Override protected void playDispenseSound(IWorld world, BlockPos pos) { - world.playEvent(1004, pos, 0); + world.levelEvent(1004, pos, 0); } }); @@ -127,22 +127,22 @@ public interface IMovedDispenseItemBehaviour { new MovedDefaultDispenseItemBehaviour() { @Override protected void playDispenseSound(IWorld world, BlockPos pos) { - world.playEvent(1018, pos, 0); + world.levelEvent(1018, pos, 0); } @Override protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, Vector3d facing) { - Random random = context.world.rand; + Random random = context.world.random; double x = pos.getX() + facing.x * .7 + .5; double y = pos.getY() + facing.y * .7 + .5; double z = pos.getZ() + facing.z * .7 + .5; - context.world.addEntity(Util.make( + context.world.addFreshEntity(Util.make( new SmallFireballEntity(context.world, x, y, z, random.nextGaussian() * 0.05D + facing.x + context.motion.x, random.nextGaussian() * 0.05D + facing.y + context.motion.y, random.nextGaussian() * 0.05D + facing.z + context.motion.z), - (p_229425_1_) -> p_229425_1_.setStack(itemStack))); + (p_229425_1_) -> p_229425_1_.setItem(itemStack))); itemStack.shrink(1); return itemStack; } @@ -154,21 +154,21 @@ public interface IMovedDispenseItemBehaviour { protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, Vector3d facing) { this.successful = false; - BlockPos interactAt = pos.offset(getClosestFacingDirection(facing)); + BlockPos interactAt = pos.relative(getClosestFacingDirection(facing)); BlockState state = context.world.getBlockState(interactAt); Block block = state.getBlock(); - if (block.isIn(BlockTags.BEEHIVES) && state.get(BeehiveBlock.HONEY_LEVEL) >= 5) { - ((BeehiveBlock) block).takeHoney(context.world, state, interactAt, null, + if (block.is(BlockTags.BEEHIVES) && state.getValue(BeehiveBlock.HONEY_LEVEL) >= 5) { + ((BeehiveBlock) block).releaseBeesAndResetHoneyLevel(context.world, state, interactAt, null, BeehiveTileEntity.State.BEE_RELEASED); this.successful = true; return placeItemInInventory(itemStack, new ItemStack(Items.HONEY_BOTTLE), context, pos, facing); } else if (context.world.getFluidState(interactAt) - .isTagged(FluidTags.WATER)) { + .is(FluidTags.WATER)) { this.successful = true; return placeItemInInventory(itemStack, - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER), context, pos, + PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER), context, pos, facing); } else { return super.dispenseStack(itemStack, context, pos, facing); @@ -181,13 +181,13 @@ public interface IMovedDispenseItemBehaviour { @Override protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, Vector3d facing) { - BlockPos interactAt = pos.offset(getClosestFacingDirection(facing)); + BlockPos interactAt = pos.relative(getClosestFacingDirection(facing)); BlockState state = context.world.getBlockState(interactAt); Block block = state.getBlock(); if (block instanceof IBucketPickupHandler) { - Fluid fluid = ((IBucketPickupHandler) block).pickupFluid(context.world, interactAt, state); + Fluid fluid = ((IBucketPickupHandler) block).takeLiquid(context.world, interactAt, state); if (fluid instanceof FlowingFluid) - return placeItemInInventory(itemStack, new ItemStack(fluid.getFilledBucket()), context, pos, + return placeItemInInventory(itemStack, new ItemStack(fluid.getBucket()), context, pos, facing); } return super.dispenseStack(itemStack, context, pos, facing); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedDefaultDispenseItemBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedDefaultDispenseItemBehaviour.java index 88aea0fed..d12d2d31a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedDefaultDispenseItemBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedDefaultDispenseItemBehaviour.java @@ -21,32 +21,32 @@ public class MovedDefaultDispenseItemBehaviour implements IMovedDispenseItemBeha double d0 = p_82486_4_.getX() + facing.x + .5; double d1 = p_82486_4_.getY() + facing.y + .5; double d2 = p_82486_4_.getZ() + facing.z + .5; - if (Direction.getFacingFromVector(facing.x, facing.y, facing.z).getAxis() == Direction.Axis.Y) { + if (Direction.getNearest(facing.x, facing.y, facing.z).getAxis() == Direction.Axis.Y) { d1 = d1 - 0.125D; } else { d1 = d1 - 0.15625D; } ItemEntity itementity = new ItemEntity(p_82486_0_, d0, d1, d2, p_82486_1_); - double d3 = p_82486_0_.rand.nextDouble() * 0.1D + 0.2D; - itementity.setMotion(p_82486_0_.rand.nextGaussian() * (double) 0.0075F * (double) p_82486_2_ + facing.getX() * d3 + context.motion.x, p_82486_0_.rand.nextGaussian() * (double) 0.0075F * (double) p_82486_2_ + facing.getY() * d3 + context.motion.y, p_82486_0_.rand.nextGaussian() * (double) 0.0075F * (double) p_82486_2_ + facing.getZ() * d3 + context.motion.z); - p_82486_0_.addEntity(itementity); + double d3 = p_82486_0_.random.nextDouble() * 0.1D + 0.2D; + itementity.setDeltaMovement(p_82486_0_.random.nextGaussian() * (double) 0.0075F * (double) p_82486_2_ + facing.x() * d3 + context.motion.x, p_82486_0_.random.nextGaussian() * (double) 0.0075F * (double) p_82486_2_ + facing.y() * d3 + context.motion.y, p_82486_0_.random.nextGaussian() * (double) 0.0075F * (double) p_82486_2_ + facing.z() * d3 + context.motion.z); + p_82486_0_.addFreshEntity(itementity); } @Override public ItemStack dispense(ItemStack itemStack, MovementContext context, BlockPos pos) { - Vector3d facingVec = Vector3d.of(context.state.get(DispenserBlock.FACING).getDirectionVec()); + Vector3d facingVec = Vector3d.atLowerCornerOf(context.state.getValue(DispenserBlock.FACING).getNormal()); facingVec = context.rotation.apply(facingVec); facingVec.normalize(); Direction closestToFacing = getClosestFacingDirection(facingVec); - IInventory iinventory = HopperTileEntity.getInventoryAtPosition(context.world, pos.offset(closestToFacing)); + IInventory iinventory = HopperTileEntity.getContainerAt(context.world, pos.relative(closestToFacing)); if (iinventory == null) { this.playDispenseSound(context.world, pos); this.spawnDispenseParticles(context.world, pos, closestToFacing); return this.dispenseStack(itemStack, context, pos, facingVec); } else { - if (HopperTileEntity.putStackInInventoryAllSlots(null, iinventory, itemStack.copy().split(1), closestToFacing.getOpposite()).isEmpty()) + if (HopperTileEntity.addItem(null, iinventory, itemStack.copy().split(1), closestToFacing.getOpposite()).isEmpty()) itemStack.shrink(1); return itemStack; } @@ -65,7 +65,7 @@ public class MovedDefaultDispenseItemBehaviour implements IMovedDispenseItemBeha * Play the dispense sound from the specified block. */ protected void playDispenseSound(IWorld world, BlockPos pos) { - world.playEvent(1000, pos, 0); + world.levelEvent(1000, pos, 0); } /** @@ -76,11 +76,11 @@ public class MovedDefaultDispenseItemBehaviour implements IMovedDispenseItemBeha } protected void spawnDispenseParticles(IWorld world, BlockPos pos, Direction direction) { - world.playEvent(2000, pos, direction.getIndex()); + world.levelEvent(2000, pos, direction.get3DDataValue()); } protected Direction getClosestFacingDirection(Vector3d exactFacing) { - return Direction.getFacingFromVector(exactFacing.x, exactFacing.y, exactFacing.z); + return Direction.getNearest(exactFacing.x, exactFacing.y, exactFacing.z); } protected ItemStack placeItemInInventory(ItemStack consumedFrom, ItemStack output, MovementContext context, BlockPos pos, Vector3d facing) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedOptionalDispenseBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedOptionalDispenseBehaviour.java index d3eb7e88e..9b8ecef5e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedOptionalDispenseBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedOptionalDispenseBehaviour.java @@ -8,6 +8,6 @@ public class MovedOptionalDispenseBehaviour extends MovedDefaultDispenseItemBeha @Override protected void playDispenseSound(IWorld world, BlockPos pos) { - world.playEvent(this.successful ? 1000 : 1001, pos, 0); + world.levelEvent(this.successful ? 1000 : 1001, pos, 0); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java index bd39d404f..d717dfa63 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java @@ -28,14 +28,14 @@ public abstract class MovedProjectileDispenserBehaviour extends MovedDefaultDisp return itemStack; Vector3d effectiveMovementVec = facing.scale(getProjectileVelocity()).add(context.motion); ProjectileEntity.shoot(effectiveMovementVec.x, effectiveMovementVec.y, effectiveMovementVec.z, (float) effectiveMovementVec.length(), this.getProjectileInaccuracy()); - context.world.addEntity(ProjectileEntity); + context.world.addFreshEntity(ProjectileEntity); itemStack.shrink(1); return itemStack; } @Override protected void playDispenseSound(IWorld world, BlockPos pos) { - world.playEvent(1002, pos, 0); + world.levelEvent(1002, pos, 0); } @Nullable @@ -81,19 +81,19 @@ public abstract class MovedProjectileDispenserBehaviour extends MovedDefaultDisp } private static Method getProjectileEntityLookup() { - Method getProjectileEntity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82499_a", World.class, IPosition.class, ItemStack.class); + Method getProjectileEntity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "getProjectile", World.class, IPosition.class, ItemStack.class); // getProjectile getProjectileEntity.setAccessible(true); return getProjectileEntity; } private static Method getProjectileInaccuracyLookup() { - Method getProjectileInaccuracy = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82498_a"); + Method getProjectileInaccuracy = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "getUncertainty"); // getUncertainty getProjectileInaccuracy.setAccessible(true); return getProjectileInaccuracy; } private static Method getProjectileVelocityLookup() { - Method getProjectileVelocity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82500_b"); + Method getProjectileVelocity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "getPower"); // getPower getProjectileVelocity.setAccessible(true); return getProjectileVelocity; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/SimplePos.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/SimplePos.java index 5da3e0b13..a751cc024 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/SimplePos.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/SimplePos.java @@ -14,17 +14,17 @@ public class SimplePos implements IPosition { } @Override - public double getX() { + public double x() { return x; } @Override - public double getY() { + public double y() { return y; } @Override - public double getZ() { + public double z() { return z; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockBlock.java index 3b179fc49..97d823099 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockBlock.java @@ -20,6 +20,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; +import net.minecraft.block.AbstractBlock.Properties; + public class CuckooClockBlock extends HorizontalKineticBlock { private boolean mysterious; @@ -49,22 +51,22 @@ public class CuckooClockBlock extends HorizontalKineticBlock { } @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { + public void fillItemCategory(ItemGroup group, NonNullList items) { if (!mysterious) - super.fillItemGroup(group, items); + super.fillItemCategory(group, items); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Direction preferred = getPreferredHorizontalFacing(context); if (preferred != null) - return getDefaultState().with(HORIZONTAL_FACING, preferred.getOpposite()); - return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); + return defaultBlockState().setValue(HORIZONTAL_FACING, preferred.getOpposite()); + return this.defaultBlockState().setValue(HORIZONTAL_FACING, context.getHorizontalDirection().getOpposite()); } @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face == state.get(HORIZONTAL_FACING).getOpposite(); + return face == state.getValue(HORIZONTAL_FACING).getOpposite(); } public static boolean containsSurprise(BlockState state) { @@ -74,11 +76,11 @@ public class CuckooClockBlock extends HorizontalKineticBlock { @Override public Axis getRotationAxis(BlockState state) { - return state.get(HORIZONTAL_FACING).getAxis(); + return state.getValue(HORIZONTAL_FACING).getAxis(); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java index 03f8fa982..443c00b11 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java @@ -34,10 +34,10 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { CuckooClockTileEntity clock = (CuckooClockTileEntity) te; BlockState blockState = te.getBlockState(); - int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos()); - Direction direction = blockState.get(CuckooClockBlock.HORIZONTAL_FACING); + int packedLightmapCoords = WorldRenderer.getLightColor(te.getLevel(), blockState, te.getBlockPos()); + Direction direction = blockState.getValue(CuckooClockBlock.HORIZONTAL_FACING); - IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); + IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); // Render Hands SuperByteBuffer hourHand = PartialBufferer.get(AllBlockPartials.CUCKOO_HOUR_HAND, blockState); @@ -83,7 +83,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { PartialModel partialModel = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER); SuperByteBuffer figure = PartialBufferer.get(partialModel, blockState); - figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.rotateYCCW()))); + figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise()))); figure.translate(offset, 0, 0); figure.light(packedLightmapCoords) .renderInto(ms, vb); @@ -98,7 +98,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { private SuperByteBuffer transform(PartialModel partial, KineticTileEntity te) { return PartialBufferer.getFacing(partial, te.getBlockState(), te.getBlockState() - .get(CuckooClockBlock.HORIZONTAL_FACING) + .getValue(CuckooClockBlock.HORIZONTAL_FACING) .getOpposite()); } @@ -106,7 +106,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { float pivotX = 2 / 16f; float pivotY = 6 / 16f; float pivotZ = 8 / 16f; - buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.rotateYCCW()))); + buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getCounterClockWise()))); buffer.translate(pivotX, pivotY, pivotZ); buffer.rotate(Direction.EAST, angle); buffer.translate(-pivotX, -pivotY, -pivotZ); @@ -117,7 +117,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { float pivotX = 2 / 16f; float pivotY = 0; float pivotZ = (left ? 6 : 10) / 16f; - buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.rotateYCCW()))); + buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getCounterClockWise()))); buffer.translate(pivotX, pivotY, pivotZ); buffer.rotate(Direction.UP, AngleHelper.rad(angle) * (left ? -1 : 1)); buffer.translate(-pivotX, -pivotY, -pivotZ); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockTileEntity.java index 9b3aefbd8..a38d44ee1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockTileEntity.java @@ -67,24 +67,24 @@ public class CuckooClockTileEntity extends KineticTileEntity { return; - boolean isNatural = world.getDimension().isNatural(); - int dayTime = (int) ((world.getDayTime() * (isNatural ? 1 : 24)) % 24000); + boolean isNatural = level.dimensionType().natural(); + int dayTime = (int) ((level.getDayTime() * (isNatural ? 1 : 24)) % 24000); int hours = (dayTime / 1000 + 6) % 24; int minutes = (dayTime % 1000) * 60 / 1000; if (!isNatural) { - if (world.isRemote) { + if (level.isClientSide) { moveHands(hours, minutes); if (AnimationTickHolder.getTicks() % 6 == 0) - playSound(SoundEvents.BLOCK_NOTE_BLOCK_HAT, 1 / 16f, 2f); + playSound(SoundEvents.NOTE_BLOCK_HAT, 1 / 16f, 2f); else if (AnimationTickHolder.getTicks() % 3 == 0) - playSound(SoundEvents.BLOCK_NOTE_BLOCK_HAT, 1 / 16f, 1.5f); + playSound(SoundEvents.NOTE_BLOCK_HAT, 1 / 16f, 1.5f); } return; } - if (!world.isRemote) { + if (!level.isClientSide) { if (animationType == Animation.NONE) { if (hours == 12 && minutes < 5) startAnimation(Animation.PIG); @@ -97,23 +97,23 @@ public class CuckooClockTileEntity extends KineticTileEntity { animationType = Animation.NONE; if (animationType == Animation.SURPRISE && animationProgress.value == 50) { - Vector3d center = VecHelper.getCenterOf(pos); - world.destroyBlock(pos, false); - world.createExplosion(null, CUCKOO_SURPRISE, null, center.x, center.y, center.z, 3, false, + Vector3d center = VecHelper.getCenterOf(worldPosition); + level.destroyBlock(worldPosition, false); + level.explode(null, CUCKOO_SURPRISE, null, center.x, center.y, center.z, 3, false, Explosion.Mode.BREAK); } } } - if (world.isRemote) { + if (level.isClientSide) { moveHands(hours, minutes); if (animationType == Animation.NONE) { if (AnimationTickHolder.getTicks() % 32 == 0) - playSound(SoundEvents.BLOCK_NOTE_BLOCK_HAT, 1 / 16f, 2f); + playSound(SoundEvents.NOTE_BLOCK_HAT, 1 / 16f, 2f); else if (AnimationTickHolder.getTicks() % 16 == 0) - playSound(SoundEvents.BLOCK_NOTE_BLOCK_HAT, 1 / 16f, 1.5f); + playSound(SoundEvents.NOTE_BLOCK_HAT, 1 / 16f, 1.5f); } else { boolean isSurprise = animationType == Animation.SURPRISE; @@ -125,29 +125,29 @@ public class CuckooClockTileEntity extends KineticTileEntity { // sounds if (value == 1) - playSound(SoundEvents.BLOCK_NOTE_BLOCK_CHIME, 2, .5f); + playSound(SoundEvents.NOTE_BLOCK_CHIME, 2, .5f); if (value == 21) - playSound(SoundEvents.BLOCK_NOTE_BLOCK_CHIME, 2, 0.793701f); + playSound(SoundEvents.NOTE_BLOCK_CHIME, 2, 0.793701f); if (value > 30 && isSurprise) { - Vector3d pos = VecHelper.offsetRandomly(VecHelper.getCenterOf(this.pos), world.rand, .5f); - world.addParticle(ParticleTypes.LARGE_SMOKE, pos.x, pos.y, pos.z, 0, 0, 0); + Vector3d pos = VecHelper.offsetRandomly(VecHelper.getCenterOf(this.worldPosition), level.random, .5f); + level.addParticle(ParticleTypes.LARGE_SMOKE, pos.x, pos.y, pos.z, 0, 0, 0); } if (value == 40 && isSurprise) - playSound(SoundEvents.ENTITY_TNT_PRIMED, 1f, 1f); + playSound(SoundEvents.TNT_PRIMED, 1f, 1f); int step = isSurprise ? 3 : 15; for (int phase = 30; phase <= 60; phase += step) { if (value == phase - step / 3) - playSound(SoundEvents.BLOCK_CHEST_OPEN, 1 / 16f, 2f); + playSound(SoundEvents.CHEST_OPEN, 1 / 16f, 2f); if (value == phase) { if (animationType == Animation.PIG) - playSound(SoundEvents.ENTITY_PIG_AMBIENT, 1 / 4f, 1f); + playSound(SoundEvents.PIG_AMBIENT, 1 / 4f, 1f); else - playSound(SoundEvents.ENTITY_CREEPER_HURT, 1 / 4f, 3f); + playSound(SoundEvents.CREEPER_HURT, 1 / 4f, 3f); } if (value == phase + step / 3) - playSound(SoundEvents.BLOCK_CHEST_CLOSE, 1 / 16f, 2f); + playSound(SoundEvents.CHEST_CLOSE, 1 / 16f, 2f); } @@ -166,7 +166,7 @@ public class CuckooClockTileEntity extends KineticTileEntity { sendAnimationUpdate = true; if (animation == Animation.CREEPER) - AllTriggers.triggerForNearbyPlayers(AllTriggers.CUCKOO, world, pos, 10); + AllTriggers.triggerForNearbyPlayers(AllTriggers.CUCKOO, level, worldPosition, 10); sendData(); } @@ -183,8 +183,8 @@ public class CuckooClockTileEntity extends KineticTileEntity { } private void playSound(SoundEvent sound, float volume, float pitch) { - Vector3d vec = VecHelper.getCenterOf(pos); - world.playSound(vec.x, vec.y, vec.z, sound, SoundCategory.BLOCKS, volume, pitch, false); + Vector3d vec = VecHelper.getCenterOf(worldPosition); + level.playLocalSound(vec.x, vec.y, vec.z, sound, SoundCategory.BLOCKS, volume, pitch, false); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/ConnectedInputHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/ConnectedInputHandler.java index db6b86bfd..39e725e9b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/ConnectedInputHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/ConnectedInputHandler.java @@ -34,17 +34,17 @@ public class ConnectedInputHandler { public static boolean shouldConnect(World world, BlockPos pos, Direction face, Direction direction) { BlockState refState = world.getBlockState(pos); - if (!refState.contains(HORIZONTAL_FACING)) + if (!refState.hasProperty(HORIZONTAL_FACING)) return false; - Direction refDirection = refState.get(HORIZONTAL_FACING); + Direction refDirection = refState.getValue(HORIZONTAL_FACING); if (direction.getAxis() == refDirection.getAxis()) return false; if (face == refDirection) return false; - BlockState neighbour = world.getBlockState(pos.offset(direction)); + BlockState neighbour = world.getBlockState(pos.relative(direction)); if (!AllBlocks.MECHANICAL_CRAFTER.has(neighbour)) return false; - if (refDirection != neighbour.get(HORIZONTAL_FACING)) + if (refDirection != neighbour.getValue(HORIZONTAL_FACING)) return false; return true; } @@ -56,16 +56,16 @@ public class ConnectedInputHandler { if (crafter1 == null || crafter2 == null) return; - BlockPos controllerPos1 = crafter1.getPos() - .add(crafter1.input.data.get(0)); - BlockPos controllerPos2 = crafter2.getPos() - .add(crafter2.input.data.get(0)); + BlockPos controllerPos1 = crafter1.getBlockPos() + .offset(crafter1.input.data.get(0)); + BlockPos controllerPos2 = crafter2.getBlockPos() + .offset(crafter2.input.data.get(0)); if (controllerPos1.equals(controllerPos2)) { MechanicalCrafterTileEntity controller = CrafterHelper.getCrafter(world, controllerPos1); Set positions = controller.input.data.stream() - .map(controllerPos1::add) + .map(controllerPos1::offset) .collect(Collectors.toSet()); List frontier = new LinkedList<>(); List splitGroup = new ArrayList<>(); @@ -76,7 +76,7 @@ public class ConnectedInputHandler { while (!frontier.isEmpty()) { BlockPos current = frontier.remove(0); for (Direction direction : Iterate.directions) { - BlockPos next = current.offset(direction); + BlockPos next = current.relative(direction); if (!positions.remove(next)) continue; splitGroup.add(next); @@ -87,9 +87,9 @@ public class ConnectedInputHandler { initAndAddAll(world, crafter1, positions); initAndAddAll(world, crafter2, splitGroup); - crafter1.markDirty(); + crafter1.setChanged(); crafter1.connectivityChanged(); - crafter2.markDirty(); + crafter2.setChanged(); crafter2.connectivityChanged(); return; } @@ -103,11 +103,11 @@ public class ConnectedInputHandler { connectControllers(world, crafter1, crafter2); - world.setBlockState(crafter1.getPos(), crafter1.getBlockState(), 3); + world.setBlock(crafter1.getBlockPos(), crafter1.getBlockState(), 3); - crafter1.markDirty(); + crafter1.setChanged(); crafter1.connectivityChanged(); - crafter2.markDirty(); + crafter2.setChanged(); crafter2.connectivityChanged(); } @@ -115,8 +115,8 @@ public class ConnectedInputHandler { crafter.input = new ConnectedInput(); positions.forEach(splitPos -> { modifyAndUpdate(world, splitPos, input -> { - input.attachTo(crafter.getPos(), splitPos); - crafter.input.data.add(splitPos.subtract(crafter.getPos())); + input.attachTo(crafter.getBlockPos(), splitPos); + crafter.input.data.add(splitPos.subtract(crafter.getBlockPos())); }); }); } @@ -125,8 +125,8 @@ public class ConnectedInputHandler { MechanicalCrafterTileEntity crafter2) { crafter1.input.data.forEach(offset -> { - BlockPos connectedPos = crafter1.getPos() - .add(offset); + BlockPos connectedPos = crafter1.getBlockPos() + .offset(offset); modifyAndUpdate(world, connectedPos, input -> { }); }); @@ -134,26 +134,26 @@ public class ConnectedInputHandler { crafter2.input.data.forEach(offset -> { if (offset.equals(BlockPos.ZERO)) return; - BlockPos connectedPos = crafter2.getPos() - .add(offset); + BlockPos connectedPos = crafter2.getBlockPos() + .offset(offset); modifyAndUpdate(world, connectedPos, input -> { - input.attachTo(crafter1.getPos(), connectedPos); + input.attachTo(crafter1.getBlockPos(), connectedPos); crafter1.input.data.add(BlockPos.ZERO.subtract(input.data.get(0))); }); }); - crafter2.input.attachTo(crafter1.getPos(), crafter2.getPos()); + crafter2.input.attachTo(crafter1.getBlockPos(), crafter2.getBlockPos()); crafter1.input.data.add(BlockPos.ZERO.subtract(crafter2.input.data.get(0))); } private static void modifyAndUpdate(World world, BlockPos pos, Consumer callback) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (!(te instanceof MechanicalCrafterTileEntity)) return; MechanicalCrafterTileEntity crafter = (MechanicalCrafterTileEntity) te; callback.accept(crafter.input); - crafter.markDirty(); + crafter.setChanged(); crafter.connectivityChanged(); } @@ -174,7 +174,7 @@ public class ConnectedInputHandler { public IItemHandler getItemHandler(World world, BlockPos pos) { if (!isController) { - BlockPos controllerPos = pos.add(data.get(0)); + BlockPos controllerPos = pos.offset(data.get(0)); ConnectedInput input = CrafterHelper.getInput(world, controllerPos); if (input == this || input == null || !input.isController) return new ItemStackHandler(); @@ -182,7 +182,7 @@ public class ConnectedInputHandler { } List list = data.stream() - .map(l -> CrafterHelper.getCrafter(world, pos.add(l))) + .map(l -> CrafterHelper.getCrafter(world, pos.offset(l))) .filter(Objects::nonNull) .map(crafter -> crafter.getInventory()) .collect(Collectors.toList()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/CrafterCTBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/CrafterCTBehaviour.java index f4cf702e7..3649a3ab4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/CrafterCTBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/CrafterCTBehaviour.java @@ -21,7 +21,7 @@ public class CrafterCTBehaviour extends ConnectedTextureBehaviour { Direction face) { if (state.getBlock() != other.getBlock()) return false; - if (state.get(HORIZONTAL_FACING) != other.get(HORIZONTAL_FACING)) + if (state.getValue(HORIZONTAL_FACING) != other.getValue(HORIZONTAL_FACING)) return false; ConnectedInput input1 = CrafterHelper.getInput(reader, pos); @@ -32,8 +32,8 @@ public class CrafterCTBehaviour extends ConnectedTextureBehaviour { if (input1.data.isEmpty() || input2.data.isEmpty()) return false; try { - if (pos.add(input1.data.get(0)) - .equals(otherPos.add(input2.data.get(0)))) + if (pos.offset(input1.data.get(0)) + .equals(otherPos.offset(input2.data.get(0)))) return true; } catch (IndexOutOfBoundsException e) { // race condition. data somehow becomes empty between the last 2 if statements @@ -47,7 +47,7 @@ public class CrafterCTBehaviour extends ConnectedTextureBehaviour { if (!direction.getAxis() .isVertical()) return false; - Direction facing = state.get(HORIZONTAL_FACING); + Direction facing = state.getValue(HORIZONTAL_FACING); if (facing.getAxis() == direction.getAxis()) return false; @@ -59,7 +59,7 @@ public class CrafterCTBehaviour extends ConnectedTextureBehaviour { @Override public CTSpriteShiftEntry get(BlockState state, Direction direction) { - Direction facing = state.get(HORIZONTAL_FACING); + Direction facing = state.getValue(HORIZONTAL_FACING); boolean isFront = facing.getAxis() == direction.getAxis(); boolean isVertical = direction.getAxis() .isVertical(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/CrafterHelper.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/CrafterHelper.java index ed41f7c3a..b954fe412 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/CrafterHelper.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/CrafterHelper.java @@ -7,7 +7,7 @@ import net.minecraft.world.IBlockDisplayReader; public class CrafterHelper { public static MechanicalCrafterTileEntity getCrafter(IBlockDisplayReader reader, BlockPos pos) { - TileEntity te = reader.getTileEntity(pos); + TileEntity te = reader.getBlockEntity(pos); if (!(te instanceof MechanicalCrafterTileEntity)) return null; return (MechanicalCrafterTileEntity) te; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java index 05c41789d..b4ef94055 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java @@ -41,18 +41,20 @@ import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; +import net.minecraft.block.AbstractBlock.Properties; + public class MechanicalCrafterBlock extends HorizontalKineticBlock implements ITE, ICogWheel { public static final EnumProperty POINTING = EnumProperty.create("pointing", Pointing.class); public MechanicalCrafterBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(POINTING, Pointing.UP)); + registerDefaultState(defaultBlockState().setValue(POINTING, Pointing.UP)); } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(POINTING)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(POINTING)); } @Override @@ -62,35 +64,35 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT @Override public Axis getRotationAxis(BlockState state) { - return state.get(HORIZONTAL_FACING) + return state.getValue(HORIZONTAL_FACING) .getAxis(); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - Direction face = context.getFace(); - BlockPos placedOnPos = context.getPos() - .offset(face.getOpposite()); - BlockState blockState = context.getWorld() + Direction face = context.getClickedFace(); + BlockPos placedOnPos = context.getClickedPos() + .relative(face.getOpposite()); + BlockState blockState = context.getLevel() .getBlockState(placedOnPos); if ((blockState.getBlock() != this) || (context.getPlayer() != null && context.getPlayer() - .isSneaking())) { + .isShiftKeyDown())) { BlockState stateForPlacement = super.getStateForPlacement(context); - Direction direction = stateForPlacement.get(HORIZONTAL_FACING); + Direction direction = stateForPlacement.getValue(HORIZONTAL_FACING); if (direction != face) - stateForPlacement = stateForPlacement.with(POINTING, pointingFromFacing(face, direction)); + stateForPlacement = stateForPlacement.setValue(POINTING, pointingFromFacing(face, direction)); return stateForPlacement; } - Direction otherFacing = blockState.get(HORIZONTAL_FACING); + Direction otherFacing = blockState.getValue(HORIZONTAL_FACING); Pointing pointing = pointingFromFacing(face, otherFacing); - return getDefaultState().with(HORIZONTAL_FACING, otherFacing) - .with(POINTING, pointing); + return defaultBlockState().setValue(HORIZONTAL_FACING, otherFacing) + .setValue(POINTING, pointing); } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() == newState.getBlock()) { if (getTargetDirection(state) != getTargetDirection(newState)) { MechanicalCrafterTileEntity crafter = CrafterHelper.getCrafter(worldIn, pos); @@ -103,29 +105,29 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT MechanicalCrafterTileEntity crafter = CrafterHelper.getCrafter(worldIn, pos); if (crafter != null) { if (crafter.covered) - Block.spawnAsEntity(worldIn, pos, AllItems.CRAFTER_SLOT_COVER.asStack()); + Block.popResource(worldIn, pos, AllItems.CRAFTER_SLOT_COVER.asStack()); crafter.ejectWholeGrid(); } for (Direction direction : Iterate.directions) { - if (direction.getAxis() == state.get(HORIZONTAL_FACING) + if (direction.getAxis() == state.getValue(HORIZONTAL_FACING) .getAxis()) continue; - BlockPos otherPos = pos.offset(direction); + BlockPos otherPos = pos.relative(direction); ConnectedInput thisInput = CrafterHelper.getInput(worldIn, pos); ConnectedInput otherInput = CrafterHelper.getInput(worldIn, otherPos); if (thisInput == null || otherInput == null) continue; - if (!pos.add(thisInput.data.get(0)) - .equals(otherPos.add(otherInput.data.get(0)))) + if (!pos.offset(thisInput.data.get(0)) + .equals(otherPos.offset(otherInput.data.get(0)))) continue; ConnectedInputHandler.toggleConnection(worldIn, pos, otherPos); } - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } } @@ -146,9 +148,9 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - if (context.getFace() == state.get(HORIZONTAL_FACING)) { - if (!context.getWorld().isRemote) - KineticTileEntity.switchToBlockState(context.getWorld(), context.getPos(), state.cycle(POINTING)); + if (context.getClickedFace() == state.getValue(HORIZONTAL_FACING)) { + if (!context.getLevel().isClientSide) + KineticTileEntity.switchToBlockState(context.getLevel(), context.getClickedPos(), state.cycle(POINTING)); return ActionResultType.SUCCESS; } @@ -156,12 +158,12 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - ItemStack heldItem = player.getHeldItem(handIn); + ItemStack heldItem = player.getItemInHand(handIn); boolean isHand = heldItem.isEmpty() && handIn == Hand.MAIN_HAND; - TileEntity te = worldIn.getTileEntity(pos); + TileEntity te = worldIn.getBlockEntity(pos); if (!(te instanceof MechanicalCrafterTileEntity)) return ActionResultType.PASS; MechanicalCrafterTileEntity crafter = (MechanicalCrafterTileEntity) te; @@ -170,7 +172,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT if (AllBlocks.MECHANICAL_ARM.isIn(heldItem)) return ActionResultType.PASS; - if (hit.getFace() == state.get(HORIZONTAL_FACING)) { + if (hit.getDirection() == state.getValue(HORIZONTAL_FACING)) { if (crafter.phase != Phase.IDLE && !wrenched) { crafter.ejectWholeGrid(); @@ -178,7 +180,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT } if (crafter.phase == Phase.IDLE && !isHand && !wrenched) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return ActionResultType.SUCCESS; if (AllItems.CRAFTER_SLOT_COVER.isIn(heldItem)) { @@ -187,7 +189,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT if (!crafter.inventory.isEmpty()) return ActionResultType.PASS; crafter.covered = true; - crafter.markDirty(); + crafter.setChanged(); crafter.sendData(); if (!player.isCreative()) heldItem.shrink(1); @@ -201,17 +203,17 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT ItemStack remainder = ItemHandlerHelper.insertItem(capability.orElse(new ItemStackHandler()), heldItem.copy(), false); if (remainder.getCount() != heldItem.getCount()) - player.setHeldItem(handIn, remainder); + player.setItemInHand(handIn, remainder); return ActionResultType.SUCCESS; } - ItemStack inSlot = crafter.getInventory().getStackInSlot(0); + ItemStack inSlot = crafter.getInventory().getItem(0); if (inSlot.isEmpty()) { if (crafter.covered && !wrenched) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return ActionResultType.SUCCESS; crafter.covered = false; - crafter.markDirty(); + crafter.setChanged(); crafter.sendData(); if (!player.isCreative()) player.inventory.placeItemBackInInventory(worldIn, AllItems.CRAFTER_SLOT_COVER.asStack()); @@ -221,7 +223,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT } if (!isHand && !ItemHandlerHelper.canItemStacksStack(heldItem, inSlot)) return ActionResultType.PASS; - if (worldIn.isRemote) + if (worldIn.isClientSide) return ActionResultType.SUCCESS; player.inventory.placeItemBackInInventory(worldIn, inSlot); crafter.getInventory().setStackInSlot(0, ItemStack.EMPTY); @@ -252,25 +254,25 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT public static Direction getTargetDirection(BlockState state) { if (!AllBlocks.MECHANICAL_CRAFTER.has(state)) return Direction.UP; - Direction facing = state.get(HORIZONTAL_FACING); - Pointing point = state.get(POINTING); + Direction facing = state.getValue(HORIZONTAL_FACING); + Pointing point = state.getValue(POINTING); Vector3d targetVec = new Vector3d(0, 1, 0); targetVec = VecHelper.rotate(targetVec, -point.getXRotation(), Axis.Z); targetVec = VecHelper.rotate(targetVec, AngleHelper.horizontalAngle(facing), Axis.Y); - return Direction.getFacingFromVector(targetVec.x, targetVec.y, targetVec.z); + return Direction.getNearest(targetVec.x, targetVec.y, targetVec.z); } public static boolean isValidTarget(World world, BlockPos targetPos, BlockState crafterState) { BlockState targetState = world.getBlockState(targetPos); - if (!world.isBlockPresent(targetPos)) + if (!world.isLoaded(targetPos)) return false; if (!AllBlocks.MECHANICAL_CRAFTER.has(targetState)) return false; - if (crafterState.get(HORIZONTAL_FACING) != targetState.get(HORIZONTAL_FACING)) + if (crafterState.getValue(HORIZONTAL_FACING) != targetState.getValue(HORIZONTAL_FACING)) return false; - if (Math.abs(crafterState.get(POINTING) + if (Math.abs(crafterState.getValue(POINTING) .getXRotation() - - targetState.get(POINTING) + - targetState.getValue(POINTING) .getXRotation()) == 180) return false; return true; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterInstance.java index 4ca256adf..009dc3abe 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterInstance.java @@ -21,7 +21,7 @@ public class MechanicalCrafterInstance extends SingleRotatingInstance { @Override protected Instancer getModel() { - Direction facing = blockState.get(MechanicalCrafterBlock.HORIZONTAL_FACING); + Direction facing = blockState.getValue(MechanicalCrafterBlock.HORIZONTAL_FACING); Supplier ms = () -> { MatrixStack stack = new MatrixStack(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java index a4575de82..e77faa354 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java @@ -41,25 +41,25 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer { - if (getStackInSlot(slot).isEmpty()) + if (getItem(slot).isEmpty()) return; if (te.phase == Phase.IDLE) te.checkCompletedRecipe(false); @@ -72,8 +72,8 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { return stack; ItemStack insertItem = super.insertItem(slot, stack, simulate); if (insertItem.getCount() != stack.getCount() && !simulate) - te.getWorld() - .playSound(null, te.getPos(), SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, SoundCategory.BLOCKS, .25f, + te.getLevel() + .playSound(null, te.getBlockPos(), SoundEvents.ITEM_FRAME_ADD_ITEM, SoundCategory.BLOCKS, .25f, .5f); return insertItem; } @@ -83,7 +83,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { protected Inventory inventory; protected GroupedItems groupedItems = new GroupedItems(); protected ConnectedInput input = new ConnectedInput(); - protected LazyOptional invSupplier = LazyOptional.of(() -> input.getItemHandler(world, pos)); + protected LazyOptional invSupplier = LazyOptional.of(() -> input.getItemHandler(level, worldPosition)); protected boolean reRender; protected Phase phase; protected int countDown; @@ -176,25 +176,25 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { if (!clientPacket) return; if (compound.contains("Redraw")) - world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 16); + level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), 16); if (phaseBefore != phase && phase == Phase.CRAFTING) groupedItemsBeforeCraft = before; if (phaseBefore == Phase.EXPORTING && phase == Phase.WAITING) { - Direction facing = getBlockState().get(MechanicalCrafterBlock.HORIZONTAL_FACING); - Vector3d vec = Vector3d.of(facing.getDirectionVec()) + Direction facing = getBlockState().getValue(MechanicalCrafterBlock.HORIZONTAL_FACING); + Vector3d vec = Vector3d.atLowerCornerOf(facing.getNormal()) .scale(.75) - .add(VecHelper.getCenterOf(pos)); + .add(VecHelper.getCenterOf(worldPosition)); Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(getBlockState()); - vec = vec.add(Vector3d.of(targetDirection.getDirectionVec()) + vec = vec.add(Vector3d.atLowerCornerOf(targetDirection.getNormal()) .scale(1)); - world.addParticle(ParticleTypes.CRIT, vec.x, vec.y, vec.z, 0, 0, 0); + level.addParticle(ParticleTypes.CRIT, vec.x, vec.y, vec.z, 0, 0, 0); } } @Override - public void remove() { + public void setRemoved() { invSupplier.invalidate(); - super.remove(); + super.setRemoved(); } public int getCountDownSpeed() { @@ -210,11 +210,11 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { if (phase == Phase.ACCEPTING) return; - boolean onClient = world.isRemote; + boolean onClient = level.isClientSide; boolean runLogic = !onClient || isVirtual(); - if (wasPoweredBefore != world.isBlockPowered(pos)) { - wasPoweredBefore = world.isBlockPowered(pos); + if (wasPoweredBefore != level.hasNeighborSignal(worldPosition)) { + wasPoweredBefore = level.hasNeighborSignal(worldPosition); if (wasPoweredBefore) { if (!runLogic) return; @@ -236,7 +236,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { } ItemStack result = - isVirtual() ? scriptedResult : RecipeGridHandler.tryToApplyRecipe(world, groupedItems); + isVirtual() ? scriptedResult : RecipeGridHandler.tryToApplyRecipe(level, groupedItems); if (result != null) { List containers = new ArrayList<>(); @@ -282,12 +282,12 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { return; } - Pointing pointing = getBlockState().get(MechanicalCrafterBlock.POINTING); + Pointing pointing = getBlockState().getValue(MechanicalCrafterBlock.POINTING); groupedItems.mergeOnto(targetingCrafter.groupedItems, pointing); groupedItems = new GroupedItems(); float pitch = targetingCrafter.groupedItems.grid.size() * 1/16f + .5f; - AllSoundEvents.CRAFTER_CLICK.playOnServer(world, pos, 1, pitch); + AllSoundEvents.CRAFTER_CLICK.playOnServer(level, worldPosition, 1, pitch); phase = Phase.WAITING; countDown = 0; @@ -301,18 +301,18 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { if (phase == Phase.CRAFTING) { if (onClient) { - Direction facing = getBlockState().get(MechanicalCrafterBlock.HORIZONTAL_FACING); + Direction facing = getBlockState().getValue(MechanicalCrafterBlock.HORIZONTAL_FACING); float progress = countDown / 2000f; - Vector3d facingVec = Vector3d.of(facing.getDirectionVec()); + Vector3d facingVec = Vector3d.atLowerCornerOf(facing.getNormal()); Vector3d vec = facingVec.scale(.65) - .add(VecHelper.getCenterOf(pos)); - Vector3d offset = VecHelper.offsetRandomly(Vector3d.ZERO, world.rand, .125f) - .mul(VecHelper.axisAlingedPlaneOf(facingVec)) + .add(VecHelper.getCenterOf(worldPosition)); + Vector3d offset = VecHelper.offsetRandomly(Vector3d.ZERO, level.random, .125f) + .multiply(VecHelper.axisAlingedPlaneOf(facingVec)) .normalize() .scale(progress * .5f) .add(vec); if (progress > .5f) - world.addParticle(ParticleTypes.CRIT, offset.x, offset.y, offset.z, 0, 0, 0); + level.addParticle(ParticleTypes.CRIT, offset.x, offset.y, offset.z, 0, 0, 0); if (!groupedItemsBeforeCraft.grid.isEmpty() && progress < .5f) { if (groupedItems.grid.containsKey(Pair.of(0, 0))) { @@ -320,13 +320,13 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { groupedItemsBeforeCraft = new GroupedItems(); for (int i = 0; i < 10; i++) { - Vector3d randVec = VecHelper.offsetRandomly(Vector3d.ZERO, world.rand, .125f) - .mul(VecHelper.axisAlingedPlaneOf(facingVec)) + Vector3d randVec = VecHelper.offsetRandomly(Vector3d.ZERO, level.random, .125f) + .multiply(VecHelper.axisAlingedPlaneOf(facingVec)) .normalize() .scale(.25f); Vector3d offset2 = randVec.add(vec); randVec = randVec.scale(.35f); - world.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), offset2.x, offset2.y, + level.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), offset2.x, offset2.y, offset2.z, randVec.x, randVec.y, randVec.z); } } @@ -337,8 +337,8 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { countDown -= getCountDownSpeed(); if (countDown < 1000 && prev >= 1000) { - AllSoundEvents.CRAFTER_CLICK.playOnServer(world, pos, 1, 2); - AllSoundEvents.CRAFTER_CRAFT.playOnServer(world, pos); + AllSoundEvents.CRAFTER_CLICK.playOnServer(level, worldPosition, 1, 2); + AllSoundEvents.CRAFTER_CRAFT.playOnServer(level, worldPosition); } if (countDown < 0) { @@ -363,8 +363,8 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { } protected DirectBeltInputBehaviour getTargetingBelt() { - BlockPos targetPos = pos.offset(getTargetDirection()); - return TileEntityBehaviour.get(world, targetPos, DirectBeltInputBehaviour.TYPE); + BlockPos targetPos = worldPosition.relative(getTargetDirection()); + return TileEntityBehaviour.get(level, targetPos, DirectBeltInputBehaviour.TYPE); } public void tryInsert() { @@ -380,7 +380,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { for (Entry, ItemStack> entry : groupedItems.grid.entrySet()) { Pair pair = entry.getKey(); ItemStack stack = entry.getValue(); - BlockFace face = getTargetFace(world, pos, getBlockState()); + BlockFace face = getTargetFace(level, worldPosition, getBlockState()); ItemStack remainder = behaviour == null ? inserting.insert(stack.copy()) : behaviour.handleInsertion(stack, face.getFace(), false); @@ -411,15 +411,15 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { public void eject() { BlockState blockState = getBlockState(); boolean present = AllBlocks.MECHANICAL_CRAFTER.has(blockState); - Vector3d vec = present ? Vector3d.of(blockState.get(HORIZONTAL_FACING) - .getDirectionVec()) + Vector3d vec = present ? Vector3d.atLowerCornerOf(blockState.getValue(HORIZONTAL_FACING) + .getNormal()) .scale(.75f) : Vector3d.ZERO; - Vector3d ejectPos = VecHelper.getCenterOf(pos) + Vector3d ejectPos = VecHelper.getCenterOf(worldPosition) .add(vec); groupedItems.grid.forEach((pair, stack) -> dropItem(ejectPos, stack)); - if (!inventory.getStackInSlot(0) + if (!inventory.getItem(0) .isEmpty()) - dropItem(ejectPos, inventory.getStackInSlot(0)); + dropItem(ejectPos, inventory.getItem(0)); phase = Phase.IDLE; groupedItems = new GroupedItems(); inventory.setStackInSlot(0, ItemStack.EMPTY); @@ -427,15 +427,15 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { } public void dropItem(Vector3d ejectPos, ItemStack stack) { - ItemEntity itemEntity = new ItemEntity(world, ejectPos.x, ejectPos.y, ejectPos.z, stack); - itemEntity.setDefaultPickupDelay(); - world.addEntity(itemEntity); + ItemEntity itemEntity = new ItemEntity(level, ejectPos.x, ejectPos.y, ejectPos.z, stack); + itemEntity.setDefaultPickUpDelay(); + level.addFreshEntity(itemEntity); } @Override public void lazyTick() { super.lazyTick(); - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) return; if (phase == Phase.IDLE && craftingItemPresent()) checkCompletedRecipe(false); @@ -444,19 +444,19 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { } public boolean craftingItemPresent() { - return !inventory.getStackInSlot(0) + return !inventory.getItem(0) .isEmpty(); } public boolean craftingItemOrCoverPresent() { - return !inventory.getStackInSlot(0) + return !inventory.getItem(0) .isEmpty() || covered; } protected void checkCompletedRecipe(boolean poweredStart) { if (getSpeed() == 0) return; - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) return; List chain = RecipeGridHandler.getAllCraftersOfChainIf(this, poweredStart ? MechanicalCrafterTileEntity::craftingItemPresent @@ -469,7 +469,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { protected void begin() { phase = Phase.ACCEPTING; - groupedItems = new GroupedItems(inventory.getStackInSlot(0)); + groupedItems = new GroupedItems(inventory.getItem(0)); inventory.setStackInSlot(0, ItemStack.EMPTY); if (RecipeGridHandler.getPrecedingCrafters(this) .isEmpty()) { @@ -505,7 +505,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { reRender = true; sendData(); invSupplier.invalidate(); - invSupplier = LazyOptional.of(() -> input.getItemHandler(world, pos)); + invSupplier = LazyOptional.of(() -> input.getItemHandler(level, worldPosition)); } public Inventory getInventory() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCraftingInventory.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCraftingInventory.java index 600cb4996..21cf5d725 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCraftingInventory.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCraftingInventory.java @@ -12,7 +12,7 @@ import net.minecraft.item.ItemStack; public class MechanicalCraftingInventory extends CraftingInventory { private static Container dummyContainer = new Container(null, -1) { - public boolean canInteractWith(PlayerEntity playerIn) { + public boolean stillValid(PlayerEntity playerIn) { return false; } }; @@ -22,7 +22,7 @@ public class MechanicalCraftingInventory extends CraftingInventory { for (int y = 0; y < items.height; y++) { for (int x = 0; x < items.width; x++) { ItemStack stack = items.grid.get(Pair.of(x + items.minX, y + items.minY)); - setInventorySlotContents(x + (items.height - y - 1) * items.width, + setItem(x + (items.height - y - 1) * items.width, stack == null ? ItemStack.EMPTY : stack.copy()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCraftingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCraftingRecipe.java index a44acfa42..6ee3fb525 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCraftingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCraftingRecipe.java @@ -23,7 +23,7 @@ public class MechanicalCraftingRecipe extends ShapedRecipe { private static MechanicalCraftingRecipe fromShaped(ShapedRecipe recipe) { return new MechanicalCraftingRecipe(recipe.getId(), recipe.getGroup(), recipe.getWidth(), recipe.getHeight(), - recipe.getIngredients(), recipe.getRecipeOutput()); + recipe.getIngredients(), recipe.getResultItem()); } @Override @@ -37,7 +37,7 @@ public class MechanicalCraftingRecipe extends ShapedRecipe { } @Override - public boolean isDynamic() { + public boolean isSpecial() { return true; } @@ -49,13 +49,13 @@ public class MechanicalCraftingRecipe extends ShapedRecipe { public static class Serializer extends ShapedRecipe.Serializer { @Override - public ShapedRecipe read(ResourceLocation recipeId, JsonObject json) { - return fromShaped(super.read(recipeId, json)); + public ShapedRecipe fromJson(ResourceLocation recipeId, JsonObject json) { + return fromShaped(super.fromJson(recipeId, json)); } @Override - public ShapedRecipe read(ResourceLocation recipeId, PacketBuffer buffer) { - return fromShaped(super.read(recipeId, buffer)); + public ShapedRecipe fromNetwork(ResourceLocation recipeId, PacketBuffer buffer) { + return fromShaped(super.fromNetwork(recipeId, buffer)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java index 0650e9107..12a0ee73a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java @@ -66,8 +66,8 @@ public class RecipeGridHandler { empty = true; else allEmpty = false; - if (poweredStart && current.getWorld() - .isBlockPowered(current.getPos())) + if (poweredStart && current.getLevel() + .hasNeighborSignal(current.getBlockPos())) powered = true; crafters.add(current); @@ -89,29 +89,29 @@ public class RecipeGridHandler { if (!isCrafter(state)) return null; - BlockPos targetPos = crafter.getPos() - .offset(MechanicalCrafterBlock.getTargetDirection(state)); - MechanicalCrafterTileEntity targetTE = CrafterHelper.getCrafter(crafter.getWorld(), targetPos); + BlockPos targetPos = crafter.getBlockPos() + .relative(MechanicalCrafterBlock.getTargetDirection(state)); + MechanicalCrafterTileEntity targetTE = CrafterHelper.getCrafter(crafter.getLevel(), targetPos); if (targetTE == null) return null; BlockState targetState = targetTE.getBlockState(); if (!isCrafter(targetState)) return null; - if (state.get(HORIZONTAL_FACING) != targetState.get(HORIZONTAL_FACING)) + if (state.getValue(HORIZONTAL_FACING) != targetState.getValue(HORIZONTAL_FACING)) return null; return targetTE; } public static List getPrecedingCrafters(MechanicalCrafterTileEntity crafter) { - BlockPos pos = crafter.getPos(); - World world = crafter.getWorld(); + BlockPos pos = crafter.getBlockPos(); + World world = crafter.getLevel(); List crafters = new ArrayList<>(); BlockState blockState = crafter.getBlockState(); if (!isCrafter(blockState)) return crafters; - Direction blockFacing = blockState.get(HORIZONTAL_FACING); + Direction blockFacing = blockState.getValue(HORIZONTAL_FACING); Direction blockPointing = MechanicalCrafterBlock.getTargetDirection(blockState); for (Direction facing : Iterate.directions) { if (blockFacing.getAxis() == facing.getAxis()) @@ -119,13 +119,13 @@ public class RecipeGridHandler { if (blockPointing == facing) continue; - BlockPos neighbourPos = pos.offset(facing); + BlockPos neighbourPos = pos.relative(facing); BlockState neighbourState = world.getBlockState(neighbourPos); if (!isCrafter(neighbourState)) continue; if (MechanicalCrafterBlock.getTargetDirection(neighbourState) != facing.getOpposite()) continue; - if (blockFacing != neighbourState.get(HORIZONTAL_FACING)) + if (blockFacing != neighbourState.getValue(HORIZONTAL_FACING)) continue; MechanicalCrafterTileEntity te = CrafterHelper.getCrafter(world, neighbourPos); if (te == null) @@ -147,21 +147,21 @@ public class RecipeGridHandler { ItemStack result = null; if (AllConfigs.SERVER.recipes.allowRegularCraftingInCrafter.get()) result = world.getRecipeManager() - .getRecipe(IRecipeType.CRAFTING, craftinginventory, world) + .getRecipeFor(IRecipeType.CRAFTING, craftinginventory, world) .filter(r -> isRecipeAllowed(r, craftinginventory)) - .map(r -> r.getCraftingResult(craftinginventory)) + .map(r -> r.assemble(craftinginventory)) .orElse(null); if (result == null) result = AllRecipeTypes.MECHANICAL_CRAFTING.find(craftinginventory, world) - .map(r -> r.getCraftingResult(craftinginventory)) + .map(r -> r.assemble(craftinginventory)) .orElse(null); return result; } public static boolean isRecipeAllowed(ICraftingRecipe recipe, CraftingInventory inventory) { if (!AllConfigs.SERVER.recipes.allowBiggerFireworksInCrafter.get() && recipe instanceof FireworkRocketRecipe) { - int numItems = IntStream.range(0, inventory.getSizeInventory()) - .map(i -> inventory.getStackInSlot(i).isEmpty() ? 0 : 1) + int numItems = IntStream.range(0, inventory.getContainerSize()) + .map(i -> inventory.getItem(i).isEmpty() ? 0 : 1) .sum(); if (numItems > 9) return false; @@ -207,7 +207,7 @@ public class RecipeGridHandler { CompoundNBT entry = (CompoundNBT) inbt; int x = entry.getInt("x"); int y = entry.getInt("y"); - ItemStack stack = ItemStack.read(entry.getCompound("item")); + ItemStack stack = ItemStack.of(entry.getCompound("item")); items.grid.put(Pair.of(x, y), stack); }); return items; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankBlock.java index bef299a96..601de50ad 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankBlock.java @@ -29,6 +29,8 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.block.AbstractBlock.Properties; + public class HandCrankBlock extends DirectionalKineticBlock implements ITE { public HandCrankBlock(Properties properties) { @@ -37,7 +39,7 @@ public class HandCrankBlock extends DirectionalKineticBlock implements ITE te.turn(player.isSneaking())); - player.addExhaustion(getRotationSpeed() * AllConfigs.SERVER.kinetics.crankHungerMultiplier.getF()); + withTileEntityDo(worldIn, pos, te -> te.turn(player.isShiftKeyDown())); + player.causeFoodExhaustion(getRotationSpeed() * AllConfigs.SERVER.kinetics.crankHungerMultiplier.getF()); return ActionResultType.SUCCESS; } @@ -67,16 +69,16 @@ public class HandCrankBlock extends DirectionalKineticBlock implements ITE model = getTransformMaterial().getModel(renderedHandle, blockState, opposite); crank = model.createInstance(); @@ -54,7 +54,7 @@ public class HandCrankInstance extends SingleRotatingInstance implements IDynami MatrixStacker.of(ms) .translate(getInstancePosition()) .centre() - .rotate(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis), angle) + .rotate(Direction.get(Direction.AxisDirection.POSITIVE, axis), angle) .unCentre(); crank.setTransform(ms); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java index 586f0ea90..f4a6c7871 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java @@ -28,7 +28,7 @@ public class HandCrankRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; BlockState state = te.getBlockState(); Block block = state.getBlock(); @@ -38,12 +38,12 @@ public class HandCrankRenderer extends KineticTileEntityRenderer { if (renderedHandle == null) return; - Direction facing = state.get(FACING); + Direction facing = state.getValue(FACING); SuperByteBuffer handle = PartialBufferer.getFacing(renderedHandle, state, facing.getOpposite()); HandCrankTileEntity crank = (HandCrankTileEntity) te; kineticRotationTransform(handle, te, facing.getAxis(), (crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light); - handle.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + handle.renderInto(ms, buffer.getBuffer(RenderType.solid())); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankTileEntity.java index 13c10c6e3..c7ad300fd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankTileEntity.java @@ -31,7 +31,7 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity { inUse = 10; this.backwards = back; - if (update && !world.isRemote) + if (update && !level.isClientSide) updateGeneratedRotation(); } @@ -42,7 +42,7 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity { return 0; HandCrankBlock crank = (HandCrankBlock) block; int speed = (inUse == 0 ? 0 : backwards ? -1 : 1) * crank.getRotationSpeed(); - return convertToDirection(speed, getBlockState().get(HandCrankBlock.FACING)); + return convertToDirection(speed, getBlockState().getValue(HandCrankBlock.FACING)); } @Override @@ -68,7 +68,7 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity { if (inUse > 0) { inUse--; - if (inUse == 0 && !world.isRemote) + if (inUse == 0 && !level.isClientSide) updateGeneratedRotation(); } } @@ -90,7 +90,7 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity { if (inUse > 0 && AnimationTickHolder.getTicks() % 10 == 0) { if (!AllBlocks.HAND_CRANK.has(getBlockState())) return; - AllSoundEvents.CRANKING.playAt(world, pos, (inUse) / 2.5f, .65f + (10 - inUse) / 10f, true); + AllSoundEvents.CRANKING.playAt(level, worldPosition, (inUse) / 2.5f, .65f + (10 - inUse) / 10f, true); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java index 8b0b71e91..7698e17af 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java @@ -20,6 +20,8 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault public class ValveHandleBlock extends HandCrankBlock { private final boolean inCreativeTab; @@ -38,32 +40,32 @@ public class ValveHandleBlock extends HandCrankBlock { } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - ItemStack heldItem = player.getHeldItem(handIn); + ItemStack heldItem = player.getItemInHand(handIn); for (DyeColor color : DyeColor.values()) { if (!heldItem.getItem() - .isIn(DyeHelper.getTagOfDye(color))) + .is(DyeHelper.getTagOfDye(color))) continue; - if (worldIn.isRemote) + if (worldIn.isClientSide) return ActionResultType.SUCCESS; BlockState newState = AllBlocks.DYED_VALVE_HANDLES.get(color) .getDefaultState() - .with(FACING, state.get(FACING)); + .setValue(FACING, state.getValue(FACING)); if (newState != state) - worldIn.setBlockState(pos, newState); + worldIn.setBlockAndUpdate(pos, newState); return ActionResultType.SUCCESS; } - return super.onUse(state, worldIn, pos, player, handIn, hit); + return super.use(state, worldIn, pos, player, handIn, hit); } @Override - public void fillItemGroup(ItemGroup group, NonNullList p_149666_2_) { - if (group != ItemGroup.SEARCH && !inCreativeTab) + public void fillItemCategory(ItemGroup group, NonNullList p_149666_2_) { + if (group != ItemGroup.TAB_SEARCH && !inCreativeTab) return; - super.fillItemGroup(group, p_149666_2_); + super.fillItemCategory(group, p_149666_2_); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingRecipe.java index d03b8e07e..1260470e8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingRecipe.java @@ -20,7 +20,7 @@ public class CrushingRecipe extends AbstractCrushingRecipe { if (inv.isEmpty()) return false; return ingredients.get(0) - .test(inv.getStackInSlot(0)); + .test(inv.getItem(0)); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java index 34e587985..de5526d9e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java @@ -25,6 +25,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE { public CrushingWheelBlock(Properties properties) { @@ -38,11 +40,11 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE @Override public Axis getRotationAxis(BlockState state) { - return state.get(AXIS); + return state.getValue(AXIS); } @Override - public BlockRenderType getRenderType(BlockState state) { + public BlockRenderType getRenderShape(BlockState state) { return BlockRenderType.ENTITYBLOCK_ANIMATED; } @@ -53,35 +55,35 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { for (Direction d : Iterate.directions) { - if (d.getAxis() == state.get(AXIS)) + if (d.getAxis() == state.getValue(AXIS)) continue; - if (AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(worldIn.getBlockState(pos.offset(d)))) - worldIn.setBlockState(pos.offset(d), Blocks.AIR.getDefaultState()); + if (AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(worldIn.getBlockState(pos.relative(d)))) + worldIn.setBlockAndUpdate(pos.relative(d), Blocks.AIR.defaultBlockState()); } if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } } public void updateControllers(BlockState state, World world, BlockPos pos, Direction side) { - if (side.getAxis() == state.get(AXIS)) + if (side.getAxis() == state.getValue(AXIS)) return; if (world == null) return; - BlockPos controllerPos = pos.offset(side); - BlockPos otherWheelPos = pos.offset(side, 2); + BlockPos controllerPos = pos.relative(side); + BlockPos otherWheelPos = pos.relative(side, 2); boolean controllerExists = AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(world.getBlockState(controllerPos)); boolean controllerIsValid = controllerExists && world.getBlockState(controllerPos) - .get(VALID); + .getValue(VALID); Direction controllerOldDirection = controllerExists ? world.getBlockState(controllerPos) - .get(FACING) + .getValue(FACING) : null; boolean controllerShouldExist = false; @@ -97,29 +99,29 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE if (te != null && otherTe != null && (te.getSpeed() > 0) != (otherTe.getSpeed() > 0) && te.getSpeed() != 0) { - Axis wheelAxis = state.get(AXIS); + Axis wheelAxis = state.getValue(AXIS); Axis sideAxis = side.getAxis(); - int controllerADO = Math.round(Math.signum(te.getSpeed())) * side.getAxisDirection().getOffset(); + int controllerADO = Math.round(Math.signum(te.getSpeed())) * side.getAxisDirection().getStep(); Vector3d controllerDirVec = new Vector3d(wheelAxis == Axis.X ? 1 : 0 , wheelAxis == Axis.Y ? 1 : 0 , wheelAxis == Axis.Z ? 1 : 0) - .crossProduct(new Vector3d(sideAxis == Axis.X ? 1 : 0 + .cross(new Vector3d(sideAxis == Axis.X ? 1 : 0 , sideAxis == Axis.Y ? 1 : 0 , sideAxis == Axis.Z ? 1 : 0)); - controllerNewDirection = Direction.getFacingFromVector(controllerDirVec.x * controllerADO + controllerNewDirection = Direction.getNearest(controllerDirVec.x * controllerADO , controllerDirVec.y * controllerADO , controllerDirVec.z * controllerADO); controllerShouldBeValid = true; } - if (otherState.get(AXIS) != state.get(AXIS)) + if (otherState.getValue(AXIS) != state.getValue(AXIS)) controllerShouldExist = false; } if (!controllerShouldExist) { if (controllerExists) - world.setBlockState(controllerPos, Blocks.AIR.getDefaultState()); + world.setBlockAndUpdate(controllerPos, Blocks.AIR.defaultBlockState()); return; } @@ -128,13 +130,13 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE .getMaterial() .isReplaceable()) return; - world.setBlockState(controllerPos, AllBlocks.CRUSHING_WHEEL_CONTROLLER.getDefaultState() - .with(VALID, controllerShouldBeValid) - .with(FACING, controllerNewDirection)); + world.setBlockAndUpdate(controllerPos, AllBlocks.CRUSHING_WHEEL_CONTROLLER.getDefaultState() + .setValue(VALID, controllerShouldBeValid) + .setValue(FACING, controllerNewDirection)); } else if (controllerIsValid != controllerShouldBeValid || controllerOldDirection != controllerNewDirection) { - world.setBlockState(controllerPos, world.getBlockState(controllerPos) - .with(VALID, controllerShouldBeValid) - .with(FACING, controllerNewDirection)); + world.setBlockAndUpdate(controllerPos, world.getBlockState(controllerPos) + .setValue(VALID, controllerShouldBeValid) + .setValue(FACING, controllerNewDirection)); } ((CrushingWheelControllerBlock) AllBlocks.CRUSHING_WHEEL_CONTROLLER.get()) @@ -143,7 +145,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE } @Override - public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + public void entityInside(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { if (entityIn.getY() < pos.getY() + 1.25f || !entityIn.isOnGround()) return; @@ -153,29 +155,29 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE double x = 0; double z = 0; - if (state.get(AXIS) == Axis.X) { + if (state.getValue(AXIS) == Axis.X) { z = speed / 20f; x += (pos.getX() + .5f - entityIn.getX()) * .1f; } - if (state.get(AXIS) == Axis.Z) { + if (state.getValue(AXIS) == Axis.Z) { x = speed / -20f; z += (pos.getZ() + .5f - entityIn.getZ()) * .1f; } - entityIn.setMotion(entityIn.getMotion() + entityIn.setDeltaMovement(entityIn.getDeltaMovement() .add(x, 0, z)); } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { for (Direction direction : Iterate.directions) { - BlockPos neighbourPos = pos.offset(direction); + BlockPos neighbourPos = pos.relative(direction); BlockState neighbourState = worldIn.getBlockState(neighbourPos); - Axis stateAxis = state.get(AXIS); + Axis stateAxis = state.getValue(AXIS); if (AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(neighbourState) && direction.getAxis() != stateAxis) return false; if (!AllBlocks.CRUSHING_WHEEL.has(neighbourState)) continue; - if (neighbourState.get(AXIS) != stateAxis || stateAxis != direction.getAxis()) + if (neighbourState.getValue(AXIS) != stateAxis || stateAxis != direction.getAxis()) return false; } @@ -184,7 +186,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face.getAxis() == state.get(AXIS); + return face.getAxis() == state.getValue(AXIS); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java index 944b8e073..686d13d2b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java @@ -37,6 +37,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class CrushingWheelControllerBlock extends DirectionalBlock implements ITE { @@ -52,7 +54,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) { + public boolean canBeReplaced(BlockState state, BlockItemUseContext useContext) { return false; } @@ -67,17 +69,17 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(VALID); builder.add(FACING); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } - public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { - if (!state.get(VALID)) + public void entityInside(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + if (!state.getValue(VALID)) return; - Direction facing = state.get(FACING); + Direction facing = state.getValue(FACING); Axis axis = facing.getAxis(); checkEntityForProcessing(worldIn, pos, entityIn); @@ -85,7 +87,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock withTileEntityDo(worldIn, pos, te -> { if (te.processingEntity == entityIn) - entityIn.setMotionMultiplier(state, new Vector3d(axis == Axis.X ? (double) 0.05F : 0.25D + entityIn.makeStuckInBlock(state, new Vector3d(axis == Axis.X ? (double) 0.05F : 0.25D , axis == Axis.Y ? (double) 0.05F : 0.25D , axis == Axis.Z ? (double) 0.05F : 0.25D)); }); @@ -98,7 +100,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock if (te.crushingspeed == 0) return; if (entityIn instanceof ItemEntity) - ((ItemEntity) entityIn).setPickupDelay(10); + ((ItemEntity) entityIn).setPickUpDelay(10); CompoundNBT data = entityIn.getPersistentData(); if (data.contains("BypassCrushingWheel")) { if (pos.equals(NBTUtil.readBlockPos(data.getCompound("BypassCrushingWheel")))) @@ -109,21 +111,21 @@ public class CrushingWheelControllerBlock extends DirectionalBlock boolean isPlayer = entityIn instanceof PlayerEntity; if (isPlayer && ((PlayerEntity) entityIn).isCreative()) return; - if (isPlayer && entityIn.world.getDifficulty() == Difficulty.PEACEFUL) + if (isPlayer && entityIn.level.getDifficulty() == Difficulty.PEACEFUL) return; te.startCrushing(entityIn); } @Override - public void onLanded(IBlockReader worldIn, Entity entityIn) { - super.onLanded(worldIn, entityIn); + public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + super.updateEntityAfterFallOn(worldIn, entityIn); //Moved to onEntityCollision to allow for omnidirectional input } @Override public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { - if (!stateIn.get(VALID)) + if (!stateIn.getValue(VALID)) return; if (rand.nextInt(1) != 0) return; @@ -134,7 +136,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { updateSpeed(stateIn, worldIn, currentPos); return stateIn; @@ -142,7 +144,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock public void updateSpeed(BlockState state, IWorld world, BlockPos pos) { withTileEntityDo(world, pos, te -> { - if (!state.get(VALID)) { + if (!state.getValue(VALID)) { if (te.crushingspeed != 0) { te.crushingspeed = 0; te.sendData(); @@ -151,12 +153,12 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } for (Direction d : Iterate.directions) { - BlockState neighbour = world.getBlockState(pos.offset(d)); + BlockState neighbour = world.getBlockState(pos.relative(d)); if (!AllBlocks.CRUSHING_WHEEL.has(neighbour)) continue; - if (neighbour.get(BlockStateProperties.AXIS) == d.getAxis()) + if (neighbour.getValue(BlockStateProperties.AXIS) == d.getAxis()) continue; - KineticTileEntity wheelTe = (KineticTileEntity) world.getTileEntity(pos.offset(d)); + KineticTileEntity wheelTe = (KineticTileEntity) world.getBlockEntity(pos.relative(d)); te.crushingspeed = Math.abs(wheelTe.getSpeed() / 50f); te.sendData(); break; @@ -167,9 +169,9 @@ public class CrushingWheelControllerBlock extends DirectionalBlock @Override public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - VoxelShape standardShape = AllShapes.CRUSHING_WHEEL_CONTROLLER_COLLISION.get(state.get(FACING)); + VoxelShape standardShape = AllShapes.CRUSHING_WHEEL_CONTROLLER_COLLISION.get(state.getValue(FACING)); - if (!state.get(VALID)) + if (!state.getValue(VALID)) return standardShape; Entity entity = context.getEntity(); @@ -179,7 +181,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock CompoundNBT data = entity.getPersistentData(); if (data.contains("BypassCrushingWheel")) if (pos.equals(NBTUtil.readBlockPos(data.getCompound("BypassCrushingWheel")))) - if (state.get(FACING) != Direction.UP) // Allow output items to land on top of the block rather than falling back through. + if (state.getValue(FACING) != Direction.UP) // Allow output items to land on top of the block rather than falling back through. return VoxelShapes.empty(); CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos); @@ -190,12 +192,12 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (!state.hasTileEntity() || state.getBlock() == newState.getBlock()) return; withTileEntityDo(worldIn, pos, te -> ItemHelper.dropContents(worldIn, pos, te.inventory)); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } @Override @@ -204,7 +206,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java index dbe728ad9..5928a5838 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java @@ -82,7 +82,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { BlockState blockState = getBlockState(); if (blockState == null) return false; - Direction direction = blockState.get(CrushingWheelControllerBlock.FACING); + Direction direction = blockState.getValue(CrushingWheelControllerBlock.FACING); return direction == Direction.DOWN || direction == side; } @@ -91,8 +91,8 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { super.tick(); if (searchForEntity) { searchForEntity = false; - List search = world.getEntitiesInAABBexcluding(null, new AxisAlignedBB(getPos()), - e -> entityUUID.equals(e.getUniqueID())); + List search = level.getEntities((Entity) null, new AxisAlignedBB(getBlockPos()), + e -> entityUUID.equals(e.getUUID())); if (search.isEmpty()) clear(); else @@ -104,15 +104,15 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { if (crushingspeed == 0) return; - if (world.isRemote) + if (level.isClientSide) DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> this.tickAudio()); float speed = crushingspeed * 4; - Vector3d centerPos = VecHelper.getCenterOf(pos); - Direction facing = getBlockState().get(FACING); + Vector3d centerPos = VecHelper.getCenterOf(worldPosition); + Direction facing = getBlockState().getValue(FACING); int offset = facing.getAxisDirection() - .getOffset(); + .getStep(); Vector3d outSpeed = new Vector3d((facing.getAxis() == Axis.X ? 0.25D : 0.0D) * offset, offset == 1 ? (facing.getAxis() == Axis.Y ? 0.5D : 0.0D) : 0.0D // Increased upwards speed so upwards // crushing wheels shoot out the item @@ -130,13 +130,13 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { inventory.remainingTime -= processingSpeed; spawnParticles(inventory.getStackInSlot(0)); - if (world.isRemote) + if (level.isClientSide) return; if (inventory.remainingTime < 20 && !inventory.appliedRecipe) { applyRecipe(); inventory.appliedRecipe = true; - world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 2 | 16); + level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 2 | 16); return; } @@ -148,10 +148,10 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { // Output Items if (facing.getAxis() .isHorizontal() || facing == Direction.DOWN) { - BlockPos nextPos = pos.add(facing.getAxis() == Axis.X ? 1f * offset : 0f, (-1f), + BlockPos nextPos = worldPosition.offset(facing.getAxis() == Axis.X ? 1f * offset : 0f, (-1f), facing.getAxis() == Axis.Z ? 1f * offset : 0f); DirectBeltInputBehaviour behaviour = - TileEntityBehaviour.get(world, nextPos, DirectBeltInputBehaviour.TYPE); + TileEntityBehaviour.get(level, nextPos, DirectBeltInputBehaviour.TYPE); if (behaviour != null) { boolean changed = false; if (!behaviour.canInsertFromSide(facing)) @@ -167,7 +167,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { changed = true; } if (changed) { - markDirty(); + setChanged(); sendData(); } return; @@ -179,30 +179,30 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { ItemStack stack = inventory.getStackInSlot(slot); if (stack.isEmpty()) continue; - ItemEntity entityIn = new ItemEntity(world, outPos.x, outPos.y, outPos.z, stack); - entityIn.setMotion(outSpeed); + ItemEntity entityIn = new ItemEntity(level, outPos.x, outPos.y, outPos.z, stack); + entityIn.setDeltaMovement(outSpeed); entityIn.getPersistentData() - .put("BypassCrushingWheel", NBTUtil.writeBlockPos(pos)); - world.addEntity(entityIn); + .put("BypassCrushingWheel", NBTUtil.writeBlockPos(worldPosition)); + level.addFreshEntity(entityIn); } inventory.clear(); - world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 2 | 16); + level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 2 | 16); return; } if (!processingEntity.isAlive() || !processingEntity.getBoundingBox() - .intersects(new AxisAlignedBB(pos).grow(.5f))) { + .intersects(new AxisAlignedBB(worldPosition).inflate(.5f))) { clear(); return; } - double xMotion = ((pos.getX() + .5f) - processingEntity.getX()) / 2f; - double zMotion = ((pos.getZ() + .5f) - processingEntity.getZ()) / 2f; - if (processingEntity.isSneaking()) + double xMotion = ((worldPosition.getX() + .5f) - processingEntity.getX()) / 2f; + double zMotion = ((worldPosition.getZ() + .5f) - processingEntity.getZ()) / 2f; + if (processingEntity.isShiftKeyDown()) xMotion = zMotion = 0; double movement = Math.max(-speed / 4f, -.5f) * -offset; - processingEntity.setMotion( + processingEntity.setDeltaMovement( new Vector3d(facing.getAxis() == Axis.X ? movement : xMotion, facing.getAxis() == Axis.Y ? movement : 0f // Do // not // move @@ -215,7 +215,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { // crushers, , facing.getAxis() == Axis.Z ? movement : zMotion)); // Or they'll only get their feet crushed. - if (world.isRemote) + if (level.isClientSide) return; if (!(processingEntity instanceof ItemEntity)) { @@ -230,18 +230,18 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { // kill them. && (((LivingEntity) processingEntity).hurtTime <= 0)) { // This way it can actually output the items // to the right spot. - processingEntity.setPosition(entityOutPos.x, entityOutPos.y, entityOutPos.z); + processingEntity.setPos(entityOutPos.x, entityOutPos.y, entityOutPos.z); } } - processingEntity.attackEntityFrom(CrushingWheelTileEntity.damageSource, crusherDamage); + processingEntity.hurt(CrushingWheelTileEntity.damageSource, crusherDamage); if (!processingEntity.isAlive()) { - processingEntity.setPosition(entityOutPos.x, entityOutPos.y, entityOutPos.z); + processingEntity.setPos(entityOutPos.x, entityOutPos.y, entityOutPos.z); } return; } ItemEntity itemEntity = (ItemEntity) processingEntity; - itemEntity.setPickupDelay(20); + itemEntity.setPickUpDelay(20); if (facing.getAxis() == Axis.Y) { if (processingEntity.getY() * -offset < (centerPos.y - .25f) * -offset) { intakeItem(itemEntity); @@ -263,7 +263,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { if (entityUUID == null && inventory.getStackInSlot(0) .isEmpty()) return; - SoundScapes.play(AmbienceGroup.CRUSHING, pos, pitch); + SoundScapes.play(AmbienceGroup.CRUSHING, worldPosition, pitch); } private void intakeItem(ItemEntity itemEntity) { @@ -272,7 +272,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { .copy()); itemInserted(inventory.getStackInSlot(0)); itemEntity.remove(); - world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 2 | 16); + level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 2 | 16); } protected void spawnParticles(ItemStack stack) { @@ -282,14 +282,14 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { IParticleData particleData = null; if (stack.getItem() instanceof BlockItem) particleData = new BlockParticleData(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock() - .getDefaultState()); + .defaultBlockState()); else particleData = new ItemParticleData(ParticleTypes.ITEM, stack); - Random r = world.rand; + Random r = level.random; for (int i = 0; i < 4; i++) - world.addParticle(particleData, pos.getX() + r.nextFloat(), pos.getY() + r.nextFloat(), - pos.getZ() + r.nextFloat(), 0, 0, 0); + level.addParticle(particleData, worldPosition.getX() + r.nextFloat(), worldPosition.getY() + r.nextFloat(), + worldPosition.getZ() + r.nextFloat(), 0, 0, 0); } private void applyRecipe() { @@ -317,16 +317,16 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { } public Optional> findRecipe() { - Optional> crushingRecipe = AllRecipeTypes.CRUSHING.find(wrapper, world); + Optional> crushingRecipe = AllRecipeTypes.CRUSHING.find(wrapper, level); if (!crushingRecipe.isPresent()) - crushingRecipe = AllRecipeTypes.MILLING.find(wrapper, world); + crushingRecipe = AllRecipeTypes.MILLING.find(wrapper, level); return crushingRecipe; } @Override public void write(CompoundNBT compound, boolean clientPacket) { if (hasEntity()) - compound.put("Entity", NBTUtil.fromUuid(entityUUID)); + compound.put("Entity", NBTUtil.createUUID(entityUUID)); compound.put("Inventory", inventory.serializeNBT()); compound.putFloat("Speed", crushingspeed); super.write(compound, clientPacket); @@ -336,7 +336,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); if (compound.contains("Entity") && !isOccupied()) { - entityUUID = NBTUtil.readUniqueId(NBTHelper.getINBT(compound, "Entity")); + entityUUID = NBTUtil.loadUUID(NBTHelper.getINBT(compound, "Entity")); this.searchForEntity = true; } crushingspeed = compound.getFloat("Speed"); @@ -345,7 +345,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { public void startCrushing(Entity entity) { processingEntity = entity; - entityUUID = entity.getUniqueID(); + entityUUID = entity.getUUID(); } private void itemInserted(ItemStack stack) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java index ea210238d..fa0fa32af 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java @@ -17,8 +17,8 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @EventBusSubscriber public class CrushingWheelTileEntity extends KineticTileEntity { - public static DamageSource damageSource = new DamageSource("create.crush").setDamageBypassesArmor() - .setDifficultyScaled(); + public static DamageSource damageSource = new DamageSource("create.crush").bypassArmor() + .setScalesWithDifficulty(); public CrushingWheelTileEntity(TileEntityType type) { super(type); @@ -33,13 +33,13 @@ public class CrushingWheelTileEntity extends KineticTileEntity { public void fixControllers() { for (Direction d : Iterate.directions) - ((CrushingWheelBlock) getBlockState().getBlock()).updateControllers(getBlockState(), getWorld(), getPos(), + ((CrushingWheelBlock) getBlockState().getBlock()).updateControllers(getBlockState(), getLevel(), getBlockPos(), d); } @Override public AxisAlignedBB makeRenderBoundingBox() { - return new AxisAlignedBB(pos).grow(1); + return new AxisAlignedBB(worldPosition).inflate(1); } @Override @@ -61,7 +61,7 @@ public class CrushingWheelTileEntity extends KineticTileEntity { return; Vector3d outSpeed = Vector3d.ZERO; for (ItemEntity outputItem : event.getDrops()) { - outputItem.setMotion(outSpeed); + outputItem.setDeltaMovement(outSpeed); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java index 7d007d11e..b0900e2be 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java @@ -38,7 +38,7 @@ public class BeltDeployerCallbacks { if (deployerTileEntity.mode == Mode.PUNCH) return ProcessingResult.PASS; BlockState blockState = deployerTileEntity.getBlockState(); - if (!blockState.contains(FACING) || blockState.get(FACING) != Direction.DOWN) + if (!blockState.hasProperty(FACING) || blockState.getValue(FACING) != Direction.DOWN) return ProcessingResult.PASS; if (deployerTileEntity.state != State.WAITING) return ProcessingResult.HOLD; @@ -58,7 +58,7 @@ public class BeltDeployerCallbacks { if (deployerTileEntity.getSpeed() == 0) return ProcessingResult.PASS; BlockState blockState = deployerTileEntity.getBlockState(); - if (!blockState.contains(FACING) || blockState.get(FACING) != Direction.DOWN) + if (!blockState.hasProperty(FACING) || blockState.getValue(FACING) != Direction.DOWN) return ProcessingResult.PASS; IRecipe recipe = deployerTileEntity.getRecipe(s.stack); if (recipe == null) @@ -103,17 +103,17 @@ public class BeltDeployerCallbacks { else handler.handleProcessingOnItem(transported, TransportedResult.convertToAndLeaveHeld(collect, left)); - ItemStack heldItem = deployerTileEntity.player.getHeldItemMainhand(); - if (heldItem.isDamageable()) - heldItem.damageItem(1, deployerTileEntity.player, s -> s.sendBreakAnimation(Hand.MAIN_HAND)); + ItemStack heldItem = deployerTileEntity.player.getMainHandItem(); + if (heldItem.isDamageableItem()) + heldItem.hurtAndBreak(1, deployerTileEntity.player, s -> s.broadcastBreakEvent(Hand.MAIN_HAND)); else heldItem.shrink(1); - BlockPos pos = deployerTileEntity.getPos(); - World world = deployerTileEntity.getWorld(); + BlockPos pos = deployerTileEntity.getBlockPos(); + World world = deployerTileEntity.getLevel(); if (heldItem.isEmpty()) - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_BREAK, SoundCategory.BLOCKS, .25f, 1); - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, .25f, .75f); + world.playSound(null, pos, SoundEvents.ITEM_BREAK, SoundCategory.BLOCKS, .25f, 1); + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.BLOCKS, .25f, .75f); if (recipe instanceof SandPaperPolishingRecipe) AllSoundEvents.AUTO_POLISH.playOnServer(world, pos, .25f, 1f); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java index 437ac1686..2a2d19cd1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java @@ -51,9 +51,9 @@ public class DeployerActorInstance extends ActorInstance { PartialModel handPose = DeployerRenderer.getHandPose(mode); stationaryTimer = context.data.contains("StationaryTimer"); - facing = state.get(FACING); + facing = state.getValue(FACING); - boolean rotatePole = state.get(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z; + boolean rotatePole = state.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z; yRot = AngleHelper.horizontalAngle(facing); zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; zRotPole = rotatePole ? 90 : 0; @@ -89,7 +89,7 @@ public class DeployerActorInstance extends ActorInstance { factor = .5f - MathHelper.clamp(MathHelper.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1); } - Vector3d offset = Vector3d.of(facing.getDirectionVec()).scale(factor); + Vector3d offset = Vector3d.atLowerCornerOf(facing.getNormal()).scale(factor); MatrixStack ms = new MatrixStack(); MatrixStacker msr = MatrixStacker.of(ms); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerApplicationRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerApplicationRecipe.java index d3c6f0ed8..c315bea50 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerApplicationRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerApplicationRecipe.java @@ -37,9 +37,9 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i @Override public boolean matches(RecipeWrapper inv, World p_77569_2_) { return ingredients.get(0) - .test(inv.getStackInSlot(0)) + .test(inv.getItem(0)) && ingredients.get(1) - .test(inv.getStackInSlot(1)); + .test(inv.getItem(1)); } @Override @@ -69,8 +69,8 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i .map(r -> new ProcessingRecipeBuilder<>(DeployerApplicationRecipe::new, Create.asResource(r.getId() .getPath() + "_using_deployer")).require(r.getIngredients() .get(0)) - .require(Ingredient.fromItems(AllItems.SAND_PAPER.get(), AllItems.RED_SAND_PAPER.get())) - .output(r.getRecipeOutput()) + .require(Ingredient.of(AllItems.SAND_PAPER.get(), AllItems.RED_SAND_PAPER.get())) + .output(r.getResultItem()) .build()) .collect(Collectors.toList()); } @@ -84,11 +84,11 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i @OnlyIn(Dist.CLIENT) public ITextComponent getDescriptionForAssembly() { ItemStack[] matchingStacks = ingredients.get(1) - .getMatchingStacks(); + .getItems(); if (matchingStacks.length == 0) return new StringTextComponent("Invalid"); return Lang.translate("recipe.assembly.deploying_item", - new TranslationTextComponent(matchingStacks[0].getTranslationKey()).getString()); + new TranslationTextComponent(matchingStacks[0].getDescriptionId()).getString()); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerBlock.java index 8934429fa..5485dd542 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerBlock.java @@ -31,6 +31,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE { @@ -45,63 +47,63 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE { if (te.player != null && !isMoving) { - te.player.inventory.dropAllItems(); - te.overflowItems.forEach(itemstack -> te.player.dropItem(itemstack, true, false)); + te.player.inventory.dropAll(); + te.overflowItems.forEach(itemstack -> te.player.drop(itemstack, true, false)); te.player.remove(); te.player = null; } }); TileEntityBehaviour.destroy(worldIn, pos, FilteringBehaviour.TYPE); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - ItemStack heldByPlayer = player.getHeldItem(handIn) + ItemStack heldByPlayer = player.getItemInHand(handIn) .copy(); if (AllItems.WRENCH.isIn(heldByPlayer)) return ActionResultType.PASS; - if (hit.getFace() != state.get(FACING)) + if (hit.getDirection() != state.getValue(FACING)) return ActionResultType.PASS; - if (worldIn.isRemote) + if (worldIn.isClientSide) return ActionResultType.SUCCESS; withTileEntityDo(worldIn, pos, te -> { - ItemStack heldByDeployer = te.player.getHeldItemMainhand() + ItemStack heldByDeployer = te.player.getMainHandItem() .copy(); if (heldByDeployer.isEmpty() && heldByPlayer.isEmpty()) return; - player.setHeldItem(handIn, heldByDeployer); - te.player.setHeldItem(Hand.MAIN_HAND, heldByPlayer); + player.setItemInHand(handIn, heldByDeployer); + te.player.setItemInHand(Hand.MAIN_HAND, heldByPlayer); te.sendData(); }); @@ -114,8 +116,8 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE fakePlayer.inventory.placeItemBackInInventory(trueSource.world, stack.getItem())); + .forEach(stack -> fakePlayer.inventory.placeItemBackInInventory(trueSource.level, stack.getItem())); event.setCanceled(true); } } @@ -118,8 +118,8 @@ public class DeployerFakePlayer extends FakePlayer { @Override public void remove(boolean keepData) { - if (blockBreakingProgress != null && !world.isRemote) - world.sendBlockBreakProgress(getEntityId(), blockBreakingProgress.getKey(), -1); + if (blockBreakingProgress != null && !level.isClientSide) + level.destroyBlockProgress(getId(), blockBreakingProgress.getKey(), -1); super.remove(keepData); } @@ -142,11 +142,11 @@ public class DeployerFakePlayer extends FakePlayer { switch (setting) { case ALL: - mob.setAttackTarget(null); + mob.setTarget(null); break; case CREEPERS: if (mob instanceof CreeperEntity) - mob.setAttackTarget(null); + mob.setTarget(null); break; case NONE: default: @@ -159,10 +159,10 @@ public class DeployerFakePlayer extends FakePlayer { } @Override - public void sendPacket(IPacket packetIn) {} + public void send(IPacket packetIn) {} @Override - public void sendPacket(IPacket packetIn, + public void send(IPacket packetIn, GenericFutureListener> futureListeners) {} } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerFilterSlot.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerFilterSlot.java index b5c071b12..5267ac546 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerFilterSlot.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerFilterSlot.java @@ -15,7 +15,7 @@ public class DeployerFilterSlot extends ValueBoxTransform { @Override protected Vector3d getLocalOffset(BlockState state) { - Direction facing = state.get(DeployerBlock.FACING); + Direction facing = state.getValue(DeployerBlock.FACING); Vector3d vec = VecHelper.voxelSpace(8f, 13.5f, 11.5f); float yRot = AngleHelper.horizontalAngle(facing); @@ -28,7 +28,7 @@ public class DeployerFilterSlot extends ValueBoxTransform { @Override protected void rotate(BlockState state, MatrixStack ms) { - Direction facing = state.get(DeployerBlock.FACING); + Direction facing = state.getValue(DeployerBlock.FACING); float xRot = facing == Direction.UP ? 90 : facing == Direction.DOWN ? 270 : 0; float yRot = AngleHelper.horizontalAngle(facing) + 180; MatrixStacker.of(ms) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java index 696332e89..60809d55c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java @@ -80,26 +80,26 @@ public class DeployerHandler { boolean rayMode = false; private ItemUseWorld(World world, Direction face, BlockPos pos) { - super(world, world.getChunkProvider()); + super(world, world.getChunkSource()); this.face = face; this.pos = pos; } @Override - public BlockRayTraceResult rayTraceBlocks(RayTraceContext context) { + public BlockRayTraceResult clip(RayTraceContext context) { rayMode = true; - BlockRayTraceResult rayTraceBlocks = super.rayTraceBlocks(context); + BlockRayTraceResult rayTraceBlocks = super.clip(context); rayMode = false; return rayTraceBlocks; } @Override public BlockState getBlockState(BlockPos position) { - if (rayMode && (pos.offset(face.getOpposite(), 3) + if (rayMode && (pos.relative(face.getOpposite(), 3) .equals(position) - || pos.offset(face.getOpposite(), 1) + || pos.relative(face.getOpposite(), 1) .equals(position))) - return Blocks.BEDROCK.getDefaultState(); + return Blocks.BEDROCK.defaultBlockState(); return world.getBlockState(position); } } @@ -114,7 +114,7 @@ public class DeployerHandler { BucketItem bucketItem = (BucketItem) held.getItem(); Fluid fluid = bucketItem.getFluid(); if (fluid != Fluids.EMPTY && world.getFluidState(targetPos) - .getFluid() == fluid) + .getType() == fluid) return false; } @@ -127,13 +127,13 @@ public class DeployerHandler { static void activate(DeployerFakePlayer player, Vector3d vec, BlockPos clickedPos, Vector3d extensionVector, Mode mode) { - Multimap attributeModifiers = player.getHeldItemMainhand() + Multimap attributeModifiers = player.getMainHandItem() .getAttributeModifiers(EquipmentSlotType.MAINHAND); player.getAttributes() - .addTemporaryModifiers(attributeModifiers); + .addTransientAttributeModifiers(attributeModifiers); activateInner(player, vec, clickedPos, extensionVector, mode); player.getAttributes() - .addTemporaryModifiers(attributeModifiers); + .addTransientAttributeModifiers(attributeModifiers); } private static void activateInner(DeployerFakePlayer player, Vector3d vec, BlockPos clickedPos, @@ -141,19 +141,19 @@ public class DeployerHandler { Vector3d rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f)); Vector3d rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f)); - player.setPosition(rayOrigin.x, rayOrigin.y, rayOrigin.z); + player.setPos(rayOrigin.x, rayOrigin.y, rayOrigin.z); BlockPos pos = new BlockPos(vec); - ItemStack stack = player.getHeldItemMainhand(); + ItemStack stack = player.getMainHandItem(); Item item = stack.getItem(); // Check for entities - final ServerWorld world = player.getServerWorld(); - List entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(clickedPos)).stream() + final ServerWorld world = player.getLevel(); + List entities = world.getEntitiesOfClass(Entity.class, new AxisAlignedBB(clickedPos)).stream() .filter(e -> !(e instanceof AbstractContraptionEntity)) .collect(Collectors.toList()); Hand hand = Hand.MAIN_HAND; if (!entities.isEmpty()) { - Entity entity = entities.get(world.rand.nextInt(entities.size())); + Entity entity = entities.get(world.random.nextInt(entities.size())); List capturedDrops = new ArrayList<>(); boolean success = false; entity.captureDrops(capturedDrops); @@ -166,24 +166,24 @@ public class DeployerHandler { return; } if (cancelResult == null) { - if (entity.processInitialInteract(player, hand) - .isAccepted()){ + if (entity.interact(player, hand) + .consumesAction()){ if (entity instanceof AbstractVillagerEntity) { AbstractVillagerEntity villager = ((AbstractVillagerEntity) entity); - if (villager.getCustomer() instanceof DeployerFakePlayer) - villager.setCustomer(null); + if (villager.getTradingPlayer() instanceof DeployerFakePlayer) + villager.setTradingPlayer(null); } success = true; } - else if (entity instanceof LivingEntity && stack.useOnEntity(player, (LivingEntity) entity, hand) - .isAccepted()) + else if (entity instanceof LivingEntity && stack.interactLivingEntity(player, (LivingEntity) entity, hand) + .consumesAction()) success = true; } - if (!success && stack.isFood() && entity instanceof PlayerEntity) { + if (!success && stack.isEdible() && entity instanceof PlayerEntity) { PlayerEntity playerEntity = (PlayerEntity) entity; - if (playerEntity.canEat(item.getFood() - .canEatWhenFull())) { - playerEntity.onFoodEaten(world, stack); + if (playerEntity.canEat(item.getFoodProperties() + .canAlwaysEat())) { + playerEntity.eat(world, stack); player.spawnedItemEffects = stack.copy(); success = true; } @@ -192,8 +192,8 @@ public class DeployerHandler { // Punch entity if (mode == Mode.PUNCH) { - player.resetCooldown(); - player.attackTargetEntityWithCurrentItem(entity); + player.resetAttackStrengthTicker(); + player.attack(entity); success = true; } @@ -206,18 +206,18 @@ public class DeployerHandler { // Shoot ray RayTraceContext rayTraceContext = new RayTraceContext(rayOrigin, rayTarget, BlockMode.OUTLINE, FluidMode.NONE, player); - BlockRayTraceResult result = world.rayTraceBlocks(rayTraceContext); - if (result.getPos() != clickedPos) - result = new BlockRayTraceResult(result.getHitVec(), result.getFace(), clickedPos, result.isInside()); + BlockRayTraceResult result = world.clip(rayTraceContext); + if (result.getBlockPos() != clickedPos) + result = new BlockRayTraceResult(result.getLocation(), result.getDirection(), clickedPos, result.isInside()); BlockState clickedState = world.getBlockState(clickedPos); - Direction face = result.getFace(); + Direction face = result.getDirection(); if (face == null) - face = Direction.getFacingFromVector(extensionVector.x, extensionVector.y, extensionVector.z) + face = Direction.getNearest(extensionVector.x, extensionVector.y, extensionVector.z) .getOpposite(); // Left click if (mode == Mode.PUNCH) { - if (!world.isBlockModifiable(player, clickedPos)) + if (!world.mayInteract(player, clickedPos)) return; if (clickedState.getShape(world, clickedPos) .isEmpty()) { @@ -230,11 +230,11 @@ public class DeployerHandler { if (BlockHelper.extinguishFire(world, player, clickedPos, face)) // FIXME: is there an equivalent in world, as there was in 1.15? return; if (event.getUseBlock() != DENY) - clickedState.onBlockClicked(world, clickedPos, player); + clickedState.attack(world, clickedPos, player); if (stack.isEmpty()) return; - float progress = clickedState.getPlayerRelativeBlockHardness(player, world, clickedPos) * 16; + float progress = clickedState.getDestroyProgress(player, world, clickedPos) * 16; float before = 0; Pair blockBreakingProgress = player.blockBreakingProgress; if (blockBreakingProgress != null) @@ -244,8 +244,8 @@ public class DeployerHandler { .getHitSound(), SoundCategory.NEUTRAL, .25f, 1); if (progress >= 1) { - tryHarvestBlock(player.interactionManager, clickedPos); - world.sendBlockBreakProgress(player.getEntityId(), clickedPos, -1); + tryHarvestBlock(player.gameMode, clickedPos); + world.destroyBlockProgress(player.getId(), clickedPos, -1); player.blockBreakingProgress = null; return; } @@ -255,7 +255,7 @@ public class DeployerHandler { } if ((int) (before * 10) != (int) (progress * 10)) - world.sendBlockBreakProgress(player.getEntityId(), clickedPos, (int) (progress * 10)); + world.destroyBlockProgress(player.getId(), clickedPos, (int) (progress * 10)); player.blockBreakingProgress = Pair.of(clickedPos, progress); return; } @@ -278,14 +278,14 @@ public class DeployerHandler { return; } - boolean holdingSomething = !player.getHeldItemMainhand() + boolean holdingSomething = !player.getMainHandItem() .isEmpty(); boolean flag1 = - !(player.isSneaking() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player)); + !(player.isShiftKeyDown() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player)); // Use on block if (useBlock != DENY && flag1 - && safeOnUse(clickedState, world, clickedPos, player, hand, result).isAccepted()) + && safeOnUse(clickedState, world, clickedPos, player, hand, result).consumesAction()) return; if (stack.isEmpty()) return; @@ -293,24 +293,24 @@ public class DeployerHandler { return; if (item instanceof BlockItem && !(item instanceof CartAssemblerBlockItem) - && !clickedState.isReplaceable(new BlockItemUseContext(itemusecontext))) + && !clickedState.canBeReplaced(new BlockItemUseContext(itemusecontext))) return; // Reposition fire placement for convenience if (item == Items.FLINT_AND_STEEL) { - Direction newFace = result.getFace(); - BlockPos newPos = result.getPos(); - if (!AbstractFireBlock.method_30032(world, clickedPos, newFace)) + Direction newFace = result.getDirection(); + BlockPos newPos = result.getBlockPos(); + if (!AbstractFireBlock.canBePlacedAt(world, clickedPos, newFace)) newFace = Direction.UP; if (clickedState.getMaterial() == Material.AIR) - newPos = newPos.offset(face.getOpposite()); - result = new BlockRayTraceResult(result.getHitVec(), newFace, newPos, result.isInside()); + newPos = newPos.relative(face.getOpposite()); + result = new BlockRayTraceResult(result.getLocation(), newFace, newPos, result.isInside()); itemusecontext = new ItemUseContext(player, hand, result); } // 'Inert' item use behaviour & block placement - ActionResultType onItemUse = stack.onItemUse(itemusecontext); - if (onItemUse.isAccepted()) + ActionResultType onItemUse = stack.useOn(itemusecontext); + if (onItemUse.consumesAction()) return; if (item == Items.ENDER_PEARL) return; @@ -320,76 +320,76 @@ public class DeployerHandler { if (item instanceof BucketItem || item instanceof SandPaperItem) itemUseWorld = new ItemUseWorld(world, face, pos); - ActionResult onItemRightClick = item.onItemRightClick(itemUseWorld, player, hand); - ItemStack resultStack = onItemRightClick.getResult(); + ActionResult onItemRightClick = item.use(itemUseWorld, player, hand); + ItemStack resultStack = onItemRightClick.getObject(); if (resultStack != stack || resultStack.getCount() != stack.getCount() || resultStack.getUseDuration() > 0 - || resultStack.getDamage() != stack.getDamage()) { - player.setHeldItem(hand, onItemRightClick.getResult()); + || resultStack.getDamageValue() != stack.getDamageValue()) { + player.setItemInHand(hand, onItemRightClick.getObject()); } CompoundNBT tag = stack.getTag(); if (tag != null && stack.getItem() instanceof SandPaperItem && tag.contains("Polishing")) { - player.spawnedItemEffects = ItemStack.read(tag.getCompound("Polishing")); + player.spawnedItemEffects = ItemStack.of(tag.getCompound("Polishing")); AllSoundEvents.AUTO_POLISH.playOnServer(world, pos, .25f, 1f); } - if (!player.getActiveItemStack() + if (!player.getUseItem() .isEmpty()) - player.setHeldItem(hand, stack.onItemUseFinish(world, player)); + player.setItemInHand(hand, stack.finishUsingItem(world, player)); - player.resetActiveHand(); + player.stopUsingItem(); } public static boolean tryHarvestBlock(PlayerInteractionManager interactionManager, BlockPos pos) { // <> PlayerInteractionManager#tryHarvestBlock - ServerWorld world = interactionManager.world; + ServerWorld world = interactionManager.level; ServerPlayerEntity player = interactionManager.player; BlockState blockstate = world.getBlockState(pos); - GameType gameType = interactionManager.getGameType(); + GameType gameType = interactionManager.getGameModeForPlayer(); if (net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(world, gameType, player, pos) == -1) return false; - TileEntity tileentity = world.getTileEntity(pos); - if (player.getHeldItemMainhand() + TileEntity tileentity = world.getBlockEntity(pos); + if (player.getMainHandItem() .onBlockStartBreak(pos, player)) return false; - if (player.isBlockBreakingRestricted(world, pos, gameType)) + if (player.blockActionRestricted(world, pos, gameType)) return false; - ItemStack prevHeldItem = player.getHeldItemMainhand(); + ItemStack prevHeldItem = player.getMainHandItem(); ItemStack heldItem = prevHeldItem.copy(); boolean canHarvest = blockstate.canHarvestBlock(world, pos, player); - prevHeldItem.onBlockDestroyed(world, blockstate, pos, player); + prevHeldItem.mineBlock(world, blockstate, pos, player); if (prevHeldItem.isEmpty() && !heldItem.isEmpty()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, heldItem, Hand.MAIN_HAND); - BlockPos posUp = pos.up(); + BlockPos posUp = pos.above(); BlockState stateUp = world.getBlockState(posUp); if (blockstate.getBlock() instanceof DoublePlantBlock - && blockstate.get(DoublePlantBlock.HALF) == DoubleBlockHalf.LOWER + && blockstate.getValue(DoublePlantBlock.HALF) == DoubleBlockHalf.LOWER && stateUp.getBlock() == blockstate.getBlock() - && stateUp.get(DoublePlantBlock.HALF) == DoubleBlockHalf.UPPER + && stateUp.getValue(DoublePlantBlock.HALF) == DoubleBlockHalf.UPPER ) { // hack to prevent DoublePlantBlock from dropping a duplicate item - world.setBlockState(pos, Blocks.AIR.getDefaultState(), 35); - world.setBlockState(posUp, Blocks.AIR.getDefaultState(), 35); + world.setBlock(pos, Blocks.AIR.defaultBlockState(), 35); + world.setBlock(posUp, Blocks.AIR.defaultBlockState(), 35); } else { if (!blockstate.removedByPlayer(world, pos, player, canHarvest, world.getFluidState(pos))) return true; } blockstate.getBlock() - .onPlayerDestroy(world, pos, blockstate); + .destroy(world, pos, blockstate); if (!canHarvest) return true; Block.getDrops(blockstate, world, pos, tileentity, player, prevHeldItem) .forEach(item -> player.inventory.placeItemBackInInventory(world, item)); - blockstate.spawnAdditionalDrops(world, pos, prevHeldItem); + blockstate.spawnAfterBreak(world, pos, prevHeldItem); return true; } @@ -397,7 +397,7 @@ public class DeployerHandler { Hand hand, BlockRayTraceResult ray) { if (state.getBlock() instanceof BeehiveBlock) return safeOnBeehiveUse(state, world, pos, player, hand); - return state.onUse(world, player, hand, ray); + return state.use(world, player, hand, ray); } protected static ActionResultType safeOnBeehiveUse(BlockState state, World world, BlockPos pos, PlayerEntity player, @@ -405,28 +405,28 @@ public class DeployerHandler { // <> BeehiveBlock#onUse BeehiveBlock block = (BeehiveBlock) state.getBlock(); - ItemStack prevHeldItem = player.getHeldItem(hand); - int honeyLevel = state.get(BeehiveBlock.HONEY_LEVEL); + ItemStack prevHeldItem = player.getItemInHand(hand); + int honeyLevel = state.getValue(BeehiveBlock.HONEY_LEVEL); boolean success = false; if (honeyLevel < 5) return ActionResultType.PASS; if (prevHeldItem.getItem() == Items.SHEARS) { - world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BLOCK_BEEHIVE_SHEAR, + world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundCategory.NEUTRAL, 1.0F, 1.0F); // <> BeehiveBlock#dropHoneycomb player.inventory.placeItemBackInInventory(world, new ItemStack(Items.HONEYCOMB, 3)); - prevHeldItem.damageItem(1, player, s -> s.sendBreakAnimation(hand)); + prevHeldItem.hurtAndBreak(1, player, s -> s.broadcastBreakEvent(hand)); success = true; } if (prevHeldItem.getItem() == Items.GLASS_BOTTLE) { prevHeldItem.shrink(1); - world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.ITEM_BOTTLE_FILL, + world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F); ItemStack honeyBottle = new ItemStack(Items.HONEY_BOTTLE); if (prevHeldItem.isEmpty()) - player.setHeldItem(hand, honeyBottle); + player.setItemInHand(hand, honeyBottle); else player.inventory.placeItemBackInInventory(world, honeyBottle); success = true; @@ -435,7 +435,7 @@ public class DeployerHandler { if (!success) return ActionResultType.PASS; - block.takeHoney(world, state, pos); + block.resetHoneyLevel(world, state, pos); return ActionResultType.SUCCESS; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java index 5981b32d8..dfff538bd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java @@ -40,9 +40,9 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, super(dispatcher, tile); this.tile = (DeployerTileEntity) super.tile; - facing = blockState.get(FACING); + facing = blockState.getValue(FACING); - boolean rotatePole = blockState.get(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z; + boolean rotatePole = blockState.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z; yRot = AngleHelper.horizontalAngle(facing); zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; @@ -68,7 +68,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, float newProgress = getProgress(AnimationTickHolder.getPartialTicks()); - if (!newHand && MathHelper.epsilonEquals(newProgress, progress)) return; + if (!newHand && MathHelper.equal(newProgress, progress)) return; progress = newProgress; newHand = false; @@ -118,7 +118,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, float handLength = currentHand == AllBlockPartials.DEPLOYER_HAND_POINTING ? 0 : currentHand == AllBlockPartials.DEPLOYER_HAND_HOLDING ? 4 / 16f : 3 / 16f; float distance = Math.min(MathHelper.clamp(progress, 0, 1) * (tile.reach + handLength), 21 / 16f); - Vector3i facingVec = facing.getDirectionVec(); + Vector3i facingVec = facing.getNormal(); BlockPos blockPos = getInstancePosition(); float x = blockPos.getX() + ((float) facingVec.getX()) * distance; @@ -131,12 +131,12 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, static void updateRotation(OrientedData pole, OrientedData hand, float yRot, float zRot, float zRotPole) { - Quaternion q = Direction.SOUTH.getUnitVector().getDegreesQuaternion(zRot); - q.multiply(Direction.UP.getUnitVector().getDegreesQuaternion(yRot)); + Quaternion q = Direction.SOUTH.step().rotationDegrees(zRot); + q.mul(Direction.UP.step().rotationDegrees(yRot)); hand.setRotation(q); - q.multiply(Direction.SOUTH.getUnitVector().getDegreesQuaternion(zRotPole)); + q.mul(Direction.SOUTH.step().rotationDegrees(zRotPole)); pole.setRotation(q); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerItemHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerItemHandler.java index 0e7ba0183..55dfa8d48 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerItemHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerItemHandler.java @@ -32,16 +32,16 @@ public class DeployerItemHandler implements IItemHandlerModifiable { public ItemStack getHeld() { if (player == null) return ItemStack.EMPTY; - return player.getHeldItemMainhand(); + return player.getMainHandItem(); } public void set(ItemStack stack) { if (player == null) return; - if (te.getWorld().isRemote) + if (te.getLevel().isClientSide) return; - player.setHeldItem(Hand.MAIN_HAND, stack); - te.markDirty(); + player.setItemInHand(Hand.MAIN_HAND, stack); + te.setChanged(); te.sendData(); } @@ -119,7 +119,7 @@ public class DeployerItemHandler implements IItemHandlerModifiable { .split(amount); ItemStack toReturn = held.split(amount); - te.markDirty(); + te.setChanged(); te.sendData(); return toReturn; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java index 4243f024a..6b0a5601d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -51,20 +51,20 @@ public class DeployerMovementBehaviour extends MovementBehaviour { @Override public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.of(context.state.get(DeployerBlock.FACING) - .getDirectionVec()) + return Vector3d.atLowerCornerOf(context.state.getValue(DeployerBlock.FACING) + .getNormal()) .scale(2); } @Override public void visitNewPosition(MovementContext context, BlockPos pos) { - if (context.world.isRemote) + if (context.world.isClientSide) return; tryGrabbingItem(context); DeployerFakePlayer player = getPlayer(context); Mode mode = getMode(context); - if (mode == Mode.USE && !DeployerHandler.shouldActivate(player.getHeldItemMainhand(), context.world, pos, null)) + if (mode == Mode.USE && !DeployerHandler.shouldActivate(player.getMainHandItem(), context.world, pos, null)) return; activate(context, pos, player, mode); @@ -79,12 +79,12 @@ public class DeployerMovementBehaviour extends MovementBehaviour { if (AllItems.SCHEMATIC.isIn(filter)) activateAsSchematicPrinter(context, pos, player, world, filter); - Vector3d facingVec = Vector3d.of(context.state.get(DeployerBlock.FACING) - .getDirectionVec()); + Vector3d facingVec = Vector3d.atLowerCornerOf(context.state.getValue(DeployerBlock.FACING) + .getNormal()); facingVec = context.rotation.apply(facingVec); Vector3d vec = context.position.subtract(facingVec.scale(2)); - player.rotationYaw = AbstractContraptionEntity.yawFromVector(facingVec); - player.rotationPitch = AbstractContraptionEntity.pitchFromVector(facingVec) - 90; + player.yRot = AbstractContraptionEntity.yawFromVector(facingVec); + player.xRot = AbstractContraptionEntity.pitchFromVector(facingVec) - 90; DeployerHandler.activate(player, vec, pos, facingVec, mode); } @@ -105,10 +105,10 @@ public class DeployerMovementBehaviour extends MovementBehaviour { if (schematicWorld == null) return; if (!schematicWorld.getBounds() - .isVecInside(pos.subtract(schematicWorld.anchor))) + .isInside(pos.subtract(schematicWorld.anchor))) return; BlockState blockState = schematicWorld.getBlockState(pos); - ItemRequirement requirement = ItemRequirement.of(blockState, schematicWorld.getTileEntity(pos)); + ItemRequirement requirement = ItemRequirement.of(blockState, schematicWorld.getBlockEntity(pos)); if (requirement.isInvalid() || requirement.isEmpty()) return; if (AllBlocks.BELT.has(blockState)) @@ -134,14 +134,14 @@ public class DeployerMovementBehaviour extends MovementBehaviour { CompoundNBT data = null; if (AllBlockTags.SAFE_NBT.matches(blockState)) { - TileEntity tile = schematicWorld.getTileEntity(pos); + TileEntity tile = schematicWorld.getBlockEntity(pos); if (tile != null) { - data = tile.write(new CompoundNBT()); + data = tile.save(new CompoundNBT()); data = NBTProcessors.process(tile, data, true); } } - BlockSnapshot blocksnapshot = BlockSnapshot.create(world.getRegistryKey(), world, pos); + BlockSnapshot blocksnapshot = BlockSnapshot.create(world.dimension(), world, pos); BlockHelper.placeSchematicBlock(world, blockState, pos, firstRequired, data); if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP)) blocksnapshot.restore(true, false); @@ -149,7 +149,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { @Override public void tick(MovementContext context) { - if (context.world.isRemote) + if (context.world.isClientSide) return; if (!context.stall) return; @@ -176,14 +176,14 @@ public class DeployerMovementBehaviour extends MovementBehaviour { @Override public void stopMoving(MovementContext context) { - if (context.world.isRemote) + if (context.world.isClientSide) return; DeployerFakePlayer player = getPlayer(context); if (player == null) return; - context.tileData.put("Inventory", player.inventory.write(new ListNBT())); + context.tileData.put("Inventory", player.inventory.save(new ListNBT())); player.remove(); } @@ -191,14 +191,14 @@ public class DeployerMovementBehaviour extends MovementBehaviour { DeployerFakePlayer player = getPlayer(context); if (player == null) return; - if (player.getHeldItemMainhand() + if (player.getMainHandItem() .isEmpty()) { ItemStack filter = getFilter(context); if (AllItems.SCHEMATIC.isIn(filter)) return; ItemStack held = ItemHelper.extract(context.contraption.inventory, stack -> FilterItem.test(context.world, stack, filter), 1, false); - player.setHeldItem(Hand.MAIN_HAND, held); + player.setItemInHand(Hand.MAIN_HAND, held); } } @@ -209,13 +209,13 @@ public class DeployerMovementBehaviour extends MovementBehaviour { PlayerInventory inv = player.inventory; ItemStack filter = getFilter(context); - for (List list : Arrays.asList(inv.armorInventory, inv.offHandInventory, inv.mainInventory)) { + for (List list : Arrays.asList(inv.armor, inv.offhand, inv.items)) { for (int i = 0; i < list.size(); ++i) { ItemStack itemstack = list.get(i); if (itemstack.isEmpty()) continue; - if (list == inv.mainInventory && i == inv.currentItem + if (list == inv.items && i == inv.selected && FilterItem.test(context.world, itemstack, filter)) continue; @@ -230,16 +230,16 @@ public class DeployerMovementBehaviour extends MovementBehaviour { DeployerFakePlayer player = getPlayer(context); if (player == null) return; - context.data.put("HeldItem", player.getHeldItemMainhand() + context.data.put("HeldItem", player.getMainHandItem() .serializeNBT()); } private DeployerFakePlayer getPlayer(MovementContext context) { if (!(context.temporaryData instanceof DeployerFakePlayer) && context.world instanceof ServerWorld) { DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerWorld) context.world); - deployerFakePlayer.inventory.read(context.tileData.getList("Inventory", NBT.TAG_COMPOUND)); + deployerFakePlayer.inventory.load(context.tileData.getList("Inventory", NBT.TAG_COMPOUND)); if (context.data.contains("HeldItem")) - deployerFakePlayer.setHeldItem(Hand.MAIN_HAND, ItemStack.read(context.data.getCompound("HeldItem"))); + deployerFakePlayer.setItemInHand(Hand.MAIN_HAND, ItemStack.of(context.data.getCompound("HeldItem"))); context.tileData.remove("Inventory"); context.temporaryData = deployerFakePlayer; } @@ -247,7 +247,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { } private ItemStack getFilter(MovementContext context) { - return ItemStack.read(context.tileData.getCompound("Filter")); + return ItemStack.of(context.tileData.getCompound("Filter")); } private Mode getMode(MovementContext context) { 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 9eee73565..72b799cb3 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 @@ -53,7 +53,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer renderItem(te, partialTicks, ms, buffer, light, overlay); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; renderComponents(te, partialTicks, ms, buffer, light, overlay); } @@ -65,19 +65,19 @@ public class DeployerRenderer extends SafeTileEntityRenderer BlockState deployerState = te.getBlockState(); Vector3d offset = getHandOffset(te, partialTicks, deployerState).add(VecHelper.getCenterOf(BlockPos.ZERO)); - ms.push(); + ms.pushPose(); ms.translate(offset.x, offset.y, offset.z); - Direction facing = deployerState.get(FACING); + Direction facing = deployerState.getValue(FACING); boolean punching = te.mode == Mode.PUNCH; float yRot = AngleHelper.horizontalAngle(facing) + 180; float zRot = facing == Direction.UP ? 90 : facing == Direction.DOWN ? 270 : 0; boolean displayMode = facing == Direction.UP && te.getSpeed() == 0 && !punching; - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yRot)); + ms.mulPose(Vector3f.YP.rotationDegrees(yRot)); if (!displayMode) { - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(zRot)); + ms.mulPose(Vector3f.XP.rotationDegrees(zRot)); ms.translate(0, 0, -11 / 16f); } @@ -89,7 +89,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer TransformType transform = TransformType.NONE; boolean isBlockItem = (te.heldItem.getItem() instanceof BlockItem) - && itemRenderer.getItemModelWithOverrides(te.heldItem, Minecraft.getInstance().world, null) + && itemRenderer.getModel(te.heldItem, Minecraft.getInstance().level, null) .isGui3d(); if (displayMode) { @@ -97,7 +97,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(te.getWorld()))); + ms.mulPose(Vector3f.YP.rotationDegrees(AnimationTickHolder.getRenderTime(te.getLevel()))); } else { float scale = punching ? .75f : isBlockItem ? .75f - 1 / 64f : .5f; @@ -105,33 +105,33 @@ public class DeployerRenderer extends SafeTileEntityRenderer transform = punching ? TransformType.THIRD_PERSON_RIGHT_HAND : TransformType.FIXED; } - itemRenderer.renderItem(te.heldItem, transform, light, overlay, ms, buffer); - ms.pop(); + itemRenderer.renderStatic(te.heldItem, transform, light, overlay, ms, buffer); + ms.popPose(); } protected void renderComponents(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); - if (!Backend.getInstance().canUseInstancing(te.getWorld())) { + IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + if (!Backend.getInstance().canUseInstancing(te.getLevel())) { KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light); } BlockState blockState = te.getBlockState(); - BlockPos pos = te.getPos(); + BlockPos pos = te.getBlockPos(); Vector3d offset = getHandOffset(te, partialTicks, blockState); SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState); - transform(te.getWorld(), pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms, + transform(te.getLevel(), pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms, vb); - transform(te.getWorld(), hand.translate(offset.x, offset.y, offset.z), blockState, pos, false).renderInto(ms, + transform(te.getLevel(), hand.translate(offset.x, offset.y, offset.z), blockState, pos, false).renderInto(ms, vb); } protected Vector3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) { float distance = te.getHandOffset(partialTicks); - return Vector3d.of(blockState.get(FACING).getDirectionVec()).scale(distance); + return Vector3d.atLowerCornerOf(blockState.getValue(FACING).getNormal()).scale(distance); } protected BlockState getRenderedBlockState(KineticTileEntity te) { @@ -140,10 +140,10 @@ public class DeployerRenderer extends SafeTileEntityRenderer private static SuperByteBuffer transform(World world, SuperByteBuffer buffer, BlockState deployerState, BlockPos pos, boolean axisDirectionMatters) { - Direction facing = deployerState.get(FACING); + Direction facing = deployerState.getValue(FACING); float zRotLast = - axisDirectionMatters && (deployerState.get(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Axis.Z) ? 90 + axisDirectionMatters && (deployerState.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Axis.Z) ? 90 : 0; float yRot = AngleHelper.horizontalAngle(facing); float zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; @@ -151,13 +151,13 @@ public class DeployerRenderer extends SafeTileEntityRenderer buffer.rotateCentered(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI)); buffer.rotateCentered(Direction.UP, (float) ((yRot) / 180 * Math.PI)); buffer.rotateCentered(Direction.SOUTH, (float) ((zRotLast) / 180 * Math.PI)); - buffer.light(WorldRenderer.getLightmapCoordinates(world, deployerState, pos)); + buffer.light(WorldRenderer.getLightColor(world, deployerState, pos)); return buffer; } public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, ContraptionMatrices matrices, IRenderTypeBuffer buffer) { - IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid()); + IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); BlockState blockState = context.state; BlockPos pos = BlockPos.ZERO; Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class); @@ -178,11 +178,11 @@ public class DeployerRenderer extends SafeTileEntityRenderer factor = .5f - MathHelper.clamp(MathHelper.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1); } - Vector3d offset = Vector3d.of(blockState.get(FACING) - .getDirectionVec()).scale(factor); + Vector3d offset = Vector3d.atLowerCornerOf(blockState.getValue(FACING) + .getNormal()).scale(factor); MatrixStack m = matrices.contraptionStack; - m.push(); + m.pushPose(); m.translate(offset.x, offset.y, offset.z); pole.transform(m); @@ -195,7 +195,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer hand.light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) .renderInto(matrices.entityStack, builder); - m.pop(); + m.popPose(); } static PartialModel getHandPose(DeployerTileEntity.Mode mode) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java index 8c69d61d9..b8af6dae6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java @@ -104,24 +104,24 @@ public class DeployerTileEntity extends KineticTileEntity { @Override public void initialize() { super.initialize(); - if (!world.isRemote) { - player = new DeployerFakePlayer((ServerWorld) world); + if (!level.isClientSide) { + player = new DeployerFakePlayer((ServerWorld) level); if (deferredInventoryList != null) { - player.inventory.read(deferredInventoryList); + player.inventory.load(deferredInventoryList); deferredInventoryList = null; - heldItem = player.getHeldItemMainhand(); + heldItem = player.getMainHandItem(); sendData(); } - Vector3d initialPos = VecHelper.getCenterOf(pos.offset(getBlockState().get(FACING))); - player.setPosition(initialPos.x, initialPos.y, initialPos.z); + Vector3d initialPos = VecHelper.getCenterOf(worldPosition.relative(getBlockState().getValue(FACING))); + player.setPos(initialPos.x, initialPos.y, initialPos.z); } invHandler = LazyOptional.of(this::createHandler); } protected void onExtract(ItemStack stack) { - player.setHeldItem(Hand.MAIN_HAND, stack.copy()); + player.setItemInHand(Hand.MAIN_HAND, stack.copy()); sendData(); - markDirty(); + setChanged(); } protected int getTimerSpeed() { @@ -134,9 +134,9 @@ public class DeployerTileEntity extends KineticTileEntity { if (getSpeed() == 0) return; - if (!world.isRemote && player != null && player.blockBreakingProgress != null) { - if (world.isAirBlock(player.blockBreakingProgress.getKey())) { - world.sendBlockBreakProgress(player.getEntityId(), player.blockBreakingProgress.getKey(), -1); + if (!level.isClientSide && player != null && player.blockBreakingProgress != null) { + if (level.isEmptyBlock(player.blockBreakingProgress.getKey())) { + level.destroyBlockProgress(player.getId(), player.blockBreakingProgress.getKey(), -1); player.blockBreakingProgress = null; } } @@ -144,10 +144,10 @@ public class DeployerTileEntity extends KineticTileEntity { timer -= getTimerSpeed(); return; } - if (world.isRemote) + if (level.isClientSide) return; - ItemStack stack = player.getHeldItemMainhand(); + ItemStack stack = player.getMainHandItem(); if (state == State.WAITING) { if (!overflowItems.isEmpty()) { timer = getTimerSpeed() * 10; @@ -155,15 +155,15 @@ public class DeployerTileEntity extends KineticTileEntity { } boolean changed = false; - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + for (int i = 0; i < player.inventory.getContainerSize(); i++) { if (overflowItems.size() > 10) break; - ItemStack item = player.inventory.getStackInSlot(i); + ItemStack item = player.inventory.getItem(i); if (item.isEmpty()) continue; if (item != stack || !filtering.test(item)) { overflowItems.add(item); - player.inventory.setInventorySlotContents(i, ItemStack.EMPTY); + player.inventory.setItem(i, ItemStack.EMPTY); changed = true; } } @@ -174,8 +174,8 @@ public class DeployerTileEntity extends KineticTileEntity { return; } - Direction facing = getBlockState().get(FACING); - if (mode == Mode.USE && !DeployerHandler.shouldActivate(stack, world, pos.offset(facing, 2), facing)) { + Direction facing = getBlockState().getValue(FACING); + if (mode == Mode.USE && !DeployerHandler.shouldActivate(stack, level, worldPosition.relative(facing, 2), facing)) { timer = getTimerSpeed() * 10; return; } @@ -213,14 +213,14 @@ public class DeployerTileEntity extends KineticTileEntity { protected void start() { state = State.EXPANDING; Vector3d movementVector = getMovementVector(); - Vector3d rayOrigin = VecHelper.getCenterOf(pos) + Vector3d rayOrigin = VecHelper.getCenterOf(worldPosition) .add(movementVector.scale(3 / 2f)); - Vector3d rayTarget = VecHelper.getCenterOf(pos) + Vector3d rayTarget = VecHelper.getCenterOf(worldPosition) .add(movementVector.scale(5 / 2f)); RayTraceContext rayTraceContext = new RayTraceContext(rayOrigin, rayTarget, BlockMode.OUTLINE, FluidMode.NONE, player); - BlockRayTraceResult result = world.rayTraceBlocks(rayTraceContext); - reach = (float) (.5f + Math.min(result.getHitVec() + BlockRayTraceResult result = level.clip(rayTraceContext); + reach = (float) (.5f + Math.min(result.getLocation() .subtract(rayOrigin) .length(), .75f)); timer = 1000; @@ -228,17 +228,17 @@ public class DeployerTileEntity extends KineticTileEntity { } public boolean startBoop(Direction facing) { - if (!world.isAirBlock(pos.offset(facing, 1)) || !world.isAirBlock(pos.offset(facing, 2))) + if (!level.isEmptyBlock(worldPosition.relative(facing, 1)) || !level.isEmptyBlock(worldPosition.relative(facing, 2))) return false; - BlockPos otherDeployer = pos.offset(facing, 4); - if (!world.isBlockPresent(otherDeployer)) + BlockPos otherDeployer = worldPosition.relative(facing, 4); + if (!level.isLoaded(otherDeployer)) return false; - TileEntity otherTile = world.getTileEntity(otherDeployer); + TileEntity otherTile = level.getBlockEntity(otherDeployer); if (!(otherTile instanceof DeployerTileEntity)) return false; DeployerTileEntity deployerTile = (DeployerTileEntity) otherTile; - if (world.getBlockState(otherDeployer) - .get(FACING) + if (level.getBlockState(otherDeployer) + .getValue(FACING) .getOpposite() != facing || deployerTile.mode != Mode.PUNCH) return false; @@ -251,7 +251,7 @@ public class DeployerTileEntity extends KineticTileEntity { } public void triggerBoop() { - TileEntity otherTile = world.getTileEntity(pos.offset(getBlockState().get(FACING), 4)); + TileEntity otherTile = level.getBlockEntity(worldPosition.relative(getBlockState().getValue(FACING), 4)); if (!(otherTile instanceof DeployerTileEntity)) return; @@ -270,32 +270,32 @@ public class DeployerTileEntity extends KineticTileEntity { // award nearby players List players = - world.getEntitiesWithinAABB(ServerPlayerEntity.class, new AxisAlignedBB(pos).grow(9)); + level.getEntitiesOfClass(ServerPlayerEntity.class, new AxisAlignedBB(worldPosition).inflate(9)); players.forEach(AllTriggers.DEPLOYER_BOOP::trigger); } protected void activate() { Vector3d movementVector = getMovementVector(); - Direction direction = getBlockState().get(FACING); - Vector3d center = VecHelper.getCenterOf(pos); - BlockPos clickedPos = pos.offset(direction, 2); - player.rotationYaw = direction.getHorizontalAngle(); - player.rotationPitch = direction == Direction.UP ? -90 : direction == Direction.DOWN ? 90 : 0; + Direction direction = getBlockState().getValue(FACING); + Vector3d center = VecHelper.getCenterOf(worldPosition); + BlockPos clickedPos = worldPosition.relative(direction, 2); + player.yRot = direction.toYRot(); + player.xRot = direction == Direction.UP ? -90 : direction == Direction.DOWN ? 90 : 0; if (direction == Direction.DOWN - && TileEntityBehaviour.get(world, clickedPos, TransportedItemStackHandlerBehaviour.TYPE) != null) + && TileEntityBehaviour.get(level, clickedPos, TransportedItemStackHandlerBehaviour.TYPE) != null) return; // Belt processing handled in BeltDeployerCallbacks DeployerHandler.activate(player, center, clickedPos, movementVector, mode); if (player != null) - heldItem = player.getHeldItemMainhand(); + heldItem = player.getMainHandItem(); } protected Vector3d getMovementVector() { if (!AllBlocks.DEPLOYER.has(getBlockState())) return Vector3d.ZERO; - return Vector3d.of(getBlockState().get(FACING) - .getDirectionVec()); + return Vector3d.atLowerCornerOf(getBlockState().getValue(FACING) + .getNormal()); } @Override @@ -308,16 +308,16 @@ public class DeployerTileEntity extends KineticTileEntity { deferredInventoryList = compound.getList("Inventory", NBT.TAG_COMPOUND); overflowItems = NBTHelper.readItemList(compound.getList("Overflow", NBT.TAG_COMPOUND)); if (compound.contains("HeldItem")) - heldItem = ItemStack.read(compound.getCompound("HeldItem")); + heldItem = ItemStack.of(compound.getCompound("HeldItem")); super.fromTag(blockState, compound, clientPacket); if (!clientPacket) return; reach = compound.getFloat("Reach"); if (compound.contains("Particle")) { - ItemStack particleStack = ItemStack.read(compound.getCompound("Particle")); - SandPaperItem.spawnParticles(VecHelper.getCenterOf(pos) - .add(getMovementVector().scale(reach + 1)), particleStack, this.world); + ItemStack particleStack = ItemStack.of(compound.getCompound("Particle")); + SandPaperItem.spawnParticles(VecHelper.getCenterOf(worldPosition) + .add(getMovementVector().scale(reach + 1)), particleStack, this.level); } } @@ -330,9 +330,9 @@ public class DeployerTileEntity extends KineticTileEntity { if (player != null) { ListNBT invNBT = new ListNBT(); - player.inventory.write(invNBT); + player.inventory.save(invNBT); compound.put("Inventory", invNBT); - compound.put("HeldItem", player.getHeldItemMainhand().serializeNBT()); + compound.put("HeldItem", player.getMainHandItem().serializeNBT()); compound.put("Overflow", NBTHelper.writeItemList(overflowItems)); } else if (deferredInventoryList != null) { compound.put("Inventory", deferredInventoryList); @@ -345,7 +345,7 @@ public class DeployerTileEntity extends KineticTileEntity { compound.putFloat("Reach", reach); if (player == null) return; - compound.put("HeldItem", player.getHeldItemMainhand() + compound.put("HeldItem", player.getMainHandItem() .serializeNBT()); if (player.spawnedItemEffects != null) { compound.put("Particle", player.spawnedItemEffects.serializeNBT()); @@ -358,9 +358,9 @@ public class DeployerTileEntity extends KineticTileEntity { } public void redstoneUpdate() { - if (world.isRemote) + if (level.isClientSide) return; - boolean blockPowered = world.isBlockPowered(pos); + boolean blockPowered = level.hasNeighborSignal(worldPosition); if (blockPowered == redstoneLocked) return; redstoneLocked = blockPowered; @@ -374,19 +374,19 @@ public class DeployerTileEntity extends KineticTileEntity { @Override public AxisAlignedBB makeRenderBoundingBox() { - return super.makeRenderBoundingBox().grow(3); + return super.makeRenderBoundingBox().inflate(3); } @Override - public void remove() { - super.remove(); + public void setRemoved() { + super.setRemoved(); if (invHandler != null) invHandler.invalidate(); } public void changeMode() { mode = mode == Mode.PUNCH ? Mode.USE : Mode.PUNCH; - markDirty(); + setChanged(); sendData(); } @@ -444,21 +444,21 @@ public class DeployerTileEntity extends KineticTileEntity { public IRecipe getRecipe(ItemStack stack) { if (player == null) return null; - ItemStack heldItemMainhand = player.getHeldItemMainhand(); + ItemStack heldItemMainhand = player.getMainHandItem(); if (heldItemMainhand.getItem() instanceof SandPaperItem) { - sandpaperInv.setInventorySlotContents(0, stack); - return AllRecipeTypes.SANDPAPER_POLISHING.find(sandpaperInv, world) + sandpaperInv.setItem(0, stack); + return AllRecipeTypes.SANDPAPER_POLISHING.find(sandpaperInv, level) .orElse(null); } - recipeInv.setInventorySlotContents(0, stack); - recipeInv.setInventorySlotContents(1, heldItemMainhand); + recipeInv.setItem(0, stack); + recipeInv.setItem(1, heldItemMainhand); - Optional assemblyRecipe = SequencedAssemblyRecipe.getRecipe(world, recipeInv, + Optional assemblyRecipe = SequencedAssemblyRecipe.getRecipe(level, recipeInv, AllRecipeTypes.DEPLOYING.getType(), DeployerApplicationRecipe.class); if (assemblyRecipe.isPresent()) return assemblyRecipe.get(); - return AllRecipeTypes.DEPLOYING.find(recipeInv, world) + return AllRecipeTypes.DEPLOYING.find(recipeInv, level) .orElse(null); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java index 72001c7ee..97f522e18 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java @@ -46,10 +46,10 @@ import net.minecraftforge.fml.DistExecutor; public class AirCurrent { - private static final DamageSource damageSourceFire = new DamageSource("create.fan_fire").setDifficultyScaled() - .setFireDamage(); - private static final DamageSource damageSourceLava = new DamageSource("create.fan_lava").setDifficultyScaled() - .setFireDamage(); + private static final DamageSource damageSourceFire = new DamageSource("create.fan_fire").setScalesWithDifficulty() + .setIsFire(); + private static final DamageSource damageSourceLava = new DamageSource("create.fan_lava").setScalesWithDifficulty() + .setIsFire(); public final IAirCurrentSource source; public AxisAlignedBB bounds = new AxisAlignedBB(0, 0, 0, 0, 0, 0); @@ -73,12 +73,12 @@ public class AirCurrent { rebuild(); World world = source.getAirCurrentWorld(); Direction facing = direction; - if (world != null && world.isRemote) { + if (world != null && world.isClientSide) { float offset = pushing ? 0.5f : maxDistance + .5f; Vector3d pos = VecHelper.getCenterOf(source.getAirCurrentPos()) - .add(Vector3d.of(facing.getDirectionVec()) + .add(Vector3d.atLowerCornerOf(facing.getNormal()) .scale(offset)); - if (world.rand.nextFloat() < AllConfigs.CLIENT.fanParticleDensity.get()) + if (world.random.nextFloat() < AllConfigs.CLIENT.fanParticleDensity.get()) world.addParticle(new AirFlowParticleData(source.getAirCurrentPos()), pos.x, pos.y, pos.z, 0, 0, 0); } @@ -95,14 +95,14 @@ public class AirCurrent { } Vector3d center = VecHelper.getCenterOf(source.getAirCurrentPos()); - Vector3i flow = (pushing ? facing : facing.getOpposite()).getDirectionVec(); + Vector3i flow = (pushing ? facing : facing.getOpposite()).getNormal(); - float sneakModifier = entity.isSneaking() ? 4096f : 512f; + float sneakModifier = entity.isShiftKeyDown() ? 4096f : 512f; float speed = Math.abs(source.getSpeed()); - double entityDistance = entity.getPositionVec() + double entityDistance = entity.position() .distanceTo(center); float acceleration = (float) (speed / sneakModifier / (entityDistance / maxDistance)); - Vector3d previousMotion = entity.getMotion(); + Vector3d previousMotion = entity.getDeltaMovement(); float maxAcceleration = 5; double xIn = @@ -112,13 +112,13 @@ public class AirCurrent { double zIn = MathHelper.clamp(flow.getZ() * acceleration - previousMotion.z, -maxAcceleration, maxAcceleration); - entity.setMotion(previousMotion.add(new Vector3d(xIn, yIn, zIn).scale(1 / 8f))); + entity.setDeltaMovement(previousMotion.add(new Vector3d(xIn, yIn, zIn).scale(1 / 8f))); entity.fallDistance = 0; DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> enableClientPlayerSound(entity, MathHelper.clamp(speed / 128f * .4f, 0.01f, .4f))); if (entity instanceof ServerPlayerEntity) - ((ServerPlayerEntity) entity).connection.floatingTickCount = 0; + ((ServerPlayerEntity) entity).connection.aboveGroundTickCount = 0; entityDistance -= .5f; InWorldProcessing.Type processingType = getSegmentAt((float) entityDistance); @@ -131,41 +131,41 @@ public class AirCurrent { } if (entity instanceof ItemEntity) { - InWorldProcessing.spawnParticlesForProcessing(world, entity.getPositionVec(), processingType); + InWorldProcessing.spawnParticlesForProcessing(world, entity.position(), processingType); ItemEntity itemEntity = (ItemEntity) entity; - if (world.isRemote) + if (world.isClientSide) continue; if (InWorldProcessing.canProcess(itemEntity, processingType)) InWorldProcessing.applyProcessing(itemEntity, processingType); continue; } - if (world.isRemote) + if (world.isClientSide) continue; switch (processingType) { case BLASTING: - if (!entity.isFireImmune()) { - entity.setFire(10); - entity.attackEntityFrom(damageSourceLava, 4); + if (!entity.fireImmune()) { + entity.setSecondsOnFire(10); + entity.hurt(damageSourceLava, 4); } break; case SMOKING: - if (!entity.isFireImmune()) { - entity.setFire(2); - entity.attackEntityFrom(damageSourceFire, 2); + if (!entity.fireImmune()) { + entity.setSecondsOnFire(2); + entity.hurt(damageSourceFire, 2); } break; case SPLASHING: if (entity instanceof EndermanEntity || entity.getType() == EntityType.SNOW_GOLEM || entity.getType() == EntityType.BLAZE) { - entity.attackEntityFrom(DamageSource.DROWN, 2); + entity.hurt(DamageSource.DROWN, 2); } - if (!entity.isBurning()) + if (!entity.isOnFire()) break; - entity.extinguish(); - world.playSound(null, entity.getBlockPos(), SoundEvents.ENTITY_GENERIC_EXTINGUISH_FIRE, - SoundCategory.NEUTRAL, 0.7F, 1.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.4F); + entity.clearFire(); + world.playSound(null, entity.blockPosition(), SoundEvents.GENERIC_EXTINGUISH_FIRE, + SoundCategory.NEUTRAL, 0.7F, 1.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.4F); break; default: break; @@ -190,7 +190,7 @@ public class AirCurrent { BlockPos start = source.getAirCurrentPos(); float max = this.maxDistance; Direction facing = direction; - Vector3d directionVec = Vector3d.of(facing.getDirectionVec()); + Vector3d directionVec = Vector3d.atLowerCornerOf(facing.getNormal()); maxDistance = getFlowLimit(world, start, max, facing); // Determine segments with transported fluids/gases @@ -205,7 +205,7 @@ public class AirCurrent { int searchStep = pushing ? 1 : -1; for (int i = searchStart; i * searchStep <= searchEnd * searchStep; i += searchStep) { - BlockPos currentPos = start.offset(direction, i); + BlockPos currentPos = start.relative(direction, i); InWorldProcessing.Type newType = InWorldProcessing.Type.byBlock(world, currentPos); if (newType != Type.NONE) type = newType; @@ -228,40 +228,40 @@ public class AirCurrent { float factor = maxDistance - 1; Vector3d scale = directionVec.scale(factor); if (factor > 0) - bounds = new AxisAlignedBB(start.offset(direction)).expand(scale); + bounds = new AxisAlignedBB(start.relative(direction)).expandTowards(scale); else { - bounds = new AxisAlignedBB(start.offset(direction)).contract(scale.x, scale.y, scale.z) - .offset(scale); + bounds = new AxisAlignedBB(start.relative(direction)).contract(scale.x, scale.y, scale.z) + .move(scale); } } findAffectedHandlers(); } public static float getFlowLimit(World world, BlockPos start, float max, Direction facing) { - Vector3d directionVec = Vector3d.of(facing.getDirectionVec()); + Vector3d directionVec = Vector3d.atLowerCornerOf(facing.getNormal()); Vector3d planeVec = VecHelper.axisAlingedPlaneOf(directionVec); // 4 Rays test for holes in the shapes blocking the flow float offsetDistance = .25f; - Vector3d[] offsets = new Vector3d[] { planeVec.mul(offsetDistance, offsetDistance, offsetDistance), - planeVec.mul(-offsetDistance, -offsetDistance, offsetDistance), - planeVec.mul(offsetDistance, -offsetDistance, -offsetDistance), - planeVec.mul(-offsetDistance, offsetDistance, -offsetDistance), }; + Vector3d[] offsets = new Vector3d[] { planeVec.multiply(offsetDistance, offsetDistance, offsetDistance), + planeVec.multiply(-offsetDistance, -offsetDistance, offsetDistance), + planeVec.multiply(offsetDistance, -offsetDistance, -offsetDistance), + planeVec.multiply(-offsetDistance, offsetDistance, -offsetDistance), }; float limitedDistance = 0; // Determine the distance of the air flow Outer: for (int i = 1; i <= max; i++) { - BlockPos currentPos = start.offset(facing, i); - if (!world.isBlockPresent(currentPos)) + BlockPos currentPos = start.relative(facing, i); + if (!world.isLoaded(currentPos)) break; BlockState state = world.getBlockState(currentPos); if (shouldAlwaysPass(state)) continue; - VoxelShape voxelshape = state.getCollisionShape(world, currentPos, ISelectionContext.dummy()); + VoxelShape voxelshape = state.getCollisionShape(world, currentPos, ISelectionContext.empty()); if (voxelshape.isEmpty()) continue; - if (voxelshape == VoxelShapes.fullCube()) { + if (voxelshape == VoxelShapes.block()) { max = i - 1; break; } @@ -272,11 +272,11 @@ public class AirCurrent { .add(offset); Vector3d rayEnd = rayStart.add(directionVec.scale(1 + 1 / 32f)); BlockRayTraceResult blockraytraceresult = - world.rayTraceBlocks(rayStart, rayEnd, currentPos, voxelshape, state); + world.clipWithInteractionOverride(rayStart, rayEnd, currentPos, voxelshape, state); if (blockraytraceresult == null) continue Outer; - double distance = i - 1 + blockraytraceresult.getHitVec() + double distance = i - 1 + blockraytraceresult.getLocation() .distanceTo(rayStart); if (limitedDistance < distance) limitedDistance = (float) distance; @@ -291,7 +291,7 @@ public class AirCurrent { public void findEntities() { caughtEntities.clear(); caughtEntities = source.getAirCurrentWorld() - .getEntitiesWithinAABBExcludingEntity(null, bounds); + .getEntities(null, bounds); } public void findAffectedHandlers() { @@ -304,8 +304,8 @@ public class AirCurrent { continue; for (int offset : Iterate.zeroAndOne) { - BlockPos pos = start.offset(direction, i) - .down(offset); + BlockPos pos = start.relative(direction, i) + .below(offset); TransportedItemStackHandlerBehaviour behaviour = TileEntityBehaviour.get(world, pos, TransportedItemStackHandlerBehaviour.TYPE); if (behaviour != null) @@ -326,7 +326,7 @@ public class AirCurrent { handler.handleProcessingOnAllItems((transported) -> { InWorldProcessing.spawnParticlesForProcessing(world, handler.getWorldPositionOf(transported), processingType); - if (world.isRemote) + if (world.isClientSide) return TransportedResult.doNothing(); return InWorldProcessing.applyProcessing(transported, world, processingType); }); @@ -360,18 +360,18 @@ public class AirCurrent { @OnlyIn(Dist.CLIENT) private static void enableClientPlayerSound(Entity e, float maxVolume) { if (e != Minecraft.getInstance() - .getRenderViewEntity()) + .getCameraEntity()) return; isClientPlayerInAirCurrent = true; - float pitch = (float) MathHelper.clamp(e.getMotion() + float pitch = (float) MathHelper.clamp(e.getDeltaMovement() .length() * .5f, .5f, 2f); - if (flyingSound == null || flyingSound.isDonePlaying()) { - flyingSound = new AirCurrentSound(SoundEvents.ITEM_ELYTRA_FLYING, pitch); + if (flyingSound == null || flyingSound.isStopped()) { + flyingSound = new AirCurrentSound(SoundEvents.ELYTRA_FLYING, pitch); Minecraft.getInstance() - .getSoundHandler() + .getSoundManager() .play(flyingSound); } flyingSound.setPitch(pitch); @@ -382,7 +382,7 @@ public class AirCurrent { public static void tickClientPlayerSounds() { if (!AirCurrent.isClientPlayerInAirCurrent && flyingSound != null) if (flyingSound.isFaded()) - flyingSound.stop(); + flyingSound.stopSound(); else flyingSound.fadeOut(); isClientPlayerInAirCurrent = false; @@ -391,7 +391,7 @@ public class AirCurrent { public static boolean isPlayerCreativeFlying(Entity entity) { if (entity instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entity; - return player.isCreative() && player.abilities.isFlying; + return player.isCreative() && player.abilities.flying; } return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrentSound.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrentSound.java index 7a9c4a7db..72a39910b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrentSound.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrentSound.java @@ -12,9 +12,9 @@ public class AirCurrentSound extends TickableSound { super(p_i46532_1_, SoundCategory.BLOCKS); this.pitch = pitch; volume = 0.01f; - repeat = true; - repeatDelay = 0; - global = true; + looping = true; + delay = 0; + relative = true; } @Override @@ -23,26 +23,26 @@ public class AirCurrentSound extends TickableSound { public void setPitch(float pitch) { this.pitch = pitch; } - + public void fadeIn(float maxVolume) { volume = Math.min(maxVolume, volume + .05f); } - + public void fadeOut() { volume = Math.max(0, volume - .05f); } - + public boolean isFaded() { return volume == 0; } - + @Override public float getPitch() { return pitch; } - - public void stop() { - setDone(); + + public void stopSound() { + stop(); } - + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanBlock.java index 8cb03c361..79f244a1d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanBlock.java @@ -19,6 +19,8 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class EncasedFanBlock extends DirectionalKineticBlock implements ITE { public EncasedFanBlock(Properties properties) { @@ -31,22 +33,22 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements ITE te.queueGeneratorUpdate()); } @@ -91,19 +93,19 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements ITE 0) speed = MathHelper.clamp(speed, 80, 64 * 20); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanTileEntity.java index 16da67993..fc1730c97 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanTileEntity.java @@ -78,11 +78,11 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements if (!AllBlocks.ENCASED_FAN.has(blockState)) shouldGenerate = false; - if (shouldGenerate && blockState.get(EncasedFanBlock.FACING) != Direction.DOWN) + if (shouldGenerate && blockState.getValue(EncasedFanBlock.FACING) != Direction.DOWN) shouldGenerate = false; if (shouldGenerate) - shouldGenerate = world != null && world.isBlockPowered(pos) && world.isBlockPresent(pos.down()) && blockBelowIsHot(); + shouldGenerate = level != null && level.hasNeighborSignal(worldPosition) && level.isLoaded(worldPosition.below()) && blockBelowIsHot(); if (shouldGenerate == isGenerator) return; @@ -91,19 +91,19 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements } public boolean blockBelowIsHot() { - if (world == null) + if (level == null) return false; - BlockState checkState = world.getBlockState(pos.down()); + BlockState checkState = level.getBlockState(worldPosition.below()); if (!checkState.getBlock() - .isIn(AllBlockTags.FAN_HEATERS.tag)) + .is(AllBlockTags.FAN_HEATERS.tag)) return false; - if (checkState.contains(BlazeBurnerBlock.HEAT_LEVEL) && !checkState.get(BlazeBurnerBlock.HEAT_LEVEL) + if (checkState.hasProperty(BlazeBurnerBlock.HEAT_LEVEL) && !checkState.getValue(BlazeBurnerBlock.HEAT_LEVEL) .isAtLeast(BlazeBurnerBlock.HeatLevel.FADING)) return false; - if (checkState.contains(BlockStateProperties.LIT) && !checkState.get(BlockStateProperties.LIT)) + if (checkState.hasProperty(BlockStateProperties.LIT) && !checkState.getValue(BlockStateProperties.LIT)) return false; return true; @@ -117,18 +117,18 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements @Nullable @Override public World getAirCurrentWorld() { - return world; + return level; } @Override public BlockPos getAirCurrentPos() { - return pos; + return worldPosition; } @Override public Direction getAirflowOriginSide() { return this.getBlockState() - .get(EncasedFanBlock.FACING); + .getValue(EncasedFanBlock.FACING); } @Override @@ -136,14 +136,14 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements float speed = getSpeed(); if (speed == 0) return null; - Direction facing = getBlockState().get(BlockStateProperties.FACING); + Direction facing = getBlockState().getValue(BlockStateProperties.FACING); speed = convertToDirection(speed, facing); return speed > 0 ? facing : facing.getOpposite(); } @Override public boolean isSourceRemoved() { - return removed; + return remove; } @Override @@ -154,11 +154,11 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements } public void updateChute() { - Direction direction = getBlockState().get(EncasedFanBlock.FACING); + Direction direction = getBlockState().getValue(EncasedFanBlock.FACING); if (!direction.getAxis() .isVertical()) return; - TileEntity poweredChute = world.getTileEntity(pos.offset(direction)); + TileEntity poweredChute = level.getBlockEntity(worldPosition.relative(direction)); if (!(poweredChute instanceof ChuteTileEntity)) return; ChuteTileEntity chuteTE = (ChuteTileEntity) poweredChute; @@ -176,7 +176,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements public void tick() { super.tick(); - boolean server = !world.isRemote || isVirtual(); + boolean server = !level.isClientSide || isVirtual(); if (server && airCurrentUpdateCooldown-- <= 0) { airCurrentUpdateCooldown = AllConfigs.SERVER.kinetics.fanBlockCheckRate.get(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java index 5bae092ce..91f4edce5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java @@ -21,7 +21,7 @@ public class FanInstance extends KineticTileInstance { public FanInstance(MaterialManager modelManager, EncasedFanTileEntity tile) { super(modelManager, tile); - direction = blockState.get(FACING); + direction = blockState.getValue(FACING); opposite = direction.getOpposite(); shaft = getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite).createInstance(); @@ -48,10 +48,10 @@ public class FanInstance extends KineticTileInstance { @Override public void updateLight() { - BlockPos behind = pos.offset(opposite); + BlockPos behind = pos.relative(opposite); relight(behind, shaft); - BlockPos inFront = pos.offset(direction); + BlockPos inFront = pos.relative(direction); relight(inFront, fan); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleBlock.java index b25a7d0d5..ed9b2fb73 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleBlock.java @@ -22,6 +22,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class NozzleBlock extends ProperDirectionalBlock { @@ -47,37 +49,37 @@ public class NozzleBlock extends ProperDirectionalBlock { @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return getDefaultState().with(FACING, context.getFace()); + return defaultBlockState().setValue(FACING, context.getClickedFace()); } @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return AllShapes.NOZZLE.get(state.get(FACING)); + return AllShapes.NOZZLE.get(state.getValue(FACING)); } @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - if (fromPos.equals(pos.offset(state.get(FACING).getOpposite()))) - if (!isValidPosition(state, worldIn, pos)) { + if (fromPos.equals(pos.relative(state.getValue(FACING).getOpposite()))) + if (!canSurvive(state, worldIn, pos)) { worldIn.destroyBlock(pos, true); return; } } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - Direction towardsFan = state.get(FACING).getOpposite(); - TileEntity te = worldIn.getTileEntity(pos.offset(towardsFan)); + public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + Direction towardsFan = state.getValue(FACING).getOpposite(); + TileEntity te = worldIn.getBlockEntity(pos.relative(towardsFan)); return te instanceof IAirCurrentSource && ((IAirCurrentSource) te).getAirflowOriginSide() == towardsFan.getOpposite(); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java index 73066ab14..1ca0d1ee5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java @@ -61,7 +61,7 @@ public class NozzleTileEntity extends SmartTileEntity { @Override public void initialize() { - fanPos = pos.offset(getBlockState().get(NozzleBlock.FACING) + fanPos = worldPosition.relative(getBlockState().getValue(NozzleBlock.FACING) .getOpposite()); super.initialize(); } @@ -74,28 +74,28 @@ public class NozzleTileEntity extends SmartTileEntity { if (this.range != range) setRange(range); - Vector3d center = VecHelper.getCenterOf(pos); - if (world.isRemote && range != 0) { - if (world.rand.nextInt( + Vector3d center = VecHelper.getCenterOf(worldPosition); + if (level.isClientSide && range != 0) { + if (level.random.nextInt( MathHelper.clamp((AllConfigs.SERVER.kinetics.fanPushDistance.get() - (int) range), 1, 10)) == 0) { - Vector3d start = VecHelper.offsetRandomly(center, world.rand, pushing ? 1 : range / 2); + Vector3d start = VecHelper.offsetRandomly(center, level.random, pushing ? 1 : range / 2); Vector3d motion = center.subtract(start) .normalize() .scale(MathHelper.clamp(range * (pushing ? .025f : 1f), 0, .5f) * (pushing ? -1 : 1)); - world.addParticle(ParticleTypes.POOF, start.x, start.y, start.z, motion.x, motion.y, motion.z); + level.addParticle(ParticleTypes.POOF, start.x, start.y, start.z, motion.x, motion.y, motion.z); } } for (Iterator iterator = pushingEntities.iterator(); iterator.hasNext();) { Entity entity = iterator.next(); - Vector3d diff = entity.getPositionVec() + Vector3d diff = entity.position() .subtract(center); - if (!(entity instanceof PlayerEntity) && world.isRemote) + if (!(entity instanceof PlayerEntity) && level.isClientSide) continue; double distance = diff.length(); - if (distance > range || entity.isSneaking() || AirCurrent.isPlayerCreativeFlying(entity)) { + if (distance > range || entity.isShiftKeyDown() || AirCurrent.isPlayerCreativeFlying(entity)) { iterator.remove(); continue; } @@ -106,10 +106,10 @@ public class NozzleTileEntity extends SmartTileEntity { float factor = (entity instanceof ItemEntity) ? 1 / 128f : 1 / 32f; Vector3d pushVec = diff.normalize() .scale((range - distance) * (pushing ? 1 : -1)); - entity.setMotion(entity.getMotion() + entity.setDeltaMovement(entity.getDeltaMovement() .add(pushVec.scale(factor))); entity.fallDistance = 0; - entity.velocityChanged = true; + entity.hurtMarked = true; } } @@ -122,7 +122,7 @@ public class NozzleTileEntity extends SmartTileEntity { } private float calcRange() { - TileEntity te = world.getTileEntity(fanPos); + TileEntity te = level.getBlockEntity(fanPos); if (!(te instanceof IAirCurrentSource)) return 0; @@ -144,15 +144,15 @@ public class NozzleTileEntity extends SmartTileEntity { if (range == 0) return; - Vector3d center = VecHelper.getCenterOf(pos); - AxisAlignedBB bb = new AxisAlignedBB(center, center).grow(range / 2f); + Vector3d center = VecHelper.getCenterOf(worldPosition); + AxisAlignedBB bb = new AxisAlignedBB(center, center).inflate(range / 2f); - for (Entity entity : world.getEntitiesWithinAABB(Entity.class, bb)) { - Vector3d diff = entity.getPositionVec() + for (Entity entity : level.getEntitiesOfClass(Entity.class, bb)) { + Vector3d diff = entity.position() .subtract(center); double distance = diff.length(); - if (distance > range || entity.isSneaking() || AirCurrent.isPlayerCreativeFlying(entity)) + if (distance > range || entity.isShiftKeyDown() || AirCurrent.isPlayerCreativeFlying(entity)) continue; boolean canSee = canSee(entity); @@ -172,8 +172,8 @@ public class NozzleTileEntity extends SmartTileEntity { iterator.remove(); } - if (!pushing && pushingEntities.size() > 256 && !world.isRemote) { - world.createExplosion(null, center.x, center.y, center.z, 2, Mode.NONE); + if (!pushing && pushingEntities.size() > 256 && !level.isClientSide) { + level.explode(null, center.x, center.y, center.z, 2, Mode.NONE); for (Iterator iterator = pushingEntities.iterator(); iterator.hasNext();) { Entity entity = iterator.next(); entity.remove(); @@ -184,10 +184,10 @@ public class NozzleTileEntity extends SmartTileEntity { } private boolean canSee(Entity entity) { - RayTraceContext context = new RayTraceContext(entity.getPositionVec(), VecHelper.getCenterOf(pos), + RayTraceContext context = new RayTraceContext(entity.position(), VecHelper.getCenterOf(worldPosition), BlockMode.COLLIDER, FluidMode.NONE, entity); - return pos.equals(world.rayTraceBlocks(context) - .getPos()); + return worldPosition.equals(level.clip(context) + .getBlockPos()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/SplashingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/SplashingRecipe.java index 9a9801cc3..499f6c8ff 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/SplashingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/SplashingRecipe.java @@ -22,7 +22,7 @@ public class SplashingRecipe extends ProcessingRecipe im public FlyWheelInstance(MaterialManager modelManager, FlywheelTileEntity tile) { super(modelManager, tile); - facing = blockState.get(HORIZONTAL_FACING); + facing = blockState.getValue(HORIZONTAL_FACING); shaft = setup(shaftModel().createInstance()); BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90); - wheel = getTransformMaterial().getModel(AllBlockPartials.FLYWHEEL, referenceState, referenceState.get(HORIZONTAL_FACING)).createInstance(); + wheel = getTransformMaterial().getModel(AllBlockPartials.FLYWHEEL, referenceState, referenceState.getValue(HORIZONTAL_FACING)).createInstance(); connection = FlywheelBlock.getConnection(blockState); if (connection != null) { - connectedLeft = blockState.get(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT; + connectedLeft = blockState.getValue(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT; boolean flipAngle = connection.getAxis() == Direction.Axis.X ^ connection.getAxisDirection() == Direction.AxisDirection.NEGATIVE; @@ -102,34 +102,34 @@ public class FlyWheelInstance extends KineticTileInstance im if (connection != null) { float rotation = angle * connectorAngleMult; - ms.push(); + ms.pushPose(); rotateToFacing(msr, connection); - ms.push(); + ms.pushPose(); transformConnector(msr, true, true, rotation, connectedLeft); upperRotating.setTransform(ms); - ms.pop(); + ms.popPose(); - ms.push(); + ms.pushPose(); transformConnector(msr, false, true, rotation, connectedLeft); lowerRotating.setTransform(ms); - ms.pop(); + ms.popPose(); - ms.push(); + ms.pushPose(); transformConnector(msr, true, false, rotation, connectedLeft); upperSliding.setTransform(ms); - ms.pop(); + ms.popPose(); - ms.push(); + ms.pushPose(); transformConnector(msr, false, false, rotation, connectedLeft); lowerSliding.setTransform(ms); - ms.pop(); + ms.popPose(); - ms.pop(); + ms.popPose(); } msr.centre() - .rotate(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, facing.getAxis()), AngleHelper.rad(angle)) + .rotate(Direction.get(Direction.AxisDirection.POSITIVE, facing.getAxis()), AngleHelper.rad(angle)) .unCentre(); wheel.setTransform(ms); @@ -145,7 +145,7 @@ public class FlyWheelInstance extends KineticTileInstance im relight(pos, shaft, wheel); if (connection != null) { - relight(this.pos.offset(connection), connectors.stream()); + relight(this.pos.relative(connection), connectors.stream()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelBlock.java index 607dcdd19..453b74a35 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelBlock.java @@ -23,18 +23,20 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class FlywheelBlock extends HorizontalKineticBlock { public static EnumProperty CONNECTION = EnumProperty.create("connection", ConnectionState.class); public FlywheelBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(CONNECTION, ConnectionState.NONE)); + registerDefaultState(defaultBlockState().setValue(CONNECTION, ConnectionState.NONE)); } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(CONNECTION)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(CONNECTION)); } @Override @@ -46,8 +48,8 @@ public class FlywheelBlock extends HorizontalKineticBlock { public BlockState getStateForPlacement(BlockItemUseContext context) { Direction preferred = getPreferredHorizontalFacing(context); if (preferred != null) - return getDefaultState().with(HORIZONTAL_FACING, preferred.getOpposite()); - return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing()); + return defaultBlockState().setValue(HORIZONTAL_FACING, preferred.getOpposite()); + return this.defaultBlockState().setValue(HORIZONTAL_FACING, context.getHorizontalDirection()); } public static boolean isConnected(BlockState state) { @@ -55,37 +57,37 @@ public class FlywheelBlock extends HorizontalKineticBlock { } public static Direction getConnection(BlockState state) { - Direction facing = state.get(HORIZONTAL_FACING); - ConnectionState connection = state.get(CONNECTION); + Direction facing = state.getValue(HORIZONTAL_FACING); + ConnectionState connection = state.getValue(CONNECTION); if (connection == ConnectionState.LEFT) - return facing.rotateYCCW(); + return facing.getCounterClockWise(); if (connection == ConnectionState.RIGHT) - return facing.rotateY(); + return facing.getClockWise(); return null; } public static void setConnection(World world, BlockPos pos, BlockState state, Direction direction) { - Direction facing = state.get(HORIZONTAL_FACING); + Direction facing = state.getValue(HORIZONTAL_FACING); ConnectionState connection = ConnectionState.NONE; - if (direction == facing.rotateY()) + if (direction == facing.getClockWise()) connection = ConnectionState.RIGHT; - if (direction == facing.rotateYCCW()) + if (direction == facing.getCounterClockWise()) connection = ConnectionState.LEFT; - world.setBlockState(pos, state.with(CONNECTION, connection), 18); + world.setBlock(pos, state.setValue(CONNECTION, connection), 18); AllTriggers.triggerForNearbyPlayers(AllTriggers.FLYWHEEL, world, pos, 4); } @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face == state.get(HORIZONTAL_FACING).getOpposite(); + return face == state.getValue(HORIZONTAL_FACING).getOpposite(); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(HORIZONTAL_FACING).getAxis(); + return state.getValue(HORIZONTAL_FACING).getAxis(); } @Override @@ -94,23 +96,23 @@ public class FlywheelBlock extends HorizontalKineticBlock { if (connection == null) return super.onWrenched(state ,context); - if (context.getFace().getAxis() == state.get(HORIZONTAL_FACING).getAxis()) + if (context.getClickedFace().getAxis() == state.getValue(HORIZONTAL_FACING).getAxis()) return ActionResultType.PASS; - World world = context.getWorld(); - BlockPos enginePos = context.getPos().offset(connection, 2); + World world = context.getLevel(); + BlockPos enginePos = context.getClickedPos().relative(connection, 2); BlockState engine = world.getBlockState(enginePos); if (engine.getBlock() instanceof FurnaceEngineBlock) ((FurnaceEngineBlock) engine.getBlock()).withTileEntityDo(world, enginePos, EngineTileEntity::detachWheel); - return super.onWrenched(state.with(CONNECTION, ConnectionState.NONE), context); + return super.onWrenched(state.setValue(CONNECTION, ConnectionState.NONE), context); } public enum ConnectionState implements IStringSerializable { NONE, LEFT, RIGHT; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelGenerator.java index 13dc7759d..9244651ad 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelGenerator.java @@ -17,14 +17,14 @@ public class FlywheelGenerator extends SpecialBlockStateGen { @Override protected int getYRotation(BlockState state) { - return horizontalAngle(state.get(FlywheelBlock.HORIZONTAL_FACING)) + 90; + return horizontalAngle(state.getValue(FlywheelBlock.HORIZONTAL_FACING)) + 90; } @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { return prov.models() - .getExistingFile(prov.modLoc("block/" + ctx.getName() + "/casing_" + state.get(FlywheelBlock.CONNECTION) - .getString())); + .getExistingFile(prov.modLoc("block/" + ctx.getName() + "/casing_" + state.getValue(FlywheelBlock.CONNECTION) + .getSerializedName())); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java index fc67fbd98..6eac080f0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java @@ -36,7 +36,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; BlockState blockState = te.getBlockState(); FlywheelTileEntity wte = (FlywheelTileEntity) te; @@ -44,16 +44,16 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { float speed = wte.visualSpeed.get(partialTicks) * 3 / 10f; float angle = wte.angle + speed * partialTicks; - IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); + IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); if (FlywheelBlock.isConnected(blockState)) { Direction connection = FlywheelBlock.getConnection(blockState); - light = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos() - .offset(connection)); + light = WorldRenderer.getLightColor(te.getLevel(), blockState, te.getBlockPos() + .relative(connection)); float rotation = connection.getAxis() == Axis.X ^ connection.getAxisDirection() == AxisDirection.NEGATIVE ? -angle : angle; - boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT; + boolean flip = blockState.getValue(FlywheelBlock.CONNECTION) == ConnectionState.LEFT; transformConnector( rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, @@ -77,9 +77,9 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { private void renderFlywheel(KineticTileEntity te, MatrixStack ms, int light, BlockState blockState, float angle, IVertexBuilder vb) { BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90); - Direction facing = referenceState.get(BlockStateProperties.HORIZONTAL_FACING); + Direction facing = referenceState.getValue(BlockStateProperties.HORIZONTAL_FACING); SuperByteBuffer wheel = PartialBufferer.getFacing(AllBlockPartials.FLYWHEEL, referenceState, facing); - kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING) + kineticRotationTransform(wheel, te, blockState.getValue(HORIZONTAL_FACING) .getAxis(), AngleHelper.rad(angle), light); wheel.renderInto(ms, vb); } @@ -87,7 +87,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() - .get(BlockStateProperties.HORIZONTAL_FACING) + .getValue(BlockStateProperties.HORIZONTAL_FACING) .getOpposite()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelTileEntity.java index b27ccb01c..ece43296c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelTileEntity.java @@ -40,7 +40,7 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity { @Override public float getGeneratedSpeed() { - return convertToDirection(generatedSpeed, getBlockState().get(FlywheelBlock.HORIZONTAL_FACING)); + return convertToDirection(generatedSpeed, getBlockState().getValue(FlywheelBlock.HORIZONTAL_FACING)); } @Override @@ -50,7 +50,7 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity { @Override public AxisAlignedBB makeRenderBoundingBox() { - return super.makeRenderBoundingBox().grow(2); + return super.makeRenderBoundingBox().inflate(2); } @Override @@ -76,7 +76,7 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity { public void tick() { super.tick(); - if (world.isRemote) { + if (level.isClientSide) { float targetSpeed = isVirtual() ? speed : getGeneratedSpeed(); visualSpeed.target(targetSpeed); visualSpeed.tick(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java index a32696209..a817af1aa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java @@ -22,6 +22,8 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class EngineBlock extends HorizontalBlock implements IWrenchable { protected EngineBlock(Properties builder) { @@ -29,8 +31,8 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - return isValidPosition(state, worldIn, pos, state.get(HORIZONTAL_FACING)); + public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + return isValidPosition(state, worldIn, pos, state.getValue(FACING)); } @Override @@ -48,24 +50,24 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - Direction facing = context.getFace(); - return getDefaultState().with(HORIZONTAL_FACING, - facing.getAxis().isVertical() ? context.getPlacementHorizontalFacing().getOpposite() : facing); + Direction facing = context.getClickedFace(); + return defaultBlockState().setValue(FACING, + facing.getAxis().isVertical() ? context.getHorizontalDirection().getOpposite() : facing); } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(HORIZONTAL_FACING)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(FACING)); } @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; if (fromPos.equals(getBaseBlockPos(state, pos))) { - if (!isValidPosition(state, worldIn, pos)) { + if (!canSurvive(state, worldIn, pos)) { worldIn.destroyBlock(pos, true); return; } @@ -79,7 +81,7 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable for (Direction otherFacing : Iterate.horizontalDirections) { if (otherFacing == facing) continue; - BlockPos otherPos = baseBlockPos.offset(otherFacing); + BlockPos otherPos = baseBlockPos.relative(otherFacing); BlockState otherState = world.getBlockState(otherPos); if (otherState.getBlock() instanceof EngineBlock && getBaseBlockPos(otherState, otherPos).equals(baseBlockPos)) @@ -90,7 +92,7 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable } public static BlockPos getBaseBlockPos(BlockState state, BlockPos pos) { - return pos.offset(state.get(HORIZONTAL_FACING).getOpposite()); + return pos.relative(state.getValue(FACING).getOpposite()); } @Nullable diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java index 4ce123e96..94092ad1e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java @@ -27,7 +27,7 @@ public class EngineInstance extends TileEntityInstance { EngineBlock engineBlock = (EngineBlock) block; PartialModel frame = engineBlock.getFrameModel(); - Direction facing = blockState.get(BlockStateProperties.HORIZONTAL_FACING); + Direction facing = blockState.getValue(BlockStateProperties.HORIZONTAL_FACING); this.frame = getTransformMaterial().getModel(frame, blockState).createInstance(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java index ce77b42ef..0d09715ae 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java @@ -24,7 +24,7 @@ public class EngineRenderer extends SafeTileEntityRe protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; Block block = te.getBlockState() .getBlock(); @@ -33,13 +33,13 @@ public class EngineRenderer extends SafeTileEntityRe PartialModel frame = engineBlock.getFrameModel(); if (frame != null) { Direction facing = te.getBlockState() - .get(EngineBlock.HORIZONTAL_FACING); + .getValue(EngineBlock.FACING); float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing)); PartialBufferer.get(frame, te.getBlockState()) .rotateCentered(Direction.UP, angle) .translate(0, 0, -1) - .light(WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getBlockState(), te.getPos())) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .light(WorldRenderer.getLightColor(te.getLevel(), te.getBlockState(), te.getBlockPos())) + .renderInto(ms, buffer.getBuffer(RenderType.solid())); } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineTileEntity.java index 719a735ca..9ae752b75 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineTileEntity.java @@ -15,6 +15,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -37,7 +38,7 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender @OnlyIn(Dist.CLIENT) public AxisAlignedBB getRenderBoundingBox() { if (cachedBoundingBox == null) { - cachedBoundingBox = super.getRenderBoundingBox().grow(1.5f); + cachedBoundingBox = super.getRenderBoundingBox().inflate(1.5f); } return cachedBoundingBox; } @@ -45,7 +46,7 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender @Override public void lazyTick() { super.lazyTick(); - if (world.isRemote) + if (level.isClientSide) return; if (poweredWheel != null && poweredWheel.isRemoved()) poweredWheel = null; @@ -54,23 +55,23 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender } public void attachWheel() { - Direction engineFacing = getBlockState().get(EngineBlock.HORIZONTAL_FACING); - BlockPos wheelPos = pos.offset(engineFacing, 2); - BlockState wheelState = world.getBlockState(wheelPos); + Direction engineFacing = getBlockState().getValue(EngineBlock.FACING); + BlockPos wheelPos = worldPosition.relative(engineFacing, 2); + BlockState wheelState = level.getBlockState(wheelPos); if (!AllBlocks.FLYWHEEL.has(wheelState)) return; - Direction wheelFacing = wheelState.get(FlywheelBlock.HORIZONTAL_FACING); - if (wheelFacing.getAxis() != engineFacing.rotateY().getAxis()) + Direction wheelFacing = wheelState.getValue(FlywheelBlock.HORIZONTAL_FACING); + if (wheelFacing.getAxis() != engineFacing.getClockWise().getAxis()) return; if (FlywheelBlock.isConnected(wheelState) && FlywheelBlock.getConnection(wheelState) != engineFacing.getOpposite()) return; - TileEntity te = world.getTileEntity(wheelPos); + TileEntity te = level.getBlockEntity(wheelPos); if (te.isRemoved()) return; if (te instanceof FlywheelTileEntity) { if (!FlywheelBlock.isConnected(wheelState)) - FlywheelBlock.setConnection(world, te.getPos(), te.getBlockState(), engineFacing.getOpposite()); + FlywheelBlock.setConnection(level, te.getBlockPos(), te.getBlockState(), engineFacing.getOpposite()); poweredWheel = (FlywheelTileEntity) te; refreshWheelSpeed(); } @@ -80,14 +81,14 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender if (poweredWheel == null || poweredWheel.isRemoved()) return; poweredWheel.setRotation(0, 0); - FlywheelBlock.setConnection(world, poweredWheel.getPos(), poweredWheel.getBlockState(), null); + FlywheelBlock.setConnection(level, poweredWheel.getBlockPos(), poweredWheel.getBlockState(), null); poweredWheel = null; } @Override - public void remove() { + public void setRemoved() { detachWheel(); - super.remove(); + super.setRemoved(); } protected void refreshWheelSpeed() { @@ -96,4 +97,5 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender poweredWheel.setRotation(appliedSpeed, appliedCapacity); } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java index e3083ac1a..fe251a7ba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java @@ -24,6 +24,8 @@ import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.block.AbstractBlock.Properties; + @EventBusSubscriber public class FurnaceEngineBlock extends EngineBlock implements ITE { @@ -38,7 +40,7 @@ public class FurnaceEngineBlock extends EngineBlock implements ITE, ICogWheel { public MillstoneBlock(Properties properties) { @@ -54,11 +56,11 @@ public class MillstoneBlock extends KineticBlock implements ITE { @@ -80,7 +82,7 @@ public class MillstoneBlock extends KineticBlock implements ITE { ItemHelper.dropContents(worldIn, pos, te.inputInv); ItemHelper.dropContents(worldIn, pos, te.outputInv); }); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } } @@ -141,7 +143,7 @@ public class MillstoneBlock extends KineticBlock implements ITE 0) { timer -= getProcessingSpeed(); - if (world.isRemote) { + if (level.isClientSide) { spawnParticles(); return; } @@ -95,8 +95,8 @@ public class MillstoneTileEntity extends KineticTileEntity { return; RecipeWrapper inventoryIn = new RecipeWrapper(inputInv); - if (lastRecipe == null || !lastRecipe.matches(inventoryIn, world)) { - Optional recipe = AllRecipeTypes.MILLING.find(inventoryIn, world); + if (lastRecipe == null || !lastRecipe.matches(inventoryIn, level)) { + Optional recipe = AllRecipeTypes.MILLING.find(inventoryIn, level); if (!recipe.isPresent()) { timer = 100; sendData(); @@ -113,16 +113,16 @@ public class MillstoneTileEntity extends KineticTileEntity { } @Override - public void remove() { - super.remove(); + public void setRemoved() { + super.setRemoved(); capability.invalidate(); } private void process() { RecipeWrapper inventoryIn = new RecipeWrapper(inputInv); - if (lastRecipe == null || !lastRecipe.matches(inventoryIn, world)) { - Optional recipe = AllRecipeTypes.MILLING.find(inventoryIn, world); + if (lastRecipe == null || !lastRecipe.matches(inventoryIn, level)) { + Optional recipe = AllRecipeTypes.MILLING.find(inventoryIn, level); if (!recipe.isPresent()) return; lastRecipe = recipe.get(); @@ -134,7 +134,7 @@ public class MillstoneTileEntity extends KineticTileEntity { lastRecipe.rollResults() .forEach(stack -> ItemHandlerHelper.insertItemStacked(outputInv, stack, false)); sendData(); - markDirty(); + setChanged(); } public void spawnParticles() { @@ -143,14 +143,14 @@ public class MillstoneTileEntity extends KineticTileEntity { return; ItemParticleData data = new ItemParticleData(ParticleTypes.ITEM, stackInSlot); - float angle = world.rand.nextFloat() * 360; + float angle = level.random.nextFloat() * 360; Vector3d offset = new Vector3d(0, 0, 0.5f); offset = VecHelper.rotate(offset, angle, Axis.Y); Vector3d target = VecHelper.rotate(offset, getSpeed() > 0 ? 25 : -25, Axis.Y); - Vector3d center = offset.add(VecHelper.getCenterOf(pos)); - target = VecHelper.offsetRandomly(target.subtract(offset), world.rand, 1 / 128f); - world.addParticle(data, center.x, center.y, center.z, target.x, target.y, target.z); + Vector3d center = offset.add(VecHelper.getCenterOf(worldPosition)); + target = VecHelper.offsetRandomly(target.subtract(offset), level.random, 1 / 128f); + level.addParticle(data, center.x, center.y, center.z, target.x, target.y, target.z); } @Override @@ -185,9 +185,9 @@ public class MillstoneTileEntity extends KineticTileEntity { tester.setStackInSlot(0, stack); RecipeWrapper inventoryIn = new RecipeWrapper(tester); - if (lastRecipe != null && lastRecipe.matches(inventoryIn, world)) + if (lastRecipe != null && lastRecipe.matches(inventoryIn, level)) return true; - return AllRecipeTypes.MILLING.find(inventoryIn, world) + return AllRecipeTypes.MILLING.find(inventoryIn, level) .isPresent(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerBlock.java index 1d20436b9..0e80f176c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerBlock.java @@ -19,6 +19,9 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; +import com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel; +import net.minecraft.block.AbstractBlock.Properties; + public class MechanicalMixerBlock extends KineticBlock implements ITE, ICogWheel { public MechanicalMixerBlock(Properties properties) { @@ -31,8 +34,8 @@ public class MechanicalMixerBlock extends KineticBlock implements ITE bte.setAreFluidsMoving(running && runningTicks <= 20)); } @@ -120,11 +120,11 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { } float speed = Math.abs(getSpeed()); - if (running && world != null) { - if (world.isRemote && runningTicks == 20) + if (running && level != null) { + if (level.isClientSide && runningTicks == 20) renderParticles(); - if ((!world.isRemote || isVirtual()) && runningTicks == 20) { + if ((!level.isClientSide || isVirtual()) && runningTicks == 20) { if (processingTicks < 0) { processingTicks = MathHelper.clamp((MathHelper.log2((int) (512 / speed))) * 15 + 1, 1, 512); @@ -136,7 +136,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { .isEmpty() || !tanks.getSecond() .isEmpty()) - world.playSound(null, pos, SoundEvents.BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT, + level.playSound(null, worldPosition, SoundEvents.BUBBLE_COLUMN_WHIRLPOOL_AMBIENT, SoundCategory.BLOCKS, .75f, speed < 65 ? .75f : 1.5f); } @@ -158,13 +158,13 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { public void renderParticles() { Optional basin = getBasin(); - if (!basin.isPresent() || world == null) + if (!basin.isPresent() || level == null) return; for (SmartInventory inv : basin.get() .getInvs()) { for (int slot = 0; slot < inv.getSlots(); slot++) { - ItemStack stackInSlot = inv.getStackInSlot(slot); + ItemStack stackInSlot = inv.getItem(slot); if (stackInSlot.isEmpty()) continue; ItemParticleData data = new ItemParticleData(ParticleTypes.ITEM, stackInSlot); @@ -185,14 +185,14 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { } protected void spillParticle(IParticleData data) { - float angle = world.rand.nextFloat() * 360; + float angle = level.random.nextFloat() * 360; Vector3d offset = new Vector3d(0, 0, 0.25f); offset = VecHelper.rotate(offset, angle, Axis.Y); Vector3d target = VecHelper.rotate(offset, getSpeed() > 0 ? 25 : -25, Axis.Y) .add(0, .25f, 0); - Vector3d center = offset.add(VecHelper.getCenterOf(pos)); - target = VecHelper.offsetRandomly(target.subtract(offset), world.rand, 1 / 128f); - world.addParticle(data, center.x, center.y - 1.75f, center.z, target.x, target.y, target.z); + Vector3d center = offset.add(VecHelper.getCenterOf(worldPosition)); + target = VecHelper.offsetRandomly(target.subtract(offset), level.random, 1 / 128f); + level.addParticle(data, center.x, center.y - 1.75f, center.z, target.x, target.y, target.z); } @Override @@ -226,7 +226,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { @Override protected boolean matchStaticFilters(IRecipe r) { - return ((r.getSerializer() == IRecipeSerializer.CRAFTING_SHAPELESS + return ((r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE && AllConfigs.SERVER.recipes.allowShapelessInMixer.get() && r.getIngredients() .size() > 1) || r.getType() == AllRecipeTypes.MIXING.type); @@ -280,7 +280,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { if (slow && AnimationTickHolder.getTicks() % 2 == 0) return; if (runningTicks == 20) - AllSoundEvents.MIXING.playAt(world, pos, .75f, 1, true); + AllSoundEvents.MIXING.playAt(level, worldPosition, .75f, 1, true); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java index 7aac448c8..19d81bdc9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java @@ -66,7 +66,7 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta public void updateLight() { super.updateLight(); - relight(pos.down(), mixerHead); + relight(pos.below(), mixerHead); relight(pos, mixerPole); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorBlock.java index 7239a505e..037947564 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorBlock.java @@ -16,6 +16,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; +import net.minecraft.block.AbstractBlock.Properties; + public class CreativeMotorBlock extends DirectionalKineticBlock { public CreativeMotorBlock(Properties properties) { @@ -24,7 +26,7 @@ public class CreativeMotorBlock extends DirectionalKineticBlock { @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return AllShapes.MOTOR_BLOCK.get(state.get(FACING)); + return AllShapes.MOTOR_BLOCK.get(state.getValue(FACING)); } @Override @@ -36,21 +38,21 @@ public class CreativeMotorBlock extends DirectionalKineticBlock { public BlockState getStateForPlacement(BlockItemUseContext context) { Direction preferred = getPreferredFacing(context); if ((context.getPlayer() != null && context.getPlayer() - .isSneaking()) || preferred == null) + .isShiftKeyDown()) || preferred == null) return super.getStateForPlacement(context); - return getDefaultState().with(FACING, preferred); + return defaultBlockState().setValue(FACING, preferred); } // IRotate: @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face == state.get(FACING); + return face == state.getValue(FACING); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(FACING) + return state.getValue(FACING) .getAxis(); } @@ -60,7 +62,7 @@ public class CreativeMotorBlock extends DirectionalKineticBlock { } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorGenerator.java index a26c54d41..032783bb6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorGenerator.java @@ -14,20 +14,20 @@ public class CreativeMotorGenerator extends SpecialBlockStateGen { @Override protected int getXRotation(BlockState state) { - return state.get(CreativeMotorBlock.FACING) == Direction.DOWN ? 180 : 0; + return state.getValue(CreativeMotorBlock.FACING) == Direction.DOWN ? 180 : 0; } @Override protected int getYRotation(BlockState state) { - return state.get(CreativeMotorBlock.FACING) + return state.getValue(CreativeMotorBlock.FACING) .getAxis() - .isVertical() ? 0 : horizontalAngle(state.get(CreativeMotorBlock.FACING)); + .isVertical() ? 0 : horizontalAngle(state.getValue(CreativeMotorBlock.FACING)); } @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - return state.get(CreativeMotorBlock.FACING) + return state.getValue(CreativeMotorBlock.FACING) .getAxis() .isVertical() ? AssetLookup.partialBaseModel(ctx, prov, "vertical") : AssetLookup.partialBaseModel(ctx, prov); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorTileEntity.java index 1f0168b87..4509f6ff8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorTileEntity.java @@ -28,7 +28,7 @@ public class CreativeMotorTileEntity extends GeneratingKineticTileEntity { Integer max = AllConfigs.SERVER.kinetics.maxMotorSpeed.get(); CenteredSideValueBoxTransform slot = new CenteredSideValueBoxTransform( - (motor, side) -> motor.get(CreativeMotorBlock.FACING) == side.getOpposite()); + (motor, side) -> motor.getValue(CreativeMotorBlock.FACING) == side.getOpposite()); generatedSpeed = new ScrollValueBehaviour(Lang.translate("generic.speed"), this, slot); generatedSpeed.between(-max, max); @@ -51,7 +51,7 @@ public class CreativeMotorTileEntity extends GeneratingKineticTileEntity { public float getGeneratedSpeed() { if (!AllBlocks.CREATIVE_MOTOR.has(getBlockState())) return 0; - return convertToDirection(generatedSpeed.getValue(), getBlockState().get(CreativeMotorBlock.FACING)); + return convertToDirection(generatedSpeed.getValue(), getBlockState().getValue(CreativeMotorBlock.FACING)); } public static int step(StepContext context) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/BeltPressingCallbacks.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/BeltPressingCallbacks.java index 3c4c63ef4..1af77a41f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/BeltPressingCallbacks.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/BeltPressingCallbacks.java @@ -84,7 +84,7 @@ public class BeltPressingCallbacks { handler.handleProcessingOnItem(transported, TransportedResult.convertToAndLeaveHeld(collect, left)); } - AllTriggers.triggerForNearbyPlayers(AllTriggers.BONK, pressTe.getWorld(), pressTe.getPos(), 4); + AllTriggers.triggerForNearbyPlayers(AllTriggers.BONK, pressTe.getLevel(), pressTe.getBlockPos(), 4); pressTe.sendData(); return HOLD; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressBlock.java index 8de328a78..d4ca80567 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressBlock.java @@ -19,6 +19,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; +import net.minecraft.block.AbstractBlock.Properties; + public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE { public MechanicalPressBlock(Properties properties) { @@ -33,8 +35,8 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE< } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - return !AllBlocks.BASIN.has(worldIn.getBlockState(pos.down())); + public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + return !AllBlocks.BASIN.has(worldIn.getBlockState(pos.below())); } @Override @@ -46,19 +48,19 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE< public BlockState getStateForPlacement(BlockItemUseContext context) { Direction prefferedSide = getPreferredHorizontalFacing(context); if (prefferedSide != null) - return getDefaultState().with(HORIZONTAL_FACING, prefferedSide); + return defaultBlockState().setValue(HORIZONTAL_FACING, prefferedSide); return super.getStateForPlacement(context); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(HORIZONTAL_FACING) + return state.getValue(HORIZONTAL_FACING) .getAxis(); } @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face.getAxis() == state.get(HORIZONTAL_FACING) + return face.getAxis() == state.getValue(HORIZONTAL_FACING) .getAxis(); } @@ -68,7 +70,7 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE< } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java index 2b31d4afc..731294f2c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java @@ -24,7 +24,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer { } @Override - public boolean isGlobalRenderer(KineticTileEntity te) { + public boolean shouldRenderOffScreen(KineticTileEntity te) { return true; } @@ -33,17 +33,17 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; - BlockPos pos = te.getPos(); + BlockPos pos = te.getBlockPos(); BlockState blockState = te.getBlockState(); - int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos); + int packedLightmapCoords = WorldRenderer.getLightColor(te.getLevel(), blockState, pos); float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks); - SuperByteBuffer headRender = PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.get(HORIZONTAL_FACING)); + SuperByteBuffer headRender = PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.getValue(HORIZONTAL_FACING)); headRender.translate(0, -renderedHeadOffset, 0) .light(packedLightmapCoords) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .renderInto(ms, buffer.getBuffer(RenderType.solid())); } @Override 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 78ff1aeab..38b639cc7 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 @@ -86,7 +86,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { if (clientPacket) { NBTHelper.iterateCompoundList(compound.getList("ParticleItems", NBT.TAG_COMPOUND), - c -> pressedItems.add(ItemStack.read(c))); + c -> pressedItems.add(ItemStack.of(c))); spawnParticles(); } } @@ -107,8 +107,8 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { @Override public AxisAlignedBB makeRenderBoundingBox() { - return new AxisAlignedBB(pos).expand(0, -1.5, 0) - .expand(0, 1, 0); + return new AxisAlignedBB(worldPosition).expandTowards(0, -1.5, 0) + .expandTowards(0, 1, 0); } public float getRenderedHeadOffset(float partialTicks) { @@ -142,8 +142,8 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { public void tick() { super.tick(); - if (!running || world == null) { - if (hasWorld() && !world.isRemote) { + if (!running || level == null) { + if (hasLevel() && !level.isClientSide) { if (getSpeed() == 0) return; @@ -151,13 +151,13 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { entityScanCooldown--; if (entityScanCooldown <= 0) { entityScanCooldown = ENTITY_SCAN; - if (TileEntityBehaviour.get(world, pos.down(2), TransportedItemStackHandlerBehaviour.TYPE) != null) + if (TileEntityBehaviour.get(level, worldPosition.below(2), TransportedItemStackHandlerBehaviour.TYPE) != null) return; - if (AllBlocks.BASIN.has(world.getBlockState(pos.down(2)))) + if (AllBlocks.BASIN.has(level.getBlockState(worldPosition.below(2)))) return; - for (ItemEntity itemEntity : world.getEntitiesWithinAABB(ItemEntity.class, - new AxisAlignedBB(pos.down()).shrink(.125f))) { + for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, + new AxisAlignedBB(worldPosition.below()).deflate(.125f))) { if (!itemEntity.isAlive() || !itemEntity.isOnGround()) continue; ItemStack stack = itemEntity.getItem(); @@ -173,7 +173,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { return; } - if (world.isRemote && runningTicks == -CYCLE / 2) { + if (level.isClientSide && runningTicks == -CYCLE / 2) { prevRunningTicks = CYCLE / 2; return; } @@ -184,16 +184,16 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { if (onBasin()) applyCompactingOnBasin(); - if (world.getBlockState(pos.down(2)).getSoundType() == SoundType.CLOTH) - AllSoundEvents.MECHANICAL_PRESS_ACTIVATION_ON_BELT.playOnServer(world, pos); + if (level.getBlockState(worldPosition.below(2)).getSoundType() == SoundType.WOOL) + AllSoundEvents.MECHANICAL_PRESS_ACTIVATION_ON_BELT.playOnServer(level, worldPosition); else - AllSoundEvents.MECHANICAL_PRESS_ACTIVATION.playOnServer(world, pos, .5f, .75f + (Math.abs(getSpeed()) / 1024f)); + AllSoundEvents.MECHANICAL_PRESS_ACTIVATION.playOnServer(level, worldPosition, .5f, .75f + (Math.abs(getSpeed()) / 1024f)); - if (!world.isRemote) + if (!level.isClientSide) sendData(); } - if (!world.isRemote && runningTicks > CYCLE) { + if (!level.isClientSide && runningTicks > CYCLE) { finished = true; running = false; @@ -212,13 +212,13 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { if (prevRunningTicks < CYCLE / 2 && runningTicks >= CYCLE / 2) { runningTicks = CYCLE / 2; // Pause the ticks until a packet is received - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) runningTicks = -(CYCLE / 2); } } protected void applyCompactingOnBasin() { - if (world.isRemote) + if (level.isClientSide) return; pressedItems.clear(); applyBasinRecipe(); @@ -227,7 +227,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { .getInputInventory(); if (basin.isPresent()) { for (int slot = 0; slot < inputs.getSlots(); slot++) { - ItemStack stackInSlot = inputs.getStackInSlot(slot); + ItemStack stackInSlot = inputs.getItem(slot); if (stackInSlot.isEmpty()) continue; pressedItems.add(stackInSlot); @@ -237,12 +237,12 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { } protected void applyPressingInWorld() { - AxisAlignedBB bb = new AxisAlignedBB(pos.down(1)); + AxisAlignedBB bb = new AxisAlignedBB(worldPosition.below(1)); boolean bulk = canProcessInBulk(); pressedItems.clear(); - if (world.isRemote) + if (level.isClientSide) return; - for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(null, bb)) { + for (Entity entity : level.getEntities(null, bb)) { if (!(entity instanceof ItemEntity)) continue; if (!entity.isAlive() || !entity.isOnGround()) @@ -261,15 +261,15 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { for (ItemStack result : InWorldProcessing.applyRecipeOn(ItemHandlerHelper.copyStackWithSize(item, 1), recipe.get())) { ItemEntity created = - new ItemEntity(world, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), result); - created.setDefaultPickupDelay(); - created.setMotion(VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .05f)); - world.addEntity(created); + new ItemEntity(level, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), result); + created.setDefaultPickUpDelay(); + created.setDeltaMovement(VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .05f)); + level.addFreshEntity(created); } item.shrink(1); } - AllTriggers.triggerForNearbyPlayers(AllTriggers.BONK, world, pos, 4); + AllTriggers.triggerForNearbyPlayers(AllTriggers.BONK, level, worldPosition, 4); entityScanCooldown = 0; if (!bulk) @@ -292,35 +292,35 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { return; if (mode == Mode.BASIN) - pressedItems.forEach(stack -> makeCompactingParticleEffect(VecHelper.getCenterOf(pos.down(2)), stack)); + pressedItems.forEach(stack -> makeCompactingParticleEffect(VecHelper.getCenterOf(worldPosition.below(2)), stack)); if (mode == Mode.BELT) - pressedItems.forEach(stack -> makePressingParticleEffect(VecHelper.getCenterOf(pos.down(2)) + pressedItems.forEach(stack -> makePressingParticleEffect(VecHelper.getCenterOf(worldPosition.below(2)) .add(0, 8 / 16f, 0), stack)); if (mode == Mode.WORLD) - pressedItems.forEach(stack -> makePressingParticleEffect(VecHelper.getCenterOf(pos.down(1)) + pressedItems.forEach(stack -> makePressingParticleEffect(VecHelper.getCenterOf(worldPosition.below(1)) .add(0, -1 / 4f, 0), stack)); pressedItems.clear(); } public void makePressingParticleEffect(Vector3d pos, ItemStack stack) { - if (world == null || !world.isRemote) + if (level == null || !level.isClientSide) return; for (int i = 0; i < 20; i++) { - Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, world.rand, .125f) - .mul(1, 0, 1); - world.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), pos.x, pos.y - .25f, pos.z, motion.x, + Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, level.random, .125f) + .multiply(1, 0, 1); + level.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), pos.x, pos.y - .25f, pos.z, motion.x, motion.y + .125f, motion.z); } } public void makeCompactingParticleEffect(Vector3d pos, ItemStack stack) { - if (world == null || !world.isRemote) + if (level == null || !level.isClientSide) return; for (int i = 0; i < 20; i++) { - Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, world.rand, .175f) - .mul(1, 0, 1); - world.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), pos.x, pos.y, pos.z, motion.x, + Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, level.random, .175f) + .multiply(1, 0, 1); + level.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), pos.x, pos.y, pos.z, motion.x, motion.y + .25f, motion.z); } } @@ -329,12 +329,12 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { public Optional getRecipe(ItemStack item) { Optional assemblyRecipe = - SequencedAssemblyRecipe.getRecipe(world, item, AllRecipeTypes.PRESSING.getType(), PressingRecipe.class); + SequencedAssemblyRecipe.getRecipe(level, item, AllRecipeTypes.PRESSING.getType(), PressingRecipe.class); if (assemblyRecipe.isPresent()) return assemblyRecipe; - pressingInv.setInventorySlotContents(0, item); - return AllRecipeTypes.PRESSING.find(pressingInv, world); + pressingInv.setItem(0, item); + return AllRecipeTypes.PRESSING.find(pressingInv, level); } public static boolean canCompress(NonNullList ingredients) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java index 866fd4fa3..418fa0fea 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java @@ -24,7 +24,7 @@ public class PressInstance extends ShaftInstance implements IDynamicInstance { .getModel(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState) .createInstance(); - Quaternion q = Vector3f.POSITIVE_Y.getDegreesQuaternion(AngleHelper.horizontalAngle(blockState.get(MechanicalPressBlock.HORIZONTAL_FACING))); + Quaternion q = Vector3f.YP.rotationDegrees(AngleHelper.horizontalAngle(blockState.getValue(MechanicalPressBlock.HORIZONTAL_FACING))); pressHead.setRotation(q); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/PressingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/PressingRecipe.java index 4f9374ec1..f68c4abeb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/PressingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/PressingRecipe.java @@ -34,7 +34,7 @@ public class PressingRecipe extends ProcessingRecipe implements I if (inv.isEmpty()) return false; return ingredients.get(0) - .test(inv.getStackInSlot(0)); + .test(inv.getItem(0)); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/CuttingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/CuttingRecipe.java index eddb48062..0933bec29 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/CuttingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/CuttingRecipe.java @@ -34,7 +34,7 @@ public class CuttingRecipe extends ProcessingRecipe implements IA if (inv.isEmpty()) return false; return ingredients.get(0) - .test(inv.getStackInSlot(0)); + .test(inv.getItem(0)); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawBlock.java index a4458acd7..30aa20e8f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawBlock.java @@ -30,10 +30,12 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class SawBlock extends DirectionalAxisKineticBlock implements ITE { - public static DamageSource damageSourceSaw = new DamageSource("create.mechanical_saw").setDamageBypassesArmor(); + public static DamageSource damageSourceSaw = new DamageSource("create.mechanical_saw").bypassArmor(); public SawBlock(Properties properties) { super(properties); @@ -42,10 +44,10 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE { if (te.getSpeed() == 0) return; - entityIn.attackEntityFrom(damageSourceSaw, (float) DrillBlock.getDamage(te.getSpeed())); + entityIn.hurt(damageSourceSaw, (float) DrillBlock.getDamage(te.getSpeed())); }); } @Override - public void onLanded(IBlockReader worldIn, Entity entityIn) { - super.onLanded(worldIn, entityIn); + public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + super.updateEntityAfterFallOn(worldIn, entityIn); if (!(entityIn instanceof ItemEntity)) return; - if (entityIn.world.isRemote) + if (entityIn.level.isClientSide) return; - BlockPos pos = entityIn.getBlockPos(); - withTileEntityDo(entityIn.world, pos, te -> { + BlockPos pos = entityIn.blockPosition(); + withTileEntityDo(entityIn.level, pos, te -> { if (te.getSpeed() == 0) return; te.insertItem((ItemEntity) entityIn); @@ -88,33 +90,33 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE ItemHelper.dropContents(worldIn, pos, te.inventory)); TileEntityBehaviour.destroy(worldIn, pos, FilteringBehaviour.TYPE); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } @Override @@ -123,7 +125,7 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { String path = "block/" + ctx.getName() + "/"; - String orientation = state.get(SawBlock.FACING) + String orientation = state.getValue(SawBlock.FACING) .getAxis() .isVertical() ? "vertical" : "horizontal"; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawInstance.java index 287e1b80f..73fac169c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawInstance.java @@ -21,9 +21,9 @@ public class SawInstance extends SingleRotatingInstance { @Override protected Instancer getModel() { - if (blockState.get(FACING).getAxis().isHorizontal()) { - BlockState referenceState = blockState.rotate(tile.getWorld(), tile.getPos(), Rotation.CLOCKWISE_180); - Direction facing = referenceState.get(FACING); + if (blockState.getValue(FACING).getAxis().isHorizontal()) { + BlockState referenceState = blockState.rotate(tile.getLevel(), tile.getBlockPos(), Rotation.CLOCKWISE_180); + Direction facing = referenceState.getValue(FACING); return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, referenceState, facing); } else { return getRotatingMaterial().getModel(shaft()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index 3d0ab3a95..76831398a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -50,7 +50,7 @@ public class SawRenderer extends SafeTileEntityRenderer { FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); if (Backend.getInstance() - .canUseInstancing(te.getWorld())) + .canUseInstancing(te.getLevel())) return; renderShaft(te, ms, buffer, light, overlay); @@ -79,7 +79,7 @@ public class SawRenderer extends SafeTileEntityRenderer { partial = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE; } - if (!blockState.get(SawBlock.AXIS_ALONG_FIRST_COORDINATE)) + if (!blockState.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE)) rotate = true; } @@ -89,22 +89,22 @@ public class SawRenderer extends SafeTileEntityRenderer { } superBuffer.color(0xFFFFFF) .light(light) - .renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); + .renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped())); } protected void renderShaft(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { KineticTileEntityRenderer.renderRotatingBuffer(te, getRotatedModel(te), ms, - buffer.getBuffer(RenderType.getSolid()), light); + buffer.getBuffer(RenderType.solid()), light); } protected void renderItems(SawTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { boolean processingMode = te.getBlockState() - .get(SawBlock.FACING) == Direction.UP; + .getValue(SawBlock.FACING) == Direction.UP; if (processingMode && !te.inventory.isEmpty()) { boolean alongZ = !te.getBlockState() - .get(SawBlock.AXIS_ALONG_FIRST_COORDINATE); - ms.push(); + .getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE); + ms.pushPose(); boolean moving = te.inventory.recipeDuration != 0; float offset = moving ? (float) (te.inventory.remainingTime) / te.inventory.recipeDuration : 0; @@ -129,30 +129,30 @@ public class SawRenderer extends SafeTileEntityRenderer { ItemRenderer itemRenderer = Minecraft.getInstance() .getItemRenderer(); - IBakedModel modelWithOverrides = itemRenderer.getItemModelWithOverrides(stack, te.getWorld(), null); + IBakedModel modelWithOverrides = itemRenderer.getModel(stack, te.getLevel(), null); boolean blockItem = modelWithOverrides.isGui3d(); ms.translate(alongZ ? offset : .5, blockItem ? .925f : 13f / 16f, alongZ ? .5 : offset); ms.scale(.5f, .5f, .5f); if (alongZ) - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90)); - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); - itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, light, overlay, ms, buffer); + ms.mulPose(Vector3f.YP.rotationDegrees(90)); + ms.mulPose(Vector3f.XP.rotationDegrees(90)); + itemRenderer.renderStatic(stack, ItemCameraTransforms.TransformType.FIXED, light, overlay, ms, buffer); break; } - ms.pop(); + ms.popPose(); } } protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { BlockState state = te.getBlockState(); - if (state.get(FACING) + if (state.getValue(FACING) .getAxis() .isHorizontal()) return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, - state.rotate(te.getWorld(), te.getPos(), Rotation.CLOCKWISE_180)); + state.rotate(te.getLevel(), te.getBlockPos(), Rotation.CLOCKWISE_180)); return CreateClient.BUFFER_CACHE.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE, getRenderedBlockState(te)); } @@ -164,13 +164,13 @@ public class SawRenderer extends SafeTileEntityRenderer { public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, ContraptionMatrices matrices, IRenderTypeBuffer buffer) { BlockState state = context.state; - Direction facing = state.get(SawBlock.FACING); + Direction facing = state.getValue(SawBlock.FACING); - Vector3d facingVec = Vector3d.of(context.state.get(SawBlock.FACING) - .getDirectionVec()); + Vector3d facingVec = Vector3d.atLowerCornerOf(context.state.getValue(SawBlock.FACING) + .getNormal()); facingVec = context.rotation.apply(facingVec); - Direction closestToFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z); + Direction closestToFacing = Direction.getNearest(facingVec.x, facingVec.y, facingVec.z); boolean horizontal = closestToFacing.getAxis() .isHorizontal(); @@ -193,22 +193,22 @@ public class SawRenderer extends SafeTileEntityRenderer { } MatrixStack m = matrices.contraptionStack; - m.push(); + m.pushPose(); MatrixStacker.of(m) .centre() .rotateY(AngleHelper.horizontalAngle(facing)) .rotateX(AngleHelper.verticalAngle(facing)); if (!SawBlock.isHorizontal(state)) MatrixStacker.of(m) - .rotateZ(state.get(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 0 : 90); + .rotateZ(state.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 0 : 90); MatrixStacker.of(m) .unCentre(); superBuffer.transform(m) .light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) - .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getCutoutMipped())); + .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.cutoutMipped())); - m.pop(); + m.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntity.java index 5eeb534f1..f05dba37e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntity.java @@ -76,7 +76,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { private static final Object cuttingRecipesKey = new Object(); public static final LazyValue> woodcuttingRecipeType = - new LazyValue<>(() -> Registry.RECIPE_TYPE.getOrDefault(new ResourceLocation("druidcraft", "woodcutting"))); + new LazyValue<>(() -> Registry.RECIPE_TYPE.get(new ResourceLocation("druidcraft", "woodcutting"))); public ProcessingInventory inventory; private int recipeIndex; @@ -120,14 +120,14 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { inventory.deserializeNBT(compound.getCompound("Inventory")); recipeIndex = compound.getInt("RecipeIndex"); if (compound.contains("PlayEvent")) - playEvent = ItemStack.read(compound.getCompound("PlayEvent")); + playEvent = ItemStack.of(compound.getCompound("PlayEvent")); } @Override protected AxisAlignedBB makeRenderBoundingBox() { - Direction facing = getBlockState().get(SawBlock.FACING); - AxisAlignedBB box = RENDER_BOX.expand(facing.getXOffset() * 0.125f, facing.getYOffset() * 0.125f, facing.getZOffset() * 0.125f); - return box.offset(pos); + Direction facing = getBlockState().getValue(SawBlock.FACING); + AxisAlignedBB box = RENDER_BOX.expandTowards(facing.getStepX() * 0.125f, facing.getStepY() * 0.125f, facing.getStepZ() * 0.125f); + return box.move(worldPosition); } @Override @@ -142,14 +142,14 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { Item item = playEvent.getItem(); if (item instanceof BlockItem) { Block block = ((BlockItem) item).getBlock(); - isWood = block.getSoundType(block.getDefaultState(), world, pos, null) == SoundType.WOOD; + isWood = block.getSoundType(block.defaultBlockState(), level, worldPosition, null) == SoundType.WOOD; } spawnEventParticles(playEvent); playEvent = ItemStack.EMPTY; if (!isWood) - AllSoundEvents.SAW_ACTIVATE_STONE.playAt(world, pos, 3, 1, true); + AllSoundEvents.SAW_ACTIVATE_STONE.playAt(level, worldPosition, 3, 1, true); else - AllSoundEvents.SAW_ACTIVATE_WOOD.playAt(world, pos, 3, 1, true); + AllSoundEvents.SAW_ACTIVATE_WOOD.playAt(level, worldPosition, 3, 1, true); return; } } @@ -177,7 +177,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { spawnParticles(inventory.getStackInSlot(0)); if (inventory.remainingTime < 5 && !inventory.appliedRecipe) { - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) return; playEvent = inventory.getStackInSlot(0); applyRecipe(); @@ -189,7 +189,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } Vector3d itemMovement = getItemMovementVec(); - Direction itemMovementFacing = Direction.getFacingFromVector(itemMovement.x, itemMovement.y, itemMovement.z); + Direction itemMovementFacing = Direction.getNearest(itemMovement.x, itemMovement.y, itemMovement.z); if (inventory.remainingTime > 0) return; inventory.remainingTime = 0; @@ -211,13 +211,13 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } } - BlockPos nextPos = pos.add(itemMovement.x, itemMovement.y, itemMovement.z); - DirectBeltInputBehaviour behaviour = TileEntityBehaviour.get(world, nextPos, DirectBeltInputBehaviour.TYPE); + BlockPos nextPos = worldPosition.offset(itemMovement.x, itemMovement.y, itemMovement.z); + DirectBeltInputBehaviour behaviour = TileEntityBehaviour.get(level, nextPos, DirectBeltInputBehaviour.TYPE); if (behaviour != null) { boolean changed = false; if (!behaviour.canInsertFromSide(itemMovementFacing)) return; - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) return; for (int slot = 0; slot < inventory.getSlots(); slot++) { ItemStack stack = inventory.getStackInSlot(slot); @@ -230,14 +230,14 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { changed = true; } if (changed) { - markDirty(); + setChanged(); sendData(); } return; } // Eject Items - Vector3d outPos = VecHelper.getCenterOf(pos) + Vector3d outPos = VecHelper.getCenterOf(worldPosition) .add(itemMovement.scale(.5f) .add(0, .5, 0)); Vector3d outMotion = itemMovement.scale(.0625) @@ -246,20 +246,20 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { ItemStack stack = inventory.getStackInSlot(slot); if (stack.isEmpty()) continue; - ItemEntity entityIn = new ItemEntity(world, outPos.x, outPos.y, outPos.z, stack); - entityIn.setMotion(outMotion); - world.addEntity(entityIn); + ItemEntity entityIn = new ItemEntity(level, outPos.x, outPos.y, outPos.z, stack); + entityIn.setDeltaMovement(outMotion); + level.addFreshEntity(entityIn); } inventory.clear(); - world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); + level.updateNeighbourForOutputSignal(worldPosition, getBlockState().getBlock()); inventory.remainingTime = -1; sendData(); } @Override - public void remove() { + public void setRemoved() { invProvider.invalidate(); - super.remove(); + super.setRemoved(); } @Override @@ -276,16 +276,16 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { IParticleData particleData = null; if (stack.getItem() instanceof BlockItem) particleData = new BlockParticleData(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock() - .getDefaultState()); + .defaultBlockState()); else particleData = new ItemParticleData(ParticleTypes.ITEM, stack); - Random r = world.rand; - Vector3d v = VecHelper.getCenterOf(this.pos) + Random r = level.random; + Vector3d v = VecHelper.getCenterOf(this.worldPosition) .add(0, 5 / 16f, 0); for (int i = 0; i < 10; i++) { Vector3d m = VecHelper.offsetRandomly(new Vector3d(0, 0.25f, 0), r, .125f); - world.addParticle(particleData, v.x, v.y, v.z, m.x, m.y, m.y); + level.addParticle(particleData, v.x, v.y, v.z, m.x, m.y, m.y); } } @@ -297,25 +297,25 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { float speed = 1; if (stack.getItem() instanceof BlockItem) particleData = new BlockParticleData(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock() - .getDefaultState()); + .defaultBlockState()); else { particleData = new ItemParticleData(ParticleTypes.ITEM, stack); speed = .125f; } - Random r = world.rand; + Random r = level.random; Vector3d vec = getItemMovementVec(); - Vector3d pos = VecHelper.getCenterOf(this.pos); + Vector3d pos = VecHelper.getCenterOf(this.worldPosition); float offset = inventory.recipeDuration != 0 ? (float) (inventory.remainingTime) / inventory.recipeDuration : 0; offset /= 2; if (inventory.appliedRecipe) offset -= .5f; - world.addParticle(particleData, pos.getX() + -vec.x * offset, pos.getY() + .45f, pos.getZ() + -vec.z * offset, + level.addParticle(particleData, pos.x() + -vec.x * offset, pos.y() + .45f, pos.z() + -vec.z * offset, -vec.x * speed, r.nextFloat() * speed, -vec.z * speed); } public Vector3d getItemMovementVec() { - boolean alongX = !getBlockState().get(SawBlock.AXIS_ALONG_FIRST_COORDINATE); + boolean alongX = !getBlockState().getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE); int offset = getSpeed() < 0 ? -1 : 1; return new Vector3d(offset * (alongX ? 1 : 0), 0, offset * (alongX ? 0 : -1)); } @@ -338,8 +338,8 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { List results = new LinkedList(); if (recipe instanceof CuttingRecipe) results = ((CuttingRecipe) recipe).rollResults(); - else if (recipe instanceof StonecuttingRecipe || recipe.getType() == woodcuttingRecipeType.getValue()) - results.add(recipe.getRecipeOutput() + else if (recipe instanceof StonecuttingRecipe || recipe.getType() == woodcuttingRecipeType.get()) + results.add(recipe.getResultItem() .copy()); for (int i = 0; i < results.size(); i++) { @@ -354,17 +354,17 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } private List> getRecipes() { - Optional assemblyRecipe = SequencedAssemblyRecipe.getRecipe(world, inventory.getStackInSlot(0), + Optional assemblyRecipe = SequencedAssemblyRecipe.getRecipe(level, inventory.getStackInSlot(0), AllRecipeTypes.CUTTING.getType(), CuttingRecipe.class); if (assemblyRecipe.isPresent() && filtering.test(assemblyRecipe.get() - .getRecipeOutput())) + .getResultItem())) return ImmutableList.of(assemblyRecipe.get()); Predicate> types = RecipeConditions.isOfType(AllRecipeTypes.CUTTING.getType(), AllConfigs.SERVER.recipes.allowStonecuttingOnSaw.get() ? IRecipeType.STONECUTTING : null, - AllConfigs.SERVER.recipes.allowWoodcuttingOnSaw.get() ? woodcuttingRecipeType.getValue() : null); + AllConfigs.SERVER.recipes.allowWoodcuttingOnSaw.get() ? woodcuttingRecipeType.get() : null); - List> startedSearch = RecipeFinder.get(cuttingRecipesKey, world, types); + List> startedSearch = RecipeFinder.get(cuttingRecipesKey, level, types); return startedSearch.stream() .filter(RecipeConditions.outputMatchesFilter(filtering)) .filter(RecipeConditions.firstIngredientMatches(inventory.getStackInSlot(0))) @@ -378,7 +378,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { return; if (!entity.isAlive()) return; - if (world.isRemote) + if (level.isClientSide) return; inventory.clear(); @@ -395,7 +395,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { return; if (inventory.isEmpty()) return; - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) return; List> recipes = getRecipes(); @@ -427,43 +427,43 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } protected boolean canProcess() { - return getBlockState().get(SawBlock.FACING) == Direction.UP; + return getBlockState().getValue(SawBlock.FACING) == Direction.UP; } // Block Breaker @Override protected boolean shouldRun() { - return getBlockState().get(SawBlock.FACING) + return getBlockState().getValue(SawBlock.FACING) .getAxis() .isHorizontal(); } @Override protected BlockPos getBreakingPos() { - return getPos().offset(getBlockState().get(SawBlock.FACING)); + return getBlockPos().relative(getBlockState().getValue(SawBlock.FACING)); } @Override public void onBlockBroken(BlockState stateToBreak) { Optional dynamicTree = TreeCutter.findDynamicTree(stateToBreak.getBlock(), breakingPos); if (dynamicTree.isPresent()) { - dynamicTree.get().destroyBlocks(world, null, this::dropItemFromCutTree); + dynamicTree.get().destroyBlocks(level, null, this::dropItemFromCutTree); return; } super.onBlockBroken(stateToBreak); - TreeCutter.findTree(world, breakingPos) - .destroyBlocks(world, null, this::dropItemFromCutTree); + TreeCutter.findTree(level, breakingPos) + .destroyBlocks(level, null, this::dropItemFromCutTree); } public void dropItemFromCutTree(BlockPos pos, ItemStack stack) { - float distance = (float) Math.sqrt(pos.distanceSq(breakingPos)); + float distance = (float) Math.sqrt(pos.distSqr(breakingPos)); Vector3d dropPos = VecHelper.getCenterOf(pos); - ItemEntity entity = new ItemEntity(world, dropPos.x, dropPos.y, dropPos.z, stack); - entity.setMotion(Vector3d.of(breakingPos.subtract(this.pos)) + ItemEntity entity = new ItemEntity(level, dropPos.x, dropPos.y, dropPos.z, stack); + entity.setDeltaMovement(Vector3d.atLowerCornerOf(breakingPos.subtract(this.worldPosition)) .scale(distance / 20f)); - world.addEntity(entity); + level.addFreshEntity(entity); } @Override @@ -473,8 +473,8 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } public static boolean isSawable(BlockState stateToBreak) { - if (stateToBreak.isIn(BlockTags.LOGS) || AllTags.AllBlockTags.SLIMY_LOGS.matches(stateToBreak) - || stateToBreak.isIn(BlockTags.LEAVES)) + if (stateToBreak.is(BlockTags.LOGS) || AllTags.AllBlockTags.SLIMY_LOGS.matches(stateToBreak) + || stateToBreak.is(BlockTags.LEAVES)) return true; Block block = stateToBreak.getBlock(); if (block instanceof BambooBlock) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java index d898d12c3..3c2dcc97a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java @@ -55,10 +55,12 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.PacketDistributor; +import net.minecraft.entity.Entity.IMoveCallback; + public abstract class AbstractContraptionEntity extends Entity implements IEntityAdditionalSpawnData { private static final DataParameter STALLED = - EntityDataManager.createKey(AbstractContraptionEntity.class, DataSerializers.BOOLEAN); + EntityDataManager.defineId(AbstractContraptionEntity.class, DataSerializers.BOOLEAN); public final Map collidingEntities; @@ -77,7 +79,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit this.contraption = contraption; if (contraption == null) return; - if (world.isRemote) + if (level.isClientSide) return; contraption.onEntityCreated(this); } @@ -87,7 +89,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } protected void contraptionInitialize() { - contraption.onEntityInitialize(world, this); + contraption.onEntityInitialize(level, this); initialized = true; } @@ -97,32 +99,32 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit public void addSittingPassenger(Entity passenger, int seatIndex) { passenger.startRiding(this, true); - if (world.isRemote) + if (level.isClientSide) return; contraption.getSeatMapping() - .put(passenger.getUniqueID(), seatIndex); + .put(passenger.getUUID(), seatIndex); AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> this), - new ContraptionSeatMappingPacket(getEntityId(), contraption.getSeatMapping())); + new ContraptionSeatMappingPacket(getId(), contraption.getSeatMapping())); } @Override protected void removePassenger(Entity passenger) { Vector3d transformedVector = getPassengerPosition(passenger, 1); super.removePassenger(passenger); - if (world.isRemote) + if (level.isClientSide) return; if (transformedVector != null) passenger.getPersistentData() .put("ContraptionDismountLocation", VecHelper.writeNBT(transformedVector)); contraption.getSeatMapping() - .remove(passenger.getUniqueID()); + .remove(passenger.getUUID()); AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> this), - new ContraptionSeatMappingPacket(getEntityId(), contraption.getSeatMapping())); + new ContraptionSeatMappingPacket(getId(), contraption.getSeatMapping())); } @Override - public void updatePassengerPosition(Entity passenger, IMoveCallback callback) { - if (!isPassenger(passenger)) + public void positionRider(Entity passenger, IMoveCallback callback) { + if (!hasPassenger(passenger)) return; Vector3d transformedVector = getPassengerPosition(passenger, 1); if (transformedVector == null) @@ -131,7 +133,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } protected Vector3d getPassengerPosition(Entity passenger, float partialTicks) { - UUID id = passenger.getUniqueID(); + UUID id = passenger.getUUID(); if (passenger instanceof OrientedContraptionEntity) { BlockPos localPos = contraption.getBearingPosOf(id); if (localPos != null) @@ -141,18 +143,18 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } AxisAlignedBB bb = passenger.getBoundingBox(); - double ySize = bb.getYSize(); + double ySize = bb.getYsize(); BlockPos seat = contraption.getSeatOf(id); if (seat == null) return null; - Vector3d transformedVector = toGlobalVector(Vector3d.of(seat) - .add(.5, passenger.getYOffset() + ySize - .15f, .5), partialTicks).add(VecHelper.getCenterOf(BlockPos.ZERO)) + Vector3d transformedVector = toGlobalVector(Vector3d.atLowerCornerOf(seat) + .add(.5, passenger.getMyRidingOffset() + ySize - .15f, .5), partialTicks).add(VecHelper.getCenterOf(BlockPos.ZERO)) .subtract(0.5, ySize, 0.5); return transformedVector; } @Override - protected boolean canFitPassenger(Entity p_184219_1_) { + protected boolean canAddPassenger(Entity p_184219_1_) { if (p_184219_1_ instanceof OrientedContraptionEntity) return true; return contraption.getSeatMapping() @@ -175,7 +177,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit continue; for (Entity entity : getPassengers()) { if (!entry.getKey() - .equals(entity.getUniqueID())) + .equals(entity.getUUID())) continue; if (entity instanceof PlayerEntity) return false; @@ -183,14 +185,14 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } } - if (toDismount != null && !world.isRemote) { + if (toDismount != null && !level.isClientSide) { Vector3d transformedVector = getPassengerPosition(toDismount, 1); toDismount.stopRiding(); if (transformedVector != null) - toDismount.setPositionAndUpdate(transformedVector.x, transformedVector.y, transformedVector.z); + toDismount.teleportTo(transformedVector.x, transformedVector.y, transformedVector.z); } - if (world.isRemote) + if (level.isClientSide) return true; addSittingPassenger(player, indexOfSeat); return true; @@ -228,14 +230,14 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit .incrementAndGet() > 3) iterator.remove(); - prevPosX = getX(); - prevPosY = getY(); - prevPosZ = getZ(); + xo = getX(); + yo = getY(); + zo = getZ(); prevPosInvalid = false; if (!initialized) contraptionInitialize(); - contraption.onEntityTick(world); + contraption.onEntityTick(level); tickContraption(); super.tick(); } @@ -249,7 +251,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit public void tickActors() { boolean stalledPreviously = contraption.stalled; - if (!world.isRemote) + if (!level.isClientSide) contraption.stalled = false; ticking = true; @@ -286,7 +288,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit contraption.stalled |= context.stall; } if (!isAlive()) { - contraption.stop(world); + contraption.stop(level); return; } ticking = false; @@ -294,7 +296,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit for (Entity entity : getPassengers()) { if (!(entity instanceof OrientedContraptionEntity)) continue; - if (!contraption.stabilizedSubContraptions.containsKey(entity.getUniqueID())) + if (!contraption.stabilizedSubContraptions.containsKey(entity.getUUID())) continue; OrientedContraptionEntity orientedCE = (OrientedContraptionEntity) entity; if (orientedCE.contraption != null && orientedCE.contraption.stalled) { @@ -303,10 +305,10 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } } - if (!world.isRemote) { + if (!level.isClientSide) { if (!stalledPreviously && contraption.stalled) onContraptionStalled(); - dataManager.set(STALLED, contraption.stalled); + entityData.set(STALLED, contraption.stalled); return; } @@ -315,7 +317,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit protected void onContraptionStalled() { AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> this), - new ContraptionStallPacket(getEntityId(), getX(), getY(), getZ(), getStalledAngle())); + new ContraptionStallPacket(getId(), getX(), getY(), getZ(), getStalledAngle())); } protected boolean shouldActorTrigger(MovementContext context, BlockInfo blockInfo, MovementBehaviour actor, @@ -333,11 +335,11 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } public void move(double x, double y, double z) { - setPosition(getX() + x, getY() + y, getZ() + z); + setPos(getX() + x, getY() + y, getZ() + z); } public Vector3d getAnchorVec() { - return getPositionVec(); + return position(); } public float getYawOffset() { @@ -345,15 +347,15 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } @Override - public void setPosition(double x, double y, double z) { - super.setPosition(x, y, z); + public void setPos(double x, double y, double z) { + super.setPos(x, y, z); if (contraption == null) return; AxisAlignedBB cbox = contraption.bounds; if (cbox == null) return; Vector3d actualVec = getAnchorVec(); - setBoundingBox(cbox.offset(actualVec)); + setBoundingBox(cbox.move(actualVec)); } public static float yawFromVector(Vector3d vec) { @@ -368,16 +370,16 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit @SuppressWarnings("unchecked") EntityType.Builder entityBuilder = (EntityType.Builder) builder; - return entityBuilder.size(1, 1); + return entityBuilder.sized(1, 1); } @Override - protected void registerData() { - this.dataManager.register(STALLED, false); + protected void defineSynchedData() { + this.entityData.define(STALLED, false); } @Override - public IPacket createSpawnPacket() { + public IPacket getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @@ -393,22 +395,22 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit int estimatedPacketSize = byteArray.length; if (estimatedPacketSize > 2_000_000) { Create.LOGGER.warn("Could not send Contraption Spawn Data (Packet too big): " - + getContraption().getType().id + " @" + getPositionVec() + " (" + getUniqueID().toString() + ")"); - buffer.writeCompoundTag(new CompoundNBT()); + + getContraption().getType().id + " @" + position() + " (" + getUUID().toString() + ")"); + buffer.writeNbt(new CompoundNBT()); return; } } catch (IOException e) { e.printStackTrace(); - buffer.writeCompoundTag(new CompoundNBT()); + buffer.writeNbt(new CompoundNBT()); return; } - buffer.writeCompoundTag(compound); + buffer.writeNbt(compound); } @Override - protected final void writeAdditional(CompoundNBT compound) { + protected final void addAdditionalSaveData(CompoundNBT compound) { writeAdditional(compound, false); } @@ -421,11 +423,11 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit @Override public void readSpawnData(PacketBuffer additionalData) { - readAdditional(additionalData.readCompoundTag(), true); + readAdditional(additionalData.readNbt(), true); } @Override - protected final void readAdditional(CompoundNBT compound) { + protected final void readAdditionalSaveData(CompoundNBT compound) { readAdditional(compound, false); } @@ -434,9 +436,9 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit return; initialized = compound.getBoolean("Initialized"); - contraption = Contraption.fromNBT(world, compound.getCompound("Contraption"), spawnData); + contraption = Contraption.fromNBT(level, compound.getCompound("Contraption"), spawnData); contraption.entity = this; - dataManager.set(STALLED, compound.getBoolean("Stalled")); + entityData.set(STALLED, compound.getBoolean("Stalled")); } public void disassemble() { @@ -449,45 +451,45 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit StructureTransform transform = makeStructureTransform(); AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> this), - new ContraptionDisassemblyPacket(this.getEntityId(), transform)); + new ContraptionDisassemblyPacket(this.getId(), transform)); - contraption.addBlocksToWorld(world, transform); - contraption.addPassengersToWorld(world, transform, getPassengers()); + contraption.addBlocksToWorld(level, transform); + contraption.addPassengersToWorld(level, transform, getPassengers()); for (Entity entity : getPassengers()) { if (!(entity instanceof OrientedContraptionEntity)) continue; - UUID id = entity.getUniqueID(); + UUID id = entity.getUUID(); if (!contraption.stabilizedSubContraptions.containsKey(id)) continue; BlockPos transformed = transform.apply(contraption.stabilizedSubContraptions.get(id) .getConnectedPos()); - entity.setPosition(transformed.getX(), transformed.getY(), transformed.getZ()); + entity.setPos(transformed.getX(), transformed.getY(), transformed.getZ()); ((AbstractContraptionEntity) entity).disassemble(); } - removePassengers(); + ejectPassengers(); moveCollidedEntitiesOnDisassembly(transform); - AllSoundEvents.CONTRAPTION_DISASSEMBLE.playOnServer(world, getBlockPos()); + AllSoundEvents.CONTRAPTION_DISASSEMBLE.playOnServer(level, blockPosition()); } private void moveCollidedEntitiesOnDisassembly(StructureTransform transform) { for (Entity entity : collidingEntities.keySet()) { - Vector3d localVec = toLocalVector(entity.getPositionVec(), 0); + Vector3d localVec = toLocalVector(entity.position(), 0); Vector3d transformed = transform.apply(localVec); - if (world.isRemote) - entity.setPosition(transformed.x, transformed.y + 1 / 16f, transformed.z); + if (level.isClientSide) + entity.setPos(transformed.x, transformed.y + 1 / 16f, transformed.z); else - entity.setPositionAndUpdate(transformed.x, transformed.y + 1 / 16f, transformed.z); + entity.teleportTo(transformed.x, transformed.y + 1 / 16f, transformed.z); } } @SuppressWarnings("deprecation") @Override public void remove(boolean keepData) { - if (!world.isRemote && !removed && contraption != null) { + if (!level.isClientSide && !removed && contraption != null) { if (!ticking) - contraption.stop(world); + contraption.stop(level); } if (contraption != null) contraption.onEntityRemoved(this); @@ -497,21 +499,21 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit protected abstract StructureTransform makeStructureTransform(); @Override - public void onKillCommand() { - removePassengers(); - super.onKillCommand(); + public void kill() { + ejectPassengers(); + super.kill(); } @Override protected void outOfWorld() { - removePassengers(); + ejectPassengers(); super.outOfWorld(); } @Override public void onRemovedFromWorld() { super.onRemovedFromWorld(); - if (world != null && world.isRemote) + if (level != null && level.isClientSide) return; getPassengers().forEach(Entity::remove); } @@ -524,12 +526,12 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } public boolean isStalled() { - return dataManager.get(STALLED); + return entityData.get(STALLED); } @OnlyIn(Dist.CLIENT) static void handleStallPacket(ContraptionStallPacket packet) { - Entity entity = Minecraft.getInstance().world.getEntityByID(packet.entityID); + Entity entity = Minecraft.getInstance().level.getEntity(packet.entityID); if (!(entity instanceof AbstractContraptionEntity)) return; AbstractContraptionEntity ce = (AbstractContraptionEntity) entity; @@ -538,7 +540,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit @OnlyIn(Dist.CLIENT) static void handleDisassemblyPacket(ContraptionDisassemblyPacket packet) { - Entity entity = Minecraft.getInstance().world.getEntityByID(packet.entityID); + Entity entity = Minecraft.getInstance().level.getEntity(packet.entityID); if (!(entity instanceof AbstractContraptionEntity)) return; AbstractContraptionEntity ce = (AbstractContraptionEntity) entity; @@ -551,8 +553,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit @Override @SuppressWarnings("deprecation") - public CompoundNBT writeWithoutTypeId(CompoundNBT nbt) { - Vector3d vec = getPositionVec(); + public CompoundNBT saveWithoutId(CompoundNBT nbt) { + Vector3d vec = position(); List passengers = getPassengers(); for (Entity entity : passengers) { @@ -560,43 +562,43 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit entity.removed = true; // Gather passengers into same chunk when saving - Vector3d prevVec = entity.getPositionVec(); - entity.setPos(vec.x, prevVec.y, vec.z); + Vector3d prevVec = entity.position(); + entity.setPosRaw(vec.x, prevVec.y, vec.z); // Super requires all passengers to not be removed in order to write them to the // tag entity.removed = false; } - CompoundNBT tag = super.writeWithoutTypeId(nbt); + CompoundNBT tag = super.saveWithoutId(nbt); return tag; } @Override // Make sure nothing can move contraptions out of the way - public void setMotion(Vector3d motionIn) {} + public void setDeltaMovement(Vector3d motionIn) {} @Override - public PushReaction getPushReaction() { + public PushReaction getPistonPushReaction() { return PushReaction.IGNORE; } public void setContraptionMotion(Vector3d vec) { - super.setMotion(vec); + super.setDeltaMovement(vec); } @Override - public boolean canBeCollidedWith() { + public boolean isPickable() { return false; } @Override - public boolean attackEntityFrom(DamageSource source, float amount) { + public boolean hurt(DamageSource source, float amount) { return false; } public Vector3d getPrevPositionVec() { - return prevPosInvalid ? getPositionVec() : new Vector3d(prevPosX, prevPosY, prevPosZ); + return prevPosInvalid ? position() : new Vector3d(xo, yo, zo); } public abstract ContraptionRotationState getRotationState(); @@ -606,13 +608,13 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit return Vector3d.ZERO; Vector3d contactPoint = toGlobalVector(toLocalVector(globalContactPoint, 0), 1); return contactPoint.subtract(globalContactPoint) - .add(getPositionVec().subtract(getPrevPositionVec())); + .add(position().subtract(getPrevPositionVec())); } public boolean canCollideWith(Entity e) { if (e instanceof PlayerEntity && e.isSpectator()) return false; - if (e.noClip) + if (e.noPhysics) return false; if (e instanceof HangingEntity) return false; @@ -624,21 +626,21 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit return false; if (e instanceof ProjectileEntity) return false; - if (e.getRidingEntity() != null) + if (e.getVehicle() != null) return false; - Entity riding = this.getRidingEntity(); + Entity riding = this.getVehicle(); while (riding != null) { if (riding == e) return false; - riding = riding.getRidingEntity(); + riding = riding.getVehicle(); } - return e.getPushReaction() == PushReaction.NORMAL; + return e.getPistonPushReaction() == PushReaction.NORMAL; } @Override - public boolean isOnePlayerRiding() { + public boolean hasOnePlayerPassenger() { return false; } @@ -680,7 +682,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit @Override - protected boolean updateWaterState() { + protected boolean updateInWaterStateAndDoFluidPushing() { /* * Override this with an empty method to reduce enormous calculation time when contraptions are in water * WARNING: THIS HAS A BUNCH OF SIDE EFFECTS! @@ -695,7 +697,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } @Override - public void setFire(int p_70015_1_) { + public void setSecondsOnFire(int p_70015_1_) { // Contraptions no longer catch fire } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AssemblyException.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AssemblyException.java index 51eb14340..0f1972ad4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AssemblyException.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AssemblyException.java @@ -22,7 +22,7 @@ public class AssemblyException extends Exception { nbt.putString("Component", ITextComponent.Serializer.toJson(exception.component)); if (exception.hasPosition()) nbt.putLong("Position", exception.getPosition() - .toLong()); + .asLong()); compound.put("LastException", nbt); } @@ -35,7 +35,7 @@ public class AssemblyException extends Exception { String string = nbt.getString("Component"); AssemblyException exception = new AssemblyException(ITextComponent.Serializer.fromJson(string)); if (nbt.contains("Position")) - exception.position = BlockPos.fromLong(nbt.getLong("Position")); + exception.position = BlockPos.of(nbt.getLong("Position")); return exception; } @@ -51,7 +51,7 @@ public class AssemblyException extends Exception { public static AssemblyException unmovableBlock(BlockPos pos, BlockState state) { AssemblyException e = new AssemblyException("unmovableBlock", pos.getX(), pos.getY(), pos.getZ(), new TranslationTextComponent(state.getBlock() - .getTranslationKey())); + .getDescriptionId())); e.position = pos; return e; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java index f2d12f89d..c1b5b796b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java @@ -191,7 +191,7 @@ public class BlockMovementChecks { Block block = state.getBlock(); if (block instanceof AbstractChassisBlock) return true; - if (state.getBlockHardness(world, pos) == -1) + if (state.getDestroySpeed(world, pos) == -1) return false; if (state.getBlock().getTags().contains(NON_MOVABLE)) return false; @@ -200,25 +200,25 @@ public class BlockMovementChecks { return false; // Move controllers only when they aren't moving - if (block instanceof MechanicalPistonBlock && state.get(MechanicalPistonBlock.STATE) != PistonState.MOVING) + if (block instanceof MechanicalPistonBlock && state.getValue(MechanicalPistonBlock.STATE) != PistonState.MOVING) return true; if (block instanceof MechanicalBearingBlock) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (te instanceof MechanicalBearingTileEntity) return !((MechanicalBearingTileEntity) te).isRunning(); } if (block instanceof WindmillBearingBlock) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (te instanceof WindmillBearingTileEntity) return !((WindmillBearingTileEntity) te).isRunning(); } if (block instanceof ClockworkBearingBlock) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (te instanceof ClockworkBearingTileEntity) return !((ClockworkBearingTileEntity) te).isRunning(); } if (block instanceof PulleyBlock) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (te instanceof PulleyTileEntity) return !((PulleyTileEntity) te).running; } @@ -227,12 +227,12 @@ public class BlockMovementChecks { return true; if (state.getBlock() instanceof GrindstoneBlock) return true; - return state.getPushReaction() != PushReaction.BLOCK; + return state.getPistonPushReaction() != PushReaction.BLOCK; } private static boolean isBrittleFallback(BlockState state) { Block block = state.getBlock(); - if (state.contains(BlockStateProperties.HANGING)) + if (state.hasProperty(BlockStateProperties.HANGING)) return true; if (block instanceof LadderBlock) @@ -262,28 +262,28 @@ public class BlockMovementChecks { Direction direction) { Block block = state.getBlock(); if (block instanceof LadderBlock) - return state.get(LadderBlock.FACING) == direction.getOpposite(); + return state.getValue(LadderBlock.FACING) == direction.getOpposite(); if (block instanceof WallTorchBlock) - return state.get(WallTorchBlock.HORIZONTAL_FACING) == direction.getOpposite(); + return state.getValue(WallTorchBlock.FACING) == direction.getOpposite(); if (block instanceof WallSignBlock) - return state.get(WallSignBlock.FACING) == direction.getOpposite(); + return state.getValue(WallSignBlock.FACING) == direction.getOpposite(); if (block instanceof StandingSignBlock) return direction == Direction.DOWN; if (block instanceof AbstractPressurePlateBlock) return direction == Direction.DOWN; if (block instanceof DoorBlock) { - if (state.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER && direction == Direction.UP) + if (state.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER && direction == Direction.UP) return true; return direction == Direction.DOWN; } if (block instanceof BedBlock) { - Direction facing = state.get(BedBlock.HORIZONTAL_FACING); - if (state.get(BedBlock.PART) == BedPart.HEAD) + Direction facing = state.getValue(BedBlock.FACING); + if (state.getValue(BedBlock.PART) == BedPart.HEAD) facing = facing.getOpposite(); return direction == facing; } if (block instanceof RedstoneLinkBlock) - return direction.getOpposite() == state.get(RedstoneLinkBlock.FACING); + return direction.getOpposite() == state.getValue(RedstoneLinkBlock.FACING); if (block instanceof FlowerPotBlock) return direction == Direction.DOWN; if (block instanceof RedstoneDiodeBlock) @@ -293,82 +293,82 @@ public class BlockMovementChecks { if (block instanceof CarpetBlock) return direction == Direction.DOWN; if (block instanceof RedstoneWallTorchBlock) - return state.get(RedstoneWallTorchBlock.FACING) == direction.getOpposite(); + return state.getValue(RedstoneWallTorchBlock.FACING) == direction.getOpposite(); if (block instanceof TorchBlock) return direction == Direction.DOWN; if (block instanceof HorizontalFaceBlock) { - AttachFace attachFace = state.get(HorizontalFaceBlock.FACE); + AttachFace attachFace = state.getValue(HorizontalFaceBlock.FACE); if (attachFace == AttachFace.CEILING) return direction == Direction.UP; if (attachFace == AttachFace.FLOOR) return direction == Direction.DOWN; if (attachFace == AttachFace.WALL) - return direction.getOpposite() == state.get(HorizontalFaceBlock.HORIZONTAL_FACING); + return direction.getOpposite() == state.getValue(HorizontalFaceBlock.FACING); } - if (state.contains(BlockStateProperties.HANGING)) - return direction == (state.get(BlockStateProperties.HANGING) ? Direction.UP : Direction.DOWN); + if (state.hasProperty(BlockStateProperties.HANGING)) + return direction == (state.getValue(BlockStateProperties.HANGING) ? Direction.UP : Direction.DOWN); if (block instanceof AbstractRailBlock) return direction == Direction.DOWN; if (block instanceof AttachedActorBlock) - return direction == state.get(HarvesterBlock.HORIZONTAL_FACING) + return direction == state.getValue(HarvesterBlock.FACING) .getOpposite(); if (block instanceof HandCrankBlock) - return direction == state.get(HandCrankBlock.FACING) + return direction == state.getValue(HandCrankBlock.FACING) .getOpposite(); if (block instanceof NozzleBlock) - return direction == state.get(NozzleBlock.FACING) + return direction == state.getValue(NozzleBlock.FACING) .getOpposite(); if (block instanceof EngineBlock) - return direction == state.get(EngineBlock.HORIZONTAL_FACING) + return direction == state.getValue(EngineBlock.FACING) .getOpposite(); if (block instanceof BellBlock) { - BellAttachment attachment = state.get(BlockStateProperties.BELL_ATTACHMENT); + BellAttachment attachment = state.getValue(BlockStateProperties.BELL_ATTACHMENT); if (attachment == BellAttachment.FLOOR) return direction == Direction.DOWN; if (attachment == BellAttachment.CEILING) return direction == Direction.UP; - return direction == state.get(HorizontalBlock.HORIZONTAL_FACING); + return direction == state.getValue(HorizontalBlock.FACING); } if (state.getBlock() instanceof SailBlock) - return direction.getAxis() != state.get(SailBlock.FACING) + return direction.getAxis() != state.getValue(SailBlock.FACING) .getAxis(); if (state.getBlock() instanceof FluidTankBlock) - return FluidTankConnectivityHandler.isConnected(world, pos, pos.offset(direction)); - if (AllBlocks.STICKER.has(state) && state.get(StickerBlock.EXTENDED)) { - return direction == state.get(StickerBlock.FACING) - && !isNotSupportive(world.getBlockState(pos.offset(direction)), direction.getOpposite()); + return FluidTankConnectivityHandler.isConnected(world, pos, pos.relative(direction)); + if (AllBlocks.STICKER.has(state) && state.getValue(StickerBlock.EXTENDED)) { + return direction == state.getValue(StickerBlock.FACING) + && !isNotSupportive(world.getBlockState(pos.relative(direction)), direction.getOpposite()); } return false; } private static boolean isNotSupportiveFallback(BlockState state, Direction facing) { if (AllBlocks.MECHANICAL_DRILL.has(state)) - return state.get(BlockStateProperties.FACING) == facing; + return state.getValue(BlockStateProperties.FACING) == facing; if (AllBlocks.MECHANICAL_BEARING.has(state)) - return state.get(BlockStateProperties.FACING) == facing; + return state.getValue(BlockStateProperties.FACING) == facing; if (AllBlocks.CART_ASSEMBLER.has(state)) return Direction.DOWN == facing; if (AllBlocks.MECHANICAL_SAW.has(state)) - return state.get(BlockStateProperties.FACING) == facing; + return state.getValue(BlockStateProperties.FACING) == facing; if (AllBlocks.PORTABLE_STORAGE_INTERFACE.has(state)) - return state.get(PortableStorageInterfaceBlock.FACING) == facing; + return state.getValue(PortableStorageInterfaceBlock.FACING) == facing; if (state.getBlock() instanceof AttachedActorBlock) - return state.get(BlockStateProperties.HORIZONTAL_FACING) == facing; + return state.getValue(BlockStateProperties.HORIZONTAL_FACING) == facing; if (AllBlocks.ROPE_PULLEY.has(state)) return facing == Direction.DOWN; if (state.getBlock() instanceof CarpetBlock) return facing == Direction.UP; if (state.getBlock() instanceof SailBlock) - return facing.getAxis() == state.get(SailBlock.FACING) + return facing.getAxis() == state.getValue(SailBlock.FACING) .getAxis(); if (AllBlocks.PISTON_EXTENSION_POLE.has(state)) - return facing.getAxis() != state.get(BlockStateProperties.FACING) + return facing.getAxis() != state.getValue(BlockStateProperties.FACING) .getAxis(); if (AllBlocks.MECHANICAL_PISTON_HEAD.has(state)) - return facing.getAxis() != state.get(BlockStateProperties.FACING) + return facing.getAxis() != state.getValue(BlockStateProperties.FACING) .getAxis(); - if (AllBlocks.STICKER.has(state) && !state.get(StickerBlock.EXTENDED)) - return facing == state.get(StickerBlock.FACING); + if (AllBlocks.STICKER.has(state) && !state.getValue(StickerBlock.EXTENDED)) + return facing == state.getValue(StickerBlock.FACING); return isBrittle(state); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index 0454b058c..e36065d43 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -170,7 +170,7 @@ public abstract class Contraption { public ContraptionWorld getContraptionWorld() { if (world == null) - world = new ContraptionWorld(entity.world, this); + world = new ContraptionWorld(entity.level, this); return world; } @@ -232,7 +232,7 @@ public abstract class Contraption { for (BlockFace blockFace : pendingSubContraptions) { Direction face = blockFace.getFace(); StabilizedContraption subContraption = new StabilizedContraption(face); - World world = entity.world; + World world = entity.level; BlockPos pos = blockFace.getPos(); try { if (!subContraption.assemble(world, pos)) @@ -243,9 +243,9 @@ public abstract class Contraption { subContraption.removeBlocksFromWorld(world, BlockPos.ZERO); OrientedContraptionEntity movedContraption = OrientedContraptionEntity.create(world, subContraption, face); BlockPos anchor = blockFace.getConnectedPos(); - movedContraption.setPosition(anchor.getX() + .5f, anchor.getY(), anchor.getZ() + .5f); - world.addEntity(movedContraption); - stabilizedSubContraptions.put(movedContraption.getUniqueID(), new BlockFace(toLocalPos(pos), face)); + movedContraption.setPos(anchor.getX() + .5f, anchor.getY(), anchor.getZ() + .5f); + world.addFreshEntity(movedContraption); + stabilizedSubContraptions.put(movedContraption.getUUID(), new BlockFace(toLocalPos(pos), face)); } // Gather itemhandlers of mounted storage @@ -272,13 +272,13 @@ public abstract class Contraption { } public void onEntityInitialize(World world, AbstractContraptionEntity contraptionEntity) { - if (world.isRemote) + if (world.isClientSide) return; - for (OrientedContraptionEntity orientedCE : world.getEntitiesWithinAABB(OrientedContraptionEntity.class, + for (OrientedContraptionEntity orientedCE : world.getEntitiesOfClass(OrientedContraptionEntity.class, contraptionEntity.getBoundingBox() - .grow(1))) - if (stabilizedSubContraptions.containsKey(orientedCE.getUniqueID())) + .inflate(1))) + if (stabilizedSubContraptions.containsKey(orientedCE.getUUID())) orientedCE.startRiding(contraptionEntity); for (BlockPos seatPos : getSeats()) { @@ -293,7 +293,7 @@ public abstract class Contraption { } public void onEntityTick(World world) { - fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, world.isRemote)); + fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, world.isClientSide)); } /** move the first block in frontier queue */ @@ -306,7 +306,7 @@ public abstract class Contraption { if (World.isOutsideBuildHeight(pos)) return true; - if (!world.isBlockPresent(pos)) + if (!world.isLoaded(pos)) throw AssemblyException.unloadedChunk(pos); if (isAnchoringBlockAt(pos)) return true; @@ -331,9 +331,9 @@ public abstract class Contraption { if (AllBlocks.GANTRY_SHAFT.has(state)) moveGantryShaft(world, pos, frontier, visited, state); - if (AllBlocks.STICKER.has(state) && state.get(StickerBlock.EXTENDED)) { - Direction offset = state.get(StickerBlock.FACING); - BlockPos attached = pos.offset(offset); + if (AllBlocks.STICKER.has(state) && state.getValue(StickerBlock.EXTENDED)) { + Direction offset = state.getValue(StickerBlock.FACING); + BlockPos attached = pos.relative(offset); if (!visited.contains(attached) && !BlockMovementChecks.isNotSupportive(world.getBlockState(attached), offset.getOpposite())) frontier.add(attached); @@ -365,7 +365,7 @@ public abstract class Contraption { movePistonHead(world, pos, frontier, visited, state); // Cart assemblers attach themselves - BlockPos posDown = pos.down(); + BlockPos posDown = pos.below(); BlockState stateBelow = world.getBlockState(posDown); if (!visited.contains(posDown) && AllBlocks.CART_ASSEMBLER.has(stateBelow)) frontier.add(posDown); @@ -374,7 +374,7 @@ public abstract class Contraption { // Slime blocks and super glue drag adjacent blocks if possible for (Direction offset : Iterate.directions) { - BlockPos offsetPos = pos.offset(offset); + BlockPos offsetPos = pos.relative(offset); BlockState blockState = world.getBlockState(offsetPos); if (isAnchoringBlockAt(offsetPos)) continue; @@ -391,8 +391,8 @@ public abstract class Contraption { boolean brittle = BlockMovementChecks.isBrittle(blockState); boolean canStick = !brittle && state.canStickTo(blockState) && blockState.canStickTo(state); if (canStick) { - if (state.getPushReaction() == PushReaction.PUSH_ONLY - || blockState.getPushReaction() == PushReaction.PUSH_ONLY) { + if (state.getPistonPushReaction() == PushReaction.PUSH_ONLY + || blockState.getPistonPushReaction() == PushReaction.PUSH_ONLY) { canStick = false; } if (BlockMovementChecks.isNotSupportive(state, offset)) { @@ -419,21 +419,21 @@ public abstract class Contraption { protected void movePistonHead(World world, BlockPos pos, Queue frontier, Set visited, BlockState state) { - Direction direction = state.get(MechanicalPistonHeadBlock.FACING); - BlockPos offset = pos.offset(direction.getOpposite()); + Direction direction = state.getValue(MechanicalPistonHeadBlock.FACING); + BlockPos offset = pos.relative(direction.getOpposite()); if (!visited.contains(offset)) { BlockState blockState = world.getBlockState(offset); - if (isExtensionPole(blockState) && blockState.get(PistonExtensionPoleBlock.FACING) + if (isExtensionPole(blockState) && blockState.getValue(PistonExtensionPoleBlock.FACING) .getAxis() == direction.getAxis()) frontier.add(offset); if (blockState.getBlock() instanceof MechanicalPistonBlock) { - Direction pistonFacing = blockState.get(MechanicalPistonBlock.FACING); - if (pistonFacing == direction && blockState.get(MechanicalPistonBlock.STATE) == PistonState.EXTENDED) + Direction pistonFacing = blockState.getValue(MechanicalPistonBlock.FACING); + if (pistonFacing == direction && blockState.getValue(MechanicalPistonBlock.STATE) == PistonState.EXTENDED) frontier.add(offset); } } - if (state.get(MechanicalPistonHeadBlock.TYPE) == PistonType.STICKY) { - BlockPos attached = pos.offset(direction); + if (state.getValue(MechanicalPistonHeadBlock.TYPE) == PistonType.STICKY) { + BlockPos attached = pos.relative(direction); if (!visited.contains(attached)) frontier.add(attached); } @@ -441,21 +441,21 @@ public abstract class Contraption { protected void movePistonPole(World world, BlockPos pos, Queue frontier, Set visited, BlockState state) { - for (Direction d : Iterate.directionsInAxis(state.get(PistonExtensionPoleBlock.FACING) + for (Direction d : Iterate.directionsInAxis(state.getValue(PistonExtensionPoleBlock.FACING) .getAxis())) { - BlockPos offset = pos.offset(d); + BlockPos offset = pos.relative(d); if (!visited.contains(offset)) { BlockState blockState = world.getBlockState(offset); - if (isExtensionPole(blockState) && blockState.get(PistonExtensionPoleBlock.FACING) + if (isExtensionPole(blockState) && blockState.getValue(PistonExtensionPoleBlock.FACING) .getAxis() == d.getAxis()) frontier.add(offset); - if (isPistonHead(blockState) && blockState.get(MechanicalPistonHeadBlock.FACING) + if (isPistonHead(blockState) && blockState.getValue(MechanicalPistonHeadBlock.FACING) .getAxis() == d.getAxis()) frontier.add(offset); if (blockState.getBlock() instanceof MechanicalPistonBlock) { - Direction pistonFacing = blockState.get(MechanicalPistonBlock.FACING); + Direction pistonFacing = blockState.getValue(MechanicalPistonBlock.FACING); if (pistonFacing == d || pistonFacing == d.getOpposite() - && blockState.get(MechanicalPistonBlock.STATE) == PistonState.EXTENDED) + && blockState.getValue(MechanicalPistonBlock.STATE) == PistonState.EXTENDED) frontier.add(offset); } } @@ -464,14 +464,14 @@ public abstract class Contraption { protected void moveGantryPinion(World world, BlockPos pos, Queue frontier, Set visited, BlockState state) { - BlockPos offset = pos.offset(state.get(GantryCarriageBlock.FACING)); + BlockPos offset = pos.relative(state.getValue(GantryCarriageBlock.FACING)); if (!visited.contains(offset)) frontier.add(offset); Axis rotationAxis = ((IRotate) state.getBlock()).getRotationAxis(state); for (Direction d : Iterate.directionsInAxis(rotationAxis)) { - offset = pos.offset(d); + offset = pos.relative(d); BlockState offsetState = world.getBlockState(offset); - if (AllBlocks.GANTRY_SHAFT.has(offsetState) && offsetState.get(GantryShaftBlock.FACING) + if (AllBlocks.GANTRY_SHAFT.has(offsetState) && offsetState.getValue(GantryShaftBlock.FACING) .getAxis() == d.getAxis()) if (!visited.contains(offset)) frontier.add(offset); @@ -481,30 +481,30 @@ public abstract class Contraption { protected void moveGantryShaft(World world, BlockPos pos, Queue frontier, Set visited, BlockState state) { for (Direction d : Iterate.directions) { - BlockPos offset = pos.offset(d); + BlockPos offset = pos.relative(d); if (!visited.contains(offset)) { BlockState offsetState = world.getBlockState(offset); - Direction facing = state.get(GantryShaftBlock.FACING); + Direction facing = state.getValue(GantryShaftBlock.FACING); if (d.getAxis() == facing.getAxis() && AllBlocks.GANTRY_SHAFT.has(offsetState) - && offsetState.get(GantryShaftBlock.FACING) == facing) + && offsetState.getValue(GantryShaftBlock.FACING) == facing) frontier.add(offset); - else if (AllBlocks.GANTRY_CARRIAGE.has(offsetState) && offsetState.get(GantryCarriageBlock.FACING) == d) + else if (AllBlocks.GANTRY_CARRIAGE.has(offsetState) && offsetState.getValue(GantryCarriageBlock.FACING) == d) frontier.add(offset); } } } private void moveWindmillBearing(BlockPos pos, Queue frontier, Set visited, BlockState state) { - Direction facing = state.get(WindmillBearingBlock.FACING); - BlockPos offset = pos.offset(facing); + Direction facing = state.getValue(WindmillBearingBlock.FACING); + BlockPos offset = pos.relative(facing); if (!visited.contains(offset)) frontier.add(offset); } private void moveBearing(BlockPos pos, Queue frontier, Set visited, BlockState state) { - Direction facing = state.get(MechanicalBearingBlock.FACING); + Direction facing = state.getValue(MechanicalBearingBlock.FACING); if (!canBeStabilized(facing, pos.subtract(anchor))) { - BlockPos offset = pos.offset(facing); + BlockPos offset = pos.relative(facing); if (!visited.contains(offset)) frontier.add(offset); return; @@ -524,7 +524,7 @@ public abstract class Contraption { private void moveSeat(World world, BlockPos pos) { BlockPos local = toLocalPos(pos); getSeats().add(local); - List seatsEntities = world.getEntitiesWithinAABB(SeatEntity.class, new AxisAlignedBB(pos)); + List seatsEntities = world.getEntitiesOfClass(SeatEntity.class, new AxisAlignedBB(pos)); if (!seatsEntities.isEmpty()) { SeatEntity seat = seatsEntities.get(0); List passengers = seat.getPassengers(); @@ -537,8 +537,8 @@ public abstract class Contraption { int limit = AllConfigs.SERVER.kinetics.maxRopeLength.get(); BlockPos ropePos = pos; while (limit-- >= 0) { - ropePos = ropePos.down(); - if (!world.isBlockPresent(ropePos)) + ropePos = ropePos.below(); + if (!world.isLoaded(ropePos)) break; BlockState ropeState = world.getBlockState(ropePos); Block block = ropeState.getBlock(); @@ -553,21 +553,21 @@ public abstract class Contraption { private boolean moveMechanicalPiston(World world, BlockPos pos, Queue frontier, Set visited, BlockState state) throws AssemblyException { - Direction direction = state.get(MechanicalPistonBlock.FACING); - PistonState pistonState = state.get(MechanicalPistonBlock.STATE); + Direction direction = state.getValue(MechanicalPistonBlock.FACING); + PistonState pistonState = state.getValue(MechanicalPistonBlock.STATE); if (pistonState == PistonState.MOVING) return false; - BlockPos offset = pos.offset(direction.getOpposite()); + BlockPos offset = pos.relative(direction.getOpposite()); if (!visited.contains(offset)) { BlockState poleState = world.getBlockState(offset); - if (AllBlocks.PISTON_EXTENSION_POLE.has(poleState) && poleState.get(PistonExtensionPoleBlock.FACING) + if (AllBlocks.PISTON_EXTENSION_POLE.has(poleState) && poleState.getValue(PistonExtensionPoleBlock.FACING) .getAxis() == direction.getAxis()) frontier.add(offset); } if (pistonState == PistonState.EXTENDED || MechanicalPistonBlock.isStickyPiston(state)) { - offset = pos.offset(direction); + offset = pos.relative(direction); if (!visited.contains(offset)) frontier.add(offset); } @@ -577,7 +577,7 @@ public abstract class Contraption { private boolean moveChassis(World world, BlockPos pos, Direction movementDirection, Queue frontier, Set visited) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (!(te instanceof ChassisTileEntity)) return false; ChassisTileEntity chassis = (ChassisTileEntity) te; @@ -594,23 +594,23 @@ public abstract class Contraption { protected Pair capture(World world, BlockPos pos) { BlockState blockstate = world.getBlockState(pos); if (blockstate.getBlock() instanceof ChestBlock) - blockstate = blockstate.with(ChestBlock.TYPE, ChestType.SINGLE); + blockstate = blockstate.setValue(ChestBlock.TYPE, ChestType.SINGLE); if (AllBlocks.ADJUSTABLE_CRATE.has(blockstate)) - blockstate = blockstate.with(AdjustableCrateBlock.DOUBLE, false); + blockstate = blockstate.setValue(AdjustableCrateBlock.DOUBLE, false); if (AllBlocks.REDSTONE_CONTACT.has(blockstate)) - blockstate = blockstate.with(RedstoneContactBlock.POWERED, true); + blockstate = blockstate.setValue(RedstoneContactBlock.POWERED, true); if (blockstate.getBlock() instanceof AbstractButtonBlock) { - blockstate = blockstate.with(AbstractButtonBlock.POWERED, false); - world.getPendingBlockTicks() + blockstate = blockstate.setValue(AbstractButtonBlock.POWERED, false); + world.getBlockTicks() .scheduleTick(pos, blockstate.getBlock(), -1); } if (blockstate.getBlock() instanceof PressurePlateBlock) { - blockstate = blockstate.with(PressurePlateBlock.POWERED, false); - world.getPendingBlockTicks() + blockstate = blockstate.setValue(PressurePlateBlock.POWERED, false); + world.getBlockTicks() .scheduleTick(pos, blockstate.getBlock(), -1); } CompoundNBT compoundnbt = getTileEntityNBT(world, pos); - TileEntity tileentity = world.getTileEntity(pos); + TileEntity tileentity = world.getBlockEntity(pos); return Pair.of(new BlockInfo(pos, blockstate, compoundnbt), tileentity); } @@ -621,7 +621,7 @@ public abstract class Contraption { if (blocks.put(localPos, blockInfo) != null) return; - bounds = bounds.union(new AxisAlignedBB(localPos)); + bounds = bounds.minmax(new AxisAlignedBB(localPos)); TileEntity te = pair.getValue(); if (te != null && MountedStorage.canUseAsStorage(te)) @@ -639,10 +639,10 @@ public abstract class Contraption { @Nullable protected CompoundNBT getTileEntityNBT(World world, BlockPos pos) { - TileEntity tileentity = world.getTileEntity(pos); + TileEntity tileentity = world.getBlockEntity(pos); if (tileentity == null) return null; - CompoundNBT nbt = tileentity.write(new CompoundNBT()); + CompoundNBT nbt = tileentity.save(new CompoundNBT()); nbt.remove("x"); nbt.remove("y"); nbt.remove("z"); @@ -695,18 +695,18 @@ public abstract class Contraption { superglue.clear(); NBTHelper.iterateCompoundList(nbt.getList("Superglue", NBT.TAG_COMPOUND), c -> superglue - .add(Pair.of(NBTUtil.readBlockPos(c.getCompound("Pos")), Direction.byIndex(c.getByte("Direction"))))); + .add(Pair.of(NBTUtil.readBlockPos(c.getCompound("Pos")), Direction.from3DDataValue(c.getByte("Direction"))))); seats.clear(); NBTHelper.iterateCompoundList(nbt.getList("Seats", NBT.TAG_COMPOUND), c -> seats.add(NBTUtil.readBlockPos(c))); seatMapping.clear(); NBTHelper.iterateCompoundList(nbt.getList("Passengers", NBT.TAG_COMPOUND), - c -> seatMapping.put(NBTUtil.readUniqueId(NBTHelper.getINBT(c, "Id")), c.getInt("Seat"))); + c -> seatMapping.put(NBTUtil.loadUUID(NBTHelper.getINBT(c, "Id")), c.getInt("Seat"))); stabilizedSubContraptions.clear(); NBTHelper.iterateCompoundList(nbt.getList("SubContraptions", NBT.TAG_COMPOUND), - c -> stabilizedSubContraptions.put(c.getUniqueId("Id"), BlockFace.fromNBT(c.getCompound("Location")))); + c -> stabilizedSubContraptions.put(c.getUUID("Id"), BlockFace.fromNBT(c.getCompound("Location")))); storage.clear(); NBTHelper.iterateCompoundList(nbt.getList("Storage", NBT.TAG_COMPOUND), c -> storage @@ -774,7 +774,7 @@ public abstract class Contraption { CompoundNBT c = new CompoundNBT(); c.put("Pos", NBTUtil.writeBlockPos(glueEntry.getKey())); c.putByte("Direction", (byte) glueEntry.getValue() - .getIndex()); + .get3DDataValue()); superglueNBT.add(c); } @@ -803,14 +803,14 @@ public abstract class Contraption { nbt.put("Seats", NBTHelper.writeCompoundList(getSeats(), NBTUtil::writeBlockPos)); nbt.put("Passengers", NBTHelper.writeCompoundList(getSeatMapping().entrySet(), e -> { CompoundNBT tag = new CompoundNBT(); - tag.put("Id", NBTUtil.fromUuid(e.getKey())); + tag.put("Id", NBTUtil.createUUID(e.getKey())); tag.putInt("Seat", e.getValue()); return tag; })); nbt.put("SubContraptions", NBTHelper.writeCompoundList(stabilizedSubContraptions.entrySet(), e -> { CompoundNBT tag = new CompoundNBT(); - tag.putUniqueId("Id", e.getKey()); + tag.putUUID("Id", e.getKey()); tag.put("Location", e.getValue() .serializeNBT()); return tag; @@ -843,7 +843,7 @@ public abstract class Contraption { for (BlockInfo block : this.blocks.values()) { int id = palette.idFor(block.state); CompoundNBT c = new CompoundNBT(); - c.putLong("Pos", block.pos.toLong()); + c.putLong("Pos", block.pos.asLong()); c.putInt("State", id); if (block.nbt != null) c.put("Data", block.nbt); @@ -851,7 +851,7 @@ public abstract class Contraption { } ListNBT paletteNBT = new ListNBT(); - palette.writePaletteToList(paletteNBT); + palette.write(paletteNBT); compound.put("Palette", paletteNBT); compound.put("BlockList", blockList); @@ -881,7 +881,7 @@ public abstract class Contraption { this.blocks.put(info.pos, info); - if (world.isRemote) { + if (world.isClientSide) { Block block = info.state.getBlock(); CompoundNBT tag = info.nbt; MovementBehaviour movementBehaviour = AllMovementBehaviours.of(block); @@ -892,10 +892,10 @@ public abstract class Contraption { tag.putInt("y", info.pos.getY()); tag.putInt("z", info.pos.getZ()); - TileEntity te = TileEntity.createFromTag(info.state, tag); + TileEntity te = TileEntity.loadStatic(info.state, tag); if (te == null) return; - te.setLocation(new ContraptionTileWorld(world, te, info), te.getPos()); + te.setLevelAndPosition(new ContraptionTileWorld(world, te, info), te.getBlockPos()); if (te instanceof KineticTileEntity) ((KineticTileEntity) te).setSpeed(0); te.getBlockState(); @@ -914,8 +914,8 @@ public abstract class Contraption { } private static BlockInfo readBlockInfo(CompoundNBT blockListEntry, HashMapPalette palette) { - return new BlockInfo(BlockPos.fromLong(blockListEntry.getLong("Pos")), - Objects.requireNonNull(palette.get(blockListEntry.getInt("State"))), + return new BlockInfo(BlockPos.of(blockListEntry.getLong("Pos")), + Objects.requireNonNull(palette.valueFor(blockListEntry.getInt("State"))), blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null); } @@ -939,33 +939,33 @@ public abstract class Contraption { if (brittles != BlockMovementChecks.isBrittle(block.state)) continue; - BlockPos add = block.pos.add(anchor) - .add(offset); + BlockPos add = block.pos.offset(anchor) + .offset(offset); if (customBlockRemoval(world, add, block.state)) continue; BlockState oldState = world.getBlockState(add); Block blockIn = oldState.getBlock(); if (block.state.getBlock() != blockIn) iterator.remove(); - world.removeTileEntity(add); + world.removeBlockEntity(add); int flags = BlockFlags.IS_MOVING | BlockFlags.NO_NEIGHBOR_DROPS | BlockFlags.UPDATE_NEIGHBORS | BlockFlags.BLOCK_UPDATE | BlockFlags.RERENDER_MAIN_THREAD; - if (blockIn instanceof IWaterLoggable && oldState.contains(BlockStateProperties.WATERLOGGED) - && oldState.get(BlockStateProperties.WATERLOGGED)) { - world.setBlockState(add, Blocks.WATER.getDefaultState(), flags); + if (blockIn instanceof IWaterLoggable && oldState.hasProperty(BlockStateProperties.WATERLOGGED) + && oldState.getValue(BlockStateProperties.WATERLOGGED)) { + world.setBlock(add, Blocks.WATER.defaultBlockState(), flags); continue; } - world.setBlockState(add, Blocks.AIR.getDefaultState(), flags); + world.setBlock(add, Blocks.AIR.defaultBlockState(), flags); } } for (BlockInfo block : blocks.values()) { - BlockPos add = block.pos.add(anchor) - .add(offset); + BlockPos add = block.pos.offset(anchor) + .offset(offset); // if (!shouldUpdateAfterMovement(block)) // continue; int flags = BlockFlags.IS_MOVING | BlockFlags.DEFAULT; - world.notifyBlockUpdate(add, block.state, Blocks.AIR.getDefaultState(), flags); + world.sendBlockUpdated(add, block.state, Blocks.AIR.defaultBlockState(), flags); // when the blockstate is set to air, the block's POI data is removed, but markAndNotifyBlock tries to // remove it again, so to prevent an error from being logged by double-removal we add the POI data back now @@ -973,13 +973,13 @@ public abstract class Contraption { ServerWorld serverWorld = (ServerWorld) world; PointOfInterestType.forState(block.state).ifPresent(poiType -> { world.getServer().execute(() -> { - serverWorld.getPointOfInterestManager().func_219135_a(add, poiType); - DebugPacketSender.func_218799_a(serverWorld, add); + serverWorld.getPoiManager().add(add, poiType); + DebugPacketSender.sendPoiAddedPacket(serverWorld, add); }); }); - world.markAndNotifyBlock(add, world.getChunkAt(add), block.state, Blocks.AIR.getDefaultState(), flags, 512); - block.state.updateDiagonalNeighbors(world, add, flags & -2); + world.markAndNotifyBlock(add, world.getChunkAt(add), block.state, Blocks.AIR.defaultBlockState(), flags, 512); + block.state.updateIndirectNeighbourShapes(world, add, flags & -2); } } @@ -997,27 +997,27 @@ public abstract class Contraption { if (nonBrittles) for (Direction face : Iterate.directions) - state = state.updatePostPlacement(face, world.getBlockState(targetPos.offset(face)), world, - targetPos, targetPos.offset(face)); + state = state.updateShape(face, world.getBlockState(targetPos.relative(face)), world, + targetPos, targetPos.relative(face)); BlockState blockState = world.getBlockState(targetPos); - if (blockState.getBlockHardness(world, targetPos) == -1 || (state.getCollisionShape(world, targetPos) + if (blockState.getDestroySpeed(world, targetPos) == -1 || (state.getCollisionShape(world, targetPos) .isEmpty() && !blockState.getCollisionShape(world, targetPos) .isEmpty())) { if (targetPos.getY() == 0) - targetPos = targetPos.up(); - world.playEvent(2001, targetPos, Block.getStateId(state)); - Block.spawnDrops(state, world, targetPos, null); + targetPos = targetPos.above(); + world.levelEvent(2001, targetPos, Block.getId(state)); + Block.dropResources(state, world, targetPos, null); continue; } - if (state.getBlock() instanceof IWaterLoggable && state.contains(BlockStateProperties.WATERLOGGED)) { + if (state.getBlock() instanceof IWaterLoggable && state.hasProperty(BlockStateProperties.WATERLOGGED)) { FluidState FluidState = world.getFluidState(targetPos); - state = state.with(BlockStateProperties.WATERLOGGED, FluidState.getFluid() == Fluids.WATER); + state = state.setValue(BlockStateProperties.WATERLOGGED, FluidState.getType() == Fluids.WATER); } world.destroyBlock(targetPos, true); - world.setBlockState(targetPos, state, 3 | BlockFlags.IS_MOVING); + world.setBlock(targetPos, state, 3 | BlockFlags.IS_MOVING); boolean verticalRotation = transform.rotationAxis == null || transform.rotationAxis.isHorizontal(); verticalRotation = verticalRotation && transform.rotation != Rotation.NONE; @@ -1026,7 +1026,7 @@ public abstract class Contraption { world.destroyBlock(targetPos, true); } - TileEntity tileEntity = world.getTileEntity(targetPos); + TileEntity tileEntity = world.getBlockEntity(targetPos); CompoundNBT tag = block.nbt; if (tileEntity != null) tag = NBTProcessors.process(tileEntity, tag, false); @@ -1041,9 +1041,9 @@ public abstract class Contraption { } if (tileEntity instanceof FluidTankTileEntity && tag.contains("LastKnownPos")) - tag.put("LastKnownPos", NBTUtil.writeBlockPos(BlockPos.ZERO.down())); + tag.put("LastKnownPos", NBTUtil.writeBlockPos(BlockPos.ZERO.below())); - tileEntity.fromTag(block.state, tag); + tileEntity.load(block.state, tag); if (storage.containsKey(block.pos)) { MountedStorage mountedStorage = storage.get(block.pos); @@ -1082,8 +1082,8 @@ public abstract class Contraption { SuperGlueEntity entity = new SuperGlueEntity(world, targetPos, targetFacing); if (entity.onValidSurface()) { - if (!world.isRemote) - world.addEntity(entity); + if (!world.isClientSide) + world.addFreshEntity(entity); } } } @@ -1092,7 +1092,7 @@ public abstract class Contraption { for (Entity seatedEntity : seatedEntities) { if (getSeatMapping().isEmpty()) continue; - Integer seatIndex = getSeatMapping().get(seatedEntity.getUniqueID()); + Integer seatIndex = getSeatMapping().get(seatedEntity.getUUID()); BlockPos seatPos = getSeats().get(seatIndex); seatPos = transform.apply(seatPos); if (!(world.getBlockState(seatPos) @@ -1216,11 +1216,11 @@ public abstract class Contraption { VoxelShape collisionShape = info.state.getCollisionShape(world, localPos); if (collisionShape.isEmpty()) continue; - combinedShape = VoxelShapes.combine(combinedShape, - collisionShape.withOffset(localPos.getX(), localPos.getY(), localPos.getZ()), IBooleanFunction.OR); + combinedShape = VoxelShapes.joinUnoptimized(combinedShape, + collisionShape.move(localPos.getX(), localPos.getY(), localPos.getZ()), IBooleanFunction.OR); } - return combinedShape.simplify() - .toBoundingBoxList(); + return combinedShape.optimize() + .toAabbs(); }) .thenAccept(r -> { simplifiedEntityColliders = Optional.of(r); @@ -1269,14 +1269,14 @@ public abstract class Contraption { @Override public BlockState getBlockState(BlockPos pos) { - if (!pos.equals(te.getPos())) - return Blocks.AIR.getDefaultState(); + if (!pos.equals(te.getBlockPos())) + return Blocks.AIR.defaultBlockState(); return info.state; } @Override - public boolean isBlockPresent(BlockPos pos) { - return pos.equals(te.getPos()); + public boolean isLoaded(BlockPos pos) { + return pos.equals(te.getBlockPos()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java index 0c0bee7e1..f07a194b1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import static net.minecraft.entity.Entity.collideBoundingBoxHeuristically; -import static net.minecraft.entity.Entity.horizontalMag; +import static net.minecraft.entity.Entity.getHorizontalDistanceSqr; import java.util.ArrayList; import java.util.List; @@ -60,7 +60,7 @@ public class ContraptionCollider { } static void collideEntities(AbstractContraptionEntity contraptionEntity) { - World world = contraptionEntity.getEntityWorld(); + World world = contraptionEntity.getCommandSenderWorld(); Contraption contraption = contraptionEntity.getContraption(); AxisAlignedBB bounds = contraptionEntity.getBoundingBox(); @@ -69,7 +69,7 @@ public class ContraptionCollider { if (bounds == null) return; - Vector3d contraptionPosition = contraptionEntity.getPositionVec(); + Vector3d contraptionPosition = contraptionEntity.position(); Vector3d contraptionMotion = contraptionPosition.subtract(contraptionEntity.getPrevPositionVec()); Vector3d anchorVec = contraptionEntity.getAnchorVec(); ContraptionRotationState rotation = null; @@ -77,8 +77,8 @@ public class ContraptionCollider { // After death, multiple refs to the client player may show up in the area boolean skipClientPlayer = false; - List entitiesWithinAABB = world.getEntitiesWithinAABB(Entity.class, bounds.grow(2) - .expand(0, 32, 0), contraptionEntity::canCollideWith); + List entitiesWithinAABB = world.getEntitiesOfClass(Entity.class, bounds.inflate(2) + .expandTowards(0, 32, 0), contraptionEntity::canCollideWith); for (Entity entity : entitiesWithinAABB) { PlayerType playerType = getPlayerType(entity); @@ -86,7 +86,7 @@ public class ContraptionCollider { continue; if (playerType == PlayerType.SERVER && entity instanceof ServerPlayerEntity) { - ((ServerPlayerEntity) entity).connection.floatingTickCount = 0; + ((ServerPlayerEntity) entity).connection.aboveGroundTickCount = 0; continue; } @@ -102,30 +102,30 @@ public class ContraptionCollider { Matrix3d rotationMatrix = rotation.asMatrix(); // Transform entity position and motion to local space - Vector3d entityPosition = entity.getPositionVec(); + Vector3d entityPosition = entity.position(); AxisAlignedBB entityBounds = entity.getBoundingBox(); - Vector3d motion = entity.getMotion(); + Vector3d motion = entity.getDeltaMovement(); float yawOffset = rotation.getYawOffset(); Vector3d position = getWorldToLocalTranslation(entity, anchorVec, rotationMatrix, yawOffset); // Prepare entity bounds - AxisAlignedBB localBB = entityBounds.offset(position) - .grow(1.0E-7D); + AxisAlignedBB localBB = entityBounds.move(position) + .inflate(1.0E-7D); OrientedBB obb = new OrientedBB(localBB); obb.setRotation(rotationMatrix); motion = motion.subtract(contraptionMotion); motion = rotationMatrix.transform(motion); - // Use simplified bbs when present + // Use simplified bbs when present final Vector3d motionCopy = motion; List collidableBBs = contraption.simplifiedEntityColliders.orElseGet(() -> { // Else find 'nearby' individual block shapes to collide with List bbs = new ArrayList<>(); ReuseableStream potentialHits = - getPotentiallyCollidedShapes(world, contraption, localBB.expand(motionCopy)); - potentialHits.createStream() - .forEach(shape -> shape.toBoundingBoxList() + getPotentiallyCollidedShapes(world, contraption, localBB.expandTowards(motionCopy)); + potentialHits.getStream() + .forEach(shape -> shape.toAabbs() .forEach(bbs::add)); return bbs; @@ -147,12 +147,12 @@ public class ContraptionCollider { Vector3d currentResponse = collisionResponse.getValue(); Vector3d currentCenter = obbCenter.add(currentResponse); - if (Math.abs(currentCenter.x - bb.getCenter().x) - entityBounds.getXSize() - 1 > bb.getXSize() / 2) + if (Math.abs(currentCenter.x - bb.getCenter().x) - entityBounds.getXsize() - 1 > bb.getXsize() / 2) continue; - if (Math.abs((currentCenter.y + motion.y) - bb.getCenter().y) - entityBounds.getYSize() - - 1 > bb.getYSize() / 2) + if (Math.abs((currentCenter.y + motion.y) - bb.getCenter().y) - entityBounds.getYsize() + - 1 > bb.getYsize() / 2) continue; - if (Math.abs(currentCenter.z - bb.getCenter().z) - entityBounds.getZSize() - 1 > bb.getZSize() / 2) + if (Math.abs(currentCenter.z - bb.getCenter().z) - entityBounds.getZsize() - 1 > bb.getZsize() / 2) continue; obb.setCenter(currentCenter); @@ -169,7 +169,7 @@ public class ContraptionCollider { Vector3d collisionPosition = intersect.getCollisionPosition(); if (!isTemporal) { - Vector3d separation = intersect.asSeparationVec(entity.stepHeight); + Vector3d separation = intersect.asSeparationVec(entity.maxUpStep); if (separation != null && !separation.equals(Vector3d.ZERO)) { collisionResponse.setValue(currentResponse.add(separation)); timeOfImpact = 0; @@ -198,12 +198,12 @@ public class ContraptionCollider { // Re-run collisions with horizontal offset collisionResponse.setValue(collisionResponse.getValue() - .mul(129 / 128f, 0, 129 / 128f)); + .multiply(129 / 128f, 0, 129 / 128f)); continue; } // Resolve collision - Vector3d entityMotion = entity.getMotion(); + Vector3d entityMotion = entity.getDeltaMovement(); Vector3d entityMotionNoTemporal = entityMotion; Vector3d collisionNormal = normal.getValue(); Vector3d collisionLocation = location.getValue(); @@ -230,7 +230,7 @@ public class ContraptionCollider { double slide = 0; if (!collisionLocation.equals(Vector3d.ZERO)) { - collisionLocation = collisionLocation.add(entity.getPositionVec() + collisionLocation = collisionLocation.add(entity.position() .add(entity.getBoundingBox() .getCenter()) .scale(.5f)); @@ -250,8 +250,8 @@ public class ContraptionCollider { boolean anyCollision = hardCollision || temporalCollision; if (bounce > 0 && hasNormal && anyCollision && bounceEntity(entity, collisionNormal, contraptionEntity, bounce)) { - entity.world.playSound(playerType == PlayerType.CLIENT ? (PlayerEntity) entity : null, - entity.getX(), entity.getY(), entity.getZ(), SoundEvents.BLOCK_SLIME_BLOCK_FALL, + entity.level.playSound(playerType == PlayerType.CLIENT ? (PlayerEntity) entity : null, + entity.getX(), entity.getY(), entity.getZ(), SoundEvents.SLIME_BLOCK_FALL, SoundCategory.BLOCKS, .5f, 1); continue; } @@ -259,53 +259,53 @@ public class ContraptionCollider { if (temporalCollision) { double idealVerticalMotion = motionResponse.y; if (idealVerticalMotion != entityMotion.y) { - entity.setMotion(entityMotion.mul(1, 0, 1) + entity.setDeltaMovement(entityMotion.multiply(1, 0, 1) .add(0, idealVerticalMotion, 0)); - entityMotion = entity.getMotion(); + entityMotion = entity.getDeltaMovement(); } } if (hardCollision) { - double motionX = entityMotion.getX(); - double motionY = entityMotion.getY(); - double motionZ = entityMotion.getZ(); - double intersectX = totalResponse.getX(); - double intersectY = totalResponse.getY(); - double intersectZ = totalResponse.getZ(); + double motionX = entityMotion.x(); + double motionY = entityMotion.y(); + double motionZ = entityMotion.z(); + double intersectX = totalResponse.x(); + double intersectY = totalResponse.y(); + double intersectZ = totalResponse.z(); double horizonalEpsilon = 1 / 128f; if (motionX != 0 && Math.abs(intersectX) > horizonalEpsilon && motionX > 0 == intersectX < 0) - entityMotion = entityMotion.mul(0, 1, 1); + entityMotion = entityMotion.multiply(0, 1, 1); if (motionY != 0 && intersectY != 0 && motionY > 0 == intersectY < 0) - entityMotion = entityMotion.mul(1, 0, 1) + entityMotion = entityMotion.multiply(1, 0, 1) .add(0, contraptionMotion.y, 0); if (motionZ != 0 && Math.abs(intersectZ) > horizonalEpsilon && motionZ > 0 == intersectZ < 0) - entityMotion = entityMotion.mul(1, 1, 0); + entityMotion = entityMotion.multiply(1, 1, 0); } if (bounce == 0 && slide > 0 && hasNormal && anyCollision && rotation.hasVerticalRotation()) { - double slideFactor = collisionNormal.mul(1, 0, 1) + double slideFactor = collisionNormal.multiply(1, 0, 1) .length() * 1.25f; - Vector3d motionIn = entityMotionNoTemporal.mul(0, .9, 0) + Vector3d motionIn = entityMotionNoTemporal.multiply(0, .9, 0) .add(0, -.01f, 0); - Vector3d slideNormal = collisionNormal.crossProduct(motionIn.crossProduct(collisionNormal)) + Vector3d slideNormal = collisionNormal.cross(motionIn.cross(collisionNormal)) .normalize(); - Vector3d newMotion = entityMotion.mul(.85, 0, .85) + Vector3d newMotion = entityMotion.multiply(.85, 0, .85) .add(slideNormal.scale((.2f + slide) * motionIn.length() * slideFactor) .add(0, -.1f - collisionNormal.y * .125f, 0)); - entity.setMotion(newMotion); - entityMotion = entity.getMotion(); + entity.setDeltaMovement(newMotion); + entityMotion = entity.getDeltaMovement(); } if (!hardCollision && surfaceCollision.isFalse()) continue; Vector3d allowedMovement = getAllowedMovement(totalResponse, entity); - entity.setPosition(entityPosition.x + allowedMovement.x, entityPosition.y + allowedMovement.y, + entity.setPos(entityPosition.x + allowedMovement.x, entityPosition.y + allowedMovement.y, entityPosition.z + allowedMovement.z); - entityPosition = entity.getPositionVec(); + entityPosition = entity.position(); - entity.velocityChanged = true; + entity.hurtMarked = true; Vector3d contactPointMotion = Vector3d.ZERO; if (surfaceCollision.isTrue()) { @@ -316,21 +316,21 @@ public class ContraptionCollider { if (canWalk) entity.onGround = true; if (entity instanceof ItemEntity) - entityMotion = entityMotion.mul(.5f, 1, .5f); + entityMotion = entityMotion.multiply(.5f, 1, .5f); } contactPointMotion = contraptionEntity.getContactPointMotion(entityPosition); allowedMovement = getAllowedMovement(contactPointMotion, entity); - entity.setPosition(entityPosition.x + allowedMovement.x, entityPosition.y, + entity.setPos(entityPosition.x + allowedMovement.x, entityPosition.y, entityPosition.z + allowedMovement.z); } - entity.setMotion(entityMotion); + entity.setDeltaMovement(entityMotion); if (playerType != PlayerType.CLIENT) continue; - double d0 = entity.getX() - entity.prevPosX - contactPointMotion.x; - double d1 = entity.getZ() - entity.prevPosZ - contactPointMotion.z; + double d0 = entity.getX() - entity.xo - contactPointMotion.x; + double d1 = entity.getZ() - entity.zo - contactPointMotion.z; float limbSwing = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F; if (limbSwing > 1.0F) limbSwing = 1.0F; @@ -342,15 +342,15 @@ public class ContraptionCollider { static boolean bounceEntity(Entity entity, Vector3d normal, AbstractContraptionEntity contraption, double factor) { if (factor == 0) return false; - if (entity.bypassesLandingEffects()) + if (entity.isSuppressingBounce()) return false; - Vector3d contactPointMotion = contraption.getContactPointMotion(entity.getPositionVec()); - Vector3d motion = entity.getMotion().subtract(contactPointMotion); - Vector3d deltav = normal.scale(factor*2*motion.dotProduct(normal)); - if (deltav.dotProduct(deltav) < 0.1f) + Vector3d contactPointMotion = contraption.getContactPointMotion(entity.position()); + Vector3d motion = entity.getDeltaMovement().subtract(contactPointMotion); + Vector3d deltav = normal.scale(factor*2*motion.dot(normal)); + if (deltav.dot(deltav) < 0.1f) return false; - entity.setMotion(entity.getMotion().subtract(deltav)); + entity.setDeltaMovement(entity.getDeltaMovement().subtract(deltav)); return true; } @@ -363,8 +363,8 @@ public class ContraptionCollider { } public static Vector3d getWorldToLocalTranslation(Entity entity, Vector3d anchorVec, Matrix3d rotationMatrix, float yawOffset) { - Vector3d entityPosition = entity.getPositionVec(); - Vector3d centerY = new Vector3d(0, entity.getBoundingBox().getYSize() / 2, 0); + Vector3d entityPosition = entity.position(); + Vector3d centerY = new Vector3d(0, entity.getBoundingBox().getYsize() / 2, 0); Vector3d position = entityPosition; position = position.add(centerY); position = position.subtract(VecHelper.CENTER_OF_ORIGIN); @@ -399,38 +399,38 @@ public class ContraptionCollider { /** From Entity#getAllowedMovement **/ static Vector3d getAllowedMovement(Vector3d movement, Entity e) { AxisAlignedBB bb = e.getBoundingBox(); - ISelectionContext ctx = ISelectionContext.forEntity(e); - World world = e.world; + ISelectionContext ctx = ISelectionContext.of(e); + World world = e.level; VoxelShape voxelshape = world.getWorldBorder() - .getShape(); + .getCollisionShape(); Stream stream = - VoxelShapes.compare(voxelshape, VoxelShapes.create(bb.shrink(1.0E-7D)), IBooleanFunction.AND) + VoxelShapes.joinIsNotEmpty(voxelshape, VoxelShapes.create(bb.deflate(1.0E-7D)), IBooleanFunction.AND) ? Stream.empty() : Stream.of(voxelshape); - Stream stream1 = world.getEntityCollisions(e, bb.expand(movement), entity -> false); // FIXME: 1.15 equivalent translated correctly? + Stream stream1 = world.getEntityCollisions(e, bb.expandTowards(movement), entity -> false); // FIXME: 1.15 equivalent translated correctly? ReuseableStream reuseablestream = new ReuseableStream<>(Stream.concat(stream1, stream)); - Vector3d allowedMovement = movement.lengthSquared() == 0.0D ? movement + Vector3d allowedMovement = movement.lengthSqr() == 0.0D ? movement : collideBoundingBoxHeuristically(e, movement, bb, world, ctx, reuseablestream); boolean xDifferent = movement.x != allowedMovement.x; boolean yDifferent = movement.y != allowedMovement.y; boolean zDifferent = movement.z != allowedMovement.z; boolean notMovingUp = e.isOnGround() || yDifferent && movement.y < 0.0D; - if (e.stepHeight > 0.0F && notMovingUp && (xDifferent || zDifferent)) { - Vector3d allowedStep = collideBoundingBoxHeuristically(e, new Vector3d(movement.x, (double) e.stepHeight, movement.z), + if (e.maxUpStep > 0.0F && notMovingUp && (xDifferent || zDifferent)) { + Vector3d allowedStep = collideBoundingBoxHeuristically(e, new Vector3d(movement.x, (double) e.maxUpStep, movement.z), bb, world, ctx, reuseablestream); - Vector3d allowedStepGivenMovement = collideBoundingBoxHeuristically(e, new Vector3d(0.0D, (double) e.stepHeight, 0.0D), - bb.expand(movement.x, 0.0D, movement.z), world, ctx, reuseablestream); - if (allowedStepGivenMovement.y < (double) e.stepHeight) { + Vector3d allowedStepGivenMovement = collideBoundingBoxHeuristically(e, new Vector3d(0.0D, (double) e.maxUpStep, 0.0D), + bb.expandTowards(movement.x, 0.0D, movement.z), world, ctx, reuseablestream); + if (allowedStepGivenMovement.y < (double) e.maxUpStep) { Vector3d vec3 = collideBoundingBoxHeuristically(e, new Vector3d(movement.x, 0.0D, movement.z), - bb.offset(allowedStepGivenMovement), world, ctx, reuseablestream).add(allowedStepGivenMovement); - if (horizontalMag(vec3) > horizontalMag(allowedStep)) { + bb.move(allowedStepGivenMovement), world, ctx, reuseablestream).add(allowedStepGivenMovement); + if (getHorizontalDistanceSqr(vec3) > getHorizontalDistanceSqr(allowedStep)) { allowedStep = vec3; } } - if (horizontalMag(allowedStep) > horizontalMag(allowedMovement)) { + if (getHorizontalDistanceSqr(allowedStep) > getHorizontalDistanceSqr(allowedMovement)) { return allowedStep.add(collideBoundingBoxHeuristically(e, new Vector3d(0.0D, -allowedStep.y + movement.y, 0.0D), - bb.offset(allowedStep), world, ctx, reuseablestream)); + bb.move(allowedStep), world, ctx, reuseablestream)); } } @@ -440,7 +440,7 @@ public class ContraptionCollider { private static PlayerType getPlayerType(Entity entity) { if (!(entity instanceof PlayerEntity)) return PlayerType.NONE; - if (!entity.world.isRemote) + if (!entity.level.isClientSide) return PlayerType.SERVER; MutableBoolean isClient = new MutableBoolean(false); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> isClient.setValue(isClientPlayerEntity(entity))); @@ -455,17 +455,17 @@ public class ContraptionCollider { private static ReuseableStream getPotentiallyCollidedShapes(World world, Contraption contraption, AxisAlignedBB localBB) { - double height = localBB.getYSize(); - double width = localBB.getXSize(); + double height = localBB.getYsize(); + double width = localBB.getXsize(); double horizontalFactor = (height > width && width != 0) ? height / width : 1; double verticalFactor = (width > height && height != 0) ? width / height : 1; - AxisAlignedBB blockScanBB = localBB.grow(0.5f); - blockScanBB = blockScanBB.grow(horizontalFactor, verticalFactor, horizontalFactor); + AxisAlignedBB blockScanBB = localBB.inflate(0.5f); + blockScanBB = blockScanBB.inflate(horizontalFactor, verticalFactor, horizontalFactor); BlockPos min = new BlockPos(blockScanBB.minX, blockScanBB.minY, blockScanBB.minZ); BlockPos max = new BlockPos(blockScanBB.maxX, blockScanBB.maxY, blockScanBB.maxZ); - ReuseableStream potentialHits = new ReuseableStream<>(BlockPos.getAllInBox(min, max) + ReuseableStream potentialHits = new ReuseableStream<>(BlockPos.betweenClosedStream(min, max) .filter(contraption.getBlocks()::containsKey) .map(p -> { BlockState blockState = contraption.getBlocks() @@ -473,7 +473,7 @@ public class ContraptionCollider { BlockPos pos = contraption.getBlocks() .get(p).pos; VoxelShape collisionShape = blockState.getCollisionShape(world, p); - return collisionShape.withOffset(pos.getX(), pos.getY(), pos.getZ()); + return collisionShape.move(pos.getX(), pos.getY(), pos.getZ()); }) .filter(Predicates.not(VoxelShape::isEmpty))); @@ -484,11 +484,11 @@ public class ContraptionCollider { if (!contraptionEntity.supportsTerrainCollision()) return false; - World world = contraptionEntity.getEntityWorld(); - Vector3d motion = contraptionEntity.getMotion(); + World world = contraptionEntity.getCommandSenderWorld(); + Vector3d motion = contraptionEntity.getDeltaMovement(); TranslatingContraption contraption = (TranslatingContraption) contraptionEntity.getContraption(); AxisAlignedBB bounds = contraptionEntity.getBoundingBox(); - Vector3d position = contraptionEntity.getPositionVec(); + Vector3d position = contraptionEntity.position(); BlockPos gridPos = new BlockPos(position); if (contraption == null) @@ -498,37 +498,37 @@ public class ContraptionCollider { if (motion.equals(Vector3d.ZERO)) return false; - Direction movementDirection = Direction.getFacingFromVector(motion.x, motion.y, motion.z); + Direction movementDirection = Direction.getNearest(motion.x, motion.y, motion.z); // Blocks in the world if (movementDirection.getAxisDirection() == AxisDirection.POSITIVE) - gridPos = gridPos.offset(movementDirection); + gridPos = gridPos.relative(movementDirection); if (isCollidingWithWorld(world, contraption, gridPos, movementDirection)) return true; // Other moving Contraptions - for (ControlledContraptionEntity otherContraptionEntity : world.getEntitiesWithinAABB( - ControlledContraptionEntity.class, bounds.grow(1), e -> !e.equals(contraptionEntity))) { + for (ControlledContraptionEntity otherContraptionEntity : world.getEntitiesOfClass( + ControlledContraptionEntity.class, bounds.inflate(1), e -> !e.equals(contraptionEntity))) { if (!otherContraptionEntity.supportsTerrainCollision()) continue; - Vector3d otherMotion = otherContraptionEntity.getMotion(); + Vector3d otherMotion = otherContraptionEntity.getDeltaMovement(); TranslatingContraption otherContraption = (TranslatingContraption) otherContraptionEntity.getContraption(); AxisAlignedBB otherBounds = otherContraptionEntity.getBoundingBox(); - Vector3d otherPosition = otherContraptionEntity.getPositionVec(); + Vector3d otherPosition = otherContraptionEntity.position(); if (otherContraption == null) return false; if (otherBounds == null) return false; - if (!bounds.offset(motion) - .intersects(otherBounds.offset(otherMotion))) + if (!bounds.move(motion) + .intersects(otherBounds.move(otherMotion))) continue; for (BlockPos colliderPos : contraption.getColliders(world, movementDirection)) { - colliderPos = colliderPos.add(gridPos) + colliderPos = colliderPos.offset(gridPos) .subtract(new BlockPos(otherPosition)); if (!otherContraption.getBlocks() .containsKey(colliderPos)) @@ -543,9 +543,9 @@ public class ContraptionCollider { public static boolean isCollidingWithWorld(World world, TranslatingContraption contraption, BlockPos anchor, Direction movementDirection) { for (BlockPos pos : contraption.getColliders(world, movementDirection)) { - BlockPos colliderPos = pos.add(anchor); + BlockPos colliderPos = pos.offset(anchor); - if (!world.isBlockPresent(colliderPos)) + if (!world.isLoaded(colliderPos)) return true; BlockState collidedState = world.getBlockState(colliderPos); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionEntityRenderer.java index 8d8ed3b62..fe20059fa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionEntityRenderer.java @@ -17,7 +17,7 @@ public class ContraptionEntityRenderer exte } @Override - public ResourceLocation getEntityTexture(C entity) { + public ResourceLocation getTextureLocation(C entity) { return null; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandler.java index c1c5dfea3..ef0a9dedd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandler.java @@ -36,7 +36,7 @@ public class ContraptionHandler { List queued = queuedAdditions.get(world); for (AbstractContraptionEntity contraptionEntity : queued) - map.put(contraptionEntity.getEntityId(), new WeakReference<>(contraptionEntity)); + map.put(contraptionEntity.getId(), new WeakReference<>(contraptionEntity)); queued.clear(); Collection> values = map.values(); @@ -58,14 +58,14 @@ public class ContraptionHandler { } public static void entitiesWhoJustDismountedGetSentToTheRightLocation(LivingEntity entityLiving, World world) { - if (world.isRemote) + if (world.isClientSide) return; CompoundNBT data = entityLiving.getPersistentData(); if (!data.contains("ContraptionDismountLocation")) return; Vector3d position = VecHelper.readNBT(data.getList("ContraptionDismountLocation", NBT.TAG_DOUBLE)); - if (entityLiving.getRidingEntity() == null) - entityLiving.setPositionAndUpdate(position.x, position.y, position.z); + if (entityLiving.getVehicle() == null) + entityLiving.teleportTo(position.x, position.y, position.z); data.remove("ContraptionDismountLocation"); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandlerClient.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandlerClient.java index 3ab9bb670..deb7ec47c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandlerClient.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandlerClient.java @@ -52,8 +52,8 @@ public class ContraptionHandlerClient { } float limbSwing = data.getFloat("OverrideLimbSwing"); - remotePlayer.prevPosX = remotePlayer.getX() - (limbSwing / 4); - remotePlayer.prevPosZ = remotePlayer.getZ(); + remotePlayer.xo = remotePlayer.getX() - (limbSwing / 4); + remotePlayer.zo = remotePlayer.getZ(); } @SubscribeEvent @@ -65,20 +65,20 @@ public class ContraptionHandlerClient { return; if (player.isPassenger()) return; - if (mc.world == null) + if (mc.level == null) return; if (!event.isUseItem()) return; Vector3d origin = RaycastHelper.getTraceOrigin(player); - double reach = mc.playerController.getBlockReachDistance(); - if (mc.objectMouseOver != null && mc.objectMouseOver.getHitVec() != null) - reach = Math.min(mc.objectMouseOver.getHitVec() + double reach = mc.gameMode.getPickRange(); + if (mc.hitResult != null && mc.hitResult.getLocation() != null) + reach = Math.min(mc.hitResult.getLocation() .distanceTo(origin), reach); Vector3d target = RaycastHelper.getTraceTarget(player, reach, origin); - for (AbstractContraptionEntity contraptionEntity : mc.world - .getEntitiesWithinAABB(AbstractContraptionEntity.class, new AxisAlignedBB(origin, target))) { + for (AbstractContraptionEntity contraptionEntity : mc.level + .getEntitiesOfClass(AbstractContraptionEntity.class, new AxisAlignedBB(origin, target))) { Vector3d localOrigin = contraptionEntity.toLocalVector(origin, 1); Vector3d localTarget = contraptionEntity.toLocalVector(target, 1); @@ -91,10 +91,10 @@ public class ContraptionHandlerClient { if (blockInfo == null) return false; BlockState state = blockInfo.state; - VoxelShape raytraceShape = state.getShape(Minecraft.getInstance().world, BlockPos.ZERO.down()); + VoxelShape raytraceShape = state.getShape(Minecraft.getInstance().level, BlockPos.ZERO.below()); if (raytraceShape.isEmpty()) return false; - BlockRayTraceResult rayTrace = raytraceShape.rayTrace(localOrigin, localTarget, p); + BlockRayTraceResult rayTrace = raytraceShape.clip(localOrigin, localTarget, p); if (rayTrace != null) { mutableResult.setValue(rayTrace); return true; @@ -107,8 +107,8 @@ public class ContraptionHandlerClient { BlockRayTraceResult rayTraceResult = mutableResult.getValue(); Hand hand = event.getHand(); - Direction face = rayTraceResult.getFace(); - BlockPos pos = rayTraceResult.getPos(); + Direction face = rayTraceResult.getDirection(); + BlockPos pos = rayTraceResult.getBlockPos(); if (!contraptionEntity.handlePlayerInteraction(player, pos, face, hand)) return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java index 73d5a39e2..7b130e908 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java @@ -24,7 +24,7 @@ public abstract class ContraptionLighter implements ILigh lightVolume = new LightVolume(contraptionBoundsToVolume(bounds.copy())); - lightVolume.initialize(contraption.entity.world); + lightVolume.initialize(contraption.entity.level); scheduleRebuild = true; startListening(); @@ -32,7 +32,7 @@ public abstract class ContraptionLighter implements ILigh public void tick(RenderedContraption owner) { if (scheduleRebuild) { - lightVolume.initialize(owner.contraption.entity.world); + lightVolume.initialize(owner.contraption.entity.level); scheduleRebuild = false; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionWorld.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionWorld.java index bff9499dd..28d9dc99b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionWorld.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionWorld.java @@ -29,7 +29,7 @@ public class ContraptionWorld extends WrappedWorld { if (blockInfo != null) return blockInfo.state; - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } @Override @@ -43,7 +43,7 @@ public class ContraptionWorld extends WrappedWorld { } @Override - public void playSound(double x, double y, double z, SoundEvent p_184134_7_, SoundCategory p_184134_8_, float p_184134_9_, float p_184134_10_, boolean p_184134_11_) { - world.playSound(x, y, z, p_184134_7_, p_184134_8_, p_184134_9_, p_184134_10_, p_184134_11_); + public void playLocalSound(double x, double y, double z, SoundEvent p_184134_7_, SoundCategory p_184134_8_, float p_184134_9_, float p_184134_10_, boolean p_184134_11_) { + world.playLocalSound(x, y, z, p_184134_7_, p_184134_8_, p_184134_9_, p_184134_10_, p_184134_11_); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java index dbdef7a30..be07bba20 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java @@ -22,6 +22,8 @@ import net.minecraft.world.gen.feature.template.Template.BlockInfo; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity.ContraptionRotationState; + /** * Ex: Pistons, bearings
* Controlled Contraption Entities can rotate around one axis and translate. @@ -52,7 +54,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { @Override public Vector3d getContactPointMotion(Vector3d globalContactPoint) { if (contraption instanceof TranslatingContraption) - return getMotion(); + return getDeltaMovement(); return super.getContactPointMotion(globalContactPoint); } @@ -124,11 +126,11 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { } @Override - public void setPositionAndUpdate(double p_70634_1_, double p_70634_3_, double p_70634_5_) {} + public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {} @Override @OnlyIn(Dist.CLIENT) - public void setPositionAndRotationDirect(double x, double y, double z, float yw, float pt, int inc, boolean t) {} + public void lerpTo(double x, double y, double z, float yw, float pt, int inc, boolean t) {} protected void tickContraption() { angleDelta = angle - prevAngle; @@ -137,7 +139,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { if (controllerPos == null) return; - if (!world.isBlockPresent(controllerPos)) + if (!level.isLoaded(controllerPos)) return; IControlContraption controller = getController(); if (controller == null) { @@ -146,11 +148,11 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { } if (!controller.isAttachedTo(this)) { controller.attach(this); - if (world.isRemote) - setPosition(getX(), getY(), getZ()); + if (level.isClientSide) + setPos(getX(), getY(), getZ()); } - Vector3d motion = getMotion(); + Vector3d motion = getDeltaMovement(); move(motion.x, motion.y, motion.z); if (ContraptionCollider.collideBlocks(this)) getController().collided(); @@ -168,12 +170,12 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { BearingContraption bc = (BearingContraption) contraption; Direction facing = bc.getFacing(); Vector3d activeAreaOffset = actor.getActiveAreaOffset(context); - if (!activeAreaOffset.mul(VecHelper.axisAlingedPlaneOf(Vector3d.of(facing.getDirectionVec()))) + if (!activeAreaOffset.multiply(VecHelper.axisAlingedPlaneOf(Vector3d.atLowerCornerOf(facing.getNormal()))) .equals(Vector3d.ZERO)) return false; if (!VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis())) return false; - context.motion = Vector3d.of(facing.getDirectionVec()).scale(angleDelta / 360.0); + context.motion = Vector3d.atLowerCornerOf(facing.getNormal()).scale(angleDelta / 360.0); context.relativeMotion = context.motion; int timer = context.data.getInt("StationaryTimer"); if (timer > 0) { @@ -188,9 +190,9 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { protected IControlContraption getController() { if (controllerPos == null) return null; - if (!world.isBlockPresent(controllerPos)) + if (!level.isLoaded(controllerPos)) return null; - TileEntity te = world.getTileEntity(controllerPos); + TileEntity te = level.getBlockEntity(controllerPos); if (!(te instanceof IControlContraption)) return null; return (IControlContraption) te; @@ -220,7 +222,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { @Override protected void handleStallInformation(float x, float y, float z, float angle) { - setPos(x, y, z); + setPosRaw(x, y, z); this.angle = angle; } @@ -232,7 +234,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { for (MatrixStack stack : matrixStacks) MatrixStacker.of(stack) - .nudge(getEntityId()) + .nudge(getId()) .centre() .rotate(angle, axis) .unCentre(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/DirectionalExtenderScrollOptionSlot.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/DirectionalExtenderScrollOptionSlot.java index 2bf9f5db0..defea334f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/DirectionalExtenderScrollOptionSlot.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/DirectionalExtenderScrollOptionSlot.java @@ -21,13 +21,13 @@ public class DirectionalExtenderScrollOptionSlot extends CenteredSideValueBoxTra @Override protected Vector3d getLocalOffset(BlockState state) { return super.getLocalOffset(state) - .add(Vector3d.of(state.get(BlockStateProperties.FACING).getDirectionVec()).scale(-2 / 16f)); + .add(Vector3d.atLowerCornerOf(state.getValue(BlockStateProperties.FACING).getNormal()).scale(-2 / 16f)); } @Override protected void rotate(BlockState state, MatrixStack ms) { if (!getSide().getAxis().isHorizontal()) - MatrixStacker.of(ms).rotateY(AngleHelper.horizontalAngle(state.get(BlockStateProperties.FACING)) - 90); + MatrixStacker.of(ms).rotateY(AngleHelper.horizontalAngle(state.getValue(BlockStateProperties.FACING)) - 90); super.rotate(state, ms); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/IDisplayAssemblyExceptions.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/IDisplayAssemblyExceptions.java index 36455b9cd..80c154e7e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/IDisplayAssemblyExceptions.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/IDisplayAssemblyExceptions.java @@ -24,12 +24,12 @@ public interface IDisplayAssemblyExceptions { if (!tooltip.isEmpty()) tooltip.add(StringTextComponent.EMPTY); - tooltip.add(IHaveGoggleInformation.componentSpacing.copy().append(Lang.translate("gui.assembly.exception").formatted(TextFormatting.GOLD))); + tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy().append(Lang.translate("gui.assembly.exception").withStyle(TextFormatting.GOLD))); String text = e.component.getString(); Arrays.stream(text.split("\n")) .forEach(l -> TooltipHelper.cutStringTextComponent(l, GRAY, WHITE) - .forEach(c -> tooltip.add(IHaveGoggleInformation.componentSpacing.copy().append(c)))); + .forEach(c -> tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy().append(c)))); return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MountedFluidStorage.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MountedFluidStorage.java index 1709ae7d9..8ef8f2a3a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MountedFluidStorage.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MountedFluidStorage.java @@ -63,7 +63,7 @@ public class MountedFluidStorage { else if (sendPacket) { sendPacket = false; AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> entity), - new ContraptionFluidPacket(entity.getEntityId(), pos, tank.getFluid())); + new ContraptionFluidPacket(entity.getId(), pos, tank.getFluid())); packetCooldown = 8; } return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MountedStorage.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MountedStorage.java index fb49312d3..cc9769c8a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MountedStorage.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MountedStorage.java @@ -62,21 +62,21 @@ public class MountedStorage { // Split double chests if (te.getType() == TileEntityType.CHEST || te.getType() == TileEntityType.TRAPPED_CHEST) { if (te.getBlockState() - .get(ChestBlock.TYPE) != ChestType.SINGLE) - te.getWorld() - .setBlockState(te.getPos(), te.getBlockState() - .with(ChestBlock.TYPE, ChestType.SINGLE)); - te.updateContainingBlockInfo(); + .getValue(ChestBlock.TYPE) != ChestType.SINGLE) + te.getLevel() + .setBlockAndUpdate(te.getBlockPos(), te.getBlockState() + .setValue(ChestBlock.TYPE, ChestType.SINGLE)); + te.clearCache(); } // Split double flexcrates if (AllTileEntities.ADJUSTABLE_CRATE.is(te)) { if (te.getBlockState() - .get(AdjustableCrateBlock.DOUBLE)) - te.getWorld() - .setBlockState(te.getPos(), te.getBlockState() - .with(AdjustableCrateBlock.DOUBLE, false)); - te.updateContainingBlockInfo(); + .getValue(AdjustableCrateBlock.DOUBLE)) + te.getLevel() + .setBlockAndUpdate(te.getBlockPos(), te.getBlockState() + .setValue(AdjustableCrateBlock.DOUBLE, false)); + te.clearCache(); } IItemHandler teHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) @@ -146,7 +146,7 @@ public class MountedStorage { storage.valid = true; if (nbt.contains("Bottomless")) { - ItemStack providedStack = ItemStack.read(nbt.getCompound("ProvidedStack")); + ItemStack providedStack = ItemStack.of(nbt.getCompound("ProvidedStack")); storage.handler = new BottomlessItemHandler(() -> providedStack); return storage; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java index e2b035323..a94aa49c8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java @@ -39,9 +39,9 @@ public abstract class MovementBehaviour { Vector3d vec = context.position; ItemEntity itemEntity = new ItemEntity(context.world, vec.x, vec.y, vec.z, remainder); - itemEntity.setMotion(context.motion.add(0, 0.5f, 0) - .scale(context.world.rand.nextFloat() * .3f)); - context.world.addEntity(itemEntity); + itemEntity.setDeltaMovement(context.motion.add(0, 0.5f, 0) + .scale(context.world.random.nextFloat() * .3f)); + context.world.addFreshEntity(itemEntity); } public void stopMoving(MovementContext context) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementContext.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementContext.java index fa26f9ca1..d100c6707 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementContext.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementContext.java @@ -49,7 +49,7 @@ public class MovementContext { public float getAnimationSpeed() { int modifier = 1000; double length = -motion.length(); - if (world.isRemote && contraption.stalled) + if (world.isClientSide && contraption.stalled) return 700; if (Math.abs(length) < 1 / 512f) return 0; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java index 50345908c..800ee2a59 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java @@ -14,7 +14,7 @@ public class NonStationaryLighter extends ContraptionLigh GridAlignedBB contraptionBounds = getContraptionBounds(); if (!contraptionBounds.sameAs(bounds)) { - lightVolume.move(contraption.entity.world, contraptionBoundsToVolume(contraptionBounds)); + lightVolume.move(contraption.entity.level, contraptionBoundsToVolume(contraptionBounds)); bounds = contraptionBounds; startListening(); @@ -25,7 +25,7 @@ public class NonStationaryLighter extends ContraptionLigh public GridAlignedBB getContraptionBounds() { GridAlignedBB bb = GridAlignedBB.from(contraption.bounds); - bb.translate(contraption.entity.getBlockPos()); + bb.translate(contraption.entity.blockPosition()); return bb; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java index cbed32edf..d78fe1f53 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java @@ -48,6 +48,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; +import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity.ContraptionRotationState; + /** * Ex: Minecarts, Couplings
* Oriented Contraption Entities can rotate freely around two axes @@ -55,12 +57,12 @@ import net.minecraftforge.common.util.LazyOptional; */ public class OrientedContraptionEntity extends AbstractContraptionEntity { - private static final Ingredient FUEL_ITEMS = Ingredient.fromItems(Items.COAL, Items.CHARCOAL); + private static final Ingredient FUEL_ITEMS = Ingredient.of(Items.COAL, Items.CHARCOAL); private static final DataParameter> COUPLING = - EntityDataManager.createKey(OrientedContraptionEntity.class, DataSerializers.OPTIONAL_UNIQUE_ID); + EntityDataManager.defineId(OrientedContraptionEntity.class, DataSerializers.OPTIONAL_UUID); private static final DataParameter INITIAL_ORIENTATION = - EntityDataManager.createKey(OrientedContraptionEntity.class, DataSerializers.DIRECTION); + EntityDataManager.defineId(OrientedContraptionEntity.class, DataSerializers.DIRECTION); protected Vector3d motionBeforeStall; protected boolean forceAngle; @@ -105,16 +107,16 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } public void setInitialOrientation(Direction direction) { - dataManager.set(INITIAL_ORIENTATION, direction); + entityData.set(INITIAL_ORIENTATION, direction); } public Direction getInitialOrientation() { - return dataManager.get(INITIAL_ORIENTATION); + return entityData.get(INITIAL_ORIENTATION); } public void deferOrientation(Direction newInitialAngle) { - dataManager.set(INITIAL_ORIENTATION, Direction.UP); - yaw = initialYawOffset = newInitialAngle.getHorizontalAngle(); + entityData.set(INITIAL_ORIENTATION, Direction.UP); + yaw = initialYawOffset = newInitialAngle.toYRot(); } @Override @@ -123,15 +125,15 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } public float getInitialYaw() { - return (isInitialOrientationPresent() ? dataManager.get(INITIAL_ORIENTATION) : Direction.SOUTH) - .getHorizontalAngle(); + return (isInitialOrientationPresent() ? entityData.get(INITIAL_ORIENTATION) : Direction.SOUTH) + .toYRot(); } @Override - protected void registerData() { - super.registerData(); - dataManager.register(COUPLING, Optional.empty()); - dataManager.register(INITIAL_ORIENTATION, Direction.UP); + protected void defineSynchedData() { + super.defineSynchedData(); + entityData.define(COUPLING, Optional.empty()); + entityData.define(INITIAL_ORIENTATION, Direction.UP); } @Override @@ -152,7 +154,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { @Override public void stopRiding() { - if (!world.isRemote && isAlive()) + if (!level.isClientSide && isAlive()) disassemble(); super.stopRiding(); } @@ -176,10 +178,10 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { motionBeforeStall = new Vector3d(vecNBT.getDouble(0), vecNBT.getDouble(1), vecNBT.getDouble(2)); if (!motionBeforeStall.equals(Vector3d.ZERO)) targetYaw = prevYaw = yaw += yawFromVector(motionBeforeStall); - setMotion(Vector3d.ZERO); + setDeltaMovement(Vector3d.ZERO); } - setCouplingId(compound.contains("OnCoupling") ? compound.getUniqueId("OnCoupling") : null); + setCouplingId(compound.contains("OnCoupling") ? compound.getUUID("OnCoupling") : null); } @Override @@ -188,9 +190,9 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { if (motionBeforeStall != null) compound.put("CachedMotion", - newDoubleNBTList(motionBeforeStall.x, motionBeforeStall.y, motionBeforeStall.z)); + newDoubleList(motionBeforeStall.x, motionBeforeStall.y, motionBeforeStall.z)); - Direction optional = dataManager.get(INITIAL_ORIENTATION); + Direction optional = entityData.get(INITIAL_ORIENTATION); if (optional.getAxis() .isHorizontal()) NBTHelper.writeEnum(compound, "InitialOrientation", optional); @@ -204,18 +206,18 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { compound.putFloat("Pitch", pitch); if (getCouplingId() != null) - compound.putUniqueId("OnCoupling", getCouplingId()); + compound.putUUID("OnCoupling", getCouplingId()); } @Override - public void notifyDataManagerChange(DataParameter key) { - super.notifyDataManagerChange(key); + public void onSyncedDataUpdated(DataParameter key) { + super.onSyncedDataUpdated(key); if (key == INITIAL_ORIENTATION && isInitialOrientationPresent() && !manuallyPlaced) startAtInitialYaw(); } public boolean isInitialOrientationPresent() { - return dataManager.get(INITIAL_ORIENTATION) + return entityData.get(INITIAL_ORIENTATION) .getAxis() .isHorizontal(); } @@ -232,30 +234,30 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { @Override public Vector3d applyRotation(Vector3d localPos, float partialTicks) { localPos = VecHelper.rotate(localPos, getInitialYaw(), Axis.Y); - localPos = VecHelper.rotate(localPos, getPitch(partialTicks), Axis.Z); - localPos = VecHelper.rotate(localPos, getYaw(partialTicks), Axis.Y); + localPos = VecHelper.rotate(localPos, getViewXRot(partialTicks), Axis.Z); + localPos = VecHelper.rotate(localPos, getViewYRot(partialTicks), Axis.Y); return localPos; } @Override public Vector3d reverseRotation(Vector3d localPos, float partialTicks) { - localPos = VecHelper.rotate(localPos, -getYaw(partialTicks), Axis.Y); - localPos = VecHelper.rotate(localPos, -getPitch(partialTicks), Axis.Z); + localPos = VecHelper.rotate(localPos, -getViewYRot(partialTicks), Axis.Y); + localPos = VecHelper.rotate(localPos, -getViewXRot(partialTicks), Axis.Z); localPos = VecHelper.rotate(localPos, -getInitialYaw(), Axis.Y); return localPos; } - public float getYaw(float partialTicks) { + public float getViewYRot(float partialTicks) { return -(partialTicks == 1.0F ? yaw : angleLerp(partialTicks, prevYaw, yaw)); } - public float getPitch(float partialTicks) { + public float getViewXRot(float partialTicks) { return partialTicks == 1.0F ? pitch : angleLerp(partialTicks, prevPitch, pitch); } @Override protected void tickContraption() { - Entity e = getRidingEntity(); + Entity e = getVehicle(); if (e == null) return; @@ -269,8 +271,8 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } Entity riding = e; - while (riding.getRidingEntity() != null && !(contraption instanceof StabilizedContraption)) - riding = riding.getRidingEntity(); + while (riding.getVehicle() != null && !(contraption instanceof StabilizedContraption)) + riding = riding.getVehicle(); boolean isOnCoupling = false; UUID couplingId = getCouplingId(); @@ -289,22 +291,22 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { LazyOptional capability = riding.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY); if (capability.isPresent()) { - if (!world.isRemote()) + if (!level.isClientSide()) capability.orElse(null) .setStalledExternally(isStalled); } else { if (isStalled) { if (!wasStalled) - motionBeforeStall = riding.getMotion(); - riding.setMotion(0, 0, 0); + motionBeforeStall = riding.getDeltaMovement(); + riding.setDeltaMovement(0, 0, 0); } if (wasStalled && !isStalled) { - riding.setMotion(motionBeforeStall); + riding.setDeltaMovement(motionBeforeStall); motionBeforeStall = Vector3d.ZERO; } } - if (world.isRemote) + if (level.isClientSide) return; if (!isStalled()) { @@ -328,10 +330,10 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { Vector3d positionVec = coupledCarts.getFirst() .cart() - .getPositionVec(); + .position(); Vector3d coupledVec = coupledCarts.getSecond() .cart() - .getPositionVec(); + .position(); double diffX = positionVec.x - coupledVec.x; double diffY = positionVec.y - coupledVec.y; @@ -342,7 +344,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { yaw = (float) (MathHelper.atan2(diffZ, diffX) * 180 / Math.PI); pitch = (float) (Math.atan2(diffY, Math.sqrt(diffX * diffX + diffZ * diffZ)) * 180 / Math.PI); - if (getCouplingId().equals(riding.getUniqueID())) { + if (getCouplingId().equals(riding.getUUID())) { pitch *= -1; yaw += 180; } @@ -359,7 +361,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { return false; OrientedContraptionEntity parent = (OrientedContraptionEntity) riding; prevYaw = yaw; - yaw = -parent.getYaw(1); + yaw = -parent.getViewYRot(1); return false; } @@ -368,9 +370,9 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { return false; boolean rotating = false; - Vector3d movementVector = riding.getMotion(); - Vector3d locationDiff = riding.getPositionVec() - .subtract(riding.prevPosX, riding.prevPosY, riding.prevPosZ); + Vector3d movementVector = riding.getDeltaMovement(); + Vector3d locationDiff = riding.position() + .subtract(riding.xo, riding.yo, riding.zo); if (!(riding instanceof AbstractMinecartEntity)) movementVector = locationDiff; Vector3d motion = movementVector.normalize(); @@ -379,11 +381,11 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { if (riding instanceof AbstractMinecartEntity) { AbstractMinecartEntity minecartEntity = (AbstractMinecartEntity) riding; BlockPos railPosition = minecartEntity.getCurrentRailPosition(); - BlockState blockState = world.getBlockState(railPosition); + BlockState blockState = level.getBlockState(railPosition); if (blockState.getBlock() instanceof AbstractRailBlock) { AbstractRailBlock abstractRailBlock = (AbstractRailBlock) blockState.getBlock(); RailShape railDirection = - abstractRailBlock.getRailDirection(blockState, world, railPosition, minecartEntity); + abstractRailBlock.getRailDirection(blockState, level, railPosition, minecartEntity); motion = VecHelper.project(motion, MinecartSim2020.getRailVec(railDirection)); } } @@ -397,7 +399,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } prevYaw = yaw; - float maxApproachSpeed = (float) (motion.length() * 12f / (Math.max(1, getBoundingBox().getXSize() / 6f))); + float maxApproachSpeed = (float) (motion.length() * 12f / (Math.max(1, getBoundingBox().getXsize() / 6f))); float approach = AngleHelper.getShortestAngleDiff(yaw, targetYaw); approach = MathHelper.clamp(approach, -maxApproachSpeed, maxApproachSpeed); yaw += approach; @@ -427,15 +429,15 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { int i = MathHelper.floor(furnaceCart.getX()); int j = MathHelper.floor(furnaceCart.getY()); int k = MathHelper.floor(furnaceCart.getZ()); - if (furnaceCart.world.getBlockState(new BlockPos(i, j - 1, k)) - .isIn(BlockTags.RAILS)) + if (furnaceCart.level.getBlockState(new BlockPos(i, j - 1, k)) + .is(BlockTags.RAILS)) --j; BlockPos blockpos = new BlockPos(i, j, k); - BlockState blockstate = this.world.getBlockState(blockpos); - if (furnaceCart.canUseRail() && blockstate.isIn(BlockTags.RAILS)) + BlockState blockstate = this.level.getBlockState(blockpos); + if (furnaceCart.canUseRail() && blockstate.is(BlockTags.RAILS)) if (fuel > 1) - riding.setMotion(riding.getMotion() + riding.setDeltaMovement(riding.getDeltaMovement() .normalize() .scale(1)); if (fuel < 5 && contraption != null) { @@ -457,11 +459,11 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { UUID couplingId = getCouplingId(); if (couplingId == null) return null; - MinecartController controller = CapabilityMinecartController.getIfPresent(world, couplingId); + MinecartController controller = CapabilityMinecartController.getIfPresent(level, couplingId); if (controller == null || !controller.isPresent()) return null; UUID coupledCart = controller.getCoupledCart(true); - MinecartController coupledController = CapabilityMinecartController.getIfPresent(world, coupledCart); + MinecartController coupledController = CapabilityMinecartController.getIfPresent(level, coupledCart); if (coupledController == null || !coupledController.isPresent()) return null; return Couple.create(controller, coupledController); @@ -480,18 +482,18 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } @Override - public CompoundNBT writeWithoutTypeId(CompoundNBT nbt) { - return isSerializingFurnaceCart ? nbt : super.writeWithoutTypeId(nbt); + public CompoundNBT saveWithoutId(CompoundNBT nbt) { + return isSerializingFurnaceCart ? nbt : super.saveWithoutId(nbt); } @Nullable public UUID getCouplingId() { - Optional uuid = dataManager.get(COUPLING); + Optional uuid = entityData.get(COUPLING); return uuid == null ? null : uuid.isPresent() ? uuid.get() : null; } public void setCouplingId(UUID id) { - dataManager.set(COUPLING, Optional.ofNullable(id)); + entityData.set(COUPLING, Optional.ofNullable(id)); } @Override @@ -519,25 +521,25 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { @OnlyIn(Dist.CLIENT) public void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks) { float angleInitialYaw = getInitialYaw(); - float angleYaw = getYaw(partialTicks); - float anglePitch = getPitch(partialTicks); + float angleYaw = getViewYRot(partialTicks); + float anglePitch = getViewXRot(partialTicks); for (MatrixStack stack : matrixStacks) stack.translate(-.5f, 0, -.5f); - Entity ridingEntity = getRidingEntity(); + Entity ridingEntity = getVehicle(); if (ridingEntity instanceof AbstractMinecartEntity) repositionOnCart(partialTicks, matrixStacks, ridingEntity); else if (ridingEntity instanceof AbstractContraptionEntity) { - if (ridingEntity.getRidingEntity() instanceof AbstractMinecartEntity) - repositionOnCart(partialTicks, matrixStacks, ridingEntity.getRidingEntity()); + if (ridingEntity.getVehicle() instanceof AbstractMinecartEntity) + repositionOnCart(partialTicks, matrixStacks, ridingEntity.getVehicle()); else repositionOnContraption(partialTicks, matrixStacks, ridingEntity); } for (MatrixStack stack : matrixStacks) MatrixStacker.of(stack) - .nudge(getEntityId()) + .nudge(getId()) .centre() .rotateY(angleYaw) .rotateZ(anglePitch) @@ -569,9 +571,9 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { private Vector3d getContraptionOffset(float partialTicks, Entity ridingEntity) { AbstractContraptionEntity parent = (AbstractContraptionEntity) ridingEntity; Vector3d passengerPosition = parent.getPassengerPosition(this, partialTicks); - double x = passengerPosition.x - MathHelper.lerp(partialTicks, this.lastTickPosX, this.getX()); - double y = passengerPosition.y - MathHelper.lerp(partialTicks, this.lastTickPosY, this.getY()); - double z = passengerPosition.z - MathHelper.lerp(partialTicks, this.lastTickPosZ, this.getZ()); + double x = passengerPosition.x - MathHelper.lerp(partialTicks, this.xOld, this.getX()); + double y = passengerPosition.y - MathHelper.lerp(partialTicks, this.yOld, this.getY()); + double z = passengerPosition.z - MathHelper.lerp(partialTicks, this.zOld, this.getZ()); return new Vector3d(x, y, z); } @@ -579,14 +581,14 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { @OnlyIn(Dist.CLIENT) private Vector3d getCartOffset(float partialTicks, Entity ridingEntity) { AbstractMinecartEntity cart = (AbstractMinecartEntity) ridingEntity; - double cartX = MathHelper.lerp(partialTicks, cart.lastTickPosX, cart.getX()); - double cartY = MathHelper.lerp(partialTicks, cart.lastTickPosY, cart.getY()); - double cartZ = MathHelper.lerp(partialTicks, cart.lastTickPosZ, cart.getZ()); + double cartX = MathHelper.lerp(partialTicks, cart.xOld, cart.getX()); + double cartY = MathHelper.lerp(partialTicks, cart.yOld, cart.getY()); + double cartZ = MathHelper.lerp(partialTicks, cart.zOld, cart.getZ()); Vector3d cartPos = cart.getPos(cartX, cartY, cartZ); if (cartPos != null) { - Vector3d cartPosFront = cart.getPosOffset(cartX, cartY, cartZ, (double) 0.3F); - Vector3d cartPosBack = cart.getPosOffset(cartX, cartY, cartZ, (double) -0.3F); + Vector3d cartPosFront = cart.getPosOffs(cartX, cartY, cartZ, (double) 0.3F); + Vector3d cartPosBack = cart.getPosOffs(cartX, cartY, cartZ, (double) -0.3F); if (cartPosFront == null) cartPosFront = cartPos; if (cartPosBack == null) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntityRenderer.java index d1cfea7c5..a2fa2b4ab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntityRenderer.java @@ -15,7 +15,7 @@ public class OrientedContraptionEntityRenderer extends ContraptionEntityRenderer if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_)) return false; if (entity.getContraption() - .getType() == ContraptionType.MOUNTED && entity.getRidingEntity() == null) + .getType() == ContraptionType.MOUNTED && entity.getVehicle() == null) return false; return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/StructureTransform.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/StructureTransform.java index 225cbc02f..67aab845a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/StructureTransform.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/StructureTransform.java @@ -97,7 +97,7 @@ public class StructureTransform { } public Vector3d apply(Vector3d localVec) { - return applyWithoutOffset(localVec).add(Vector3d.of(offset)); + return applyWithoutOffset(localVec).add(Vector3d.atLowerCornerOf(offset)); } public BlockPos applyWithoutOffset(BlockPos localPos) { @@ -105,7 +105,7 @@ public class StructureTransform { } public BlockPos apply(BlockPos localPos) { - return applyWithoutOffset(localPos).add(offset); + return applyWithoutOffset(localPos).offset(offset); } public void apply(TileEntity te) { @@ -126,11 +126,11 @@ public class StructureTransform { if (rotationAxis == Axis.Y) { if (block instanceof BellBlock) { - if (state.get(BlockStateProperties.BELL_ATTACHMENT) == BellAttachment.DOUBLE_WALL) { - state = state.with(BlockStateProperties.BELL_ATTACHMENT, BellAttachment.SINGLE_WALL); + if (state.getValue(BlockStateProperties.BELL_ATTACHMENT) == BellAttachment.DOUBLE_WALL) { + state = state.setValue(BlockStateProperties.BELL_ATTACHMENT, BellAttachment.SINGLE_WALL); } - return state.with(HorizontalFaceBlock.HORIZONTAL_FACING, - rotation.rotate(state.get(HorizontalFaceBlock.HORIZONTAL_FACING))); + return state.setValue(HorizontalFaceBlock.FACING, + rotation.rotate(state.getValue(HorizontalFaceBlock.FACING))); } return state.rotate(rotation); } @@ -139,30 +139,30 @@ public class StructureTransform { return rotateChassis(state); if (block instanceof HorizontalFaceBlock) { - Direction stateFacing = state.get(HorizontalFaceBlock.HORIZONTAL_FACING); - AttachFace stateFace = state.get(FACE); + Direction stateFacing = state.getValue(HorizontalFaceBlock.FACING); + AttachFace stateFace = state.getValue(FACE); Direction forcedAxis = rotationAxis == Axis.Z ? Direction.EAST : Direction.SOUTH; if (stateFacing.getAxis() == rotationAxis && stateFace == AttachFace.WALL) return state; for (int i = 0; i < rotation.ordinal(); i++) { - stateFace = state.get(FACE); - stateFacing = state.get(HorizontalFaceBlock.HORIZONTAL_FACING); + stateFace = state.getValue(FACE); + stateFacing = state.getValue(HorizontalFaceBlock.FACING); - boolean b = state.get(FACE) == AttachFace.CEILING; - state = state.with(HORIZONTAL_FACING, b ? forcedAxis : forcedAxis.getOpposite()); + boolean b = state.getValue(FACE) == AttachFace.CEILING; + state = state.setValue(HORIZONTAL_FACING, b ? forcedAxis : forcedAxis.getOpposite()); if (stateFace != AttachFace.WALL) { - state = state.with(FACE, AttachFace.WALL); + state = state.setValue(FACE, AttachFace.WALL); continue; } if (stateFacing.getAxisDirection() == AxisDirection.POSITIVE) { - state = state.with(FACE, AttachFace.FLOOR); + state = state.setValue(FACE, AttachFace.FLOOR); continue; } - state = state.with(FACE, AttachFace.CEILING); + state = state.setValue(FACE, AttachFace.CEILING); } return state; @@ -179,51 +179,51 @@ public class StructureTransform { return state; } - if (state.contains(FACING)) { - Direction newFacing = transformFacing(state.get(FACING)); - if (state.contains(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE)) { + if (state.hasProperty(FACING)) { + Direction newFacing = transformFacing(state.getValue(FACING)); + if (state.hasProperty(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE)) { if (rotationAxis == newFacing.getAxis() && rotation.ordinal() % 2 == 1) state = state.cycle(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE); } - state = state.with(FACING, newFacing); + state = state.setValue(FACING, newFacing); - } else if (state.contains(AXIS)) { - state = state.with(AXIS, transformAxis(state.get(AXIS))); + } else if (state.hasProperty(AXIS)) { + state = state.setValue(AXIS, transformAxis(state.getValue(AXIS))); } else if (halfTurn) { - if (state.contains(FACING)) { - Direction stateFacing = state.get(FACING); + if (state.hasProperty(FACING)) { + Direction stateFacing = state.getValue(FACING); if (stateFacing.getAxis() == rotationAxis) return state; } - if (state.contains(HORIZONTAL_FACING)) { - Direction stateFacing = state.get(HORIZONTAL_FACING); + if (state.hasProperty(HORIZONTAL_FACING)) { + Direction stateFacing = state.getValue(HORIZONTAL_FACING); if (stateFacing.getAxis() == rotationAxis) return state; } state = state.rotate(rotation); - if (state.contains(SlabBlock.TYPE) && state.get(SlabBlock.TYPE) != SlabType.DOUBLE) - state = state.with(SlabBlock.TYPE, - state.get(SlabBlock.TYPE) == SlabType.BOTTOM ? SlabType.TOP : SlabType.BOTTOM); + if (state.hasProperty(SlabBlock.TYPE) && state.getValue(SlabBlock.TYPE) != SlabType.DOUBLE) + state = state.setValue(SlabBlock.TYPE, + state.getValue(SlabBlock.TYPE) == SlabType.BOTTOM ? SlabType.TOP : SlabType.BOTTOM); } return state; } protected BlockState transformStairs(BlockState state, boolean halfTurn) { - if (state.get(StairsBlock.FACING) + if (state.getValue(StairsBlock.FACING) .getAxis() != rotationAxis) { for (int i = 0; i < rotation.ordinal(); i++) { - Direction direction = state.get(StairsBlock.FACING); - Half half = state.get(StairsBlock.HALF); + Direction direction = state.getValue(StairsBlock.FACING); + Half half = state.getValue(StairsBlock.HALF); if (direction.getAxisDirection() == AxisDirection.POSITIVE ^ half == Half.BOTTOM ^ direction.getAxis() == Axis.Z) state = state.cycle(StairsBlock.HALF); else - state = state.with(StairsBlock.FACING, direction.getOpposite()); + state = state.setValue(StairsBlock.FACING, direction.getOpposite()); } } else { if (halfTurn) { @@ -234,14 +234,14 @@ public class StructureTransform { } protected BlockState transformBelt(BlockState state, boolean halfTurn) { - Direction initialDirection = state.get(BeltBlock.HORIZONTAL_FACING); + Direction initialDirection = state.getValue(BeltBlock.HORIZONTAL_FACING); boolean diagonal = - state.get(BeltBlock.SLOPE) == BeltSlope.DOWNWARD || state.get(BeltBlock.SLOPE) == BeltSlope.UPWARD; + state.getValue(BeltBlock.SLOPE) == BeltSlope.DOWNWARD || state.getValue(BeltBlock.SLOPE) == BeltSlope.UPWARD; if (!diagonal) { for (int i = 0; i < rotation.ordinal(); i++) { - Direction direction = state.get(BeltBlock.HORIZONTAL_FACING); - BeltSlope slope = state.get(BeltBlock.SLOPE); + Direction direction = state.getValue(BeltBlock.HORIZONTAL_FACING); + BeltSlope slope = state.getValue(BeltBlock.SLOPE); boolean vertical = slope == BeltSlope.VERTICAL; boolean horizontal = slope == BeltSlope.HORIZONTAL; boolean sideways = slope == BeltSlope.SIDEWAYS; @@ -251,7 +251,7 @@ public class StructureTransform { if (vertical) { if (direction.getAxis() == rotationAxis) { - newDirection = direction.rotateYCCW(); + newDirection = direction.getCounterClockWise(); newSlope = BeltSlope.SIDEWAYS; } else { newSlope = BeltSlope.HORIZONTAL; @@ -266,7 +266,7 @@ public class StructureTransform { if (direction.getAxis() == rotationAxis) newSlope = BeltSlope.HORIZONTAL; else - newDirection = direction.rotateYCCW(); + newDirection = direction.getCounterClockWise(); } if (horizontal) { @@ -277,44 +277,44 @@ public class StructureTransform { newDirection = direction.getOpposite(); } - state = state.with(BeltBlock.HORIZONTAL_FACING, newDirection); - state = state.with(BeltBlock.SLOPE, newSlope); + state = state.setValue(BeltBlock.HORIZONTAL_FACING, newDirection); + state = state.setValue(BeltBlock.SLOPE, newSlope); } } else if (initialDirection.getAxis() != rotationAxis) { for (int i = 0; i < rotation.ordinal(); i++) { - Direction direction = state.get(BeltBlock.HORIZONTAL_FACING); + Direction direction = state.getValue(BeltBlock.HORIZONTAL_FACING); Direction newDirection = direction.getOpposite(); - BeltSlope slope = state.get(BeltBlock.SLOPE); + BeltSlope slope = state.getValue(BeltBlock.SLOPE); boolean upward = slope == BeltSlope.UPWARD; boolean downward = slope == BeltSlope.DOWNWARD; // Rotate diagonal if (direction.getAxisDirection() == AxisDirection.POSITIVE ^ downward ^ direction.getAxis() == Axis.Z) { - state = state.with(BeltBlock.SLOPE, upward ? BeltSlope.DOWNWARD : BeltSlope.UPWARD); + state = state.setValue(BeltBlock.SLOPE, upward ? BeltSlope.DOWNWARD : BeltSlope.UPWARD); } else { - state = state.with(BeltBlock.HORIZONTAL_FACING, newDirection); + state = state.setValue(BeltBlock.HORIZONTAL_FACING, newDirection); } } } else if (halfTurn) { - Direction direction = state.get(BeltBlock.HORIZONTAL_FACING); + Direction direction = state.getValue(BeltBlock.HORIZONTAL_FACING); Direction newDirection = direction.getOpposite(); - BeltSlope slope = state.get(BeltBlock.SLOPE); + BeltSlope slope = state.getValue(BeltBlock.SLOPE); boolean vertical = slope == BeltSlope.VERTICAL; if (diagonal) { - state = state.with(BeltBlock.SLOPE, slope == BeltSlope.UPWARD ? BeltSlope.DOWNWARD + state = state.setValue(BeltBlock.SLOPE, slope == BeltSlope.UPWARD ? BeltSlope.DOWNWARD : slope == BeltSlope.DOWNWARD ? BeltSlope.UPWARD : slope); } else if (vertical) { - state = state.with(BeltBlock.HORIZONTAL_FACING, newDirection); + state = state.setValue(BeltBlock.HORIZONTAL_FACING, newDirection); } } return state; } public Axis transformAxis(Axis axisIn) { - Direction facing = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axisIn); + Direction facing = Direction.get(AxisDirection.POSITIVE, axisIn); facing = transformFacing(facing); Axis axis = facing.getAxis(); return axis; @@ -332,23 +332,23 @@ public class StructureTransform { if (rotation == Rotation.NONE) return state; - BlockState rotated = state.with(AXIS, transformAxis(state.get(AXIS))); + BlockState rotated = state.setValue(AXIS, transformAxis(state.getValue(AXIS))); AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock(); for (Direction face : Iterate.directions) { BooleanProperty glueableSide = block.getGlueableSide(rotated, face); if (glueableSide != null) - rotated = rotated.with(glueableSide, false); + rotated = rotated.setValue(glueableSide, false); } for (Direction face : Iterate.directions) { BooleanProperty glueableSide = block.getGlueableSide(state, face); - if (glueableSide == null || !state.get(glueableSide)) + if (glueableSide == null || !state.getValue(glueableSide)) continue; Direction rotatedFacing = transformFacing(face); BooleanProperty rotatedGlueableSide = block.getGlueableSide(rotated, rotatedFacing); if (rotatedGlueableSide != null) - rotated = rotated.with(rotatedGlueableSide, true); + rotated = rotated.setValue(rotatedGlueableSide, true); } return rotated; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/TranslatingContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/TranslatingContraption.java index a692a112a..a28788f0e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/TranslatingContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/TranslatingContraption.java @@ -22,7 +22,7 @@ public abstract class TranslatingContraption extends Contraption { cachedColliderDirection = movementDirection; for (BlockInfo info : getBlocks().values()) { - BlockPos offsetPos = info.pos.offset(movementDirection); + BlockPos offsetPos = info.pos.relative(movementDirection); if (info.state.getCollisionShape(world, offsetPos) .isEmpty()) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingBlock.java index 66e55acbe..bfd702852 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingBlock.java @@ -11,6 +11,8 @@ import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorldReader; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class BearingBlock extends DirectionalKineticBlock { public BearingBlock(Properties properties) { @@ -19,12 +21,12 @@ public abstract class BearingBlock extends DirectionalKineticBlock { @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face == state.get(FACING).getOpposite(); + return face == state.getValue(FACING).getOpposite(); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(FACING).getAxis(); + return state.getValue(FACING).getAxis(); } @Override @@ -35,8 +37,8 @@ public abstract class BearingBlock extends DirectionalKineticBlock { @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { ActionResultType resultType = super.onWrenched(state, context); - if (!context.getWorld().isRemote && resultType.isAccepted()) { - TileEntity te = context.getWorld().getTileEntity(context.getPos()); + if (!context.getLevel().isClientSide && resultType.consumesAction()) { + TileEntity te = context.getLevel().getBlockEntity(context.getClickedPos()); if (te instanceof MechanicalBearingTileEntity) { ((MechanicalBearingTileEntity) te).disassemble(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption.java index 8e1e60aa6..871ce7a0f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption.java @@ -34,7 +34,7 @@ public class BearingContraption extends Contraption { @Override public boolean assemble(World world, BlockPos pos) throws AssemblyException { - BlockPos offset = pos.offset(facing); + BlockPos offset = pos.relative(facing); if (!searchMovedStructure(world, offset, null)) return false; startMoving(world); @@ -53,7 +53,7 @@ public class BearingContraption extends Contraption { @Override protected boolean isAnchoringBlockAt(BlockPos pos) { - return pos.equals(anchor.offset(facing.getOpposite())); + return pos.equals(anchor.relative(facing.getOpposite())); } @Override @@ -68,14 +68,14 @@ public class BearingContraption extends Contraption { public CompoundNBT writeNBT(boolean spawnPacket) { CompoundNBT tag = super.writeNBT(spawnPacket); tag.putInt("Sails", sailBlocks); - tag.putInt("Facing", facing.getIndex()); + tag.putInt("Facing", facing.get3DDataValue()); return tag; } @Override public void readNBT(World world, CompoundNBT tag, boolean spawnData) { sailBlocks = tag.getInt("Sails"); - facing = Direction.byIndex(tag.getInt("Facing")); + facing = Direction.from3DDataValue(tag.getInt("Facing")); super.readNBT(world, tag, spawnData); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java index 52febb972..67f2cb537 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java @@ -27,8 +27,8 @@ public class BearingInstance e super(modelManager, tile); this.bearing = tile; - Direction facing = blockState.get(BlockStateProperties.FACING); - rotationAxis = Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector(); + Direction facing = blockState.getValue(BlockStateProperties.FACING); + rotationAxis = Direction.get(Direction.AxisDirection.POSITIVE, axis).step(); blockOrientation = getBlockStateOrientation(facing); @@ -44,9 +44,9 @@ public class BearingInstance e public void beginFrame() { float interpolatedAngle = bearing.getInterpolatedAngle(AnimationTickHolder.getPartialTicks() - 1); - Quaternion rot = rotationAxis.getDegreesQuaternion(interpolatedAngle); + Quaternion rot = rotationAxis.rotationDegrees(interpolatedAngle); - rot.multiply(blockOrientation); + rot.mul(blockOrientation); topInstance.setRotation(rot); } @@ -67,12 +67,12 @@ public class BearingInstance e Quaternion orientation; if (facing.getAxis().isHorizontal()) { - orientation = Vector3f.POSITIVE_Y.getDegreesQuaternion(AngleHelper.horizontalAngle(facing.getOpposite())); + orientation = Vector3f.YP.rotationDegrees(AngleHelper.horizontalAngle(facing.getOpposite())); } else { - orientation = Quaternion.IDENTITY.copy(); + orientation = Quaternion.ONE.copy(); } - orientation.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90 - AngleHelper.verticalAngle(facing))); + orientation.mul(Vector3f.XP.rotationDegrees(-90 - AngleHelper.verticalAngle(facing))); return orientation; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java index 0d23f7523..e8521f53b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java @@ -26,13 +26,13 @@ public class BearingRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); IBearingTileEntity bearingTe = (IBearingTileEntity) te; final Direction facing = te.getBlockState() - .get(BlockStateProperties.FACING); + .getValue(BlockStateProperties.FACING); PartialModel top = bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP; SuperByteBuffer superBuffer = PartialBufferer.get(top, te.getBlockState()); @@ -45,13 +45,13 @@ public class BearingRenderer extends KineticTileEntityRenderer { superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite()))); superBuffer.rotateCentered(Direction.EAST, AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing))); - superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + superBuffer.renderInto(ms, buffer.getBuffer(RenderType.solid())); } @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() - .get(BearingBlock.FACING) + .getValue(BearingBlock.FACING) .getOpposite()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkBearingBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkBearingBlock.java index 125950656..eb84c4af1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkBearingBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkBearingBlock.java @@ -14,6 +14,8 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class ClockworkBearingBlock extends BearingBlock implements ITE { public ClockworkBearingBlock(Properties properties) { @@ -26,14 +28,14 @@ public class ClockworkBearingBlock extends BearingBlock implements ITE { if (te.running) { te.disassemble(); @@ -55,8 +57,8 @@ public class ClockworkBearingBlock extends BearingBlock implements ITE contraption; try { - contraption = ClockworkContraption.assembleClockworkAt(world, pos, direction); + contraption = ClockworkContraption.assembleClockworkAt(level, worldPosition, direction); lastException = null; } catch (AssemblyException e) { lastException = e; @@ -230,25 +230,25 @@ public class ClockworkBearingTileEntity extends KineticTileEntity .getBlocks() .isEmpty()) return; - BlockPos anchor = pos.offset(direction); + BlockPos anchor = worldPosition.relative(direction); contraption.getLeft() - .removeBlocksFromWorld(world, BlockPos.ZERO); - hourHand = ControlledContraptionEntity.create(world, this, contraption.getLeft()); - hourHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); + .removeBlocksFromWorld(level, BlockPos.ZERO); + hourHand = ControlledContraptionEntity.create(level, this, contraption.getLeft()); + hourHand.setPos(anchor.getX(), anchor.getY(), anchor.getZ()); hourHand.setRotationAxis(direction.getAxis()); - world.addEntity(hourHand); + level.addFreshEntity(hourHand); - AllTriggers.triggerForNearbyPlayers(AllTriggers.CLOCKWORK_BEARING, world, pos, 5); + AllTriggers.triggerForNearbyPlayers(AllTriggers.CLOCKWORK_BEARING, level, worldPosition, 5); if (contraption.getRight() != null) { - anchor = pos.offset(direction, contraption.getRight().offset + 1); + anchor = worldPosition.relative(direction, contraption.getRight().offset + 1); contraption.getRight() - .removeBlocksFromWorld(world, BlockPos.ZERO); - minuteHand = ControlledContraptionEntity.create(world, this, contraption.getRight()); - minuteHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); + .removeBlocksFromWorld(level, BlockPos.ZERO); + minuteHand = ControlledContraptionEntity.create(level, this, contraption.getRight()); + minuteHand.setPos(anchor.getX(), anchor.getY(), anchor.getZ()); minuteHand.setRotationAxis(direction.getAxis()); - world.addEntity(minuteHand); + level.addFreshEntity(minuteHand); } // Run @@ -284,17 +284,17 @@ public class ClockworkBearingTileEntity extends KineticTileEntity return; ClockworkContraption cc = (ClockworkContraption) contraption.getContraption(); - markDirty(); - Direction facing = getBlockState().get(BlockStateProperties.FACING); - BlockPos anchor = pos.offset(facing, cc.offset + 1); + setChanged(); + Direction facing = getBlockState().getValue(BlockStateProperties.FACING); + BlockPos anchor = worldPosition.relative(facing, cc.offset + 1); if (cc.handType == HandType.HOUR) { this.hourHand = contraption; - hourHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); + hourHand.setPos(anchor.getX(), anchor.getY(), anchor.getZ()); } else { this.minuteHand = contraption; - minuteHand.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); + minuteHand.setPos(anchor.getX(), anchor.getY(), anchor.getZ()); } - if (!world.isRemote) { + if (!level.isClientSide) { this.running = true; sendData(); } @@ -356,15 +356,15 @@ public class ClockworkBearingTileEntity extends KineticTileEntity @Override public void onStall() { - if (!world.isRemote) + if (!level.isClientSide) sendData(); } @Override - public void remove() { - if (!world.isRemote) + public void setRemoved() { + if (!level.isClientSide) disassemble(); - super.remove(); + super.setRemoved(); } @Override @@ -415,7 +415,7 @@ public class ClockworkBearingTileEntity extends KineticTileEntity @Override public BlockPos getBlockPosition() { - return pos; + return worldPosition; } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkContraption.java index 949228ba9..7c0af2c70 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/ClockworkContraption.java @@ -31,12 +31,12 @@ public class ClockworkContraption extends Contraption { private void ignoreBlocks(Set blocks, BlockPos anchor) { for (BlockPos blockPos : blocks) - ignoreBlocks.add(anchor.add(blockPos)); + ignoreBlocks.add(anchor.offset(blockPos)); } @Override protected boolean isAnchoringBlockAt(BlockPos pos) { - return pos.equals(anchor.offset(facing.getOpposite(), offset + 1)); + return pos.equals(anchor.relative(facing.getOpposite(), offset + 1)); } public static Pair assembleClockworkAt(World world, BlockPos pos, @@ -51,7 +51,7 @@ public class ClockworkContraption extends Contraption { if (!hourArm.assemble(world, pos)) return null; for (int i = 0; i < 16; i++) { - BlockPos offsetPos = BlockPos.ZERO.offset(direction, i); + BlockPos offsetPos = BlockPos.ZERO.relative(direction, i); if (hourArm.getBlocks() .containsKey(offsetPos)) continue; @@ -89,7 +89,7 @@ public class ClockworkContraption extends Contraption { @Override public boolean searchMovedStructure(World world, BlockPos pos, Direction direction) throws AssemblyException { - return super.searchMovedStructure(world, pos.offset(direction, offset + 1), null); + return super.searchMovedStructure(world, pos.relative(direction, offset + 1), null); } @Override @@ -105,7 +105,7 @@ public class ClockworkContraption extends Contraption { @Override public CompoundNBT writeNBT(boolean spawnPacket) { CompoundNBT tag = super.writeNBT(spawnPacket); - tag.putInt("facing", facing.getIndex()); + tag.putInt("facing", facing.get3DDataValue()); tag.putInt("offset", offset); NBTHelper.writeEnum(tag, "HandType", handType); return tag; @@ -113,7 +113,7 @@ public class ClockworkContraption extends Contraption { @Override public void readNBT(World world, CompoundNBT tag, boolean spawnData) { - facing = Direction.byIndex(tag.getInt("facing")); + facing = Direction.from3DDataValue(tag.getInt("facing")); handType = NBTHelper.readEnum(tag, "HandType", HandType.class); offset = tag.getInt("offset"); super.readNBT(world, tag, spawnData); @@ -121,7 +121,7 @@ public class ClockworkContraption extends Contraption { @Override public boolean canBeStabilized(Direction facing, BlockPos localPos) { - if (BlockPos.ZERO.equals(localPos) || BlockPos.ZERO.equals(localPos.offset(facing))) + if (BlockPos.ZERO.equals(localPos) || BlockPos.ZERO.equals(localPos.relative(facing))) return false; return facing.getAxis() == this.facing.getAxis(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/IBearingTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/IBearingTileEntity.java index e729feae4..af8a52b22 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/IBearingTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/IBearingTileEntity.java @@ -15,7 +15,7 @@ public interface IBearingTileEntity extends IControlContraption { default ValueBoxTransform getMovementModeSlot() { return new DirectionalExtenderScrollOptionSlot((state, d) -> { Axis axis = d.getAxis(); - Axis bearingAxis = state.get(BearingBlock.FACING) + Axis bearingAxis = state.getValue(BearingBlock.FACING) .getAxis(); return bearingAxis != axis; }); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingBlock.java index 9bf59c537..6114db22d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingBlock.java @@ -13,6 +13,8 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class MechanicalBearingBlock extends BearingBlock implements ITE { public MechanicalBearingBlock(Properties properties) { @@ -25,15 +27,15 @@ public class MechanicalBearingBlock extends BearingBlock implements ITE { if (te.running) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingTileEntity.java index ef692c0a3..7c90fcc94 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingTileEntity.java @@ -27,6 +27,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; +import com.simibubi.create.content.contraptions.components.structureMovement.IControlContraption.RotationMode; + public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity implements IBearingTileEntity, IDisplayAssemblyExceptions { @@ -60,10 +62,10 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity } @Override - public void remove() { - if (!world.isRemote) + public void setRemoved() { + if (!level.isClientSide) disassemble(); - super.remove(); + super.setRemoved(); } @Override @@ -111,7 +113,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity if (movedContraption != null && Math.signum(prevSpeed) != Math.signum(getSpeed()) && prevSpeed != 0) { movedContraption.getContraption() - .stop(world); + .stop(level); } } @@ -119,7 +121,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity float speed = convertToAngular(isWindmill() ? getGeneratedSpeed() : getSpeed()); if (getSpeed() == 0) speed = 0; - if (world.isRemote) { + if (level.isClientSide) { speed *= ServerSpeedProvider.get(); speed += clientAngleDiff / 3f; } @@ -137,18 +139,18 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity @Override public BlockPos getBlockPosition() { - return pos; + return worldPosition; } public void assemble() { - if (!(world.getBlockState(pos) + if (!(level.getBlockState(worldPosition) .getBlock() instanceof BearingBlock)) return; - Direction direction = getBlockState().get(FACING); + Direction direction = getBlockState().getValue(FACING); BearingContraption contraption = new BearingContraption(isWindmill(), direction); try { - if (!contraption.assemble(world, pos)) + if (!contraption.assemble(level, worldPosition)) return; lastException = null; @@ -159,18 +161,18 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity } if (isWindmill()) - AllTriggers.triggerForNearbyPlayers(AllTriggers.WINDMILL, world, pos, 5); + AllTriggers.triggerForNearbyPlayers(AllTriggers.WINDMILL, level, worldPosition, 5); if (contraption.getSailBlocks() >= 16 * 8) - AllTriggers.triggerForNearbyPlayers(AllTriggers.MAXED_WINDMILL, world, pos, 5); + AllTriggers.triggerForNearbyPlayers(AllTriggers.MAXED_WINDMILL, level, worldPosition, 5); - contraption.removeBlocksFromWorld(world, BlockPos.ZERO); - movedContraption = ControlledContraptionEntity.create(world, this, contraption); - BlockPos anchor = pos.offset(direction); - movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); + contraption.removeBlocksFromWorld(level, BlockPos.ZERO); + movedContraption = ControlledContraptionEntity.create(level, this, contraption); + BlockPos anchor = worldPosition.relative(direction); + movedContraption.setPos(anchor.getX(), anchor.getY(), anchor.getZ()); movedContraption.setRotationAxis(direction.getAxis()); - world.addEntity(movedContraption); + level.addFreshEntity(movedContraption); - AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(world, pos); + AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(level, worldPosition); running = true; angle = 0; @@ -186,7 +188,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity applyRotation(); if (movedContraption != null) { movedContraption.disassemble(); - AllSoundEvents.CONTRAPTION_DISASSEMBLE.playOnServer(world, pos); + AllSoundEvents.CONTRAPTION_DISASSEMBLE.playOnServer(level, worldPosition); } movedContraption = null; @@ -201,10 +203,10 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity super.tick(); prevAngle = angle; - if (world.isRemote) + if (level.isClientSide) clientAngleDiff /= 2; - if (!world.isRemote && assembleNextTick) { + if (!level.isClientSide && assembleNextTick) { assembleNextTick = false; if (running) { boolean canDisassemble = movementMode.get() == RotationMode.ROTATE_PLACE @@ -214,7 +216,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity .isEmpty())) { if (movedContraption != null) movedContraption.getContraption() - .stop(world); + .stop(level); disassemble(); return; } @@ -244,7 +246,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity @Override public void lazyTick() { super.lazyTick(); - if (movedContraption != null && !world.isRemote) + if (movedContraption != null && !level.isClientSide) sendData(); } @@ -253,8 +255,8 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity return; movedContraption.setAngle(angle); BlockState blockState = getBlockState(); - if (blockState.contains(BlockStateProperties.FACING)) - movedContraption.setRotationAxis(blockState.get(BlockStateProperties.FACING) + if (blockState.hasProperty(BlockStateProperties.FACING)) + movedContraption.setRotationAxis(blockState.getValue(BlockStateProperties.FACING) .getAxis()); } @@ -263,14 +265,14 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity BlockState blockState = getBlockState(); if (!(contraption.getContraption() instanceof BearingContraption)) return; - if (!blockState.contains(FACING)) + if (!blockState.hasProperty(FACING)) return; this.movedContraption = contraption; - markDirty(); - BlockPos anchor = pos.offset(blockState.get(FACING)); - movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); - if (!world.isRemote) { + setChanged(); + BlockPos anchor = worldPosition.relative(blockState.getValue(FACING)); + movedContraption.setPos(anchor.getX(), anchor.getY(), anchor.getZ()); + if (!level.isClientSide) { this.running = true; sendData(); } @@ -278,7 +280,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity @Override public void onStall() { - if (!world.isRemote) + if (!level.isClientSide) sendData(); } @@ -313,7 +315,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity if (!(state.getBlock() instanceof BearingBlock)) return false; - BlockState attachedState = world.getBlockState(pos.offset(state.get(BearingBlock.FACING))); + BlockState attachedState = level.getBlockState(worldPosition.relative(state.getValue(BearingBlock.FACING))); if (attachedState.getMaterial() .isReplaceable()) return false; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/SailBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/SailBlock.java index b4cfaea85..bdee280ce 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/SailBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/SailBlock.java @@ -41,6 +41,8 @@ import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class SailBlock extends ProperDirectionalBlock { public static SailBlock frame(Properties properties) { @@ -63,19 +65,19 @@ public class SailBlock extends ProperDirectionalBlock { @Override public BlockState getStateForPlacement(BlockItemUseContext context) { BlockState state = super.getStateForPlacement(context); - return state.with(FACING, state.get(FACING).getOpposite()); + return state.setValue(FACING, state.getValue(FACING).getOpposite()); } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { - ItemStack heldItem = player.getHeldItem(hand); + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { + ItemStack heldItem = player.getItemInHand(hand); IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId); if (placementHelper.matchesItem(heldItem)) return placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray); if (heldItem.getItem() instanceof ShearsItem) { - if (!world.isRemote) + if (!world.isClientSide) applyDye(state, world, pos, null); return ActionResultType.SUCCESS; } @@ -85,9 +87,9 @@ public class SailBlock extends ProperDirectionalBlock { for (DyeColor color : DyeColor.values()) { if (!heldItem.getItem() - .isIn(DyeHelper.getTagOfDye(color))) + .is(DyeHelper.getTagOfDye(color))) continue; - if (!world.isRemote) + if (!world.isClientSide) applyDye(state, world, pos, color); return ActionResultType.SUCCESS; } @@ -98,27 +100,27 @@ public class SailBlock extends ProperDirectionalBlock { protected void applyDye(BlockState state, World world, BlockPos pos, @Nullable DyeColor color) { BlockState newState = (color == null ? AllBlocks.SAIL_FRAME : AllBlocks.DYED_SAILS.get(color)).getDefaultState() - .with(FACING, state.get(FACING)); + .setValue(FACING, state.getValue(FACING)); // Dye the block itself if (state != newState) { - world.setBlockState(pos, newState); + world.setBlockAndUpdate(pos, newState); return; } // Dye all adjacent for (Direction d : Iterate.directions) { - if (d.getAxis() == state.get(FACING) + if (d.getAxis() == state.getValue(FACING) .getAxis()) continue; - BlockPos offset = pos.offset(d); + BlockPos offset = pos.relative(d); BlockState adjacentState = world.getBlockState(offset); Block block = adjacentState.getBlock(); if (!(block instanceof SailBlock) || ((SailBlock) block).frame) continue; if (state == adjacentState) continue; - world.setBlockState(offset, newState); + world.setBlockAndUpdate(offset, newState); return; } @@ -135,10 +137,10 @@ public class SailBlock extends ProperDirectionalBlock { visited.add(currentPos); for (Direction d : Iterate.directions) { - if (d.getAxis() == state.get(FACING) + if (d.getAxis() == state.getValue(FACING) .getAxis()) continue; - BlockPos offset = currentPos.offset(d); + BlockPos offset = currentPos.relative(d); if (visited.contains(offset)) continue; BlockState adjacentState = world.getBlockState(offset); @@ -146,7 +148,7 @@ public class SailBlock extends ProperDirectionalBlock { if (!(block instanceof SailBlock) || ((SailBlock) block).frame && color != null) continue; if (state != adjacentState) - world.setBlockState(offset, newState); + world.setBlockAndUpdate(offset, newState); frontier.add(offset); visited.add(offset); } @@ -155,13 +157,13 @@ public class SailBlock extends ProperDirectionalBlock { @Override public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - return (frame ? AllShapes.SAIL_FRAME : AllShapes.SAIL).get(state.get(FACING)); + return (frame ? AllShapes.SAIL_FRAME : AllShapes.SAIL).get(state.getValue(FACING)); } @Override public VoxelShape getCollisionShape(BlockState state, IBlockReader p_220071_2_, BlockPos p_220071_3_, ISelectionContext p_220071_4_) { if (frame) - return AllShapes.SAIL_FRAME_COLLISION.get(state.get(FACING)); + return AllShapes.SAIL_FRAME_COLLISION.get(state.getValue(FACING)); return getShape(state, p_220071_2_, p_220071_3_, p_220071_4_); } @@ -174,31 +176,31 @@ public class SailBlock extends ProperDirectionalBlock { return pickBlock; } - public void onFallenUpon(World p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { + public void fallOn(World p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { if (frame) - super.onFallenUpon(p_180658_1_, p_180658_2_, p_180658_3_, p_180658_4_); - super.onFallenUpon(p_180658_1_, p_180658_2_, p_180658_3_, 0); + super.fallOn(p_180658_1_, p_180658_2_, p_180658_3_, p_180658_4_); + super.fallOn(p_180658_1_, p_180658_2_, p_180658_3_, 0); } - public void onLanded(IBlockReader p_176216_1_, Entity p_176216_2_) { - if (frame || p_176216_2_.bypassesLandingEffects()) { - super.onLanded(p_176216_1_, p_176216_2_); + public void updateEntityAfterFallOn(IBlockReader p_176216_1_, Entity p_176216_2_) { + if (frame || p_176216_2_.isSuppressingBounce()) { + super.updateEntityAfterFallOn(p_176216_1_, p_176216_2_); } else { this.bounce(p_176216_2_); } } private void bounce(Entity p_226860_1_) { - Vector3d Vector3d = p_226860_1_.getMotion(); + Vector3d Vector3d = p_226860_1_.getDeltaMovement(); if (Vector3d.y < 0.0D) { double d0 = p_226860_1_ instanceof LivingEntity ? 1.0D : 0.8D; - p_226860_1_.setMotion(Vector3d.x, -Vector3d.y * (double) 0.26F * d0, Vector3d.z); + p_226860_1_.setDeltaMovement(Vector3d.x, -Vector3d.y * (double) 0.26F * d0, Vector3d.z); } } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } @@ -216,12 +218,12 @@ public class SailBlock extends ProperDirectionalBlock { @Override public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { - List directions = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getHitVec(), state.get(SailBlock.FACING).getAxis(), dir -> world.getBlockState(pos.offset(dir)).getMaterial().isReplaceable()); + List directions = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), state.getValue(SailBlock.FACING).getAxis(), dir -> world.getBlockState(pos.relative(dir)).getMaterial().isReplaceable()); if (directions.isEmpty()) return PlacementOffset.fail(); else { - return PlacementOffset.success(pos.offset(directions.get(0)), s -> s.with(FACING, state.get(FACING))); + return PlacementOffset.success(pos.relative(directions.get(0)), s -> s.setValue(FACING, state.getValue(FACING))); } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java index 9f7080e50..13c7b8836 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java @@ -27,8 +27,8 @@ public class StabilizedBearingInstance extends ActorInstance { BlockState blockState = context.state; - facing = blockState.get(BlockStateProperties.FACING); - rotationAxis = Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, facing.getAxis()).getUnitVector(); + facing = blockState.getValue(BlockStateProperties.FACING); + rotationAxis = Direction.get(Direction.AxisDirection.POSITIVE, facing.getAxis()).step(); blockOrientation = BearingInstance.getBlockStateOrientation(facing); @@ -43,9 +43,9 @@ public class StabilizedBearingInstance extends ActorInstance { public void beginFrame() { float counterRotationAngle = StabilizedBearingMovementBehaviour.getCounterRotationAngle(context, facing, AnimationTickHolder.getPartialTicks()); - Quaternion rotation = rotationAxis.getDegreesQuaternion(counterRotationAngle); + Quaternion rotation = rotationAxis.rotationDegrees(counterRotationAngle); - rotation.multiply(blockOrientation); + rotation.mul(blockOrientation); topInstance.setRotation(rotation); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java index 3ca4d5d17..d45c48db0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java @@ -36,7 +36,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { ContraptionMatrices matrices, IRenderTypeBuffer buffer) { if (Backend.getInstance().canUseInstancing()) return; - Direction facing = context.state.get(BlockStateProperties.FACING); + Direction facing = context.state.getValue(BlockStateProperties.FACING); PartialModel top = AllBlockPartials.BEARING_TOP; SuperByteBuffer superBuffer = PartialBufferer.get(top, context.state); float renderPartialTicks = AnimationTickHolder.getPartialTicks(); @@ -45,11 +45,11 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { Quaternion orientation = BearingInstance.getBlockStateOrientation(facing); // rotate against parent - float angle = getCounterRotationAngle(context, facing, renderPartialTicks) * facing.getAxisDirection().getOffset(); + float angle = getCounterRotationAngle(context, facing, renderPartialTicks) * facing.getAxisDirection().getStep(); - Quaternion rotation = facing.getUnitVector().getDegreesQuaternion(angle); + Quaternion rotation = facing.step().rotationDegrees(angle); - rotation.multiply(orientation); + rotation.mul(orientation); orientation = rotation; @@ -60,7 +60,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { superBuffer .light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) - .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getSolid())); + .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.solid())); } @Override @@ -88,11 +88,11 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { } else if (entity instanceof OrientedContraptionEntity) { OrientedContraptionEntity orientedCE = (OrientedContraptionEntity) entity; if (axis.isVertical()) - offset = -orientedCE.getYaw(renderPartialTicks); + offset = -orientedCE.getViewYRot(renderPartialTicks); else { if (orientedCE.isInitialOrientationPresent() && orientedCE.getInitialOrientation() .getAxis() == axis) - offset = -orientedCE.getPitch(renderPartialTicks); + offset = -orientedCE.getViewXRot(renderPartialTicks); } } return offset; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedContraption.java index 4eec742bc..e3f96872d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedContraption.java @@ -23,7 +23,7 @@ public class StabilizedContraption extends Contraption { @Override public boolean assemble(World world, BlockPos pos) throws AssemblyException { - BlockPos offset = pos.offset(facing); + BlockPos offset = pos.relative(facing); if (!searchMovedStructure(world, offset, null)) return false; startMoving(world); @@ -45,13 +45,13 @@ public class StabilizedContraption extends Contraption { @Override public CompoundNBT writeNBT(boolean spawnPacket) { CompoundNBT tag = super.writeNBT(spawnPacket); - tag.putInt("Facing", facing.getIndex()); + tag.putInt("Facing", facing.get3DDataValue()); return tag; } @Override public void readNBT(World world, CompoundNBT tag, boolean spawnData) { - facing = Direction.byIndex(tag.getInt("Facing")); + facing = Direction.from3DDataValue(tag.getInt("Facing")); super.readNBT(world, tag, spawnData); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/WindmillBearingBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/WindmillBearingBlock.java index 0f5bb749f..f6a82f784 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/WindmillBearingBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/WindmillBearingBlock.java @@ -13,6 +13,8 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class WindmillBearingBlock extends BearingBlock implements ITE { public WindmillBearingBlock(Properties properties) { @@ -25,15 +27,15 @@ public class WindmillBearingBlock extends BearingBlock implements ITE { if (te.running) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/WindmillBearingTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/WindmillBearingTileEntity.java index ccd717284..ff43fe15d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/WindmillBearingTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/WindmillBearingTileEntity.java @@ -82,7 +82,7 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity { private void onDirectionChanged() { if (!running) return; - if (!world.isRemote) + if (!level.isClientSide) updateGeneratedRotation(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java index 2156411af..4fc5cdaee 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java @@ -25,6 +25,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.common.Tags; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class AbstractChassisBlock extends RotatedPillarBlock implements IWrenchable { public AbstractChassisBlock(Properties properties) { @@ -42,51 +44,51 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!player.isAllowEdit()) + if (!player.mayBuild()) return ActionResultType.PASS; - ItemStack heldItem = player.getHeldItem(handIn); + ItemStack heldItem = player.getItemInHand(handIn); boolean isSlimeBall = heldItem.getItem() - .isIn(Tags.Items.SLIMEBALLS) || AllItems.SUPER_GLUE.isIn(heldItem); + .is(Tags.Items.SLIMEBALLS) || AllItems.SUPER_GLUE.isIn(heldItem); - BooleanProperty affectedSide = getGlueableSide(state, hit.getFace()); + BooleanProperty affectedSide = getGlueableSide(state, hit.getDirection()); if (affectedSide == null) return ActionResultType.PASS; - if (isSlimeBall && state.get(affectedSide)) { + if (isSlimeBall && state.getValue(affectedSide)) { for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(state, face); - if (glueableSide != null && !state.get(glueableSide) && glueAllowedOnSide(worldIn, pos, state, face)) { - if (worldIn.isRemote) { - Vector3d vec = hit.getHitVec(); + if (glueableSide != null && !state.getValue(glueableSide) && glueAllowedOnSide(worldIn, pos, state, face)) { + if (worldIn.isClientSide) { + Vector3d vec = hit.getLocation(); worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0); return ActionResultType.SUCCESS; } AllSoundEvents.SLIME_ADDED.playOnServer(worldIn, pos, .5f, 1); - state = state.with(glueableSide, true); + state = state.setValue(glueableSide, true); } } - if (!worldIn.isRemote) - worldIn.setBlockState(pos, state); + if (!worldIn.isClientSide) + worldIn.setBlockAndUpdate(pos, state); return ActionResultType.SUCCESS; } - if ((!heldItem.isEmpty() || !player.isSneaking()) && !isSlimeBall) + if ((!heldItem.isEmpty() || !player.isShiftKeyDown()) && !isSlimeBall) return ActionResultType.PASS; - if (state.get(affectedSide) == isSlimeBall) + if (state.getValue(affectedSide) == isSlimeBall) return ActionResultType.PASS; - if (!glueAllowedOnSide(worldIn, pos, state, hit.getFace())) + if (!glueAllowedOnSide(worldIn, pos, state, hit.getDirection())) return ActionResultType.PASS; - if (worldIn.isRemote) { - Vector3d vec = hit.getHitVec(); + if (worldIn.isClientSide) { + Vector3d vec = hit.getLocation(); worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0); return ActionResultType.SUCCESS; } AllSoundEvents.SLIME_ADDED.playOnServer(worldIn, pos, .5f, 1); - worldIn.setBlockState(pos, state.with(affectedSide, isSlimeBall)); + worldIn.setBlockAndUpdate(pos, state.setValue(affectedSide, isSlimeBall)); return ActionResultType.SUCCESS; } @@ -100,17 +102,17 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(rotated, face); if (glueableSide != null) - rotated = rotated.with(glueableSide, false); + rotated = rotated.setValue(glueableSide, false); } for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(state, face); - if (glueableSide == null || !state.get(glueableSide)) + if (glueableSide == null || !state.getValue(glueableSide)) continue; Direction rotatedFacing = rotation.rotate(face); BooleanProperty rotatedGlueableSide = getGlueableSide(rotated, rotatedFacing); if (rotatedGlueableSide != null) - rotated = rotated.with(rotatedGlueableSide, true); + rotated = rotated.setValue(rotatedGlueableSide, true); } return rotated; @@ -125,17 +127,17 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(mirrored, face); if (glueableSide != null) - mirrored = mirrored.with(glueableSide, false); + mirrored = mirrored.setValue(glueableSide, false); } for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(state, face); - if (glueableSide == null || !state.get(glueableSide)) + if (glueableSide == null || !state.getValue(glueableSide)) continue; Direction mirroredFacing = mirrorIn.mirror(face); BooleanProperty mirroredGlueableSide = getGlueableSide(mirrored, mirroredFacing); if (mirroredGlueableSide != null) - mirrored = mirrored.with(mirroredGlueableSide, true); + mirrored = mirrored.setValue(mirroredGlueableSide, true); } return mirrored; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisRangeDisplay.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisRangeDisplay.java index fee951e82..5477f449e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisRangeDisplay.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisRangeDisplay.java @@ -43,7 +43,7 @@ public class ChassisRangeDisplay { } protected Object getOutlineKey() { - return Pair.of(te.getPos(), 1); + return Pair.of(te.getBlockPos(), 1); } protected Set createSelection(ChassisTileEntity chassis) { @@ -88,8 +88,8 @@ public class ChassisRangeDisplay { public static void tick() { PlayerEntity player = Minecraft.getInstance().player; - World world = Minecraft.getInstance().world; - boolean hasWrench = AllItems.WRENCH.isIn(player.getHeldItemMainhand()); + World world = Minecraft.getInstance().level; + boolean hasWrench = AllItems.WRENCH.isIn(player.getMainHandItem()); for (Iterator iterator = entries.keySet() .iterator(); iterator.hasNext();) { @@ -113,12 +113,12 @@ public class ChassisRangeDisplay { if (!hasWrench) return; - RayTraceResult over = Minecraft.getInstance().objectMouseOver; + RayTraceResult over = Minecraft.getInstance().hitResult; if (!(over instanceof BlockRayTraceResult)) return; BlockRayTraceResult ray = (BlockRayTraceResult) over; - BlockPos pos = ray.getPos(); - TileEntity tileEntity = world.getTileEntity(pos); + BlockPos pos = ray.getBlockPos(); + TileEntity tileEntity = world.getBlockEntity(pos); if (tileEntity == null || tileEntity.isRemoved()) return; if (!(tileEntity instanceof ChassisTileEntity)) @@ -131,7 +131,7 @@ public class ChassisRangeDisplay { GroupEntry existingGroupForPos = getExistingGroupForPos(pos); if (existingGroupForPos != null) { for (ChassisTileEntity included : existingGroupForPos.includedTEs) - entries.remove(included.getPos()); + entries.remove(included.getBlockPos()); existingGroupForPos.timer = DISPLAY_TIME; return; } @@ -147,11 +147,11 @@ public class ChassisRangeDisplay { private static boolean tickEntry(Entry entry, boolean hasWrench) { ChassisTileEntity chassisTileEntity = entry.te; - World teWorld = chassisTileEntity.getWorld(); - World world = Minecraft.getInstance().world; + World teWorld = chassisTileEntity.getLevel(); + World world = Minecraft.getInstance().level; if (chassisTileEntity.isRemoved() || teWorld == null || teWorld != world - || !world.isBlockPresent(chassisTileEntity.getPos())) { + || !world.isLoaded(chassisTileEntity.getBlockPos())) { return true; } @@ -173,7 +173,7 @@ public class ChassisRangeDisplay { GroupEntry hoveredGroup = new GroupEntry(chassis); for (ChassisTileEntity included : hoveredGroup.includedTEs) - CreateClient.OUTLINER.remove(included.getPos()); + CreateClient.OUTLINER.remove(included.getBlockPos()); groupEntries.forEach(entry -> CreateClient.OUTLINER.remove(entry.getOutlineKey())); groupEntries.clear(); @@ -183,7 +183,7 @@ public class ChassisRangeDisplay { } // Display an individual chassis and kill any group selections that contained it - BlockPos pos = chassis.getPos(); + BlockPos pos = chassis.getBlockPos(); GroupEntry entry = getExistingGroupForPos(pos); if (entry != null) CreateClient.OUTLINER.remove(entry.getOutlineKey()); @@ -197,7 +197,7 @@ public class ChassisRangeDisplay { private static GroupEntry getExistingGroupForPos(BlockPos pos) { for (GroupEntry groupEntry : groupEntries) for (ChassisTileEntity chassis : groupEntry.includedTEs) - if (pos.equals(chassis.getPos())) + if (pos.equals(chassis.getBlockPos())) return groupEntry; return null; } 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 51e17c7fc..a5590caf6 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 @@ -73,20 +73,20 @@ public class ChassisTileEntity extends SmartTileEntity { } protected boolean isRadial() { - return world.getBlockState(pos).getBlock() instanceof RadialChassisBlock; + return level.getBlockState(worldPosition).getBlock() instanceof RadialChassisBlock; } public List collectChassisGroup() { Queue frontier = new LinkedList<>(); List collected = new ArrayList<>(); Set visited = new HashSet<>(); - frontier.add(pos); + frontier.add(worldPosition); while (!frontier.isEmpty()) { BlockPos current = frontier.poll(); if (visited.contains(current)) continue; visited.add(current); - TileEntity tileEntity = world.getTileEntity(current); + TileEntity tileEntity = level.getBlockEntity(current); if (tileEntity instanceof ChassisTileEntity) { ChassisTileEntity chassis = (ChassisTileEntity) tileEntity; collected.add(chassis); @@ -101,20 +101,20 @@ public class ChassisTileEntity extends SmartTileEntity { BlockState state = getBlockState(); if (!(state.getBlock() instanceof AbstractChassisBlock)) return false; - Axis axis = state.get(AbstractChassisBlock.AXIS); + Axis axis = state.getValue(AbstractChassisBlock.AXIS); if (isRadial()) { // Collect chain of radial chassis for (int offset : new int[] { -1, 1 }) { - Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); - BlockPos currentPos = pos.offset(direction, offset); - if (!world.isBlockPresent(currentPos)) + Direction direction = Direction.get(AxisDirection.POSITIVE, axis); + BlockPos currentPos = worldPosition.relative(direction, offset); + if (!level.isLoaded(currentPos)) return false; - BlockState neighbourState = world.getBlockState(currentPos); + BlockState neighbourState = level.getBlockState(currentPos); if (!AllBlocks.RADIAL_CHASSIS.has(neighbourState)) continue; - if (axis != neighbourState.get(BlockStateProperties.AXIS)) + if (axis != neighbourState.getValue(BlockStateProperties.AXIS)) continue; if (!visited.contains(currentPos)) frontier.add(currentPos); @@ -125,18 +125,18 @@ public class ChassisTileEntity extends SmartTileEntity { // Collect group of connected linear chassis for (Direction offset : Iterate.directions) { - BlockPos current = pos.offset(offset); + BlockPos current = worldPosition.relative(offset); if (visited.contains(current)) continue; - if (!world.isBlockPresent(current)) + if (!level.isLoaded(current)) return false; - BlockState neighbourState = world.getBlockState(current); + BlockState neighbourState = level.getBlockState(current); if (!LinearChassisBlock.isChassis(neighbourState)) continue; if (!LinearChassisBlock.sameKind(state, neighbourState)) continue; - if (neighbourState.get(AXIS) != axis) + if (neighbourState.getValue(AXIS) != axis) continue; frontier.add(current); @@ -149,23 +149,23 @@ public class ChassisTileEntity extends SmartTileEntity { List positions = new ArrayList<>(); BlockState state = getBlockState(); AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock(); - Axis axis = state.get(AbstractChassisBlock.AXIS); - Direction facing = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); + Axis axis = state.getValue(AbstractChassisBlock.AXIS); + Direction facing = Direction.get(AxisDirection.POSITIVE, axis); int chassisRange = visualize ? range.scrollableValue : getRange(); for (int offset : new int[] { 1, -1 }) { if (offset == -1) facing = facing.getOpposite(); - boolean sticky = state.get(block.getGlueableSide(state, facing)); + boolean sticky = state.getValue(block.getGlueableSide(state, facing)); for (int i = 1; i <= chassisRange; i++) { - BlockPos current = pos.offset(facing, i); - BlockState currentState = world.getBlockState(current); + BlockPos current = worldPosition.relative(facing, i); + BlockState currentState = level.getBlockState(current); if (forcedMovement != facing && !sticky) break; // Ignore replaceable Blocks and Air-like - if (!BlockMovementChecks.isMovementNecessary(currentState, world, current)) + if (!BlockMovementChecks.isMovementNecessary(currentState, level, current)) break; if (BlockMovementChecks.isBrittle(currentState)) break; @@ -182,48 +182,48 @@ public class ChassisTileEntity extends SmartTileEntity { private List getIncludedBlockPositionsRadial(Direction forcedMovement, boolean visualize) { List positions = new ArrayList<>(); - BlockState state = world.getBlockState(pos); - Axis axis = state.get(AbstractChassisBlock.AXIS); + BlockState state = level.getBlockState(worldPosition); + Axis axis = state.getValue(AbstractChassisBlock.AXIS); AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock(); int chassisRange = visualize ? range.scrollableValue : getRange(); for (Direction facing : Iterate.directions) { if (facing.getAxis() == axis) continue; - if (!state.get(block.getGlueableSide(state, facing))) + if (!state.getValue(block.getGlueableSide(state, facing))) continue; - BlockPos startPos = pos.offset(facing); + BlockPos startPos = worldPosition.relative(facing); List localFrontier = new LinkedList<>(); Set localVisited = new HashSet<>(); localFrontier.add(startPos); while (!localFrontier.isEmpty()) { BlockPos searchPos = localFrontier.remove(0); - BlockState searchedState = world.getBlockState(searchPos); + BlockState searchedState = level.getBlockState(searchPos); if (localVisited.contains(searchPos)) continue; - if (!searchPos.withinDistance(pos, chassisRange + .5f)) + if (!searchPos.closerThan(worldPosition, chassisRange + .5f)) continue; - if (!BlockMovementChecks.isMovementNecessary(searchedState, world, searchPos)) + if (!BlockMovementChecks.isMovementNecessary(searchedState, level, searchPos)) continue; if (BlockMovementChecks.isBrittle(searchedState)) continue; localVisited.add(searchPos); - if (!searchPos.equals(pos)) + if (!searchPos.equals(worldPosition)) positions.add(searchPos); for (Direction offset : Iterate.directions) { if (offset.getAxis() == axis) continue; - if (searchPos.equals(pos) && offset != facing) + if (searchPos.equals(worldPosition) && offset != facing) continue; if (BlockMovementChecks.isNotSupportive(searchedState, offset)) continue; - localFrontier.add(searchPos.offset(offset)); + localFrontier.add(searchPos.relative(offset)); } } } 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 c10ea95da..cc648fd20 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 @@ -18,6 +18,8 @@ import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class LinearChassisBlock extends AbstractChassisBlock { public static final BooleanProperty STICKY_TOP = BooleanProperty.create("sticky_top"); @@ -25,54 +27,54 @@ public class LinearChassisBlock extends AbstractChassisBlock { public LinearChassisBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(STICKY_TOP, false) - .with(STICKY_BOTTOM, false)); + registerDefaultState(defaultBlockState().setValue(STICKY_TOP, false) + .setValue(STICKY_BOTTOM, false)); } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(STICKY_TOP, STICKY_BOTTOM); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - BlockPos placedOnPos = context.getPos() - .offset(context.getFace() + BlockPos placedOnPos = context.getClickedPos() + .relative(context.getClickedFace() .getOpposite()); - BlockState blockState = context.getWorld() + BlockState blockState = context.getLevel() .getBlockState(placedOnPos); if (context.getPlayer() == null || !context.getPlayer() - .isSneaking()) { + .isShiftKeyDown()) { if (isChassis(blockState)) - return getDefaultState().with(AXIS, blockState.get(AXIS)); - return getDefaultState().with(AXIS, context.getNearestLookingDirection() + return defaultBlockState().setValue(AXIS, blockState.getValue(AXIS)); + return defaultBlockState().setValue(AXIS, context.getNearestLookingDirection() .getAxis()); } return super.getStateForPlacement(context); } @Override - public BlockState updatePostPlacement(BlockState state, Direction side, BlockState other, IWorld p_196271_4_, + public BlockState updateShape(BlockState state, Direction side, BlockState other, IWorld p_196271_4_, BlockPos p_196271_5_, BlockPos p_196271_6_) { BooleanProperty property = getGlueableSide(state, side); - if (property == null || !sameKind(state, other) || state.get(AXIS) != other.get(AXIS)) + if (property == null || !sameKind(state, other) || state.getValue(AXIS) != other.getValue(AXIS)) return state; - return state.with(property, false); + return state.setValue(property, false); } @Override public BooleanProperty getGlueableSide(BlockState state, Direction face) { - if (face.getAxis() != state.get(AXIS)) + if (face.getAxis() != state.getValue(AXIS)) return null; return face.getAxisDirection() == AxisDirection.POSITIVE ? STICKY_TOP : STICKY_BOTTOM; } @Override protected boolean glueAllowedOnSide(IBlockReader world, BlockPos pos, BlockState state, Direction side) { - BlockState other = world.getBlockState(pos.offset(side)); - return !sameKind(other, state) || state.get(AXIS) != other.get(AXIS); + BlockState other = world.getBlockState(pos.relative(side)); + return !sameKind(other, state) || state.getValue(AXIS) != other.getValue(AXIS); } public static boolean isChassis(BlockState state) { @@ -92,20 +94,20 @@ public class LinearChassisBlock extends AbstractChassisBlock { if (glueableSide == null) return AllBlocks.LINEAR_CHASSIS.has(state) ? AllSpriteShifts.CHASSIS_SIDE : AllSpriteShifts.SECONDARY_CHASSIS_SIDE; - return state.get(glueableSide) ? AllSpriteShifts.CHASSIS_STICKY : AllSpriteShifts.CHASSIS; + return state.getValue(glueableSide) ? AllSpriteShifts.CHASSIS_STICKY : AllSpriteShifts.CHASSIS; } @Override protected Direction getUpDirection(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face) { - Axis axis = state.get(AXIS); + Axis axis = state.getValue(AXIS); if (face.getAxis() == axis) return super.getUpDirection(reader, pos, state, face); - return Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); + return Direction.get(AxisDirection.POSITIVE, axis); } @Override protected Direction getRightDirection(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face) { - Axis axis = state.get(AXIS); + Axis axis = state.getValue(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); @@ -113,7 +115,7 @@ public class LinearChassisBlock extends AbstractChassisBlock { @Override protected boolean reverseUVsHorizontally(BlockState state, Direction face) { - Axis axis = state.get(AXIS); + Axis axis = state.getValue(AXIS); boolean side = face.getAxis() != axis; if (side && axis == Axis.X && face.getAxis() .isHorizontal()) @@ -128,7 +130,7 @@ public class LinearChassisBlock extends AbstractChassisBlock { @Override public boolean reverseUVs(BlockState state, Direction face) { - Axis axis = state.get(AXIS); + Axis axis = state.getValue(AXIS); boolean end = face.getAxis() == axis; if (end && axis.isHorizontal() && (face.getAxisDirection() == AxisDirection.POSITIVE)) return true; @@ -140,10 +142,10 @@ public class LinearChassisBlock extends AbstractChassisBlock { @Override public boolean connectsTo(BlockState state, BlockState other, IBlockDisplayReader reader, BlockPos pos, BlockPos otherPos, Direction face) { - Axis axis = state.get(AXIS); + Axis axis = state.getValue(AXIS); boolean superConnect = face.getAxis() == axis ? super.connectsTo(state, other, reader, pos, otherPos, face) : sameKind(state, other); - return superConnect && axis == other.get(AXIS); + return superConnect && axis == other.getValue(AXIS); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/RadialChassisBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/RadialChassisBlock.java index 852c168bb..9231de81b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/RadialChassisBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/RadialChassisBlock.java @@ -7,6 +7,8 @@ import net.minecraft.state.StateContainer.Builder; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; +import net.minecraft.block.AbstractBlock.Properties; + public class RadialChassisBlock extends AbstractChassisBlock { public static final BooleanProperty STICKY_NORTH = BooleanProperty.create("sticky_north"); @@ -16,19 +18,19 @@ public class RadialChassisBlock extends AbstractChassisBlock { public RadialChassisBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(STICKY_EAST, false).with(STICKY_SOUTH, false).with(STICKY_NORTH, false) - .with(STICKY_WEST, false)); + registerDefaultState(defaultBlockState().setValue(STICKY_EAST, false).setValue(STICKY_SOUTH, false).setValue(STICKY_NORTH, false) + .setValue(STICKY_WEST, false)); } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(STICKY_NORTH, STICKY_EAST, STICKY_SOUTH, STICKY_WEST); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override public BooleanProperty getGlueableSide(BlockState state, Direction face) { - Axis axis = state.get(AXIS); + Axis axis = state.getValue(AXIS); if (axis == Axis.X) { if (face == Direction.NORTH) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerBlock.java index 277223c95..126f1722a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerBlock.java @@ -25,6 +25,8 @@ import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class StickerBlock extends ProperDirectionalBlock implements ITE { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; @@ -32,39 +34,39 @@ public class StickerBlock extends ProperDirectionalBlock implements ITE builder) { - super.fillStateContainer(builder.add(POWERED, EXTENDED)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(POWERED, EXTENDED)); } @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - boolean previouslyPowered = state.get(POWERED); - if (previouslyPowered != worldIn.isBlockPowered(pos)) { + boolean previouslyPowered = state.getValue(POWERED); + if (previouslyPowered != worldIn.hasNeighborSignal(pos)) { state = state.cycle(POWERED); - if (state.get(POWERED)) + if (state.getValue(POWERED)) state = state.cycle(EXTENDED); - worldIn.setBlockState(pos, state, 2); + worldIn.setBlock(pos, state, 2); } } @@ -92,52 +94,52 @@ public class StickerBlock extends ProperDirectionalBlock implements ITE imple head = getTransformMaterial().getModel(AllBlockPartials.STICKER_HEAD, blockState).createInstance(); - fakeWorld = tile.getWorld() != Minecraft.getInstance().world; - facing = blockState.get(StickerBlock.FACING); - offset = blockState.get(StickerBlock.EXTENDED) ? 1 : 0; + fakeWorld = tile.getLevel() != Minecraft.getInstance().level; + facing = blockState.getValue(StickerBlock.FACING); + offset = blockState.getValue(StickerBlock.EXTENDED) ? 1 : 0; animateHead(offset); } @@ -42,7 +42,7 @@ public class StickerInstance extends TileEntityInstance imple if (fakeWorld) offset = this.offset; - if (MathHelper.epsilonEquals(offset, lastOffset)) + if (MathHelper.equal(offset, lastOffset)) return; animateHead(offset); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java index a63c27957..91ef67f06 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java @@ -26,16 +26,16 @@ public class StickerRenderer extends SafeTileEntityRenderer { protected void renderSafe(StickerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; BlockState state = te.getBlockState(); SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.STICKER_HEAD, state); - float offset = te.piston.getValue(AnimationTickHolder.getPartialTicks(te.getWorld())); + float offset = te.piston.getValue(AnimationTickHolder.getPartialTicks(te.getLevel())); - if (te.getWorld() != Minecraft.getInstance().world && !te.isVirtual()) - offset = state.get(StickerBlock.EXTENDED) ? 1 : 0; + if (te.getLevel() != Minecraft.getInstance().level && !te.isVirtual()) + offset = state.getValue(StickerBlock.EXTENDED) ? 1 : 0; - Direction facing = state.get(StickerBlock.FACING); + Direction facing = state.getValue(StickerBlock.FACING); head.matrixStacker() .nudge(te.hashCode()) .centre() @@ -45,7 +45,7 @@ public class StickerRenderer extends SafeTileEntityRenderer { .translate(0, (offset * offset) * 4 / 16f, 0); head.light(light) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .renderInto(ms, buffer.getBuffer(RenderType.solid())); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java index 7282a1183..8b2a039c6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java @@ -18,6 +18,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; +import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; @@ -39,26 +40,26 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende @Override public void initialize() { super.initialize(); - if (!world.isRemote) + if (!level.isClientSide) return; piston.startWithValue(isBlockStateExtended() ? 1 : 0); } public boolean isBlockStateExtended() { BlockState blockState = getBlockState(); - boolean extended = AllBlocks.STICKER.has(blockState) && blockState.get(StickerBlock.EXTENDED); + boolean extended = AllBlocks.STICKER.has(blockState) && blockState.getValue(StickerBlock.EXTENDED); return extended; } @Override public void tick() { super.tick(); - if (!world.isRemote) + if (!level.isClientSide) return; piston.tickChaser(); if (isAttachedToBlock() && piston.getValue(0) != piston.getValue() && piston.getValue() == 1) { - SuperGlueItem.spawnParticles(world, pos, getBlockState().get(StickerBlock.FACING), true); + SuperGlueItem.spawnParticles(level, worldPosition, getBlockState().getValue(StickerBlock.FACING), true); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> playSound(true)); } @@ -77,8 +78,8 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende BlockState blockState = getBlockState(); if (!AllBlocks.STICKER.has(blockState)) return false; - Direction direction = blockState.get(StickerBlock.FACING); - return SuperGlueEntity.isValidFace(world, pos.offset(direction), direction.getOpposite()); + Direction direction = blockState.getValue(StickerBlock.FACING); + return SuperGlueEntity.isValidFace(level, worldPosition.relative(direction), direction.getOpposite()); } @Override @@ -90,7 +91,8 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende @OnlyIn(Dist.CLIENT) public void playSound(boolean attach) { - AllSoundEvents.SLIME_ADDED.play(world, Minecraft.getInstance().player, pos, 0.35f, attach ? 0.75f : 0.2f); + AllSoundEvents.SLIME_ADDED.play(level, Minecraft.getInstance().player, worldPosition, 0.35f, attach ? 0.75f : 0.2f); } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageBlock.java index 849bfb36b..f969f3840 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageBlock.java @@ -24,6 +24,8 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements ITE { public GantryCarriageBlock(Properties properties) { @@ -31,22 +33,22 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements } @Override - public boolean isValidPosition(BlockState state, IWorldReader world, BlockPos pos) { - Direction direction = state.get(FACING); - BlockState shaft = world.getBlockState(pos.offset(direction.getOpposite())); - return AllBlocks.GANTRY_SHAFT.has(shaft) && shaft.get(GantryShaftBlock.FACING) + public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { + Direction direction = state.getValue(FACING); + BlockState shaft = world.getBlockState(pos.relative(direction.getOpposite())); + return AllBlocks.GANTRY_SHAFT.has(shaft) && shaft.getValue(GantryShaftBlock.FACING) .getAxis() != direction.getAxis(); } @Override - public void updateDiagonalNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) { - super.updateDiagonalNeighbors(stateIn, worldIn, pos, flags, count); + public void updateIndirectNeighbourShapes(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) { + super.updateIndirectNeighbourShapes(stateIn, worldIn, pos, flags, count); withTileEntityDo(worldIn, pos, GantryCarriageTileEntity::checkValidGantryShaft); } @Override - public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { - super.onBlockAdded(state, worldIn, pos, oldState, isMoving); + public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + super.onPlace(state, worldIn, pos, oldState, isMoving); } @Override @@ -56,14 +58,14 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements @Override protected Direction getFacingForPlacement(BlockItemUseContext context) { - return context.getFace(); + return context.getClickedFace(); } - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!player.isAllowEdit() || player.isSneaking()) + if (!player.mayBuild() || player.isShiftKeyDown()) return ActionResultType.PASS; - if (player.getHeldItem(handIn) + if (player.getItemInHand(handIn) .isEmpty()) { withTileEntityDo(worldIn, pos, te -> te.checkValidGantryShaft()); return ActionResultType.SUCCESS; @@ -74,25 +76,25 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements @Override public BlockState getStateForPlacement(BlockItemUseContext context) { BlockState stateForPlacement = super.getStateForPlacement(context); - Direction opposite = stateForPlacement.get(FACING) + Direction opposite = stateForPlacement.getValue(FACING) .getOpposite(); - return cycleAxisIfNecessary(stateForPlacement, opposite, context.getWorld() - .getBlockState(context.getPos() - .offset(opposite))); + return cycleAxisIfNecessary(stateForPlacement, opposite, context.getLevel() + .getBlockState(context.getClickedPos() + .relative(opposite))); } @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, BlockPos updatePos, boolean p_220069_6_) { - if (updatePos.equals(pos.offset(state.get(FACING) - .getOpposite())) && !isValidPosition(state, world, pos)) + if (updatePos.equals(pos.relative(state.getValue(FACING) + .getOpposite())) && !canSurvive(state, world, pos)) world.destroyBlock(pos, true); } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState otherState, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState otherState, IWorld world, BlockPos pos, BlockPos p_196271_6_) { - if (state.get(FACING) != direction.getOpposite()) + if (state.getValue(FACING) != direction.getOpposite()) return state; return cycleAxisIfNecessary(state, direction, otherState); } @@ -100,7 +102,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements protected BlockState cycleAxisIfNecessary(BlockState state, Direction direction, BlockState otherState) { if (!AllBlocks.GANTRY_SHAFT.has(otherState)) return state; - if (otherState.get(GantryShaftBlock.FACING) + if (otherState.getValue(GantryShaftBlock.FACING) .getAxis() == direction.getAxis()) return state; if (isValidGantryShaftAxis(state, otherState)) @@ -109,7 +111,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements } public static boolean isValidGantryShaftAxis(BlockState pinionState, BlockState gantryState) { - return getValidGantryShaftAxis(pinionState) == gantryState.get(GantryShaftBlock.FACING) + return getValidGantryShaftAxis(pinionState) == gantryState.getValue(GantryShaftBlock.FACING) .getAxis(); } @@ -118,7 +120,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements return Axis.Y; IRotate block = (IRotate) state.getBlock(); Axis rotationAxis = block.getRotationAxis(state); - Axis facingAxis = state.get(FACING) + Axis facingAxis = state.getValue(FACING) .getAxis(); for (Axis axis : Iterate.axes) if (axis != rotationAxis && axis != facingAxis) @@ -127,7 +129,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements } public static Axis getValidGantryPinionAxis(BlockState state, Axis shaftAxis) { - Axis facingAxis = state.get(FACING) + Axis facingAxis = state.getValue(FACING) .getAxis(); for (Axis axis : Iterate.axes) if (axis != shaftAxis && axis != facingAxis) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java index e2d3a8630..e60fee02c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java @@ -36,15 +36,15 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns .getModel(AllBlockPartials.GANTRY_COGS, blockState) .createInstance(); - facing = blockState.get(GantryCarriageBlock.FACING); - alongFirst = blockState.get(GantryCarriageBlock.AXIS_ALONG_FIRST_COORDINATE); + facing = blockState.getValue(GantryCarriageBlock.FACING); + alongFirst = blockState.getValue(GantryCarriageBlock.AXIS_ALONG_FIRST_COORDINATE); rotationAxis = KineticTileEntityRenderer.getRotationAxisOf(tile); rotationMult = getRotationMultiplier(getGantryAxis(), facing); - visualPos = facing.getAxisDirection() == Direction.AxisDirection.POSITIVE ? tile.getPos() - : tile.getPos() - .offset(facing.getOpposite()); + visualPos = facing.getAxisDirection() == Direction.AxisDirection.POSITIVE ? tile.getBlockPos() + : tile.getBlockPos() + .relative(facing.getOpposite()); animateCogs(getCogAngle()); } @@ -53,7 +53,7 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns public void beginFrame() { float cogAngle = getCogAngle(); - if (MathHelper.epsilonEquals(cogAngle, lastAngle)) return; + if (MathHelper.equal(cogAngle, lastAngle)) return; animateCogs(cogAngle); } @@ -71,7 +71,7 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) .rotateY(alongFirst ^ facing.getAxis() == Direction.Axis.Z ? 90 : 0) .translate(0, -9 / 16f, 0) - .multiply(Vector3f.POSITIVE_X.getRadialQuaternion(-cogAngle)) + .multiply(Vector3f.XP.rotation(-cogAngle)) .translate(0, 9 / 16f, 0) .unCentre(); 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 5ae13bc6d..63efd4fc7 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 @@ -32,15 +32,15 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; BlockState state = te.getBlockState(); - Direction facing = state.get(GantryCarriageBlock.FACING); - Boolean alongFirst = state.get(GantryCarriageBlock.AXIS_ALONG_FIRST_COORDINATE); + Direction facing = state.getValue(GantryCarriageBlock.FACING); + Boolean alongFirst = state.getValue(GantryCarriageBlock.AXIS_ALONG_FIRST_COORDINATE); Axis rotationAxis = getRotationAxisOf(te); - BlockPos visualPos = facing.getAxisDirection() == AxisDirection.POSITIVE ? te.getPos() - : te.getPos() - .offset(facing.getOpposite()); + BlockPos visualPos = facing.getAxisDirection() == AxisDirection.POSITIVE ? te.getBlockPos() + : te.getBlockPos() + .relative(facing.getOpposite()); float angleForTe = getAngleForTe(te, visualPos, rotationAxis); Axis gantryAxis = Axis.X; @@ -62,17 +62,17 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer { .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) .rotateY(alongFirst ^ facing.getAxis() == Axis.Z ? 90 : 0) .translate(0, -9 / 16f, 0) - .multiply(Vector3f.POSITIVE_X.getRadialQuaternion(-angleForTe)) + .multiply(Vector3f.XP.rotation(-angleForTe)) .translate(0, 9 / 16f, 0) .unCentre(); cogs.light(light) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .renderInto(ms, buffer.getBuffer(RenderType.solid())); } public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) { - float time = AnimationTickHolder.getRenderTime(te.getWorld()); + float time = AnimationTickHolder.getRenderTime(te.getLevel()); 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/gantry/GantryCarriageTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageTileEntity.java index 897068624..7e516d2dc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageTileEntity.java @@ -41,8 +41,8 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp @Override public void initialize() { super.initialize(); - if (!getBlockState().isValidPosition(world, pos)) - world.destroyBlock(pos, true); + if (!getBlockState().canSurvive(level, worldPosition)) + level.destroyBlock(worldPosition, true); } public void queueAssembly() { @@ -53,7 +53,7 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp public void tick() { super.tick(); - if (world.isRemote) + if (level.isClientSide) return; if (assembleNextTick) { @@ -72,10 +72,10 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp if (!(blockState.getBlock() instanceof GantryCarriageBlock)) return; - Direction direction = blockState.get(FACING); + Direction direction = blockState.getValue(FACING); GantryContraption contraption = new GantryContraption(direction); - TileEntity shaftTe = world.getTileEntity(pos.offset(direction.getOpposite())); + TileEntity shaftTe = level.getBlockEntity(worldPosition.relative(direction.getOpposite())); if (!(shaftTe instanceof GantryShaftTileEntity)) return; BlockState shaftState = shaftTe.getBlockState(); @@ -83,14 +83,14 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp return; float pinionMovementSpeed = ((GantryShaftTileEntity) shaftTe).getPinionMovementSpeed(); - Direction shaftOrientation = shaftState.get(GantryShaftBlock.FACING); + Direction shaftOrientation = shaftState.getValue(GantryShaftBlock.FACING); Direction movementDirection = shaftOrientation; if (pinionMovementSpeed < 0) movementDirection = movementDirection.getOpposite(); try { lastException = null; - if (!contraption.assemble(world, pos)) + if (!contraption.assemble(level, worldPosition)) return; sendData(); @@ -99,17 +99,17 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp sendData(); return; } - if (ContraptionCollider.isCollidingWithWorld(world, contraption, pos.offset(movementDirection), + if (ContraptionCollider.isCollidingWithWorld(level, contraption, worldPosition.relative(movementDirection), movementDirection)) return; - contraption.removeBlocksFromWorld(world, BlockPos.ZERO); + contraption.removeBlocksFromWorld(level, BlockPos.ZERO); GantryContraptionEntity movedContraption = - GantryContraptionEntity.create(world, contraption, shaftOrientation); - BlockPos anchor = pos; - movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); - AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(world, pos); - world.addEntity(movedContraption); + GantryContraptionEntity.create(level, contraption, shaftOrientation); + BlockPos anchor = worldPosition; + movedContraption.setPos(anchor.getX(), anchor.getY(), anchor.getZ()); + AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(level, worldPosition); + level.addFreshEntity(movedContraption); } @Override @@ -134,19 +134,19 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp return defaultModifier; if (!AllBlocks.GANTRY_SHAFT.has(stateTo)) return defaultModifier; - if (!stateTo.get(GantryShaftBlock.POWERED)) + if (!stateTo.getValue(GantryShaftBlock.POWERED)) return defaultModifier; - Direction direction = Direction.getFacingFromVector(diff.getX(), diff.getY(), diff.getZ()); - if (stateFrom.get(GantryCarriageBlock.FACING) != direction.getOpposite()) + Direction direction = Direction.getNearest(diff.getX(), diff.getY(), diff.getZ()); + if (stateFrom.getValue(GantryCarriageBlock.FACING) != direction.getOpposite()) return defaultModifier; - return getGantryPinionModifier(stateTo.get(GantryShaftBlock.FACING), stateFrom.get(GantryCarriageBlock.FACING)); + return getGantryPinionModifier(stateTo.getValue(GantryShaftBlock.FACING), stateFrom.getValue(GantryCarriageBlock.FACING)); } public static float getGantryPinionModifier(Direction shaft, Direction pinionDirection) { Axis shaftAxis = shaft.getAxis(); float directionModifier = shaft.getAxisDirection() - .getOffset(); + .getStep(); if (shaftAxis == Axis.Y) if (pinionDirection == Direction.NORTH || pinionDirection == Direction.EAST) return -directionModifier; @@ -163,14 +163,14 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp BlockState blockState = getBlockState(); if (!(blockState.getBlock() instanceof GantryCarriageBlock)) return false; - Direction facing = blockState.get(GantryCarriageBlock.FACING) + Direction facing = blockState.getValue(GantryCarriageBlock.FACING) .getOpposite(); - BlockState shaftState = world.getBlockState(pos.offset(facing)); + BlockState shaftState = level.getBlockState(worldPosition.relative(facing)); if (!(shaftState.getBlock() instanceof GantryShaftBlock)) return false; - if (shaftState.get(GantryShaftBlock.POWERED)) + if (shaftState.getValue(GantryShaftBlock.POWERED)) return false; - TileEntity te = world.getTileEntity(pos.offset(facing)); + TileEntity te = level.getBlockEntity(worldPosition.relative(facing)); return te instanceof GantryShaftTileEntity && ((GantryShaftTileEntity) te).canAssembleOn(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraption.java index df6366c73..260da29e1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraption.java @@ -34,19 +34,19 @@ public class GantryContraption extends TranslatingContraption { @Override public CompoundNBT writeNBT(boolean spawnPacket) { CompoundNBT tag = super.writeNBT(spawnPacket); - tag.putInt("Facing", facing.getIndex()); + tag.putInt("Facing", facing.get3DDataValue()); return tag; } @Override public void readNBT(World world, CompoundNBT tag, boolean spawnData) { - facing = Direction.byIndex(tag.getInt("Facing")); + facing = Direction.from3DDataValue(tag.getInt("Facing")); super.readNBT(world, tag, spawnData); } @Override protected boolean isAnchoringBlockAt(BlockPos pos) { - return super.isAnchoringBlockAt(pos.offset(facing)); + return super.isAnchoringBlockAt(pos.relative(facing)); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java index 4066c61b4..bcf52fedb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java @@ -28,6 +28,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.PacketDistributor; +import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity.ContraptionRotationState; + public class GantryContraptionEntity extends AbstractContraptionEntity { Direction movementAxis; @@ -51,27 +53,27 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { return; double prevAxisMotion = axisMotion; - if (world.isRemote) { + if (level.isClientSide) { clientOffsetDiff *= .75f; updateClientMotion(); } checkPinionShaft(); tickActors(); - Vector3d movementVec = getMotion(); + Vector3d movementVec = getDeltaMovement(); if (ContraptionCollider.collideBlocks(this)) { - if (!world.isRemote) + if (!level.isClientSide) disassemble(); return; } - if (!isStalled() && ticksExisted > 2) + if (!isStalled() && tickCount > 2) move(movementVec.x, movementVec.y, movementVec.z); if (Math.signum(prevAxisMotion) != Math.signum(axisMotion) && prevAxisMotion != 0) - contraption.stop(world); - if (!world.isRemote && (prevAxisMotion != axisMotion || ticksExisted % 3 == 0)) + contraption.stop(level); + if (!level.isClientSide && (prevAxisMotion != axisMotion || tickCount % 3 == 0)) sendPacket(); } @@ -79,11 +81,11 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { Vector3d movementVec; Direction facing = ((GantryContraption) contraption).getFacing(); Vector3d currentPosition = getAnchorVec().add(.5, .5, .5); - BlockPos gantryShaftPos = new BlockPos(currentPosition).offset(facing.getOpposite()); + BlockPos gantryShaftPos = new BlockPos(currentPosition).relative(facing.getOpposite()); - TileEntity te = world.getTileEntity(gantryShaftPos); + TileEntity te = level.getBlockEntity(gantryShaftPos); if (!(te instanceof GantryShaftTileEntity) || !AllBlocks.GANTRY_SHAFT.has(te.getBlockState())) { - if (!world.isRemote) { + if (!level.isClientSide) { setContraptionMotion(Vector3d.ZERO); disassemble(); } @@ -91,35 +93,35 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { } BlockState blockState = te.getBlockState(); - Direction direction = blockState.get(GantryShaftBlock.FACING); + Direction direction = blockState.getValue(GantryShaftBlock.FACING); GantryShaftTileEntity gantryShaftTileEntity = (GantryShaftTileEntity) te; float pinionMovementSpeed = gantryShaftTileEntity.getPinionMovementSpeed(); - movementVec = Vector3d.of(direction.getDirectionVec()).scale(pinionMovementSpeed); + movementVec = Vector3d.atLowerCornerOf(direction.getNormal()).scale(pinionMovementSpeed); - if (blockState.get(GantryShaftBlock.POWERED) || pinionMovementSpeed == 0) { + if (blockState.getValue(GantryShaftBlock.POWERED) || pinionMovementSpeed == 0) { setContraptionMotion(Vector3d.ZERO); - if (!world.isRemote) + if (!level.isClientSide) disassemble(); return; } Vector3d nextPosition = currentPosition.add(movementVec); double currentCoord = direction.getAxis() - .getCoordinate(currentPosition.x, currentPosition.y, currentPosition.z); + .choose(currentPosition.x, currentPosition.y, currentPosition.z); double nextCoord = direction.getAxis() - .getCoordinate(nextPosition.x, nextPosition.y, nextPosition.z); + .choose(nextPosition.x, nextPosition.y, nextPosition.z); if ((MathHelper.floor(currentCoord) + .5f < nextCoord != (pinionMovementSpeed * direction.getAxisDirection() - .getOffset() < 0))) + .getStep() < 0))) if (!gantryShaftTileEntity.canAssembleOn()) { setContraptionMotion(Vector3d.ZERO); - if (!world.isRemote) + if (!level.isClientSide) disassemble(); return; } - if (world.isRemote) + if (level.isClientSide) return; axisMotion = pinionMovementSpeed; @@ -158,15 +160,15 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { } @Override - public void setPositionAndUpdate(double p_70634_1_, double p_70634_3_, double p_70634_5_) {} + public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {} @Override @OnlyIn(Dist.CLIENT) - public void setPositionAndRotationDirect(double x, double y, double z, float yw, float pt, int inc, boolean t) {} + public void lerpTo(double x, double y, double z, float yw, float pt, int inc, boolean t) {} @Override protected void handleStallInformation(float x, float y, float z, float angle) { - setPos(x, y, z); + setPosRaw(x, y, z); clientOffsetDiff = 0; } @@ -180,25 +182,25 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { public void updateClientMotion() { float modifier = movementAxis.getAxisDirection() - .getOffset(); - setContraptionMotion(Vector3d.of(movementAxis.getDirectionVec()) + .getStep(); + setContraptionMotion(Vector3d.atLowerCornerOf(movementAxis.getNormal()) .scale((axisMotion + clientOffsetDiff * modifier / 2f) * ServerSpeedProvider.get())); } public double getAxisCoord() { Vector3d anchorVec = getAnchorVec(); return movementAxis.getAxis() - .getCoordinate(anchorVec.x, anchorVec.y, anchorVec.z); + .choose(anchorVec.x, anchorVec.y, anchorVec.z); } public void sendPacket() { AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> this), - new GantryContraptionUpdatePacket(getEntityId(), getAxisCoord(), axisMotion)); + new GantryContraptionUpdatePacket(getId(), getAxisCoord(), axisMotion)); } @OnlyIn(Dist.CLIENT) public static void handlePacket(GantryContraptionUpdatePacket packet) { - Entity entity = Minecraft.getInstance().world.getEntityByID(packet.entityID); + Entity entity = Minecraft.getInstance().level.getEntity(packet.entityID); if (!(entity instanceof GantryContraptionEntity)) return; GantryContraptionEntity ce = (GantryContraptionEntity) entity; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueEffectPacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueEffectPacket.java index a70a8d1c7..8811e0208 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueEffectPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueEffectPacket.java @@ -27,13 +27,13 @@ public class GlueEffectPacket extends SimplePacketBase { public GlueEffectPacket(PacketBuffer buffer) { pos = buffer.readBlockPos(); - direction = Direction.byIndex(buffer.readByte()); + direction = Direction.from3DDataValue(buffer.readByte()); fullBlock = buffer.readBoolean(); } public void write(PacketBuffer buffer) { buffer.writeBlockPos(pos); - buffer.writeByte(direction.getIndex()); + buffer.writeByte(direction.get3DDataValue()); buffer.writeBoolean(fullBlock); } @@ -41,9 +41,9 @@ public class GlueEffectPacket extends SimplePacketBase { public void handle(Supplier context) { context.get().enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { Minecraft mc = Minecraft.getInstance(); - if (!mc.player.getBlockPos().withinDistance(pos, 100)) + if (!mc.player.blockPosition().closerThan(pos, 100)) return; - SuperGlueItem.spawnParticles(mc.world, pos, direction, fullBlock); + SuperGlueItem.spawnParticles(mc.level, pos, direction, fullBlock); })); context.get().setPacketHandled(true); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java index 4f57c980f..38fc81deb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java @@ -87,25 +87,25 @@ public class GlueInstance extends EntityInstance implements ITi private void updateLight(OrientedData model) { BlockPos pos = entity.getHangingPosition(); - model.setBlockLight(world.getLightLevel(LightType.BLOCK, pos)) - .setSkyLight(world.getLightLevel(LightType.SKY, pos)); + model.setBlockLight(world.getBrightness(LightType.BLOCK, pos)) + .setSkyLight(world.getBrightness(LightType.SKY, pos)); } private boolean shouldShow() { PlayerEntity player = Minecraft.getInstance().player; return entity.isVisible() - || AllItems.SUPER_GLUE.isIn(player.getHeldItemMainhand()) - || AllItems.SUPER_GLUE.isIn(player.getHeldItemOffhand()); + || AllItems.SUPER_GLUE.isIn(player.getMainHandItem()) + || AllItems.SUPER_GLUE.isIn(player.getOffhandItem()); } public static BufferedModel supplyModel() { - Vector3d diff = Vector3d.of(Direction.SOUTH.getDirectionVec()); + Vector3d diff = Vector3d.atLowerCornerOf(Direction.SOUTH.getNormal()); Vector3d extension = diff.normalize() .scale(1 / 32f - 1 / 128f); Vector3d plane = VecHelper.axisAlingedPlaneOf(diff); - Direction.Axis axis = Direction.getFacingFromVector(diff.x, diff.y, diff.z) + Direction.Axis axis = Direction.getNearest(diff.x, diff.y, diff.z) .getAxis(); Vector3d start = Vector3d.ZERO.subtract(extension); @@ -133,10 +133,10 @@ public class GlueInstance extends EntityInstance implements ITi if (USE_ATLAS) { TextureAtlasSprite sprite = AllStitchedTextures.SUPER_GLUE.getSprite(); - minU = sprite.getMinU(); - maxU = sprite.getMaxU(); - minV = sprite.getMinV(); - maxV = sprite.getMaxV(); + minU = sprite.getU0(); + maxU = sprite.getU1(); + minV = sprite.getV0(); + maxV = sprite.getV1(); } else { minU = minV = 0; maxU = maxV = 1; 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 2e206b129..c6e6ff037 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 @@ -85,7 +85,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - protected void registerData() {} + protected void defineSynchedData() {} public int getWidthPixels() { return 12; @@ -96,7 +96,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } public void onBroken(@Nullable Entity breaker) { - playSound(SoundEvents.ENTITY_SLIME_SQUISH_SMALL, 1.0F, 1.0F); + playSound(SoundEvents.SLIME_SQUISH_SMALL, 1.0F, 1.0F); if (onValidSurface()) { AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> this), new GlueEffectPacket(getHangingPosition(), getFacingDirection().getOpposite(), false)); @@ -112,26 +112,26 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat Validate.notNull(getFacingDirection()); if (getFacingDirection().getAxis() .isHorizontal()) { - this.rotationPitch = 0.0F; - this.rotationYaw = getFacingDirection().getHorizontalIndex() * 90; + this.xRot = 0.0F; + this.yRot = getFacingDirection().get2DDataValue() * 90; } else { - this.rotationPitch = -90 * getFacingDirection().getAxisDirection() - .getOffset(); - this.rotationYaw = 0.0F; + this.xRot = -90 * getFacingDirection().getAxisDirection() + .getStep(); + this.yRot = 0.0F; } - this.prevRotationPitch = this.rotationPitch; - this.prevRotationYaw = this.rotationYaw; + this.xRotO = this.xRot; + this.yRotO = this.yRot; this.updateBoundingBox(); } protected void updateBoundingBox() { if (this.getFacingDirection() != null) { double offset = 0.5 - 1 / 256d; - double x = hangingPosition.getX() + 0.5 - facingDirection.getXOffset() * offset; - double y = hangingPosition.getY() + 0.5 - facingDirection.getYOffset() * offset; - double z = hangingPosition.getZ() + 0.5 - facingDirection.getZOffset() * offset; - this.setPos(x, y, z); + double x = hangingPosition.getX() + 0.5 - facingDirection.getStepX() * offset; + double y = hangingPosition.getY() + 0.5 - facingDirection.getStepY() * offset; + double z = hangingPosition.getZ() + 0.5 - facingDirection.getStepZ() * offset; + this.setPosRaw(x, y, z); double w = getWidthPixels(); double h = getHeightPixels(); double l = getWidthPixels(); @@ -159,7 +159,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat @Override public void tick() { - if (this.validationTimer++ == 10 && !this.world.isRemote) { + if (this.validationTimer++ == 10 && !this.level.isClientSide) { this.validationTimer = 0; if (isAlive() && !this.onValidSurface()) { remove(); @@ -172,29 +172,29 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat public boolean isVisible() { if (!isAlive()) return false; - if (world instanceof WrappedWorld) + if (level instanceof WrappedWorld) return true; BlockPos pos = hangingPosition; - BlockPos pos2 = pos.offset(getFacingDirection().getOpposite()); - return isValidFace(world, pos2, getFacingDirection()) != isValidFace(world, pos, + BlockPos pos2 = pos.relative(getFacingDirection().getOpposite()); + return isValidFace(level, pos2, getFacingDirection()) != isValidFace(level, pos, getFacingDirection().getOpposite()); } public boolean onValidSurface() { BlockPos pos = hangingPosition; - BlockPos pos2 = hangingPosition.offset(getFacingDirection().getOpposite()); + BlockPos pos2 = hangingPosition.relative(getFacingDirection().getOpposite()); if (pos2.getY() >= 256) return false; - if (!world.isAreaLoaded(pos, 0) || !world.isAreaLoaded(pos2, 0)) + if (!level.isAreaLoaded(pos, 0) || !level.isAreaLoaded(pos2, 0)) return true; - if (!isValidFace(world, pos2, getFacingDirection()) - && !isValidFace(world, pos, getFacingDirection().getOpposite())) + if (!isValidFace(level, pos2, getFacingDirection()) + && !isValidFace(level, pos, getFacingDirection().getOpposite())) return false; - if (isSideSticky(world, pos2, getFacingDirection()) - || isSideSticky(world, pos, getFacingDirection().getOpposite())) + if (isSideSticky(level, pos2, getFacingDirection()) + || isSideSticky(level, pos, getFacingDirection().getOpposite())) return false; - return world.getEntitiesInAABBexcluding(this, getBoundingBox(), e -> e instanceof SuperGlueEntity) + return level.getEntities(this, getBoundingBox(), e -> e instanceof SuperGlueEntity) .isEmpty(); } @@ -212,10 +212,10 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat 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; + return state.getValue(DirectionalKineticBlock.FACING) == direction; if (AllBlocks.STICKER.has(state)) - return state.get(DirectionalBlock.FACING) == direction; + return state.getValue(DirectionalBlock.FACING) == direction; if (state.getBlock() == Blocks.SLIME_BLOCK) return true; @@ -226,59 +226,59 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat return Direction.UP == direction; if (AllBlocks.GANTRY_CARRIAGE.has(state)) - return state.get(DirectionalKineticBlock.FACING) == direction; + return state.getValue(DirectionalKineticBlock.FACING) == direction; if (state.getBlock() instanceof BearingBlock) { - return state.get(DirectionalKineticBlock.FACING) == direction; + return state.getValue(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 state.getValue(glueableSide); } return false; } @Override - public boolean canBeCollidedWith() { + public boolean isPickable() { return true; } @Override - public boolean hitByEntity(Entity entity) { + public boolean skipAttackInteraction(Entity entity) { return entity instanceof PlayerEntity - ? attackEntityFrom(DamageSource.causePlayerDamage((PlayerEntity) entity), 0) + ? hurt(DamageSource.playerAttack((PlayerEntity) entity), 0) : false; } @Override - public Direction getHorizontalFacing() { + public Direction getDirection() { return this.getFacingDirection(); } @Override - public boolean attackEntityFrom(DamageSource source, float amount) { + public boolean hurt(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) return false; - boolean mobGriefing = world.getGameRules().getBoolean(GameRules.MOB_GRIEFING); - Entity trueSource = source.getTrueSource(); + boolean mobGriefing = level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + Entity trueSource = source.getEntity(); if (!mobGriefing && trueSource instanceof MobEntity) return false; - Entity immediateSource = source.getImmediateSource(); + Entity immediateSource = source.getDirectEntity(); if (!isVisible() && immediateSource instanceof PlayerEntity) { - if (!AllItems.SUPER_GLUE.isIn(((PlayerEntity) immediateSource).getHeldItemMainhand())) + if (!AllItems.SUPER_GLUE.isIn(((PlayerEntity) immediateSource).getMainHandItem())) return true; } - if (isAlive() && !world.isRemote) { + if (isAlive() && !level.isClientSide) { remove(); - markVelocityChanged(); - onBroken(source.getTrueSource()); + markHurt(); + onBroken(source.getEntity()); } return true; @@ -286,15 +286,15 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat @Override public void move(MoverType typeIn, Vector3d pos) { - if (!world.isRemote && isAlive() && pos.lengthSquared() > 0.0D) { + if (!level.isClientSide && isAlive() && pos.lengthSqr() > 0.0D) { remove(); onBroken(null); } } @Override - public void addVelocity(double x, double y, double z) { - if (!world.isRemote && isAlive() && x * x + y * y + z * z > 0.0D) { + public void push(double x, double y, double z) { + if (!level.isClientSide && isAlive() && x * x + y * y + z * z > 0.0D) { remove(); onBroken(null); } @@ -311,12 +311,12 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public void applyEntityCollision(Entity entityIn) { - super.applyEntityCollision(entityIn); + public void push(Entity entityIn) { + super.push(entityIn); } @Override - public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) { + public ActionResultType interact(PlayerEntity player, Hand hand) { if (player instanceof FakePlayer) return ActionResultType.PASS; DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { @@ -329,43 +329,43 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat private void triggerPlaceBlock(PlayerEntity player, Hand hand) { if (!(player instanceof ClientPlayerEntity)) return; - if (!(player.world instanceof ClientWorld)) + if (!(player.level instanceof ClientWorld)) return; ClientPlayerEntity cPlayer = (ClientPlayerEntity) player; Minecraft mc = Minecraft.getInstance(); RayTraceResult ray = - cPlayer.pick(mc.playerController.getBlockReachDistance(), AnimationTickHolder.getPartialTicks(), false); + cPlayer.pick(mc.gameMode.getPickRange(), AnimationTickHolder.getPartialTicks(), false); if (!(ray instanceof BlockRayTraceResult)) return; if (ray.getType() == Type.MISS) return; BlockRayTraceResult blockRay = (BlockRayTraceResult) ray; - BlockFace rayFace = new BlockFace(blockRay.getPos(), blockRay.getFace()); + BlockFace rayFace = new BlockFace(blockRay.getBlockPos(), blockRay.getDirection()); BlockFace hangingFace = new BlockFace(getHangingPosition(), getFacingDirection().getOpposite()); if (!rayFace.isEquivalent(hangingFace)) return; for (Hand handIn : Hand.values()) { - ItemStack itemstack = cPlayer.getHeldItem(handIn); + ItemStack itemstack = cPlayer.getItemInHand(handIn); int countBefore = itemstack.getCount(); ActionResultType actionResultType = - mc.playerController.func_217292_a(cPlayer, (ClientWorld) cPlayer.world, handIn, blockRay); + mc.gameMode.useItemOn(cPlayer, (ClientWorld) cPlayer.level, handIn, blockRay); if (actionResultType != ActionResultType.SUCCESS) return; - cPlayer.swingArm(handIn); - if (!itemstack.isEmpty() && (itemstack.getCount() != countBefore || mc.playerController.isInCreativeMode())) - mc.gameRenderer.itemRenderer.resetEquippedProgress(handIn); + cPlayer.swing(handIn); + if (!itemstack.isEmpty() && (itemstack.getCount() != countBefore || mc.gameMode.hasInfiniteItems())) + mc.gameRenderer.itemInHandRenderer.itemUsed(handIn); return; } } @Override - public void writeAdditional(CompoundNBT compound) { + public void addAdditionalSaveData(CompoundNBT compound) { compound.putByte("Facing", (byte) this.getFacingDirection() - .getIndex()); + .get3DDataValue()); BlockPos blockpos = this.getHangingPosition(); compound.putInt("TileX", blockpos.getX()); compound.putInt("TileY", blockpos.getY()); @@ -373,40 +373,40 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public void readAdditional(CompoundNBT compound) { + public void readAdditionalSaveData(CompoundNBT compound) { this.hangingPosition = new BlockPos(compound.getInt("TileX"), compound.getInt("TileY"), compound.getInt("TileZ")); - this.facingDirection = Direction.byIndex(compound.getByte("Facing")); + this.facingDirection = Direction.from3DDataValue(compound.getByte("Facing")); updateFacingWithBoundingBox(); } @Override - public ItemEntity entityDropItem(ItemStack stack, float yOffset) { + public ItemEntity spawnAtLocation(ItemStack stack, float yOffset) { float xOffset = (float) this.getFacingDirection() - .getXOffset() * 0.15F; + .getStepX() * 0.15F; float zOffset = (float) this.getFacingDirection() - .getZOffset() * 0.15F; + .getStepZ() * 0.15F; ItemEntity itementity = - new ItemEntity(this.world, this.getX() + xOffset, this.getY() + yOffset, this.getZ() + zOffset, stack); - itementity.setDefaultPickupDelay(); - this.world.addEntity(itementity); + new ItemEntity(this.level, this.getX() + xOffset, this.getY() + yOffset, this.getZ() + zOffset, stack); + itementity.setDefaultPickUpDelay(); + this.level.addFreshEntity(itementity); return itementity; } @Override - protected boolean shouldSetPosAfterLoading() { + protected boolean repositionEntityAfterLoad() { return false; } @Override - public void setPosition(double x, double y, double z) { + public void setPos(double x, double y, double z) { hangingPosition = new BlockPos(x, y, z); updateBoundingBox(); - isAirBorne = true; + hasImpulse = true; } @Override - public float getRotatedYaw(Rotation transformRotation) { + public float rotate(Rotation transformRotation) { if (this.getFacingDirection() .getAxis() != Direction.Axis.Y) { switch (transformRotation) { @@ -414,16 +414,16 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat facingDirection = facingDirection.getOpposite(); break; case COUNTERCLOCKWISE_90: - facingDirection = facingDirection.rotateYCCW(); + facingDirection = facingDirection.getCounterClockWise(); break; case CLOCKWISE_90: - facingDirection = facingDirection.rotateY(); + facingDirection = facingDirection.getClockWise(); default: break; } } - float f = MathHelper.wrapDegrees(this.rotationYaw); + float f = MathHelper.wrapDegrees(this.yRot); switch (transformRotation) { case CLOCKWISE_180: return f + 180.0F; @@ -441,8 +441,8 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public float getMirroredYaw(Mirror transformMirror) { - return this.getRotatedYaw(transformMirror.toRotation(this.getFacingDirection())); + public float mirror(Mirror transformMirror) { + return this.rotate(transformMirror.getRotation(this.getFacingDirection())); } public Direction getAttachedDirection(BlockPos pos) { @@ -450,10 +450,10 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public void onStruckByLightning(ServerWorld world, LightningBoltEntity lightningBolt) {} + public void thunderHit(ServerWorld world, LightningBoltEntity lightningBolt) {} @Override - public void recalculateSize() {} + public void refreshDimensions() {} public static EntityType.Builder build(EntityType.Builder builder) { @SuppressWarnings("unchecked") @@ -462,20 +462,20 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public IPacket createSpawnPacket() { + public IPacket getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override public void writeSpawnData(PacketBuffer buffer) { CompoundNBT compound = new CompoundNBT(); - writeAdditional(compound); - buffer.writeCompoundTag(compound); + addAdditionalSaveData(compound); + buffer.writeNbt(compound); } @Override public void readSpawnData(PacketBuffer additionalData) { - readAdditional(additionalData.readCompoundTag()); + readAdditionalSaveData(additionalData.readNbt()); } public Direction getFacingDirection() { @@ -488,12 +488,12 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public boolean doesEntityNotTriggerPressurePlate() { + public boolean isIgnoringBlockTriggers() { return true; } @Override public World getWorld() { - return world; + return level; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueHandler.java index 89830765c..f1778657f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueHandler.java @@ -35,7 +35,7 @@ import net.minecraftforge.fml.network.PacketDistributor; public class SuperGlueHandler { public static Map gatherGlue(IWorld world, BlockPos pos) { - List entities = world.getEntitiesWithinAABB(SuperGlueEntity.class, new AxisAlignedBB(pos)); + List entities = world.getEntitiesOfClass(SuperGlueEntity.class, new AxisAlignedBB(pos)); Map map = new HashMap<>(); for (SuperGlueEntity entity : entities) map.put(entity.getAttachedDirection(pos), entity); @@ -50,7 +50,7 @@ public class SuperGlueHandler { if (entity == null || world == null || pos == null) return; - if (world.isRemote()) + if (world.isClientSide()) return; Map gatheredGlue = gatherGlue(world, pos); @@ -63,50 +63,50 @@ public class SuperGlueHandler { } public static void glueInOffHandAppliesOnBlockPlace(EntityPlaceEvent event, BlockPos pos, PlayerEntity placer) { - ItemStack itemstack = placer.getHeldItemOffhand(); + ItemStack itemstack = placer.getOffhandItem(); ModifiableAttributeInstance reachAttribute = placer.getAttribute(ForgeMod.REACH_DISTANCE.get()); if (!AllItems.SUPER_GLUE.isIn(itemstack) || reachAttribute == null) return; - if (AllItems.WRENCH.isIn(placer.getHeldItemMainhand())) + if (AllItems.WRENCH.isIn(placer.getMainHandItem())) return; if (event.getPlacedAgainst() == IPlacementHelper.ID) return; double distance = reachAttribute.getValue(); Vector3d start = placer.getEyePosition(1); - Vector3d look = placer.getLook(1); + Vector3d look = placer.getViewVector(1); Vector3d end = start.add(look.x * distance, look.y * distance, look.z * distance); - World world = placer.world; + World world = placer.level; RayTraceWorld rayTraceWorld = - new RayTraceWorld(world, (p, state) -> p.equals(pos) ? Blocks.AIR.getDefaultState() : state); - BlockRayTraceResult ray = rayTraceWorld.rayTraceBlocks( + new RayTraceWorld(world, (p, state) -> p.equals(pos) ? Blocks.AIR.defaultBlockState() : state); + BlockRayTraceResult ray = rayTraceWorld.clip( new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, placer)); - Direction face = ray.getFace(); + Direction face = ray.getDirection(); if (face == null || ray.getType() == Type.MISS) return; - if (!ray.getPos() - .offset(face) + if (!ray.getBlockPos() + .relative(face) .equals(pos)) { event.setCanceled(true); return; } - SuperGlueEntity entity = new SuperGlueEntity(world, ray.getPos(), face.getOpposite()); + SuperGlueEntity entity = new SuperGlueEntity(world, ray.getBlockPos(), face.getOpposite()); CompoundNBT compoundnbt = itemstack.getTag(); if (compoundnbt != null) - EntityType.applyItemNBT(world, placer, entity, compoundnbt); + EntityType.updateCustomEntityTag(world, placer, entity, compoundnbt); if (entity.onValidSurface()) { - if (!world.isRemote) { + if (!world.isClientSide) { entity.playPlaceSound(); - world.addEntity(entity); + world.addFreshEntity(entity); AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> entity), - new GlueEffectPacket(ray.getPos(), face, true)); + new GlueEffectPacket(ray.getBlockPos(), face, true)); } - itemstack.damageItem(1, placer, SuperGlueItem::onBroken); + itemstack.hurtAndBreak(1, placer, SuperGlueItem::onBroken); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueItem.java index 98863bfaa..7cbd56b8f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueItem.java @@ -20,6 +20,8 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.Item.Properties; + public class SuperGlueItem extends Item { public SuperGlueItem(Properties properties) { @@ -27,7 +29,7 @@ public class SuperGlueItem extends Item { } @Override - public boolean isDamageable() { + public boolean canBeDepleted() { return true; } @@ -42,30 +44,30 @@ public class SuperGlueItem extends Item { } @Override - public ActionResultType onItemUse(ItemUseContext context) { - BlockPos blockpos = context.getPos(); - Direction direction = context.getFace(); - BlockPos blockpos1 = blockpos.offset(direction); + public ActionResultType useOn(ItemUseContext context) { + BlockPos blockpos = context.getClickedPos(); + Direction direction = context.getClickedFace(); + BlockPos blockpos1 = blockpos.relative(direction); PlayerEntity playerentity = context.getPlayer(); - ItemStack itemstack = context.getItem(); + ItemStack itemstack = context.getItemInHand(); if (playerentity == null || !this.canPlace(playerentity, direction, itemstack, blockpos1)) return ActionResultType.FAIL; - World world = context.getWorld(); + World world = context.getLevel(); SuperGlueEntity entity = new SuperGlueEntity(world, blockpos1, direction); CompoundNBT compoundnbt = itemstack.getTag(); if (compoundnbt != null) - EntityType.applyItemNBT(world, playerentity, entity, compoundnbt); + EntityType.updateCustomEntityTag(world, playerentity, entity, compoundnbt); if (!entity.onValidSurface()) return ActionResultType.FAIL; - if (!world.isRemote) { + if (!world.isClientSide) { entity.playPlaceSound(); - world.addEntity(entity); + world.addFreshEntity(entity); } - itemstack.damageItem(1, playerentity, SuperGlueItem::onBroken); + itemstack.hurtAndBreak(1, playerentity, SuperGlueItem::onBroken); return ActionResultType.SUCCESS; } @@ -75,22 +77,22 @@ public class SuperGlueItem extends Item { } protected boolean canPlace(PlayerEntity entity, Direction facing, ItemStack stack, BlockPos pos) { - return !World.isOutsideBuildHeight(pos) && entity.canPlayerEdit(pos, facing, stack); + return !World.isOutsideBuildHeight(pos) && entity.mayUseItemAt(pos, facing, stack); } @OnlyIn(Dist.CLIENT) public static void spawnParticles(World world, BlockPos pos, Direction direction, boolean fullBlock) { - Vector3d vec = Vector3d.of(direction.getDirectionVec()); + Vector3d vec = Vector3d.atLowerCornerOf(direction.getNormal()); Vector3d plane = VecHelper.axisAlingedPlaneOf(vec); Vector3d facePos = VecHelper.getCenterOf(pos) .add(vec.scale(.5f)); - float distance = fullBlock ? 1f : .25f + .25f * (world.rand.nextFloat() - .5f); + float distance = fullBlock ? 1f : .25f + .25f * (world.random.nextFloat() - .5f); plane = plane.scale(distance); ItemStack stack = new ItemStack(Items.SLIME_BALL); for (int i = fullBlock ? 40 : 15; i > 0; i--) { - Vector3d offset = VecHelper.rotate(plane, 360 * world.rand.nextFloat(), direction.getAxis()); + Vector3d offset = VecHelper.rotate(plane, 360 * world.random.nextFloat(), direction.getAxis()); Vector3d motion = offset.normalize() .scale(1 / 16f); if (fullBlock) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java index 34bfa5f3b..78e6f7868 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java @@ -41,7 +41,7 @@ public class SuperGlueRenderer extends EntityRenderer { } @Override - public ResourceLocation getEntityTexture(SuperGlueEntity entity) { + public ResourceLocation getTextureLocation(SuperGlueEntity entity) { return regular; } @@ -50,8 +50,8 @@ public class SuperGlueRenderer extends EntityRenderer { if (super.shouldRender(entity, frustum, x, y, z)) { PlayerEntity player = Minecraft.getInstance().player; boolean visible = entity.isVisible(); - boolean holdingGlue = AllItems.SUPER_GLUE.isIn(player.getHeldItemMainhand()) - || AllItems.SUPER_GLUE.isIn(player.getHeldItemOffhand()); + boolean holdingGlue = AllItems.SUPER_GLUE.isIn(player.getMainHandItem()) + || AllItems.SUPER_GLUE.isIn(player.getOffhandItem()); if (visible || holdingGlue) return true; @@ -64,29 +64,29 @@ public class SuperGlueRenderer extends EntityRenderer { IRenderTypeBuffer buffer, int light) { super.render(entity, yaw, partialTicks, ms, buffer, light); - IVertexBuilder builder = buffer.getBuffer(RenderType.getEntityCutout(getEntityTexture(entity))); + IVertexBuilder builder = buffer.getBuffer(RenderType.entityCutout(getTextureLocation(entity))); light = getBrightnessForRender(entity); Direction face = entity.getFacingDirection(); - ms.push(); + ms.pushPose(); MatrixStacker.of(ms) .rotateY(AngleHelper.horizontalAngleNew(face)) .rotateX(AngleHelper.verticalAngle(face)); - Entry peek = ms.peek(); + Entry peek = ms.last(); renderQuad(builder, peek, insideQuad, light, -1); renderQuad(builder, peek, outsideQuad, light, 1); - ms.pop(); + ms.popPose(); } private void initQuads() { - Vector3d diff = Vector3d.of(Direction.SOUTH.getDirectionVec()); + Vector3d diff = Vector3d.atLowerCornerOf(Direction.SOUTH.getNormal()); Vector3d extension = diff.normalize() .scale(1 / 32f - 1 / 128f); Vector3d plane = VecHelper.axisAlingedPlaneOf(diff); - Axis axis = Direction.getFacingFromVector(diff.x, diff.y, diff.z) + Axis axis = Direction.getNearest(diff.x, diff.y, diff.z) .getAxis(); Vector3d start = Vector3d.ZERO.subtract(extension); @@ -121,24 +121,24 @@ public class SuperGlueRenderer extends EntityRenderer { private int getBrightnessForRender(SuperGlueEntity entity) { BlockPos blockpos = entity.getHangingPosition(); - BlockPos blockpos2 = blockpos.offset(entity.getFacingDirection() + BlockPos blockpos2 = blockpos.relative(entity.getFacingDirection() .getOpposite()); - World world = entity.getEntityWorld(); - int light = world.isBlockPresent(blockpos) ? WorldRenderer.getLightmapCoordinates(world, blockpos) : 15; - int light2 = world.isBlockPresent(blockpos2) ? WorldRenderer.getLightmapCoordinates(world, blockpos2) : 15; + World world = entity.getCommandSenderWorld(); + int light = world.isLoaded(blockpos) ? WorldRenderer.getLightColor(world, blockpos) : 15; + int light2 = world.isLoaded(blockpos2) ? WorldRenderer.getLightColor(world, blockpos2) : 15; return Math.max(light, light2); } // Vertex format: pos x, pos y, pos z, u, v private void renderQuad(IVertexBuilder builder, Entry matrix, float[] data, int light, float normalZ) { for (int i = 0; i < 4; i++) { - builder.vertex(matrix.getModel(), data[5 * i], data[5 * i + 1], data[5 * i + 2]) + builder.vertex(matrix.pose(), data[5 * i], data[5 * i + 1], data[5 * i + 2]) .color(255, 255, 255, 255) - .texture(data[5 * i + 3], data[5 * i + 4]) - .overlay(OverlayTexture.DEFAULT_UV) - .light(light) - .normal(matrix.getNormal(), 0.0f, 0.0f, normalZ) + .uv(data[5 * i + 3], data[5 * i + 4]) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(light) + .normal(matrix.normal(), 0.0f, 0.0f, normalZ) .endVertex(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssembleRailType.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssembleRailType.java index 555d2ef1d..20dd43e65 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssembleRailType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssembleRailType.java @@ -48,7 +48,7 @@ public enum CartAssembleRailType implements IStringSerializable { } @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java index 73c1d93a2..18ffa2a3d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java @@ -57,6 +57,8 @@ import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class CartAssemblerBlock extends AbstractRailBlock implements ITE, IWrenchable, ISpecialBlockItemRequirement { @@ -69,36 +71,36 @@ public class CartAssemblerBlock extends AbstractRailBlock public CartAssemblerBlock(Properties properties) { super(true, properties); - setDefaultState(getDefaultState().with(POWERED, false) - .with(BACKWARDS, false) - .with(RAIL_TYPE, CartAssembleRailType.POWERED_RAIL)); + registerDefaultState(defaultBlockState().setValue(POWERED, false) + .setValue(BACKWARDS, false) + .setValue(RAIL_TYPE, CartAssembleRailType.POWERED_RAIL)); } public static BlockState createAnchor(BlockState state) { - Axis axis = state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Axis.Z : Axis.X; + Axis axis = state.getValue(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Axis.Z : Axis.X; return AllBlocks.MINECART_ANCHOR.getDefaultState() - .with(BlockStateProperties.HORIZONTAL_AXIS, axis); + .setValue(BlockStateProperties.HORIZONTAL_AXIS, axis); } private static Item getRailItem(BlockState state) { - return state.get(RAIL_TYPE) + return state.getValue(RAIL_TYPE) .getItem(); } public static BlockState getRailBlock(BlockState state) { - AbstractRailBlock railBlock = (AbstractRailBlock) state.get(RAIL_TYPE) + AbstractRailBlock railBlock = (AbstractRailBlock) state.getValue(RAIL_TYPE) .getBlock(); - BlockState railState = railBlock.getDefaultState() - .with(railBlock.getShapeProperty(), state.get(RAIL_SHAPE)); - if (railState.contains(ControllerRailBlock.BACKWARDS)) - railState = railState.with(ControllerRailBlock.BACKWARDS, state.get(BACKWARDS)); + BlockState railState = railBlock.defaultBlockState() + .setValue(railBlock.getShapeProperty(), state.getValue(RAIL_SHAPE)); + if (railState.hasProperty(ControllerRailBlock.BACKWARDS)) + railState = railState.setValue(ControllerRailBlock.BACKWARDS, state.getValue(BACKWARDS)); return railState; } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(RAIL_SHAPE, POWERED, RAIL_TYPE, BACKWARDS); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override @@ -121,7 +123,7 @@ public class CartAssemblerBlock extends AbstractRailBlock AbstractMinecartEntity cart) { if (!canAssembleTo(cart)) return; - if (world.isRemote) + if (world.isClientSide) return; withTileEntityDo(world, pos, te -> te.assembleNextTick(cart)); @@ -140,8 +142,8 @@ public class CartAssemblerBlock extends AbstractRailBlock } public static CartAssemblerAction getActionForCart(BlockState state, AbstractMinecartEntity cart) { - CartAssembleRailType type = state.get(RAIL_TYPE); - boolean powered = state.get(POWERED); + CartAssembleRailType type = state.getValue(RAIL_TYPE); + boolean powered = state.getValue(POWERED); switch (type) { case ACTIVATOR_RAIL: return powered ? CartAssemblerAction.DISASSEMBLE : CartAssemblerAction.PASS; @@ -166,10 +168,10 @@ public class CartAssemblerBlock extends AbstractRailBlock @Override @Nonnull - public ActionResultType onUse(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, + public ActionResultType use(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult blockRayTraceResult) { - ItemStack itemStack = player.getHeldItem(hand); + ItemStack itemStack = player.getItemInHand(hand); Item previousItem = getRailItem(state); Item heldItem = itemStack.getItem(); if (heldItem != previousItem) { @@ -180,8 +182,8 @@ public class CartAssemblerBlock extends AbstractRailBlock newType = type; if (newType == null) return ActionResultType.PASS; - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 1, 1); - world.setBlockState(pos, state.with(RAIL_TYPE, newType)); + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, 1, 1); + world.setBlockAndUpdate(pos, state.setValue(RAIL_TYPE, newType)); if (!player.isCreative()) { itemStack.shrink(1); @@ -196,11 +198,11 @@ public class CartAssemblerBlock extends AbstractRailBlock @Override public void neighborChanged(@Nonnull BlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull Block blockIn, @Nonnull BlockPos fromPos, boolean isMoving) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - boolean previouslyPowered = state.get(POWERED); - if (previouslyPowered != worldIn.isBlockPowered(pos)) - worldIn.setBlockState(pos, state.cycle(POWERED), 2); + boolean previouslyPowered = state.getValue(POWERED); + if (previouslyPowered != worldIn.hasNeighborSignal(pos)) + worldIn.setBlock(pos, state.cycle(POWERED), 2); super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving); } @@ -218,7 +220,7 @@ public class CartAssemblerBlock extends AbstractRailBlock } protected Axis getRailAxis(BlockState state) { - return state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Direction.Axis.Z : Direction.Axis.X; + return state.getValue(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Direction.Axis.Z : Direction.Axis.X; } @Override @@ -230,12 +232,12 @@ public class CartAssemblerBlock extends AbstractRailBlock return VoxelShapes.empty(); if (entity instanceof PlayerEntity) return AllShapes.CART_ASSEMBLER_PLAYER_COLLISION.get(getRailAxis(state)); - return VoxelShapes.fullCube(); + return VoxelShapes.block(); } @Override @Nonnull - public PushReaction getPushReaction(@Nonnull BlockState state) { + public PushReaction getPistonPushReaction(@Nonnull BlockState state) { return PushReaction.BLOCK; } @@ -245,7 +247,7 @@ public class CartAssemblerBlock extends AbstractRailBlock } @Override - public boolean isValidPosition(@Nonnull BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos) { + public boolean canSurvive(@Nonnull BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos) { return false; } @@ -270,26 +272,26 @@ public class CartAssemblerBlock extends AbstractRailBlock @SuppressWarnings("deprecation") public List getDropsNoRail(BlockState state, ServerWorld world, BlockPos pos, @Nullable TileEntity p_220077_3_, @Nullable Entity p_220077_4_, ItemStack p_220077_5_) { - return super.getDrops(state, (new LootContext.Builder(world)).withRandom(world.rand) - .withParameter(LootParameters.ORIGIN, Vector3d.of(pos)) + return super.getDrops(state, (new LootContext.Builder(world)).withRandom(world.random) + .withParameter(LootParameters.ORIGIN, Vector3d.atLowerCornerOf(pos)) .withParameter(LootParameters.TOOL, p_220077_5_) - .withNullableParameter(LootParameters.THIS_ENTITY, p_220077_4_) - .withNullableParameter(LootParameters.BLOCK_ENTITY, p_220077_3_)); + .withOptionalParameter(LootParameters.THIS_ENTITY, p_220077_4_) + .withOptionalParameter(LootParameters.BLOCK_ENTITY, p_220077_3_)); } @Override public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) { - World world = context.getWorld(); - BlockPos pos = context.getPos(); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); PlayerEntity player = context.getPlayer(); - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; if (player != null && !player.isCreative()) - getDropsNoRail(state, (ServerWorld) world, pos, world.getTileEntity(pos), player, context.getItem()) + getDropsNoRail(state, (ServerWorld) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) .forEach(itemStack -> player.inventory.placeItemBackInInventory(world, itemStack)); if (world instanceof ServerWorld) - state.spawnAdditionalDrops((ServerWorld) world, pos, ItemStack.EMPTY); - world.setBlockState(pos, getRailBlock(state)); + state.spawnAfterBreak((ServerWorld) world, pos, ItemStack.EMPTY); + world.setBlockAndUpdate(pos, getRailBlock(state)); return ActionResultType.SUCCESS; } @@ -300,9 +302,9 @@ public class CartAssemblerBlock extends AbstractRailBlock } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(BlockStateProperties.HORIZONTAL_AXIS); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override @@ -314,18 +316,18 @@ public class CartAssemblerBlock extends AbstractRailBlock } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getWorld(); - if (world.isRemote) + World world = context.getLevel(); + if (world.isClientSide) return ActionResultType.SUCCESS; - BlockPos pos = context.getPos(); - world.setBlockState(pos, rotate(state, Rotation.CLOCKWISE_90), 3); - world.notifyNeighborsOfStateChange(pos.down(), this); + BlockPos pos = context.getClickedPos(); + world.setBlock(pos, rotate(state, Rotation.CLOCKWISE_90), 3); + world.updateNeighborsAt(pos.below(), this); return ActionResultType.SUCCESS; } @@ -334,11 +336,11 @@ public class CartAssemblerBlock extends AbstractRailBlock if (rotation == Rotation.NONE) return state; BlockState base = AllBlocks.CONTROLLER_RAIL.getDefaultState() - .with(ControllerRailBlock.SHAPE, state.get(RAIL_SHAPE)) - .with(ControllerRailBlock.BACKWARDS, state.get(BACKWARDS)) + .setValue(ControllerRailBlock.SHAPE, state.getValue(RAIL_SHAPE)) + .setValue(ControllerRailBlock.BACKWARDS, state.getValue(BACKWARDS)) .rotate(rotation); - return state.with(RAIL_SHAPE, base.get(ControllerRailBlock.SHAPE)) - .with(BACKWARDS, base.get(ControllerRailBlock.BACKWARDS)); + return state.setValue(RAIL_SHAPE, base.getValue(ControllerRailBlock.SHAPE)) + .setValue(BACKWARDS, base.getValue(ControllerRailBlock.BACKWARDS)); } @Override @@ -346,21 +348,21 @@ public class CartAssemblerBlock extends AbstractRailBlock if (mirror == Mirror.NONE) return state; BlockState base = AllBlocks.CONTROLLER_RAIL.getDefaultState() - .with(ControllerRailBlock.SHAPE, state.get(RAIL_SHAPE)) - .with(ControllerRailBlock.BACKWARDS, state.get(BACKWARDS)) + .setValue(ControllerRailBlock.SHAPE, state.getValue(RAIL_SHAPE)) + .setValue(ControllerRailBlock.BACKWARDS, state.getValue(BACKWARDS)) .mirror(mirror); - return state.with(BACKWARDS, base.get(ControllerRailBlock.BACKWARDS)); + return state.setValue(BACKWARDS, base.getValue(ControllerRailBlock.BACKWARDS)); } public static Direction getHorizontalDirection(BlockState blockState) { if (!(blockState.getBlock() instanceof CartAssemblerBlock)) return Direction.SOUTH; Direction pointingTo = getPointingTowards(blockState); - return blockState.get(BACKWARDS) ? pointingTo.getOpposite() : pointingTo; + return blockState.getValue(BACKWARDS) ? pointingTo.getOpposite() : pointingTo; } private static Direction getPointingTowards(BlockState state) { - switch (state.get(RAIL_SHAPE)) { + switch (state.getValue(RAIL_SHAPE)) { case EAST_WEST: return Direction.WEST; default: diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java index b09d2a59c..cb597bab5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java @@ -21,6 +21,8 @@ import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.item.Item.Properties; + public class CartAssemblerBlockItem extends BlockItem { public CartAssemblerBlockItem(Block block, Properties properties) { @@ -29,18 +31,18 @@ public class CartAssemblerBlockItem extends BlockItem { @Override @Nonnull - public ActionResultType onItemUse(ItemUseContext context) { + public ActionResultType useOn(ItemUseContext context) { if (tryPlaceAssembler(context)) { - context.getWorld() - .playSound(null, context.getPos(), SoundEvents.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1); + context.getLevel() + .playSound(null, context.getClickedPos(), SoundEvents.STONE_PLACE, SoundCategory.BLOCKS, 1, 1); return ActionResultType.SUCCESS; } - return super.onItemUse(context); + return super.useOn(context); } public boolean tryPlaceAssembler(ItemUseContext context) { - BlockPos pos = context.getPos(); - World world = context.getWorld(); + BlockPos pos = context.getClickedPos(); + World world = context.getLevel(); BlockState state = world.getBlockState(pos); Block block = state.getBlock(); PlayerEntity player = context.getPlayer(); @@ -52,33 +54,33 @@ public class CartAssemblerBlockItem extends BlockItem { return false; } - RailShape shape = state.get(((AbstractRailBlock) block).getShapeProperty()); + RailShape shape = state.getValue(((AbstractRailBlock) block).getShapeProperty()); if (shape != RailShape.EAST_WEST && shape != RailShape.NORTH_SOUTH) return false; BlockState newState = AllBlocks.CART_ASSEMBLER.getDefaultState() - .with(CartAssemblerBlock.RAIL_SHAPE, shape); + .setValue(CartAssemblerBlock.RAIL_SHAPE, shape); CartAssembleRailType newType = null; for (CartAssembleRailType type : CartAssembleRailType.values()) if (type.matches(state)) newType = type; if (newType == null) return false; - if (world.isRemote) + if (world.isClientSide) return true; - newState = newState.with(CartAssemblerBlock.RAIL_TYPE, newType); - if (state.contains(ControllerRailBlock.BACKWARDS)) - newState = newState.with(CartAssemblerBlock.BACKWARDS, state.get(ControllerRailBlock.BACKWARDS)); + newState = newState.setValue(CartAssemblerBlock.RAIL_TYPE, newType); + if (state.hasProperty(ControllerRailBlock.BACKWARDS)) + newState = newState.setValue(CartAssemblerBlock.BACKWARDS, state.getValue(ControllerRailBlock.BACKWARDS)); else { - Direction direction = player.getAdjustedHorizontalFacing(); + Direction direction = player.getMotionDirection(); newState = - newState.with(CartAssemblerBlock.BACKWARDS, direction.getAxisDirection() == AxisDirection.POSITIVE); + newState.setValue(CartAssemblerBlock.BACKWARDS, direction.getAxisDirection() == AxisDirection.POSITIVE); } - world.setBlockState(pos, newState); + world.setBlockAndUpdate(pos, newState); if (!player.isCreative()) - context.getItem() + context.getItemInHand() .shrink(1); return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerTileEntity.java index ea52e21b3..80393ed1e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerTileEntity.java @@ -73,43 +73,43 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay return; resetTicksSinceMinecartUpdate(); - BlockState state = world.getBlockState(pos); + BlockState state = level.getBlockState(worldPosition); if (!AllBlocks.CART_ASSEMBLER.has(state)) return; CartAssemblerBlock block = (CartAssemblerBlock) state.getBlock(); CartAssemblerBlock.CartAssemblerAction action = CartAssemblerBlock.getActionForCart(state, cart); if (action.shouldAssemble()) - assemble(world, pos, cart); + assemble(level, worldPosition, cart); if (action.shouldDisassemble()) - disassemble(world, pos, cart); + disassemble(level, worldPosition, cart); if (action == CartAssemblerBlock.CartAssemblerAction.ASSEMBLE_ACCELERATE) { - if (cart.getMotion() + if (cart.getDeltaMovement() .length() > 1 / 128f) { - Direction facing = cart.getAdjustedHorizontalFacing(); - RailShape railShape = state.get(CartAssemblerBlock.RAIL_SHAPE); + Direction facing = cart.getMotionDirection(); + RailShape railShape = state.getValue(CartAssemblerBlock.RAIL_SHAPE); for (Direction d : Iterate.directionsInAxis(railShape == RailShape.EAST_WEST ? Axis.X : Axis.Z)) - if (world.getBlockState(pos.offset(d)) - .isNormalCube(world, pos.offset(d))) + if (level.getBlockState(worldPosition.relative(d)) + .isRedstoneConductor(level, worldPosition.relative(d))) facing = d.getOpposite(); - float speed = block.getRailMaxSpeed(state, world, pos, cart); - cart.setMotion(facing.getXOffset() * speed, facing.getYOffset() * speed, facing.getZOffset() * speed); + float speed = block.getRailMaxSpeed(state, level, worldPosition, cart); + cart.setDeltaMovement(facing.getStepX() * speed, facing.getStepY() * speed, facing.getStepZ() * speed); } } if (action == CartAssemblerBlock.CartAssemblerAction.ASSEMBLE_ACCELERATE_DIRECTIONAL) { Vector3i accelerationVector = ControllerRailBlock.getAccelerationVector(AllBlocks.CONTROLLER_RAIL.getDefaultState() - .with(ControllerRailBlock.SHAPE, state.get(CartAssemblerBlock.RAIL_SHAPE)) - .with(ControllerRailBlock.BACKWARDS, state.get(CartAssemblerBlock.BACKWARDS))); - float speed = block.getRailMaxSpeed(state, world, pos, cart); - cart.setMotion(Vector3d.of(accelerationVector) + .setValue(ControllerRailBlock.SHAPE, state.getValue(CartAssemblerBlock.RAIL_SHAPE)) + .setValue(ControllerRailBlock.BACKWARDS, state.getValue(CartAssemblerBlock.BACKWARDS))); + float speed = block.getRailMaxSpeed(state, level, worldPosition, cart); + cart.setDeltaMovement(Vector3d.atLowerCornerOf(accelerationVector) .scale(speed)); } if (action == CartAssemblerBlock.CartAssemblerAction.DISASSEMBLE_BRAKE) { - Vector3d diff = VecHelper.getCenterOf(pos) - .subtract(cart.getPositionVec()); - cart.setMotion(diff.x / 16f, 0, diff.z / 16f); + Vector3d diff = VecHelper.getCenterOf(worldPosition) + .subtract(cart.position()); + cart.setDeltaMovement(diff.x / 16f, 0, diff.z / 16f); } } @@ -143,9 +143,9 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay Direction initialOrientation = CartAssemblerBlock.getHorizontalDirection(getBlockState()); if (couplingFound) { - cart.setPosition(pos.getX() + .5f, pos.getY(), pos.getZ() + .5f); - if (!CouplingHandler.tryToCoupleCarts(null, world, cart.getEntityId(), - contraption.connectedCart.getEntityId())) + cart.setPos(pos.getX() + .5f, pos.getY(), pos.getZ() + .5f); + if (!CouplingHandler.tryToCoupleCarts(null, world, cart.getId(), + contraption.connectedCart.getId())) return; } @@ -154,16 +154,16 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay contraption.expandBoundsAroundAxis(Axis.Y); if (couplingFound) { - Vector3d diff = contraption.connectedCart.getPositionVec() - .subtract(cart.getPositionVec()); - initialOrientation = Direction.fromAngle(MathHelper.atan2(diff.z, diff.x) * 180 / Math.PI); + Vector3d diff = contraption.connectedCart.position() + .subtract(cart.position()); + initialOrientation = Direction.fromYRot(MathHelper.atan2(diff.z, diff.x) * 180 / Math.PI); } OrientedContraptionEntity entity = OrientedContraptionEntity.create(world, contraption, initialOrientation); if (couplingFound) - entity.setCouplingId(cart.getUniqueID()); - entity.setPosition(pos.getX(), pos.getY(), pos.getZ()); - world.addEntity(entity); + entity.setCouplingId(cart.getUUID()); + entity.setPos(pos.getX(), pos.getY(), pos.getZ()); + world.addFreshEntity(entity); entity.startRiding(cart); if (cart instanceof FurnaceMinecartEntity) { @@ -187,7 +187,7 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay if (couplingId == null) { contraption.yaw = CartAssemblerBlock.getHorizontalDirection(getBlockState()) - .getHorizontalAngle(); + .toYRot(); disassembleCart(cart); return; } @@ -202,7 +202,7 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay if (minecartController.cart() == cart) continue; BlockPos otherPos = minecartController.cart() - .getBlockPos(); + .blockPosition(); BlockState blockState = world.getBlockState(otherPos); if (!AllBlocks.CART_ASSEMBLER.has(blockState)) return; @@ -218,11 +218,11 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay } protected void disassembleCart(AbstractMinecartEntity cart) { - cart.removePassengers(); + cart.ejectPassengers(); if (cart instanceof FurnaceMinecartEntity) { CompoundNBT nbt = cart.serializeNBT(); - nbt.putDouble("PushZ", cart.getMotion().x); - nbt.putDouble("PushX", cart.getMotion().z); + nbt.putDouble("PushZ", cart.getDeltaMovement().x); + nbt.putDouble("PushX", cart.getDeltaMovement().z); cart.deserializeNBT(nbt); } } @@ -263,9 +263,9 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay if (d.getAxis() .isVertical()) return false; - if (!state.contains(CartAssemblerBlock.RAIL_SHAPE)) + if (!state.hasProperty(CartAssemblerBlock.RAIL_SHAPE)) return false; - RailShape railShape = state.get(CartAssemblerBlock.RAIL_SHAPE); + RailShape railShape = state.getValue(CartAssemblerBlock.RAIL_SHAPE); return (d.getAxis() == Axis.X) == (railShape == RailShape.NORTH_SOUTH); }); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/ItemHandlerModifiableFromIInventory.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/ItemHandlerModifiableFromIInventory.java index 3dd313411..669bff17e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/ItemHandlerModifiableFromIInventory.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/ItemHandlerModifiableFromIInventory.java @@ -21,17 +21,17 @@ public class ItemHandlerModifiableFromIInventory implements IItemHandlerModifiab @Override public void setStackInSlot(int slot, ItemStack stack) { - inventory.setInventorySlotContents(slot, stack); + inventory.setItem(slot, stack); } @Override public int getSlots() { - return inventory.getSizeInventory(); + return inventory.getContainerSize(); } @Override public ItemStack getStackInSlot(int slot) { - return inventory.getStackInSlot(slot); + return inventory.getItem(slot); } @Override @@ -119,12 +119,12 @@ public class ItemHandlerModifiableFromIInventory implements IItemHandlerModifiab @Override public int getSlotLimit(int slot) { - return inventory.getInventoryStackLimit(); + return inventory.getMaxStackSize(); } @Override public boolean isItemValid(int slot, ItemStack stack) { - return inventory.isItemValidForSlot(slot, stack); + return inventory.canPlaceItem(slot, stack); } private void validateSlotIndex(int slot) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java index 3bd9f4fe4..8e88ff2a5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java @@ -46,6 +46,8 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.item.Item.Properties; + @EventBusSubscriber public class MinecartContraptionItem extends Item { @@ -66,7 +68,7 @@ public class MinecartContraptionItem extends Item { private MinecartContraptionItem(Type minecartTypeIn, Properties builder) { super(builder); this.minecartType = minecartTypeIn; - DispenserBlock.registerDispenseBehavior(this, DISPENSER_BEHAVIOR); + DispenserBlock.registerBehavior(this, DISPENSER_BEHAVIOR); } // Taken and adjusted from MinecartItem @@ -74,35 +76,35 @@ public class MinecartContraptionItem extends Item { private final DefaultDispenseItemBehavior behaviourDefaultDispenseItem = new DefaultDispenseItemBehavior(); @Override - public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { + public ItemStack execute(IBlockSource source, ItemStack stack) { Direction direction = source.getBlockState() - .get(DispenserBlock.FACING); - World world = source.getWorld(); - double d0 = source.getX() + (double) direction.getXOffset() * 1.125D; - double d1 = Math.floor(source.getY()) + (double) direction.getYOffset(); - double d2 = source.getZ() + (double) direction.getZOffset() * 1.125D; - BlockPos blockpos = source.getBlockPos() - .offset(direction); + .getValue(DispenserBlock.FACING); + World world = source.getLevel(); + double d0 = source.x() + (double) direction.getStepX() * 1.125D; + double d1 = Math.floor(source.y()) + (double) direction.getStepY(); + double d2 = source.z() + (double) direction.getStepZ() * 1.125D; + BlockPos blockpos = source.getPos() + .relative(direction); BlockState blockstate = world.getBlockState(blockpos); RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock) blockstate.getBlock()).getRailDirection(blockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; double d3; - if (blockstate.isIn(BlockTags.RAILS)) { + if (blockstate.is(BlockTags.RAILS)) { if (railshape.isAscending()) { d3 = 0.6D; } else { d3 = 0.1D; } } else { - if (blockstate.getMaterial() != Material.AIR || !world.getBlockState(blockpos.down()) - .isIn(BlockTags.RAILS)) { + if (blockstate.getMaterial() != Material.AIR || !world.getBlockState(blockpos.below()) + .is(BlockTags.RAILS)) { return this.behaviourDefaultDispenseItem.dispense(source, stack); } - BlockState blockstate1 = world.getBlockState(blockpos.down()); + BlockState blockstate1 = world.getBlockState(blockpos.below()); RailShape railshape1 = blockstate1.getBlock() instanceof AbstractRailBlock - ? ((AbstractRailBlock) blockstate1.getBlock()).getRailDirection(blockstate1, world, blockpos.down(), + ? ((AbstractRailBlock) blockstate1.getBlock()).getRailDirection(blockstate1, world, blockpos.below(), null) : RailShape.NORTH_SOUTH; if (direction != Direction.DOWN && railshape1.isAscending()) { @@ -112,11 +114,11 @@ public class MinecartContraptionItem extends Item { } } - AbstractMinecartEntity abstractminecartentity = AbstractMinecartEntity.create(world, d0, d1 + d3, d2, + AbstractMinecartEntity abstractminecartentity = AbstractMinecartEntity.createMinecart(world, d0, d1 + d3, d2, ((MinecartContraptionItem) stack.getItem()).minecartType); - if (stack.hasDisplayName()) - abstractminecartentity.setCustomName(stack.getDisplayName()); - world.addEntity(abstractminecartentity); + if (stack.hasCustomHoverName()) + abstractminecartentity.setCustomName(stack.getHoverName()); + world.addFreshEntity(abstractminecartentity); addContraptionToMinecart(world, stack, abstractminecartentity, direction); stack.shrink(1); @@ -124,23 +126,23 @@ public class MinecartContraptionItem extends Item { } @Override - protected void playDispenseSound(IBlockSource source) { - source.getWorld() - .playEvent(1000, source.getBlockPos(), 0); + protected void playSound(IBlockSource source) { + source.getLevel() + .levelEvent(1000, source.getPos(), 0); } }; // Taken and adjusted from MinecartItem @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); - BlockPos blockpos = context.getPos(); + public ActionResultType useOn(ItemUseContext context) { + World world = context.getLevel(); + BlockPos blockpos = context.getClickedPos(); BlockState blockstate = world.getBlockState(blockpos); - if (!blockstate.isIn(BlockTags.RAILS)) { + if (!blockstate.is(BlockTags.RAILS)) { return ActionResultType.FAIL; } else { - ItemStack itemstack = context.getItem(); - if (!world.isRemote) { + ItemStack itemstack = context.getItemInHand(); + if (!world.isClientSide) { RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock) blockstate.getBlock()).getRailDirection(blockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; @@ -150,14 +152,14 @@ public class MinecartContraptionItem extends Item { } AbstractMinecartEntity abstractminecartentity = - AbstractMinecartEntity.create(world, (double) blockpos.getX() + 0.5D, + AbstractMinecartEntity.createMinecart(world, (double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 0.0625D + d0, (double) blockpos.getZ() + 0.5D, this.minecartType); - if (itemstack.hasDisplayName()) - abstractminecartentity.setCustomName(itemstack.getDisplayName()); + if (itemstack.hasCustomHoverName()) + abstractminecartentity.setCustomName(itemstack.getHoverName()); PlayerEntity player = context.getPlayer(); - world.addEntity(abstractminecartentity); + world.addFreshEntity(abstractminecartentity); addContraptionToMinecart(world, itemstack, abstractminecartentity, - player == null ? null : player.getHorizontalFacing()); + player == null ? null : player.getDirection()); } itemstack.shrink(1); @@ -177,21 +179,21 @@ public class MinecartContraptionItem extends Item { OrientedContraptionEntity contraptionEntity = newFacing == null ? OrientedContraptionEntity.create(world, mountedContraption, intialOrientation) : OrientedContraptionEntity.createAtYaw(world, mountedContraption, intialOrientation, - newFacing.getHorizontalAngle()); + newFacing.toYRot()); contraptionEntity.startRiding(cart); - contraptionEntity.setPosition(cart.getX(), cart.getY(), cart.getZ()); - world.addEntity(contraptionEntity); + contraptionEntity.setPos(cart.getX(), cart.getY(), cart.getZ()); + world.addFreshEntity(contraptionEntity); } } @Override - public String getTranslationKey(ItemStack stack) { + public String getDescriptionId(ItemStack stack) { return "item.create.minecart_contraption"; } @Override - public void fillItemGroup(ItemGroup group, NonNullList items) {} + public void fillItemCategory(ItemGroup group, NonNullList items) {} @SubscribeEvent public static void wrenchCanBeUsedToPickUpMinecartContraptions(PlayerInteractEvent.EntityInteract event) { @@ -200,11 +202,11 @@ public class MinecartContraptionItem extends Item { if (player == null || entity == null) return; - ItemStack wrench = player.getHeldItem(event.getHand()); + ItemStack wrench = player.getItemInHand(event.getHand()); if (!AllItems.WRENCH.isIn(wrench)) return; if (entity instanceof AbstractContraptionEntity) - entity = entity.getRidingEntity(); + entity = entity.getVehicle(); if (!(entity instanceof AbstractMinecartEntity)) return; if (!entity.isAlive()) @@ -222,27 +224,27 @@ public class MinecartContraptionItem extends Item { Contraption blocks = contraption.getContraption(); if (blocks != null && blocks.getBlocks().values().stream() .anyMatch(i -> i.state.getBlock() instanceof SpawnerBlock)) { - player.sendStatusMessage(Lang.translate("contraption.minecart_contraption_illegal_pickup") - .formatted(TextFormatting.RED), true); + player.displayClientMessage(Lang.translate("contraption.minecart_contraption_illegal_pickup") + .withStyle(TextFormatting.RED), true); return; } } - if (event.getWorld().isRemote) { + if (event.getWorld().isClientSide) { event.setCancellationResult(ActionResultType.SUCCESS); event.setCanceled(true); return; } - ItemStack generatedStack = create(type, contraption).setDisplayName(entity.getCustomName()); + ItemStack generatedStack = create(type, contraption).setHoverName(entity.getCustomName()); try { ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(); CompressedStreamTools.write(generatedStack.serializeNBT(), dataOutput); int estimatedPacketSize = dataOutput.toByteArray().length; if (estimatedPacketSize > 2_000_000) { - player.sendStatusMessage(Lang.translate("contraption.minecart_contraption_too_big") - .formatted(TextFormatting.RED), true); + player.displayClientMessage(Lang.translate("contraption.minecart_contraption_too_big") + .withStyle(TextFormatting.RED), true); return; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MountedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MountedContraption.java index 9f4149f81..959dcc4cf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MountedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MountedContraption.java @@ -35,6 +35,8 @@ import net.minecraft.world.gen.feature.template.Template.BlockInfo; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.wrapper.InvWrapper; +import com.simibubi.create.content.contraptions.components.structureMovement.Contraption.ContraptionInvWrapper; + public class MountedContraption extends Contraption { public CartMovementMode rotationMode; @@ -56,14 +58,14 @@ public class MountedContraption extends Contraption { @Override public boolean assemble(World world, BlockPos pos) throws AssemblyException { BlockState state = world.getBlockState(pos); - if (!state.contains(RAIL_SHAPE)) + if (!state.hasProperty(RAIL_SHAPE)) return false; if (!searchMovedStructure(world, pos, null)) return false; - Axis axis = state.get(RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.X : Axis.Z; + Axis axis = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.X : Axis.Z; addBlock(pos, Pair.of(new BlockInfo(pos, AllBlocks.MINECART_ANCHOR.getDefaultState() - .with(BlockStateProperties.HORIZONTAL_AXIS, axis), null), null)); + .setValue(BlockStateProperties.HORIZONTAL_AXIS, axis), null), null)); if (blocks.size() == 1) return false; @@ -74,7 +76,7 @@ public class MountedContraption extends Contraption { @Override protected boolean addToInitialFrontier(World world, BlockPos pos, Direction direction, Queue frontier) { frontier.clear(); - frontier.add(pos.up()); + frontier.add(pos.above()); return true; } @@ -94,11 +96,11 @@ public class MountedContraption extends Contraption { if (axis.isVertical() || !VecHelper.onSameAxis(anchor, pos, axis)) continue; for (AbstractMinecartEntity abstractMinecartEntity : world - .getEntitiesWithinAABB(AbstractMinecartEntity.class, new AxisAlignedBB(pos))) { + .getEntitiesOfClass(AbstractMinecartEntity.class, new AxisAlignedBB(pos))) { if (!CartAssemblerBlock.canAssembleTo(abstractMinecartEntity)) break; connectedCart = abstractMinecartEntity; - connectedCart.setPosition(pos.getX() + .5, pos.getY(), pos.getZ() + .5f); + connectedCart.setPos(pos.getX() + .5, pos.getY(), pos.getZ() + .5f); } } @@ -117,7 +119,7 @@ public class MountedContraption extends Contraption { if (axis.isVertical() || !VecHelper.onSameAxis(anchor, pos, axis)) continue; for (AbstractMinecartEntity abstractMinecartEntity : world - .getEntitiesWithinAABB(AbstractMinecartEntity.class, new AxisAlignedBB(pos))) { + .getEntitiesOfClass(AbstractMinecartEntity.class, new AxisAlignedBB(pos))) { if (!CartAssemblerBlock.canAssembleTo(abstractMinecartEntity)) break; return true; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java index 35dfac048..bb4962679 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java @@ -21,6 +21,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; +import com.simibubi.create.content.contraptions.components.structureMovement.IControlContraption.MovementMode; + public abstract class LinearActuatorTileEntity extends KineticTileEntity implements IControlContraption, IDisplayAssemblyExceptions { @@ -61,11 +63,11 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity movedContraption = null; } - if (world.isRemote) + if (level.isClientSide) clientOffsetDiff *= .75f; if (waitingForSpeedChange && movedContraption != null) { - if (world.isRemote) { + if (level.isClientSide) { float syncSpeed = clientOffsetDiff / 2f; offset += syncSpeed; movedContraption.setContraptionMotion(toMotionVector(syncSpeed)); @@ -75,7 +77,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity return; } - if (!world.isRemote && assembleNextTick) { + if (!level.isClientSide && assembleNextTick) { assembleNextTick = false; if (running) { if (getSpeed() == 0) @@ -114,7 +116,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity int extensionRange = getExtensionRange(); if (offset <= 0 || offset >= extensionRange) { offset = offset <= 0 ? 0 : extensionRange; - if (!world.isRemote) { + if (!level.isClientSide) { applyContraptionMotion(); applyContraptionPosition(); tryDisassemble(); @@ -130,7 +132,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity @Override public void lazyTick() { super.lazyTick(); - if (movedContraption != null && !world.isRemote) + if (movedContraption != null && !level.isClientSide) sendData(); } @@ -152,16 +154,16 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity if (movedContraption != null && Math.signum(prevSpeed) != Math.signum(getSpeed()) && prevSpeed != 0) { movedContraption.getContraption() - .stop(world); + .stop(level); } } @Override - public void remove() { - this.removed = true; - if (!world.isRemote) + public void setRemoved() { + this.remove = true; + if (!level.isClientSide) disassemble(); - super.remove(); + super.setRemoved(); } @Override @@ -223,7 +225,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity protected void visitNewPosition() {} protected void tryDisassemble() { - if (removed) { + if (remove) { disassemble(); return; } @@ -241,7 +243,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity @Override public void collided() { - if (world.isRemote) { + if (level.isClientSide) { waitingForSpeedChange = true; return; } @@ -264,14 +266,14 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity if (movedContraption == null) return; Vector3d vec = toPosition(offset); - movedContraption.setPosition(vec.x, vec.y, vec.z); + movedContraption.setPos(vec.x, vec.y, vec.z); if (getSpeed() == 0 || waitingForSpeedChange) movedContraption.setContraptionMotion(Vector3d.ZERO); } public float getMovementSpeed() { float movementSpeed = MathHelper.clamp(convertToLinear(getSpeed()), -.49f, .49f) + clientOffsetDiff / 2f; - if (world.isRemote) + if (level.isClientSide) movementSpeed *= ServerSpeedProvider.get(); return movementSpeed; } @@ -282,7 +284,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity @Override public void onStall() { - if (!world.isRemote) { + if (!level.isClientSide) { forceMove = true; sendData(); } @@ -301,7 +303,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity @Override public void attach(ControlledContraptionEntity contraption) { this.movedContraption = contraption; - if (!world.isRemote) { + if (!level.isClientSide) { this.running = true; sendData(); } @@ -314,6 +316,6 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity @Override public BlockPos getBlockPosition() { - return pos; + return worldPosition; } } 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 98efed20f..04d12e65b 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 @@ -35,6 +35,8 @@ import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.Tags; +import net.minecraft.block.AbstractBlock.Properties; + public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implements ITE { public static final EnumProperty STATE = EnumProperty.create("state", PistonState.class); @@ -50,75 +52,75 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement protected MechanicalPistonBlock(Properties properties, boolean sticky) { super(properties); - setDefaultState(getDefaultState().with(FACING, Direction.NORTH) - .with(STATE, PistonState.RETRACTED)); + registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH) + .setValue(STATE, PistonState.RETRACTED)); isSticky = sticky; } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(STATE); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!player.isAllowEdit()) + if (!player.mayBuild()) return ActionResultType.PASS; - if (player.isSneaking()) + if (player.isShiftKeyDown()) return ActionResultType.PASS; - if (!player.getHeldItem(handIn) + if (!player.getItemInHand(handIn) .getItem() - .isIn(Tags.Items.SLIMEBALLS)) { - if (player.getHeldItem(handIn) + .is(Tags.Items.SLIMEBALLS)) { + if (player.getItemInHand(handIn) .isEmpty()) { withTileEntityDo(worldIn, pos, te -> te.assembleNextTick = true); return ActionResultType.SUCCESS; } return ActionResultType.PASS; } - if (state.get(STATE) != PistonState.RETRACTED) + if (state.getValue(STATE) != PistonState.RETRACTED) return ActionResultType.PASS; - Direction direction = state.get(FACING); - if (hit.getFace() != direction) + Direction direction = state.getValue(FACING); + if (hit.getDirection() != direction) return ActionResultType.PASS; if (((MechanicalPistonBlock) state.getBlock()).isSticky) return ActionResultType.PASS; - if (worldIn.isRemote) { - Vector3d vec = hit.getHitVec(); + if (worldIn.isClientSide) { + Vector3d vec = hit.getLocation(); worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0); return ActionResultType.SUCCESS; } AllSoundEvents.SLIME_ADDED.playOnServer(worldIn, pos, .5f, 1); if (!player.isCreative()) - player.getHeldItem(handIn) + player.getItemInHand(handIn) .shrink(1); - worldIn.setBlockState(pos, AllBlocks.STICKY_MECHANICAL_PISTON.getDefaultState() - .with(FACING, direction) - .with(AXIS_ALONG_FIRST_COORDINATE, state.get(AXIS_ALONG_FIRST_COORDINATE))); + worldIn.setBlockAndUpdate(pos, AllBlocks.STICKY_MECHANICAL_PISTON.getDefaultState() + .setValue(FACING, direction) + .setValue(AXIS_ALONG_FIRST_COORDINATE, state.getValue(AXIS_ALONG_FIRST_COORDINATE))); 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()))) + Direction direction = state.getValue(FACING); + if (!fromPos.equals(pos.relative(direction.getOpposite()))) return; - if (!world.isRemote && !world.getPendingBlockTicks() - .isTickPending(pos, this)) - world.getPendingBlockTicks() + if (!world.isClientSide && !world.getBlockTicks() + .willTickThisTick(pos, this)) + world.getBlockTicks() .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())); + public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + Direction direction = state.getValue(FACING); + BlockState pole = worldIn.getBlockState(pos.relative(direction.getOpposite())); if (!AllBlocks.PISTON_EXTENSION_POLE.has(pole)) return; - if (pole.get(PistonExtensionPoleBlock.FACING) + if (pole.getValue(PistonExtensionPoleBlock.FACING) .getAxis() != direction.getAxis()) return; withTileEntityDo(worldIn, pos, te -> { @@ -136,7 +138,7 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - if (state.get(STATE) != PistonState.RETRACTED) + if (state.getValue(STATE) != PistonState.RETRACTED) return ActionResultType.PASS; return super.onWrenched(state, context); } @@ -145,28 +147,28 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement RETRACTED, MOVING, EXTENDED; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } } @Override - public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { - Direction direction = state.get(FACING); + public void playerWillDestroy(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { + Direction direction = state.getValue(FACING); BlockPos pistonHead = null; BlockPos pistonBase = pos; boolean dropBlocks = player == null || !player.isCreative(); Integer maxPoles = maxAllowedPistonPoles(); for (int offset = 1; offset < maxPoles; offset++) { - BlockPos currentPos = pos.offset(direction, offset); + BlockPos currentPos = pos.relative(direction, offset); BlockState block = worldIn.getBlockState(currentPos); - if (isExtensionPole(block) && direction.getAxis() == block.get(BlockStateProperties.FACING) + if (isExtensionPole(block) && direction.getAxis() == block.getValue(BlockStateProperties.FACING) .getAxis()) continue; - if (isPistonHead(block) && block.get(BlockStateProperties.FACING) == direction) { + if (isPistonHead(block) && block.getValue(BlockStateProperties.FACING) == direction) { pistonHead = currentPos; } @@ -174,16 +176,16 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement } if (pistonHead != null && pistonBase != null) { - BlockPos.getAllInBox(pistonBase, pistonHead) + BlockPos.betweenClosedStream(pistonBase, pistonHead) .filter(p -> !p.equals(pos)) .forEach(p -> worldIn.destroyBlock(p, dropBlocks)); } for (int offset = 1; offset < maxPoles; offset++) { - BlockPos currentPos = pos.offset(direction.getOpposite(), offset); + BlockPos currentPos = pos.relative(direction.getOpposite(), offset); BlockState block = worldIn.getBlockState(currentPos); - if (isExtensionPole(block) && direction.getAxis() == block.get(BlockStateProperties.FACING) + if (isExtensionPole(block) && direction.getAxis() == block.getValue(BlockStateProperties.FACING) .getAxis()) { worldIn.destroyBlock(currentPos, dropBlocks); continue; @@ -192,7 +194,7 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement break; } - super.onBlockHarvested(worldIn, pos, state, player); + super.playerWillDestroy(worldIn, pos, state, player); } public static int maxAllowedPistonPoles() { @@ -202,13 +204,13 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - if (state.get(STATE) == PistonState.EXTENDED) - return AllShapes.MECHANICAL_PISTON_EXTENDED.get(state.get(FACING)); + if (state.getValue(STATE) == PistonState.EXTENDED) + return AllShapes.MECHANICAL_PISTON_EXTENDED.get(state.getValue(FACING)); - if (state.get(STATE) == PistonState.MOVING) - return AllShapes.MECHANICAL_PISTON.get(state.get(FACING)); + if (state.getValue(STATE) == PistonState.MOVING) + return AllShapes.MECHANICAL_PISTON.get(state.getValue(FACING)); - return VoxelShapes.fullCube(); + return VoxelShapes.block(); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonGenerator.java index 34e30c52c..4b3363bcf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonGenerator.java @@ -23,14 +23,14 @@ public class MechanicalPistonGenerator extends SpecialBlockStateGen { @Override protected int getXRotation(BlockState state) { - Direction facing = state.get(MechanicalPistonBlock.FACING); + Direction facing = state.getValue(MechanicalPistonBlock.FACING); return facing.getAxis() .isVertical() ? facing == Direction.DOWN ? 180 : 0 : 90; } @Override protected int getYRotation(BlockState state) { - Direction facing = state.get(MechanicalPistonBlock.FACING); + Direction facing = state.getValue(MechanicalPistonBlock.FACING); return facing.getAxis() .isVertical() ? 0 : horizontalAngle(facing) + 180; } @@ -38,12 +38,12 @@ public class MechanicalPistonGenerator extends SpecialBlockStateGen { @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - Direction facing = state.get(PistonBlock.FACING); - boolean axisAlongFirst = state.get(MechanicalPistonBlock.AXIS_ALONG_FIRST_COORDINATE); - PistonState pistonState = state.get(MechanicalPistonBlock.STATE); + Direction facing = state.getValue(PistonBlock.FACING); + boolean axisAlongFirst = state.getValue(MechanicalPistonBlock.AXIS_ALONG_FIRST_COORDINATE); + PistonState pistonState = state.getValue(MechanicalPistonBlock.STATE); String path = "block/mechanical_piston"; - String folder = pistonState == PistonState.RETRACTED ? type.getString() : pistonState.getString(); + String folder = pistonState == PistonState.RETRACTED ? type.getSerializedName() : pistonState.getSerializedName(); String partial = facing.getAxis() == Axis.X ^ axisAlongFirst ? "block_rotated" : "block"; return prov.models() diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonHeadBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonHeadBlock.java index fe9c50d8a..0b8e4553c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonHeadBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonHeadBlock.java @@ -30,23 +30,25 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements IWaterLoggable { public static final EnumProperty TYPE = BlockStateProperties.PISTON_TYPE; public MechanicalPistonHeadBlock(Properties p_i48415_1_) { super(p_i48415_1_); - setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false)); + registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false)); } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(TYPE, BlockStateProperties.WATERLOGGED); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override - public PushReaction getPushReaction(BlockState state) { + public PushReaction getPistonPushReaction(BlockState state) { return PushReaction.NORMAL; } @@ -57,20 +59,20 @@ public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements } @Override - public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { - Direction direction = state.get(FACING); + public void playerWillDestroy(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { + Direction direction = state.getValue(FACING); BlockPos pistonHead = pos; BlockPos pistonBase = null; for (int offset = 1; offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset++) { - BlockPos currentPos = pos.offset(direction.getOpposite(), offset); + BlockPos currentPos = pos.relative(direction.getOpposite(), offset); BlockState block = worldIn.getBlockState(currentPos); - if (isExtensionPole(block) && direction.getAxis() == block.get(BlockStateProperties.FACING) + if (isExtensionPole(block) && direction.getAxis() == block.getValue(BlockStateProperties.FACING) .getAxis()) continue; - if (MechanicalPistonBlock.isPiston(block) && block.get(BlockStateProperties.FACING) == direction) + if (MechanicalPistonBlock.isPiston(block) && block.getValue(BlockStateProperties.FACING) == direction) pistonBase = currentPos; break; @@ -78,43 +80,43 @@ public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements if (pistonHead != null && pistonBase != null) { final BlockPos basePos = pistonBase; - BlockPos.getAllInBox(pistonBase, pistonHead) + BlockPos.betweenClosedStream(pistonBase, pistonHead) .filter(p -> !p.equals(pos) && !p.equals(basePos)) .forEach(p -> worldIn.destroyBlock(p, !player.isCreative())); - worldIn.setBlockState(basePos, worldIn.getBlockState(basePos) - .with(MechanicalPistonBlock.STATE, PistonState.RETRACTED)); + worldIn.setBlockAndUpdate(basePos, worldIn.getBlockState(basePos) + .setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED)); } - super.onBlockHarvested(worldIn, pos, state, player); + super.playerWillDestroy(worldIn, pos, state, player); } @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return AllShapes.MECHANICAL_PISTON_HEAD.get(state.get(FACING)); + return AllShapes.MECHANICAL_PISTON_HEAD.get(state.getValue(FACING)); } @Override public FluidState getFluidState(BlockState state) { - return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : Fluids.EMPTY.getDefaultState(); + return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState(); } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, BlockPos pos, BlockPos neighbourPos) { - if (state.get(BlockStateProperties.WATERLOGGED)) { - world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if (state.getValue(BlockStateProperties.WATERLOGGED)) { + world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } return state; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - FluidState FluidState = context.getWorld().getFluidState(context.getPos()); - return super.getStateForPlacement(context).with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getFluid() == Fluids.WATER)); + FluidState FluidState = context.getLevel().getFluidState(context.getClickedPos()); + return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER)); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonTileEntity.java index 8297c9b20..5ca97b096 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonTileEntity.java @@ -45,23 +45,23 @@ public class MechanicalPistonTileEntity extends LinearActuatorTileEntity { @Override public void assemble() throws AssemblyException { - if (!(world.getBlockState(pos) + if (!(level.getBlockState(worldPosition) .getBlock() instanceof MechanicalPistonBlock)) return; - Direction direction = getBlockState().get(BlockStateProperties.FACING); + Direction direction = getBlockState().getValue(BlockStateProperties.FACING); // Collect Construct PistonContraption contraption = new PistonContraption(direction, getMovementSpeed() < 0); - if (!contraption.assemble(world, pos)) + if (!contraption.assemble(level, worldPosition)) return; - Direction positive = Direction.getFacingFromAxis(AxisDirection.POSITIVE, direction.getAxis()); + Direction positive = Direction.get(AxisDirection.POSITIVE, direction.getAxis()); Direction movementDirection = getSpeed() > 0 ^ direction.getAxis() != Axis.Z ? positive : positive.getOpposite(); - BlockPos anchor = contraption.anchor.offset(direction, contraption.initialExtensionProgress); - if (ContraptionCollider.isCollidingWithWorld(world, contraption, anchor.offset(movementDirection), + BlockPos anchor = contraption.anchor.relative(direction, contraption.initialExtensionProgress); + if (ContraptionCollider.isCollidingWithWorld(level, contraption, anchor.relative(movementDirection), movementDirection)) return; @@ -78,35 +78,35 @@ public class MechanicalPistonTileEntity extends LinearActuatorTileEntity { sendData(); clientOffsetDiff = 0; - BlockPos startPos = BlockPos.ZERO.offset(direction, contraption.initialExtensionProgress); - contraption.removeBlocksFromWorld(world, startPos); - movedContraption = ControlledContraptionEntity.create(getWorld(), this, contraption); + BlockPos startPos = BlockPos.ZERO.relative(direction, contraption.initialExtensionProgress); + contraption.removeBlocksFromWorld(level, startPos); + movedContraption = ControlledContraptionEntity.create(getLevel(), this, contraption); applyContraptionPosition(); forceMove = true; - world.addEntity(movedContraption); + level.addFreshEntity(movedContraption); - AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(world, pos); + AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(level, worldPosition); } @Override public void disassemble() { if (!running && movedContraption == null) return; - if (!removed) - getWorld().setBlockState(pos, getBlockState().with(MechanicalPistonBlock.STATE, PistonState.EXTENDED), + if (!remove) + getLevel().setBlock(worldPosition, getBlockState().setValue(MechanicalPistonBlock.STATE, PistonState.EXTENDED), 3 | 16); if (movedContraption != null) { applyContraptionPosition(); movedContraption.disassemble(); - AllSoundEvents.CONTRAPTION_DISASSEMBLE.playOnServer(world, pos); + AllSoundEvents.CONTRAPTION_DISASSEMBLE.playOnServer(level, worldPosition); } running = false; movedContraption = null; sendData(); - if (removed) + if (remove) AllBlocks.MECHANICAL_PISTON.get() - .onBlockHarvested(world, pos, getBlockState(), null); + .playerWillDestroy(level, worldPosition, getBlockState(), null); } @Override @@ -119,11 +119,11 @@ public class MechanicalPistonTileEntity extends LinearActuatorTileEntity { @Override public float getMovementSpeed() { float movementSpeed = MathHelper.clamp(convertToLinear(getSpeed()), -.49f, .49f); - if (world.isRemote) + if (level.isClientSide) movementSpeed *= ServerSpeedProvider.get(); - Direction pistonDirection = getBlockState().get(BlockStateProperties.FACING); + Direction pistonDirection = getBlockState().getValue(BlockStateProperties.FACING); int movementModifier = pistonDirection.getAxisDirection() - .getOffset() * (pistonDirection.getAxis() == Axis.Z ? -1 : 1); + .getStep() * (pistonDirection.getAxis() == Axis.Z ? -1 : 1); movementSpeed = movementSpeed * -movementModifier + clientOffsetDiff / 2f; int extensionRange = getExtensionRange(); @@ -141,24 +141,24 @@ public class MechanicalPistonTileEntity extends LinearActuatorTileEntity { @Override protected Vector3d toMotionVector(float speed) { - Direction pistonDirection = getBlockState().get(BlockStateProperties.FACING); - return Vector3d.of(pistonDirection.getDirectionVec()) + Direction pistonDirection = getBlockState().getValue(BlockStateProperties.FACING); + return Vector3d.atLowerCornerOf(pistonDirection.getNormal()) .scale(speed); } @Override protected Vector3d toPosition(float offset) { - Vector3d position = Vector3d.of(getBlockState().get(BlockStateProperties.FACING) - .getDirectionVec()) + Vector3d position = Vector3d.atLowerCornerOf(getBlockState().getValue(BlockStateProperties.FACING) + .getNormal()) .scale(offset); - return position.add(Vector3d.of(movedContraption.getContraption().anchor)); + return position.add(Vector3d.atLowerCornerOf(movedContraption.getContraption().anchor)); } @Override protected ValueBoxTransform getMovementModeSlot() { return new DirectionalExtenderScrollOptionSlot((state, d) -> { Axis axis = d.getAxis(); - Axis extensionAxis = state.get(MechanicalPistonBlock.FACING) + Axis extensionAxis = state.getValue(MechanicalPistonBlock.FACING) .getAxis(); Axis shaftAxis = ((IRotate) state.getBlock()).getRotationAxis(state); return extensionAxis != axis && shaftAxis != axis; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonContraption.java index b8c33f45b..5c79bd6fb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonContraption.java @@ -70,7 +70,7 @@ public class PistonContraption extends TranslatingContraption { if (blocks.size() == count) { // no new blocks added bounds = pistonExtensionCollisionBox; } else { - bounds = bounds.union(pistonExtensionCollisionBox); + bounds = bounds.minmax(pistonExtensionCollisionBox); } startMoving(world); return true; @@ -79,7 +79,7 @@ public class PistonContraption extends TranslatingContraption { private boolean collectExtensions(World world, BlockPos pos, Direction direction) throws AssemblyException { List poles = new ArrayList<>(); BlockPos actualStart = pos; - BlockState nextBlock = world.getBlockState(actualStart.offset(direction)); + BlockState nextBlock = world.getBlockState(actualStart.relative(direction)); int extensionsInFront = 0; BlockState blockState = world.getBlockState(pos); boolean sticky = isStickyPiston(blockState); @@ -87,17 +87,17 @@ public class PistonContraption extends TranslatingContraption { if (!isPiston(blockState)) return false; - if (blockState.get(MechanicalPistonBlock.STATE) == PistonState.EXTENDED) { - while (PistonExtensionPoleBlock.PlacementHelper.get().matchesAxis(nextBlock, direction.getAxis()) || isPistonHead(nextBlock) && nextBlock.get(FACING) == direction) { + if (blockState.getValue(MechanicalPistonBlock.STATE) == PistonState.EXTENDED) { + while (PistonExtensionPoleBlock.PlacementHelper.get().matchesAxis(nextBlock, direction.getAxis()) || isPistonHead(nextBlock) && nextBlock.getValue(FACING) == direction) { - actualStart = actualStart.offset(direction); - poles.add(new BlockInfo(actualStart, nextBlock.with(FACING, direction), null)); + actualStart = actualStart.relative(direction); + poles.add(new BlockInfo(actualStart, nextBlock.setValue(FACING, direction), null)); extensionsInFront++; if (isPistonHead(nextBlock)) break; - nextBlock = world.getBlockState(actualStart.offset(direction)); + nextBlock = world.getBlockState(actualStart.relative(direction)); if (extensionsInFront > MechanicalPistonBlock.maxAllowedPistonPoles()) throw AssemblyException.tooManyPistonPoles(); } @@ -105,32 +105,32 @@ public class PistonContraption extends TranslatingContraption { if (extensionsInFront == 0) poles.add(new BlockInfo(pos, MECHANICAL_PISTON_HEAD.getDefaultState() - .with(FACING, direction) - .with(BlockStateProperties.PISTON_TYPE, sticky ? PistonType.STICKY : PistonType.DEFAULT), null)); + .setValue(FACING, direction) + .setValue(BlockStateProperties.PISTON_TYPE, sticky ? PistonType.STICKY : PistonType.DEFAULT), null)); else poles.add(new BlockInfo(pos, PISTON_EXTENSION_POLE.getDefaultState() - .with(FACING, direction), null)); + .setValue(FACING, direction), null)); BlockPos end = pos; - nextBlock = world.getBlockState(end.offset(direction.getOpposite())); + nextBlock = world.getBlockState(end.relative(direction.getOpposite())); int extensionsInBack = 0; while (PistonExtensionPoleBlock.PlacementHelper.get().matchesAxis(nextBlock, direction.getAxis())) { - end = end.offset(direction.getOpposite()); - poles.add(new BlockInfo(end, nextBlock.with(FACING, direction), null)); + end = end.relative(direction.getOpposite()); + poles.add(new BlockInfo(end, nextBlock.setValue(FACING, direction), null)); extensionsInBack++; - nextBlock = world.getBlockState(end.offset(direction.getOpposite())); + nextBlock = world.getBlockState(end.relative(direction.getOpposite())); if (extensionsInFront + extensionsInBack > MechanicalPistonBlock.maxAllowedPistonPoles()) throw AssemblyException.tooManyPistonPoles(); } - anchor = pos.offset(direction, initialExtensionProgress + 1); + anchor = pos.relative(direction, initialExtensionProgress + 1); extensionLength = extensionsInBack + extensionsInFront; initialExtensionProgress = extensionsInFront; pistonExtensionCollisionBox = new AxisAlignedBB( - BlockPos.ZERO.offset(direction, -1), - BlockPos.ZERO.offset(direction, -extensionLength - 1)).expand(1, + BlockPos.ZERO.relative(direction, -1), + BlockPos.ZERO.relative(direction, -extensionLength - 1)).expandTowards(1, 1, 1); if (extensionLength == 0) @@ -139,7 +139,7 @@ public class PistonContraption extends TranslatingContraption { bounds = new AxisAlignedBB(0, 0, 0, 0, 0, 0); for (BlockInfo pole : poles) { - BlockPos relPos = pole.pos.offset(direction, -extensionsInFront); + BlockPos relPos = pole.pos.relative(direction, -extensionsInFront); BlockPos localPos = relPos.subtract(anchor); getBlocks().put(localPos, new BlockInfo(localPos, pole.state, null)); //pistonExtensionCollisionBox = pistonExtensionCollisionBox.union(new AxisAlignedBB(localPos)); @@ -156,31 +156,31 @@ public class PistonContraption extends TranslatingContraption { @Override protected boolean addToInitialFrontier(World world, BlockPos pos, Direction direction, Queue frontier) throws AssemblyException { frontier.clear(); - boolean sticky = isStickyPiston(world.getBlockState(pos.offset(orientation, -1))); + boolean sticky = isStickyPiston(world.getBlockState(pos.relative(orientation, -1))); boolean retracting = direction != orientation; if (retracting && !sticky) return true; for (int offset = 0; offset <= AllConfigs.SERVER.kinetics.maxChassisRange.get(); offset++) { if (offset == 1 && retracting) return true; - BlockPos currentPos = pos.offset(orientation, offset + initialExtensionProgress); + BlockPos currentPos = pos.relative(orientation, offset + initialExtensionProgress); if (retracting && World.isOutsideBuildHeight(currentPos)) return true; - if (!world.isBlockPresent(currentPos)) + if (!world.isLoaded(currentPos)) throw AssemblyException.unloadedChunk(currentPos); BlockState state = world.getBlockState(currentPos); if (!BlockMovementChecks.isMovementNecessary(state, world, currentPos)) return true; if (BlockMovementChecks.isBrittle(state) && !(state.getBlock() instanceof CarpetBlock)) return true; - if (isPistonHead(state) && state.get(FACING) == direction.getOpposite()) + if (isPistonHead(state) && state.getValue(FACING) == direction.getOpposite()) return true; if (!BlockMovementChecks.isMovementAllowed(state, world, currentPos)) if (retracting) return true; else throw AssemblyException.unmovableBlock(currentPos, state); - if (retracting && state.getPushReaction() == PushReaction.PUSH_ONLY) + if (retracting && state.getPistonPushReaction() == PushReaction.PUSH_ONLY) return true; frontier.add(currentPos); if (BlockMovementChecks.isNotSupportive(state, orientation)) @@ -191,25 +191,25 @@ public class PistonContraption extends TranslatingContraption { @Override public void addBlock(BlockPos pos, Pair capture) { - super.addBlock(pos.offset(orientation, -initialExtensionProgress), capture); + super.addBlock(pos.relative(orientation, -initialExtensionProgress), capture); } @Override public BlockPos toLocalPos(BlockPos globalPos) { return globalPos.subtract(anchor) - .offset(orientation, -initialExtensionProgress); + .relative(orientation, -initialExtensionProgress); } @Override protected boolean customBlockPlacement(IWorld world, BlockPos pos, BlockState state) { - BlockPos pistonPos = anchor.offset(orientation, -1); + BlockPos pistonPos = anchor.relative(orientation, -1); BlockState pistonState = world.getBlockState(pistonPos); - TileEntity te = world.getTileEntity(pistonPos); + TileEntity te = world.getBlockEntity(pistonPos); if (pos.equals(pistonPos)) { if (te == null || te.isRemoved()) return true; if (!isExtensionPole(state) && isPiston(pistonState)) - world.setBlockState(pistonPos, pistonState.with(MechanicalPistonBlock.STATE, PistonState.RETRACTED), + world.setBlock(pistonPos, pistonState.setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED), 3 | 16); return true; } @@ -218,10 +218,10 @@ public class PistonContraption extends TranslatingContraption { @Override protected boolean customBlockRemoval(IWorld world, BlockPos pos, BlockState state) { - BlockPos pistonPos = anchor.offset(orientation, -1); + BlockPos pistonPos = anchor.relative(orientation, -1); BlockState blockState = world.getBlockState(pos); if (pos.equals(pistonPos) && isPiston(blockState)) { - world.setBlockState(pos, blockState.with(MechanicalPistonBlock.STATE, PistonState.MOVING), 66 | 16); + world.setBlock(pos, blockState.setValue(MechanicalPistonBlock.STATE, PistonState.MOVING), 66 | 16); return true; } return false; @@ -232,7 +232,7 @@ public class PistonContraption extends TranslatingContraption { super.readNBT(world, nbt, spawnData); initialExtensionProgress = nbt.getInt("InitialLength"); extensionLength = nbt.getInt("ExtensionLength"); - orientation = Direction.byIndex(nbt.getInt("Orientation")); + orientation = Direction.from3DDataValue(nbt.getInt("Orientation")); } @Override @@ -240,7 +240,7 @@ public class PistonContraption extends TranslatingContraption { CompoundNBT tag = super.writeNBT(spawnPacket); tag.putInt("InitialLength", initialExtensionProgress); tag.putInt("ExtensionLength", extensionLength); - tag.putInt("Orientation", orientation.getIndex()); + tag.putInt("Orientation", orientation.get3DDataValue()); return tag; } 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 38191de92..658c60781 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 @@ -44,13 +44,15 @@ import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; +import net.minecraft.block.AbstractBlock.Properties; + public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements IWrenchable, IWaterLoggable { private static final int placementHelperId = PlacementHelpers.register(PlacementHelper.get()); public PistonExtensionPoleBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(FACING, Direction.UP).with(BlockStateProperties.WATERLOGGED, false)); + registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP).setValue(BlockStateProperties.WATERLOGGED, false)); } @Override @@ -60,7 +62,7 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements @Override public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) { - for (ToolType toolType : player.getHeldItemMainhand() + for (ToolType toolType : player.getMainHandItem() .getToolTypes()) { if (isToolEffective(state, toolType)) return true; @@ -74,33 +76,33 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements } @Override - public PushReaction getPushReaction(BlockState state) { + public PushReaction getPistonPushReaction(BlockState state) { return PushReaction.NORMAL; } @Override - public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { - Axis axis = state.get(FACING) + public void playerWillDestroy(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { + Axis axis = state.getValue(FACING) .getAxis(); - Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); + Direction direction = Direction.get(AxisDirection.POSITIVE, axis); BlockPos pistonHead = null; BlockPos pistonBase = null; for (int modifier : new int[] { 1, -1 }) { for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset += modifier) { - BlockPos currentPos = pos.offset(direction, offset); + BlockPos currentPos = pos.relative(direction, offset); BlockState block = worldIn.getBlockState(currentPos); - if (isExtensionPole(block) && axis == block.get(FACING) + if (isExtensionPole(block) && axis == block.getValue(FACING) .getAxis()) continue; - if (isPiston(block) && block.get(BlockStateProperties.FACING) + if (isPiston(block) && block.getValue(BlockStateProperties.FACING) .getAxis() == axis) pistonBase = currentPos; - if (isPistonHead(block) && block.get(BlockStateProperties.FACING) + if (isPistonHead(block) && block.getValue(BlockStateProperties.FACING) .getAxis() == axis) pistonHead = currentPos; @@ -109,17 +111,17 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements } if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead) - .get(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase) - .get(BlockStateProperties.FACING)) { + .getValue(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase) + .getValue(BlockStateProperties.FACING)) { final BlockPos basePos = pistonBase; - BlockPos.getAllInBox(pistonBase, pistonHead) + BlockPos.betweenClosedStream(pistonBase, pistonHead) .filter(p -> !p.equals(pos) && !p.equals(basePos)) .forEach(p -> worldIn.destroyBlock(p, !player.isCreative())); - worldIn.setBlockState(basePos, worldIn.getBlockState(basePos) - .with(MechanicalPistonBlock.STATE, PistonState.RETRACTED)); + worldIn.setBlockAndUpdate(basePos, worldIn.getBlockState(basePos) + .setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED)); - TileEntity te = worldIn.getTileEntity(basePos); + TileEntity te = worldIn.getBlockEntity(basePos); if (te instanceof MechanicalPistonTileEntity) { MechanicalPistonTileEntity baseTE = (MechanicalPistonTileEntity) te; baseTE.offset = 0; @@ -127,31 +129,31 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements } } - super.onBlockHarvested(worldIn, pos, state, player); + super.playerWillDestroy(worldIn, pos, state, player); } @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return AllShapes.FOUR_VOXEL_POLE.get(state.get(FACING) + return AllShapes.FOUR_VOXEL_POLE.get(state.getValue(FACING) .getAxis()); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - FluidState FluidState = context.getWorld() - .getFluidState(context.getPos()); - return getDefaultState().with(FACING, context.getFace() + FluidState FluidState = context.getLevel() + .getFluidState(context.getClickedPos()); + return defaultBlockState().setValue(FACING, context.getClickedFace() .getOpposite()) - .with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getFluid() == Fluids.WATER)); + .setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER)); } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId); - if (placementHelper.matchesItem(heldItem) && !player.isSneaking()) + if (placementHelper.matchesItem(heldItem) && !player.isShiftKeyDown()) return placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray); return ActionResultType.PASS; @@ -159,26 +161,26 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements @Override public FluidState getFluidState(BlockState state) { - return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) - : Fluids.EMPTY.getDefaultState(); + return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) + : Fluids.EMPTY.defaultFluidState(); } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(BlockStateProperties.WATERLOGGED); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState, IWorld world, BlockPos pos, BlockPos neighbourPos) { - if (state.get(BlockStateProperties.WATERLOGGED)) { - world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, BlockPos pos, BlockPos neighbourPos) { + if (state.getValue(BlockStateProperties.WATERLOGGED)) { + world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } return state; } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } @@ -194,7 +196,7 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements private PlacementHelper(){ super( AllBlocks.PISTON_EXTENSION_POLE::has, - state -> state.get(FACING).getAxis(), + state -> state.getValue(FACING).getAxis(), FACING ); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java index 84fa87b31..1c05d8b77 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java @@ -16,7 +16,7 @@ public class PistonLighter extends ContraptionLighter { bounds.translate(contraption.anchor); int length = contraption.extensionLength; - Vector3i direction = contraption.orientation.getDirectionVec(); + Vector3i direction = contraption.orientation.getNormal(); int shift = length / 2; int shiftX = direction.getX() * shift; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java index b77adc308..9e88c809c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java @@ -40,8 +40,8 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID public AbstractPulleyInstance(MaterialManager dispatcher, KineticTileEntity tile) { super(dispatcher, tile); - rotatingAbout = Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis); - rotationAxis = rotatingAbout.getUnitVector(); + rotatingAbout = Direction.get(Direction.AxisDirection.POSITIVE, axis); + rotationAxis = rotatingAbout.step(); coil = getCoilModel() .createInstance() @@ -66,7 +66,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID private void transformModels() { resizeRope(); - coil.setRotation(rotationAxis.getDegreesQuaternion(offset * 180)); + coil.setRotation(rotationAxis.rotationDegrees(offset * 180)); magnet.update().get().ifPresent(data -> { int index = Math.max(0, MathHelper.floor(offset)); @@ -137,7 +137,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID int length = MathHelper.ceil(offset); if (volume == null || bLight.length < length + 1) { - volume = GridAlignedBB.from(pos.down(length), pos); + volume = GridAlignedBB.from(pos.below(length), pos); volume.fixMinMax(); bLight = Arrays.copyOf(bLight, length + 1); @@ -188,9 +188,9 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID int top = this.pos.getY(); BlockPos.Mutable pos = new BlockPos.Mutable(); changed.forEachContained((x, y, z) -> { - pos.setPos(x, y, z); - byte block = (byte) world.getLightLevel(LightType.BLOCK, pos); - byte sky = (byte) world.getLightLevel(LightType.SKY, pos); + pos.set(x, y, z); + byte block = (byte) world.getBrightness(LightType.BLOCK, pos); + byte sky = (byte) world.getBrightness(LightType.SKY, pos); int i = top - y; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java index f8994d9e7..5599b93a4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java @@ -36,7 +36,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { } @Override - public boolean isGlobalRenderer(KineticTileEntity p_188185_1_) { + public boolean shouldRenderOffScreen(KineticTileEntity p_188185_1_) { return true; } @@ -44,7 +44,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); float offset = getOffset(te, partialTicks); @@ -53,18 +53,18 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { Axis rotationAxis = ((IRotate) te.getBlockState() .getBlock()).getRotationAxis(te.getBlockState()); kineticRotationTransform(getRotatedCoil(te), te, rotationAxis, AngleHelper.rad(offset * 180), light) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .renderInto(ms, buffer.getBuffer(RenderType.solid())); - World world = te.getWorld(); + World world = te.getLevel(); BlockState blockState = te.getBlockState(); - BlockPos pos = te.getPos(); + BlockPos pos = te.getBlockPos(); SuperByteBuffer halfMagnet = PartialBufferer.get(this.halfMagnet, blockState); SuperByteBuffer halfRope = PartialBufferer.get(this.halfRope, blockState); SuperByteBuffer magnet = renderMagnet(te); SuperByteBuffer rope = renderRope(te); - IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); + IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); if (running || offset == 0) renderAt(world, offset > .25f ? magnet : halfMagnet, offset, pos, ms, vb); @@ -81,8 +81,8 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { private void renderAt(IWorld world, SuperByteBuffer partial, float offset, BlockPos pulleyPos, MatrixStack ms, IVertexBuilder buffer) { - BlockPos actualPos = pulleyPos.down((int) offset); - int light = WorldRenderer.getLightmapCoordinates(world, world.getBlockState(actualPos), actualPos); + BlockPos actualPos = pulleyPos.below((int) offset); + int light = WorldRenderer.getLightColor(world, world.getBlockState(actualPos), actualPos); partial.translate(0, -offset, 0) .light(light) .renderInto(ms, buffer); @@ -107,7 +107,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) { BlockState blockState = te.getBlockState(); - return PartialBufferer.getFacing(getCoil(), blockState, Direction.getFacingFromAxis(AxisDirection.POSITIVE, getShaftAxis(te))); + return PartialBufferer.getFacing(getCoil(), blockState, Direction.get(AxisDirection.POSITIVE, getShaftAxis(te))); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java index adcaca95f..aafc9c3e2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java @@ -33,6 +33,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE { public static EnumProperty HORIZONTAL_AXIS = BlockStateProperties.HORIZONTAL_AXIS; @@ -42,7 +44,7 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE te.assembleNextTick = true); return ActionResultType.SUCCESS; @@ -84,7 +86,7 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(BlockStateProperties.WATERLOGGED); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, BlockPos pos, BlockPos neighbourPos) { - if (state.get(BlockStateProperties.WATERLOGGED)) { - world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if (state.getValue(BlockStateProperties.WATERLOGGED)) { + world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } return state; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - FluidState FluidState = context.getWorld().getFluidState(context.getPos()); - return super.getStateForPlacement(context).with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getFluid() == Fluids.WATER)); + FluidState FluidState = context.getLevel().getFluidState(context.getClickedPos()); + return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java index 27d75fa07..e148c3837 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java @@ -17,9 +17,9 @@ public class PulleyLighter extends ContraptionLighter { GridAlignedBB bounds = GridAlignedBB.from(contraption.bounds); - World world = contraption.entity.world; + World world = contraption.entity.level; - BlockPos.Mutable pos = contraption.anchor.mutableCopy(); + BlockPos.Mutable pos = contraption.anchor.mutable(); while (!AllBlocks.ROPE_PULLEY.has(world.getBlockState(pos)) && pos.getY() < 256) { pos.move(0, 1, 0); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java index c1813dc06..233dbe8d5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java @@ -21,7 +21,7 @@ public class PulleyRenderer extends AbstractPulleyRenderer { @Override protected Axis getShaftAxis(KineticTileEntity te) { return te.getBlockState() - .get(PulleyBlock.HORIZONTAL_AXIS); + .getValue(PulleyBlock.HORIZONTAL_AXIS); } @Override @@ -57,7 +57,7 @@ public class PulleyRenderer extends AbstractPulleyRenderer { if (tile.movedContraption != null) { AbstractContraptionEntity e = tile.movedContraption; PulleyContraption c = (PulleyContraption) tile.movedContraption.getContraption(); - double entityPos = MathHelper.lerp(partialTicks, e.lastTickPosY, e.getY()); + double entityPos = MathHelper.lerp(partialTicks, e.yOld, e.getY()); offset = (float) -(entityPos - c.anchor.getY() - c.initialOffset); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java index f892445c5..5af548f7c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java @@ -35,12 +35,12 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { @Override public AxisAlignedBB makeRenderBoundingBox() { - return super.makeRenderBoundingBox().expand(0, -offset, 0); + return super.makeRenderBoundingBox().expandTowards(0, -offset, 0); } @Override - public double getMaxRenderDistanceSquared() { - return super.getMaxRenderDistanceSquared() + offset * offset; + public double getViewDistance() { + return super.getViewDistance() + offset * offset; } @Override @@ -52,7 +52,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { @Override protected void assemble() throws AssemblyException { - if (!(world.getBlockState(pos) + if (!(level.getBlockState(worldPosition) .getBlock() instanceof PulleyBlock)) return; if (speed == 0) @@ -60,8 +60,8 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { int maxLength = AllConfigs.SERVER.kinetics.maxRopeLength.get(); int i = 1; while (i <= maxLength) { - BlockPos ropePos = pos.down(i); - BlockState ropeState = world.getBlockState(ropePos); + BlockPos ropePos = worldPosition.below(i); + BlockState ropeState = level.getBlockState(ropePos); if (!AllBlocks.ROPE.has(ropeState) && !AllBlocks.PULLEY_MAGNET.has(ropeState)) { break; } @@ -74,15 +74,15 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { return; // Collect Construct - if (!world.isRemote) { - BlockPos anchor = pos.down(MathHelper.floor(offset + 1)); + if (!level.isClientSide) { + BlockPos anchor = worldPosition.below(MathHelper.floor(offset + 1)); initialOffset = MathHelper.floor(offset); PulleyContraption contraption = new PulleyContraption(initialOffset); - boolean canAssembleStructure = contraption.assemble(world, anchor); + boolean canAssembleStructure = contraption.assemble(level, anchor); if (canAssembleStructure) { Direction movementDirection = getSpeed() > 0 ? Direction.DOWN : Direction.UP; - if (ContraptionCollider.isCollidingWithWorld(world, contraption, anchor.offset(movementDirection), + if (ContraptionCollider.isCollidingWithWorld(level, contraption, anchor.relative(movementDirection), movementDirection)) canAssembleStructure = false; } @@ -91,21 +91,21 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { return; for (i = ((int) offset); i > 0; i--) { - BlockPos offset = pos.down(i); - BlockState oldState = world.getBlockState(offset); - if (oldState.getBlock() instanceof IWaterLoggable && oldState.contains(BlockStateProperties.WATERLOGGED) - && oldState.get(BlockStateProperties.WATERLOGGED)) { - world.setBlockState(offset, Blocks.WATER.getDefaultState(), 66); + BlockPos offset = worldPosition.below(i); + BlockState oldState = level.getBlockState(offset); + if (oldState.getBlock() instanceof IWaterLoggable && oldState.hasProperty(BlockStateProperties.WATERLOGGED) + && oldState.getValue(BlockStateProperties.WATERLOGGED)) { + level.setBlock(offset, Blocks.WATER.defaultBlockState(), 66); continue; } - world.setBlockState(offset, Blocks.AIR.getDefaultState(), 66); + level.setBlock(offset, Blocks.AIR.defaultBlockState(), 66); } if (!contraption.getBlocks().isEmpty()) { - contraption.removeBlocksFromWorld(world, BlockPos.ZERO); - movedContraption = ControlledContraptionEntity.create(world, this, contraption); - movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ()); - world.addEntity(movedContraption); + contraption.removeBlocksFromWorld(level, BlockPos.ZERO); + movedContraption = ControlledContraptionEntity.create(level, this, contraption); + movedContraption.setPos(anchor.getX(), anchor.getY(), anchor.getZ()); + level.addFreshEntity(movedContraption); forceMove = true; } } @@ -123,33 +123,33 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { if (movedContraption != null) applyContraptionPosition(); - if (!world.isRemote) { - if (!removed) { + if (!level.isClientSide) { + if (!remove) { if (offset > 0) { - BlockPos magnetPos = pos.down((int) offset); - FluidState ifluidstate = world.getFluidState(magnetPos); - world.destroyBlock(magnetPos, world.getBlockState(magnetPos) - .getCollisionShape(world, magnetPos) + BlockPos magnetPos = worldPosition.below((int) offset); + FluidState ifluidstate = level.getFluidState(magnetPos); + level.destroyBlock(magnetPos, level.getBlockState(magnetPos) + .getCollisionShape(level, magnetPos) .isEmpty()); - world.setBlockState(magnetPos, AllBlocks.PULLEY_MAGNET.getDefaultState() - .with(BlockStateProperties.WATERLOGGED, - Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER)), + level.setBlock(magnetPos, AllBlocks.PULLEY_MAGNET.getDefaultState() + .setValue(BlockStateProperties.WATERLOGGED, + Boolean.valueOf(ifluidstate.getType() == Fluids.WATER)), 66); } boolean[] waterlog = new boolean[(int) offset]; for (int i = 1; i <= ((int) offset) - 1; i++) { - BlockPos ropePos = pos.down(i); - FluidState ifluidstate = world.getFluidState(ropePos); - waterlog[i] = ifluidstate.getFluid() == Fluids.WATER; - world.destroyBlock(ropePos, world.getBlockState(ropePos) - .getCollisionShape(world, ropePos) + BlockPos ropePos = worldPosition.below(i); + FluidState ifluidstate = level.getFluidState(ropePos); + waterlog[i] = ifluidstate.getType() == Fluids.WATER; + level.destroyBlock(ropePos, level.getBlockState(ropePos) + .getCollisionShape(level, ropePos) .isEmpty()); } for (int i = 1; i <= ((int) offset) - 1; i++) - world.setBlockState(pos.down(i), AllBlocks.ROPE.getDefaultState() - .with(BlockStateProperties.WATERLOGGED, waterlog[i]), 66); + level.setBlock(worldPosition.below(i), AllBlocks.ROPE.getDefaultState() + .setValue(BlockStateProperties.WATERLOGGED, waterlog[i]), 66); } if (movedContraption != null) @@ -168,7 +168,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { protected Vector3d toPosition(float offset) { if (movedContraption.getContraption() instanceof PulleyContraption) { PulleyContraption contraption = (PulleyContraption) movedContraption.getContraption(); - return Vector3d.of(contraption.anchor).add(0, contraption.initialOffset - offset, 0); + return Vector3d.atLowerCornerOf(contraption.anchor).add(0, contraption.initialOffset - offset, 0); } return Vector3d.ZERO; @@ -177,16 +177,16 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { @Override protected void visitNewPosition() { super.visitNewPosition(); - if (world.isRemote) + if (level.isClientSide) return; if (movedContraption != null) return; if (getSpeed() <= 0) return; - BlockPos posBelow = pos.down((int) (offset + getMovementSpeed()) + 1); - BlockState state = world.getBlockState(posBelow); - if (!BlockMovementChecks.isMovementNecessary(state, world, posBelow)) + BlockPos posBelow = worldPosition.below((int) (offset + getMovementSpeed()) + 1); + BlockState state = level.getBlockState(posBelow); + if (!BlockMovementChecks.isMovementNecessary(state, level, posBelow)) return; if (BlockMovementChecks.isBrittle(state)) return; @@ -209,7 +209,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { @Override protected int getExtensionRange() { - return Math.max(0, Math.min(AllConfigs.SERVER.kinetics.maxRopeLength.get(), pos.getY() - 1)); + return Math.max(0, Math.min(AllConfigs.SERVER.kinetics.maxRopeLength.get(), worldPosition.getY() - 1)); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ActorInstance.java index 4c02741d1..77ffe3c9f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ActorInstance.java @@ -22,6 +22,6 @@ public abstract class ActorInstance { public void beginFrame() { } protected int localBlockLight() { - return simulationWorld.getLightLevel(LightType.BLOCK, context.localPos); + return simulationWorld.getBrightness(LightType.BLOCK, context.localPos); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionMatrices.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionMatrices.java index d6e82d17d..199d07e48 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionMatrices.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionMatrices.java @@ -30,36 +30,36 @@ public class ContraptionMatrices { } public Matrix4f getFinalModel() { - Matrix4f finalModel = entityStack.peek().getModel().copy(); - finalModel.multiply(contraptionStack.peek().getModel()); + Matrix4f finalModel = entityStack.last().pose().copy(); + finalModel.multiply(contraptionStack.last().pose()); return finalModel; } public Matrix3f getFinalNormal() { - Matrix3f finalNormal = entityStack.peek().getNormal().copy(); - finalNormal.multiply(contraptionStack.peek().getNormal()); + Matrix3f finalNormal = entityStack.last().normal().copy(); + finalNormal.mul(contraptionStack.last().normal()); return finalNormal; } public Matrix4f getFinalLight() { Matrix4f lightTransform = entityMatrix.copy(); - lightTransform.multiply(contraptionStack.peek().getModel()); + lightTransform.multiply(contraptionStack.last().pose()); return lightTransform; } public static Matrix4f translateTo(Entity entity, float partialTicks) { - double x = MathHelper.lerp(partialTicks, entity.lastTickPosX, entity.getX()); - double y = MathHelper.lerp(partialTicks, entity.lastTickPosY, entity.getY()); - double z = MathHelper.lerp(partialTicks, entity.lastTickPosZ, entity.getZ()); - return Matrix4f.translate((float) x, (float) y, (float) z); + double x = MathHelper.lerp(partialTicks, entity.xOld, entity.getX()); + double y = MathHelper.lerp(partialTicks, entity.yOld, entity.getY()); + double z = MathHelper.lerp(partialTicks, entity.zOld, entity.getZ()); + return Matrix4f.createTranslateMatrix((float) x, (float) y, (float) z); } public static void transform(MatrixStack ms, MatrixStack transform) { - ms.peek().getModel() - .multiply(transform.peek() - .getModel()); - ms.peek().getNormal() - .multiply(transform.peek() - .getNormal()); + ms.last().pose() + .multiply(transform.last() + .pose()); + ms.last().normal() + .mul(transform.last() + .normal()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 96086b861..aaff598e0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -71,7 +71,7 @@ import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(Dist.CLIENT) public class ContraptionRenderDispatcher { private static final Lazy MODEL_RENDERER = Lazy.of(() -> new BlockModelRenderer(Minecraft.getInstance().getBlockColors())); - private static final Lazy BLOCK_MODELS = Lazy.of(() -> Minecraft.getInstance().getModelManager().getBlockModelShapes()); + private static final Lazy BLOCK_MODELS = Lazy.of(() -> Minecraft.getInstance().getModelManager().getBlockModelShaper()); private static int worldHolderRefreshCounter; public static final Int2ObjectMap RENDERERS = new Int2ObjectOpenHashMap<>(); @@ -79,7 +79,7 @@ public class ContraptionRenderDispatcher { public static final Compartment> CONTRAPTION = new Compartment<>(); public static void tick() { - if (Minecraft.getInstance().isGamePaused()) return; + if (Minecraft.getInstance().isPaused()) return; for (RenderedContraption contraption : RENDERERS.values()) { ContraptionLighter lighter = contraption.getLighter(); @@ -99,9 +99,9 @@ public class ContraptionRenderDispatcher { @SubscribeEvent public static void beginFrame(BeginFrameEvent event) { ActiveRenderInfo info = event.getInfo(); - double camX = info.getProjectedView().x; - double camY = info.getProjectedView().y; - double camZ = info.getProjectedView().z; + double camX = info.getPosition().x; + double camY = info.getPosition().y; + double camZ = info.getPosition().z; for (RenderedContraption renderer : RENDERERS.values()) { renderer.beginFrame(info, camX, camY, camZ); } @@ -114,7 +114,7 @@ public class ContraptionRenderDispatcher { if (RENDERERS.isEmpty()) return; RenderType layer = event.getType(); - layer.startDrawing(); + layer.setupRenderState(); glEnable(GL_TEXTURE_3D); glActiveTexture(GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 @@ -137,7 +137,7 @@ public class ContraptionRenderDispatcher { } glBindTexture(GL_TEXTURE_3D, 0); - layer.endDrawing(); + layer.clearRenderState(); glDisable(GL_TEXTURE_3D); glActiveTexture(GL_TEXTURE0); glUseProgram(0); @@ -154,7 +154,7 @@ public class ContraptionRenderDispatcher { public static void render(AbstractContraptionEntity entity, Contraption contraption, ContraptionMatrices matrices, IRenderTypeBuffer buffers) { - World world = entity.world; + World world = entity.level; if (Backend.getInstance().canUseVBOs() && Backend.isFlywheelWorld(world)) { RenderedContraption renderer = getRenderer(world, contraption); PlacementSimulationWorld renderWorld = renderer.renderWorld; @@ -170,7 +170,7 @@ public class ContraptionRenderDispatcher { } private static RenderedContraption getRenderer(World world, Contraption c) { - int entityId = c.entity.getEntityId(); + int entityId = c.entity.getId(); RenderedContraption contraption = RENDERERS.get(entityId); if (contraption == null) { @@ -183,7 +183,7 @@ public class ContraptionRenderDispatcher { } private static ContraptionWorldHolder getWorldHolder(World world, Contraption c) { - int entityId = c.entity.getEntityId(); + int entityId = c.entity.getId(); ContraptionWorldHolder holder = WORLD_HOLDERS.get(entityId); if (holder == null) { @@ -203,10 +203,10 @@ public class ContraptionRenderDispatcher { for (Template.BlockInfo info : c.getBlocks() .values()) // Skip individual lighting updates to prevent lag with large contraptions - renderWorld.setBlockState(info.pos, info.state, 128); + renderWorld.setBlock(info.pos, info.state, 128); renderWorld.updateLightSources(); - renderWorld.lighter.tick(Integer.MAX_VALUE, false, false); + renderWorld.lighter.runUpdates(Integer.MAX_VALUE, false, false); return renderWorld; } @@ -215,7 +215,7 @@ public class ContraptionRenderDispatcher { ContraptionMatrices matrices, IRenderTypeBuffer buffer) { renderTileEntities(world, renderWorld, c, matrices, buffer); if (buffer instanceof IRenderTypeBuffer.Impl) - ((IRenderTypeBuffer.Impl) buffer).draw(); + ((IRenderTypeBuffer.Impl) buffer).endBatch(); renderActors(world, renderWorld, c, matrices, buffer); } @@ -236,7 +236,7 @@ public class ContraptionRenderDispatcher { Template.BlockInfo blockInfo = actor.getLeft(); MatrixStack m = matrices.contraptionStack; - m.push(); + m.pushPose(); MatrixStacker.of(m) .translate(blockInfo.pos); @@ -244,16 +244,16 @@ public class ContraptionRenderDispatcher { if (movementBehaviour != null) movementBehaviour.renderInContraption(context, renderWorld, matrices, buffer); - m.pop(); + m.popPose(); } } public static void renderStructure(World world, PlacementSimulationWorld renderWorld, Contraption c, ContraptionMatrices matrices, IRenderTypeBuffer buffer) { SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE; - List blockLayers = RenderType.getBlockLayers(); + List blockLayers = RenderType.chunkBufferLayers(); - buffer.getBuffer(RenderType.getSolid()); + buffer.getBuffer(RenderType.solid()); for (int i = 0; i < blockLayers.size(); i++) { RenderType layer = blockLayers.get(i); Pair key = Pair.of(c, i); @@ -280,28 +280,28 @@ public class ContraptionRenderDispatcher { builder.begin(GL_QUADS, DefaultVertexFormats.BLOCK); ForgeHooksClient.setRenderLayer(layer); - BlockModelRenderer.enableCache(); + BlockModelRenderer.enableCaching(); for (Template.BlockInfo info : c.getBlocks() .values()) { BlockState state = info.state; - if (state.getRenderType() != BlockRenderType.MODEL) + if (state.getRenderShape() != BlockRenderType.MODEL) continue; if (!RenderTypeLookup.canRenderInLayer(state, layer)) continue; BlockPos pos = info.pos; - ms.push(); + ms.pushPose(); ms.translate(pos.getX(), pos.getY(), pos.getZ()); - MODEL_RENDERER.get().renderModel(renderWorld, BLOCK_MODELS.get().getModel(state), state, pos, ms, builder, true, - random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); - ms.pop(); + MODEL_RENDERER.get().renderModel(renderWorld, BLOCK_MODELS.get().getBlockModel(state), state, pos, ms, builder, true, + random, 42, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE); + ms.popPose(); } - BlockModelRenderer.disableCache(); + BlockModelRenderer.clearCache(); ForgeHooksClient.setRenderLayer(null); - builder.finishDrawing(); + builder.end(); return builder; } @@ -313,16 +313,16 @@ public class ContraptionRenderDispatcher { for (float zOffset = offset; zOffset >= -offset; zOffset -= 2 * offset) for (float yOffset = offset; yOffset >= -offset; yOffset -= 2 * offset) for (float xOffset = offset; xOffset >= -offset; xOffset -= 2 * offset) { - pos.setPos(lx + xOffset, ly + yOffset, lz + zOffset); - block += world.getLightLevel(LightType.BLOCK, pos) / 8f; - sky += world.getLightLevel(LightType.SKY, pos) / 8f; + pos.set(lx + xOffset, ly + yOffset, lz + zOffset); + block += world.getBrightness(LightType.BLOCK, pos) / 8f; + sky += world.getBrightness(LightType.SKY, pos) / 8f; } return LightTexture.pack((int) block, (int) sky); } public static int getContraptionWorldLight(MovementContext context, PlacementSimulationWorld renderWorld) { - return WorldRenderer.getLightmapCoordinates(renderWorld, context.localPos); + return WorldRenderer.getLightColor(renderWorld, context.localPos); } public static void invalidateAll() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionWorldHolder.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionWorldHolder.java index 4ae414016..0f3cc5ab7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionWorldHolder.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionWorldHolder.java @@ -13,7 +13,7 @@ public class ContraptionWorldHolder { } public int getEntityId() { - return contraption.entity.getEntityId(); + return contraption.entity.getId(); } public boolean isDead() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index 84ce22b80..3b6c4eece 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -90,18 +90,18 @@ public class RenderedContraption extends ContraptionWorldHolder { MatrixStack stack = new MatrixStack(); - double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()) - camX; - double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()) - camY; - double z = MathHelper.lerp(pt, entity.lastTickPosZ, entity.getZ()) - camZ; + double x = MathHelper.lerp(pt, entity.xOld, entity.getX()) - camX; + double y = MathHelper.lerp(pt, entity.yOld, entity.getY()) - camY; + double z = MathHelper.lerp(pt, entity.zOld, entity.getZ()) - camZ; stack.translate(x, y, z); entity.doLocalTransforms(pt, new MatrixStack[] { stack }); - model = stack.peek().getModel(); + model = stack.last().pose(); AxisAlignedBB lightBox = GridAlignedBB.toAABB(lighter.lightVolume.getTextureVolume()); - this.lightBox = lightBox.offset(-camX, -camY, -camZ); + this.lightBox = lightBox.move(-camX, -camY, -camZ); } void setup(ContraptionProgram shader) { @@ -129,7 +129,7 @@ public class RenderedContraption extends ContraptionWorldHolder { renderLayers.clear(); - List blockLayers = RenderType.getBlockLayers(); + List blockLayers = RenderType.chunkBufferLayers(); for (RenderType layer : blockLayers) { BufferedModel layerModel = buildStructureModel(renderWorld, contraption, layer); @@ -148,11 +148,11 @@ public class RenderedContraption extends ContraptionWorldHolder { if (!tileEntities.isEmpty()) { for (TileEntity te : tileEntities) { if (te instanceof IInstanceRendered) { - World world = te.getWorld(); - BlockPos pos = te.getPos(); - te.setLocation(renderWorld, pos); + World world = te.getLevel(); + BlockPos pos = te.getBlockPos(); + te.setLevelAndPosition(renderWorld, pos); kinetics.add(te); - te.setLocation(world, pos); + te.setLevelAndPosition(world, pos); } } } @@ -193,8 +193,8 @@ public class RenderedContraption extends ContraptionWorldHolder { int light = reader.getLight(i); - byte block = (byte) (LightTexture.getBlockLightCoordinates(light) << 4); - byte sky = (byte) (LightTexture.getSkyLightCoordinates(light) << 4); + byte block = (byte) (LightTexture.block(light) << 4); + byte sky = (byte) (LightTexture.sky(light) << 4); vertices.put(block); vertices.put(sky); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ClientMotionPacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ClientMotionPacket.java index 1a4c7307c..9e2487763 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ClientMotionPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ClientMotionPacket.java @@ -46,15 +46,15 @@ public class ClientMotionPacket extends SimplePacketBase { .getSender(); if (sender == null) return; - sender.setMotion(motion); + sender.setDeltaMovement(motion); sender.setOnGround(onGround); if (onGround) { - sender.handleFallDamage(sender.fallDistance, 1); + sender.causeFallDamage(sender.fallDistance, 1); sender.fallDistance = 0; - sender.connection.floatingTickCount = 0; + sender.connection.aboveGroundTickCount = 0; } AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> sender), - new LimbSwingUpdatePacket(sender.getEntityId(), sender.getPositionVec(), limbSwing)); + new LimbSwingUpdatePacket(sender.getId(), sender.position(), limbSwing)); }); context.get() .setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionFluidPacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionFluidPacket.java index bc0d308bd..fd648bb5d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionFluidPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionFluidPacket.java @@ -41,7 +41,7 @@ public class ContraptionFluidPacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - Entity entityByID = Minecraft.getInstance().world.getEntityByID(entityId); + Entity entityByID = Minecraft.getInstance().level.getEntity(entityId); if (!(entityByID instanceof AbstractContraptionEntity)) return; AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionInteractionPacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionInteractionPacket.java index 1120719d6..9d731d735 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionInteractionPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionInteractionPacket.java @@ -24,7 +24,7 @@ public class ContraptionInteractionPacket extends SimplePacketBase { public ContraptionInteractionPacket(AbstractContraptionEntity target, Hand hand, BlockPos localPos, Direction side) { this.interactionHand = hand; this.localPos = localPos; - this.target = target.getEntityId(); + this.target = target.getId(); this.face = side; } @@ -33,7 +33,7 @@ public class ContraptionInteractionPacket extends SimplePacketBase { int handId = buffer.readInt(); interactionHand = handId == -1 ? null : Hand.values()[handId]; localPos = buffer.readBlockPos(); - face = Direction.byIndex(buffer.readShort()); + face = Direction.from3DDataValue(buffer.readShort()); } @Override @@ -41,7 +41,7 @@ public class ContraptionInteractionPacket extends SimplePacketBase { buffer.writeInt(target); buffer.writeInt(interactionHand == null ? -1 : interactionHand.ordinal()); buffer.writeBlockPos(localPos); - buffer.writeShort(face.getIndex()); + buffer.writeShort(face.get3DDataValue()); } @Override @@ -50,20 +50,20 @@ public class ContraptionInteractionPacket extends SimplePacketBase { ServerPlayerEntity sender = context.get().getSender(); if (sender == null) return; - Entity entityByID = sender.getServerWorld().getEntityByID(target); + Entity entityByID = sender.getLevel().getEntity(target); if (!(entityByID instanceof AbstractContraptionEntity)) return; AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID; double d = sender.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue() + 10; - if (!sender.canEntityBeSeen(entityByID)) + if (!sender.canSee(entityByID)) d -= 3; d *= d; - if (sender.getDistanceSq(entityByID) > d) { + if (sender.distanceToSqr(entityByID) > d) { // TODO log? return; } if (contraptionEntity.handlePlayerInteraction(sender, localPos, face, interactionHand)) - sender.swingHand(interactionHand, true); + sender.swing(interactionHand, true); }); context.get().setPacketHandled(true); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionSeatMappingPacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionSeatMappingPacket.java index 6d6ce8d8f..b05df0f01 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionSeatMappingPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/ContraptionSeatMappingPacket.java @@ -28,7 +28,7 @@ public class ContraptionSeatMappingPacket extends SimplePacketBase { mapping = new HashMap<>(); short size = buffer.readShort(); for (int i = 0; i < size; i++) - mapping.put(buffer.readUniqueId(), (int) buffer.readShort()); + mapping.put(buffer.readUUID(), (int) buffer.readShort()); } @Override @@ -36,7 +36,7 @@ public class ContraptionSeatMappingPacket extends SimplePacketBase { buffer.writeInt(entityID); buffer.writeShort(mapping.size()); mapping.forEach((k, v) -> { - buffer.writeUniqueId(k); + buffer.writeUUID(k); buffer.writeShort(v); }); } @@ -45,7 +45,7 @@ public class ContraptionSeatMappingPacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - Entity entityByID = Minecraft.getInstance().world.getEntityByID(entityID); + Entity entityByID = Minecraft.getInstance().level.getEntity(entityID); if (!(entityByID instanceof AbstractContraptionEntity)) return; AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/LimbSwingUpdatePacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/LimbSwingUpdatePacket.java index c4f1f70a8..454ef81d4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/LimbSwingUpdatePacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/sync/LimbSwingUpdatePacket.java @@ -43,17 +43,17 @@ public class LimbSwingUpdatePacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ClientWorld world = Minecraft.getInstance().world; + ClientWorld world = Minecraft.getInstance().level; if (world == null) return; - Entity entity = world.getEntityByID(entityId); + Entity entity = world.getEntity(entityId); if (entity == null) return; CompoundNBT data = entity.getPersistentData(); data.putInt("LastOverrideLimbSwingUpdate", 0); data.putFloat("OverrideLimbSwing", limbSwing); - entity.setPositionAndRotationDirect(position.x, position.y, position.z, entity.rotationYaw, - entity.rotationPitch, 2, false); + entity.lerpTo(position.x, position.y, position.z, entity.yRot, + entity.xRot, 2, false); }); context.get() .setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingCreationPacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingCreationPacket.java index 795a3e89e..c042219d1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingCreationPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingCreationPacket.java @@ -14,8 +14,8 @@ public class CouplingCreationPacket extends SimplePacketBase { int id1, id2; public CouplingCreationPacket(AbstractMinecartEntity cart1, AbstractMinecartEntity cart2) { - id1 = cart1.getEntityId(); - id2 = cart2.getEntityId(); + id1 = cart1.getId(); + id2 = cart2.getId(); } public CouplingCreationPacket(PacketBuffer buffer) { @@ -36,7 +36,7 @@ public class CouplingCreationPacket extends SimplePacketBase { ServerPlayerEntity sender = context.get() .getSender(); if (sender != null) - CouplingHandler.tryToCoupleCarts(sender, sender.world, id1, id2); + CouplingHandler.tryToCoupleCarts(sender, sender.level, id1, id2); }); context.get() .setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java index e16e87de6..924bd4d11 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java @@ -67,8 +67,8 @@ public class CouplingHandler { } public static boolean tryToCoupleCarts(@Nullable PlayerEntity player, World world, int cartId1, int cartId2) { - Entity entity1 = world.getEntityByID(cartId1); - Entity entity2 = world.getEntityByID(cartId2); + Entity entity1 = world.getEntity(cartId1); + Entity entity2 = world.getEntity(cartId2); if (!(entity1 instanceof AbstractMinecartEntity)) return false; @@ -80,8 +80,8 @@ public class CouplingHandler { String noLoops = "no_loops"; String tooFar = "too_far"; - int distanceTo = (int) entity1.getPositionVec() - .distanceTo(entity2.getPositionVec()); + int distanceTo = (int) entity1.position() + .distanceTo(entity2.position()); boolean contraptionCoupling = player == null; if (distanceTo < 2) { @@ -97,8 +97,8 @@ public class CouplingHandler { AbstractMinecartEntity cart1 = (AbstractMinecartEntity) entity1; AbstractMinecartEntity cart2 = (AbstractMinecartEntity) entity2; - UUID mainID = cart1.getUniqueID(); - UUID connectedID = cart2.getUniqueID(); + UUID mainID = cart1.getUUID(); + UUID connectedID = cart2.getUUID(); MinecartController mainController = CapabilityMinecartController.getIfPresent(world, mainID); MinecartController connectedController = CapabilityMinecartController.getIfPresent(world, connectedID); @@ -146,7 +146,7 @@ public class CouplingHandler { for (Hand hand : Hand.values()) { if (player.isCreative()) break; - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); if (!AllItems.MINECART_COUPLING.isIn(heldItem)) continue; heldItem.shrink(1); @@ -177,7 +177,7 @@ public class CouplingHandler { public static void status(PlayerEntity player, String key) { if (player == null) return; - player.sendStatusMessage(Lang.translate("minecart_coupling." + key), true); + player.displayClientMessage(Lang.translate("minecart_coupling." + key), true); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandlerClient.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandlerClient.java index 00fda4789..d4b34b7c0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandlerClient.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandlerClient.java @@ -28,8 +28,8 @@ public class CouplingHandlerClient { return; spawnSelectionParticles(selectedCart.getBoundingBox(), false); ClientPlayerEntity player = Minecraft.getInstance().player; - ItemStack heldItemMainhand = player.getHeldItemMainhand(); - ItemStack heldItemOffhand = player.getHeldItemOffhand(); + ItemStack heldItemMainhand = player.getMainHandItem(); + ItemStack heldItemOffhand = player.getOffhandItem(); if (AllItems.MINECART_COUPLING.isIn(heldItemMainhand) || AllItems.MINECART_COUPLING.isIn(heldItemOffhand)) return; selectedCart = null; @@ -53,14 +53,14 @@ public class CouplingHandlerClient { } private static void spawnSelectionParticles(AxisAlignedBB axisAlignedBB, boolean highlight) { - ClientWorld world = Minecraft.getInstance().world; + ClientWorld world = Minecraft.getInstance().level; Vector3d center = axisAlignedBB.getCenter(); int amount = highlight ? 100 : 2; IParticleData particleData = highlight ? ParticleTypes.END_ROD : new RedstoneParticleData(1, 1, 1, 1); for (int i = 0; i < amount; i++) { Vector3d v = VecHelper.offsetRandomly(Vector3d.ZERO, r, 1); double yOffset = v.y; - v = v.mul(1, 0, 1) + v = v.multiply(1, 0, 1) .normalize() .add(0, yOffset / 8f, 0) .add(center); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingPhysics.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingPhysics.java index e16ea5263..24c97dc04 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingPhysics.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingPhysics.java @@ -28,7 +28,7 @@ public class CouplingPhysics { float couplingLength = c.getFirst() .getCouplingLength(true); softCollisionStep(world, carts, couplingLength); - if (world.isRemote) + if (world.isClientSide) return; hardCollisionStep(world, carts, couplingLength); } @@ -44,15 +44,15 @@ public class CouplingPhysics { AbstractMinecartEntity cart = carts.get(current); AbstractMinecartEntity otherCart = carts.get(!current); - float stress = (float) (couplingLength - cart.getPositionVec() - .distanceTo(otherCart.getPositionVec())); + float stress = (float) (couplingLength - cart.position() + .distanceTo(otherCart.position())); if (Math.abs(stress) < 1 / 8f) continue; RailShape shape = null; BlockPos railPosition = cart.getCurrentRailPosition(); - BlockState railState = world.getBlockState(railPosition.up()); + BlockState railState = world.getBlockState(railPosition.above()); if (railState.getBlock() instanceof AbstractRailBlock) { AbstractRailBlock block = (AbstractRailBlock) railState.getBlock(); @@ -60,8 +60,8 @@ public class CouplingPhysics { } Vector3d correction = Vector3d.ZERO; - Vector3d pos = cart.getPositionVec(); - Vector3d link = otherCart.getPositionVec() + Vector3d pos = cart.position(); + Vector3d link = otherCart.position() .subtract(pos); float correctionMagnitude = firstLoop ? -stress / 2f : -stress; @@ -83,7 +83,7 @@ public class CouplingPhysics { MinecartSim2020.moveCartAlongTrack(cart, correction, railPosition, railState); else { cart.move(MoverType.SELF, correction); - cart.setMotion(cart.getMotion() + cart.setDeltaMovement(cart.getDeltaMovement() .scale(0.95f)); } firstLoop = false; @@ -95,20 +95,20 @@ public class CouplingPhysics { Couple canAddmotion = carts.map(MinecartSim2020::canAddMotion); // Assuming Minecarts will never move faster than 1 block/tick - Couple motions = carts.map(Entity::getMotion); + Couple motions = carts.map(Entity::getDeltaMovement); motions.replaceWithParams(VecHelper::clamp, Couple.create(1f, 1f)); Couple nextPositions = carts.map(MinecartSim2020::predictNextPositionOf); Couple shapes = carts.mapWithContext((cart, current) -> { AbstractMinecartEntity minecart = cart.getMinecart(); Vector3d vec = nextPositions.get(current); - int x = MathHelper.floor(vec.getX()); - int y = MathHelper.floor(vec.getY()); - int z = MathHelper.floor(vec.getZ()); + int x = MathHelper.floor(vec.x()); + int y = MathHelper.floor(vec.y()); + int z = MathHelper.floor(vec.z()); BlockPos pos = new BlockPos(x, y - 1, z); - if (minecart.world.getBlockState(pos).isIn(BlockTags.RAILS)) pos = pos.down(); + if (minecart.level.getBlockState(pos).is(BlockTags.RAILS)) pos = pos.below(); BlockPos railPosition = pos; - BlockState railState = world.getBlockState(railPosition.up()); + BlockState railState = world.getBlockState(railPosition.above()); if (!(railState.getBlock() instanceof AbstractRailBlock)) return null; AbstractRailBlock block = (AbstractRailBlock) railState.getBlock(); @@ -117,7 +117,7 @@ public class CouplingPhysics { float futureStress = (float) (couplingLength - nextPositions.getFirst() .distanceTo(nextPositions.getSecond())); - if (MathHelper.epsilonEquals(futureStress, 0D)) + if (MathHelper.equal(futureStress, 0D)) return; for (boolean current : Iterate.trueAndFalse) { @@ -147,11 +147,11 @@ public class CouplingPhysics { } motions.replaceWithParams(VecHelper::clamp, maxSpeed); - carts.forEachWithParams(Entity::setMotion, motions); + carts.forEachWithParams(Entity::setDeltaMovement, motions); } public static Vector3d followLinkOnRail(Vector3d link, Vector3d cart, float diffToReduce, Vector3d railAxis) { - double dotProduct = railAxis.dotProduct(link); + double dotProduct = railAxis.dot(link); if (Double.isNaN(dotProduct) || dotProduct == 0 || diffToReduce == 0) return cart; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java index 7e987e371..577ed99c1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java @@ -33,7 +33,7 @@ import net.minecraft.util.math.vector.Vector3f; public class CouplingRenderer { public static void renderAll(MatrixStack ms, IRenderTypeBuffer buffer) { - CouplingHandler.forEachLoadedCoupling(Minecraft.getInstance().world, + CouplingHandler.forEachLoadedCoupling(Minecraft.getInstance().level, c -> { if (c.getFirst().hasContraptionCoupling(true)) return; @@ -43,29 +43,29 @@ public class CouplingRenderer { public static void tickDebugModeRenders() { if (KineticDebugger.isActive()) - CouplingHandler.forEachLoadedCoupling(Minecraft.getInstance().world, CouplingRenderer::doDebugRender); + CouplingHandler.forEachLoadedCoupling(Minecraft.getInstance().level, CouplingRenderer::doDebugRender); } public static void renderCoupling(MatrixStack ms, IRenderTypeBuffer buffer, Couple carts) { - ClientWorld world = Minecraft.getInstance().world; + ClientWorld world = Minecraft.getInstance().level; if (carts.getFirst() == null || carts.getSecond() == null) return; Couple lightValues = - carts.map(c -> WorldRenderer.getLightmapCoordinates(world, new BlockPos(c.getBoundingBox() + carts.map(c -> WorldRenderer.getLightColor(world, new BlockPos(c.getBoundingBox() .getCenter()))); Vector3d center = carts.getFirst() - .getPositionVec() + .position() .add(carts.getSecond() - .getPositionVec()) + .position()) .scale(.5f); Couple transforms = carts.map(c -> getSuitableCartEndpoint(c, center)); - BlockState renderState = Blocks.AIR.getDefaultState(); - IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid()); + BlockState renderState = Blocks.AIR.defaultBlockState(); + IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); SuperByteBuffer attachment = PartialBufferer.get(AllBlockPartials.COUPLING_ATTACHMENT, renderState); SuperByteBuffer ring = PartialBufferer.get(AllBlockPartials.COUPLING_RING, renderState); SuperByteBuffer connector = PartialBufferer.get(AllBlockPartials.COUPLING_CONNECTOR, renderState); @@ -77,21 +77,21 @@ public class CouplingRenderer { .apply(zero); Vector3d endPointDiff = secondEndpoint.subtract(firstEndpoint); double connectorYaw = -Math.atan2(endPointDiff.z, endPointDiff.x) * 180.0D / Math.PI; - double connectorPitch = Math.atan2(endPointDiff.y, endPointDiff.mul(1, 0, 1) + double connectorPitch = Math.atan2(endPointDiff.y, endPointDiff.multiply(1, 0, 1) .length()) * 180 / Math.PI; MatrixStacker msr = MatrixStacker.of(ms); carts.forEachWithContext((cart, isFirst) -> { CartEndpoint cartTransform = transforms.get(isFirst); - ms.push(); + ms.pushPose(); cartTransform.apply(ms); attachment.light(lightValues.get(isFirst)) .renderInto(ms, builder); msr.rotateY(connectorYaw - cartTransform.yaw); ring.light(lightValues.get(isFirst)) .renderInto(ms, builder); - ms.pop(); + ms.popPose(); }); int l1 = lightValues.getFirst(); @@ -99,7 +99,7 @@ public class CouplingRenderer { int meanBlockLight = (((l1 >> 4) & 0xf) + ((l2 >> 4) & 0xf)) / 2; int meanSkyLight = (((l1 >> 20) & 0xf) + ((l2 >> 20) & 0xf)) / 2; - ms.push(); + ms.pushPose(); msr.translate(firstEndpoint) .rotateY(connectorYaw) .rotateZ(connectorPitch); @@ -107,11 +107,11 @@ public class CouplingRenderer { connector.light(meanSkyLight << 20 | meanBlockLight << 4) .renderInto(ms, builder); - ms.pop(); + ms.popPose(); } private static CartEndpoint getSuitableCartEndpoint(AbstractMinecartEntity cart, Vector3d centerOfCoupling) { - long i = cart.getEntityId() * 493286711L; + long i = cart.getId() * 493286711L; i = i * i * 4392167121L + i * 98761L; float x = (((float) (i >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; float y = (((float) (i >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F + 0.375F; @@ -119,18 +119,18 @@ public class CouplingRenderer { float pt = AnimationTickHolder.getPartialTicks(); - double xIn = lerp(pt, cart.lastTickPosX, cart.getX()); - double yIn = lerp(pt, cart.lastTickPosY, cart.getY()); - double zIn = lerp(pt, cart.lastTickPosZ, cart.getZ()); + double xIn = lerp(pt, cart.xOld, cart.getX()); + double yIn = lerp(pt, cart.yOld, cart.getY()); + double zIn = lerp(pt, cart.zOld, cart.getZ()); - float yaw = lerp(pt, cart.prevRotationYaw, cart.rotationYaw); - float pitch = lerp(pt, cart.prevRotationPitch, cart.rotationPitch); - float roll = cart.getRollingAmplitude() - pt; + float yaw = lerp(pt, cart.yRotO, cart.yRot); + float pitch = lerp(pt, cart.xRotO, cart.xRot); + float roll = cart.getHurtTime() - pt; float rollAmplifier = cart.getDamage() - pt; if (rollAmplifier < 0.0F) rollAmplifier = 0.0F; - roll = roll > 0 ? MathHelper.sin(roll) * roll * rollAmplifier / 10.0F * cart.getRollingDirection() : 0; + roll = roll > 0 ? MathHelper.sin(roll) * roll * rollAmplifier / 10.0F * cart.getHurtDir() : 0; Vector3d positionVec = new Vector3d(xIn, yIn, zIn); Vector3d frontVec = positionVec.add(VecHelper.rotate(new Vector3d(.5, 0, 0), 180 - yaw, Axis.Y)); @@ -140,8 +140,8 @@ public class CouplingRenderer { boolean flip = false; if (railVecOfPos != null) { - frontVec = cart.getPosOffset(xIn, yIn, zIn, (double) 0.3F); - backVec = cart.getPosOffset(xIn, yIn, zIn, (double) -0.3F); + frontVec = cart.getPosOffs(xIn, yIn, zIn, (double) 0.3F); + backVec = cart.getPosOffs(xIn, yIn, zIn, (double) -0.3F); if (frontVec == null) frontVec = railVecOfPos; if (backVec == null) @@ -165,7 +165,7 @@ public class CouplingRenderer { final float offsetMagnitude = 13 / 16f; boolean isBackFaceCloser = - frontVec.squareDistanceTo(centerOfCoupling) > backVec.squareDistanceTo(centerOfCoupling); + frontVec.distanceToSqr(centerOfCoupling) > backVec.distanceToSqr(centerOfCoupling); flip = isBackFaceCloser; float offset = isBackFaceCloser ? -offsetMagnitude : offsetMagnitude; @@ -204,12 +204,12 @@ public class CouplingRenderer { public void apply(MatrixStack ms) { ms.translate(x, y, z); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yaw)); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(pitch)); - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(roll)); + ms.mulPose(Vector3f.YP.rotationDegrees(yaw)); + ms.mulPose(Vector3f.ZP.rotationDegrees(pitch)); + ms.mulPose(Vector3f.XP.rotationDegrees(roll)); ms.translate(offset, 0, 0); if (flip) - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180)); + ms.mulPose(Vector3f.YP.rotationDegrees(180)); } } @@ -218,23 +218,23 @@ public class CouplingRenderer { int yOffset = 1; MinecartController first = c.getFirst(); AbstractMinecartEntity mainCart = first.cart(); - Vector3d mainCenter = mainCart.getPositionVec() + Vector3d mainCenter = mainCart.position() .add(0, yOffset, 0); Vector3d connectedCenter = c.getSecond() .cart() - .getPositionVec() + .position() .add(0, yOffset, 0); int color = ColorHelper.mixColors(0xabf0e9, 0xee8572, (float) MathHelper .clamp(Math.abs(first.getCouplingLength(true) - connectedCenter.distanceTo(mainCenter)) * 8, 0, 1)); - CreateClient.OUTLINER.showLine(mainCart.getEntityId() + "", mainCenter, connectedCenter) + CreateClient.OUTLINER.showLine(mainCart.getId() + "", mainCenter, connectedCenter) .colored(color) .lineWidth(1 / 8f); - Vector3d point = mainCart.getPositionVec() + Vector3d point = mainCart.position() .add(0, yOffset, 0); - CreateClient.OUTLINER.showLine(mainCart.getEntityId() + "_dot", point, point.add(0, 1 / 128f, 0)) + CreateClient.OUTLINER.showLine(mainCart.getId() + "_dot", point, point.add(0, 1 / 128f, 0)) .colored(0xffffff) .lineWidth(1 / 4f); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartCouplingItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartCouplingItem.java index 268ba703a..9b839a131 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartCouplingItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartCouplingItem.java @@ -22,6 +22,8 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.item.Item.Properties; + @EventBusSubscriber public class MinecartCouplingItem extends Item { @@ -44,7 +46,7 @@ public class MinecartCouplingItem extends Item { return; MinecartController controller = capability.orElse(null); - ItemStack heldItem = player.getHeldItem(event.getHand()); + ItemStack heldItem = player.getItemInHand(event.getHand()); if (AllItems.MINECART_COUPLING.isIn(heldItem)) { if (!onCouplingInteractOnMinecart(event, minecart, player, controller)) return; @@ -62,11 +64,11 @@ public class MinecartCouplingItem extends Item { AbstractMinecartEntity minecart, PlayerEntity player, MinecartController controller) { World world = event.getWorld(); if (controller.isFullyCoupled()) { - if (!world.isRemote) + if (!world.isClientSide) CouplingHandler.status(player, "two_couplings_max"); return true; } - if (world != null && world.isRemote) + if (world != null && world.isClientSide) DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> cartClicked(player, minecart)); return true; } @@ -76,7 +78,7 @@ public class MinecartCouplingItem extends Item { int couplings = (controller.isConnectedToCoupling() ? 1 : 0) + (controller.isLeadingCoupling() ? 1 : 0); if (couplings == 0) return false; - if (event.getWorld().isRemote) + if (event.getWorld().isClientSide) return true; for (boolean forward : Iterate.trueAndFalse) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartSim2020.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartSim2020.java index 0a8f00f41..0c0f3689b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartSim2020.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartSim2020.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.train; -import static net.minecraft.entity.Entity.horizontalMag; +import static net.minecraft.entity.Entity.getHorizontalDistanceSqr; import java.util.Map; @@ -30,32 +30,32 @@ import net.minecraftforge.common.util.LazyOptional; public class MinecartSim2020 { private static final Map> MATRIX = Util.make(Maps.newEnumMap(RailShape.class), (map) -> { - Vector3i west = Direction.WEST.getDirectionVec(); - Vector3i east = Direction.EAST.getDirectionVec(); - Vector3i north = Direction.NORTH.getDirectionVec(); - Vector3i south = Direction.SOUTH.getDirectionVec(); + Vector3i west = Direction.WEST.getNormal(); + Vector3i east = Direction.EAST.getNormal(); + Vector3i north = Direction.NORTH.getNormal(); + Vector3i south = Direction.SOUTH.getNormal(); map.put(RailShape.NORTH_SOUTH, Pair.of(north, south)); map.put(RailShape.EAST_WEST, Pair.of(west, east)); - map.put(RailShape.ASCENDING_EAST, Pair.of(west.down(), east)); - map.put(RailShape.ASCENDING_WEST, Pair.of(west, east.down())); - map.put(RailShape.ASCENDING_NORTH, Pair.of(north, south.down())); - map.put(RailShape.ASCENDING_SOUTH, Pair.of(north.down(), south)); + map.put(RailShape.ASCENDING_EAST, Pair.of(west.below(), east)); + map.put(RailShape.ASCENDING_WEST, Pair.of(west, east.below())); + map.put(RailShape.ASCENDING_NORTH, Pair.of(north, south.below())); + map.put(RailShape.ASCENDING_SOUTH, Pair.of(north.below(), south)); map.put(RailShape.SOUTH_EAST, Pair.of(south, east)); map.put(RailShape.SOUTH_WEST, Pair.of(south, west)); map.put(RailShape.NORTH_WEST, Pair.of(north, west)); map.put(RailShape.NORTH_EAST, Pair.of(north, east)); }); - + public static Vector3d predictNextPositionOf(AbstractMinecartEntity cart) { - Vector3d position = cart.getPositionVec(); - Vector3d motion = VecHelper.clamp(cart.getMotion(), 1f); + Vector3d position = cart.position(); + Vector3d motion = VecHelper.clamp(cart.getDeltaMovement(), 1f); return position.add(motion); } public static boolean canAddMotion(AbstractMinecartEntity c) { if (c instanceof FurnaceMinecartEntity) - return MathHelper.epsilonEquals(((FurnaceMinecartEntity) c).pushX, 0) - && MathHelper.epsilonEquals(((FurnaceMinecartEntity) c).pushZ, 0); + return MathHelper.equal(((FurnaceMinecartEntity) c).xPush, 0) + && MathHelper.equal(((FurnaceMinecartEntity) c).zPush, 0); LazyOptional capability = c.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY); if (capability.isPresent() && capability.orElse(null) @@ -70,7 +70,7 @@ public class MinecartSim2020 { if (forcedMovement.equals(Vector3d.ZERO)) return; - Vector3d previousMotion = cart.getMotion(); + Vector3d previousMotion = cart.getDeltaMovement(); cart.fallDistance = 0.0F; double x = cart.getX(); @@ -85,7 +85,7 @@ public class MinecartSim2020 { actualY = cartPos.getY() + 1; AbstractRailBlock abstractrailblock = (AbstractRailBlock) trackState.getBlock(); - RailShape railshape = abstractrailblock.getRailDirection(trackState, cart.world, cartPos, cart); + RailShape railshape = abstractrailblock.getRailDirection(trackState, cart.level, cartPos, cart); switch (railshape) { case ASCENDING_EAST: forcedMovement = forcedMovement.add(-1 * cart.getSlopeAdjustment(), 0.0D, 0.0D); @@ -138,8 +138,8 @@ public class MinecartSim2020 { actualX = d23 + d4 * d14; actualZ = d10 + d5 * d14; - cart.setPosition(actualX, actualY, actualZ); - cart.setMotion(forcedMovement); + cart.setPos(actualX, actualY, actualZ); + cart.setDeltaMovement(forcedMovement); cart.moveMinecartOnRail(cartPos); x = cart.getX(); @@ -148,10 +148,10 @@ public class MinecartSim2020 { if (Vector3i.getY() != 0 && MathHelper.floor(x) - cartPos.getX() == Vector3i.getX() && MathHelper.floor(z) - cartPos.getZ() == Vector3i.getZ()) { - cart.setPosition(x, y + (double) Vector3i.getY(), z); + cart.setPos(x, y + (double) Vector3i.getY(), z); } else if (Vector3i1.getY() != 0 && MathHelper.floor(x) - cartPos.getX() == Vector3i1.getX() && MathHelper.floor(z) - cartPos.getZ() == Vector3i1.getZ()) { - cart.setPosition(x, y + (double) Vector3i1.getY(), z); + cart.setPos(x, y + (double) Vector3i1.getY(), z); } x = cart.getX(); @@ -161,13 +161,13 @@ public class MinecartSim2020 { Vector3d Vector3d3 = cart.getPos(x, y, z); if (Vector3d3 != null && actualVec != null) { double d17 = (actualVec.y - Vector3d3.y) * 0.05D; - Vector3d Vector3d4 = cart.getMotion(); - double d18 = Math.sqrt(horizontalMag(Vector3d4)); + Vector3d Vector3d4 = cart.getDeltaMovement(); + double d18 = Math.sqrt(getHorizontalDistanceSqr(Vector3d4)); if (d18 > 0.0D) { - cart.setMotion(Vector3d4.mul((d18 + d17) / d18, 1.0D, (d18 + d17) / d18)); + cart.setDeltaMovement(Vector3d4.multiply((d18 + d17) / d18, 1.0D, (d18 + d17) / d18)); } - cart.setPosition(x, Vector3d3.y, z); + cart.setPos(x, Vector3d3.y, z); } x = cart.getX(); @@ -177,12 +177,12 @@ public class MinecartSim2020 { int j = MathHelper.floor(x); int i = MathHelper.floor(z); if (j != cartPos.getX() || i != cartPos.getZ()) { - Vector3d Vector3d5 = cart.getMotion(); - double d26 = Math.sqrt(horizontalMag(Vector3d5)); - cart.setMotion(d26 * (double) (j - cartPos.getX()), Vector3d5.y, d26 * (double) (i - cartPos.getZ())); + Vector3d Vector3d5 = cart.getDeltaMovement(); + double d26 = Math.sqrt(getHorizontalDistanceSqr(Vector3d5)); + cart.setDeltaMovement(d26 * (double) (j - cartPos.getX()), Vector3d5.y, d26 * (double) (i - cartPos.getZ())); } - cart.setMotion(previousMotion); + cart.setDeltaMovement(previousMotion); } public static Vector3d getRailVec(RailShape shape) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/CapabilityMinecartController.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/CapabilityMinecartController.java index c8e790a0b..7dcb896ba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/CapabilityMinecartController.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/CapabilityMinecartController.java @@ -98,13 +98,13 @@ public class CapabilityMinecartController implements ICapabilitySerializable carts = loadedMinecartsByUUID.get(world); List unloads = queuedUnloads.get(world); - UUID uniqueID = entity.getUniqueID(); + UUID uniqueID = entity.getUUID(); if (!carts.containsKey(uniqueID) || unloads.contains(uniqueID)) return; - if (world.isRemote) + if (world.isClientSide) return; - handleKilledMinecart(world, carts.get(uniqueID), entity.getPositionVec()); + handleKilledMinecart(world, carts.get(uniqueID), entity.position()); } protected static void handleKilledMinecart(World world, MinecartController controller, Vector3d removedPos) { @@ -184,13 +184,13 @@ public class CapabilityMinecartController implements ICapabilitySerializable { internalStall.booleanValue() || otherCart == null || !otherCart.isPresent() || otherCart.isStalled(false)); })); - if (!world.isRemote) { + if (!world.isClientSide) { setStalled(internalStall.booleanValue(), true); disassemble(cart); } @@ -99,29 +99,29 @@ public class MinecartController implements INBTSerializable { if (passengers.isEmpty() || !(passengers.get(0) instanceof AbstractContraptionEntity)) { return; } - World world = cart.world; + World world = cart.level; int i = MathHelper.floor(cart.getX()); int j = MathHelper.floor(cart.getY()); int k = MathHelper.floor(cart.getZ()); if (world.getBlockState(new BlockPos(i, j - 1, k)) - .isIn(BlockTags.RAILS)) { + .is(BlockTags.RAILS)) { --j; } BlockPos blockpos = new BlockPos(i, j, k); BlockState blockstate = world.getBlockState(blockpos); - if (cart.canUseRail() && blockstate.isIn(BlockTags.RAILS) + if (cart.canUseRail() && blockstate.is(BlockTags.RAILS) && blockstate.getBlock() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.getBlock()) .isActivatorRail()) { - if (cart.isBeingRidden()) { - cart.removePassengers(); + if (cart.isVehicle()) { + cart.ejectPassengers(); } - if (cart.getRollingAmplitude() == 0) { - cart.setRollingDirection(-cart.getRollingDirection()); - cart.setRollingAmplitude(10); + if (cart.getHurtTime() == 0) { + cart.setHurtDir(-cart.getHurtDir()); + cart.setHurtTime(10); cart.setDamage(50.0F); - cart.velocityChanged = true; + cart.hurtMarked = true; } } } @@ -172,7 +172,7 @@ public class MinecartController implements INBTSerializable { } public void removeConnection(boolean main) { - if (hasContraptionCoupling(main) && !getWorld().isRemote) { + if (hasContraptionCoupling(main) && !getWorld().isClientSide) { List passengers = cart().getPassengers(); if (!passengers.isEmpty()) { Entity entity = passengers.get(0); @@ -240,8 +240,8 @@ public class MinecartController implements INBTSerializable { } public void coupleWith(boolean isLeading, UUID coupled, float length, boolean contraption) { - UUID mainID = isLeading ? cart().getUniqueID() : coupled; - UUID connectedID = isLeading ? coupled : cart().getUniqueID(); + UUID mainID = isLeading ? cart().getUUID() : coupled; + UUID connectedID = isLeading ? coupled : cart().getUUID(); couplings.set(isLeading, Optional.of(new CouplingData(mainID, connectedID, length, contraption))); needsEntryRefresh |= isLeading; sendData(); @@ -290,7 +290,7 @@ public class MinecartController implements INBTSerializable { } public void sendData() { - if (getWorld().isRemote) + if (getWorld().isClientSide) return; AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(this::cart), new MinecartControllerUpdatePacket(this)); @@ -342,7 +342,7 @@ public class MinecartController implements INBTSerializable { } private World getWorld() { - return cart().getEntityWorld(); + return cart().getCommandSenderWorld(); } private static class CouplingData { @@ -367,16 +367,16 @@ public class MinecartController implements INBTSerializable { CompoundNBT serialize() { CompoundNBT nbt = new CompoundNBT(); - nbt.put("Main", NBTUtil.fromUuid(mainCartID)); - nbt.put("Connected", NBTUtil.fromUuid(connectedCartID)); + nbt.put("Main", NBTUtil.createUUID(mainCartID)); + nbt.put("Connected", NBTUtil.createUUID(connectedCartID)); nbt.putFloat("Length", length); nbt.putBoolean("Contraption", contraption); return nbt; } static CouplingData read(CompoundNBT nbt) { - UUID mainCartID = NBTUtil.readUniqueId(NBTHelper.getINBT(nbt, "Main")); - UUID connectedCartID = NBTUtil.readUniqueId(NBTHelper.getINBT(nbt, "Connected")); + UUID mainCartID = NBTUtil.loadUUID(NBTHelper.getINBT(nbt, "Main")); + UUID connectedCartID = NBTUtil.loadUUID(NBTHelper.getINBT(nbt, "Connected")); float length = nbt.getFloat("Length"); boolean contraption = nbt.getBoolean("Contraption"); return new CouplingData(mainCartID, connectedCartID, length, contraption); @@ -396,22 +396,22 @@ public class MinecartController implements INBTSerializable { private StallData() {} StallData(AbstractMinecartEntity entity) { - position = entity.getPositionVec(); - motion = entity.getMotion(); - yaw = entity.rotationYaw; - pitch = entity.rotationPitch; + position = entity.position(); + motion = entity.getDeltaMovement(); + yaw = entity.yRot; + pitch = entity.xRot; tick(entity); } void tick(AbstractMinecartEntity entity) { - entity.setPosition(position.x, position.y, position.z); - entity.setMotion(Vector3d.ZERO); - entity.rotationYaw = yaw; - entity.rotationPitch = pitch; + entity.setPos(position.x, position.y, position.z); + entity.setDeltaMovement(Vector3d.ZERO); + entity.yRot = yaw; + entity.xRot = pitch; } void release(AbstractMinecartEntity entity) { - entity.setMotion(motion); + entity.setDeltaMovement(motion); } CompoundNBT serialize() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/MinecartControllerUpdatePacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/MinecartControllerUpdatePacket.java index 58008e2c8..2f52fb897 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/MinecartControllerUpdatePacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/MinecartControllerUpdatePacket.java @@ -21,19 +21,19 @@ public class MinecartControllerUpdatePacket extends SimplePacketBase { public MinecartControllerUpdatePacket(MinecartController controller) { entityID = controller.cart() - .getEntityId(); + .getId(); nbt = controller.serializeNBT(); } public MinecartControllerUpdatePacket(PacketBuffer buffer) { entityID = buffer.readInt(); - nbt = buffer.readCompoundTag(); + nbt = buffer.readNbt(); } @Override public void write(PacketBuffer buffer) { buffer.writeInt(entityID); - buffer.writeCompoundTag(nbt); + buffer.writeNbt(nbt); } @Override @@ -46,10 +46,10 @@ public class MinecartControllerUpdatePacket extends SimplePacketBase { @OnlyIn(Dist.CLIENT) private void handleCL() { - ClientWorld world = Minecraft.getInstance().world; + ClientWorld world = Minecraft.getInstance().level; if (world == null) return; - Entity entityByID = world.getEntityByID(entityID); + Entity entityByID = world.getEntity(entityID); if (entityByID == null) return; entityByID.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java index 4c803185f..acb0c8c20 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java @@ -39,29 +39,31 @@ import net.minecraft.util.math.vector.Vector3i; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class ControllerRailBlock extends AbstractRailBlock implements IWrenchable { public static final EnumProperty SHAPE = BlockStateProperties.RAIL_SHAPE_STRAIGHT; public static final BooleanProperty BACKWARDS = BooleanProperty.create("backwards"); - public static final IntegerProperty POWER = BlockStateProperties.POWER_0_15; + public static final IntegerProperty POWER = BlockStateProperties.POWER; public ControllerRailBlock(Properties properties) { super(true, properties); - this.setDefaultState(this.stateContainer.getBaseState() - .with(POWER, 0) - .with(BACKWARDS, false) - .with(SHAPE, NORTH_SOUTH)); + this.registerDefaultState(this.stateDefinition.any() + .setValue(POWER, 0) + .setValue(BACKWARDS, false) + .setValue(SHAPE, NORTH_SOUTH)); } public static Vector3i getAccelerationVector(BlockState state) { Direction pointingTo = getPointingTowards(state); - return (isStateBackwards(state) ? pointingTo.getOpposite() : pointingTo).getDirectionVec(); + return (isStateBackwards(state) ? pointingTo.getOpposite() : pointingTo).getNormal(); } private static Direction getPointingTowards(BlockState state) { - switch (state.get(SHAPE)) { + switch (state.getValue(SHAPE)) { case ASCENDING_WEST: case EAST_WEST: return Direction.WEST; @@ -75,9 +77,9 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl } @Override - protected BlockState getUpdatedState(World world, BlockPos pos, BlockState state, boolean p_208489_4_) { - BlockState updatedState = super.getUpdatedState(world, pos, state, p_208489_4_); - if (updatedState.get(SHAPE) == state.get(SHAPE)) + protected BlockState updateDir(World world, BlockPos pos, BlockState state, boolean p_208489_4_) { + BlockState updatedState = super.updateDir(world, pos, state, p_208489_4_); + if (updatedState.getValue(SHAPE) == state.getValue(SHAPE)) return updatedState; BlockState reversedUpdatedState = updatedState; @@ -87,13 +89,13 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl Direction offset = getPointingTowards(updatedState); if (opposite) offset = offset.getOpposite(); - for (BlockPos adjPos : Iterate.hereBelowAndAbove(pos.offset(offset))) { + for (BlockPos adjPos : Iterate.hereBelowAndAbove(pos.relative(offset))) { BlockState adjState = world.getBlockState(adjPos); if (!AllBlocks.CONTROLLER_RAIL.has(adjState)) continue; if (getPointingTowards(adjState).getAxis() != offset.getAxis()) continue; - if (adjState.get(BACKWARDS) != reversedUpdatedState.get(BACKWARDS)) + if (adjState.getValue(BACKWARDS) != reversedUpdatedState.getValue(BACKWARDS)) reversedUpdatedState = reversedUpdatedState.cycle(BACKWARDS); } } @@ -101,31 +103,31 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl // Replace if changed if (reversedUpdatedState != updatedState) - world.setBlockState(pos, reversedUpdatedState); + world.setBlockAndUpdate(pos, reversedUpdatedState); return reversedUpdatedState; } private static void decelerateCart(BlockPos pos, AbstractMinecartEntity cart) { Vector3d diff = VecHelper.getCenterOf(pos) - .subtract(cart.getPositionVec()); - cart.setMotion(diff.x / 16f, 0, diff.z / 16f); + .subtract(cart.position()); + cart.setDeltaMovement(diff.x / 16f, 0, diff.z / 16f); if (cart instanceof FurnaceMinecartEntity) { FurnaceMinecartEntity fme = (FurnaceMinecartEntity) cart; - fme.pushX = fme.pushZ = 0; + fme.xPush = fme.zPush = 0; } } private static boolean isStableWith(BlockState testState, IBlockReader world, BlockPos pos) { - return hasSolidSideOnTop(world, pos.down()) && (!testState.get(SHAPE) - .isAscending() || hasSolidSideOnTop(world, pos.offset(getPointingTowards(testState)))); + return canSupportRigidBlock(world, pos.below()) && (!testState.getValue(SHAPE) + .isAscending() || canSupportRigidBlock(world, pos.relative(getPointingTowards(testState)))); } @Override public BlockState getStateForPlacement(BlockItemUseContext p_196258_1_) { - Direction direction = p_196258_1_.getPlacementHorizontalFacing(); + Direction direction = p_196258_1_.getHorizontalDirection(); BlockState base = super.getStateForPlacement(p_196258_1_); - return (base == null ? getDefaultState() : base).with(BACKWARDS, + return (base == null ? defaultBlockState() : base).setValue(BACKWARDS, direction.getAxisDirection() == AxisDirection.POSITIVE); } @@ -135,26 +137,26 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl } @Override - protected void fillStateContainer(StateContainer.Builder p_206840_1_) { + protected void createBlockStateDefinition(StateContainer.Builder p_206840_1_) { p_206840_1_.add(SHAPE, POWER, BACKWARDS); } @Override public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) { - if (world.isRemote) + if (world.isClientSide) return; - Vector3d accelerationVec = Vector3d.of(getAccelerationVector(state)); - double targetSpeed = cart.getMaxSpeedWithRail() * state.get(POWER) / 15f; + Vector3d accelerationVec = Vector3d.atLowerCornerOf(getAccelerationVector(state)); + double targetSpeed = cart.getMaxSpeedWithRail() * state.getValue(POWER) / 15f; if (cart instanceof FurnaceMinecartEntity) { FurnaceMinecartEntity fme = (FurnaceMinecartEntity) cart; - fme.pushX = accelerationVec.x; - fme.pushZ = accelerationVec.z; + fme.xPush = accelerationVec.x; + fme.zPush = accelerationVec.z; } - Vector3d motion = cart.getMotion(); - if ((motion.dotProduct(accelerationVec) >= 0 || motion.lengthSquared() < 0.0001) && targetSpeed > 0) - cart.setMotion(accelerationVec.scale(targetSpeed)); + Vector3d motion = cart.getDeltaMovement(); + if ((motion.dot(accelerationVec) >= 0 || motion.lengthSqr() < 0.0001) && targetSpeed > 0) + cart.setDeltaMovement(accelerationVec.scale(targetSpeed)); else decelerateCart(pos, cart); } @@ -162,12 +164,12 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl @Override protected void updateState(BlockState state, World world, BlockPos pos, Block block) { int newPower = calculatePower(world, pos); - if (state.get(POWER) != newPower) - placeAndNotify(state.with(POWER, newPower), pos, world); + if (state.getValue(POWER) != newPower) + placeAndNotify(state.setValue(POWER, newPower), pos, world); } private int calculatePower(World world, BlockPos pos) { - int newPower = world.getRedstonePowerFromNeighbors(pos); + int newPower = world.getBestNeighborSignal(pos); if (newPower != 0) return newPower; @@ -184,7 +186,7 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl break; forwardDistance++; lastForwardRail = testPos; - forwardPower = world.getRedstonePowerFromNeighbors(testPos); + forwardPower = world.getBestNeighborSignal(testPos); if (forwardPower != 0) break; } @@ -194,7 +196,7 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl break; backwardsDistance++; lastBackwardsRail = testPos; - backwardsPower = world.getRedstonePowerFromNeighbors(testPos); + backwardsPower = world.getBestNeighborSignal(testPos); if (backwardsPower != 0) break; } @@ -213,10 +215,10 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getWorld(); - if (world.isRemote) + World world = context.getLevel(); + if (world.isClientSide) return ActionResultType.SUCCESS; - BlockPos pos = context.getPos(); + BlockPos pos = context.getClickedPos(); for (Rotation testRotation : new Rotation[] { Rotation.CLOCKWISE_90, Rotation.CLOCKWISE_180, Rotation.COUNTERCLOCKWISE_90 }) { BlockState testState = rotate(state, testRotation); @@ -225,18 +227,18 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl return ActionResultType.SUCCESS; } } - BlockState testState = state.with(BACKWARDS, !state.get(BACKWARDS)); + BlockState testState = state.setValue(BACKWARDS, !state.getValue(BACKWARDS)); if (isStableWith(testState, world, pos)) placeAndNotify(testState, pos, world); return ActionResultType.SUCCESS; } private void placeAndNotify(BlockState state, BlockPos pos, World world) { - world.setBlockState(pos, state, 3); - world.notifyNeighborsOfStateChange(pos.down(), this); - if (state.get(SHAPE) + world.setBlock(pos, state, 3); + world.updateNeighborsAt(pos.below(), this); + if (state.getValue(SHAPE) .isAscending()) - world.notifyNeighborsOfStateChange(pos.up(), this); + world.updateNeighborsAt(pos.above(), this); } @Nullable @@ -245,9 +247,9 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl if (!(current.getBlock() instanceof ControllerRailBlock)) return null; Vector3i accelerationVec = getAccelerationVector(current); - BlockPos baseTestPos = reversed ? from.subtract(accelerationVec) : from.add(accelerationVec); + BlockPos baseTestPos = reversed ? from.subtract(accelerationVec) : from.offset(accelerationVec); for (BlockPos testPos : Iterate.hereBelowAndAbove(baseTestPos)) { - if (testPos.getY() > from.getY() && !current.get(SHAPE) + if (testPos.getY() > from.getY() && !current.getValue(SHAPE) .isAscending()) continue; BlockState testState = world.getBlockState(testPos); @@ -259,13 +261,13 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl } @Override - public boolean hasComparatorInputOverride(BlockState state) { + public boolean hasAnalogOutputSignal(BlockState state) { return true; } @Override - public int getComparatorInputOverride(BlockState state, World world, BlockPos pos) { - return state.get(POWER); + public int getAnalogOutputSignal(BlockState state, World world, BlockPos pos) { + return state.getValue(POWER); } @Override @@ -273,11 +275,11 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl if (rotation == Rotation.NONE) return state; - RailShape railshape = Blocks.POWERED_RAIL.getDefaultState() - .with(SHAPE, state.get(SHAPE)) + RailShape railshape = Blocks.POWERED_RAIL.defaultBlockState() + .setValue(SHAPE, state.getValue(SHAPE)) .rotate(rotation) - .get(SHAPE); - state = state.with(SHAPE, railshape); + .getValue(SHAPE); + state = state.setValue(SHAPE, railshape); if (rotation == Rotation.CLOCKWISE_180 || (getPointingTowards(state).getAxis() == Axis.Z) == (rotation == Rotation.COUNTERCLOCKWISE_90)) @@ -291,11 +293,11 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl if (mirror == Mirror.NONE) return state; - RailShape railshape = Blocks.POWERED_RAIL.getDefaultState() - .with(SHAPE, state.get(SHAPE)) + RailShape railshape = Blocks.POWERED_RAIL.defaultBlockState() + .setValue(SHAPE, state.getValue(SHAPE)) .mirror(mirror) - .get(SHAPE); - state = state.with(SHAPE, railshape); + .getValue(SHAPE); + state = state.setValue(SHAPE, railshape); if ((getPointingTowards(state).getAxis() == Axis.Z) == (mirror == Mirror.LEFT_RIGHT)) return state.cycle(BACKWARDS); @@ -304,10 +306,10 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl } public static boolean isStateBackwards(BlockState state) { - return state.get(BACKWARDS) ^ isReversedSlope(state); + return state.getValue(BACKWARDS) ^ isReversedSlope(state); } public static boolean isReversedSlope(BlockState state) { - return state.get(SHAPE) == RailShape.ASCENDING_SOUTH || state.get(SHAPE) == RailShape.ASCENDING_EAST; + return state.getValue(SHAPE) == RailShape.ASCENDING_SOUTH || state.getValue(SHAPE) == RailShape.ASCENDING_EAST; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailGenerator.java index cc961ac13..0cdda2aa0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailGenerator.java @@ -25,7 +25,7 @@ public class ControllerRailGenerator extends SpecialBlockStateGen { @Override protected int getYRotation(BlockState state) { - RailShape shape = state.get(ControllerRailBlock.SHAPE); + RailShape shape = state.getValue(ControllerRailBlock.SHAPE); boolean backwards = ControllerRailBlock.isStateBackwards(state); int rotation = backwards ? 180 : 0; @@ -45,7 +45,7 @@ public class ControllerRailGenerator extends SpecialBlockStateGen { @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - RailShape shape = state.get(ControllerRailBlock.SHAPE); + RailShape shape = state.getValue(ControllerRailBlock.SHAPE); boolean backwards = ControllerRailBlock.isStateBackwards(state); String model = shape.isAscending() ? backwards ? "ascending_south" : "ascending_north" : "north_south"; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ReinforcedRailBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ReinforcedRailBlock.java index cb092ceff..e6b0e662f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ReinforcedRailBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ReinforcedRailBlock.java @@ -25,6 +25,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class ReinforcedRailBlock extends AbstractRailBlock { public static Property RAIL_SHAPE = @@ -38,7 +40,7 @@ public class ReinforcedRailBlock extends AbstractRailBlock { } @Override - public void fillItemGroup(ItemGroup p_149666_1_, NonNullList p_149666_2_) { + public void fillItemCategory(ItemGroup p_149666_1_, NonNullList p_149666_2_) { // TODO re-add when finished } @@ -49,15 +51,15 @@ public class ReinforcedRailBlock extends AbstractRailBlock { } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(RAIL_SHAPE, CONNECTS_N, CONNECTS_S); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - boolean alongX = context.getPlacementHorizontalFacing().getAxis() == Axis.X; - return super.getStateForPlacement(context).with(RAIL_SHAPE, alongX ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).with(CONNECTS_N, false).with(CONNECTS_S, false); + boolean alongX = context.getHorizontalDirection().getAxis() == Axis.X; + return super.getStateForPlacement(context).setValue(RAIL_SHAPE, alongX ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).setValue(CONNECTS_N, false).setValue(CONNECTS_S, false); } @Override @@ -68,22 +70,22 @@ public class ReinforcedRailBlock extends AbstractRailBlock { @Override protected void updateState(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Block block) { super.updateState(state, world, pos, block); - world.setBlockState(pos, getUpdatedState(world, pos, state, true)); + world.setBlockAndUpdate(pos, updateDir(world, pos, state, true)); } @Override @Nonnull - protected BlockState getUpdatedState(@Nonnull World world, BlockPos pos, BlockState state, + protected BlockState updateDir(@Nonnull World world, BlockPos pos, BlockState state, boolean p_208489_4_) { - boolean alongX = state.get(RAIL_SHAPE) == RailShape.EAST_WEST; - BlockPos sPos = pos.add(alongX ? -1 : 0, 0, alongX ? 0 : 1); - BlockPos nPos = pos.add(alongX ? 1 : 0, 0, alongX ? 0 : -1); + boolean alongX = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST; + BlockPos sPos = pos.offset(alongX ? -1 : 0, 0, alongX ? 0 : 1); + BlockPos nPos = pos.offset(alongX ? 1 : 0, 0, alongX ? 0 : -1); - return super.getUpdatedState(world, pos, state, p_208489_4_).with(CONNECTS_S, world.getBlockState(sPos).getBlock() instanceof ReinforcedRailBlock && - (world.getBlockState(sPos).get(RAIL_SHAPE) == state.get(RAIL_SHAPE))) - .with(CONNECTS_N, world.getBlockState(nPos).getBlock() instanceof ReinforcedRailBlock && - (world.getBlockState(nPos).get(RAIL_SHAPE) == state.get(RAIL_SHAPE))); + return super.updateDir(world, pos, state, p_208489_4_).setValue(CONNECTS_S, world.getBlockState(sPos).getBlock() instanceof ReinforcedRailBlock && + (world.getBlockState(sPos).getValue(RAIL_SHAPE) == state.getValue(RAIL_SHAPE))) + .setValue(CONNECTS_N, world.getBlockState(nPos).getBlock() instanceof ReinforcedRailBlock && + (world.getBlockState(nPos).getValue(RAIL_SHAPE) == state.getValue(RAIL_SHAPE))); } @Override @@ -98,13 +100,13 @@ public class ReinforcedRailBlock extends AbstractRailBlock { @Override @Nonnull public VoxelShape getShape(BlockState state, @Nonnull IBlockReader reader, @Nonnull BlockPos pos, ISelectionContext context) { - boolean alongX = state.get(RAIL_SHAPE) == RailShape.EAST_WEST; - return VoxelShapes.or(makeCuboidShape(0, -2, 0, 16, 2, 16), VoxelShapes.or(makeCuboidShape(0, -2, 0, alongX ? 16 : -1, 12, alongX ? -1 : 16), makeCuboidShape(alongX ? 0 : 17, -2, alongX ? 17 : 0, 16, 12, 16))); + boolean alongX = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST; + return VoxelShapes.or(box(0, -2, 0, 16, 2, 16), VoxelShapes.or(box(0, -2, 0, alongX ? 16 : -1, 12, alongX ? -1 : 16), box(alongX ? 0 : 17, -2, alongX ? 17 : 0, 16, 12, 16))); } @Override @Nonnull - public PushReaction getPushReaction(BlockState state) { + public PushReaction getPistonPushReaction(BlockState state) { return PushReaction.BLOCK; } @@ -115,16 +117,16 @@ public class ReinforcedRailBlock extends AbstractRailBlock { }*/ @Override - public boolean isValidPosition(BlockState state, IWorldReader world, BlockPos pos) { - return !(world.getBlockState(pos.down()).getBlock() instanceof AbstractRailBlock || world.getBlockState(pos.up()).getBlock() instanceof AbstractRailBlock); + public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { + return !(world.getBlockState(pos.below()).getBlock() instanceof AbstractRailBlock || world.getBlockState(pos.above()).getBlock() instanceof AbstractRailBlock); } @Override public void neighborChanged(@Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull Block block, @Nonnull BlockPos pos2, boolean p_220069_6_) { - if (!world.isRemote) { - if ((world.getBlockState(pos.down()).getBlock() instanceof AbstractRailBlock)) { + if (!world.isClientSide) { + if ((world.getBlockState(pos.below()).getBlock() instanceof AbstractRailBlock)) { if (!p_220069_6_) { - spawnDrops(state, world, pos); + dropResources(state, world, pos); } world.removeBlock(pos, false); } else { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/turntable/TurntableBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/turntable/TurntableBlock.java index c9763ef7f..9db909491 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/turntable/TurntableBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/turntable/TurntableBlock.java @@ -25,6 +25,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class TurntableBlock extends KineticBlock implements ITE { public TurntableBlock(Properties properties) { @@ -37,7 +39,7 @@ public class TurntableBlock extends KineticBlock implements ITE 0) + if (e.getDeltaMovement().y > 0) return; if (e.getY() < pos.getY() + .5f) return; @@ -60,36 +62,36 @@ public class TurntableBlock extends KineticBlock implements ITE 1/4f) speed *= MathHelper.clamp((1/2f - offset.length()) * 2, 0, 1); - mc.player.rotationYaw = mc.player.prevRotationYaw - speed * AnimationTickHolder.getPartialTicks(); - mc.player.renderYawOffset = mc.player.rotationYaw; + mc.player.yRot = mc.player.yRotO - speed * AnimationTickHolder.getPartialTicks(); + mc.player.yBodyRot = mc.player.yRot; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelBlock.java index 86d267b38..30f644fef 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelBlock.java @@ -32,6 +32,8 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class WaterWheelBlock extends DirectionalKineticBlock implements ITE { @@ -46,21 +48,21 @@ public class WaterWheelBlock extends DirectionalKineticBlock implements ITE 0 ^ !clockwise ? -flow.z * clockwiseMultiplier : -flow.z; } - if (te.getSpeed() == 0 && flowStrength != 0 && !world.isRemote()) { + if (te.getSpeed() == 0 && flowStrength != 0 && !world.isClientSide()) { AllTriggers.triggerForNearbyPlayers(AllTriggers.WATER_WHEEL, world, pos, 5); - if (FluidHelper.isLava(fluid.getFluid())) + if (FluidHelper.isLava(fluid.getType())) AllTriggers.triggerForNearbyPlayers(AllTriggers.LAVA_WHEEL, world, pos, 5); - if (fluid.getFluid() - .isEquivalentTo(AllFluids.CHOCOLATE.get())) + if (fluid.getType() + .isSame(AllFluids.CHOCOLATE.get())) AllTriggers.triggerForNearbyPlayers(AllTriggers.CHOCOLATE_WHEEL, world, pos, 5); } @@ -156,48 +158,48 @@ public class WaterWheelBlock extends DirectionalKineticBlock implements ITE tolerance) + else if (Vector3d.atLowerCornerOf(Direction.DOWN.getNormal()) + .dot(lookVec.normalize()) > tolerance) facing = Direction.DOWN; - else if (Vector3d.of(Direction.UP.getDirectionVec()) - .dotProduct(lookVec.normalize()) > tolerance) + else if (Vector3d.atLowerCornerOf(Direction.UP.getNormal()) + .dot(lookVec.normalize()) > tolerance) facing = Direction.UP; else facing = horizontalFacing; } - return getDefaultState().with(FACING, sneaking ? facing.getOpposite() : facing); + return defaultBlockState().setValue(FACING, sneaking ? facing.getOpposite() : facing); } @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return state.get(FACING) + return state.getValue(FACING) .getAxis() == face.getAxis(); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(FACING) + return state.getValue(FACING) .getAxis(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelTileEntity.java index 7f89e5c47..6b8b9e9d7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/waterwheel/WaterWheelTileEntity.java @@ -32,20 +32,20 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity { if (compound.contains("Flows")) { for (Direction d : Iterate.directions) setFlow(d, compound.getCompound("Flows") - .getFloat(d.getString())); + .getFloat(d.getSerializedName())); } } @Override public AxisAlignedBB makeRenderBoundingBox() { - return new AxisAlignedBB(pos).grow(1); + return new AxisAlignedBB(worldPosition).inflate(1); } @Override public void write(CompoundNBT compound, boolean clientPacket) { CompoundNBT flows = new CompoundNBT(); for (Direction d : Iterate.directions) - flows.putFloat(d.getString(), this.flows.get(d)); + flows.putFloat(d.getSerializedName(), this.flows.get(d)); compound.put("Flows", flows); super.write(compound, clientPacket); @@ -53,7 +53,7 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity { public void setFlow(Direction direction, float speed) { flows.put(direction, speed); - markDirty(); + setChanged(); } @Override @@ -70,7 +70,7 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity { public void lazyTick() { super.lazyTick(); AllBlocks.WATER_WHEEL.get() - .updateAllSides(getBlockState(), world, pos); + .updateAllSides(getBlockState(), level, worldPosition); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FlowSource.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FlowSource.java index e2beb3a37..4df90ba50 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FlowSource.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FlowSource.java @@ -70,7 +70,7 @@ public abstract class FlowSource { public void manageSource(World world) { if (fluidHandler.isPresent()) return; - TileEntity tileEntity = world.getTileEntity(location.getConnectedPos()); + TileEntity tileEntity = world.getBlockEntity(location.getConnectedPos()); if (tileEntity != null) fluidHandler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, location.getOppositeFace()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidBottleItemHook.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidBottleItemHook.java index 9a2d9f047..16df63210 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidBottleItemHook.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidBottleItemHook.java @@ -18,6 +18,8 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.item.Item.Properties; + @EventBusSubscriber public class FluidBottleItemHook extends Item { @@ -35,15 +37,15 @@ public class FluidBottleItemHook extends Item { World world = event.getWorld(); PlayerEntity player = event.getPlayer(); - RayTraceResult raytraceresult = rayTrace(world, player, RayTraceContext.FluidMode.SOURCE_ONLY); + RayTraceResult raytraceresult = getPlayerPOVHitResult(world, player, RayTraceContext.FluidMode.SOURCE_ONLY); if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) return; - BlockPos blockpos = ((BlockRayTraceResult) raytraceresult).getPos(); - if (!world.isBlockModifiable(player, blockpos)) + BlockPos blockpos = ((BlockRayTraceResult) raytraceresult).getBlockPos(); + if (!world.mayInteract(player, blockpos)) return; FluidState fluidState = world.getFluidState(blockpos); - if (fluidState.isTagged(FluidTags.WATER) && fluidState.getFluid() + if (fluidState.is(FluidTags.WATER) && fluidState.getType() .getRegistryName() .getNamespace() .equals(Create.ID)) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidFX.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidFX.java index bd22b97d1..8fb4b209f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidFX.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidFX.java @@ -29,12 +29,12 @@ public class FluidFX { if (fluid == Fluids.EMPTY) return; - FluidState defaultState = fluid.getDefaultState(); + FluidState defaultState = fluid.defaultFluidState(); if (defaultState == null || defaultState.isEmpty()) { return; } - BlockParticleData blockParticleData = new BlockParticleData(ParticleTypes.BLOCK, defaultState.getBlockState()); + BlockParticleData blockParticleData = new BlockParticleData(ParticleTypes.BLOCK, defaultState.createLegacyBlock()); Vector3d center = VecHelper.getCenterOf(pos); for (int i = 0; i < 20; i++) { @@ -61,17 +61,17 @@ public class FluidFX { public static void spawnRimParticles(World world, BlockPos pos, Direction side, int amount, IParticleData particle, float rimRadius) { - Vector3d directionVec = Vector3d.of(side.getDirectionVec()); + Vector3d directionVec = Vector3d.atLowerCornerOf(side.getNormal()); for (int i = 0; i < amount; i++) { Vector3d vec = VecHelper.offsetRandomly(Vector3d.ZERO, r, 1) .normalize(); vec = VecHelper.clampComponentWise(vec, rimRadius) - .mul(VecHelper.axisAlingedPlaneOf(directionVec)) + .multiply(VecHelper.axisAlingedPlaneOf(directionVec)) .add(directionVec.scale(.45 + r.nextFloat() / 16f)); Vector3d m = vec.scale(.05f); vec = vec.add(VecHelper.getCenterOf(pos)); - world.addOptionalParticle(particle, vec.x, vec.y - 1 / 16f, vec.z, m.x, m.y, m.z); + world.addAlwaysVisibleParticle(particle, vec.x, vec.y - 1 / 16f, vec.z, m.x, m.y, m.z); } } @@ -79,7 +79,7 @@ public class FluidFX { float rimRadius, Vector3d directionVec, boolean inbound) { for (int i = 0; i < amount; i++) { Vector3d vec = VecHelper.offsetRandomly(Vector3d.ZERO, r, rimRadius * .75f); - vec = vec.mul(VecHelper.axisAlingedPlaneOf(directionVec)) + vec = vec.multiply(VecHelper.axisAlingedPlaneOf(directionVec)) .add(directionVec.scale(.5 + r.nextFloat() / 4f)); Vector3d m = vec.scale(1 / 4f); Vector3d centerOf = VecHelper.getCenterOf(pos); @@ -90,7 +90,7 @@ public class FluidFX { .subtract(vec) .scale(1 / 16f); } - world.addOptionalParticle(particle, vec.x, vec.y - 1 / 16f, vec.z, m.x, m.y, m.z); + world.addAlwaysVisibleParticle(particle, vec.x, vec.y - 1 / 16f, vec.z, m.x, m.y, m.z); } } @@ -99,7 +99,7 @@ public class FluidFX { } private static World world() { - return Minecraft.getInstance().world; + return Minecraft.getInstance().level; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java index 6e49b3c2e..9fe68887f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java @@ -54,14 +54,14 @@ public class FluidPropagator { pipe.wipePressure(); for (Direction direction : getPipeConnections(currentState, pipe)) { - BlockPos target = currentPos.offset(direction); + BlockPos target = currentPos.relative(direction); if (!world.isAreaLoaded(target, 0)) continue; - TileEntity tileEntity = world.getTileEntity(target); + TileEntity tileEntity = world.getBlockEntity(target); BlockState targetState = world.getBlockState(target); if (tileEntity instanceof PumpTileEntity) { - if (!AllBlocks.MECHANICAL_PUMP.has(targetState) || targetState.get(PumpBlock.FACING) + if (!AllBlocks.MECHANICAL_PUMP.has(targetState) || targetState.getValue(PumpBlock.FACING) .getAxis() != direction.getAxis()) continue; discoveredPumps.add(Pair.of((PumpTileEntity) tileEntity, direction.getOpposite())); @@ -101,7 +101,7 @@ public class FluidPropagator { for (Direction d : Iterate.directions) { if (pos.equals(start) && d != side) continue; - BlockPos target = pos.offset(d); + BlockPos target = pos.relative(d); if (visited.contains(target)) continue; @@ -123,7 +123,7 @@ public class FluidPropagator { public static Direction validateNeighbourChange(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - if (world.isRemote) + if (world.isClientSide) return null; if (otherBlock instanceof FluidPipeBlock) return null; @@ -136,7 +136,7 @@ public class FluidPropagator { if (getStraightPipeAxis(state) == null) return null; for (Direction d : Iterate.directions) { - if (!pos.offset(d) + if (!pos.relative(d) .equals(neighborPos)) continue; return d; @@ -149,21 +149,21 @@ public class FluidPropagator { } public static boolean isOpenEnd(IBlockReader reader, BlockPos pos, Direction side) { - BlockPos connectedPos = pos.offset(side); + BlockPos connectedPos = pos.relative(side); BlockState connectedState = reader.getBlockState(connectedPos); FluidTransportBehaviour pipe = FluidPropagator.getPipe(reader, connectedPos); if (pipe != null && pipe.canHaveFlowToward(connectedState, side.getOpposite())) return false; - if (PumpBlock.isPump(connectedState) && connectedState.get(PumpBlock.FACING) + if (PumpBlock.isPump(connectedState) && connectedState.getValue(PumpBlock.FACING) .getAxis() == side.getAxis()) return false; - if (connectedState.contains(BlockStateProperties.HONEY_LEVEL)) + if (connectedState.hasProperty(BlockStateProperties.LEVEL_HONEY)) return true; if (BlockHelper.hasBlockSolidSide(connectedState, reader, connectedPos, side.getOpposite())) return false; if (!(connectedState.getMaterial() - .isReplaceable() && connectedState.getBlockHardness(reader, connectedPos) != -1) - && !connectedState.contains(BlockStateProperties.WATERLOGGED)) + .isReplaceable() && connectedState.getDestroySpeed(reader, connectedPos) != -1) + && !connectedState.hasProperty(BlockStateProperties.WATERLOGGED)) return false; return true; } @@ -202,7 +202,7 @@ public class FluidPropagator { // } public static boolean hasFluidCapability(IBlockReader world, BlockPos pos, Direction side) { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); return tileEntity != null && tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side) .isPresent(); } @@ -210,17 +210,17 @@ public class FluidPropagator { @Nullable public static Axis getStraightPipeAxis(BlockState state) { if (state.getBlock() instanceof PumpBlock) - return state.get(PumpBlock.FACING) + return state.getValue(PumpBlock.FACING) .getAxis(); if (state.getBlock() instanceof AxisPipeBlock) - return state.get(AxisPipeBlock.AXIS); + return state.getValue(AxisPipeBlock.AXIS); if (!FluidPipeBlock.isPipe(state)) return null; Axis axisFound = null; int connections = 0; for (Axis axis : Iterate.axes) { - Direction d1 = Direction.getFacingFromAxis(AxisDirection.NEGATIVE, axis); - Direction d2 = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); + Direction d1 = Direction.get(AxisDirection.NEGATIVE, axis); + Direction d2 = Direction.get(AxisDirection.POSITIVE, axis); boolean openAt1 = FluidPipeBlock.isOpenAt(state, d1); boolean openAt2 = FluidPipeBlock.isOpenAt(state, d2); if (openAt1) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidReactions.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidReactions.java index aa010ab7b..9c249f8fd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidReactions.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidReactions.java @@ -24,41 +24,41 @@ public class FluidReactions { AllTriggers.triggerForNearbyPlayers(AllTriggers.PIPE_COLLISION, world, pos, 5); if (f1 == Fluids.WATER && f2 == Fluids.LAVA || f2 == Fluids.WATER && f1 == Fluids.LAVA) - world.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.COBBLESTONE.defaultBlockState()); else if (f1 == Fluids.LAVA && FluidHelper.hasBlockState(f2)) { BlockState lavaInteraction = AllFluids.getLavaInteraction(FluidHelper.convertToFlowing(f2) - .getDefaultState()); + .defaultFluidState()); if (lavaInteraction != null) - world.setBlockState(pos, lavaInteraction); + world.setBlockAndUpdate(pos, lavaInteraction); } else if (f2 == Fluids.LAVA && FluidHelper.hasBlockState(f1)) { BlockState lavaInteraction = AllFluids.getLavaInteraction(FluidHelper.convertToFlowing(f1) - .getDefaultState()); + .defaultFluidState()); if (lavaInteraction != null) - world.setBlockState(pos, lavaInteraction); + world.setBlockAndUpdate(pos, lavaInteraction); } } public static void handlePipeSpillCollision(World world, BlockPos pos, Fluid pipeFluid, FluidState worldFluid) { Fluid pf = FluidHelper.convertToStill(pipeFluid); - Fluid wf = worldFluid.getFluid(); - if (pf.isIn(FluidTags.WATER) && wf == Fluids.LAVA) - world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState()); + Fluid wf = worldFluid.getType(); + if (pf.is(FluidTags.WATER) && wf == Fluids.LAVA) + world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState()); else if (pf == Fluids.WATER && wf == Fluids.FLOWING_LAVA) - world.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.COBBLESTONE.defaultBlockState()); else if (pf == Fluids.LAVA && wf == Fluids.WATER) - world.setBlockState(pos, Blocks.STONE.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.STONE.defaultBlockState()); else if (pf == Fluids.LAVA && wf == Fluids.FLOWING_WATER) - world.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.COBBLESTONE.defaultBlockState()); if (pf == Fluids.LAVA) { BlockState lavaInteraction = AllFluids.getLavaInteraction(worldFluid); if (lavaInteraction != null) - world.setBlockState(pos, lavaInteraction); + world.setBlockAndUpdate(pos, lavaInteraction); } else if (wf == Fluids.FLOWING_LAVA && FluidHelper.hasBlockState(pf)) { BlockState lavaInteraction = AllFluids.getLavaInteraction(FluidHelper.convertToFlowing(pf) - .getDefaultState()); + .defaultFluidState()); if (lavaInteraction != null) - world.setBlockState(pos, lavaInteraction); + world.setBlockAndUpdate(pos, lavaInteraction); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTransportBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTransportBehaviour.java index 1370d3b5d..87d73c00c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTransportBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTransportBehaviour.java @@ -60,7 +60,7 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { super.tick(); World world = getWorld(); BlockPos pos = getPos(); - boolean onServer = !world.isRemote || tileEntity.isVirtual(); + boolean onServer = !world.isClientSide || tileEntity.isVirtual(); if (interfaces == null) return; @@ -145,7 +145,7 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { if (interfaces == null) interfaces = new IdentityHashMap<>(); for (Direction face : Iterate.directions) - if (nbt.contains(face.getName2())) + if (nbt.contains(face.getName())) interfaces.computeIfAbsent(face, d -> new PipeConnection(d)); // Invalid data (missing/outdated). Defer init to runtime @@ -155,7 +155,7 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { } interfaces.values() - .forEach(connection -> connection.deserializeNBT(nbt, tileEntity.getPos(), clientPacket)); + .forEach(connection -> connection.deserializeNBT(nbt, tileEntity.getBlockPos(), clientPacket)); } @Override @@ -238,15 +238,15 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { if (!canHaveFlowToward(state, direction)) return AttachmentTypes.NONE; - BlockPos offsetPos = pos.offset(direction); + BlockPos offsetPos = pos.relative(direction); BlockState facingState = world.getBlockState(offsetPos); - if (facingState.getBlock() instanceof PumpBlock && facingState.get(PumpBlock.FACING) + if (facingState.getBlock() instanceof PumpBlock && facingState.getValue(PumpBlock.FACING) .getAxis() == direction.getAxis()) return AttachmentTypes.NONE; if (AllBlocks.ENCASED_FLUID_PIPE.has(facingState) - && facingState.get(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(direction.getOpposite()))) + && facingState.getValue(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(direction.getOpposite()))) return AttachmentTypes.NONE; if (FluidPropagator.hasFluidCapability(world, offsetPos, direction.getOpposite()) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java index 1aa0ecd7c..f412b03d9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.fluids; -import static net.minecraft.state.properties.BlockStateProperties.HONEY_LEVEL; +import static net.minecraft.state.properties.BlockStateProperties.LEVEL_HONEY; import static net.minecraft.state.properties.BlockStateProperties.WATERLOGGED; import java.util.List; @@ -38,6 +38,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.templates.FluidTank; +import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; + public class OpenEndedPipe extends FlowSource { World world; @@ -56,9 +58,9 @@ public class OpenEndedPipe extends FlowSource { fluidHandler = new OpenEndFluidHandler(); outputPos = face.getConnectedPos(); pos = face.getPos(); - aoe = new AxisAlignedBB(outputPos).expand(0, -1, 0); + aoe = new AxisAlignedBB(outputPos).expandTowards(0, -1, 0); if (face.getFace() == Direction.DOWN) - aoe = aoe.expand(0, -1, 0); + aoe = aoe.expandTowards(0, -1, 0); } @Override @@ -75,13 +77,13 @@ public class OpenEndedPipe extends FlowSource { BlockState state = world.getBlockState(outputPos); FluidState fluidState = state.getFluidState(); - boolean waterlog = state.contains(WATERLOGGED); + boolean waterlog = state.hasProperty(WATERLOGGED); - if (state.contains(HONEY_LEVEL) && state.get(HONEY_LEVEL) >= 5) { + if (state.hasProperty(LEVEL_HONEY) && state.getValue(LEVEL_HONEY) >= 5) { if (!simulate) - world.setBlockState(outputPos, state.with(HONEY_LEVEL, 0), 3); + world.setBlock(outputPos, state.setValue(LEVEL_HONEY, 0), 3); return new FluidStack(AllFluids.HONEY.get() - .getStillFluid(), 250); + .getSource(), 250); } if (!waterlog && !state.getMaterial() @@ -90,7 +92,7 @@ public class OpenEndedPipe extends FlowSource { if (fluidState.isEmpty() || !fluidState.isSource()) return empty; - FluidStack stack = new FluidStack(fluidState.getFluid(), 1000); + FluidStack stack = new FluidStack(fluidState.getType(), 1000); if (simulate) return stack; @@ -98,13 +100,13 @@ public class OpenEndedPipe extends FlowSource { AllTriggers.triggerForNearbyPlayers(AllTriggers.PIPE_SPILL, world, pos, 5); if (waterlog) { - world.setBlockState(outputPos, state.with(WATERLOGGED, false), 3); - world.getPendingFluidTicks() + world.setBlock(outputPos, state.setValue(WATERLOGGED, false), 3); + world.getLiquidTicks() .scheduleTick(outputPos, Fluids.WATER, 1); return stack; } - world.setBlockState(outputPos, fluidState.getBlockState() - .with(FlowingFluidBlock.LEVEL, 14), 3); + world.setBlock(outputPos, fluidState.createLegacyBlock() + .setValue(FlowingFluidBlock.LEVEL, 14), 3); return stack; } @@ -116,7 +118,7 @@ public class OpenEndedPipe extends FlowSource { BlockState state = world.getBlockState(outputPos); FluidState fluidState = state.getFluidState(); - boolean waterlog = state.contains(WATERLOGGED); + boolean waterlog = state.hasProperty(WATERLOGGED); if (!waterlog && !state.getMaterial() .isReplaceable()) @@ -129,7 +131,7 @@ public class OpenEndedPipe extends FlowSource { return true; } - if (!fluidState.isEmpty() && fluidState.getFluid() != fluid.getFluid()) { + if (!fluidState.isEmpty() && fluidState.getType() != fluid.getFluid()) { FluidReactions.handlePipeSpillCollision(world, outputPos, fluid.getFluid(), fluidState); return false; } @@ -141,35 +143,35 @@ public class OpenEndedPipe extends FlowSource { if (simulate) return true; - if (world.getDimension() - .isUltrawarm() + if (world.dimensionType() + .ultraWarm() && fluid.getFluid() - .isIn(FluidTags.WATER)) { + .is(FluidTags.WATER)) { int i = outputPos.getX(); int j = outputPos.getY(); int k = outputPos.getZ(); - world.playSound(null, i, j, k, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, - 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, + 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); return true; } AllTriggers.triggerForNearbyPlayers(AllTriggers.PIPE_SPILL, world, pos, 5); if (waterlog) { - world.setBlockState(outputPos, state.with(WATERLOGGED, true), 3); - world.getPendingFluidTicks() + world.setBlock(outputPos, state.setValue(WATERLOGGED, true), 3); + world.getLiquidTicks() .scheduleTick(outputPos, Fluids.WATER, 1); return true; } - world.setBlockState(outputPos, fluid.getFluid() - .getDefaultState() - .getBlockState(), 3); + world.setBlock(outputPos, fluid.getFluid() + .defaultFluidState() + .createLegacyBlock(), 3); return true; } private boolean canApplyEffects(World world, FluidStack fluid) { Fluid fluidType = fluid.getFluid(); - if (fluidType.isEquivalentTo(AllFluids.POTION.get())) + if (fluidType.isSame(AllFluids.POTION.get())) return true; if (Tags.Fluids.MILK.contains(fluidType)) return true; @@ -179,14 +181,14 @@ public class OpenEndedPipe extends FlowSource { private void applyEffects(World world, FluidStack fluid) { Fluid fluidType = fluid.getFluid(); - if (fluidType.isEquivalentTo(AllFluids.POTION.get())) + if (fluidType.isSame(AllFluids.POTION.get())) applyPotionEffects(world, fluid); if (Tags.Fluids.MILK.contains(fluidType)) { if (world.getGameTime() % 5 != 0) return; List list = - world.getEntitiesWithinAABB(LivingEntity.class, aoe, LivingEntity::canBeHitWithPotion); + world.getEntitiesOfClass(LivingEntity.class, aoe, LivingEntity::isAffectedByPotions); ItemStack curativeItem = new ItemStack(Items.MILK_BUCKET); for (LivingEntity livingentity : list) livingentity.curePotionEffects(curativeItem); @@ -198,22 +200,22 @@ public class OpenEndedPipe extends FlowSource { FluidStack copy = fluid.copy(); copy.setAmount(250); ItemStack bottle = PotionFluidHandler.fillBottle(new ItemStack(Items.GLASS_BOTTLE), fluid); - cachedEffects = PotionUtils.getEffectsFromStack(bottle); + cachedEffects = PotionUtils.getMobEffects(bottle); } if (cachedEffects.isEmpty()) return; List list = - world.getEntitiesWithinAABB(LivingEntity.class, aoe, LivingEntity::canBeHitWithPotion); + world.getEntitiesOfClass(LivingEntity.class, aoe, LivingEntity::isAffectedByPotions); for (LivingEntity livingentity : list) { for (EffectInstance effectinstance : cachedEffects) { - Effect effect = effectinstance.getPotion(); - if (effect.isInstant()) { - effect.affectEntity(null, null, livingentity, effectinstance.getAmplifier(), 0.5D); + Effect effect = effectinstance.getEffect(); + if (effect.isInstantenous()) { + effect.applyInstantenousEffect(null, null, livingentity, effectinstance.getAmplifier(), 0.5D); continue; } - livingentity.addPotionEffect(new EffectInstance(effectinstance)); + livingentity.addEffect(new EffectInstance(effectinstance)); } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeAttachmentModel.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeAttachmentModel.java index cda095609..686d00915 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeAttachmentModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeAttachmentModel.java @@ -90,8 +90,8 @@ public class PipeAttachmentModel extends BakedModelWrapperWithData { public void putBracket(BlockState state) { this.bracket = Minecraft.getInstance() - .getBlockRendererDispatcher() - .getModelForState(state); + .getBlockRenderer() + .getBlockModel(state); } public IBakedModel getBracket() { @@ -99,7 +99,7 @@ public class PipeAttachmentModel extends BakedModelWrapperWithData { } public void putRim(Direction face, AttachmentTypes rim) { - rims[face.getIndex()] = rim; + rims[face.get3DDataValue()] = rim; } public void setEncased(boolean encased) { @@ -107,11 +107,11 @@ public class PipeAttachmentModel extends BakedModelWrapperWithData { } public boolean hasRim(Direction face) { - return rims[face.getIndex()] != AttachmentTypes.NONE; + return rims[face.get3DDataValue()] != AttachmentTypes.NONE; } public AttachmentTypes getRim(Direction face) { - return rims[face.getIndex()]; + return rims[face.get3DDataValue()]; } public boolean isEncased() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeConnection.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeConnection.java index 072abea8c..f766f18f4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeConnection.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeConnection.java @@ -178,7 +178,7 @@ public class PipeConnection { } FluidTransportBehaviour behaviour = - TileEntityBehaviour.get(world, pos.offset(side), FluidTransportBehaviour.TYPE); + TileEntityBehaviour.get(world, pos.relative(side), FluidTransportBehaviour.TYPE); source = Optional.of(behaviour == null ? new FlowSource.Blocked(location) : new FlowSource.OtherPipe(location)); return true; } @@ -190,7 +190,7 @@ public class PipeConnection { if (flow.fluid.isEmpty()) return; - if (world.isRemote) { + if (world.isClientSide) { if (!source.isPresent()) determineSource(world, pos); @@ -211,12 +211,12 @@ public class PipeConnection { public void serializeNBT(CompoundNBT tag, boolean clientPacket) { CompoundNBT connectionData = new CompoundNBT(); - tag.put(side.getName2(), connectionData); + tag.put(side.getName(), connectionData); if (hasPressure()) { ListNBT pressureData = new ListNBT(); - pressureData.add(FloatNBT.of(getInboundPressure())); - pressureData.add(FloatNBT.of(getOutwardPressure())); + pressureData.add(FloatNBT.valueOf(getInboundPressure())); + pressureData.add(FloatNBT.valueOf(getOutwardPressure())); connectionData.put("Pressure", pressureData); } @@ -240,7 +240,7 @@ public class PipeConnection { } public void deserializeNBT(CompoundNBT tag, BlockPos tilePos, boolean clientPacket) { - CompoundNBT connectionData = tag.getCompound(side.getName2()); + CompoundNBT connectionData = tag.getCompound(side.getName()); if (connectionData.contains("Pressure")) { ListNBT pressureData = connectionData.getList("Pressure", NBT.TAG_FLOAT); @@ -367,7 +367,7 @@ public class PipeConnection { @OnlyIn(Dist.CLIENT) private void spawnParticlesInner(World world, BlockPos pos, FluidStack fluid) { - if (world == Minecraft.getInstance().world) + if (world == Minecraft.getInstance().level) if (!isRenderEntityWithinDistance(pos)) return; if (hasOpenEnd()) @@ -378,7 +378,7 @@ public class PipeConnection { @OnlyIn(Dist.CLIENT) private void spawnSplashOnRimInner(World world, BlockPos pos, FluidStack fluid) { - if (world == Minecraft.getInstance().world) + if (world == Minecraft.getInstance().level) if (!isRenderEntityWithinDistance(pos)) return; spawnRimParticles(world, pos, fluid, SPLASH_PARTICLE_AMOUNT); @@ -398,7 +398,7 @@ public class PipeConnection { @OnlyIn(Dist.CLIENT) private void spawnPouringLiquid(World world, BlockPos pos, FluidStack fluid, int amount) { IParticleData particle = FluidFX.getFluidParticle(fluid); - Vector3d directionVec = Vector3d.of(side.getDirectionVec()); + Vector3d directionVec = Vector3d.atLowerCornerOf(side.getNormal()); if (!hasFlow()) return; Flow flow = this.flow.get(); @@ -408,11 +408,11 @@ public class PipeConnection { @OnlyIn(Dist.CLIENT) public static boolean isRenderEntityWithinDistance(BlockPos pos) { Entity renderViewEntity = Minecraft.getInstance() - .getRenderViewEntity(); + .getCameraEntity(); if (renderViewEntity == null) return false; Vector3d center = VecHelper.getCenterOf(pos); - if (renderViewEntity.getPositionVec() + if (renderViewEntity.position() .distanceTo(center) > MAX_PARTICLE_RENDER_DISTANCE) return false; return true; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpBlock.java index 6dd88516a..9c40cd741 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpBlock.java @@ -32,11 +32,13 @@ import net.minecraft.world.TickPriority; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable, ICogWheel { public PumpBlock(Properties p_i48415_1_) { super(p_i48415_1_); - setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false)); + registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false)); } @Override @@ -51,18 +53,18 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable @Override public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) { - return originalState.with(FACING, originalState.get(FACING) + return originalState.setValue(FACING, originalState.getValue(FACING) .getOpposite()); } @Override public BlockState updateAfterWrenched(BlockState newState, ItemUseContext context) { BlockState state = super.updateAfterWrenched(newState, context); - World world = context.getWorld(); - BlockPos pos = context.getPos(); - if (world.isRemote) + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); + if (world.isClientSide) return state; - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (!(tileEntity instanceof PumpTileEntity)) return state; PumpTileEntity pump = (PumpTileEntity) tileEntity; @@ -73,26 +75,26 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable @Override public Axis getRotationAxis(BlockState state) { - return state.get(FACING) + return state.getValue(FACING) .getAxis(); } @Override public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - return AllShapes.PUMP.get(state.get(FACING)); + return AllShapes.PUMP.get(state.getValue(FACING)); } @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.func_218806_a(world, pos); + DebugPacketSender.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; if (!isOpenAt(state, d)) return; - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); // if (world.isRemote) // return; @@ -114,32 +116,32 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable @Override public FluidState getFluidState(BlockState state) { - return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) - : Fluids.EMPTY.getDefaultState(); + return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) + : Fluids.EMPTY.defaultFluidState(); } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(BlockStateProperties.WATERLOGGED); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, BlockPos pos, BlockPos neighbourPos) { - if (state.get(BlockStateProperties.WATERLOGGED)) { - world.getPendingFluidTicks() - .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if (state.getValue(BlockStateProperties.WATERLOGGED)) { + world.getLiquidTicks() + .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } return state; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - FluidState FluidState = context.getWorld() - .getFluidState(context.getPos()); - return super.getStateForPlacement(context).with(BlockStateProperties.WATERLOGGED, - Boolean.valueOf(FluidState.getFluid() == Fluids.WATER)); + FluidState FluidState = context.getLevel() + .getFluidState(context.getClickedPos()); + return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, + Boolean.valueOf(FluidState.getType() == Fluids.WATER)); } public static boolean isPump(BlockState state) { @@ -147,35 +149,35 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { - if (world.isRemote) + public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + if (world.isClientSide) return; if (state != oldState) - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } public static boolean isOpenAt(BlockState state, Direction d) { - return d.getAxis() == state.get(FACING) + return d.getAxis() == state.getValue(FACING) .getAxis(); } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @Override - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); - if (blockTypeChanged && !world.isRemote) + if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity())) - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpCogInstance.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpCogInstance.java index 119c8b141..2cb223bb9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpCogInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpCogInstance.java @@ -21,7 +21,7 @@ public class PumpCogInstance extends SingleRotatingInstance { @Override protected Instancer getModel() { BlockState referenceState = tile.getBlockState(); - Direction facing = referenceState.get(FACING); + Direction facing = referenceState.getValue(FACING); return getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_PUMP_COG, referenceState, facing); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java index 8ecc077a4..8d9726dba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java @@ -34,9 +34,9 @@ public class PumpRenderer extends KineticTileEntityRenderer { BlockState blockState = te.getBlockState(); float angle = MathHelper.lerp(pump.arrowDirection.getValue(partialTicks), 0, 90) - 90; for (float yRot : new float[] { 0, 90 }) { - ms.push(); + ms.pushPose(); SuperByteBuffer arrow = PartialBufferer.get(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState); - Direction direction = blockState.get(PumpBlock.FACING); + Direction direction = blockState.getValue(PumpBlock.FACING); MatrixStacker.of(ms) .centre() .rotateY(AngleHelper.horizontalAngle(direction) + 180) @@ -46,8 +46,8 @@ public class PumpRenderer extends KineticTileEntityRenderer { .rotateY(yRot) .rotateZ(angle) .translateBack(rotationOffset); - arrow.light(light).renderInto(ms, buffer.getBuffer(RenderType.getSolid())); - ms.pop(); + arrow.light(light).renderInto(ms, buffer.getBuffer(RenderType.solid())); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpTileEntity.java index 3c05b3abf..a1143ffc5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpTileEntity.java @@ -35,6 +35,8 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; +import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes; + public class PumpTileEntity extends KineticTileEntity { LerpedFloat arrowDirection; @@ -65,7 +67,7 @@ public class PumpTileEntity extends KineticTileEntity { super.tick(); float speed = getSpeed(); - if (world.isRemote) { + if (level.isClientSide) { if (speed == 0) return; arrowDirection.chase(speed >= 0 ? 1 : -1, .5f, Chaser.EXP); @@ -97,13 +99,13 @@ public class PumpTileEntity extends KineticTileEntity { return; if (speed != 0) reversed = speed < 0; - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) return; - BlockPos frontPos = pos.offset(getFront()); - BlockPos backPos = pos.offset(getFront().getOpposite()); - FluidPropagator.propagateChangedPipe(world, frontPos, world.getBlockState(frontPos)); - FluidPropagator.propagateChangedPipe(world, backPos, world.getBlockState(backPos)); + BlockPos frontPos = worldPosition.relative(getFront()); + BlockPos backPos = worldPosition.relative(getFront().getOpposite()); + FluidPropagator.propagateChangedPipe(level, frontPos, level.getBlockState(frontPos)); + FluidPropagator.propagateChangedPipe(level, backPos, level.getBlockState(backPos)); FluidTransportBehaviour behaviour = getBehaviour(FluidTransportBehaviour.TYPE); if (behaviour != null) @@ -115,17 +117,17 @@ public class PumpTileEntity extends KineticTileEntity { if (getSpeed() == 0) return; - BlockFace start = new BlockFace(pos, side); + BlockFace start = new BlockFace(worldPosition, side); boolean pull = isPullingOnSide(isFront(side)); Set targets = new HashSet<>(); Map>> pipeGraph = new HashMap<>(); if (!pull) - FluidPropagator.resetAffectedFluidNetworks(world, pos, side.getOpposite()); + FluidPropagator.resetAffectedFluidNetworks(level, worldPosition, side.getOpposite()); - if (!hasReachedValidEndpoint(world, start, pull)) { + if (!hasReachedValidEndpoint(level, start, pull)) { - pipeGraph.computeIfAbsent(pos, $ -> Pair.of(0, new IdentityHashMap<>())) + pipeGraph.computeIfAbsent(worldPosition, $ -> Pair.of(0, new IdentityHashMap<>())) .getSecond() .put(side, pull); pipeGraph.computeIfAbsent(start.getConnectedPos(), $ -> Pair.of(1, new IdentityHashMap<>())) @@ -142,13 +144,13 @@ public class PumpTileEntity extends KineticTileEntity { int distance = entry.getFirst(); BlockPos currentPos = entry.getSecond(); - if (!world.isAreaLoaded(currentPos, 0)) + if (!level.isAreaLoaded(currentPos, 0)) continue; if (visited.contains(currentPos)) continue; visited.add(currentPos); - BlockState currentState = world.getBlockState(currentPos); - FluidTransportBehaviour pipe = FluidPropagator.getPipe(world, currentPos); + BlockState currentState = level.getBlockState(currentPos); + FluidTransportBehaviour pipe = FluidPropagator.getPipe(level, currentPos); if (pipe == null) continue; @@ -156,11 +158,11 @@ public class PumpTileEntity extends KineticTileEntity { BlockFace blockFace = new BlockFace(currentPos, face); BlockPos connectedPos = blockFace.getConnectedPos(); - if (!world.isAreaLoaded(connectedPos, 0)) + if (!level.isAreaLoaded(connectedPos, 0)) continue; if (blockFace.isEquivalent(start)) continue; - if (hasReachedValidEndpoint(world, blockFace, pull)) { + if (hasReachedValidEndpoint(level, blockFace, pull)) { pipeGraph.computeIfAbsent(currentPos, $ -> Pair.of(distance, new IdentityHashMap<>())) .getSecond() .put(face, pull); @@ -168,7 +170,7 @@ public class PumpTileEntity extends KineticTileEntity { continue; } - FluidTransportBehaviour pipeBehaviour = FluidPropagator.getPipe(world, connectedPos); + FluidTransportBehaviour pipeBehaviour = FluidPropagator.getPipe(level, connectedPos); if (pipeBehaviour == null) continue; if (pipeBehaviour instanceof PumpFluidTransferBehaviour) @@ -206,13 +208,13 @@ public class PumpTileEntity extends KineticTileEntity { BlockPos pipePos = face.getPos(); Direction pipeSide = face.getFace(); - if (pipePos.equals(pos)) + if (pipePos.equals(worldPosition)) continue; boolean inbound = pipeGraph.get(pipePos) .getSecond() .get(pipeSide); - FluidTransportBehaviour pipeBehaviour = FluidPropagator.getPipe(world, pipePos); + FluidTransportBehaviour pipeBehaviour = FluidPropagator.getPipe(level, pipePos); if (pipeBehaviour == null) continue; @@ -249,7 +251,7 @@ public class PumpTileEntity extends KineticTileEntity { if (map.get(nextFacing) != pull) continue; if (!searchForEndpointRecursively(pipeGraph, targets, validFaces, - new BlockFace(currentPos.offset(nextFacing), nextFacing.getOpposite()), pull)) + new BlockFace(currentPos.relative(nextFacing), nextFacing.getOpposite()), pull)) continue; validFaces.computeIfAbsent(distance, $ -> new HashSet<>()) @@ -267,11 +269,11 @@ public class PumpTileEntity extends KineticTileEntity { private boolean hasReachedValidEndpoint(IWorld world, BlockFace blockFace, boolean pull) { BlockPos connectedPos = blockFace.getConnectedPos(); BlockState connectedState = world.getBlockState(connectedPos); - TileEntity tileEntity = world.getTileEntity(connectedPos); + TileEntity tileEntity = world.getBlockEntity(connectedPos); Direction face = blockFace.getFace(); // facing a pump - if (PumpBlock.isPump(connectedState) && connectedState.get(PumpBlock.FACING) + if (PumpBlock.isPump(connectedState) && connectedState.getValue(PumpBlock.FACING) .getAxis() == face.getAxis() && tileEntity instanceof PumpTileEntity) { PumpTileEntity pumpTE = (PumpTileEntity) tileEntity; return pumpTE.isPullingOnSide(pumpTE.isFront(blockFace.getOppositeFace())) != pull; @@ -317,7 +319,7 @@ public class PumpTileEntity extends KineticTileEntity { BlockState blockState = getBlockState(); if (!(blockState.getBlock() instanceof PumpBlock)) return false; - Direction front = blockState.get(PumpBlock.FACING); + Direction front = blockState.getValue(PumpBlock.FACING); boolean isFront = side == front; return isFront; } @@ -327,7 +329,7 @@ public class PumpTileEntity extends KineticTileEntity { BlockState blockState = getBlockState(); if (!(blockState.getBlock() instanceof PumpBlock)) return null; - return blockState.get(PumpBlock.FACING); + return blockState.getValue(PumpBlock.FACING); } protected void updatePipeNetwork(boolean front) { @@ -339,7 +341,7 @@ public class PumpTileEntity extends KineticTileEntity { BlockState blockState = getBlockState(); if (!(blockState.getBlock() instanceof PumpBlock)) return false; - return blockState.get(PumpBlock.FACING) + return blockState.getValue(PumpBlock.FACING) .getAxis() == side.getAxis(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/VirtualFluid.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/VirtualFluid.java index 9ab196582..6affc6d7b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/VirtualFluid.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/VirtualFluid.java @@ -8,6 +8,8 @@ import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraftforge.fluids.ForgeFlowingFluid; +import net.minecraftforge.fluids.ForgeFlowingFluid.Properties; + public class VirtualFluid extends ForgeFlowingFluid { public VirtualFluid(Properties properties) { @@ -15,23 +17,23 @@ public class VirtualFluid extends ForgeFlowingFluid { } @Override - public Fluid getStillFluid() { - return super.getStillFluid(); + public Fluid getSource() { + return super.getSource(); } @Override - public Fluid getFlowingFluid() { + public Fluid getFlowing() { return this; } @Override - public Item getFilledBucket() { + public Item getBucket() { return Items.AIR; } @Override - protected BlockState getBlockState(FluidState state) { - return Blocks.AIR.getDefaultState(); + protected BlockState createLegacyBlock(FluidState state) { + return Blocks.AIR.defaultBlockState(); } @Override @@ -40,7 +42,7 @@ public class VirtualFluid extends ForgeFlowingFluid { } @Override - public int getLevel(FluidState p_207192_1_) { + public int getAmount(FluidState p_207192_1_) { return 0; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FillingBySpout.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FillingBySpout.java index a3036d007..314a02e88 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FillingBySpout.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FillingBySpout.java @@ -19,7 +19,7 @@ public class FillingBySpout { static RecipeWrapper wrapper = new RecipeWrapper(new ItemStackHandler(1)); public static boolean canItemBeFilled(World world, ItemStack stack) { - wrapper.setInventorySlotContents(0, stack); + wrapper.setItem(0, stack); Optional assemblyRecipe = SequencedAssemblyRecipe.getRecipe(world, wrapper, AllRecipeTypes.FILLING.getType(), FillingRecipe.class); @@ -33,7 +33,7 @@ public class FillingBySpout { } public static int getRequiredAmountForItem(World world, ItemStack stack, FluidStack availableFluid) { - wrapper.setInventorySlotContents(0, stack); + wrapper.setItem(0, stack); Optional assemblyRecipe = SequencedAssemblyRecipe.getRecipe(world, wrapper, AllRecipeTypes.FILLING.getType(), FillingRecipe.class); @@ -45,7 +45,7 @@ public class FillingBySpout { } for (IRecipe recipe : world.getRecipeManager() - .getRecipes(AllRecipeTypes.FILLING.getType(), wrapper, world)) { + .getRecipesFor(AllRecipeTypes.FILLING.getType(), wrapper, world)) { FillingRecipe fillingRecipe = (FillingRecipe) recipe; FluidIngredient requiredFluid = fillingRecipe.getRequiredFluid(); if (requiredFluid.test(availableFluid)) @@ -58,7 +58,7 @@ public class FillingBySpout { FluidStack toFill = availableFluid.copy(); toFill.setAmount(requiredAmount); - wrapper.setInventorySlotContents(0, stack); + wrapper.setItem(0, stack); FillingRecipe fillingRecipe = SequencedAssemblyRecipe.getRecipe(world, wrapper, AllRecipeTypes.FILLING.getType(), FillingRecipe.class) @@ -66,7 +66,7 @@ public class FillingBySpout { .test(toFill)) .orElseGet(() -> { for (IRecipe recipe : world.getRecipeManager() - .getRecipes(AllRecipeTypes.FILLING.getType(), wrapper, world)) { + .getRecipesFor(AllRecipeTypes.FILLING.getType(), wrapper, world)) { FillingRecipe fr = (FillingRecipe) recipe; FluidIngredient requiredFluid = fr.getRequiredFluid(); if (requiredFluid.test(toFill)) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FillingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FillingRecipe.java index 56dd45e26..21e3d3499 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FillingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FillingRecipe.java @@ -33,7 +33,7 @@ public class FillingRecipe extends ProcessingRecipe implements IA @Override public boolean matches(RecipeWrapper inv, World p_77569_2_) { return ingredients.get(0) - .test(inv.getStackInSlot(0)); + .test(inv.getItem(0)); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidDrainingBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidDrainingBehaviour.java index b1bbcb128..3ebbd9e83 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidDrainingBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidDrainingBehaviour.java @@ -28,6 +28,8 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; +import com.simibubi.create.content.contraptions.fluids.actors.FluidManipulationBehaviour.BlockPosEntry; + public class FluidDrainingBehaviour extends FluidManipulationBehaviour { Fluid fluid; @@ -86,18 +88,18 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { BlockState emptied = blockState; Fluid fluid = Fluids.EMPTY; - if (blockState.contains(BlockStateProperties.WATERLOGGED) && blockState.get(BlockStateProperties.WATERLOGGED)) { - emptied = blockState.with(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false)); + if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)) { + emptied = blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false)); fluid = Fluids.WATER; } else if (blockState.getBlock() instanceof FlowingFluidBlock) { FlowingFluidBlock flowingFluid = (FlowingFluidBlock) blockState.getBlock(); - emptied = Blocks.AIR.getDefaultState(); - if (blockState.get(FlowingFluidBlock.LEVEL) == 0) + emptied = Blocks.AIR.defaultBlockState(); + if (blockState.getValue(FlowingFluidBlock.LEVEL) == 0) fluid = flowingFluid.getFluid(); else { - affectedArea.expandTo(new MutableBoundingBox(currentPos, currentPos)); + affectedArea.expand(new MutableBoundingBox(currentPos, currentPos)); if (!tileEntity.isVirtual()) - world.setBlockState(currentPos, emptied, 2 | 16); + world.setBlock(currentPos, emptied, 2 | 16); queue.dequeue(); if (queue.isEmpty()) { isValid = checkValid(world, rootPos); @@ -106,18 +108,18 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { continue; } } else if (blockState.getFluidState() - .getFluid() != Fluids.EMPTY - && blockState.getCollisionShape(world, currentPos, ISelectionContext.dummy()) + .getType() != Fluids.EMPTY + && blockState.getCollisionShape(world, currentPos, ISelectionContext.empty()) .isEmpty()) { fluid = blockState.getFluidState() - .getFluid(); - emptied = Blocks.AIR.getDefaultState(); + .getType(); + emptied = Blocks.AIR.defaultBlockState(); } if (this.fluid == null) this.fluid = fluid; - if (!this.fluid.isEquivalentTo(fluid)) { + if (!this.fluid.isSame(fluid)) { queue.dequeue(); if (queue.isEmpty()) { isValid = checkValid(world, rootPos); @@ -130,16 +132,16 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { return true; playEffect(world, currentPos, fluid, true); - AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getPos(), 8); + AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getBlockPos(), 8); if (infinite) { - AllTriggers.triggerForNearbyPlayers(AllTriggers.INFINITE_FLUID.constructTriggerFor(FluidHelper.convertToStill(fluid)), world, tileEntity.getPos(), 8); + AllTriggers.triggerForNearbyPlayers(AllTriggers.INFINITE_FLUID.constructTriggerFor(FluidHelper.convertToStill(fluid)), world, tileEntity.getBlockPos(), 8); return true; } if (!tileEntity.isVirtual()) - world.setBlockState(currentPos, emptied, 2 | 16); - affectedArea.expandTo(new MutableBoundingBox(currentPos, currentPos)); + world.setBlock(currentPos, emptied, 2 | 16); + affectedArea.expand(new MutableBoundingBox(currentPos, currentPos)); queue.dequeue(); if (queue.isEmpty()) { @@ -175,10 +177,10 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { protected boolean checkValid(World world, BlockPos root) { BlockPos currentPos = root; - for (int timeout = 1000; timeout > 0 && !root.equals(tileEntity.getPos()); timeout--) { + for (int timeout = 1000; timeout > 0 && !root.equals(tileEntity.getBlockPos()); timeout--) { FluidBlockType canPullFluidsFrom = canPullFluidsFrom(world.getBlockState(currentPos), currentPos); if (canPullFluidsFrom == FluidBlockType.FLOWING) { - currentPos = currentPos.up(); + currentPos = currentPos.above(); continue; } if (canPullFluidsFrom == FluidBlockType.SOURCE) @@ -200,12 +202,12 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { } protected FluidBlockType canPullFluidsFrom(BlockState blockState, BlockPos pos) { - if (blockState.contains(BlockStateProperties.WATERLOGGED) && blockState.get(BlockStateProperties.WATERLOGGED)) + if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)) return FluidBlockType.SOURCE; if (blockState.getBlock() instanceof FlowingFluidBlock) - return blockState.get(FlowingFluidBlock.LEVEL) == 0 ? FluidBlockType.SOURCE : FluidBlockType.FLOWING; + return blockState.getValue(FlowingFluidBlock.LEVEL) == 0 ? FluidBlockType.SOURCE : FluidBlockType.FLOWING; if (blockState.getFluidState() - .getFluid() != Fluids.EMPTY && blockState.getCollisionShape(getWorld(), pos, ISelectionContext.dummy()) + .getType() != Fluids.EMPTY && blockState.getCollisionShape(getWorld(), pos, ISelectionContext.empty()) .isEmpty()) return FluidBlockType.SOURCE; return FluidBlockType.NONE; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java index 0fbd08807..0ad365d4c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java @@ -39,6 +39,8 @@ import net.minecraft.world.NextTickListEntry; import net.minecraft.world.World; import net.minecraft.world.server.ServerTickList; +import com.simibubi.create.content.contraptions.fluids.actors.FluidManipulationBehaviour.BlockPosEntry; + public class FluidFillingBehaviour extends FluidManipulationBehaviour { PriorityQueue queue; @@ -59,7 +61,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { super.tick(); if (!infinityCheckFrontier.isEmpty() && rootPos != null) { Fluid fluid = getWorld().getFluidState(rootPos) - .getFluid(); + .getType(); if (fluid != Fluids.EMPTY) continueValidation(fluid); } @@ -124,13 +126,13 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { int maxRange = maxRange(); int maxRangeSq = maxRange * maxRange; int maxBlocks = maxBlocks(); - boolean evaporate = world.getDimension() - .isUltrawarm() && fluid.isIn(FluidTags.WATER); + boolean evaporate = world.dimensionType() + .ultraWarm() && fluid.is(FluidTags.WATER); if (infinite || evaporate) { FluidState fluidState = world.getFluidState(rootPos); - boolean equivalentTo = fluidState.getFluid() - .isEquivalentTo(fluid); + boolean equivalentTo = fluidState.getType() + .isSame(fluid); if (!equivalentTo && !evaporate) return false; if (simulate) @@ -140,8 +142,8 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { int i = root.getX(); int j = root.getY(); int k = root.getZ(); - world.playSound(null, i, j, k, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, - 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, + 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); } return true; } @@ -175,36 +177,36 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { playEffect(world, currentPos, fluid, false); BlockState blockState = world.getBlockState(currentPos); - if (blockState.contains(BlockStateProperties.WATERLOGGED) && fluid.isEquivalentTo(Fluids.WATER)) { + if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && fluid.isSame(Fluids.WATER)) { if (!tileEntity.isVirtual()) - world.setBlockState(currentPos, - updatePostWaterlogging(blockState.with(BlockStateProperties.WATERLOGGED, true)), + world.setBlock(currentPos, + updatePostWaterlogging(blockState.setValue(BlockStateProperties.WATERLOGGED, true)), 2 | 16); } else { replaceBlock(world, currentPos, blockState); if (!tileEntity.isVirtual()) - world.setBlockState(currentPos, FluidHelper.convertToStill(fluid) - .getDefaultState() - .getBlockState(), 2 | 16); + world.setBlock(currentPos, FluidHelper.convertToStill(fluid) + .defaultFluidState() + .createLegacyBlock(), 2 | 16); } - ITickList pendingFluidTicks = world.getPendingFluidTicks(); + ITickList pendingFluidTicks = world.getLiquidTicks(); if (pendingFluidTicks instanceof ServerTickList) { ServerTickList serverTickList = (ServerTickList) pendingFluidTicks; NextTickListEntry removedEntry = null; - for (NextTickListEntry nextTickListEntry : serverTickList.pendingTickListEntriesHashSet) { - if (nextTickListEntry.position.equals(currentPos)) { + for (NextTickListEntry nextTickListEntry : serverTickList.tickNextTickSet) { + if (nextTickListEntry.pos.equals(currentPos)) { removedEntry = nextTickListEntry; break; } } if (removedEntry != null) { - serverTickList.pendingTickListEntriesHashSet.remove(removedEntry); - serverTickList.pendingTickListEntriesTreeSet.remove(removedEntry); + serverTickList.tickNextTickSet.remove(removedEntry); + serverTickList.tickNextTickList.remove(removedEntry); } } - affectedArea.expandTo(new MutableBoundingBox(currentPos, currentPos)); + affectedArea.expand(new MutableBoundingBox(currentPos, currentPos)); } } @@ -218,10 +220,10 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { if (side == Direction.UP) continue; - BlockPos offsetPos = currentPos.offset(side); + BlockPos offsetPos = currentPos.relative(side); if (visited.contains(offsetPos)) continue; - if (offsetPos.distanceSq(rootPos) > maxRangeSq) + if (offsetPos.distSqr(rootPos) > maxRangeSq) continue; SpaceType nextSpaceType = getAtPos(world, offsetPos, fluid); @@ -231,7 +233,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { } if (!simulate && success) - AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getPos(), 8); + AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getBlockPos(), 8); return success; } @@ -252,39 +254,39 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { BlockState blockState = world.getBlockState(pos); FluidState fluidState = blockState.getFluidState(); - if (blockState.contains(BlockStateProperties.WATERLOGGED)) - return toFill.isEquivalentTo(Fluids.WATER) - ? blockState.get(BlockStateProperties.WATERLOGGED) ? SpaceType.FILLED : SpaceType.FILLABLE + if (blockState.hasProperty(BlockStateProperties.WATERLOGGED)) + return toFill.isSame(Fluids.WATER) + ? blockState.getValue(BlockStateProperties.WATERLOGGED) ? SpaceType.FILLED : SpaceType.FILLABLE : SpaceType.BLOCKING; if (blockState.getBlock() instanceof FlowingFluidBlock) - return blockState.get(FlowingFluidBlock.LEVEL) == 0 - ? toFill.isEquivalentTo(fluidState.getFluid()) ? SpaceType.FILLED : SpaceType.BLOCKING + return blockState.getValue(FlowingFluidBlock.LEVEL) == 0 + ? toFill.isSame(fluidState.getType()) ? SpaceType.FILLED : SpaceType.BLOCKING : SpaceType.FILLABLE; - if (fluidState.getFluid() != Fluids.EMPTY - && blockState.getCollisionShape(getWorld(), pos, ISelectionContext.dummy()) + if (fluidState.getType() != Fluids.EMPTY + && blockState.getCollisionShape(getWorld(), pos, ISelectionContext.empty()) .isEmpty()) - return toFill.isEquivalentTo(fluidState.getFluid()) ? SpaceType.FILLED : SpaceType.BLOCKING; + return toFill.isSame(fluidState.getType()) ? SpaceType.FILLED : SpaceType.BLOCKING; return canBeReplacedByFluid(world, pos, blockState) ? SpaceType.FILLABLE : SpaceType.BLOCKING; } protected void replaceBlock(World world, BlockPos pos, BlockState state) { TileEntity tileentity = state.getBlock() - .hasTileEntity(state) ? world.getTileEntity(pos) : null; - Block.spawnDrops(state, world, pos, tileentity); + .hasTileEntity(state) ? world.getBlockEntity(pos) : null; + Block.dropResources(state, world, pos, tileentity); } // From FlowingFluidBlock#isBlocked protected boolean canBeReplacedByFluid(IBlockReader world, BlockPos pos, BlockState state) { Block block = state.getBlock(); - if (!(block instanceof DoorBlock) && !block.isIn(BlockTags.SIGNS) && block != Blocks.LADDER + if (!(block instanceof DoorBlock) && !block.is(BlockTags.SIGNS) && block != Blocks.LADDER && block != Blocks.SUGAR_CANE && block != Blocks.BUBBLE_COLUMN) { Material material = state.getMaterial(); - if (material != Material.PORTAL && material != Material.STRUCTURE_VOID && material != Material.OCEAN_PLANT - && material != Material.SEA_GRASS) { - return !material.blocksMovement(); + if (material != Material.PORTAL && material != Material.STRUCTURAL_AIR && material != Material.WATER_PLANT + && material != Material.REPLACEABLE_WATER_PLANT) { + return !material.blocksMotion(); } else { return false; } @@ -294,8 +296,8 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { } protected BlockState updatePostWaterlogging(BlockState state) { - if (state.contains(BlockStateProperties.LIT)) - state = state.with(BlockStateProperties.LIT, false); + if (state.hasProperty(BlockStateProperties.LIT)) + state = state.setValue(BlockStateProperties.LIT, false); return state; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java index a3c70ed09..d3ecf1394 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidManipulationBehaviour.java @@ -108,13 +108,13 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { protected void scheduleUpdatesInAffectedArea() { World world = getWorld(); - BlockPos.getAllInBox(new BlockPos(affectedArea.minX - 1, affectedArea.minY - 1, affectedArea.minZ - 1), new BlockPos(affectedArea.maxX + 1, affectedArea.maxY + 1, affectedArea.maxZ + 1)) + BlockPos.betweenClosedStream(new BlockPos(affectedArea.x0 - 1, affectedArea.y0 - 1, affectedArea.z0 - 1), new BlockPos(affectedArea.x1 + 1, affectedArea.y1 + 1, affectedArea.z1 + 1)) .forEach(pos -> { FluidState nextFluidState = world.getFluidState(pos); if (nextFluidState.isEmpty()) return; - world.getPendingFluidTicks() - .scheduleTick(pos, nextFluidState.getFluid(), world.getRandom() + world.getLiquidTicks() + .scheduleTick(pos, nextFluidState.getType(), world.getRandom() .nextInt(5)); }); } @@ -129,9 +129,9 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { if (compareDistance != 0) return compareDistance; return Double.compare(VecHelper.getCenterOf(pos2) - .squareDistanceTo(centerOfRoot), + .distanceToSqr(centerOfRoot), VecHelper.getCenterOf(pos1) - .squareDistanceTo(centerOfRoot)); + .distanceToSqr(centerOfRoot)); } protected Fluid search(Fluid fluid, List frontier, Set visited, @@ -154,10 +154,10 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { if (fluidState.isEmpty()) continue; - Fluid currentFluid = FluidHelper.convertToStill(fluidState.getFluid()); + Fluid currentFluid = FluidHelper.convertToStill(fluidState.getType()); if (fluid == null) fluid = currentFluid; - if (!currentFluid.isEquivalentTo(fluid)) + if (!currentFluid.isSame(fluid)) continue; add.accept(currentPos, entry.distance); @@ -166,16 +166,16 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { if (!searchDownward && side == Direction.DOWN) continue; - BlockPos offsetPos = currentPos.offset(side); + BlockPos offsetPos = currentPos.relative(side); if (visited.contains(offsetPos)) continue; - if (offsetPos.distanceSq(rootPos) > maxRangeSq) + if (offsetPos.distSqr(rootPos) > maxRangeSq) continue; FluidState nextFluidState = world.getFluidState(offsetPos); if (nextFluidState.isEmpty()) continue; - Fluid nextFluid = nextFluidState.getFluid(); + Fluid nextFluid = nextFluidState.getType(); if (nextFluid == FluidHelper.convertToFlowing(nextFluid) && side == Direction.UP && !VecHelper.onSameAxis(rootPos, offsetPos, Axis.Y)) continue; @@ -188,16 +188,16 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { } protected void playEffect(World world, BlockPos pos, Fluid fluid, boolean fillSound) { - BlockPos splooshPos = pos == null ? tileEntity.getPos() : pos; + BlockPos splooshPos = pos == null ? tileEntity.getBlockPos() : pos; SoundEvent soundevent = fillSound ? fluid.getAttributes() .getFillSound() : fluid.getAttributes() .getEmptySound(); if (soundevent == null) - soundevent = fluid.isIn(FluidTags.LAVA) - ? fillSound ? SoundEvents.ITEM_BUCKET_FILL_LAVA : SoundEvents.ITEM_BUCKET_EMPTY_LAVA - : fillSound ? SoundEvents.ITEM_BUCKET_FILL : SoundEvents.ITEM_BUCKET_EMPTY; + soundevent = fluid.is(FluidTags.LAVA) + ? fillSound ? SoundEvents.BUCKET_FILL_LAVA : SoundEvents.BUCKET_EMPTY_LAVA + : fillSound ? SoundEvents.BUCKET_FILL : SoundEvents.BUCKET_EMPTY; world.playSound(null, splooshPos, soundevent, SoundCategory.BLOCKS, 0.3F, 1.0F); if (world instanceof ServerWorld) @@ -214,9 +214,9 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { nbt.put("LastPos", NBTUtil.writeBlockPos(rootPos)); if (affectedArea != null) { nbt.put("AffectedAreaFrom", - NBTUtil.writeBlockPos(new BlockPos(affectedArea.minX, affectedArea.minY, affectedArea.minZ))); + NBTUtil.writeBlockPos(new BlockPos(affectedArea.x0, affectedArea.y0, affectedArea.z0))); nbt.put("AffectedAreaTo", - NBTUtil.writeBlockPos(new BlockPos(affectedArea.maxX, affectedArea.maxY, affectedArea.maxZ))); + NBTUtil.writeBlockPos(new BlockPos(affectedArea.x1, affectedArea.y1, affectedArea.z1))); } super.write(nbt, clientPacket); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidSplashPacket.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidSplashPacket.java index 0b523ffcc..8704f92a7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidSplashPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidSplashPacket.java @@ -37,7 +37,7 @@ public class FluidSplashPacket extends SimplePacketBase { public void handle(Supplier ctx) { ctx.get() .enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { - if (Minecraft.getInstance().player.getPositionVec() + if (Minecraft.getInstance().player.position() .distanceTo(new Vector3d(pos.getX(), pos.getY(), pos.getZ())) > 100) return; FluidFX.splash(pos, fluid); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java index 271378b4d..b4a1bc614 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java @@ -83,7 +83,7 @@ public class GenericItemFilling { return -1; if (tank instanceof FluidBucketWrapper) { Item filledBucket = availableFluid.getFluid() - .getFilledBucket(); + .getBucket(); if (filledBucket == null || filledBucket == Items.AIR) return -1; if (!((FluidBucketWrapper) tank).getFluid() @@ -98,14 +98,14 @@ public class GenericItemFilling { private static boolean canFillGlassBottleInternally(FluidStack availableFluid) { return availableFluid.getFluid() - .isEquivalentTo(Fluids.WATER) + .isSame(Fluids.WATER) || availableFluid.getFluid() - .isEquivalentTo(AllFluids.POTION.get()); + .isSame(AllFluids.POTION.get()); } private static boolean canFillBucketInternally(FluidStack availableFluid) { return availableFluid.getFluid() - .isEquivalentTo(AllFluids.MILK.get().getFlowingFluid()); + .isSame(AllFluids.MILK.get().getFlowing()); } public static ItemStack fillItem(World world, int requiredAmount, ItemStack stack, FluidStack availableFluid) { @@ -116,7 +116,7 @@ public class GenericItemFilling { if (stack.getItem() == Items.GLASS_BOTTLE && canFillGlassBottleInternally(toFill)) { ItemStack fillBottle = ItemStack.EMPTY; if (FluidHelper.isWater(toFill.getFluid())) - fillBottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER); + fillBottle = PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER); else fillBottle = PotionFluidHandler.fillBottle(stack, toFill); stack.shrink(1); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyBlock.java index 7ec814a63..19635c8d8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyBlock.java @@ -20,6 +20,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class HosePulleyBlock extends HorizontalKineticBlock implements ITE { public HosePulleyBlock(Properties properties) { @@ -28,30 +30,30 @@ public class HosePulleyBlock extends HorizontalKineticBlock implements ITE pos.down((int) Math.ceil(offset.getValue())), () -> !this.isMoving); + () -> worldPosition.below((int) Math.ceil(offset.getValue())), () -> !this.isMoving); capability = LazyOptional.of(() -> handler); } @@ -83,7 +83,7 @@ public class HosePulleyTileEntity extends KineticTileEntity { float newOffset = offset.getValue() + getMovementSpeed(); if (newOffset < 0) isMoving = false; - if (!world.getBlockState(pos.down((int) Math.ceil(newOffset))) + if (!level.getBlockState(worldPosition.below((int) Math.ceil(newOffset))) .getMaterial() .isReplaceable()) { isMoving = false; @@ -100,13 +100,13 @@ public class HosePulleyTileEntity extends KineticTileEntity { @Override @OnlyIn(Dist.CLIENT) public AxisAlignedBB getRenderBoundingBox() { - return super.getRenderBoundingBox().expand(0, -offset.getValue(), 0); + return super.getRenderBoundingBox().expandTowards(0, -offset.getValue(), 0); } @Override @OnlyIn(Dist.CLIENT) - public double getMaxRenderDistanceSquared() { - return super.getMaxRenderDistanceSquared() + offset.getValue() * offset.getValue(); + public double getViewDistance() { + return super.getViewDistance() + offset.getValue() * offset.getValue(); } @Override @@ -117,7 +117,7 @@ public class HosePulleyTileEntity extends KineticTileEntity { newOffset = 0; isMoving = false; } - if (!world.getBlockState(pos.down((int) Math.ceil(newOffset))) + if (!level.getBlockState(worldPosition.below((int) Math.ceil(newOffset))) .getMaterial() .isReplaceable()) { newOffset = (int) newOffset; @@ -132,13 +132,13 @@ public class HosePulleyTileEntity extends KineticTileEntity { @Override public void lazyTick() { super.lazyTick(); - if (world.isRemote) + if (level.isClientSide) return; if (isMoving) return; int ceil = (int) Math.ceil(offset.getValue() + getMovementSpeed()); - if (getMovementSpeed() > 0 && world.getBlockState(pos.down(ceil)) + if (getMovementSpeed() > 0 && level.getBlockState(worldPosition.below(ceil)) .getMaterial() .isReplaceable()) { isMoving = true; @@ -169,14 +169,14 @@ public class HosePulleyTileEntity extends KineticTileEntity { } @Override - public void remove() { - super.remove(); + public void setRemoved() { + super.setRemoved(); capability.invalidate(); } public float getMovementSpeed() { float movementSpeed = convertToLinear(getSpeed()); - if (world.isRemote) + if (level.isClientSide) movementSpeed *= ServerSpeedProvider.get(); return movementSpeed; } @@ -188,7 +188,7 @@ public class HosePulleyTileEntity extends KineticTileEntity { @Override public LazyOptional getCapability(Capability cap, Direction side) { if (isFluidHandlerCap(cap) - && (side == null || HosePulleyBlock.hasPipeTowards(world, pos, getBlockState(), side))) + && (side == null || HosePulleyBlock.hasPipeTowards(level, worldPosition, getBlockState(), side))) return this.capability.cast(); return super.getCapability(cap, side); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainBlock.java index 5b9e93781..0a7a13fdd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainBlock.java @@ -25,6 +25,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class ItemDrainBlock extends Block implements IWrenchable, ITE { public ItemDrainBlock(Properties p_i48440_1_) { @@ -32,21 +34,21 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE { if (!heldItem.isEmpty()) { te.internalTank.allowInsertion(); ActionResultType tryExchange = tryExchange(worldIn, player, handIn, heldItem, te); te.internalTank.forbidInsertion(); - if (tryExchange.isAccepted()) + if (tryExchange.consumesAction()) return tryExchange; } ItemStack heldItemStack = te.getHeldItemStack(); - if (!worldIn.isRemote && !heldItemStack.isEmpty()) { + if (!worldIn.isClientSide && !heldItemStack.isEmpty()) { player.inventory.placeItemBackInInventory(worldIn, heldItemStack); te.heldItem = null; te.notifyUpdate(); @@ -71,15 +73,15 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE { ItemStack heldItemStack = te.getHeldItemStack(); if (!heldItemStack.isEmpty()) - InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), heldItemStack); + InventoryHelper.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), heldItemStack); }); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } @Override @@ -98,17 +100,17 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE 1 && EmptyingByBasin.canItemBeEmptied(te.getWorld(), stack)) { + if (stack.getCount() > 1 && EmptyingByBasin.canItemBeEmptied(te.getLevel(), stack)) { returned = ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1); stack = ItemHandlerHelper.copyStackWithSize(stack, 1); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainRenderer.java index 8b7ac12f4..597289981 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainRenderer.java @@ -49,24 +49,24 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer 1 && EmptyingByBasin.canItemBeEmptied(world, inserted)) { + if (inserted.getCount() > 1 && EmptyingByBasin.canItemBeEmptied(level, inserted)) { returned = ItemHandlerHelper.copyStackWithSize(inserted, inserted.getCount() - 1); inserted = ItemHandlerHelper.copyStackWithSize(inserted, 1); } @@ -81,7 +81,7 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI transportedStack.prevSideOffset = transportedStack.sideOffset; transportedStack.prevBeltPosition = transportedStack.beltPosition; setHeldItem(transportedStack, side); - markDirty(); + setChanged(); sendData(); return returned; @@ -100,7 +100,7 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI return; } - boolean onClient = world.isRemote && !isVirtual(); + boolean onClient = level.isClientSide && !isVirtual(); if (processingTicks > 0) { heldItem.prevBeltPosition = .5f; @@ -144,26 +144,26 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI return; } - BlockPos nextPosition = pos.offset(side); + BlockPos nextPosition = worldPosition.relative(side); DirectBeltInputBehaviour directBeltInputBehaviour = - TileEntityBehaviour.get(world, nextPosition, DirectBeltInputBehaviour.TYPE); + TileEntityBehaviour.get(level, nextPosition, DirectBeltInputBehaviour.TYPE); if (directBeltInputBehaviour == null) { - if (!BlockHelper.hasBlockSolidSide(world.getBlockState(nextPosition), world, nextPosition, + if (!BlockHelper.hasBlockSolidSide(level.getBlockState(nextPosition), level, nextPosition, side.getOpposite())) { ItemStack ejected = heldItem.stack; - Vector3d outPos = VecHelper.getCenterOf(pos) - .add(Vector3d.of(side.getDirectionVec()) + Vector3d outPos = VecHelper.getCenterOf(worldPosition) + .add(Vector3d.atLowerCornerOf(side.getNormal()) .scale(.75)); float movementSpeed = itemMovementPerTick(); - Vector3d outMotion = Vector3d.of(side.getDirectionVec()) + Vector3d outMotion = Vector3d.atLowerCornerOf(side.getNormal()) .scale(movementSpeed) .add(0, 1 / 8f, 0); outPos.add(outMotion.normalize()); - ItemEntity entity = new ItemEntity(world, outPos.x, outPos.y + 6 / 16f, outPos.z, ejected); - entity.setMotion(outMotion); - entity.setDefaultPickupDelay(); - entity.velocityChanged = true; - world.addEntity(entity); + ItemEntity entity = new ItemEntity(level, outPos.x, outPos.y + 6 / 16f, outPos.z, ejected); + entity.setDeltaMovement(outMotion); + entity.setDefaultPickUpDelay(); + entity.hurtMarked = true; + level.addFreshEntity(entity); heldItem = null; notifyUpdate(); @@ -177,8 +177,8 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI ItemStack returned = directBeltInputBehaviour.handleInsertion(heldItem.copy(), side, false); if (returned.isEmpty()) { - if (world.getTileEntity(nextPosition) instanceof ItemDrainTileEntity) - AllTriggers.triggerForNearbyPlayers(AllTriggers.CHAINED_ITEM_DRAIN, world, pos, 5); + if (level.getBlockEntity(nextPosition) instanceof ItemDrainTileEntity) + AllTriggers.triggerForNearbyPlayers(AllTriggers.CHAINED_ITEM_DRAIN, level, worldPosition, 5); heldItem = null; notifyUpdate(); return; @@ -194,7 +194,7 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI } if (heldItem.prevBeltPosition < .5f && heldItem.beltPosition >= .5f) { - if (!EmptyingByBasin.canItemBeEmptied(world, heldItem.stack)) + if (!EmptyingByBasin.canItemBeEmptied(level, heldItem.stack)) return; heldItem.beltPosition = .5f; if (onClient) @@ -206,14 +206,14 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI } protected boolean continueProcessing() { - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) return true; if (processingTicks < 5) return true; - if (!EmptyingByBasin.canItemBeEmptied(world, heldItem.stack)) + if (!EmptyingByBasin.canItemBeEmptied(level, heldItem.stack)) return false; - Pair emptyItem = EmptyingByBasin.emptyItem(world, heldItem.stack, true); + Pair emptyItem = EmptyingByBasin.emptyItem(level, heldItem.stack, true); FluidStack fluidFromItem = emptyItem.getFirst(); if (processingTicks > 5) { @@ -228,8 +228,8 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI return true; } - emptyItem = EmptyingByBasin.emptyItem(world, heldItem.stack.copy(), false); - AllTriggers.triggerForNearbyPlayers(AllTriggers.ITEM_DRAIN, world, pos, 5); + emptyItem = EmptyingByBasin.emptyItem(level, heldItem.stack.copy(), false); + AllTriggers.triggerForNearbyPlayers(AllTriggers.ITEM_DRAIN, level, worldPosition, 5); // Process finished ItemStack out = emptyItem.getSecond(); @@ -250,8 +250,8 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI } @Override - public void remove() { - super.remove(); + public void setRemoved() { + super.setRemoved(); for (LazyOptional lazyOptional : itemHandlers.values()) lazyOptional.invalidate(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutBlock.java index be3a9dcd2..2d5634321 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutBlock.java @@ -15,6 +15,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class SpoutBlock extends Block implements IWrenchable { public SpoutBlock(Properties p_i48440_1_) { @@ -38,17 +40,17 @@ public class SpoutBlock extends Block implements IWrenchable { } @Override - public boolean hasComparatorInputOverride(BlockState state) { + public boolean hasAnalogOutputSignal(BlockState state) { return true; } @Override - public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { return ComparatorUtil.levelOfSmartFluidTank(worldIn, pos); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java index 56e8a77d6..5594f5ef7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java @@ -42,11 +42,11 @@ public class SpoutRenderer extends SafeTileEntityRenderer { float min = 2.5f / 16f; float max = min + (11 / 16f); float yOffset = (11 / 16f) * level; - ms.push(); + ms.pushPose(); ms.translate(0, yOffset, 0); FluidRenderer.renderTiledFluidBB(fluidStack, min, min - yOffset, min, max, min, max, buffer, ms, light, false); - ms.pop(); + ms.popPose(); } int processingTicks = te.getCorrectedProcessingTicks(); @@ -57,7 +57,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer { if (processingTicks != -1) { radius = (float) (Math.pow(((2 * processingProgress) - 1), 2) - 1); - AxisAlignedBB bb = new AxisAlignedBB(0.5, .5, 0.5, 0.5, -1.2, 0.5).grow(radius / 32f); + AxisAlignedBB bb = new AxisAlignedBB(0.5, .5, 0.5, 0.5, -1.2, 0.5).inflate(radius / 32f); FluidRenderer.renderTiledFluidBB(fluidStack, (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ, buffer, ms, light, true); } @@ -70,14 +70,14 @@ public class SpoutRenderer extends SafeTileEntityRenderer { else if (processingPT < 10) squeeze = -1; - ms.push(); + ms.pushPose(); for (PartialModel bit : BITS) { PartialBufferer.get(bit, te.getBlockState()) .light(light) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .renderInto(ms, buffer.getBuffer(RenderType.solid())); ms.translate(0, -3 * squeeze / 32f, 0); } - ms.pop(); + ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutTileEntity.java index df7db0317..371e73e47 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutTileEntity.java @@ -76,7 +76,7 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor @OnlyIn(Dist.CLIENT) public AxisAlignedBB getRenderBoundingBox() { if (cachedBoundingBox == null) - cachedBoundingBox = super.getRenderBoundingBox().expand(0, -2, 0); + cachedBoundingBox = super.getRenderBoundingBox().expandTowards(0, -2, 0); return cachedBoundingBox; } @@ -93,11 +93,11 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor protected ProcessingResult onItemReceived(TransportedItemStack transported, TransportedItemStackHandlerBehaviour handler) { - if (!FillingBySpout.canItemBeFilled(world, transported.stack)) + if (!FillingBySpout.canItemBeFilled(level, transported.stack)) return PASS; if (tank.isEmpty()) return HOLD; - if (FillingBySpout.getRequiredAmountForItem(world, transported.stack, getCurrentFluidInTank()) == -1) + if (FillingBySpout.getRequiredAmountForItem(level, transported.stack, getCurrentFluidInTank()) == -1) return PASS; return HOLD; } @@ -107,12 +107,12 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor shouldAnimate = true; if (processingTicks != -1 && processingTicks != 5) return HOLD; - if (!FillingBySpout.canItemBeFilled(world, transported.stack)) + if (!FillingBySpout.canItemBeFilled(level, transported.stack)) return PASS; if (tank.isEmpty()) return HOLD; FluidStack fluid = getCurrentFluidInTank(); - int requiredAmountForItem = FillingBySpout.getRequiredAmountForItem(world, transported.stack, fluid.copy()); + int requiredAmountForItem = FillingBySpout.getRequiredAmountForItem(level, transported.stack, fluid.copy()); if (requiredAmountForItem == -1) return PASS; if (requiredAmountForItem > fluid.getAmount()) @@ -125,7 +125,7 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor } // Process finished - ItemStack out = FillingBySpout.fillItem(world, requiredAmountForItem, transported.stack, fluid); + ItemStack out = FillingBySpout.fillItem(level, requiredAmountForItem, transported.stack, fluid); if (!out.isEmpty()) { List outList = new ArrayList<>(); TransportedItemStack held = null; @@ -137,10 +137,10 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor handler.handleProcessingOnItem(transported, TransportedResult.convertToAndLeaveHeld(outList, held)); } - AllTriggers.triggerForNearbyPlayers(AllTriggers.SPOUT, world, pos, 5); - if (out.getItem() instanceof PotionItem && !PotionUtils.getEffectsFromStack(out) + AllTriggers.triggerForNearbyPlayers(AllTriggers.SPOUT, level, worldPosition, 5); + if (out.getItem() instanceof PotionItem && !PotionUtils.getMobEffects(out) .isEmpty()) - AllTriggers.triggerForNearbyPlayers(AllTriggers.SPOUT_POTION, world, pos, 5); + AllTriggers.triggerForNearbyPlayers(AllTriggers.SPOUT_POTION, level, worldPosition, 5); tank.getPrimaryHandler() .setFluid(fluid); @@ -152,7 +152,7 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor private void processTicCastBlock() { if (!IS_TIC_LOADED || CASTING_FLUID_HANDLER_CLASS == null) return; - if (world == null) + if (level == null) return; IFluidHandler localTank = this.tank.getCapability() .orElse(null); @@ -161,10 +161,10 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor FluidStack fluid = getCurrentFluidInTank(); if (fluid.getAmount() == 0) return; - TileEntity te = world.getTileEntity(pos.down(2)); + TileEntity te = level.getBlockEntity(worldPosition.below(2)); if (te == null) return; - IFluidHandler handler = getFluidHandler(pos.down(2), Direction.UP); + IFluidHandler handler = getFluidHandler(worldPosition.below(2), Direction.UP); if (!CASTING_FLUID_HANDLER_CLASS.isInstance(handler)) return; if (handler.getTanks() != 1) @@ -242,7 +242,7 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor processTicCastBlock(); if (processingTicks >= 0) processingTicks--; - if (processingTicks >= 8 && world.isRemote && shouldAnimate) + if (processingTicks >= 8 && level.isClientSide && shouldAnimate) spawnProcessingParticles(tank.getPrimaryTank() .getRenderedFluid()); } @@ -250,10 +250,10 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor protected void spawnProcessingParticles(FluidStack fluid) { if (isVirtual()) return; - Vector3d vec = VecHelper.getCenterOf(pos); + Vector3d vec = VecHelper.getCenterOf(worldPosition); vec = vec.subtract(0, 8 / 16f, 0); IParticleData particle = FluidFX.getFluidParticle(fluid); - world.addOptionalParticle(particle, vec.x, vec.y, vec.z, 0, -.1f, 0); + level.addAlwaysVisibleParticle(particle, vec.x, vec.y, vec.z, 0, -.1f, 0); } protected static int SPLASH_PARTICLE_COUNT = 20; @@ -261,22 +261,22 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor protected void spawnSplash(FluidStack fluid) { if (isVirtual()) return; - Vector3d vec = VecHelper.getCenterOf(pos); + Vector3d vec = VecHelper.getCenterOf(worldPosition); vec = vec.subtract(0, 2 - 5 / 16f, 0); IParticleData particle = FluidFX.getFluidParticle(fluid); for (int i = 0; i < SPLASH_PARTICLE_COUNT; i++) { - Vector3d m = VecHelper.offsetRandomly(Vector3d.ZERO, world.rand, 0.125f); + Vector3d m = VecHelper.offsetRandomly(Vector3d.ZERO, level.random, 0.125f); m = new Vector3d(m.x, Math.abs(m.y), m.z); - world.addOptionalParticle(particle, vec.x, vec.y, vec.z, m.x, m.y, m.z); + level.addAlwaysVisibleParticle(particle, vec.x, vec.y, vec.z, m.x, m.y, m.z); } } @Nullable private IFluidHandler getFluidHandler(BlockPos pos, Direction direction) { - if (this.world == null) { + if (this.level == null) { return null; } else { - TileEntity te = this.world.getTileEntity(pos); + TileEntity te = this.level.getBlockEntity(pos); return te != null ? te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, direction) .orElse(null) : null; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/BasinFluidParticle.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/BasinFluidParticle.java index 64f392743..05fa110d9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/BasinFluidParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/BasinFluidParticle.java @@ -24,72 +24,72 @@ public class BasinFluidParticle extends FluidStackParticle { public BasinFluidParticle(ClientWorld world, FluidStack fluid, double x, double y, double z, double vx, double vy, double vz) { super(world, fluid, x, y, z, vx, vy, vz); - particleGravity = 0; - motionX = 0; - motionY = 0; - motionZ = 0; - yOffset = world.rand.nextFloat() * 1 / 32f; - posY += yOffset; - particleScale = 0; - maxAge = 60; - Vector3d currentPos = new Vector3d(posX, posY, posZ); + gravity = 0; + xd = 0; + yd = 0; + zd = 0; + yOffset = world.random.nextFloat() * 1 / 32f; + y += yOffset; + quadSize = 0; + lifetime = 60; + Vector3d currentPos = new Vector3d(x, y, z); basinPos = new BlockPos(currentPos); centerOfBasin = VecHelper.getCenterOf(basinPos); if (vx != 0) { - maxAge = 20; + lifetime = 20; Vector3d centerOf = VecHelper.getCenterOf(basinPos); Vector3d diff = currentPos.subtract(centerOf) - .mul(1, 0, 1) + .multiply(1, 0, 1) .normalize() .scale(.375); targetPos = centerOf.add(diff); - prevPosX = posX = centerOfBasin.x; - prevPosZ = posZ = centerOfBasin.z; + xo = x = centerOfBasin.x; + zo = z = centerOfBasin.z; } } @Override public void tick() { super.tick(); - particleScale = targetPos != null ? Math.max(1 / 32f, ((1f * age) / maxAge) / 8) - : 1 / 8f * (1 - ((Math.abs(age - (maxAge / 2)) / (1f * maxAge)))); + quadSize = targetPos != null ? Math.max(1 / 32f, ((1f * age) / lifetime) / 8) + : 1 / 8f * (1 - ((Math.abs(age - (lifetime / 2)) / (1f * lifetime)))); if (age % 2 == 0) { - if (!AllBlocks.BASIN.has(world.getBlockState(basinPos))) { - setExpired(); + if (!AllBlocks.BASIN.has(level.getBlockState(basinPos))) { + remove(); return; } - TileEntity tileEntity = world.getTileEntity(basinPos); + TileEntity tileEntity = level.getBlockEntity(basinPos); if (tileEntity instanceof BasinTileEntity) { float totalUnits = ((BasinTileEntity) tileEntity).getTotalFluidUnits(0); if (totalUnits < 1) totalUnits = 0; float fluidLevel = MathHelper.clamp(totalUnits / 2000, 0, 1); - posY = 2 / 16f + basinPos.getY() + 12 / 16f * fluidLevel + yOffset; + y = 2 / 16f + basinPos.getY() + 12 / 16f * fluidLevel + yOffset; } } if (targetPos != null) { - float progess = (1f * age) / maxAge; + float progess = (1f * age) / lifetime; Vector3d currentPos = centerOfBasin.add(targetPos.subtract(centerOfBasin) .scale(progess)); - posX = currentPos.x; - posZ = currentPos.z; + x = currentPos.x; + z = currentPos.z; } } @Override - public void buildGeometry(IVertexBuilder vb, ActiveRenderInfo info, float pt) { - Quaternion rotation = info.getRotation(); + public void render(IVertexBuilder vb, ActiveRenderInfo info, float pt) { + Quaternion rotation = info.rotation(); Quaternion prevRotation = new Quaternion(rotation); rotation.set(1, 0, 0, 1); rotation.normalize(); - super.buildGeometry(vb, info, pt); + super.render(vb, info, pt); rotation.set(0, 0, 0, 1); - rotation.multiply(prevRotation); + rotation.mul(prevRotation); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/FluidParticleData.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/FluidParticleData.java index 14c324e72..1e2b7a503 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/FluidParticleData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/FluidParticleData.java @@ -21,6 +21,8 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.particles.IParticleData.IDeserializer; + public class FluidParticleData implements IParticleData, ICustomParticleData { private ParticleType type; @@ -47,12 +49,12 @@ public class FluidParticleData implements IParticleData, ICustomParticleData() { // TODO Fluid particles on command - public FluidParticleData deserialize(ParticleType particleTypeIn, StringReader reader) + public FluidParticleData fromCommand(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { return new FluidParticleData(particleTypeIn, new FluidStack(Fluids.WATER, 1)); } - public FluidParticleData read(ParticleType particleTypeIn, PacketBuffer buffer) { + public FluidParticleData fromNetwork(ParticleType particleTypeIn, PacketBuffer buffer) { return new FluidParticleData(particleTypeIn, buffer.readFluidStack()); } }; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/FluidStackParticle.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/FluidStackParticle.java index 1119601b4..12a2eaacb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/FluidStackParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/FluidStackParticle.java @@ -15,8 +15,8 @@ import net.minecraft.util.math.vector.Vector3d; import net.minecraftforge.fluids.FluidStack; public class FluidStackParticle extends SpriteTexturedParticle { - private final float field_217587_G; - private final float field_217588_H; + private final float uo; + private final float vo; private FluidStack fluid; public static FluidStackParticle create(ParticleType type, ClientWorld world, FluidStack fluid, double x, @@ -31,31 +31,31 @@ public class FluidStackParticle extends SpriteTexturedParticle { super(world, x, y, z, vx, vy, vz); this.fluid = fluid; this.setSprite(Minecraft.getInstance() - .getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE) + .getTextureAtlas(PlayerContainer.BLOCK_ATLAS) .apply(fluid.getFluid() .getAttributes() .getStillTexture())); - this.particleGravity = 1.0F; - this.particleRed = 0.8F; - this.particleGreen = 0.8F; - this.particleBlue = 0.8F; + this.gravity = 1.0F; + this.rCol = 0.8F; + this.gCol = 0.8F; + this.bCol = 0.8F; this.multiplyColor(fluid.getFluid() .getAttributes() .getColor(fluid)); - this.motionX = vx; - this.motionY = vy; - this.motionZ = vz; + this.xd = vx; + this.yd = vy; + this.zd = vz; - this.particleScale /= 2.0F; - this.field_217587_G = this.rand.nextFloat() * 3.0F; - this.field_217588_H = this.rand.nextFloat() * 3.0F; + this.quadSize /= 2.0F; + this.uo = this.random.nextFloat() * 3.0F; + this.vo = this.random.nextFloat() * 3.0F; } @Override - protected int getBrightnessForRender(float p_189214_1_) { - int brightnessForRender = super.getBrightnessForRender(p_189214_1_); + protected int getLightColor(float p_189214_1_) { + int brightnessForRender = super.getLightColor(p_189214_1_); int skyLight = brightnessForRender >> 20; int blockLight = (brightnessForRender >> 4) & 0xf; blockLight = Math.max(blockLight, fluid.getFluid() @@ -65,25 +65,25 @@ public class FluidStackParticle extends SpriteTexturedParticle { } protected void multiplyColor(int color) { - this.particleRed *= (float) (color >> 16 & 255) / 255.0F; - this.particleGreen *= (float) (color >> 8 & 255) / 255.0F; - this.particleBlue *= (float) (color & 255) / 255.0F; + this.rCol *= (float) (color >> 16 & 255) / 255.0F; + this.gCol *= (float) (color >> 8 & 255) / 255.0F; + this.bCol *= (float) (color & 255) / 255.0F; } - protected float getMinU() { - return this.sprite.getInterpolatedU((double) ((this.field_217587_G + 1.0F) / 4.0F * 16.0F)); + protected float getU0() { + return this.sprite.getU((double) ((this.uo + 1.0F) / 4.0F * 16.0F)); } - protected float getMaxU() { - return this.sprite.getInterpolatedU((double) (this.field_217587_G / 4.0F * 16.0F)); + protected float getU1() { + return this.sprite.getU((double) (this.uo / 4.0F * 16.0F)); } - protected float getMinV() { - return this.sprite.getInterpolatedV((double) (this.field_217588_H / 4.0F * 16.0F)); + protected float getV0() { + return this.sprite.getV((double) (this.vo / 4.0F * 16.0F)); } - protected float getMaxV() { - return this.sprite.getInterpolatedV((double) ((this.field_217588_H + 1.0F) / 4.0F * 16.0F)); + protected float getV1() { + return this.sprite.getV((double) ((this.vo + 1.0F) / 4.0F * 16.0F)); } @Override @@ -92,16 +92,16 @@ public class FluidStackParticle extends SpriteTexturedParticle { if (!canEvaporate()) return; if (onGround) - setExpired(); - if (!isExpired) + remove(); + if (!removed) return; - if (!onGround && world.rand.nextFloat() < 1 / 8f) + if (!onGround && level.random.nextFloat() < 1 / 8f) return; Vector3d rgb = ColorHelper.getRGB(fluid.getFluid() .getAttributes() .getColor(fluid)); - world.addParticle(ParticleTypes.ENTITY_EFFECT, posX, posY, posZ, rgb.x, rgb.y, rgb.z); + level.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, rgb.x, rgb.y, rgb.z); } protected boolean canEvaporate() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/AxisPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/AxisPipeBlock.java index d9410ff54..1ea8c401f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/AxisPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/AxisPipeBlock.java @@ -38,6 +38,8 @@ import net.minecraft.world.TickPriority; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWithBracket, IAxisPipe { public AxisPipeBlock(Properties p_i48339_1_) { @@ -45,27 +47,27 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith } @Override - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); - if (blockTypeChanged && !world.isRemote) + if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); if (state != newState && !isMoving) - removeBracket(world, pos, true).ifPresent(stack -> Block.spawnAsEntity(world, pos, stack)); + removeBracket(world, pos, true).ifPresent(stack -> Block.popResource(world, pos, stack)); if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity())) - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { - if (!AllBlocks.COPPER_CASING.isIn(player.getHeldItem(hand))) + if (!AllBlocks.COPPER_CASING.isIn(player.getItemInHand(hand))) return ActionResultType.PASS; - if (!world.isRemote) { + if (!world.isClientSide) { BlockState newState = AllBlocks.ENCASED_FLUID_PIPE.getDefaultState(); for (Direction d : Iterate.directionsInAxis(getAxis(state))) - newState = newState.with(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), true); + newState = newState.setValue(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), true); FluidTransportBehaviour.cacheFlows(world, pos); - world.setBlockState(pos, newState); + world.setBlockAndUpdate(pos, newState); FluidTransportBehaviour.loadFlows(world, pos); } AllTriggers.triggerFor(AllTriggers.CASING_PIPE, player); @@ -73,11 +75,11 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { - if (world.isRemote) + public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + if (world.isClientSide) return; if (state != oldState) - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @@ -90,43 +92,43 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.func_218806_a(world, pos); + DebugPacketSender.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; if (!isOpenAt(state, d)) return; - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } public static boolean isOpenAt(BlockState state, Direction d) { - return d.getAxis() == state.get(AXIS); + return d.getAxis() == state.getValue(AXIS); } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @Override public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - return AllShapes.EIGHT_VOXEL_POLE.get(state.get(AXIS)); + return AllShapes.EIGHT_VOXEL_POLE.get(state.getValue(AXIS)); } public BlockState toRegularPipe(IWorld world, BlockPos pos, BlockState state) { - Direction side = Direction.getFacingFromAxis(AxisDirection.POSITIVE, state.get(AXIS)); - Map facingToPropertyMap = FluidPipeBlock.FACING_TO_PROPERTY_MAP; + Direction side = Direction.get(AxisDirection.POSITIVE, state.getValue(AXIS)); + Map facingToPropertyMap = FluidPipeBlock.PROPERTY_BY_DIRECTION; return AllBlocks.FLUID_PIPE.get() .updateBlockState(AllBlocks.FLUID_PIPE.getDefaultState() - .with(facingToPropertyMap.get(side), true) - .with(facingToPropertyMap.get(side.getOpposite()), true), side, null, world, pos); + .setValue(facingToPropertyMap.get(side), true) + .setValue(facingToPropertyMap.get(side.getOpposite()), true), side, null, world, pos); } @Override public Axis getAxis(BlockState state) { - return state.get(AXIS); + return state.getValue(AXIS); } @Override @@ -136,7 +138,7 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith return Optional.empty(); BlockState bracket = behaviour.getBracket(); behaviour.removeBracket(inOnReplacedContext); - if (bracket == Blocks.AIR.getDefaultState()) + if (bracket == Blocks.AIR.defaultBlockState()) return Optional.empty(); return Optional.of(new ItemStack(bracket.getBlock())); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java index 6932c02fb..df522f4dc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java @@ -19,6 +19,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.IStringSerializable; +import net.minecraft.block.AbstractBlock.Properties; + public class BracketBlock extends ProperDirectionalBlock { public static final BooleanProperty AXIS_ALONG_FIRST_COORDINATE = @@ -29,15 +31,15 @@ public class BracketBlock extends ProperDirectionalBlock { PIPE, COG, SHAFT; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(AXIS_ALONG_FIRST_COORDINATE) + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(AXIS_ALONG_FIRST_COORDINATE) .add(TYPE)); } @@ -47,7 +49,7 @@ public class BracketBlock extends ProperDirectionalBlock { public Optional getSuitableBracket(BlockState blockState, Direction direction) { if (blockState.getBlock() instanceof AbstractShaftBlock) - return getSuitableBracket(blockState.get(RotatedPillarKineticBlock.AXIS), direction, + return getSuitableBracket(blockState.getValue(RotatedPillarKineticBlock.AXIS), direction, blockState.getBlock() instanceof CogWheelBlock ? BracketType.COG : BracketType.SHAFT); return getSuitableBracket(FluidPropagator.getStraightPipeAxis(blockState), direction, BracketType.PIPE); } @@ -58,9 +60,9 @@ public class BracketBlock extends ProperDirectionalBlock { return Optional.empty(); boolean alongFirst = axis != Axis.Z ? targetBlockAxis == Axis.Z : targetBlockAxis == Axis.Y; - return Optional.of(getDefaultState().with(TYPE, type) - .with(FACING, direction) - .with(AXIS_ALONG_FIRST_COORDINATE, !alongFirst)); + return Optional.of(defaultBlockState().setValue(TYPE, type) + .setValue(FACING, direction) + .setValue(AXIS_ALONG_FIRST_COORDINATE, !alongFirst)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlockItem.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlockItem.java index d7aaf70b8..243f3a31b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlockItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlockItem.java @@ -17,6 +17,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.item.Item.Properties; + public class BracketBlockItem extends BlockItem { public BracketBlockItem(Block p_i48527_1_, Properties p_i48527_2_) { @@ -24,9 +26,9 @@ public class BracketBlockItem extends BlockItem { } @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); - BlockPos pos = context.getPos(); + public ActionResultType useOn(ItemUseContext context) { + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); BlockState state = world.getBlockState(pos); BracketBlock bracketBlock = getBracketBlock(); PlayerEntity player = context.getPlayer(); @@ -37,29 +39,29 @@ public class BracketBlockItem extends BlockItem { return ActionResultType.FAIL; if (!behaviour.canHaveBracket()) return ActionResultType.FAIL; - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; - Optional suitableBracket = bracketBlock.getSuitableBracket(state, context.getFace()); + Optional suitableBracket = bracketBlock.getSuitableBracket(state, context.getClickedFace()); if (!suitableBracket.isPresent() && player != null) suitableBracket = - bracketBlock.getSuitableBracket(state, Direction.getFacingDirections(player)[0].getOpposite()); + bracketBlock.getSuitableBracket(state, Direction.orderedByNearest(player)[0].getOpposite()); if (!suitableBracket.isPresent()) return ActionResultType.SUCCESS; BlockState bracket = behaviour.getBracket(); behaviour.applyBracket(suitableBracket.get()); - if (!world.isRemote && player != null) + if (!world.isClientSide && player != null) behaviour.triggerAdvancements(world, player, state); if (player == null || !player.isCreative()) { - context.getItem() + context.getItemInHand() .shrink(1); - if (bracket != Blocks.AIR.getDefaultState()) { + if (bracket != Blocks.AIR.defaultBlockState()) { ItemStack returnedStack = new ItemStack(bracket.getBlock()); if (player == null) - Block.spawnAsEntity(world, pos, returnedStack); + Block.popResource(world, pos, returnedStack); else player.inventory.placeItemBackInInventory(world, returnedStack); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketGenerator.java index 456ee4766..e31ac7a86 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketGenerator.java @@ -28,9 +28,9 @@ public class BracketGenerator extends DirectionalAxisBlockStateGen { @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - String type = state.get(BracketBlock.TYPE) - .getString(); - boolean vertical = state.get(BracketBlock.FACING) + String type = state.getValue(BracketBlock.TYPE) + .getSerializedName(); + boolean vertical = state.getValue(BracketBlock.FACING) .getAxis() .isVertical(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/EncasedPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/EncasedPipeBlock.java index 6c59b77a7..be375a2dc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/EncasedPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/EncasedPipeBlock.java @@ -38,24 +38,26 @@ import net.minecraft.world.TickPriority; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBlockItemRequirement { - public static final Map FACING_TO_PROPERTY_MAP = SixWayBlock.FACING_TO_PROPERTY_MAP; + public static final Map FACING_TO_PROPERTY_MAP = SixWayBlock.PROPERTY_BY_DIRECTION; public EncasedPipeBlock(Properties p_i48339_1_) { super(p_i48339_1_); - setDefaultState(getDefaultState().with(NORTH, false) - .with(SOUTH, false) - .with(DOWN, false) - .with(UP, false) - .with(WEST, false) - .with(EAST, false)); + registerDefaultState(defaultBlockState().setValue(NORTH, false) + .setValue(SOUTH, false) + .setValue(DOWN, false) + .setValue(UP, false) + .setValue(WEST, false) + .setValue(EAST, false)); } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(NORTH, EAST, SOUTH, WEST, UP, DOWN); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override @@ -64,18 +66,18 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc } @Override - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); - if (blockTypeChanged && !world.isRemote) + if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity())) - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { - if (!world.isRemote && state != oldState) - world.getPendingBlockTicks() + public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + if (!world.isClientSide && state != oldState) + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @@ -88,18 +90,18 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.func_218806_a(world, pos); + DebugPacketSender.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; - if (!state.get(FACING_TO_PROPERTY_MAP.get(d))) + if (!state.getValue(FACING_TO_PROPERTY_MAP.get(d))) return; - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @@ -110,25 +112,25 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getWorld(); - BlockPos pos = context.getPos(); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; - context.getWorld() - .playEvent(2001, context.getPos(), Block.getStateId(state)); + context.getLevel() + .levelEvent(2001, context.getClickedPos(), Block.getId(state)); BlockState equivalentPipe = transferSixWayProperties(state, AllBlocks.FLUID_PIPE.getDefaultState()); Direction firstFound = Direction.UP; for (Direction d : Iterate.directions) - if (state.get(FACING_TO_PROPERTY_MAP.get(d))) { + if (state.getValue(FACING_TO_PROPERTY_MAP.get(d))) { firstFound = d; break; } FluidTransportBehaviour.cacheFlows(world, pos); - world.setBlockState(pos, AllBlocks.FLUID_PIPE.get() + world.setBlockAndUpdate(pos, AllBlocks.FLUID_PIPE.get() .updateBlockState(equivalentPipe, firstFound, null, world, pos)); FluidTransportBehaviour.loadFlows(world, pos); return ActionResultType.SUCCESS; @@ -137,7 +139,7 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc public static BlockState transferSixWayProperties(BlockState from, BlockState to) { for (Direction d : Iterate.directions) { BooleanProperty property = FACING_TO_PROPERTY_MAP.get(d); - to = to.with(property, from.get(property)); + to = to.setValue(property, from.getValue(property)); } return to; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java index 2f6d15103..a42ef87b3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java @@ -46,11 +46,13 @@ import net.minecraft.world.TickPriority; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWrenchableWithBracket { public FluidPipeBlock(Properties properties) { super(4 / 16f, properties); - this.setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false)); + this.registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false)); } @Override @@ -58,33 +60,33 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren if (tryRemoveBracket(context)) return ActionResultType.SUCCESS; - World world = context.getWorld(); - BlockPos pos = context.getPos(); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); Axis axis = getAxis(world, pos, state); if (axis == null) return ActionResultType.PASS; - if (context.getFace() + if (context.getClickedFace() .getAxis() == axis) return ActionResultType.PASS; - if (!world.isRemote) { + if (!world.isClientSide) { FluidTransportBehaviour.cacheFlows(world, pos); - world.setBlockState(pos, AllBlocks.GLASS_FLUID_PIPE.getDefaultState() - .with(GlassFluidPipeBlock.AXIS, axis) - .with(BlockStateProperties.WATERLOGGED, state.get(BlockStateProperties.WATERLOGGED))); + world.setBlockAndUpdate(pos, AllBlocks.GLASS_FLUID_PIPE.getDefaultState() + .setValue(GlassFluidPipeBlock.AXIS, axis) + .setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED))); FluidTransportBehaviour.loadFlows(world, pos); } return ActionResultType.SUCCESS; } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { - if (!AllBlocks.COPPER_CASING.isIn(player.getHeldItem(hand))) + if (!AllBlocks.COPPER_CASING.isIn(player.getItemInHand(hand))) return ActionResultType.PASS; AllTriggers.triggerFor(AllTriggers.CASING_PIPE, player); - if (!world.isRemote) { + if (!world.isClientSide) { FluidTransportBehaviour.cacheFlows(world, pos); - world.setBlockState(pos, + world.setBlockAndUpdate(pos, EncasedPipeBlock.transferSixWayProperties(state, AllBlocks.ENCASED_FLUID_PIPE.getDefaultState())); FluidTransportBehaviour.loadFlows(world, pos); } @@ -92,9 +94,9 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } public BlockState getAxisState(Axis axis) { - BlockState defaultState = getDefaultState(); + BlockState defaultState = defaultBlockState(); for (Direction d : Iterate.directions) - defaultState = defaultState.with(FACING_TO_PROPERTY_MAP.get(d), d.getAxis() == axis); + defaultState = defaultState.setValue(PROPERTY_BY_DIRECTION.get(d), d.getAxis() == axis); return defaultState; } @@ -114,40 +116,40 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); - if (blockTypeChanged && !world.isRemote) + if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); if (state != newState && !isMoving) - removeBracket(world, pos, true).ifPresent(stack -> Block.spawnAsEntity(world, pos, stack)); + removeBracket(world, pos, true).ifPresent(stack -> Block.popResource(world, pos, stack)); if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity())) - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { - if (world.isRemote) + public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + if (world.isClientSide) return; if (state != oldState) - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.func_218806_a(world, pos); + DebugPacketSender.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; if (!isOpenAt(state, d)) return; - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @@ -158,7 +160,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren public static boolean canConnectTo(IBlockDisplayReader world, BlockPos neighbourPos, BlockState neighbour, Direction direction) { if (FluidPropagator.hasFluidCapability(world, neighbourPos, direction.getOpposite())) return true; - if (neighbour.contains(BlockStateProperties.HONEY_LEVEL)) + if (neighbour.hasProperty(BlockStateProperties.LEVEL_HONEY)) return true; FluidTransportBehaviour transport = TileEntityBehaviour.get(world, neighbourPos, FluidTransportBehaviour.TYPE); BracketedTileEntityBehaviour bracket = TileEntityBehaviour.get(world, neighbourPos, BracketedTileEntityBehaviour.TYPE); @@ -172,7 +174,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren public static boolean shouldDrawRim(IBlockDisplayReader world, BlockPos pos, BlockState state, Direction direction) { - BlockPos offsetPos = pos.offset(direction); + BlockPos offsetPos = pos.relative(direction); BlockState facingState = world.getBlockState(offsetPos); if (!isPipe(facingState)) return true; @@ -190,7 +192,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } public static boolean isOpenAt(BlockState state, Direction direction) { - return state.get(FACING_TO_PROPERTY_MAP.get(direction)); + return state.getValue(PROPERTY_BY_DIRECTION.get(direction)); } public static boolean isCornerOrEndPipe(IBlockDisplayReader world, BlockPos pos, BlockState state) { @@ -213,28 +215,28 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(NORTH, EAST, SOUTH, WEST, UP, DOWN, BlockStateProperties.WATERLOGGED); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - FluidState FluidState = context.getWorld() - .getFluidState(context.getPos()); - return updateBlockState(getDefaultState(), context.getNearestLookingDirection(), null, context.getWorld(), - context.getPos()).with(BlockStateProperties.WATERLOGGED, - Boolean.valueOf(FluidState.getFluid() == Fluids.WATER)); + FluidState FluidState = context.getLevel() + .getFluidState(context.getClickedPos()); + return updateBlockState(defaultBlockState(), context.getNearestLookingDirection(), null, context.getLevel(), + context.getClickedPos()).setValue(BlockStateProperties.WATERLOGGED, + Boolean.valueOf(FluidState.getType() == Fluids.WATER)); } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, BlockPos pos, BlockPos neighbourPos) { - if (state.get(BlockStateProperties.WATERLOGGED)) - world.getPendingFluidTicks() - .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - if (isOpenAt(state, direction) && neighbourState.contains(BlockStateProperties.WATERLOGGED)) - world.getPendingBlockTicks() + if (state.getValue(BlockStateProperties.WATERLOGGED)) + world.getLiquidTicks() + .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); + if (isOpenAt(state, direction) && neighbourState.hasProperty(BlockStateProperties.WATERLOGGED)) + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); return updateBlockState(state, direction, direction.getOpposite(), world, pos); } @@ -248,15 +250,15 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren BlockState prevState = state; int prevStateSides = (int) Arrays.stream(Iterate.directions) - .map(FACING_TO_PROPERTY_MAP::get) - .filter(prevState::get) + .map(PROPERTY_BY_DIRECTION::get) + .filter(prevState::getValue) .count(); // Update sides that are not ignored for (Direction d : Iterate.directions) if (d != ignore) { - boolean shouldConnect = canConnectTo(world, pos.offset(d), world.getBlockState(pos.offset(d)), d); - state = state.with(FACING_TO_PROPERTY_MAP.get(d), shouldConnect); + boolean shouldConnect = canConnectTo(world, pos.relative(d), world.getBlockState(pos.relative(d)), d); + state = state.setValue(PROPERTY_BY_DIRECTION.get(d), shouldConnect); } // See if it has enough connections @@ -271,21 +273,21 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren // Add opposite end if only one connection if (connectedDirection != null) - return state.with(FACING_TO_PROPERTY_MAP.get(connectedDirection.getOpposite()), true); + return state.setValue(PROPERTY_BY_DIRECTION.get(connectedDirection.getOpposite()), true); // If we can't connect to anything and weren't connected before, do nothing if (prevStateSides == 2) return prevState; // Use preferred - return state.with(FACING_TO_PROPERTY_MAP.get(preferredDirection), true) - .with(FACING_TO_PROPERTY_MAP.get(preferredDirection.getOpposite()), true); + return state.setValue(PROPERTY_BY_DIRECTION.get(preferredDirection), true) + .setValue(PROPERTY_BY_DIRECTION.get(preferredDirection.getOpposite()), true); } @Override public FluidState getFluidState(BlockState state) { - return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) - : Fluids.EMPTY.getDefaultState(); + return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) + : Fluids.EMPTY.defaultFluidState(); } @Override @@ -296,13 +298,13 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren return Optional.empty(); BlockState bracket = behaviour.getBracket(); behaviour.removeBracket(inOnReplacedContext); - if (bracket == Blocks.AIR.getDefaultState()) + if (bracket == Blocks.AIR.defaultBlockState()) return Optional.empty(); return Optional.of(new ItemStack(bracket.getBlock())); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java index dbcbb66f1..bc630c4aa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java @@ -15,6 +15,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockDisplayReader; +import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes; + public class FluidPipeTileEntity extends SmartTileEntity { public FluidPipeTileEntity(TileEntityType tileEntityTypeIn) { @@ -41,7 +43,7 @@ public class FluidPipeTileEntity extends SmartTileEntity { @Override public boolean canHaveFlowToward(BlockState state, Direction direction) { return (FluidPipeBlock.isPipe(state) || state.getBlock() instanceof EncasedPipeBlock) - && state.get(FluidPipeBlock.FACING_TO_PROPERTY_MAP.get(direction)); + && state.getValue(FluidPipeBlock.PROPERTY_BY_DIRECTION.get(direction)); } @Override @@ -52,7 +54,7 @@ public class FluidPipeTileEntity extends SmartTileEntity { if (attachment == AttachmentTypes.RIM && AllBlocks.ENCASED_FLUID_PIPE.has(state)) return AttachmentTypes.RIM; - BlockPos offsetPos = pos.offset(direction); + BlockPos offsetPos = pos.relative(direction); if (!FluidPipeBlock.isPipe(world.getBlockState(offsetPos))) { FluidTransportBehaviour pipeBehaviour = TileEntityBehaviour.get(world, offsetPos, FluidTransportBehaviour.TYPE); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveBlock.java index 051093f80..16faae839 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveBlock.java @@ -28,13 +28,15 @@ import net.minecraft.world.TickPriority; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxisPipe { public static final BooleanProperty ENABLED = BooleanProperty.create("enabled"); public FluidValveBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(ENABLED, false)); + registerDefaultState(defaultBlockState().setValue(ENABLED, false)); } @Override @@ -44,14 +46,14 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(ENABLED)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(ENABLED)); } @Override protected boolean prefersConnectionTo(IWorldReader reader, BlockPos pos, Direction facing, boolean shaftAxis) { if (!shaftAxis) { - BlockPos offset = pos.offset(facing); + BlockPos offset = pos.relative(facing); BlockState blockState = reader.getBlockState(offset); return FluidPipeBlock.canConnectTo(reader, offset, blockState, facing); } @@ -67,8 +69,8 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi public static Axis getPipeAxis(BlockState state) { if (!(state.getBlock() instanceof FluidValveBlock)) throw new IllegalStateException("Provided BlockState is for a different block."); - Direction facing = state.get(FACING); - boolean alongFirst = !state.get(AXIS_ALONG_FIRST_COORDINATE); + Direction facing = state.getValue(FACING); + boolean alongFirst = !state.getValue(AXIS_ALONG_FIRST_COORDINATE); for (Axis axis : Iterate.axes) { if (axis == facing.getAxis()) continue; @@ -87,38 +89,38 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); - if (blockTypeChanged && !world.isRemote) + if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity())) - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } @Override - public boolean isValidPosition(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { + public boolean canSurvive(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { return true; } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { - if (world.isRemote) + public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + if (world.isClientSide) return; if (state != oldState) - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.func_218806_a(world, pos); + DebugPacketSender.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; if (!isOpenAt(state, d)) return; - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @@ -127,12 +129,12 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java index 33632b40b..a355a98e4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java @@ -26,7 +26,7 @@ public class FluidValveInstance extends ShaftInstance implements IDynamicInstanc public FluidValveInstance(MaterialManager dispatcher, KineticTileEntity tile) { super(dispatcher, tile); - Direction facing = blockState.get(FluidValveBlock.FACING); + Direction facing = blockState.getValue(FluidValveBlock.FACING); yRot = AngleHelper.horizontalAngle(facing); xRot = facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java index f2f6306cd..4118f52a1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java @@ -28,12 +28,12 @@ public class FluidValveRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); BlockState blockState = te.getBlockState(); SuperByteBuffer pointer = PartialBufferer.get(AllBlockPartials.FLUID_VALVE_POINTER, blockState); - Direction facing = blockState.get(FluidValveBlock.FACING); + Direction facing = blockState.getValue(FluidValveBlock.FACING); if (!(te instanceof FluidValveTileEntity)) return; @@ -54,7 +54,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer { .unCentre(); pointer.light(light) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .renderInto(ms, buffer.getBuffer(RenderType.solid())); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveTileEntity.java index 8125ea16f..524a02405 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveTileEntity.java @@ -40,20 +40,20 @@ public class FluidValveTileEntity extends KineticTileEntity { super.tick(); pointer.tickChaser(); - if (world.isRemote) + if (level.isClientSide) return; BlockState blockState = getBlockState(); if (!(blockState.getBlock() instanceof FluidValveBlock)) return; - boolean stateOpen = blockState.get(FluidValveBlock.ENABLED); + boolean stateOpen = blockState.getValue(FluidValveBlock.ENABLED); if (stateOpen && pointer.getValue() == 0) { - switchToBlockState(world, pos, blockState.with(FluidValveBlock.ENABLED, false)); + switchToBlockState(level, worldPosition, blockState.setValue(FluidValveBlock.ENABLED, false)); return; } if (!stateOpen && pointer.getValue() == 1) { - switchToBlockState(world, pos, blockState.with(FluidValveBlock.ENABLED, true)); + switchToBlockState(level, worldPosition, blockState.setValue(FluidValveBlock.ENABLED, true)); return; } } @@ -97,7 +97,7 @@ public class FluidValveTileEntity extends KineticTileEntity { @Override public boolean canPullFluidFrom(FluidStack fluid, BlockState state, Direction direction) { - if (state.contains(FluidValveBlock.ENABLED) && state.get(FluidValveBlock.ENABLED)) + if (state.hasProperty(FluidValveBlock.ENABLED) && state.getValue(FluidValveBlock.ENABLED)) return super.canPullFluidFrom(fluid, state, direction); return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/GlassFluidPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/GlassFluidPipeBlock.java index d85e25e8f..7680aa163 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/GlassFluidPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/GlassFluidPipeBlock.java @@ -27,6 +27,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class GlassFluidPipeBlock extends AxisPipeBlock implements IWaterLoggable, ISpecialBlockItemRequirement { @@ -35,12 +37,12 @@ public class GlassFluidPipeBlock extends AxisPipeBlock implements IWaterLoggable public GlassFluidPipeBlock(Properties p_i48339_1_) { super(p_i48339_1_); - setDefaultState(getDefaultState().with(ALT, false).with(BlockStateProperties.WATERLOGGED, false)); + registerDefaultState(defaultBlockState().setValue(ALT, false).setValue(BlockStateProperties.WATERLOGGED, false)); } @Override - protected void fillStateContainer(Builder p_206840_1_) { - super.fillStateContainer(p_206840_1_.add(ALT, BlockStateProperties.WATERLOGGED)); + protected void createBlockStateDefinition(Builder p_206840_1_) { + super.createBlockStateDefinition(p_206840_1_.add(ALT, BlockStateProperties.WATERLOGGED)); } @Override @@ -58,28 +60,28 @@ public class GlassFluidPipeBlock extends AxisPipeBlock implements IWaterLoggable if (tryRemoveBracket(context)) return ActionResultType.SUCCESS; BlockState newState; - World world = context.getWorld(); - BlockPos pos = context.getPos(); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); FluidTransportBehaviour.cacheFlows(world, pos); - newState = toRegularPipe(world, pos, state).with(BlockStateProperties.WATERLOGGED, state.get(BlockStateProperties.WATERLOGGED)); - world.setBlockState(pos, newState, 3); + newState = toRegularPipe(world, pos, state).setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED)); + world.setBlock(pos, newState, 3); FluidTransportBehaviour.loadFlows(world, pos); return ActionResultType.SUCCESS; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - FluidState ifluidstate = context.getWorld() - .getFluidState(context.getPos()); + FluidState ifluidstate = context.getLevel() + .getFluidState(context.getClickedPos()); BlockState state = super.getStateForPlacement(context); - return state == null ? null : state.with(BlockStateProperties.WATERLOGGED, - ifluidstate.getFluid() == Fluids.WATER); + return state == null ? null : state.setValue(BlockStateProperties.WATERLOGGED, + ifluidstate.getType() == Fluids.WATER); } @Override public FluidState getFluidState(BlockState state) { - return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) - : Fluids.EMPTY.getDefaultState(); + return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) + : Fluids.EMPTY.defaultFluidState(); } @Override @@ -88,7 +90,7 @@ public class GlassFluidPipeBlock extends AxisPipeBlock implements IWaterLoggable } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeBlock.java index 2fcd7aa9a..17058c21b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeBlock.java @@ -28,6 +28,8 @@ import net.minecraft.world.TickPriority; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPipe { public SmartFluidPipeBlock(Properties p_i48339_1_) { @@ -35,17 +37,17 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(FACE) - .add(HORIZONTAL_FACING); + .add(FACING); } @Override public BlockState getStateForPlacement(BlockItemUseContext ctx) { BlockState stateForPlacement = super.getStateForPlacement(ctx); Axis prefferedAxis = null; - BlockPos pos = ctx.getPos(); - World world = ctx.getWorld(); + BlockPos pos = ctx.getClickedPos(); + World world = ctx.getLevel(); for (Direction side : Iterate.directions) { if (!prefersConnectionTo(world, pos, side)) continue; @@ -57,16 +59,16 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } if (prefferedAxis == Axis.Y) - stateForPlacement = stateForPlacement.with(FACE, AttachFace.WALL) - .with(HORIZONTAL_FACING, stateForPlacement.get(HORIZONTAL_FACING) + stateForPlacement = stateForPlacement.setValue(FACE, AttachFace.WALL) + .setValue(FACING, stateForPlacement.getValue(FACING) .getOpposite()); else if (prefferedAxis != null) { - if (stateForPlacement.get(FACE) == AttachFace.WALL) - stateForPlacement = stateForPlacement.with(FACE, AttachFace.FLOOR); + if (stateForPlacement.getValue(FACE) == AttachFace.WALL) + stateForPlacement = stateForPlacement.setValue(FACE, AttachFace.FLOOR); for (Direction direction : ctx.getNearestLookingDirections()) { if (direction.getAxis() != prefferedAxis) continue; - stateForPlacement = stateForPlacement.with(HORIZONTAL_FACING, direction.getOpposite()); + stateForPlacement = stateForPlacement.setValue(FACING, direction.getOpposite()); } } @@ -74,44 +76,44 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } protected boolean prefersConnectionTo(IWorldReader reader, BlockPos pos, Direction facing) { - BlockPos offset = pos.offset(facing); + BlockPos offset = pos.relative(facing); BlockState blockState = reader.getBlockState(offset); return FluidPipeBlock.canConnectTo(reader, offset, blockState, facing); } @Override - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); - if (blockTypeChanged && !world.isRemote) + if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity())) - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } @Override - public boolean isValidPosition(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { + public boolean canSurvive(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { return true; } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { - if (world.isRemote) + public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + if (world.isClientSide) return; if (state != oldState) - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.func_218806_a(world, pos); + DebugPacketSender.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; if (!isOpenAt(state, d)) return; - world.getPendingBlockTicks() + world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @@ -120,13 +122,13 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } protected static Axis getPipeAxis(BlockState state) { - return state.get(FACE) == AttachFace.WALL ? Axis.Y - : state.get(HORIZONTAL_FACING) + return state.getValue(FACE) == AttachFace.WALL ? Axis.Y + : state.getValue(FACING) .getAxis(); } @@ -143,10 +145,10 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip @Override public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - AttachFace face = state.get(FACE); + AttachFace face = state.getValue(FACE); VoxelShaper shape = face == AttachFace.FLOOR ? AllShapes.SMART_FLUID_PIPE_FLOOR : face == AttachFace.CEILING ? AllShapes.SMART_FLUID_PIPE_CEILING : AllShapes.SMART_FLUID_PIPE_WALL; - return shape.get(state.get(HORIZONTAL_FACING)); + return shape.get(state.getValue(FACING)); } @Override @@ -155,7 +157,7 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeGenerator.java index 0b2467ab0..aff0ac8f5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeGenerator.java @@ -14,14 +14,14 @@ public class SmartFluidPipeGenerator extends SpecialBlockStateGen { @Override protected int getXRotation(BlockState state) { - AttachFace attachFace = state.get(SmartFluidPipeBlock.FACE); + AttachFace attachFace = state.getValue(SmartFluidPipeBlock.FACE); return attachFace == AttachFace.CEILING ? 180 : attachFace == AttachFace.FLOOR ? 0 : 270; } @Override protected int getYRotation(BlockState state) { - AttachFace attachFace = state.get(SmartFluidPipeBlock.FACE); - int angle = horizontalAngle(state.get(SmartFluidPipeBlock.HORIZONTAL_FACING)); + AttachFace attachFace = state.getValue(SmartFluidPipeBlock.FACE); + int angle = horizontalAngle(state.getValue(SmartFluidPipeBlock.FACING)); return angle + (attachFace == AttachFace.CEILING ? 180 : 0); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeTileEntity.java index 8b9544464..72c4367a9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeTileEntity.java @@ -38,9 +38,9 @@ public class SmartFluidPipeTileEntity extends SmartTileEntity { } private void onFilterChanged(ItemStack newFilter) { - if (world.isRemote) + if (level.isClientSide) return; - FluidPropagator.propagateChangedPipe(world, pos, getBlockState()); + FluidPropagator.propagateChangedPipe(level, worldPosition, getBlockState()); } class SmartPipeBehaviour extends StraightPipeFluidTransportBehaviour { @@ -68,7 +68,7 @@ public class SmartFluidPipeTileEntity extends SmartTileEntity { @Override protected Vector3d getLocalOffset(BlockState state) { - AttachFace face = state.get(SmartFluidPipeBlock.FACE); + AttachFace face = state.getValue(SmartFluidPipeBlock.FACE); float y = face == AttachFace.CEILING ? 0.3f : face == AttachFace.WALL ? 11.3f : 15.3f; float z = face == AttachFace.CEILING ? 4.6f : face == AttachFace.WALL ? 0.6f : 4.6f; return VecHelper.rotateCentered(VecHelper.voxelSpace(8, y, z), angleY(state), Axis.Y); @@ -76,15 +76,15 @@ public class SmartFluidPipeTileEntity extends SmartTileEntity { @Override protected void rotate(BlockState state, MatrixStack ms) { - AttachFace face = state.get(SmartFluidPipeBlock.FACE); + AttachFace face = state.getValue(SmartFluidPipeBlock.FACE); MatrixStacker.of(ms) .rotateY(angleY(state)) .rotateX(face == AttachFace.CEILING ? -45 : 45); } protected float angleY(BlockState state) { - AttachFace face = state.get(SmartFluidPipeBlock.FACE); - float horizontalAngle = AngleHelper.horizontalAngle(state.get(SmartFluidPipeBlock.HORIZONTAL_FACING)); + AttachFace face = state.getValue(SmartFluidPipeBlock.FACE); + float horizontalAngle = AngleHelper.horizontalAngle(state.getValue(SmartFluidPipeBlock.FACING)); if (face == AttachFace.WALL) horizontalAngle += 180; return horizontalAngle; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/StraightPipeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/StraightPipeTileEntity.java index 6b886ede3..56c9ba2b0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/StraightPipeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/StraightPipeTileEntity.java @@ -15,6 +15,8 @@ import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockDisplayReader; +import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes; + public class StraightPipeTileEntity extends SmartTileEntity { public StraightPipeTileEntity(TileEntityType tileEntityTypeIn) { @@ -35,14 +37,14 @@ public class StraightPipeTileEntity extends SmartTileEntity { @Override public boolean canHaveFlowToward(BlockState state, Direction direction) { - return state.contains(AxisPipeBlock.AXIS) && state.get(AxisPipeBlock.AXIS) == direction.getAxis(); + return state.hasProperty(AxisPipeBlock.AXIS) && state.getValue(AxisPipeBlock.AXIS) == direction.getAxis(); } @Override public AttachmentTypes getRenderedRimAttachment(IBlockDisplayReader world, BlockPos pos, BlockState state, Direction direction) { AttachmentTypes attachment = super.getRenderedRimAttachment(world, pos, state, direction); - BlockState otherState = world.getBlockState(pos.offset(direction)); + BlockState otherState = world.getBlockState(pos.relative(direction)); Axis axis = IAxisPipe.getAxisOf(state); Axis otherAxis = IAxisPipe.getAxisOf(otherState); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/TransparentStraightPipeRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/TransparentStraightPipeRenderer.java index 5fc575317..2b65b410d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/TransparentStraightPipeRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/TransparentStraightPipeRenderer.java @@ -47,8 +47,8 @@ public class TransparentStraightPipeRenderer extends SafeTileEntityRenderer customEffects) { FluidStack fluidStack = new FluidStack(AllFluids.POTION.get() - .getStillFluid(), amount); + .getSource(), amount); addPotionToFluidStack(fluidStack, potion); appendEffects(fluidStack, customEffects); return fluidStack; @@ -47,7 +50,7 @@ public class PotionFluid extends VirtualFluid { @Override public int getColor(FluidStack stack) { CompoundNBT tag = stack.getOrCreateTag(); - int color = PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromTag(tag)) | 0xff000000; + int color = PotionUtils.getColor(PotionUtils.getAllEffects(tag)) | 0xff000000; return color; } @@ -56,9 +59,9 @@ public class PotionFluid extends VirtualFluid { CompoundNBT tag = stack.getOrCreateTag(); IItemProvider itemFromBottleType = PotionFluidHandler.itemFromBottleType(NBTHelper.readEnum(tag, "Bottle", BottleType.class)); - return PotionUtils.getPotionTypeFromNBT(tag) - .getNamePrefixed(itemFromBottleType.asItem() - .getTranslationKey() + ".effect."); + return PotionUtils.getPotion(tag) + .getName(itemFromBottleType.asItem() + .getDescriptionId() + ".effect."); } } @@ -80,7 +83,7 @@ public class PotionFluid extends VirtualFluid { CompoundNBT compoundnbt = fs.getOrCreateTag(); ListNBT listnbt = compoundnbt.getList("CustomPotionEffects", 9); for (EffectInstance effectinstance : customEffects) - listnbt.add(effectinstance.write(new CompoundNBT())); + listnbt.add(effectinstance.save(new CompoundNBT())); compoundnbt.put("CustomPotionEffects", listnbt); return fs; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/potion/PotionFluidHandler.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/potion/PotionFluidHandler.java index f577c249c..e53d83064 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/potion/PotionFluidHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/potion/PotionFluidHandler.java @@ -45,12 +45,12 @@ public class PotionFluidHandler { public static FluidIngredient potionIngredient(Potion potion, int amount) { return FluidIngredient.fromFluidStack(FluidHelper.copyStackWithAmount(PotionFluidHandler - .getFluidFromPotionItem(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), potion)), amount)); + .getFluidFromPotionItem(PotionUtils.setPotion(new ItemStack(Items.POTION), potion)), amount)); } public static FluidStack getFluidFromPotionItem(ItemStack stack) { - Potion potion = PotionUtils.getPotionFromItem(stack); - List list = PotionUtils.getFullEffectsFromItem(stack); + Potion potion = PotionUtils.getPotion(stack); + List list = PotionUtils.getCustomEffects(stack); FluidStack fluid = PotionFluid.withEffects(250, potion, list); BottleType bottleTypeFromItem = bottleTypeFromItem(stack); if (potion == Potions.WATER && list.isEmpty() && bottleTypeFromItem == BottleType.REGULAR) @@ -87,31 +87,31 @@ public class PotionFluidHandler { public static ItemStack fillBottle(ItemStack stack, FluidStack availableFluid) { CompoundNBT tag = availableFluid.getOrCreateTag(); ItemStack potionStack = new ItemStack(itemFromBottleType(NBTHelper.readEnum(tag, "Bottle", BottleType.class))); - PotionUtils.addPotionToItemStack(potionStack, PotionUtils.getPotionTypeFromNBT(tag)); - PotionUtils.appendEffects(potionStack, PotionUtils.getFullEffectsFromTag(tag)); + PotionUtils.setPotion(potionStack, PotionUtils.getPotion(tag)); + PotionUtils.setCustomEffects(potionStack, PotionUtils.getCustomEffects(tag)); return potionStack; } // Modified version of PotionUtils#addPotionTooltip @OnlyIn(Dist.CLIENT) public static void addPotionTooltip(FluidStack fs, List tooltip, float p_185182_2_) { - List list = PotionUtils.getEffectsFromTag(fs.getOrCreateTag()); + List list = PotionUtils.getAllEffects(fs.getOrCreateTag()); List> list1 = Lists.newArrayList(); if (list.isEmpty()) { - tooltip.add((new TranslationTextComponent("effect.none")).formatted(TextFormatting.GRAY)); + tooltip.add((new TranslationTextComponent("effect.none")).withStyle(TextFormatting.GRAY)); } else { for (EffectInstance effectinstance : list) { - TranslationTextComponent textcomponent = new TranslationTextComponent(effectinstance.getEffectName()); - Effect effect = effectinstance.getPotion(); - Map map = effect.getAttributeModifierMap(); + TranslationTextComponent textcomponent = new TranslationTextComponent(effectinstance.getDescriptionId()); + Effect effect = effectinstance.getEffect(); + Map map = effect.getAttributeModifiers(); if (!map.isEmpty()) { for (Entry entry : map.entrySet()) { AttributeModifier attributemodifier = entry.getValue(); AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), - effect.getAttributeModifierAmount(effectinstance.getAmplifier(), attributemodifier), + effect.getAttributeModifierValue(effectinstance.getAmplifier(), attributemodifier), attributemodifier.getOperation()); list1.add(new Tuple<>( - entry.getKey().getTranslationKey(), + entry.getKey().getDescriptionId(), attributemodifier1)); } } @@ -123,18 +123,18 @@ public class PotionFluidHandler { if (effectinstance.getDuration() > 20) { textcomponent.append(" (") - .append(EffectUtils.getPotionDurationString(effectinstance, p_185182_2_)) + .append(EffectUtils.formatDuration(effectinstance, p_185182_2_)) .append(")"); } - tooltip.add(textcomponent.formatted(effect.getEffectType() - .getColor())); + tooltip.add(textcomponent.withStyle(effect.getCategory() + .getTooltipFormatting())); } } if (!list1.isEmpty()) { tooltip.add(new StringTextComponent("")); - tooltip.add((new TranslationTextComponent("potion.whenDrank")).formatted(TextFormatting.DARK_PURPLE)); + tooltip.add((new TranslationTextComponent("potion.whenDrank")).withStyle(TextFormatting.DARK_PURPLE)); for (Tuple tuple : list1) { AttributeModifier attributemodifier2 = tuple.getB(); @@ -150,18 +150,18 @@ public class PotionFluidHandler { if (d0 > 0.0D) { tooltip.add((new TranslationTextComponent( "attribute.modifier.plus." + attributemodifier2.getOperation() - .getId(), - ItemStack.DECIMALFORMAT.format(d1), + .toValue(), + ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1), new TranslationTextComponent(tuple.getA()))) - .formatted(TextFormatting.BLUE)); + .withStyle(TextFormatting.BLUE)); } else if (d0 < 0.0D) { d1 = d1 * -1.0D; tooltip.add((new TranslationTextComponent( "attribute.modifier.take." + attributemodifier2.getOperation() - .getId(), - ItemStack.DECIMALFORMAT.format(d1), + .toValue(), + ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1), new TranslationTextComponent(tuple.getA()))) - .formatted(TextFormatting.RED)); + .withStyle(TextFormatting.RED)); } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/PotionMixingRecipeManager.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/PotionMixingRecipeManager.java index 1219f058a..52e356dd0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/PotionMixingRecipeManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/PotionMixingRecipeManager.java @@ -43,8 +43,8 @@ public class PotionMixingRecipeManager { continue; List bottles = new ArrayList<>(); - PotionBrewing.POTION_ITEMS.forEach(i -> { - for (ItemStack itemStack : i.getMatchingStacks()) + PotionBrewing.ALLOWED_CONTAINERS.forEach(i -> { + for (ItemStack itemStack : i.getItems()) bottles.add(itemStack); }); @@ -55,7 +55,7 @@ public class PotionMixingRecipeManager { if (potion == Potions.EMPTY) continue; for (ItemStack stack : bottles) - basicPotions.add(PotionUtils.addPotionToItemStack(stack.copy(), potion)); + basicPotions.add(PotionUtils.setPotion(stack.copy(), potion)); } Set uniqueKeys = new HashSet<>(); @@ -69,7 +69,7 @@ public class PotionMixingRecipeManager { newPotions.clear(); for (ItemStack inputPotionStack : potionFrontier) { - Potion inputPotion = PotionUtils.getPotionFromItem(inputPotionStack); + Potion inputPotion = PotionUtils.getPotion(inputPotionStack); for (ItemStack potionReagent : reagents) { ItemStack outputPotionStack = iBrewingRecipe.getOutput(inputPotionStack.copy(), potionReagent); @@ -89,7 +89,7 @@ public class PotionMixingRecipeManager { continue; if (inputPotionStack.getItem() == outputPotionStack.getItem()) { - Potion outputPotion = PotionUtils.getPotionFromItem(outputPotionStack); + Potion outputPotion = PotionUtils.getPotion(outputPotionStack); if (outputPotion == Potions.WATER) continue; } @@ -100,7 +100,7 @@ public class PotionMixingRecipeManager { fluidFromPotionItem2.setAmount(1000); MixingRecipe mixingRecipe = new ProcessingRecipeBuilder<>(MixingRecipe::new, - Create.asResource("potion_" + recipeIndex++)).require(Ingredient.fromStacks(potionReagent)) + Create.asResource("potion_" + recipeIndex++)).require(Ingredient.of(potionReagent)) .require(FluidIngredient.fromFluidStack(fluidFromPotionItem)) .output(fluidFromPotionItem2) .requiresHeat(HeatCondition.HEATED) @@ -135,7 +135,7 @@ public class PotionMixingRecipeManager { ALL.clear(); getAllBrewingRecipes().forEach(recipe -> { for (Ingredient ingredient : recipe.getIngredients()) { - for (ItemStack itemStack : ingredient.getMatchingStacks()) { + for (ItemStack itemStack : ingredient.getItems()) { ALL.computeIfAbsent(itemStack.getItem(), t -> new ArrayList<>()) .add(recipe); return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/CreativeFluidTankTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/CreativeFluidTankTileEntity.java index e5bf6f58a..2dcff2dc9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/CreativeFluidTankTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/CreativeFluidTankTileEntity.java @@ -9,6 +9,8 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; + public class CreativeFluidTankTileEntity extends FluidTankTileEntity { public CreativeFluidTankTileEntity(TileEntityType tileEntityTypeIn) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java index 3907fd89f..3b4068981 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankBlock.java @@ -47,6 +47,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraft.block.AbstractBlock.Properties; + public class FluidTankBlock extends Block implements IWrenchable, ITE { public static final BooleanProperty TOP = BooleanProperty.create("top"); @@ -66,9 +68,9 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE p_206840_1_) { + protected void createBlockStateDefinition(Builder p_206840_1_) { p_206840_1_.add(TOP, BOTTOM, SHAPE); } @@ -102,15 +104,15 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE ComparatorUtil.fractionToRedstoneLevel(te.getFillState())) .orElse(0); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankConnectivityHandler.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankConnectivityHandler.java index 39b694816..02f1d3116 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankConnectivityHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankConnectivityHandler.java @@ -39,7 +39,7 @@ public class FluidTankConnectivityHandler { TankSearchCache cache = new TankSearchCache(); List frontier = new ArrayList<>(); frontier.add(te); - formTanks(te.getType(), te.getWorld(), cache, frontier); + formTanks(te.getType(), te.getLevel(), cache, frontier); } private static void formTanks(TileEntityType type, IBlockReader world, TankSearchCache cache, @@ -50,7 +50,7 @@ public class FluidTankConnectivityHandler { int minX = Integer.MAX_VALUE; int minZ = Integer.MAX_VALUE; for (FluidTankTileEntity fluidTankTileEntity : frontier) { - BlockPos pos = fluidTankTileEntity.getPos(); + BlockPos pos = fluidTankTileEntity.getBlockPos(); minX = Math.min(pos.getX(), minX); minZ = Math.min(pos.getZ(), minZ); } @@ -59,7 +59,7 @@ public class FluidTankConnectivityHandler { while (!frontier.isEmpty()) { FluidTankTileEntity tank = frontier.remove(0); - BlockPos tankPos = tank.getPos(); + BlockPos tankPos = tank.getBlockPos(); if (visited.contains(tankPos)) continue; @@ -70,8 +70,8 @@ public class FluidTankConnectivityHandler { creationQueue.add(Pair.of(amount, tank)); for (Axis axis : Iterate.axes) { - Direction d = Direction.getFacingFromAxis(AxisDirection.NEGATIVE, axis); - BlockPos next = tankPos.offset(d); + Direction d = Direction.get(AxisDirection.NEGATIVE, axis); + BlockPos next = tankPos.relative(d); if (next.getX() <= minX || next.getZ() <= minZ) continue; @@ -91,9 +91,9 @@ public class FluidTankConnectivityHandler { while (!creationQueue.isEmpty()) { Pair next = creationQueue.poll(); FluidTankTileEntity toCreate = next.getValue(); - if (visited.contains(toCreate.getPos())) + if (visited.contains(toCreate.getBlockPos())) continue; - visited.add(toCreate.getPos()); + visited.add(toCreate.getBlockPos()); tryToFormNewTank(toCreate, cache, false); } @@ -131,15 +131,15 @@ public class FluidTankConnectivityHandler { BlockState state = te.getBlockState(); if (FluidTankBlock.isTank(state)) { - state = state.with(FluidTankBlock.BOTTOM, true); - state = state.with(FluidTankBlock.TOP, te.height == 1); - te.getWorld() - .setBlockState(te.getPos(), state, 22); + state = state.setValue(FluidTankBlock.BOTTOM, true); + state = state.setValue(FluidTankBlock.TOP, te.height == 1); + te.getLevel() + .setBlock(te.getBlockPos(), state, 22); } te.setWindows(te.window); te.onFluidStackChanged(te.tankInventory.getFluid()); - te.markDirty(); + te.setChanged(); } return bestAmount; @@ -150,8 +150,8 @@ public class FluidTankConnectivityHandler { int amount = 0; int height = 0; TileEntityType type = te.getType(); - World world = te.getWorld(); - BlockPos origin = te.getPos(); + World world = te.getLevel(); + BlockPos origin = te.getBlockPos(); LazyOptional capability = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY); FluidTank teTank = (FluidTank) capability.orElse(null); FluidStack fluid = capability.map(ifh -> ifh.getFluidInTank(0)) @@ -163,7 +163,7 @@ public class FluidTankConnectivityHandler { for (int xOffset = 0; xOffset < width; xOffset++) { for (int zOffset = 0; zOffset < width; zOffset++) { - BlockPos pos = origin.add(xOffset, yOffset, zOffset); + BlockPos pos = origin.offset(xOffset, yOffset, zOffset); Optional tank = cache.getOrCache(type, world, pos); if (!tank.isPresent()) break Search; @@ -173,7 +173,7 @@ public class FluidTankConnectivityHandler { if (otherWidth > width) break Search; - BlockPos controllerPos = controller.getPos(); + BlockPos controllerPos = controller.getBlockPos(); if (!controllerPos.equals(origin)) { if (controllerPos.getX() < origin.getX()) break Search; @@ -205,7 +205,7 @@ public class FluidTankConnectivityHandler { for (int yOffset = 0; yOffset < height; yOffset++) { for (int xOffset = 0; xOffset < width; xOffset++) { for (int zOffset = 0; zOffset < width; zOffset++) { - BlockPos pos = origin.add(xOffset, yOffset, zOffset); + BlockPos pos = origin.offset(xOffset, yOffset, zOffset); FluidTankTileEntity tank = tankAt(type, world, pos); if (tank == te) continue; @@ -228,9 +228,9 @@ public class FluidTankConnectivityHandler { BlockState state = world.getBlockState(pos); if (!FluidTankBlock.isTank(state)) continue; - state = state.with(FluidTankBlock.BOTTOM, yOffset == 0); - state = state.with(FluidTankBlock.TOP, yOffset == height - 1); - world.setBlockState(pos, state, 22); + state = state.setValue(FluidTankBlock.BOTTOM, yOffset == 0); + state = state.setValue(FluidTankBlock.TOP, yOffset == height - 1); + world.setBlock(pos, state, 22); } } } @@ -253,8 +253,8 @@ public class FluidTankConnectivityHandler { if (width == 1 && height == 1) return; - World world = te.getWorld(); - BlockPos origin = te.getPos(); + World world = te.getLevel(); + BlockPos origin = te.getBlockPos(); List frontier = new ArrayList<>(); FluidStack toDistribute = te.tankInventory.getFluid() .copy(); @@ -267,7 +267,7 @@ public class FluidTankConnectivityHandler { for (int xOffset = 0; xOffset < width; xOffset++) { for (int zOffset = 0; zOffset < width; zOffset++) { - BlockPos pos = origin.add(xOffset, yOffset, zOffset); + BlockPos pos = origin.offset(xOffset, yOffset, zOffset); FluidTankTileEntity tankAt = tankAt(te.getType(), world, pos); if (tankAt == null) continue; @@ -317,7 +317,7 @@ public class FluidTankConnectivityHandler { @Nullable public static FluidTankTileEntity tankAt(TileEntityType type, IBlockReader world, BlockPos pos) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (te instanceof FluidTankTileEntity && te.getType() == type) return (FluidTankTileEntity) te; return null; @@ -325,7 +325,7 @@ public class FluidTankConnectivityHandler { @Nullable public static FluidTankTileEntity anyTankAt(IBlockReader world, BlockPos pos) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (te instanceof FluidTankTileEntity) return (FluidTankTileEntity) te; return null; @@ -370,8 +370,8 @@ public class FluidTankConnectivityHandler { } public static boolean isConnected(IBlockReader world, BlockPos tankPos, BlockPos otherTankPos) { - TileEntity te1 = world.getTileEntity(tankPos); - TileEntity te2 = world.getTileEntity(otherTankPos); + TileEntity te1 = world.getBlockEntity(tankPos); + TileEntity te2 = world.getBlockEntity(otherTankPos); if (!(te1 instanceof FluidTankTileEntity) || !(te2 instanceof FluidTankTileEntity)) return false; return ((FluidTankTileEntity) te1).getController() diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankGenerator.java index 1a64dbeae..71fdd634b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankGenerator.java @@ -35,9 +35,9 @@ public class FluidTankGenerator extends SpecialBlockStateGen { @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - Boolean top = state.get(FluidTankBlock.TOP); - Boolean bottom = state.get(FluidTankBlock.BOTTOM); - Shape shape = state.get(FluidTankBlock.SHAPE); + Boolean top = state.getValue(FluidTankBlock.TOP); + Boolean bottom = state.getValue(FluidTankBlock.BOTTOM); + Shape shape = state.getValue(FluidTankBlock.SHAPE); String shapeName = "middle"; if (top && bottom) @@ -47,7 +47,7 @@ public class FluidTankGenerator extends SpecialBlockStateGen { else if (bottom) shapeName = "bottom"; - String modelName = shapeName + (shape == Shape.PLAIN ? "" : "_" + shape.getString()); + String modelName = shapeName + (shape == Shape.PLAIN ? "" : "_" + shape.getSerializedName()); if (!prefix.isEmpty()) return prov.models() diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankItem.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankItem.java index cec618615..3687fcf89 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankItem.java @@ -14,6 +14,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; +import net.minecraft.item.Item.Properties; + public class FluidTankItem extends BlockItem { public FluidTankItem(Block p_i48527_1_, Properties p_i48527_2_) { @@ -21,21 +23,21 @@ public class FluidTankItem extends BlockItem { } @Override - public ActionResultType tryPlace(BlockItemUseContext ctx) { - ActionResultType initialResult = super.tryPlace(ctx); - if (!initialResult.isAccepted()) + public ActionResultType place(BlockItemUseContext ctx) { + ActionResultType initialResult = super.place(ctx); + if (!initialResult.consumesAction()) return initialResult; tryMultiPlace(ctx); return initialResult; } @Override - protected boolean onBlockPlaced(BlockPos p_195943_1_, World p_195943_2_, PlayerEntity p_195943_3_, + protected boolean updateCustomBlockEntityTag(BlockPos p_195943_1_, World p_195943_2_, PlayerEntity p_195943_3_, ItemStack p_195943_4_, BlockState p_195943_5_) { MinecraftServer minecraftserver = p_195943_2_.getServer(); if (minecraftserver == null) return false; - CompoundNBT nbt = p_195943_4_.getChildTag("BlockEntityTag"); + CompoundNBT nbt = p_195943_4_.getTagElement("BlockEntityTag"); if (nbt != null) { nbt.remove("Luminosity"); nbt.remove("Size"); @@ -50,23 +52,23 @@ public class FluidTankItem extends BlockItem { } } } - return super.onBlockPlaced(p_195943_1_, p_195943_2_, p_195943_3_, p_195943_4_, p_195943_5_); + return super.updateCustomBlockEntityTag(p_195943_1_, p_195943_2_, p_195943_3_, p_195943_4_, p_195943_5_); } private void tryMultiPlace(BlockItemUseContext ctx) { PlayerEntity player = ctx.getPlayer(); if (player == null) return; - if (player.isSneaking()) + if (player.isShiftKeyDown()) return; - Direction face = ctx.getFace(); + Direction face = ctx.getClickedFace(); if (!face.getAxis() .isVertical()) return; - ItemStack stack = ctx.getItem(); - World world = ctx.getWorld(); - BlockPos pos = ctx.getPos(); - BlockPos placedOnPos = pos.offset(face.getOpposite()); + ItemStack stack = ctx.getItemInHand(); + World world = ctx.getLevel(); + BlockPos pos = ctx.getClickedPos(); + BlockPos placedOnPos = pos.relative(face.getOpposite()); BlockState placedOnState = world.getBlockState(placedOnPos); if (!FluidTankBlock.isTank(placedOnState)) @@ -83,17 +85,17 @@ public class FluidTankItem extends BlockItem { return; int tanksToPlace = 0; - BlockPos startPos = face == Direction.DOWN ? controllerTE.getPos() - .down() - : controllerTE.getPos() - .up(controllerTE.height); + BlockPos startPos = face == Direction.DOWN ? controllerTE.getBlockPos() + .below() + : controllerTE.getBlockPos() + .above(controllerTE.height); if (startPos.getY() != pos.getY()) return; for (int xOffset = 0; xOffset < width; xOffset++) { for (int zOffset = 0; zOffset < width; zOffset++) { - BlockPos offsetPos = startPos.add(xOffset, 0, zOffset); + BlockPos offsetPos = startPos.offset(xOffset, 0, zOffset); BlockState blockState = world.getBlockState(offsetPos); if (FluidTankBlock.isTank(blockState)) continue; @@ -109,14 +111,14 @@ public class FluidTankItem extends BlockItem { for (int xOffset = 0; xOffset < width; xOffset++) { for (int zOffset = 0; zOffset < width; zOffset++) { - BlockPos offsetPos = startPos.add(xOffset, 0, zOffset); + BlockPos offsetPos = startPos.offset(xOffset, 0, zOffset); BlockState blockState = world.getBlockState(offsetPos); if (FluidTankBlock.isTank(blockState)) continue; - BlockItemUseContext context = BlockItemUseContext.func_221536_a(ctx, offsetPos, face); + BlockItemUseContext context = BlockItemUseContext.at(ctx, offsetPos, face); player.getPersistentData() .putBoolean("SilenceTankSound", true); - super.tryPlace(context); + super.place(context); player.getPersistentData() .remove("SilenceTankSound"); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankModel.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankModel.java index b182b7be1..08019b105 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankModel.java @@ -41,7 +41,7 @@ public class FluidTankModel extends CTModel { protected Builder gatherModelData(Builder builder, IBlockDisplayReader world, BlockPos pos, BlockState state) { CullData cullData = new CullData(); for (Direction d : Iterate.horizontalDirections) - cullData.setCulled(d, FluidTankConnectivityHandler.isConnected(world, pos, pos.offset(d))); + cullData.setCulled(d, FluidTankConnectivityHandler.isConnected(world, pos, pos.relative(d))); return super.gatherModelData(builder, world, pos, state).withInitial(CULL_PROPERTY, cullData); } @@ -73,14 +73,14 @@ public class FluidTankModel extends CTModel { if (face.getAxis() .isVertical()) return; - culledFaces[face.getHorizontalIndex()] = cull; + culledFaces[face.get2DDataValue()] = cull; } boolean isCulled(Direction face) { if (face.getAxis() .isVertical()) return false; - return culledFaces[face.getHorizontalIndex()]; + return culledFaces[face.get2DDataValue()]; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankRenderer.java index c3d51df67..fc46d3386 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankRenderer.java @@ -62,14 +62,14 @@ public class FluidTankRenderer extends SafeTileEntityRenderer(); - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay1"))); - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay2") - .formatted(TextFormatting.GRAY))); + .withStyle(TextFormatting.GRAY))); tooltip.add(StringTextComponent.EMPTY); - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay3"))); - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay4"))); tooltip.add(StringTextComponent.EMPTY); - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay5") - .formatted(TextFormatting.GRAY))); - tooltip.add(componentSpacing.copy() + .withStyle(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay6") - .formatted(TextFormatting.GRAY))); + .withStyle(TextFormatting.GRAY))); tooltip.add(StringTextComponent.EMPTY); - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay7"))); - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay8"))); } @Override protected void init() { - this.width = client.getWindow() - .getScaledWidth(); - this.height = client.getWindow() - .getScaledHeight(); + this.width = minecraft.getWindow() + .getGuiScaledWidth(); + this.height = minecraft.getWindow() + .getGuiScaledHeight(); offsetX = AllConfigs.CLIENT.overlayOffsetX.get(); offsetY = AllConfigs.CLIENT.overlayOffsetY.get(); @@ -89,7 +89,7 @@ public class GoggleConfigScreen extends AbstractSimiScreen { int titleLinesCount = 1; int tooltipTextWidth = 0; for (ITextProperties textLine : tooltip) { - int textLineWidth = client.fontRenderer.getWidth(textLine); + int textLineWidth = minecraft.font.width(textLine); if (textLineWidth > tooltipTextWidth) tooltipTextWidth = textLineWidth; } @@ -108,7 +108,7 @@ public class GoggleConfigScreen extends AbstractSimiScreen { protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { int posX = this.width / 2 + offsetX; int posY = this.height / 2 + offsetY; - renderTooltip(ms, tooltip, posX, posY); + renderComponentTooltip(ms, tooltip, posX, posY); // UIRenderHelper.breadcrumbArrow(ms, 50, 50, 100, 50, 20, 10, 0x80aa9999, 0x10aa9999); // UIRenderHelper.breadcrumbArrow(ms, 100, 80, 0, -50, 20, -10, 0x80aa9999, 0x10aa9999); diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java index 2acd72a7a..fcc209268 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java @@ -41,7 +41,7 @@ public class GoggleOverlayRenderer { public static void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, float partialTicks) { - RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver; + RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; if (!(objectMouseOver instanceof BlockRayTraceResult)) return; @@ -56,10 +56,10 @@ public class GoggleOverlayRenderer { BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; Minecraft mc = Minecraft.getInstance(); - ClientWorld world = mc.world; - BlockPos pos = result.getPos(); - ItemStack headSlot = mc.player.getItemStackFromSlot(EquipmentSlotType.HEAD); - TileEntity te = world.getTileEntity(pos); + ClientWorld world = mc.level; + BlockPos pos = result.getBlockPos(); + ItemStack headSlot = mc.player.getItemBySlot(EquipmentSlotType.HEAD); + TileEntity te = world.getBlockEntity(pos); boolean wearingGoggles = AllItems.GOGGLES.isIn(headSlot); @@ -73,14 +73,14 @@ public class GoggleOverlayRenderer { if (hasGoggleInformation && wearingGoggles) { IHaveGoggleInformation gte = (IHaveGoggleInformation) te; - goggleAddedInformation = gte.addToGoggleTooltip(tooltip, mc.player.isSneaking()); + goggleAddedInformation = gte.addToGoggleTooltip(tooltip, mc.player.isShiftKeyDown()); } if (hasHoveringInformation) { if (!tooltip.isEmpty()) tooltip.add(StringTextComponent.EMPTY); IHaveHoveringInformation hte = (IHaveHoveringInformation) te; - hoverAddedInformation = hte.addToTooltip(tooltip, mc.player.isSneaking()); + hoverAddedInformation = hte.addToTooltip(tooltip, mc.player.isShiftKeyDown()); if (goggleAddedInformation && !hoverAddedInformation) tooltip.remove(tooltip.size() - 1); @@ -101,7 +101,7 @@ public class GoggleOverlayRenderer { // check for piston poles if goggles are worn BlockState state = world.getBlockState(pos); if (wearingGoggles && AllBlocks.PISTON_EXTENSION_POLE.has(state)) { - Direction[] directions = Iterate.directionsInAxis(state.get(PistonExtensionPoleBlock.FACING) + Direction[] directions = Iterate.directionsInAxis(state.getValue(PistonExtensionPoleBlock.FACING) .getAxis()); int poles = 1; boolean pistonFound = false; @@ -109,7 +109,7 @@ public class GoggleOverlayRenderer { int attachedPoles = PistonExtensionPoleBlock.PlacementHelper.get() .attachedPoles(world, pos, dir); poles += attachedPoles; - pistonFound |= world.getBlockState(pos.offset(dir, attachedPoles + 1)) + pistonFound |= world.getBlockState(pos.relative(dir, attachedPoles + 1)) .getBlock() instanceof MechanicalPistonBlock; } @@ -118,7 +118,7 @@ public class GoggleOverlayRenderer { if (!tooltip.isEmpty()) tooltip.add(StringTextComponent.EMPTY); - tooltip.add(IHaveGoggleInformation.componentSpacing.copy() + tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy() .append(Lang.translate("gui.goggles.pole_length")) .append(new StringTextComponent(" " + poles))); } @@ -126,17 +126,17 @@ public class GoggleOverlayRenderer { if (tooltip.isEmpty()) return; - ms.push(); + ms.pushPose(); Screen tooltipScreen = new TooltipScreen(null); tooltipScreen.init(mc, mc.getWindow() - .getScaledWidth(), + .getGuiScaledWidth(), mc.getWindow() - .getScaledHeight()); + .getGuiScaledHeight()); int titleLinesCount = 1; int tooltipTextWidth = 0; for (ITextProperties textLine : tooltip) { - int textLineWidth = mc.fontRenderer.getWidth(textLine); + int textLineWidth = mc.font.width(textLine); if (textLineWidth > tooltipTextWidth) tooltipTextWidth = textLineWidth; } @@ -154,13 +154,13 @@ public class GoggleOverlayRenderer { posX = Math.min(posX, tooltipScreen.width - tooltipTextWidth - 20); posY = Math.min(posY, tooltipScreen.height - tooltipHeight - 20); - tooltipScreen.renderTooltip(ms, tooltip, posX, posY); + tooltipScreen.renderComponentTooltip(ms, tooltip, posX, posY); ItemStack item = AllItems.GOGGLES.asStack(); GuiGameElement.of(item) .at(posX + 10, posY - 16, 450) .render(ms); - ms.pop(); + ms.popPose(); } public static final class TooltipScreen extends Screen { @@ -170,9 +170,9 @@ public class GoggleOverlayRenderer { @Override public void init(Minecraft mc, int width, int height) { - this.client = mc; + this.minecraft = mc; this.itemRenderer = mc.getItemRenderer(); - this.textRenderer = mc.fontRenderer; + this.font = mc.font; this.width = width; this.height = height; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesItem.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesItem.java index 3f917e6be..09c31ad95 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesItem.java @@ -14,11 +14,13 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.world.World; +import net.minecraft.item.Item.Properties; + public class GogglesItem extends Item { public GogglesItem(Properties properties) { super(properties); - DispenserBlock.registerDispenseBehavior(this, ArmorItem.DISPENSER_BEHAVIOR); + DispenserBlock.registerBehavior(this, ArmorItem.DISPENSE_ITEM_BEHAVIOR); } @Override @@ -26,12 +28,12 @@ public class GogglesItem extends Item { return EquipmentSlotType.HEAD; } - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { - ItemStack itemstack = playerIn.getHeldItem(handIn); - EquipmentSlotType equipmentslottype = MobEntity.getSlotForItemStack(itemstack); - ItemStack itemstack1 = playerIn.getItemStackFromSlot(equipmentslottype); + public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { + ItemStack itemstack = playerIn.getItemInHand(handIn); + EquipmentSlotType equipmentslottype = MobEntity.getEquipmentSlotForItem(itemstack); + ItemStack itemstack1 = playerIn.getItemBySlot(equipmentslottype); if (itemstack1.isEmpty()) { - playerIn.setItemStackToSlot(equipmentslottype, itemstack.copy()); + playerIn.setItemSlot(equipmentslottype, itemstack.copy()); itemstack.setCount(0); return new ActionResult<>(ActionResultType.SUCCESS, itemstack); } else { @@ -40,7 +42,7 @@ public class GogglesItem extends Item { } public static boolean canSeeParticles(PlayerEntity player) { - for (ItemStack itemStack : player.getArmorInventoryList()) + for (ItemStack itemStack : player.getArmorSlots()) if (AllItems.GOGGLES.isIn(itemStack)) return true; return false; diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java index af546a856..b67227e94 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java @@ -42,7 +42,7 @@ public interface IHaveGoggleInformation { } default boolean containedFluidTooltip(List tooltip, boolean isPlayerSneaking, LazyOptional handler) { - tooltip.add(componentSpacing.copy().append(Lang.translate("gui.goggles.fluid_container"))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.goggles.fluid_container"))); TranslationTextComponent mb = Lang.translate("generic.unit.millibuckets"); Optional resolve = handler.resolve(); if (!resolve.isPresent()) @@ -60,14 +60,14 @@ public interface IHaveGoggleInformation { if (fluidStack.isEmpty()) continue; - ITextComponent fluidName = new TranslationTextComponent(fluidStack.getTranslationKey()).formatted(TextFormatting.GRAY); - ITextComponent contained = new StringTextComponent(format(fluidStack.getAmount())).append(mb).formatted(TextFormatting.GOLD); - ITextComponent slash = new StringTextComponent(" / ").formatted(TextFormatting.GRAY); - ITextComponent capacity = new StringTextComponent(format(tank.getTankCapacity(i))).append(mb).formatted(TextFormatting.DARK_GRAY); + ITextComponent fluidName = new TranslationTextComponent(fluidStack.getTranslationKey()).withStyle(TextFormatting.GRAY); + ITextComponent contained = new StringTextComponent(format(fluidStack.getAmount())).append(mb).withStyle(TextFormatting.GOLD); + ITextComponent slash = new StringTextComponent(" / ").withStyle(TextFormatting.GRAY); + ITextComponent capacity = new StringTextComponent(format(tank.getTankCapacity(i))).append(mb).withStyle(TextFormatting.DARK_GRAY); - tooltip.add(indent.copy() + tooltip.add(indent.plainCopy() .append(fluidName)); - tooltip.add(indent.copy() + tooltip.add(indent.plainCopy() .append(contained) .append(slash) .append(capacity)); @@ -84,10 +84,10 @@ public interface IHaveGoggleInformation { if (!isEmpty) return true; - ITextComponent capacity = Lang.translate("gui.goggles.fluid_container.capacity").formatted(TextFormatting.GRAY); - ITextComponent amount = new StringTextComponent(format(tank.getTankCapacity(0))).append(mb).formatted(TextFormatting.GOLD); + ITextComponent capacity = Lang.translate("gui.goggles.fluid_container.capacity").withStyle(TextFormatting.GRAY); + ITextComponent amount = new StringTextComponent(format(tank.getTankCapacity(0))).append(mb).withStyle(TextFormatting.GOLD); - tooltip.add(indent.copy() + tooltip.add(indent.plainCopy() .append(capacity) .append(amount)); return true; @@ -106,7 +106,7 @@ public interface IHaveGoggleInformation { public void update() { format = NumberFormat.getInstance(Minecraft.getInstance() .getLanguageManager() - .getCurrentLanguage() + .getSelected() .getJavaLocale()); format.setMaximumFractionDigits(2); format.setMinimumFractionDigits(0); diff --git a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyItem.java b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyItem.java index 2ac7b3bbe..f3cb49835 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyItem.java @@ -9,14 +9,16 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; +import net.minecraft.item.Item.Properties; + public class SequencedAssemblyItem extends Item { public SequencedAssemblyItem(Properties p_i48487_1_) { - super(p_i48487_1_.maxStackSize(1)); + super(p_i48487_1_.stacksTo(1)); } @Override - public void fillItemGroup(ItemGroup p_150895_1_, NonNullList p_150895_2_) {} + public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) {} @Override public double getDurabilityForDisplay(ItemStack stack) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipe.java index 9d854412a..a09fef111 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipe.java @@ -56,14 +56,14 @@ public class SequencedAssemblyRecipe implements IRecipe { public static > Optional getRecipe(World world, C inv, IRecipeType type, Class recipeClass) { //return getRecipe(world, inv.getStackInSlot(0), type, recipeClass).filter(r -> r.matches(inv, world)); - return getRecipes(world, inv.getStackInSlot(0), type, recipeClass).filter(r -> r.matches(inv, world)) + return getRecipes(world, inv.getItem(0), type, recipeClass).filter(r -> r.matches(inv, world)) .findFirst(); } public static > Optional getRecipe(World world, ItemStack item, IRecipeType type, Class recipeClass) { List all = world.getRecipeManager() - .listAllOfType(AllRecipeTypes.SEQUENCED_ASSEMBLY.getType()); + .getAllRecipesFor(AllRecipeTypes.SEQUENCED_ASSEMBLY.getType()); for (SequencedAssemblyRecipe sequencedAssemblyRecipe : all) { if (!sequencedAssemblyRecipe.appliesTo(item)) continue; @@ -80,7 +80,7 @@ public class SequencedAssemblyRecipe implements IRecipe { public static > Stream getRecipes(World world, ItemStack item, IRecipeType type, Class recipeClass) { List all = world.getRecipeManager() - .listAllOfType(AllRecipeTypes.SEQUENCED_ASSEMBLY.getType()); + .getAllRecipesFor(AllRecipeTypes.SEQUENCED_ASSEMBLY.getType()); return all.stream() .filter(it -> it.appliesTo(item)) @@ -122,7 +122,7 @@ public class SequencedAssemblyRecipe implements IRecipe { sequence.forEach(sr -> sr.getAsAssemblyRecipe() .addRequiredMachines(machines)); machines.stream() - .map(Ingredient::fromItems) + .map(Ingredient::of) .forEach(list::add); } @@ -176,17 +176,17 @@ public class SequencedAssemblyRecipe implements IRecipe { } @Override - public ItemStack getCraftingResult(RecipeWrapper p_77572_1_) { + public ItemStack assemble(RecipeWrapper p_77572_1_) { return ItemStack.EMPTY; } @Override - public boolean canFit(int p_194133_1_, int p_194133_2_) { + public boolean canCraftInDimensions(int p_194133_1_, int p_194133_2_) { return false; } @Override - public ItemStack getRecipeOutput() { + public ItemStack getResultItem() { return resultPool.get(0) .getStack(); } @@ -210,7 +210,7 @@ public class SequencedAssemblyRecipe implements IRecipe { } @Override - public boolean isDynamic() { + public boolean isSpecial() { return true; } @@ -227,8 +227,8 @@ public class SequencedAssemblyRecipe implements IRecipe { CompoundNBT compound = stack.getTag() .getCompound("SequencedAssembly"); ResourceLocation resourceLocation = new ResourceLocation(compound.getString("id")); - Optional> recipe = Minecraft.getInstance().world.getRecipeManager() - .getRecipe(resourceLocation); + Optional> recipe = Minecraft.getInstance().level.getRecipeManager() + .byKey(resourceLocation); if (!recipe.isPresent()) return; IRecipe iRecipe = recipe.get(); @@ -241,9 +241,9 @@ public class SequencedAssemblyRecipe implements IRecipe { int total = length * sequencedAssemblyRecipe.loops; toolTip.add(new StringTextComponent("")); toolTip.add(Lang.translate("recipe.sequenced_assembly") - .formatted(TextFormatting.GRAY)); + .withStyle(TextFormatting.GRAY)); toolTip.add(Lang.translate("recipe.assembly.progress", step, total) - .formatted(TextFormatting.DARK_GRAY)); + .withStyle(TextFormatting.DARK_GRAY)); int remaining = total - step; for (int i = 0; i < length; i++) { @@ -254,10 +254,10 @@ public class SequencedAssemblyRecipe implements IRecipe { .getDescriptionForAssembly(); if (i == 0) toolTip.add(Lang.translate("recipe.assembly.next", textComponent) - .formatted(TextFormatting.AQUA)); + .withStyle(TextFormatting.AQUA)); else toolTip.add(new StringTextComponent("-> ").append(textComponent) - .formatted(TextFormatting.DARK_AQUA)); + .withStyle(TextFormatting.DARK_AQUA)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipeBuilder.java b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipeBuilder.java index 756209811..9453108aa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipeBuilder.java +++ b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipeBuilder.java @@ -51,11 +51,11 @@ public class SequencedAssemblyRecipeBuilder { } public SequencedAssemblyRecipeBuilder require(IItemProvider ingredient) { - return require(Ingredient.fromItems(ingredient)); + return require(Ingredient.of(ingredient)); } public SequencedAssemblyRecipeBuilder require(ITag.INamedTag tag) { - return require(Ingredient.fromTag(tag)); + return require(Ingredient.of(tag)); } public SequencedAssemblyRecipeBuilder require(Ingredient ingredient) { @@ -102,7 +102,7 @@ public class SequencedAssemblyRecipeBuilder { } @Override - public void serialize(JsonObject json) { + public void serializeRecipeData(JsonObject json) { serializer.write(json, recipe); if (recipeConditions.isEmpty()) return; @@ -113,22 +113,22 @@ public class SequencedAssemblyRecipeBuilder { } @Override - public ResourceLocation getID() { + public ResourceLocation getId() { return id; } @Override - public IRecipeSerializer getSerializer() { + public IRecipeSerializer getType() { return serializer; } @Override - public JsonObject getAdvancementJson() { + public JsonObject serializeAdvancement() { return null; } @Override - public ResourceLocation getAdvancementID() { + public ResourceLocation getAdvancementId() { return null; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipeSerializer.java b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipeSerializer.java index d7c922399..91d54fd21 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipeSerializer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/SequencedAssemblyRecipeSerializer.java @@ -20,7 +20,7 @@ public class SequencedAssemblyRecipeSerializer extends ForgeRegistryEntry nestedRecipes.add(i.toJson())); recipe.resultPool.forEach(p -> results.add(p.serialize())); json.add("transitionalItem", recipe.transitionalItem.serialize()); @@ -31,20 +31,20 @@ public class SequencedAssemblyRecipeSerializer extends ForgeRegistryEntry sr.writeToBuffer(buffer)); buffer.writeVarInt(recipe.resultPool.size()); @@ -55,7 +55,7 @@ public class SequencedAssemblyRecipeSerializer extends ForgeRegistryEntry> { public static SequencedRecipe fromJson(JsonObject json, SequencedAssemblyRecipe parent, int index) { ResourceLocation parentId = parent.getId(); - IRecipe recipe = RecipeManager.deserializeRecipe( + IRecipe recipe = RecipeManager.fromJson( new ResourceLocation(parentId.getNamespace(), parentId.getPath() + "_step_" + index), json); if (recipe instanceof ProcessingRecipe && recipe instanceof IAssemblyRecipe) { ProcessingRecipe processingRecipe = (ProcessingRecipe) recipe; IAssemblyRecipe assemblyRecipe = (IAssemblyRecipe) recipe; if (assemblyRecipe.supportsAssembly()) { - Ingredient transit = Ingredient.fromStacks(parent.getTransitionalItem()); + Ingredient transit = Ingredient.of(parent.getTransitionalItem()); processingRecipe.getIngredients() .set(0, index == 0 ? Ingredient.merge(ImmutableList.of(transit, parent.getIngredient())) : transit); SequencedRecipe sequencedRecipe = new SequencedRecipe<>(processingRecipe); @@ -63,7 +63,7 @@ public class SequencedRecipe> { ProcessingRecipeSerializer serializer = (ProcessingRecipeSerializer) wrapped.getSerializer(); buffer.writeResourceLocation(ForgeRegistries.RECIPE_SERIALIZERS.getKey(serializer)); buffer.writeResourceLocation(wrapped.getId()); - serializer.write(buffer, wrapped); + serializer.toNetwork(buffer, wrapped); } public static SequencedRecipe readFromBuffer(PacketBuffer buffer) { @@ -73,7 +73,7 @@ public class SequencedRecipe> { if (!(serializer instanceof ProcessingRecipeSerializer)) throw new JsonParseException("Not a supported recipe type"); @SuppressWarnings("rawtypes") - ProcessingRecipe recipe = (ProcessingRecipe) serializer.read(resourcelocation1, buffer); + ProcessingRecipe recipe = (ProcessingRecipe) serializer.fromNetwork(resourcelocation1, buffer); return new SequencedRecipe<>(recipe); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java index d4399cde7..22b0bbe7f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java @@ -29,18 +29,18 @@ public class AirFlowParticle extends SimpleAnimatedParticle { protected AirFlowParticle(ClientWorld world, IAirCurrentSource source, double x, double y, double z, IAnimatedSprite sprite) { - super(world, x, y, z, sprite, world.rand.nextFloat() * .5f); + super(world, x, y, z, sprite, world.random.nextFloat() * .5f); this.source = source; - this.particleScale *= 0.75F; - this.maxAge = 40; - canCollide = false; + this.quadSize *= 0.75F; + this.lifetime = 40; + hasPhysics = false; selectSprite(7); Vector3d offset = VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .25f); - this.setPosition(posX + offset.x, posY + offset.y, posZ + offset.z); - this.prevPosX = posX; - this.prevPosY = posY; - this.prevPosZ = posZ; - setAlphaF(.25f); + this.setPos(x + offset.x, y + offset.y, z + offset.z); + this.xo = x; + this.yo = y; + this.zo = z; + setAlpha(.25f); } @Nonnull @@ -54,43 +54,43 @@ public class AirFlowParticle extends SimpleAnimatedParticle { dissipate(); return; } - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - if (this.age++ >= this.maxAge) { - this.setExpired(); + this.xo = this.x; + this.yo = this.y; + this.zo = this.z; + if (this.age++ >= this.lifetime) { + this.remove(); } else { - if (source.getAirCurrent() == null || !source.getAirCurrent().bounds.grow(.25f).contains(posX, posY, posZ)) { + if (source.getAirCurrent() == null || !source.getAirCurrent().bounds.inflate(.25f).contains(x, y, z)) { dissipate(); return; } - Vector3d directionVec = Vector3d.of(source.getAirCurrent().direction.getDirectionVec()); + Vector3d directionVec = Vector3d.atLowerCornerOf(source.getAirCurrent().direction.getNormal()); Vector3d motion = directionVec.scale(1 / 8f); if (!source.getAirCurrent().pushing) motion = motion.scale(-1); - double distance = new Vector3d(posX, posY, posZ).subtract(VecHelper.getCenterOf(source.getAirCurrentPos())) - .mul(directionVec).length() - .5f; + double distance = new Vector3d(x, y, z).subtract(VecHelper.getCenterOf(source.getAirCurrentPos())) + .multiply(directionVec).length() - .5f; if (distance > source.getAirCurrent().maxDistance + 1 || distance < -.25f) { dissipate(); return; } motion = motion.scale(source.getAirCurrent().maxDistance - (distance - 1f)).scale(.5f); - selectSprite((int) MathHelper.clamp((distance / source.getAirCurrent().maxDistance) * 8 + world.rand.nextInt(4), + selectSprite((int) MathHelper.clamp((distance / source.getAirCurrent().maxDistance) * 8 + level.random.nextInt(4), 0, 7)); morphType(distance); - motionX = motion.x; - motionY = motion.y; - motionZ = motion.z; + xd = motion.x; + yd = motion.y; + zd = motion.z; if (this.onGround) { - this.motionX *= 0.7; - this.motionZ *= 0.7; + this.xd *= 0.7; + this.zd *= 0.7; } - this.move(this.motionX, this.motionY, this.motionZ); + this.move(this.xd, this.yd, this.zd); } @@ -102,59 +102,59 @@ public class AirFlowParticle extends SimpleAnimatedParticle { InWorldProcessing.Type type = source.getAirCurrent().getSegmentAt((float) distance); if (type == InWorldProcessing.Type.SPLASHING) { - setColor(ColorHelper.mixColors(0x4499FF, 0x2277FF, world.rand.nextFloat())); - setAlphaF(1f); - selectSprite(world.rand.nextInt(3)); - if (world.rand.nextFloat() < 1 / 32f) - world.addParticle(ParticleTypes.BUBBLE, posX, posY, posZ, motionX * .125f, motionY * .125f, - motionZ * .125f); - if (world.rand.nextFloat() < 1 / 32f) - world.addParticle(ParticleTypes.BUBBLE_POP, posX, posY, posZ, motionX * .125f, motionY * .125f, - motionZ * .125f); + setColor(ColorHelper.mixColors(0x4499FF, 0x2277FF, level.random.nextFloat())); + setAlpha(1f); + selectSprite(level.random.nextInt(3)); + if (level.random.nextFloat() < 1 / 32f) + level.addParticle(ParticleTypes.BUBBLE, x, y, z, xd * .125f, yd * .125f, + zd * .125f); + if (level.random.nextFloat() < 1 / 32f) + level.addParticle(ParticleTypes.BUBBLE_POP, x, y, z, xd * .125f, yd * .125f, + zd * .125f); } if (type == InWorldProcessing.Type.SMOKING) { - setColor(ColorHelper.mixColors(0x0, 0x555555, world.rand.nextFloat())); - setAlphaF(1f); - selectSprite(world.rand.nextInt(3)); - if (world.rand.nextFloat() < 1 / 32f) - world.addParticle(ParticleTypes.SMOKE, posX, posY, posZ, motionX * .125f, motionY * .125f, - motionZ * .125f); - if (world.rand.nextFloat() < 1 / 32f) - world.addParticle(ParticleTypes.LARGE_SMOKE, posX, posY, posZ, motionX * .125f, motionY * .125f, - motionZ * .125f); + setColor(ColorHelper.mixColors(0x0, 0x555555, level.random.nextFloat())); + setAlpha(1f); + selectSprite(level.random.nextInt(3)); + if (level.random.nextFloat() < 1 / 32f) + level.addParticle(ParticleTypes.SMOKE, x, y, z, xd * .125f, yd * .125f, + zd * .125f); + if (level.random.nextFloat() < 1 / 32f) + level.addParticle(ParticleTypes.LARGE_SMOKE, x, y, z, xd * .125f, yd * .125f, + zd * .125f); } if (type == InWorldProcessing.Type.BLASTING) { - setColor(ColorHelper.mixColors(0xFF4400, 0xFF8855, world.rand.nextFloat())); - setAlphaF(.5f); - selectSprite(world.rand.nextInt(3)); - if (world.rand.nextFloat() < 1 / 32f) - world.addParticle(ParticleTypes.FLAME, posX, posY, posZ, motionX * .25f, motionY * .25f, - motionZ * .25f); - if (world.rand.nextFloat() < 1 / 16f) - world.addParticle(new BlockParticleData(ParticleTypes.BLOCK, Blocks.LAVA.getDefaultState()), posX, posY, - posZ, motionX * .25f, motionY * .25f, motionZ * .25f); + setColor(ColorHelper.mixColors(0xFF4400, 0xFF8855, level.random.nextFloat())); + setAlpha(.5f); + selectSprite(level.random.nextInt(3)); + if (level.random.nextFloat() < 1 / 32f) + level.addParticle(ParticleTypes.FLAME, x, y, z, xd * .25f, yd * .25f, + zd * .25f); + if (level.random.nextFloat() < 1 / 16f) + level.addParticle(new BlockParticleData(ParticleTypes.BLOCK, Blocks.LAVA.defaultBlockState()), x, y, + z, xd * .25f, yd * .25f, zd * .25f); } if (type == null) { setColor(0xEEEEEE); - setAlphaF(.25f); + setAlpha(.25f); setSize(.2f, .2f); } } private void dissipate() { - setExpired(); + remove(); } - public int getBrightnessForRender(float partialTick) { - BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ); - return this.world.isBlockPresent(blockpos) ? WorldRenderer.getLightmapCoordinates(world, blockpos) : 0; + public int getLightColor(float partialTick) { + BlockPos blockpos = new BlockPos(this.x, this.y, this.z); + return this.level.isLoaded(blockpos) ? WorldRenderer.getLightColor(level, blockpos) : 0; } private void selectSprite(int index) { - setSprite(field_217584_C.get(index, 8)); + setSprite(sprites.get(index, 8)); } public static class Factory implements IParticleFactory { @@ -164,9 +164,9 @@ public class AirFlowParticle extends SimpleAnimatedParticle { this.spriteSet = animatedSprite; } - public Particle makeParticle(AirFlowParticleData data, ClientWorld worldIn, double x, double y, double z, + public Particle createParticle(AirFlowParticleData data, ClientWorld worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - TileEntity te = worldIn.getTileEntity(new BlockPos(data.posX, data.posY, data.posZ)); + TileEntity te = worldIn.getBlockEntity(new BlockPos(data.posX, data.posY, data.posZ)); if (!(te instanceof IAirCurrentSource)) te = null; return new AirFlowParticle(worldIn, (IAirCurrentSource) te, x, y, z, this.spriteSet); diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticleData.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticleData.java index 74f6d9a32..af874fb00 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticleData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticleData.java @@ -16,6 +16,8 @@ import net.minecraft.util.math.vector.Vector3i; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.particles.IParticleData.IDeserializer; + public class AirFlowParticleData implements IParticleData, ICustomParticleDataWithSprite { public static final Codec CODEC = RecordCodecBuilder.create(i -> @@ -26,7 +28,7 @@ public class AirFlowParticleData implements IParticleData, ICustomParticleDataWi .apply(i, AirFlowParticleData::new)); public static final IParticleData.IDeserializer DESERIALIZER = new IParticleData.IDeserializer() { - public AirFlowParticleData deserialize(ParticleType particleTypeIn, StringReader reader) + public AirFlowParticleData fromCommand(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { reader.expect(' '); int x = reader.readInt(); @@ -37,7 +39,7 @@ public class AirFlowParticleData implements IParticleData, ICustomParticleDataWi return new AirFlowParticleData(x, y, z); } - public AirFlowParticleData read(ParticleType particleTypeIn, PacketBuffer buffer) { + public AirFlowParticleData fromNetwork(ParticleType particleTypeIn, PacketBuffer buffer) { return new AirFlowParticleData(buffer.readInt(), buffer.readInt(), buffer.readInt()); } }; @@ -66,14 +68,14 @@ public class AirFlowParticleData implements IParticleData, ICustomParticleDataWi } @Override - public void write(PacketBuffer buffer) { + public void writeToNetwork(PacketBuffer buffer) { buffer.writeInt(posX); buffer.writeInt(posY); buffer.writeInt(posZ); } @Override - public String getParameters() { + public String writeToString() { return String.format(Locale.ROOT, "%s %d %d %d", AllParticleTypes.AIR_FLOW.parameter(), posX, posY, posZ); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java index ff51b5719..25d7d9f02 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java @@ -26,14 +26,14 @@ public class AirParticle extends SimpleAnimatedParticle { protected AirParticle(ClientWorld world, AirParticleData data, double x, double y, double z, double dx, double dy, double dz, IAnimatedSprite sprite) { - super(world, x, y, z, sprite, world.rand.nextFloat() * .5f); - particleScale *= 0.75F; - canCollide = false; + super(world, x, y, z, sprite, world.random.nextFloat() * .5f); + quadSize *= 0.75F; + hasPhysics = false; - setPosition(posX, posY, posZ); - originX = (float) (prevPosX = posX); - originY = (float) (prevPosY = posY); - originZ = (float) (prevPosZ = posZ); + setPos(x, y, z); + originX = (float) (xo = x); + originY = (float) (yo = y); + originZ = (float) (zo = z); targetX = (float) (x + dx); targetY = (float) (y + dy); targetZ = (float) (z + dz); @@ -45,13 +45,13 @@ public class AirParticle extends SimpleAnimatedParticle { // speed in m/ticks double length = new Vector3d(dx, dy, dz).length(); - maxAge = Math.min((int) (length / data.speed), 60); + lifetime = Math.min((int) (length / data.speed), 60); selectSprite(7); - setAlphaF(.25f); + setAlpha(.25f); if (length == 0) { - setExpired(); - setAlphaF(0); + remove(); + setAlpha(0); } } @@ -61,15 +61,15 @@ public class AirParticle extends SimpleAnimatedParticle { @Override public void tick() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - if (this.age++ >= this.maxAge) { - this.setExpired(); + this.xo = this.x; + this.yo = this.y; + this.zo = this.z; + if (this.age++ >= this.lifetime) { + this.remove(); return; } - float progress = (float) Math.pow(((float) age) / maxAge, drag); + float progress = (float) Math.pow(((float) age) / lifetime, drag); float angle = (progress * 2 * 360 + twirlAngleOffset) % 360; Vector3d twirl = VecHelper.rotate(new Vector3d(0, twirlRadius, 0), angle, twirlAxis); @@ -77,21 +77,21 @@ public class AirParticle extends SimpleAnimatedParticle { float y = (float) (MathHelper.lerp(progress, originY, targetY) + twirl.y); float z = (float) (MathHelper.lerp(progress, originZ, targetZ) + twirl.z); - motionX = x - posX; - motionY = y - posY; - motionZ = z - posZ; + xd = x - x; + yd = y - y; + zd = z - z; - selectSpriteWithAge(field_217584_C); - this.move(this.motionX, this.motionY, this.motionZ); + setSpriteFromAge(sprites); + this.move(this.xd, this.yd, this.zd); } - public int getBrightnessForRender(float partialTick) { - BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ); - return this.world.isBlockPresent(blockpos) ? WorldRenderer.getLightmapCoordinates(world, blockpos) : 0; + public int getLightColor(float partialTick) { + BlockPos blockpos = new BlockPos(this.x, this.y, this.z); + return this.level.isLoaded(blockpos) ? WorldRenderer.getLightColor(level, blockpos) : 0; } private void selectSprite(int index) { - setSprite(field_217584_C.get(index, 8)); + setSprite(sprites.get(index, 8)); } public static class Factory implements IParticleFactory { @@ -101,7 +101,7 @@ public class AirParticle extends SimpleAnimatedParticle { this.spriteSet = animatedSprite; } - public Particle makeParticle(AirParticleData data, ClientWorld worldIn, double x, double y, double z, double xSpeed, + public Particle createParticle(AirParticleData data, ClientWorld worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { return new AirParticle(worldIn, data, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticleData.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticleData.java index 7159756f8..9f214547d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticleData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticleData.java @@ -15,6 +15,8 @@ import net.minecraft.particles.ParticleType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.particles.IParticleData.IDeserializer; + public class AirParticleData implements IParticleData, ICustomParticleDataWithSprite { public static final Codec CODEC = RecordCodecBuilder.create(i -> @@ -25,7 +27,7 @@ public class AirParticleData implements IParticleData, ICustomParticleDataWithSp public static final IParticleData.IDeserializer DESERIALIZER = new IParticleData.IDeserializer() { - public AirParticleData deserialize(ParticleType particleTypeIn, StringReader reader) + public AirParticleData fromCommand(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { reader.expect(' '); float drag = reader.readFloat(); @@ -34,7 +36,7 @@ public class AirParticleData implements IParticleData, ICustomParticleDataWithSp return new AirParticleData(drag, speed); } - public AirParticleData read(ParticleType particleTypeIn, PacketBuffer buffer) { + public AirParticleData fromNetwork(ParticleType particleTypeIn, PacketBuffer buffer) { return new AirParticleData(buffer.readFloat(), buffer.readFloat()); } }; @@ -57,13 +59,13 @@ public class AirParticleData implements IParticleData, ICustomParticleDataWithSp } @Override - public void write(PacketBuffer buffer) { + public void writeToNetwork(PacketBuffer buffer) { buffer.writeFloat(drag); buffer.writeFloat(speed); } @Override - public String getParameters() { + public String writeToString() { return String.format(Locale.ROOT, "%s %f %f", AllParticleTypes.AIR.parameter(), drag, speed); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java index f50fdf30d..bc68081d2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java @@ -53,7 +53,7 @@ public class CubeParticle extends Particle { private static final IParticleRenderType renderType = new IParticleRenderType() { @Override - public void beginRender(BufferBuilder builder, TextureManager textureManager) { + public void begin(BufferBuilder builder, TextureManager textureManager) { RenderSystem.disableTexture(); // transparent, additive blending @@ -72,8 +72,8 @@ public class CubeParticle extends Particle { } @Override - public void finishRender(Tessellator tessellator) { - tessellator.draw(); + public void end(Tessellator tessellator) { + tessellator.end(); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.disableLighting(); @@ -86,9 +86,9 @@ public class CubeParticle extends Particle { public CubeParticle(ClientWorld world, double x, double y, double z, double motionX, double motionY, double motionZ) { super(world, x, y, z); - this.motionX = motionX; - this.motionY = motionY; - this.motionZ = motionZ; + this.xd = motionX; + this.yd = motionY; + this.zd = motionZ; setScale(0.2F); } @@ -99,7 +99,7 @@ public class CubeParticle extends Particle { } public void averageAge(int age) { - this.maxAge = (int) (age + (rand.nextDouble() * 2D - 1D) * 8); + this.lifetime = (int) (age + (random.nextDouble() * 2D - 1D) * 8); } public void setHot(boolean hot) { @@ -111,34 +111,34 @@ public class CubeParticle extends Particle { @Override public void tick() { if (this.hot && this.age > 0) { - if (this.prevPosY == this.posY) { + if (this.yo == this.y) { billowing = true; - field_21507 = false; // Prevent motion being ignored due to vertical collision - if (this.motionX == 0 && this.motionZ == 0) { - Vector3d diff = Vector3d.of(new BlockPos(posX, posY, posZ)).add(0.5, 0.5, 0.5).subtract(posX, posY, posZ); - this.motionX = -diff.x * 0.1; - this.motionZ = -diff.z * 0.1; + stoppedByCollision = false; // Prevent motion being ignored due to vertical collision + if (this.xd == 0 && this.zd == 0) { + Vector3d diff = Vector3d.atLowerCornerOf(new BlockPos(x, y, z)).add(0.5, 0.5, 0.5).subtract(x, y, z); + this.xd = -diff.x * 0.1; + this.zd = -diff.z * 0.1; } - this.motionX *= 1.1; - this.motionY *= 0.9; - this.motionZ *= 1.1; + this.xd *= 1.1; + this.yd *= 0.9; + this.zd *= 1.1; } else if (billowing) { - this.motionY *= 1.2; + this.yd *= 1.2; } } super.tick(); } @Override - public void buildGeometry(IVertexBuilder builder, ActiveRenderInfo renderInfo, float p_225606_3_) { - Vector3d projectedView = renderInfo.getProjectedView(); - float lerpedX = (float) (MathHelper.lerp(p_225606_3_, this.prevPosX, this.posX) - projectedView.getX()); - float lerpedY = (float) (MathHelper.lerp(p_225606_3_, this.prevPosY, this.posY) - projectedView.getY()); - float lerpedZ = (float) (MathHelper.lerp(p_225606_3_, this.prevPosZ, this.posZ) - projectedView.getZ()); + public void render(IVertexBuilder builder, ActiveRenderInfo renderInfo, float p_225606_3_) { + Vector3d projectedView = renderInfo.getPosition(); + float lerpedX = (float) (MathHelper.lerp(p_225606_3_, this.xo, this.x) - projectedView.x()); + float lerpedY = (float) (MathHelper.lerp(p_225606_3_, this.yo, this.y) - projectedView.y()); + float lerpedZ = (float) (MathHelper.lerp(p_225606_3_, this.zo, this.z) - projectedView.z()); // int light = getBrightnessForRender(p_225606_3_); int light = 15728880;// 15<<20 && 15<<4 - double ageMultiplier = 1 - Math.pow(age, 3) / Math.pow(maxAge, 3); + double ageMultiplier = 1 - Math.pow(age, 3) / Math.pow(lifetime, 3); for (int i = 0; i < 6; i++) { // 6 faces to a cube @@ -151,9 +151,9 @@ public class CubeParticle extends Particle { Vector3d normal = CUBE_NORMALS[i]; builder.vertex(vec.x, vec.y, vec.z) - .color(particleRed, particleGreen, particleBlue, particleAlpha) - .texture(0, 0) - .light(light) + .color(rCol, gCol, bCol, alpha) + .uv(0, 0) + .uv2(light) .normal((float) normal.x, (float) normal.y, (float) normal.z) .endVertex(); } @@ -170,7 +170,7 @@ public class CubeParticle extends Particle { public Factory() {} @Override - public Particle makeParticle(CubeParticleData data, ClientWorld world, double x, double y, double z, double motionX, + public Particle createParticle(CubeParticleData data, ClientWorld world, double x, double y, double z, double motionX, double motionY, double motionZ) { CubeParticle particle = new CubeParticle(world, x, y, z, motionX, motionY, motionZ); particle.setColor(data.r, data.g, data.b); diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticleData.java b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticleData.java index 442a68b49..39c21b7b9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticleData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticleData.java @@ -15,6 +15,8 @@ import net.minecraft.particles.ParticleType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.particles.IParticleData.IDeserializer; + public class CubeParticleData implements IParticleData, ICustomParticleData { public static final Codec CODEC = RecordCodecBuilder.create(i -> @@ -29,7 +31,7 @@ public class CubeParticleData implements IParticleData, ICustomParticleData DESERIALIZER = new IParticleData.IDeserializer() { @Override - public CubeParticleData deserialize(ParticleType type, StringReader reader) throws CommandSyntaxException { + public CubeParticleData fromCommand(ParticleType type, StringReader reader) throws CommandSyntaxException { reader.expect(' '); float r = reader.readFloat(); reader.expect(' '); @@ -46,7 +48,7 @@ public class CubeParticleData implements IParticleData, ICustomParticleData type, PacketBuffer buffer) { + public CubeParticleData fromNetwork(ParticleType type, PacketBuffer buffer) { return new CubeParticleData(buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readInt(), buffer.readBoolean()); } }; @@ -93,7 +95,7 @@ public class CubeParticleData implements IParticleData, ICustomParticleData> 16 & 255; j = j + (int) (f * 15.0F * 16.0F); @@ -76,20 +76,20 @@ public class HeaterParticle extends SimpleAnimatedParticle { @Override public void tick() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - if (this.age++ >= this.maxAge) { - this.setExpired(); + this.xo = this.x; + this.yo = this.y; + this.zo = this.z; + if (this.age++ >= this.lifetime) { + this.remove(); } else { - this.selectSpriteWithAge(animatedSprite); - this.move(this.motionX, this.motionY, this.motionZ); - this.motionX *= (double) 0.96F; - this.motionY *= (double) 0.96F; - this.motionZ *= (double) 0.96F; + this.setSpriteFromAge(animatedSprite); + this.move(this.xd, this.yd, this.zd); + this.xd *= (double) 0.96F; + this.yd *= (double) 0.96F; + this.zd *= (double) 0.96F; if (this.onGround) { - this.motionX *= (double) 0.7F; - this.motionZ *= (double) 0.7F; + this.xd *= (double) 0.7F; + this.zd *= (double) 0.7F; } } } @@ -102,7 +102,7 @@ public class HeaterParticle extends SimpleAnimatedParticle { } @Override - public Particle makeParticle(HeaterParticleData data, ClientWorld worldIn, double x, double y, double z, double vx, + public Particle createParticle(HeaterParticleData data, ClientWorld worldIn, double x, double y, double z, double vx, double vy, double vz) { return new HeaterParticle(worldIn, data.r, data.g, data.b, x, y, z, vx, vy, vz, this.spriteSet); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/HeaterParticleData.java b/src/main/java/com/simibubi/create/content/contraptions/particle/HeaterParticleData.java index a547ba995..a9a08dfba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/HeaterParticleData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/HeaterParticleData.java @@ -18,6 +18,8 @@ import net.minecraft.particles.ParticleType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.particles.IParticleData.IDeserializer; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class HeaterParticleData implements IParticleData, ICustomParticleDataWithSprite { @@ -32,7 +34,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit public static final IParticleData.IDeserializer DESERIALIZER = new IParticleData.IDeserializer() { @Override - public HeaterParticleData deserialize(ParticleType arg0, StringReader reader) + public HeaterParticleData fromCommand(ParticleType arg0, StringReader reader) throws CommandSyntaxException { reader.expect(' '); float r = reader.readFloat(); @@ -44,7 +46,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit } @Override - public HeaterParticleData read(ParticleType type, PacketBuffer buffer) { + public HeaterParticleData fromNetwork(ParticleType type, PacketBuffer buffer) { return new HeaterParticleData(buffer.readFloat(), buffer.readFloat(), buffer.readFloat()); } }; @@ -80,7 +82,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit } @Override - public String getParameters() { + public String writeToString() { return String.format(Locale.ROOT, "%s %f %f %f", AllParticleTypes.HEATER_PARTICLE.parameter(), r, g, b); } @@ -90,7 +92,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit } @Override - public void write(PacketBuffer buffer) { + public void writeToNetwork(PacketBuffer buffer) { buffer.writeFloat(r); buffer.writeFloat(g); buffer.writeFloat(b); diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/ICustomParticleData.java b/src/main/java/com/simibubi/create/content/contraptions/particle/ICustomParticleData.java index 8e067799c..8d76c0788 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/ICustomParticleData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/ICustomParticleData.java @@ -20,7 +20,7 @@ public interface ICustomParticleData { return new ParticleType(false, getDeserializer()) { @Override - public Codec getCodec() { + public Codec codec() { return ICustomParticleData.this.getCodec(this); } }; @@ -31,7 +31,7 @@ public interface ICustomParticleData { @OnlyIn(Dist.CLIENT) public default void register(ParticleType type, ParticleManager particles) { - particles.registerFactory(type, getFactory()); + particles.register(type, getFactory()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/ICustomParticleDataWithSprite.java b/src/main/java/com/simibubi/create/content/contraptions/particle/ICustomParticleDataWithSprite.java index 65dd04908..30c554549 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/ICustomParticleDataWithSprite.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/ICustomParticleDataWithSprite.java @@ -19,7 +19,7 @@ public interface ICustomParticleDataWithSprite extends return new ParticleType(false, getDeserializer()) { @Override - public Codec getCodec() { + public Codec codec() { return ICustomParticleDataWithSprite.this.getCodec(this); } }; @@ -37,7 +37,7 @@ public interface ICustomParticleDataWithSprite extends @Override @OnlyIn(Dist.CLIENT) public default void register(ParticleType type, ParticleManager particles) { - particles.registerFactory(type, getMetaFactory()); + particles.register(type, getMetaFactory()); } } 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 ffb2f1996..28b6290b9 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 @@ -31,15 +31,15 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { private RotationIndicatorParticle(ClientWorld world, double x, double y, double z, int color, float radius1, float radius2, float speed, Axis axis, int lifeSpan, boolean isVisible, IAnimatedSprite sprite) { super(world, x, y, z, sprite, 0); - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; + this.xd = 0; + this.yd = 0; + this.zd = 0; this.origin = new Vector3d(x, y, z); - this.particleScale *= 0.75F; - this.maxAge = lifeSpan + this.rand.nextInt(32); - this.setColorFade(color); + this.quadSize *= 0.75F; + this.lifetime = lifeSpan + this.random.nextInt(32); + this.setFadeColor(color); this.setColor(ColorHelper.mixColors(color, 0xFFFFFF, .5f)); - this.selectSpriteWithAge(sprite); + this.setSpriteFromAge(sprite); this.radius1 = radius1; this.radius = radius1; this.radius2 = radius2; @@ -48,9 +48,9 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { this.isVisible = isVisible; this.offset = axis.isHorizontal() ? new Vector3d(0, 1, 0) : new Vector3d(1, 0, 0); move(0, 0, 0); - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + this.xo = this.x; + this.yo = this.y; + this.zo = this.z; } @Override @@ -60,21 +60,21 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { } @Override - public void buildGeometry(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { + public void render(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { if (!isVisible) return; - super.buildGeometry(buffer, renderInfo, partialTicks); + super.render(buffer, renderInfo, partialTicks); } public void move(double x, double y, double z) { - float time = AnimationTickHolder.getTicks(world); - float angle = (float) ((time * speed) % 360) - (speed / 2 * age * (((float) age) / maxAge)); + float time = AnimationTickHolder.getTicks(level); + float angle = (float) ((time * speed) % 360) - (speed / 2 * age * (((float) age) / lifetime)); if (speed < 0 && axis.isVertical()) angle += 180; Vector3d position = VecHelper.rotate(this.offset.scale(radius), angle, axis).add(origin); - posX = position.x; - posY = position.y; - posZ = position.z; + x = position.x; + y = position.y; + z = position.z; } public static class Factory implements IParticleFactory { @@ -84,11 +84,11 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { this.spriteSet = animatedSprite; } - public Particle makeParticle(RotationIndicatorParticleData data, ClientWorld worldIn, double x, double y, double z, + public Particle createParticle(RotationIndicatorParticleData data, ClientWorld worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { Minecraft mc = Minecraft.getInstance(); ClientPlayerEntity player = mc.player; - boolean visible = worldIn != mc.world || player != null && GogglesItem.canSeeParticles(player); + boolean visible = worldIn != mc.level || player != null && GogglesItem.canSeeParticles(player); return new RotationIndicatorParticle(worldIn, x, y, z, data.color, data.radius1, data.radius2, data.speed, data.getAxis(), data.lifeSpan, visible, this.spriteSet); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticleData.java b/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticleData.java index 23fb007e9..f69c5f031 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticleData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticleData.java @@ -19,6 +19,8 @@ import net.minecraft.util.Direction.Axis; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.particles.IParticleData.IDeserializer; + public class RotationIndicatorParticleData implements IParticleData, ICustomParticleDataWithSprite { @@ -58,7 +60,7 @@ public class RotationIndicatorParticleData public static final IParticleData.IDeserializer DESERIALIZER = new IParticleData.IDeserializer() { - public RotationIndicatorParticleData deserialize(ParticleType particleTypeIn, + public RotationIndicatorParticleData fromCommand(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { reader.expect(' '); int color = reader.readInt(); @@ -75,7 +77,7 @@ public class RotationIndicatorParticleData return new RotationIndicatorParticleData(color, speed, rad1, rad2, lifeSpan, axis); } - public RotationIndicatorParticleData read(ParticleType particleTypeIn, + public RotationIndicatorParticleData fromNetwork(ParticleType particleTypeIn, PacketBuffer buffer) { return new RotationIndicatorParticleData(buffer.readInt(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readInt(), buffer.readChar()); @@ -113,7 +115,7 @@ public class RotationIndicatorParticleData } @Override - public void write(PacketBuffer buffer) { + public void writeToNetwork(PacketBuffer buffer) { buffer.writeInt(color); buffer.writeFloat(speed); buffer.writeFloat(radius1); @@ -123,7 +125,7 @@ public class RotationIndicatorParticleData } @Override - public String getParameters() { + public String writeToString() { return String.format(Locale.ROOT, "%s %d %.2f %.2f %.2f %d %c", AllParticleTypes.ROTATION_INDICATOR.parameter(), color, speed, radius1, radius2, lifeSpan, axis); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java index 3829c5339..61ada67e1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java @@ -48,13 +48,15 @@ import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; +import net.minecraft.block.AbstractBlock.Properties; + public class BasinBlock extends Block implements ITE, IWrenchable { - public static final DirectionProperty FACING = BlockStateProperties.FACING_EXCEPT_UP; + public static final DirectionProperty FACING = BlockStateProperties.FACING_HOPPER; public BasinBlock(Properties p_i48440_1_) { super(p_i48440_1_); - setDefaultState(getDefaultState().with(FACING, Direction.DOWN)); + registerDefaultState(defaultBlockState().setValue(FACING, Direction.DOWN)); } @Override @@ -63,13 +65,13 @@ public class BasinBlock extends Block implements ITE, IWrenchab } @Override - protected void fillStateContainer(Builder p_206840_1_) { - super.fillStateContainer(p_206840_1_.add(FACING)); + protected void createBlockStateDefinition(Builder p_206840_1_) { + super.createBlockStateDefinition(p_206840_1_.add(FACING)); } @Override - public boolean isValidPosition(BlockState state, IWorldReader world, BlockPos pos) { - TileEntity tileEntity = world.getTileEntity(pos.up()); + public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { + TileEntity tileEntity = world.getBlockEntity(pos.above()); if (tileEntity instanceof BasinOperatingTileEntity) return false; return true; @@ -82,15 +84,15 @@ public class BasinBlock extends Block implements ITE, IWrenchab @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - if (!context.getWorld().isRemote) - withTileEntityDo(context.getWorld(), context.getPos(), bte -> bte.onWrenched(context.getFace())); + if (!context.getLevel().isClientSide) + withTileEntityDo(context.getLevel(), context.getClickedPos(), bte -> bte.onWrenched(context.getClickedFace())); return ActionResultType.SUCCESS; } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - ItemStack heldItem = player.getHeldItem(handIn); + ItemStack heldItem = player.getItemInHand(handIn); return onTileEntityUse(worldIn, pos, te -> { if (!heldItem.isEmpty()) { @@ -124,7 +126,7 @@ public class BasinBlock extends Block implements ITE, IWrenchab success = true; } if (success) - worldIn.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, .2f, + worldIn.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .2f, 1f + Create.RANDOM.nextFloat()); te.onEmptied(); return ActionResultType.SUCCESS; @@ -132,16 +134,16 @@ public class BasinBlock extends Block implements ITE, IWrenchab } @Override - public void onLanded(IBlockReader worldIn, Entity entityIn) { - super.onLanded(worldIn, entityIn); - if (!AllBlocks.BASIN.has(worldIn.getBlockState(entityIn.getBlockPos()))) + public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + super.updateEntityAfterFallOn(worldIn, entityIn); + if (!AllBlocks.BASIN.has(worldIn.getBlockState(entityIn.blockPosition()))) return; if (!(entityIn instanceof ItemEntity)) return; if (!entityIn.isAlive()) return; ItemEntity itemEntity = (ItemEntity) entityIn; - withTileEntityDo(worldIn, entityIn.getBlockPos(), te -> { + withTileEntityDo(worldIn, entityIn.blockPosition(), te -> { // Tossed items bypass the quarter-stack limit te.inputInventory.withMaxStackSize(64); @@ -151,9 +153,9 @@ public class BasinBlock extends Block implements ITE, IWrenchab if (insertItem.isEmpty()) { itemEntity.remove(); - if (!itemEntity.world.isRemote) - AllTriggers.triggerForNearbyPlayers(AllTriggers.BASIN_THROW, itemEntity.world, - itemEntity.getBlockPos(), 3); + if (!itemEntity.level.isClientSide) + AllTriggers.triggerForNearbyPlayers(AllTriggers.BASIN_THROW, itemEntity.level, + itemEntity.blockPosition(), 3); return; } @@ -162,7 +164,7 @@ public class BasinBlock extends Block implements ITE, IWrenchab } @Override - public VoxelShape getRaytraceShape(BlockState p_199600_1_, IBlockReader p_199600_2_, BlockPos p_199600_3_) { + public VoxelShape getInteractionShape(BlockState p_199600_1_, IBlockReader p_199600_2_, BlockPos p_199600_3_) { return AllShapes.BASIN_RAYTRACE_SHAPE; } @@ -179,25 +181,25 @@ public class BasinBlock extends Block implements ITE, IWrenchab } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (!state.hasTileEntity() || state.getBlock() == newState.getBlock()) return; TileEntityBehaviour.destroy(worldIn, pos, FilteringBehaviour.TYPE); withTileEntityDo(worldIn, pos, te -> { ItemHelper.dropContents(worldIn, pos, te.inputInventory); ItemHelper.dropContents(worldIn, pos, te.outputInventory); - te.spoutputBuffer.forEach(is -> Block.spawnAsEntity(worldIn, pos, is)); + te.spoutputBuffer.forEach(is -> Block.popResource(worldIn, pos, is)); }); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } @Override - public boolean hasComparatorInputOverride(BlockState state) { + public boolean hasAnalogOutputSignal(BlockState state) { return true; } @Override - public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { return getTileEntityOptional(worldIn, pos).map(BasinTileEntity::getInputInventory) .map(ItemHelper::calcRedstoneFromInventory) .orElse(0); @@ -209,8 +211,8 @@ public class BasinBlock extends Block implements ITE, IWrenchab } public static boolean canOutputTo(IBlockReader world, BlockPos basinPos, Direction direction) { - BlockPos neighbour = basinPos.offset(direction); - BlockPos output = neighbour.down(); + BlockPos neighbour = basinPos.relative(direction); + BlockPos output = neighbour.below(); BlockState blockState = world.getBlockState(neighbour); if (FunnelBlock.isFunnel(blockState)) { @@ -220,7 +222,7 @@ public class BasinBlock extends Block implements ITE, IWrenchab .isEmpty()) { return false; } else { - TileEntity tileEntity = world.getTileEntity(output); + TileEntity tileEntity = world.getBlockEntity(output); if (tileEntity instanceof BeltTileEntity) { BeltTileEntity belt = (BeltTileEntity) tileEntity; return belt.getSpeed() == 0 || belt.getMovementFacing() != direction.getOpposite(); @@ -235,7 +237,7 @@ public class BasinBlock extends Block implements ITE, IWrenchab } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinGenerator.java index fe96055ac..5df06ac99 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinGenerator.java @@ -18,13 +18,13 @@ public class BasinGenerator extends SpecialBlockStateGen { @Override protected int getYRotation(BlockState state) { - return horizontalAngle(state.get(BasinBlock.FACING)); + return horizontalAngle(state.getValue(BasinBlock.FACING)); } @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - if (state.get(BasinBlock.FACING).getAxis().isVertical()) + if (state.getValue(BasinBlock.FACING).getAxis().isVertical()) return AssetLookup.partialBaseModel(ctx, prov); return AssetLookup.partialBaseModel(ctx, prov, "directional"); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinMovementBehaviour.java index 8c51a8fa8..1bf64f5ae 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinMovementBehaviour.java @@ -31,9 +31,9 @@ public class BasinMovementBehaviour extends MovementBehaviour { public void tick(MovementContext context) { super.tick(context); if (context.temporaryData == null || (boolean) context.temporaryData) { - Vector3d facingVec = context.rotation.apply(Vector3d.of(Direction.UP.getDirectionVec())); + Vector3d facingVec = context.rotation.apply(Vector3d.atLowerCornerOf(Direction.UP.getNormal())); facingVec.normalize(); - if (Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z) == Direction.DOWN) + if (Direction.getNearest(facingVec.x, facingVec.y, facingVec.z) == Direction.DOWN) dump(context, facingVec); } } @@ -46,8 +46,8 @@ public class BasinMovementBehaviour extends MovementBehaviour { continue; ItemEntity itemEntity = new ItemEntity(context.world, context.position.x, context.position.y, context.position.z, itemStackHandler.getStackInSlot(i)); - itemEntity.setMotion(facingVec.scale(.05)); - context.world.addEntity(itemEntity); + itemEntity.setDeltaMovement(facingVec.scale(.05)); + context.world.addFreshEntity(itemEntity); itemStackHandler.setStackInSlot(i, ItemStack.EMPTY); } context.tileData.put(key, itemStackHandler.serializeNBT()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinOperatingTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinOperatingTileEntity.java index 7710ca28e..9eae5b034 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinOperatingTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinOperatingTileEntity.java @@ -61,7 +61,7 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { return true; if (isRunning()) return true; - if (world == null || world.isRemote) + if (level == null || level.isClientSide) return true; if (!getBasin().filter(BasinTileEntity::canContinueProcessing) .isPresent()) @@ -105,8 +105,8 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { if (!BasinRecipe.apply(basin, currentRecipe)) return; Optional processedRecipeTrigger = getProcessedRecipeTrigger(); - if (world != null && !world.isRemote && processedRecipeTrigger.isPresent()) - AllTriggers.triggerForNearbyPlayers(processedRecipeTrigger.get(), world, pos, 4); + if (level != null && !level.isClientSide && processedRecipeTrigger.isPresent()) + AllTriggers.triggerForNearbyPlayers(processedRecipeTrigger.get(), level, worldPosition, 4); basin.inputTank.sendDataImmediately(); // Continue mixing @@ -119,7 +119,7 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { } protected List> getMatchingRecipes() { - List> list = RecipeFinder.get(getRecipeCacheKey(), world, this::matchStaticFilters); + List> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters); return list.stream() .filter(this::matchBasinRecipe) .sorted((r1, r2) -> r2.getIngredients() @@ -132,9 +132,9 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { protected abstract void onBasinRemoved(); protected Optional getBasin() { - if (world == null) + if (level == null) return Optional.empty(); - TileEntity basinTE = world.getTileEntity(pos.down(2)); + TileEntity basinTE = level.getBlockEntity(worldPosition.below(2)); if (!(basinTE instanceof BasinTileEntity)) return Optional.empty(); return Optional.of((BasinTileEntity) basinTE); diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRecipe.java index 80e7a6349..a45124772 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRecipe.java @@ -35,7 +35,7 @@ public class BasinRecipe extends ProcessingRecipe { if (filter == null) return false; - boolean filterTest = filter.test(recipe.getRecipeOutput()); + boolean filterTest = filter.test(recipe.getResultItem()); if (recipe instanceof BasinRecipe) { BasinRecipe basinRecipe = (BasinRecipe) recipe; if (basinRecipe.getRollableResults() @@ -66,9 +66,9 @@ public class BasinRecipe extends ProcessingRecipe { if (availableItems == null || availableFluids == null) return false; - HeatLevel heat = BasinTileEntity.getHeatLevelOf(basin.getWorld() - .getBlockState(basin.getPos() - .down(1))); + HeatLevel heat = BasinTileEntity.getHeatLevelOf(basin.getLevel() + .getBlockState(basin.getBlockPos() + .below(1))); if (isBasinRecipe && !((BasinRecipe) recipe).getRequiredHeat() .testBlazeBurner(heat)) return false; @@ -77,7 +77,7 @@ public class BasinRecipe extends ProcessingRecipe { List recipeOutputFluids = new ArrayList<>(); List ingredients = new LinkedList<>(recipe.getIngredients()); - ingredients.sort(Comparator.comparingInt(i -> i.getMatchingStacks().length)); + ingredients.sort(Comparator.comparingInt(i -> i.getItems().length)); List fluidIngredients = isBasinRecipe ? ((BasinRecipe) recipe).getFluidIngredients() : Collections.emptyList(); @@ -101,7 +101,7 @@ public class BasinRecipe extends ProcessingRecipe { continue; // Catalyst items are never consumed if (extracted.hasContainerItem() && extracted.getContainerItem() - .isItemEqual(extracted)) + .sameItem(extracted)) continue Ingredients; if (!simulate) availableItems.extractItem(slot, 1, false); @@ -155,7 +155,7 @@ public class BasinRecipe extends ProcessingRecipe { recipeOutputItems.addAll(((BasinRecipe) recipe).rollResults()); recipeOutputFluids.addAll(((BasinRecipe) recipe).getFluidResults()); } else - recipeOutputItems.add(recipe.getRecipeOutput()); + recipeOutputItems.add(recipe.getResultItem()); } if (!basin.acceptOutputs(recipeOutputItems, recipeOutputFluids, simulate)) @@ -168,7 +168,7 @@ public class BasinRecipe extends ProcessingRecipe { public static BasinRecipe convertShapeless(IRecipe recipe) { BasinRecipe basinRecipe = new ProcessingRecipeBuilder<>(BasinRecipe::new, recipe.getId()).withItemIngredients(recipe.getIngredients()) - .withSingleItemOutput(recipe.getRecipeOutput()) + .withSingleItemOutput(recipe.getResultItem()) .build(); return basinRecipe; } 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 c19142761..4f13b695e 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 @@ -42,9 +42,9 @@ public class BasinRenderer extends SmartTileEntityRenderer { float fluidLevel = renderFluids(basin, partialTicks, ms, buffer, light, overlay); float level = MathHelper.clamp(fluidLevel - .3f, .125f, .6f); - ms.push(); + ms.pushPose(); - BlockPos pos = basin.getPos(); + BlockPos pos = basin.getBlockPos(); ms.translate(.5, .2f, .5); MatrixStacker.of(ms) .rotateY(basin.ingredientRotation.getValue(partialTicks)); @@ -68,12 +68,12 @@ public class BasinRenderer extends SmartTileEntityRenderer { if (stack.isEmpty()) continue; - ms.push(); + ms.pushPose(); if (fluidLevel > 0) { ms.translate(0, (MathHelper.sin( - AnimationTickHolder.getRenderTime(basin.getWorld()) / 12f + anglePartition * itemCount) + 1.5f) + AnimationTickHolder.getRenderTime(basin.getLevel()) / 12f + anglePartition * itemCount) + 1.5f) * 1 / 32f, 0); } @@ -85,34 +85,34 @@ public class BasinRenderer extends SmartTileEntityRenderer { .rotateX(65); for (int i = 0; i <= stack.getCount() / 8; i++) { - ms.push(); + ms.pushPose(); Vector3d vec = VecHelper.offsetRandomly(Vector3d.ZERO, r, 1 / 16f); ms.translate(vec.x, vec.y, vec.z); renderItem(ms, buffer, light, overlay, stack); - ms.pop(); + ms.popPose(); } - ms.pop(); + ms.popPose(); itemCount--; } - ms.pop(); + ms.popPose(); BlockState blockState = basin.getBlockState(); if (!(blockState.getBlock() instanceof BasinBlock)) return; - Direction direction = blockState.get(BasinBlock.FACING); + Direction direction = blockState.getValue(BasinBlock.FACING); if (direction == Direction.DOWN) return; - Vector3d directionVec = Vector3d.of(direction.getDirectionVec()); + Vector3d directionVec = Vector3d.atLowerCornerOf(direction.getNormal()); Vector3d outVec = VecHelper.getCenterOf(BlockPos.ZERO) .add(directionVec.scale(.55) .subtract(0, 1 / 2f, 0)); - boolean outToBasin = basin.getWorld() - .getBlockState(basin.getPos() - .offset(direction)) + boolean outToBasin = basin.getLevel() + .getBlockState(basin.getBlockPos() + .relative(direction)) .getBlock() instanceof BasinBlock; for (IntAttached intAttached : basin.visualizedOutputItems) { @@ -121,7 +121,7 @@ public class BasinRenderer extends SmartTileEntityRenderer { if (!outToBasin && progress > .35f) continue; - ms.push(); + ms.pushPose(); MatrixStacker.of(ms) .translate(outVec) .translate(new Vector3d(0, Math.max(-.55f, -(progress * progress * 2)), 0)) @@ -129,14 +129,14 @@ public class BasinRenderer extends SmartTileEntityRenderer { .rotateY(AngleHelper.horizontalAngle(direction)) .rotateX(progress * 180); renderItem(ms, buffer, light, overlay, intAttached.getValue()); - ms.pop(); + ms.popPose(); } } protected void renderItem(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, ItemStack stack) { Minecraft.getInstance() .getItemRenderer() - .renderItem(stack, TransformType.GROUND, light, overlay, ms, buffer); + .renderStatic(stack, TransformType.GROUND, light, overlay, ms, buffer); } protected float renderFluids(BasinTileEntity basin, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java index 91e3b3c4c..e71fa7d2b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java @@ -152,7 +152,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor preferredSpoutput = NBTHelper.readEnum(compound, "PreferredSpoutput", Direction.class); disabledSpoutputs.clear(); ListNBT disabledList = compound.getList("DisabledSpoutput", NBT.TAG_STRING); - disabledList.forEach(d -> disabledSpoutputs.add(Direction.valueOf(((StringNBT) d).getString()))); + disabledList.forEach(d -> disabledSpoutputs.add(Direction.valueOf(((StringNBT) d).getAsString()))); spoutputBuffer = NBTHelper.readItemList(compound.getList("Overflow", NBT.TAG_COMPOUND)); spoutputFluidBuffer = NBTHelper.readCompoundList(compound.getList("FluidOverflow", NBT.TAG_COMPOUND), FluidStack::loadFluidStackFromNBT); @@ -161,7 +161,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor return; NBTHelper.iterateCompoundList(compound.getList("VisualizedItems", NBT.TAG_COMPOUND), - c -> visualizedOutputItems.add(IntAttached.with(OUTPUT_ANIMATION_TIME, ItemStack.read(c)))); + c -> visualizedOutputItems.add(IntAttached.with(OUTPUT_ANIMATION_TIME, ItemStack.of(c)))); NBTHelper.iterateCompoundList(compound.getList("VisualizedFluids", NBT.TAG_COMPOUND), c -> visualizedOutputFluids .add(IntAttached.with(OUTPUT_ANIMATION_TIME, FluidStack.loadFluidStackFromNBT(c)))); @@ -176,7 +176,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (preferredSpoutput != null) NBTHelper.writeEnum(compound, "PreferredSpoutput", preferredSpoutput); ListNBT disabledList = new ListNBT(); - disabledSpoutputs.forEach(d -> disabledList.add(StringNBT.of(d.name()))); + disabledSpoutputs.forEach(d -> disabledList.add(StringNBT.valueOf(d.name()))); compound.put("DisabledSpoutput", disabledList); compound.put("Overflow", NBTHelper.writeItemList(spoutputBuffer)); compound.put("FluidOverflow", @@ -198,11 +198,11 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor } @Override - public void remove() { + public void setRemoved() { onEmptied(); itemCapability.invalidate(); fluidCapability.invalidate(); - super.remove(); + super.setRemoved(); } @Nonnull @@ -224,10 +224,10 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor public void lazyTick() { super.lazyTick(); updateSpoutput(); - if (!world.isRemote) + if (!level.isClientSide) return; - TileEntity tileEntity = world.getTileEntity(pos.up(2)); + TileEntity tileEntity = level.getBlockEntity(worldPosition.above(2)); if (!(tileEntity instanceof MechanicalMixerTileEntity)) { setAreFluidsMoving(false); return; @@ -238,7 +238,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor public void onWrenched(Direction face) { BlockState blockState = getBlockState(); - Direction currentFacing = blockState.get(BasinBlock.FACING); + Direction currentFacing = blockState.getValue(BasinBlock.FACING); disabledSpoutputs.remove(face); if (currentFacing == face) { @@ -252,41 +252,41 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor } private void updateSpoutput() { - if (world.isRemote) + if (level.isClientSide) return; BlockState blockState = getBlockState(); - Direction currentFacing = blockState.get(BasinBlock.FACING); + Direction currentFacing = blockState.getValue(BasinBlock.FACING); if (currentFacing != Direction.DOWN) notifyChangeOfContents(); Direction newFacing = Direction.DOWN; for (Direction test : Iterate.horizontalDirections) { - boolean canOutputTo = BasinBlock.canOutputTo(world, pos, test); + boolean canOutputTo = BasinBlock.canOutputTo(level, worldPosition, test); if (canOutputTo && !disabledSpoutputs.contains(test)) newFacing = test; } - if (preferredSpoutput != null && BasinBlock.canOutputTo(world, pos, preferredSpoutput) + if (preferredSpoutput != null && BasinBlock.canOutputTo(level, worldPosition, preferredSpoutput) && preferredSpoutput != Direction.UP) newFacing = preferredSpoutput; if (newFacing != currentFacing) - world.setBlockState(pos, blockState.with(BasinBlock.FACING, newFacing)); + level.setBlockAndUpdate(worldPosition, blockState.setValue(BasinBlock.FACING, newFacing)); } @Override public void tick() { super.tick(); - if (world.isRemote) { + if (level.isClientSide) { createFluidParticles(); tickVisualizedOutputs(); ingredientRotationSpeed.tickChaser(); ingredientRotation.setValue(ingredientRotation.getValue() + ingredientRotationSpeed.getValue()); } - if ((!spoutputBuffer.isEmpty() || !spoutputFluidBuffer.isEmpty()) && !world.isRemote) + if ((!spoutputBuffer.isEmpty() || !spoutputFluidBuffer.isEmpty()) && !level.isClientSide) tryClearingSpoutputOverflow(); if (!contentsChanged) return; @@ -295,12 +295,12 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor getOperator().ifPresent(te -> te.basinChecker.scheduleUpdate()); for (Direction offset : Iterate.horizontalDirections) { - BlockPos toUpdate = pos.up() - .offset(offset); - BlockState stateToUpdate = world.getBlockState(toUpdate); + BlockPos toUpdate = worldPosition.above() + .relative(offset); + BlockState stateToUpdate = level.getBlockState(toUpdate); if (stateToUpdate.getBlock() instanceof BasinBlock - && stateToUpdate.get(BasinBlock.FACING) == offset.getOpposite()) { - TileEntity te = world.getTileEntity(toUpdate); + && stateToUpdate.getValue(BasinBlock.FACING) == offset.getOpposite()) { + TileEntity te = level.getBlockEntity(toUpdate); if (te instanceof BasinTileEntity) ((BasinTileEntity) te).contentsChanged = true; } @@ -311,15 +311,15 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor BlockState blockState = getBlockState(); if (!(blockState.getBlock() instanceof BasinBlock)) return; - Direction direction = blockState.get(BasinBlock.FACING); - TileEntity te = world.getTileEntity(pos.down() - .offset(direction)); + Direction direction = blockState.getValue(BasinBlock.FACING); + TileEntity te = level.getBlockEntity(worldPosition.below() + .relative(direction)); FilteringBehaviour filter = null; InvManipulationBehaviour inserter = null; if (te != null) { - filter = TileEntityBehaviour.get(world, te.getPos(), FilteringBehaviour.TYPE); - inserter = TileEntityBehaviour.get(world, te.getPos(), InvManipulationBehaviour.TYPE); + filter = TileEntityBehaviour.get(level, te.getBlockPos(), FilteringBehaviour.TYPE); + inserter = TileEntityBehaviour.get(level, te.getBlockPos(), InvManipulationBehaviour.TYPE); } IItemHandler targetInv = te == null ? null @@ -336,7 +336,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor ItemStack itemStack = iterator.next(); if (direction == Direction.DOWN) { - Block.spawnAsEntity(world, pos, itemStack); + Block.popResource(level, worldPosition, itemStack); iterator.remove(); update = true; continue; @@ -417,9 +417,9 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor } private Optional getOperator() { - if (world == null) + if (level == null) return Optional.empty(); - TileEntity te = world.getTileEntity(pos.up(2)); + TileEntity te = level.getBlockEntity(worldPosition.above(2)); if (te instanceof BasinOperatingTileEntity) return Optional.of((BasinOperatingTileEntity) te); return Optional.empty(); @@ -443,7 +443,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor @Override @OnlyIn(Dist.CLIENT) - public double getMaxRenderDistanceSquared() { + public double getViewDistance() { return 256; } @@ -465,14 +465,14 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (!(blockState.getBlock() instanceof BasinBlock)) return false; - Direction direction = blockState.get(BasinBlock.FACING); + Direction direction = blockState.getValue(BasinBlock.FACING); if (direction != Direction.DOWN) { - TileEntity te = world.getTileEntity(pos.down() - .offset(direction)); + TileEntity te = level.getBlockEntity(worldPosition.below() + .relative(direction)); InvManipulationBehaviour inserter = - te == null ? null : TileEntityBehaviour.get(world, te.getPos(), InvManipulationBehaviour.TYPE); + te == null ? null : TileEntityBehaviour.get(level, te.getBlockPos(), InvManipulationBehaviour.TYPE); IItemHandler targetInv = te == null ? null : te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite()) .orElse(inserter == null ? null : inserter.getInventory()); @@ -488,7 +488,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor return true; for (ItemStack itemStack : outputItems) { if (itemStack.hasContainerItem() && itemStack.getContainerItem() - .isItemEqual(itemStack)) + .sameItem(itemStack)) continue; spoutputBuffer.add(itemStack.copy()); } @@ -507,7 +507,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor for (ItemStack itemStack : outputItems) { // Catalyst items are never consumed if (itemStack.hasContainerItem() && itemStack.getContainerItem() - .isItemEqual(itemStack)) + .sameItem(itemStack)) continue; if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), simulate) .isEmpty()) @@ -537,8 +537,8 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor } public static HeatLevel getHeatLevelOf(BlockState state) { - if (state.contains(BlazeBurnerBlock.HEAT_LEVEL)) - return state.get(BlazeBurnerBlock.HEAT_LEVEL); + if (state.hasProperty(BlazeBurnerBlock.HEAT_LEVEL)) + return state.getValue(BlazeBurnerBlock.HEAT_LEVEL); return AllTags.AllBlockTags.FAN_HEATERS.matches(state) ? HeatLevel.SMOULDERING : HeatLevel.NONE; } @@ -560,7 +560,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor } private void createFluidParticles() { - Random r = world.rand; + Random r = level.random; if (!visualizedOutputFluids.isEmpty()) createOutputFluidParticles(r); @@ -585,7 +585,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor float fluidLevel = MathHelper.clamp(totalUnits / 2000, 0, 1); float rim = 2 / 16f; float space = 12 / 16f; - float surface = pos.getY() + rim + space * fluidLevel + 1 / 32f; + float surface = worldPosition.getY() + rim + space * fluidLevel + 1 / 32f; if (areFluidsMoving) { createMovingFluidParticles(surface, segments); @@ -598,9 +598,9 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor for (TankSegment tankSegment : behaviour.getTanks()) { if (tankSegment.isEmpty(0)) continue; - float x = pos.getX() + rim + space * r.nextFloat(); - float z = pos.getZ() + rim + space * r.nextFloat(); - world.addOptionalParticle( + float x = worldPosition.getX() + rim + space * r.nextFloat(); + float z = worldPosition.getZ() + rim + space * r.nextFloat(); + level.addAlwaysVisibleParticle( new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), tankSegment.getRenderedFluid()), x, surface, z, 0, 0, 0); } @@ -611,11 +611,11 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor BlockState blockState = getBlockState(); if (!(blockState.getBlock() instanceof BasinBlock)) return; - Direction direction = blockState.get(BasinBlock.FACING); + Direction direction = blockState.getValue(BasinBlock.FACING); if (direction == Direction.DOWN) return; - Vector3d directionVec = Vector3d.of(direction.getDirectionVec()); - Vector3d outVec = VecHelper.getCenterOf(pos) + Vector3d directionVec = Vector3d.atLowerCornerOf(direction.getNormal()); + Vector3d outVec = VecHelper.getCenterOf(worldPosition) .add(directionVec.scale(.65) .subtract(0, 1 / 4f, 0)); Vector3d outMotion = directionVec.scale(1 / 16f) @@ -626,7 +626,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor FluidStack fluidStack = ia.getValue(); IParticleData fluidParticle = FluidFX.getFluidParticle(fluidStack); Vector3d m = VecHelper.offsetRandomly(outMotion, r, 1 / 16f); - world.addOptionalParticle(fluidParticle, outVec.x, outVec.y, outVec.z, m.x, m.y, m.z); + level.addAlwaysVisibleParticle(fluidParticle, outVec.x, outVec.y, outVec.z, m.x, m.y, m.z); }); } } @@ -634,7 +634,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor private void createMovingFluidParticles(float surface, int segments) { Vector3d pointer = new Vector3d(1, 0, 0).scale(1 / 16f); float interval = 360f / segments; - Vector3d centerOf = VecHelper.getCenterOf(pos); + Vector3d centerOf = VecHelper.getCenterOf(worldPosition); float intervalOffset = (AnimationTickHolder.getTicks() * 18) % 360; int currentSegment = 0; @@ -646,9 +646,9 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor continue; float angle = interval * (1 + currentSegment) + intervalOffset; Vector3d vec = centerOf.add(VecHelper.rotate(pointer, angle, Axis.Y)); - world.addOptionalParticle( + level.addAlwaysVisibleParticle( new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), tankSegment.getRenderedFluid()), - vec.getX(), surface, vec.getZ(), 1, 0, 0); + vec.x(), surface, vec.z(), 1, 0, 0); currentSegment++; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/EmptyingByBasin.java b/src/main/java/com/simibubi/create/content/contraptions/processing/EmptyingByBasin.java index 8545a81d1..cddadc1cf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/EmptyingByBasin.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/EmptyingByBasin.java @@ -27,7 +27,7 @@ public class EmptyingByBasin { if (stack.getItem() instanceof PotionItem) return true; - wrapper.setInventorySlotContents(0, stack); + wrapper.setItem(0, stack); if (AllRecipeTypes.EMPTYING.find(wrapper, world) .isPresent()) return true; @@ -52,7 +52,7 @@ public class EmptyingByBasin { if (stack.getItem() instanceof PotionItem) return PotionFluidHandler.emptyPotion(stack, simulate); - wrapper.setInventorySlotContents(0, stack); + wrapper.setItem(0, stack); Optional> recipe = AllRecipeTypes.EMPTYING.find(wrapper, world); if (recipe.isPresent()) { EmptyingRecipe emptyingRecipe = (EmptyingRecipe) recipe.get(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/EmptyingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/processing/EmptyingRecipe.java index fbed9d886..8c7cebfab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/EmptyingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/EmptyingRecipe.java @@ -15,7 +15,7 @@ public class EmptyingRecipe extends ProcessingRecipe { @Override public boolean matches(RecipeWrapper inv, World p_77569_2_) { - return ingredients.get(0).test(inv.getStackInSlot(0)); + return ingredients.get(0).test(inv.getItem(0)); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java b/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java index b433755f1..5f97cb6c1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java @@ -57,11 +57,11 @@ public class InWorldProcessing { public static Type byBlock(IBlockReader reader, BlockPos pos) { BlockState blockState = reader.getBlockState(pos); FluidState fluidState = reader.getFluidState(pos); - if (fluidState.getFluid() == Fluids.WATER || fluidState.getFluid() == Fluids.FLOWING_WATER) + if (fluidState.getType() == Fluids.WATER || fluidState.getType() == Fluids.FLOWING_WATER) return Type.SPLASHING; Block block = blockState.getBlock(); if (block == Blocks.FIRE || AllBlocks.LIT_BLAZE_BURNER.has(blockState) - || (BlockTags.CAMPFIRES.contains(block) && blockState.method_28500(CampfireBlock.LIT).orElse(false)) + || (BlockTags.CAMPFIRES.contains(block) && blockState.getOptionalValue(CampfireBlock.LIT).orElse(false)) || getHeatLevelOf(blockState) == BlazeBurnerBlock.HeatLevel.SMOULDERING) return Type.SMOKING; if (block == Blocks.LAVA || getHeatLevelOf(blockState).isAtLeast(BlazeBurnerBlock.HeatLevel.FADING)) @@ -79,7 +79,7 @@ public class InWorldProcessing { CompoundNBT processing = compound.getCompound("Processing"); if (Type.valueOf(processing.getString("Type")) != type) { - boolean canProcess = canProcess(entity.getItem(), type, entity.world); + boolean canProcess = canProcess(entity.getItem(), type, entity.level); processing.putString("Type", type.name()); if (!canProcess) processing.putInt("Time", -1); @@ -90,32 +90,32 @@ public class InWorldProcessing { return false; } } - return canProcess(entity.getItem(), type, entity.world); + return canProcess(entity.getItem(), type, entity.level); } private static boolean canProcess(ItemStack stack, Type type, World world) { if (type == Type.BLASTING) { - WRAPPER.setInventorySlotContents(0, stack); + WRAPPER.setItem(0, stack); Optional smeltingRecipe = world.getRecipeManager() - .getRecipe(IRecipeType.SMELTING, WRAPPER, world); + .getRecipeFor(IRecipeType.SMELTING, WRAPPER, world); if (smeltingRecipe.isPresent()) return true; - WRAPPER.setInventorySlotContents(0, stack); + WRAPPER.setItem(0, stack); Optional blastingRecipe = world.getRecipeManager() - .getRecipe(IRecipeType.BLASTING, WRAPPER, world); + .getRecipeFor(IRecipeType.BLASTING, WRAPPER, world); if (blastingRecipe.isPresent()) return true; - return !stack.getItem().isFireproof(); + return !stack.getItem().isFireResistant(); } if (type == Type.SMOKING) { - WRAPPER.setInventorySlotContents(0, stack); + WRAPPER.setItem(0, stack); Optional recipe = world.getRecipeManager() - .getRecipe(IRecipeType.SMOKING, WRAPPER, world); + .getRecipeFor(IRecipeType.SMOKING, WRAPPER, world); return recipe.isPresent(); } @@ -126,7 +126,7 @@ public class InWorldProcessing { } public static boolean isWashable(ItemStack stack, World world) { - SPLASHING_WRAPPER.setInventorySlotContents(0, stack); + SPLASHING_WRAPPER.setItem(0, stack); Optional recipe = AllRecipeTypes.SPLASHING.find(SPLASHING_WRAPPER, world); return recipe.isPresent(); } @@ -134,7 +134,7 @@ public class InWorldProcessing { public static void applyProcessing(ItemEntity entity, Type type) { if (decrementProcessingTime(entity, type) != 0) return; - List stacks = process(entity.getItem(), type, entity.world); + List stacks = process(entity.getItem(), type, entity.level); if (stacks == null) return; if (stacks.isEmpty()) { @@ -143,9 +143,9 @@ public class InWorldProcessing { } entity.setItem(stacks.remove(0)); for (ItemStack additional : stacks) { - ItemEntity entityIn = new ItemEntity(entity.world, entity.getX(), entity.getY(), entity.getZ(), additional); - entityIn.setMotion(entity.getMotion()); - entity.world.addEntity(entityIn); + ItemEntity entityIn = new ItemEntity(entity.level, entity.getX(), entity.getY(), entity.getZ(), additional); + entityIn.setDeltaMovement(entity.getDeltaMovement()); + entity.level.addFreshEntity(entityIn); } } @@ -181,29 +181,29 @@ public class InWorldProcessing { private static List process(ItemStack stack, Type type, World world) { if (type == Type.SPLASHING) { - SPLASHING_WRAPPER.setInventorySlotContents(0, stack); + SPLASHING_WRAPPER.setItem(0, stack); Optional recipe = AllRecipeTypes.SPLASHING.find(SPLASHING_WRAPPER, world); if (recipe.isPresent()) return applyRecipeOn(stack, recipe.get()); return null; } - WRAPPER.setInventorySlotContents(0, stack); + WRAPPER.setItem(0, stack); Optional smokingRecipe = world.getRecipeManager() - .getRecipe(IRecipeType.SMOKING, WRAPPER, world); + .getRecipeFor(IRecipeType.SMOKING, WRAPPER, world); if (type == Type.BLASTING) { if (!smokingRecipe.isPresent()) { - WRAPPER.setInventorySlotContents(0, stack); + WRAPPER.setItem(0, stack); Optional smeltingRecipe = world.getRecipeManager() - .getRecipe(IRecipeType.SMELTING, WRAPPER, world); + .getRecipeFor(IRecipeType.SMELTING, WRAPPER, world); if (smeltingRecipe.isPresent()) return applyRecipeOn(stack, smeltingRecipe.get()); - WRAPPER.setInventorySlotContents(0, stack); + WRAPPER.setItem(0, stack); Optional blastingRecipe = world.getRecipeManager() - .getRecipe(IRecipeType.BLASTING, WRAPPER, world); + .getRecipeFor(IRecipeType.BLASTING, WRAPPER, world); if (blastingRecipe.isPresent()) return applyRecipeOn(stack, blastingRecipe.get()); @@ -253,9 +253,9 @@ public class InWorldProcessing { } entity.setItem(stacks.remove(0)); for (ItemStack additional : stacks) { - ItemEntity entityIn = new ItemEntity(entity.world, entity.getX(), entity.getY(), entity.getZ(), additional); - entityIn.setMotion(entity.getMotion()); - entity.world.addEntity(entityIn); + ItemEntity entityIn = new ItemEntity(entity.level, entity.getX(), entity.getY(), entity.getZ(), additional); + entityIn.setDeltaMovement(entity.getDeltaMovement()); + entity.level.addFreshEntity(entityIn); } } @@ -285,7 +285,7 @@ public class InWorldProcessing { } } } else { - ItemStack out = recipe.getRecipeOutput() + ItemStack out = recipe.getResultItem() .copy(); stacks = ItemHelper.multipliedOutput(stackIn, out); } @@ -294,9 +294,9 @@ public class InWorldProcessing { } public static void spawnParticlesForProcessing(@Nullable World world, Vector3d vec, Type type) { - if (world == null || !world.isRemote) + if (world == null || !world.isClientSide) return; - if (world.rand.nextInt(8) != 0) + if (world.random.nextInt(8) != 0) return; switch (type) { @@ -309,10 +309,10 @@ public class InWorldProcessing { case SPLASHING: Vector3d color = ColorHelper.getRGB(0x0055FF); world.addParticle(new RedstoneParticleData((float) color.x, (float) color.y, (float) color.z, 1), - vec.x + (world.rand.nextFloat() - .5f) * .5f, vec.y + .5f, vec.z + (world.rand.nextFloat() - .5f) * .5f, + vec.x + (world.random.nextFloat() - .5f) * .5f, vec.y + .5f, vec.z + (world.random.nextFloat() - .5f) * .5f, 0, 1 / 8f, 0); - world.addParticle(ParticleTypes.SPIT, vec.x + (world.rand.nextFloat() - .5f) * .5f, vec.y + .5f, - vec.z + (world.rand.nextFloat() - .5f) * .5f, 0, 1 / 8f, 0); + world.addParticle(ParticleTypes.SPIT, vec.x + (world.random.nextFloat() - .5f) * .5f, vec.y + .5f, + vec.z + (world.random.nextFloat() - .5f) * .5f, 0, 1 / 8f, 0); break; default: break; diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingOutput.java b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingOutput.java index 8303e0686..c83f362e8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingOutput.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingOutput.java @@ -79,16 +79,16 @@ public class ProcessingOutput { throw new JsonSyntaxException("ProcessingOutput must be a json object"); JsonObject json = je.getAsJsonObject(); - String itemId = JSONUtils.getString(json, "item"); - int count = JSONUtils.getInt(json, "count", 1); - float chance = JSONUtils.hasField(json, "chance") ? JSONUtils.getFloat(json, "chance") : 1; + String itemId = JSONUtils.getAsString(json, "item"); + int count = JSONUtils.getAsInt(json, "count", 1); + float chance = JSONUtils.isValidNode(json, "chance") ? JSONUtils.getAsFloat(json, "chance") : 1; ItemStack itemstack = new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemId)), count); - if (JSONUtils.hasField(json, "nbt")) { + if (JSONUtils.isValidNode(json, "nbt")) { try { JsonElement element = json.get("nbt"); - itemstack.setTag(JsonToNBT.getTagFromJson( - element.isJsonObject() ? Create.GSON.toJson(element) : JSONUtils.getString(element, "nbt"))); + itemstack.setTag(JsonToNBT.parseTag( + element.isJsonObject() ? Create.GSON.toJson(element) : JSONUtils.convertToString(element, "nbt"))); } catch (CommandSyntaxException e) { e.printStackTrace(); } @@ -98,12 +98,12 @@ public class ProcessingOutput { } public void write(PacketBuffer buf) { - buf.writeItemStack(getStack()); + buf.writeItem(getStack()); buf.writeFloat(getChance()); } public static ProcessingOutput read(PacketBuffer buf) { - return new ProcessingOutput(buf.readItemStack(), buf.readFloat()); + return new ProcessingOutput(buf.readItem(), buf.readFloat()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipe.java index 00317d125..4f4dff700 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipe.java @@ -169,17 +169,17 @@ public abstract class ProcessingRecipe implements IRecipe< // IRecipe<> paperwork @Override - public ItemStack getCraftingResult(T inv) { - return getRecipeOutput(); + public ItemStack assemble(T inv) { + return getResultItem(); } @Override - public boolean canFit(int width, int height) { + public boolean canCraftInDimensions(int width, int height) { return true; } @Override - public ItemStack getRecipeOutput() { + public ItemStack getResultItem() { return getRollableResults().isEmpty() ? ItemStack.EMPTY : getRollableResults().get(0) .getStack(); @@ -191,7 +191,7 @@ public abstract class ProcessingRecipe implements IRecipe< } @Override - public boolean isDynamic() { + public boolean isSpecial() { return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeBuilder.java b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeBuilder.java index 16f747acb..5099023e8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeBuilder.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeBuilder.java @@ -41,7 +41,7 @@ public class ProcessingRecipeBuilder> { } public ProcessingRecipeBuilder withItemIngredients(Ingredient... ingredients) { - return withItemIngredients(NonNullList.from(Ingredient.EMPTY, ingredients)); + return withItemIngredients(NonNullList.of(Ingredient.EMPTY, ingredients)); } public ProcessingRecipeBuilder withItemIngredients(NonNullList ingredients) { @@ -54,7 +54,7 @@ public class ProcessingRecipeBuilder> { } public ProcessingRecipeBuilder withItemOutputs(ProcessingOutput... outputs) { - return withItemOutputs(NonNullList.from(ProcessingOutput.EMPTY, outputs)); + return withItemOutputs(NonNullList.of(ProcessingOutput.EMPTY, outputs)); } public ProcessingRecipeBuilder withItemOutputs(NonNullList outputs) { @@ -63,7 +63,7 @@ public class ProcessingRecipeBuilder> { } public ProcessingRecipeBuilder withFluidIngredients(FluidIngredient... ingredients) { - return withFluidIngredients(NonNullList.from(FluidIngredient.EMPTY, ingredients)); + return withFluidIngredients(NonNullList.of(FluidIngredient.EMPTY, ingredients)); } public ProcessingRecipeBuilder withFluidIngredients(NonNullList ingredients) { @@ -72,7 +72,7 @@ public class ProcessingRecipeBuilder> { } public ProcessingRecipeBuilder withFluidOutputs(FluidStack... outputs) { - return withFluidOutputs(NonNullList.from(FluidStack.EMPTY, outputs)); + return withFluidOutputs(NonNullList.of(FluidStack.EMPTY, outputs)); } public ProcessingRecipeBuilder withFluidOutputs(NonNullList outputs) { @@ -105,11 +105,11 @@ public class ProcessingRecipeBuilder> { // Datagen shortcuts public ProcessingRecipeBuilder require(ITag.INamedTag tag) { - return require(Ingredient.fromTag(tag)); + return require(Ingredient.of(tag)); } public ProcessingRecipeBuilder require(IItemProvider item) { - return require(Ingredient.fromItems(item)); + return require(Ingredient.of(item)); } public ProcessingRecipeBuilder require(Ingredient ingredient) { @@ -235,7 +235,7 @@ public class ProcessingRecipeBuilder> { } @Override - public void serialize(JsonObject json) { + public void serializeRecipeData(JsonObject json) { serializer.write(json, recipe); if (recipeConditions.isEmpty()) return; @@ -246,22 +246,22 @@ public class ProcessingRecipeBuilder> { } @Override - public ResourceLocation getID() { + public ResourceLocation getId() { return id; } @Override - public IRecipeSerializer getSerializer() { + public IRecipeSerializer getType() { return serializer; } @Override - public JsonObject getAdvancementJson() { + public JsonObject serializeAdvancement() { return null; } @Override - public ResourceLocation getAdvancementID() { + public ResourceLocation getAdvancementId() { return null; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeSerializer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeSerializer.java index 031a7f973..9d83395c3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeSerializer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeSerializer.java @@ -35,7 +35,7 @@ public class ProcessingRecipeSerializer> extends F JsonArray jsonOutputs = new JsonArray(); recipe.getIngredients() - .forEach(i -> jsonIngredients.add(i.serialize())); + .forEach(i -> jsonIngredients.add(i.toJson())); recipe.getFluidIngredients() .forEach(i -> jsonIngredients.add(i.serialize())); @@ -65,16 +65,16 @@ public class ProcessingRecipeSerializer> extends F NonNullList results = NonNullList.create(); NonNullList fluidResults = NonNullList.create(); - for (JsonElement je : JSONUtils.getJsonArray(json, "ingredients")) { + for (JsonElement je : JSONUtils.getAsJsonArray(json, "ingredients")) { if (FluidIngredient.isFluidIngredient(je)) fluidIngredients.add(FluidIngredient.deserialize(je)); else - ingredients.add(Ingredient.deserialize(je)); + ingredients.add(Ingredient.fromJson(je)); } - for (JsonElement je : JSONUtils.getJsonArray(json, "results")) { + for (JsonElement je : JSONUtils.getAsJsonArray(json, "results")) { JsonObject jsonObject = je.getAsJsonObject(); - if (JSONUtils.hasField(jsonObject, "fluid")) + if (JSONUtils.isValidNode(jsonObject, "fluid")) fluidResults.add(FluidHelper.deserializeFluidStack(jsonObject)); else results.add(ProcessingOutput.deserialize(je)); @@ -85,10 +85,10 @@ public class ProcessingRecipeSerializer> extends F .withFluidIngredients(fluidIngredients) .withFluidOutputs(fluidResults); - if (JSONUtils.hasField(json, "processingTime")) - builder.duration(JSONUtils.getInt(json, "processingTime")); - if (JSONUtils.hasField(json, "heatRequirement")) - builder.requiresHeat(HeatCondition.deserialize(JSONUtils.getString(json, "heatRequirement"))); + if (JSONUtils.isValidNode(json, "processingTime")) + builder.duration(JSONUtils.getAsInt(json, "processingTime")); + if (JSONUtils.isValidNode(json, "heatRequirement")) + builder.requiresHeat(HeatCondition.deserialize(JSONUtils.getAsString(json, "heatRequirement"))); return builder.build(); } @@ -100,7 +100,7 @@ public class ProcessingRecipeSerializer> extends F NonNullList fluidOutputs = recipe.getFluidResults(); buffer.writeVarInt(ingredients.size()); - ingredients.forEach(i -> i.write(buffer)); + ingredients.forEach(i -> i.toNetwork(buffer)); buffer.writeVarInt(fluidIngredients.size()); fluidIngredients.forEach(i -> i.write(buffer)); @@ -122,7 +122,7 @@ public class ProcessingRecipeSerializer> extends F int size = buffer.readVarInt(); for (int i = 0; i < size; i++) - ingredients.add(Ingredient.read(buffer)); + ingredients.add(Ingredient.fromNetwork(buffer)); size = buffer.readVarInt(); for (int i = 0; i < size; i++) @@ -150,17 +150,17 @@ public class ProcessingRecipeSerializer> extends F } @Override - public final T read(ResourceLocation id, JsonObject json) { + public final T fromJson(ResourceLocation id, JsonObject json) { return readFromJson(id, json); } @Override - public final void write(PacketBuffer buffer, T recipe) { + public final void toNetwork(PacketBuffer buffer, T recipe) { writeToBuffer(buffer, recipe); } @Override - public final T read(ResourceLocation id, PacketBuffer buffer) { + public final T fromNetwork(ResourceLocation id, PacketBuffer buffer) { return readFromBuffer(id, buffer); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java index 527441ceb..c03d496d2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java @@ -54,6 +54,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.FakePlayer; +import net.minecraft.block.AbstractBlock.Properties; + @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class BlazeBurnerBlock extends Block implements ITE { @@ -62,20 +64,20 @@ public class BlazeBurnerBlock extends Block implements ITE builder) { - super.fillStateContainer(builder); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder); builder.add(HEAT_LEVEL); } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) { - if (world.isRemote) + public void onPlace(BlockState state, World world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) { + if (world.isClientSide) return; - TileEntity tileEntity = world.getTileEntity(pos.up()); + TileEntity tileEntity = world.getBlockEntity(pos.above()); if (!(tileEntity instanceof BasinTileEntity)) return; BasinTileEntity basin = (BasinTileEntity) tileEntity; @@ -84,14 +86,14 @@ public class BlazeBurnerBlock extends Block implements ITE p_149666_2_) { + public void fillItemCategory(ItemGroup p_149666_1_, NonNullList p_149666_2_) { p_149666_2_.add(AllItems.EMPTY_BLAZE_BURNER.asStack()); - super.fillItemGroup(p_149666_1_, p_149666_2_); + super.fillItemCategory(p_149666_1_, p_149666_2_); } @Nullable @@ -106,36 +108,36 @@ public class BlazeBurnerBlock extends Block implements ITE p.sendBreakAnimation(hand)); - world.setBlockState(pos, AllBlocks.LIT_BLAZE_BURNER.getDefaultState()); + heldItem.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(hand)); + world.setBlockAndUpdate(pos, AllBlocks.LIT_BLAZE_BURNER.getDefaultState()); return ActionResultType.SUCCESS; } return ActionResultType.PASS; } ActionResult res = tryInsert(state, world, pos, dontConsume ? heldItem.copy() : heldItem, forceOverflow, false); - ItemStack leftover = res.getResult(); - if (!world.isRemote && !dontConsume && !leftover.isEmpty()) { + ItemStack leftover = res.getObject(); + if (!world.isClientSide && !dontConsume && !leftover.isEmpty()) { if (heldItem.isEmpty()) { - player.setHeldItem(hand, leftover); - } else if (!player.inventory.addItemStackToInventory(leftover)) { - player.dropItem(leftover, false); + player.setItemInHand(hand, leftover); + } else if (!player.inventory.add(leftover)) { + player.drop(leftover, false); } } - return res.getType() == ActionResultType.SUCCESS ? res.getType() : ActionResultType.PASS; + return res.getResult() == ActionResultType.SUCCESS ? res.getResult() : ActionResultType.PASS; } public static ActionResult tryInsert(BlockState state, World world, BlockPos pos, ItemStack stack, boolean forceOverflow, @@ -143,7 +145,7 @@ public class BlazeBurnerBlock extends Block implements ITE p_195946_1_, Item p_195946_2_) { + public void registerBlocks(Map p_195946_1_, Item p_195946_2_) { if (!hasCapturedBlaze()) return; - super.addToBlockToItemMap(p_195946_1_, p_195946_2_); + super.registerBlocks(p_195946_1_, p_195946_2_); } private BlazeBurnerBlockItem(Block block, Properties properties, boolean capturedBlaze) { @@ -63,67 +65,67 @@ public class BlazeBurnerBlockItem extends BlockItem { } @Override - public void fillItemGroup(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { if (!hasCapturedBlaze()) return; - super.fillItemGroup(p_150895_1_, p_150895_2_); + super.fillItemCategory(p_150895_1_, p_150895_2_); } @Override - public String getTranslationKey() { - return hasCapturedBlaze() ? super.getTranslationKey() : "item.create." + getRegistryName().getPath(); + public String getDescriptionId() { + return hasCapturedBlaze() ? super.getDescriptionId() : "item.create." + getRegistryName().getPath(); } @Override - public ActionResultType onItemUse(ItemUseContext context) { + public ActionResultType useOn(ItemUseContext context) { if (hasCapturedBlaze()) - return super.onItemUse(context); + return super.useOn(context); - World world = context.getWorld(); - BlockPos pos = context.getPos(); - TileEntity te = world.getTileEntity(pos); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); + TileEntity te = world.getBlockEntity(pos); PlayerEntity player = context.getPlayer(); if (!(te instanceof MobSpawnerTileEntity)) - return super.onItemUse(context); + return super.useOn(context); - AbstractSpawner spawner = ((MobSpawnerTileEntity) te).getSpawnerBaseLogic(); + AbstractSpawner spawner = ((MobSpawnerTileEntity) te).getSpawner(); List possibleSpawns = - ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "field_98285_e"); + ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "spawnPotentials"); // spawnPotentials if (possibleSpawns.isEmpty()) { possibleSpawns = new ArrayList<>(); possibleSpawns - .add(ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "field_98282_f")); + .add(ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "nextSpawnData")); // nextSpawnData } ResourceLocation blazeId = EntityType.BLAZE.getRegistryName(); for (WeightedSpawnerEntity e : possibleSpawns) { - ResourceLocation spawnerEntityId = new ResourceLocation(e.getNbt() + ResourceLocation spawnerEntityId = new ResourceLocation(e.getTag() .getString("id")); if (!spawnerEntityId.equals(blazeId)) continue; spawnCaptureEffects(world, VecHelper.getCenterOf(pos)); - if (world.isRemote || player == null) + if (world.isClientSide || player == null) return ActionResultType.SUCCESS; - giveBurnerItemTo(player, context.getItem(), context.getHand()); + giveBurnerItemTo(player, context.getItemInHand(), context.getHand()); return ActionResultType.SUCCESS; } - return super.onItemUse(context); + return super.useOn(context); } @Override - public ActionResultType itemInteractionForEntity(ItemStack heldItem, PlayerEntity player, LivingEntity entity, Hand hand) { + public ActionResultType interactLivingEntity(ItemStack heldItem, PlayerEntity player, LivingEntity entity, Hand hand) { if (hasCapturedBlaze()) return ActionResultType.PASS; if (!(entity instanceof BlazeEntity)) return ActionResultType.PASS; - World world = player.world; - spawnCaptureEffects(world, entity.getPositionVec()); - if (world.isRemote) + World world = player.level; + spawnCaptureEffects(world, entity.position()); + if (world.isClientSide) return ActionResultType.FAIL; giveBurnerItemTo(player, heldItem, hand); @@ -136,18 +138,18 @@ public class BlazeBurnerBlockItem extends BlockItem { if (!player.isCreative()) heldItem.shrink(1); if (heldItem.isEmpty()) { - player.setHeldItem(hand, filled); + player.setItemInHand(hand, filled); return; } - player.inventory.placeItemBackInInventory(player.world, filled); + player.inventory.placeItemBackInInventory(player.level, filled); } private void spawnCaptureEffects(World world, Vector3d vec) { - if (world.isRemote) { + if (world.isClientSide) { for (int i = 0; i < 40; i++) { - Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, world.rand, .125f); + Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, world.random, .125f); world.addParticle(ParticleTypes.FLAME, vec.x, vec.y, vec.z, motion.x, motion.y, motion.z); - Vector3d circle = motion.mul(1, 0, 1) + Vector3d circle = motion.multiply(1, 0, 1) .normalize() .scale(.5f); world.addParticle(ParticleTypes.SMOKE, circle.x, vec.y, circle.z, 0, -0.125, 0); @@ -156,8 +158,8 @@ public class BlazeBurnerBlockItem extends BlockItem { } BlockPos soundPos = new BlockPos(vec); - world.playSound(null, soundPos, SoundEvents.ENTITY_BLAZE_HURT, SoundCategory.HOSTILE, .25f, .75f); - world.playSound(null, soundPos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.HOSTILE, .5f, .75f); + world.playSound(null, soundPos, SoundEvents.BLAZE_HURT, SoundCategory.HOSTILE, .25f, .75f); + world.playSound(null, soundPos, SoundEvents.FIRE_EXTINGUISH, SoundCategory.HOSTILE, .5f, .75f); } public boolean hasCapturedBlaze() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerHandler.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerHandler.java index 2b30de6ab..42affc19b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerHandler.java @@ -42,20 +42,20 @@ public class BlazeBurnerHandler { .getType() != RayTraceResult.Type.BLOCK) return; - TileEntity tile = event.getThrowable().world.getTileEntity(new BlockPos(event.getRayTraceResult() - .getHitVec())); + TileEntity tile = event.getThrowable().level.getBlockEntity(new BlockPos(event.getRayTraceResult() + .getLocation())); if (!(tile instanceof BlazeBurnerTileEntity)) { return; } event.setCanceled(true); event.getThrowable() - .setMotion(Vector3d.ZERO); + .setDeltaMovement(Vector3d.ZERO); event.getThrowable() .remove(); - World world = event.getThrowable().world; - if (world.isRemote) + World world = event.getThrowable().level; + if (world.isClientSide) return; BlazeBurnerTileEntity heater = (BlazeBurnerTileEntity) tile; @@ -67,11 +67,11 @@ public class BlazeBurnerHandler { heater.notifyUpdate(); } - AllSoundEvents.BLAZE_MUNCH.playOnServer(world, heater.getPos()); + AllSoundEvents.BLAZE_MUNCH.playOnServer(world, heater.getBlockPos()); } public static void splashExtinguishesBurner(ProjectileImpactEvent.Throwable event) { - if (event.getThrowable().world.isRemote) + if (event.getThrowable().level.isClientSide) return; if (!(event.getThrowable() instanceof PotionEntity)) @@ -83,18 +83,18 @@ public class BlazeBurnerHandler { return; ItemStack stack = entity.getItem(); - Potion potion = PotionUtils.getPotionFromItem(stack); - if (potion == Potions.WATER && PotionUtils.getEffectsFromStack(stack).isEmpty()) { + Potion potion = PotionUtils.getPotion(stack); + if (potion == Potions.WATER && PotionUtils.getMobEffects(stack).isEmpty()) { BlockRayTraceResult result = (BlockRayTraceResult) event.getRayTraceResult(); - World world = entity.world; - Direction face = result.getFace(); - BlockPos pos = result.getPos().offset(face); + World world = entity.level; + Direction face = result.getDirection(); + BlockPos pos = result.getBlockPos().relative(face); extinguishLitBurners(world, pos, face); - extinguishLitBurners(world, pos.offset(face.getOpposite()), face); + extinguishLitBurners(world, pos.relative(face.getOpposite()), face); for (Direction face1 : Direction.Plane.HORIZONTAL) { - extinguishLitBurners(world, pos.offset(face1), face1); + extinguishLitBurners(world, pos.relative(face1), face1); } } } @@ -102,8 +102,8 @@ public class BlazeBurnerHandler { private static void extinguishLitBurners(World world, BlockPos pos, Direction direction) { BlockState state = world.getBlockState(pos); if (AllBlocks.LIT_BLAZE_BURNER.has(state)) { - world.playSound(null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); - world.setBlockState(pos, AllBlocks.BLAZE_BURNER.getDefaultState()); + world.playSound(null, pos, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); + world.setBlockAndUpdate(pos, AllBlocks.BLAZE_BURNER.getDefaultState()); } } 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 cf99503c0..9f000b228 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 @@ -29,7 +29,7 @@ public class BlazeBurnerRenderer extends SafeTileEntityRenderer 0.25) @@ -217,13 +217,13 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { } private void spawnParticle(HeatLevel heatLevel, float scale, int avgAge, boolean hot, double speed, double spread) { - Random random = world.getRandom(); + Random random = level.getRandom(); Vector3d color = randomColor(heatLevel); - world.addOptionalParticle( + level.addAlwaysVisibleParticle( new CubeParticleData((float) color.x, (float) color.y, (float) color.z, scale, avgAge, hot), - (double) pos.getX() + 0.5D + (random.nextDouble() * 2.0 - 1D) * spread, - (double) pos.getY() + 0.6D + (random.nextDouble() / 4.0), - (double) pos.getZ() + 0.5D + (random.nextDouble() * 2.0 - 1D) * spread, 0.0D, speed, 0.0D); + (double) worldPosition.getX() + 0.5D + (random.nextDouble() * 2.0 - 1D) * spread, + (double) worldPosition.getY() + 0.6D + (random.nextDouble() / 4.0), + (double) worldPosition.getZ() + 0.5D + (random.nextDouble() * 2.0 - 1D) * spread, 0.0D, speed, 0.0D); } private static Vector3d randomColor(BlazeBurnerBlock.HeatLevel heatLevel) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/LitBlazeBurnerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/LitBlazeBurnerBlock.java index 51220474d..c0d9fa4fa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/LitBlazeBurnerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/LitBlazeBurnerBlock.java @@ -31,41 +31,43 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ToolType; +import net.minecraft.block.AbstractBlock.Properties; + public class LitBlazeBurnerBlock extends Block { public static final EnumProperty FLAME_TYPE = EnumProperty.create("flame_type", FlameType.class); public LitBlazeBurnerBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(FLAME_TYPE, FlameType.REGULAR)); + registerDefaultState(defaultBlockState().setValue(FLAME_TYPE, FlameType.REGULAR)); } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder); builder.add(FLAME_TYPE); } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) { - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); if (heldItem.getToolTypes().contains(ToolType.SHOVEL)) { - world.playSound(player, pos, SoundEvents.ENTITY_GENERIC_EXTINGUISH_FIRE, SoundCategory.BLOCKS, 0.5f, 2); - if (world.isRemote) + world.playSound(player, pos, SoundEvents.GENERIC_EXTINGUISH_FIRE, SoundCategory.BLOCKS, 0.5f, 2); + if (world.isClientSide) return ActionResultType.SUCCESS; - heldItem.damageItem(1, player, p -> p.sendBreakAnimation(hand)); - world.setBlockState(pos, AllBlocks.BLAZE_BURNER.getDefaultState()); + heldItem.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(hand)); + world.setBlockAndUpdate(pos, AllBlocks.BLAZE_BURNER.getDefaultState()); return ActionResultType.SUCCESS; } - if (state.get(FLAME_TYPE) == FlameType.REGULAR) { - if (heldItem.getItem().isIn(ItemTags.SOUL_FIRE_BASE_BLOCKS)) { - world.playSound(player, pos, SoundEvents.BLOCK_SOUL_SAND_PLACE, SoundCategory.BLOCKS, 1.0f, world.rand.nextFloat() * 0.4F + 0.8F); - if (world.isRemote) + if (state.getValue(FLAME_TYPE) == FlameType.REGULAR) { + if (heldItem.getItem().is(ItemTags.SOUL_FIRE_BASE_BLOCKS)) { + world.playSound(player, pos, SoundEvents.SOUL_SAND_PLACE, SoundCategory.BLOCKS, 1.0f, world.random.nextFloat() * 0.4F + 0.8F); + if (world.isClientSide) return ActionResultType.SUCCESS; - world.setBlockState(pos, getDefaultState().with(FLAME_TYPE, FlameType.SOUL)); + world.setBlockAndUpdate(pos, defaultBlockState().setValue(FLAME_TYPE, FlameType.SOUL)); return ActionResultType.SUCCESS; } } @@ -87,19 +89,19 @@ public class LitBlazeBurnerBlock extends Block { @OnlyIn(Dist.CLIENT) public void animateTick(BlockState state, World world, BlockPos pos, Random random) { - world.addOptionalParticle(ParticleTypes.LARGE_SMOKE, true, + world.addAlwaysVisibleParticle(ParticleTypes.LARGE_SMOKE, true, (double) pos.getX() + 0.5D + random.nextDouble() / 3.0D * (double) (random.nextBoolean() ? 1 : -1), (double) pos.getY() + random.nextDouble() + random.nextDouble(), (double) pos.getZ() + 0.5D + random.nextDouble() / 3.0D * (double) (random.nextBoolean() ? 1 : -1), 0.0D, 0.07D, 0.0D); if (random.nextInt(10) == 0) { - world.playSound((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), - (double) ((float) pos.getZ() + 0.5F), SoundEvents.BLOCK_CAMPFIRE_CRACKLE, SoundCategory.BLOCKS, + world.playLocalSound((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), + (double) ((float) pos.getZ() + 0.5F), SoundEvents.CAMPFIRE_CRACKLE, SoundCategory.BLOCKS, 0.25F + random.nextFloat() * .25f, random.nextFloat() * 0.7F + 0.6F, false); } - if (state.get(FLAME_TYPE) == FlameType.SOUL) { + if (state.getValue(FLAME_TYPE) == FlameType.SOUL) { if (random.nextInt(8) == 0) { world.addParticle(ParticleTypes.SOUL, pos.getX() + 0.5F + random.nextDouble() / 4 * (random.nextBoolean() ? 1 : -1), @@ -120,13 +122,13 @@ public class LitBlazeBurnerBlock extends Block { } @Override - public boolean hasComparatorInputOverride(BlockState p_149740_1_) { + public boolean hasAnalogOutputSignal(BlockState p_149740_1_) { return true; } @Override - public int getComparatorInputOverride(BlockState state, World p_180641_2_, BlockPos p_180641_3_) { - return state.get(FLAME_TYPE) == FlameType.REGULAR ? 1 : 2; + public int getAnalogOutputSignal(BlockState state, World p_180641_2_, BlockPos p_180641_3_) { + return state.getValue(FLAME_TYPE) == FlameType.REGULAR ? 1 : 2; } @Override @@ -137,12 +139,12 @@ public class LitBlazeBurnerBlock extends Block { } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } public static int getLight(BlockState state) { - if (state.get(FLAME_TYPE) == FlameType.SOUL) + if (state.getValue(FLAME_TYPE) == FlameType.SOUL) return 9; else return 12; @@ -153,7 +155,7 @@ public class LitBlazeBurnerBlock extends Block { REGULAR, SOUL; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java index 19a563c35..3219d900b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java @@ -45,6 +45,8 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class GantryShaftBlock extends DirectionalKineticBlock { public static final Property PART = EnumProperty.create("part", Part.class); @@ -56,19 +58,19 @@ public class GantryShaftBlock extends DirectionalKineticBlock { START, MIDDLE, END, SINGLE; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(PART, POWERED)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(PART, POWERED)); } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { - ItemStack heldItem = player.getHeldItem(hand); + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { + ItemStack heldItem = player.getItemInHand(hand); IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId); if (!placementHelper.matchesItem(heldItem)) @@ -80,25 +82,25 @@ public class GantryShaftBlock extends DirectionalKineticBlock { @Override public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - return AllShapes.EIGHT_VOXEL_POLE.get(state.get(FACING) + return AllShapes.EIGHT_VOXEL_POLE.get(state.getValue(FACING) .getAxis()); } @Override - public BlockRenderType getRenderType(BlockState state) { + public BlockRenderType getRenderShape(BlockState state) { return BlockRenderType.ENTITYBLOCK_ANIMATED; } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbour, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbour, IWorld world, BlockPos pos, BlockPos neighbourPos) { - Direction facing = state.get(FACING); + Direction facing = state.getValue(FACING); Axis axis = facing.getAxis(); if (direction.getAxis() != axis) return state; - boolean connect = AllBlocks.GANTRY_SHAFT.has(neighbour) && neighbour.get(FACING) == facing; + boolean connect = AllBlocks.GANTRY_SHAFT.has(neighbour) && neighbour.getValue(FACING) == facing; - Part part = state.get(PART); + Part part = state.getValue(PART); if (direction.getAxisDirection() == facing.getAxisDirection()) { if (connect) { if (part == Part.END) @@ -125,58 +127,58 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } } - return state.with(PART, part); + return state.setValue(PART, part); } public GantryShaftBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(POWERED, false) - .with(PART, Part.SINGLE)); + registerDefaultState(defaultBlockState().setValue(POWERED, false) + .setValue(PART, Part.SINGLE)); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { BlockState state = super.getStateForPlacement(context); - BlockPos pos = context.getPos(); - World world = context.getWorld(); - Direction face = context.getFace(); + BlockPos pos = context.getClickedPos(); + World world = context.getLevel(); + Direction face = context.getClickedFace(); - BlockState neighbour = world.getBlockState(pos.offset(state.get(FACING) + BlockState neighbour = world.getBlockState(pos.relative(state.getValue(FACING) .getOpposite())); BlockState clickedState = - AllBlocks.GANTRY_SHAFT.has(neighbour) ? neighbour : world.getBlockState(pos.offset(face.getOpposite())); + AllBlocks.GANTRY_SHAFT.has(neighbour) ? neighbour : world.getBlockState(pos.relative(face.getOpposite())); - if (AllBlocks.GANTRY_SHAFT.has(clickedState) && clickedState.get(FACING) - .getAxis() == state.get(FACING) + if (AllBlocks.GANTRY_SHAFT.has(clickedState) && clickedState.getValue(FACING) + .getAxis() == state.getValue(FACING) .getAxis()) { - Direction facing = clickedState.get(FACING); - state = state.with(FACING, context.getPlayer() == null || !context.getPlayer() - .isSneaking() ? facing : facing.getOpposite()); + Direction facing = clickedState.getValue(FACING); + state = state.setValue(FACING, context.getPlayer() == null || !context.getPlayer() + .isShiftKeyDown() ? facing : facing.getOpposite()); } - return state.with(POWERED, shouldBePowered(state, world, pos)); + return state.setValue(POWERED, shouldBePowered(state, world, pos)); } @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { ActionResultType onWrenched = super.onWrenched(state, context); - if (onWrenched.isAccepted()) { - BlockPos pos = context.getPos(); - World world = context.getWorld(); + if (onWrenched.consumesAction()) { + BlockPos pos = context.getClickedPos(); + World world = context.getLevel(); neighborChanged(world.getBlockState(pos), world, pos, state.getBlock(), pos, false); } return onWrenched; } @Override - public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { - super.onBlockAdded(state, worldIn, pos, oldState, isMoving); + public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + super.onPlace(state, worldIn, pos, oldState, isMoving); - if (!worldIn.isRemote() && oldState.getBlock().is(AllBlocks.GANTRY_SHAFT.get())) { - Part oldPart = oldState.get(PART), part = state.get(PART); + if (!worldIn.isClientSide() && oldState.getBlock().is(AllBlocks.GANTRY_SHAFT.get())) { + Part oldPart = oldState.getValue(PART), part = state.getValue(PART); if ((oldPart != Part.MIDDLE && part == Part.MIDDLE) || (oldPart == Part.SINGLE && part != Part.SINGLE)) { - TileEntity te = worldIn.getTileEntity(pos); + TileEntity te = worldIn.getBlockEntity(pos); if (te instanceof GantryShaftTileEntity) ((GantryShaftTileEntity) te).checkAttachedCarriageBlocks(); } @@ -186,13 +188,13 @@ public class GantryShaftBlock extends DirectionalKineticBlock { @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - boolean previouslyPowered = state.get(POWERED); - boolean shouldPower = worldIn.isBlockPowered(pos); // shouldBePowered(state, worldIn, pos); + boolean previouslyPowered = state.getValue(POWERED); + boolean shouldPower = worldIn.hasNeighborSignal(pos); // shouldBePowered(state, worldIn, pos); if (!previouslyPowered && !shouldPower && shouldBePowered(state, worldIn, pos)) { - worldIn.setBlockState(pos, state.with(POWERED, true), 3); + worldIn.setBlock(pos, state.setValue(POWERED, true), 3); return; } @@ -201,52 +203,52 @@ public class GantryShaftBlock extends DirectionalKineticBlock { // Collect affected gantry shafts List toUpdate = new ArrayList<>(); - Direction facing = state.get(FACING); + Direction facing = state.getValue(FACING); Axis axis = facing.getAxis(); for (Direction d : Iterate.directionsInAxis(axis)) { - BlockPos currentPos = pos.offset(d); + BlockPos currentPos = pos.relative(d); while (true) { - if (!worldIn.isBlockPresent(currentPos)) + if (!worldIn.isLoaded(currentPos)) break; BlockState currentState = worldIn.getBlockState(currentPos); if (!(currentState.getBlock() instanceof GantryShaftBlock)) break; - if (currentState.get(FACING) != facing) + if (currentState.getValue(FACING) != facing) break; - if (!shouldPower && currentState.get(POWERED) && worldIn.isBlockPowered(currentPos)) + if (!shouldPower && currentState.getValue(POWERED) && worldIn.hasNeighborSignal(currentPos)) return; - if (currentState.get(POWERED) == shouldPower) + if (currentState.getValue(POWERED) == shouldPower) break; toUpdate.add(currentPos); - currentPos = currentPos.offset(d); + currentPos = currentPos.relative(d); } } toUpdate.add(pos); for (BlockPos blockPos : toUpdate) { BlockState blockState = worldIn.getBlockState(blockPos); - TileEntity te = worldIn.getTileEntity(blockPos); + TileEntity te = worldIn.getBlockEntity(blockPos); if (te instanceof KineticTileEntity) ((KineticTileEntity) te).detachKinetics(); if (blockState.getBlock() instanceof GantryShaftBlock) - worldIn.setBlockState(blockPos, blockState.with(POWERED, shouldPower), 2); + worldIn.setBlock(blockPos, blockState.setValue(POWERED, shouldPower), 2); } } protected boolean shouldBePowered(BlockState state, World worldIn, BlockPos pos) { - boolean shouldPower = worldIn.isBlockPowered(pos); + boolean shouldPower = worldIn.hasNeighborSignal(pos); - Direction facing = state.get(FACING); + Direction facing = state.getValue(FACING); for (Direction d : Iterate.directionsInAxis(facing.getAxis())) { - BlockPos neighbourPos = pos.offset(d); - if (!worldIn.isBlockPresent(neighbourPos)) + BlockPos neighbourPos = pos.relative(d); + if (!worldIn.isLoaded(neighbourPos)) continue; BlockState neighbourState = worldIn.getBlockState(neighbourPos); if (!(neighbourState.getBlock() instanceof GantryShaftBlock)) continue; - if (neighbourState.get(FACING) != facing) + if (neighbourState.getValue(FACING) != facing) continue; - shouldPower |= neighbourState.get(POWERED); + shouldPower |= neighbourState.getValue(POWERED); } return shouldPower; @@ -254,13 +256,13 @@ public class GantryShaftBlock extends DirectionalKineticBlock { @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face.getAxis() == state.get(FACING) + return face.getAxis() == state.getValue(FACING) .getAxis(); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(FACING) + return state.getValue(FACING) .getAxis(); } @@ -272,7 +274,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { @Override protected boolean areStatesKineticallyEquivalent(BlockState oldState, BlockState newState) { return super.areStatesKineticallyEquivalent(oldState, newState) - && oldState.get(POWERED) == newState.get(POWERED); + && oldState.getValue(POWERED) == newState.getValue(POWERED); } @Override @@ -286,14 +288,14 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } public static class PlacementHelper extends PoleHelper { public PlacementHelper() { - super(AllBlocks.GANTRY_SHAFT::has, s -> s.get(FACING) + super(AllBlocks.GANTRY_SHAFT::has, s -> s.getValue(FACING) .getAxis(), FACING); } @@ -305,7 +307,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { @Override public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { PlacementOffset offset = super.getOffset(player, world, state, pos, ray); - offset.withTransform(offset.getTransform().andThen(s -> s.with(POWERED, state.get(POWERED)))); + offset.withTransform(offset.getTransform().andThen(s -> s.setValue(POWERED, state.getValue(POWERED)))); return offset; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java index 4cd68bcbf..2d29850bb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java @@ -23,16 +23,16 @@ public class GantryShaftTileEntity extends KineticTileEntity { if (!canAssembleOn()) return; for (Direction d : Iterate.directions) { - if (d.getAxis() == getBlockState().get(GantryShaftBlock.FACING) + if (d.getAxis() == getBlockState().getValue(GantryShaftBlock.FACING) .getAxis()) continue; - BlockPos offset = pos.offset(d); - BlockState pinionState = world.getBlockState(offset); + BlockPos offset = worldPosition.relative(d); + BlockState pinionState = level.getBlockState(offset); if (!AllBlocks.GANTRY_CARRIAGE.has(pinionState)) continue; - if (pinionState.get(GantryCarriageBlock.FACING) != d) + if (pinionState.getValue(GantryCarriageBlock.FACING) != d) continue; - TileEntity tileEntity = world.getTileEntity(offset); + TileEntity tileEntity = level.getBlockEntity(offset); if (tileEntity instanceof GantryCarriageTileEntity) ((GantryCarriageTileEntity) tileEntity).queueAssembly(); } @@ -52,37 +52,37 @@ public class GantryShaftTileEntity extends KineticTileEntity { if (connectedViaAxes) return defaultModifier; - if (!stateFrom.get(GantryShaftBlock.POWERED)) + if (!stateFrom.getValue(GantryShaftBlock.POWERED)) return defaultModifier; if (!AllBlocks.GANTRY_CARRIAGE.has(stateTo)) return defaultModifier; - Direction direction = Direction.getFacingFromVector(diff.getX(), diff.getY(), diff.getZ()); - if (stateTo.get(GantryCarriageBlock.FACING) != direction) + Direction direction = Direction.getNearest(diff.getX(), diff.getY(), diff.getZ()); + if (stateTo.getValue(GantryCarriageBlock.FACING) != direction) return defaultModifier; - return GantryCarriageTileEntity.getGantryPinionModifier(stateFrom.get(GantryShaftBlock.FACING), - stateTo.get(GantryCarriageBlock.FACING)); + return GantryCarriageTileEntity.getGantryPinionModifier(stateFrom.getValue(GantryShaftBlock.FACING), + stateTo.getValue(GantryCarriageBlock.FACING)); } @Override public boolean isCustomConnection(KineticTileEntity other, BlockState state, BlockState otherState) { if (!AllBlocks.GANTRY_CARRIAGE.has(otherState)) return false; - final BlockPos diff = other.getPos() - .subtract(pos); - Direction direction = Direction.getFacingFromVector(diff.getX(), diff.getY(), diff.getZ()); - return otherState.get(GantryCarriageBlock.FACING) == direction; + final BlockPos diff = other.getBlockPos() + .subtract(worldPosition); + Direction direction = Direction.getNearest(diff.getX(), diff.getY(), diff.getZ()); + return otherState.getValue(GantryCarriageBlock.FACING) == direction; } public boolean canAssembleOn() { BlockState blockState = getBlockState(); if (!AllBlocks.GANTRY_SHAFT.has(blockState)) return false; - if (blockState.get(GantryShaftBlock.POWERED)) + if (blockState.getValue(GantryShaftBlock.POWERED)) return false; float speed = getPinionMovementSpeed(); - switch (blockState.get(GantryShaftBlock.PART)) { + switch (blockState.getValue(GantryShaftBlock.PART)) { case END: return speed < 0; case MIDDLE: diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerBlock.java index 46a4f25d4..2c2be6f0e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerBlock.java @@ -33,6 +33,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class SpeedControllerBlock extends HorizontalAxisKineticBlock implements ITE { @@ -50,27 +52,27 @@ public class SpeedControllerBlock extends HorizontalAxisKineticBlock implements @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - BlockState above = context.getWorld() - .getBlockState(context.getPos() - .up()); - if (ICogWheel.isLargeCog(above) && above.get(CogWheelBlock.AXIS) + BlockState above = context.getLevel() + .getBlockState(context.getClickedPos() + .above()); + if (ICogWheel.isLargeCog(above) && above.getValue(CogWheelBlock.AXIS) .isHorizontal()) - return getDefaultState().with(HORIZONTAL_AXIS, above.get(CogWheelBlock.AXIS) == Axis.X ? Axis.Z : Axis.X); + return defaultBlockState().setValue(HORIZONTAL_AXIS, above.getValue(CogWheelBlock.AXIS) == Axis.X ? Axis.Z : Axis.X); return super.getStateForPlacement(context); } @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, BlockPos neighbourPos, boolean p_220069_6_) { - if (neighbourPos.equals(pos.up())) + if (neighbourPos.equals(pos.above())) withTileEntityDo(world, pos, SpeedControllerTileEntity::updateBracket); } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); IPlacementHelper helper = PlacementHelpers.get(placementHelperId); if (helper.matchesItem(heldItem)) return helper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray); @@ -97,18 +99,18 @@ public class SpeedControllerBlock extends HorizontalAxisKineticBlock implements @Override public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { - BlockPos newPos = pos.up(); + BlockPos newPos = pos.above(); if (!world.getBlockState(newPos) .getMaterial() .isReplaceable()) return PlacementOffset.fail(); - Axis newAxis = state.get(HORIZONTAL_AXIS) == Axis.X ? Axis.Z : Axis.X; + Axis newAxis = state.getValue(HORIZONTAL_AXIS) == Axis.X ? Axis.Z : Axis.X; if (!CogWheelBlock.isValidCogwheelPosition(true, world, newPos, newAxis)) return PlacementOffset.fail(); - return PlacementOffset.success(newPos, s -> s.with(CogWheelBlock.AXIS, newAxis)); + return PlacementOffset.success(newPos, s -> s.setValue(CogWheelBlock.AXIS, newAxis)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java index cb6c22d09..54349d915 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java @@ -31,24 +31,24 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer { public static final BooleanProperty VERTICAL = BooleanProperty.create("vertical"); @@ -46,8 +48,8 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(STATE, VERTICAL)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(STATE, VERTICAL)); } @Override @@ -63,18 +65,18 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - if (!worldIn.getPendingBlockTicks() - .isTickPending(pos, this)) - worldIn.getPendingBlockTicks() + if (!worldIn.getBlockTicks() + .willTickThisTick(pos, this)) + worldIn.getBlockTicks() .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); + public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + boolean previouslyPowered = state.getValue(STATE) != 0; + boolean isPowered = worldIn.hasNeighborSignal(pos); withTileEntityDo(worldIn, pos, sgte -> sgte.onRedstoneUpdate(isPowered, previouslyPowered)); } @@ -85,21 +87,21 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - if (state.get(VERTICAL)) + if (state.getValue(VERTICAL)) return face.getAxis() .isVertical(); return super.hasShaftTowards(world, pos, state, face); } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - ItemStack held = player.getHeldItemMainhand(); + ItemStack held = player.getMainHandItem(); if (AllItems.WRENCH.isIn(held)) return ActionResultType.PASS; if (held.getItem() instanceof BlockItem) { BlockItem blockItem = (BlockItem) held.getItem(); - if (blockItem.getBlock() instanceof KineticBlock && hasShaftTowards(worldIn, pos, state, hit.getFace())) + if (blockItem.getBlock() instanceof KineticBlock && hasShaftTowards(worldIn, pos, state, hit.getDirection())) return ActionResultType.PASS; } @@ -118,7 +120,7 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen public BlockState getStateForPlacement(BlockItemUseContext context) { Axis preferredAxis = RotatedPillarKineticBlock.getPreferredAxis(context); if (preferredAxis != null && (context.getPlayer() == null || !context.getPlayer() - .isSneaking())) + .isShiftKeyDown())) return withAxis(preferredAxis, context); return withAxis(context.getNearestLookingDirection() .getAxis(), context); @@ -128,9 +130,9 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen public ActionResultType onWrenched(BlockState state, ItemUseContext context) { BlockState newState = state; - if (context.getFace() + if (context.getClickedFace() .getAxis() != Axis.Y) - if (newState.get(HORIZONTAL_AXIS) != context.getFace() + if (newState.getValue(HORIZONTAL_AXIS) != context.getClickedFace() .getAxis()) newState = newState.cycle(VERTICAL); @@ -138,16 +140,16 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen } private BlockState withAxis(Axis axis, BlockItemUseContext context) { - BlockState state = getDefaultState().with(VERTICAL, axis.isVertical()); + BlockState state = defaultBlockState().setValue(VERTICAL, axis.isVertical()); if (axis.isVertical()) - return state.with(HORIZONTAL_AXIS, context.getPlacementHorizontalFacing() + return state.setValue(HORIZONTAL_AXIS, context.getHorizontalDirection() .getAxis()); - return state.with(HORIZONTAL_AXIS, axis); + return state.setValue(HORIZONTAL_AXIS, axis); } @Override public Axis getRotationAxis(BlockState state) { - if (state.get(VERTICAL)) + if (state.getValue(VERTICAL)) return Axis.Y; return super.getRotationAxis(state); } @@ -158,13 +160,13 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen } @Override - public boolean hasComparatorInputOverride(BlockState p_149740_1_) { + public boolean hasAnalogOutputSignal(BlockState p_149740_1_) { return true; } @Override - public int getComparatorInputOverride(BlockState state, World world, BlockPos pos) { - return state.get(STATE) + public int getAnalogOutputSignal(BlockState state, World world, BlockPos pos) { + return state.getValue(STATE) .intValue(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftGenerator.java index 86b5f5b59..9301fecdd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftGenerator.java @@ -13,19 +13,19 @@ public class SequencedGearshiftGenerator extends SpecialBlockStateGen { @Override protected int getXRotation(BlockState state) { - return state.get(SequencedGearshiftBlock.VERTICAL) ? 90 : 0; + return state.getValue(SequencedGearshiftBlock.VERTICAL) ? 90 : 0; } @Override protected int getYRotation(BlockState state) { - return state.get(SequencedGearshiftBlock.HORIZONTAL_AXIS) == Axis.X ? 90 : 0; + return state.getValue(SequencedGearshiftBlock.HORIZONTAL_AXIS) == Axis.X ? 90 : 0; } @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { String variant = "idle"; - int seq = state.get(SequencedGearshiftBlock.STATE); + int seq = state.getValue(SequencedGearshiftBlock.STATE); if (seq > 0) variant = "seq_" + seq; return prov.models() diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftScreen.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftScreen.java index 5ba9d46bd..30a7063fc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftScreen.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftScreen.java @@ -35,7 +35,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { public SequencedGearshiftScreen(SequencedGearshiftTileEntity te) { super(Lang.translate("gui.sequenced_gearshift.title")); this.instructions = te.instructions; - this.pos = te.getPos(); + this.pos = te.getBlockPos(); compareTag = Instruction.serializeAll(instructions); } @@ -147,14 +147,14 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { label(ms, 36, yOffset - 3, Lang.translate(def.translationKey)); if (def.hasValueParameter) { String text = def.formatValue(instruction.value); - int stringWidth = textRenderer.getStringWidth(text); + int stringWidth = font.width(text); label(ms, 90 + (12 - stringWidth / 2), yOffset - 3, new StringTextComponent(text)); } if (def.hasSpeedParameter) label(ms, 127, yOffset - 3, instruction.speedModifier.label); } - drawCenteredText(ms, textRenderer, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); + drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); GuiGameElement.of(renderedItem) .at(x + background.width + 6, y + background.height - 56, -200) @@ -163,7 +163,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { } private void label(MatrixStack ms, int x, int y, ITextComponent text) { - textRenderer.drawWithShadow(ms, text, guiLeft + x, guiTop + 26 + y, 0xFFFFEE); + font.drawShadow(ms, text, guiLeft + x, guiTop + 26 + y, 0xFFFFEE); } public void sendPacket() { @@ -201,7 +201,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { @Override public boolean mouseClicked(double x, double y, int button) { if (confirmButton.isHovered()) { - client.player.closeScreen(); + minecraft.player.closeContainer(); return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftTileEntity.java index c65896513..4801c13ac 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftTileEntity.java @@ -35,7 +35,7 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { if (isIdle()) return; - if (world.isRemote) + if (level.isClientSide) return; if (currentInstructionDuration < 0) return; @@ -78,8 +78,8 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { return; if (isPowered == isRunning) return; - if (!world.isBlockPowered(pos)) { - world.setBlockState(pos, getBlockState().with(SequencedGearshiftBlock.STATE, 0), 3); + if (!level.hasNeighborSignal(worldPosition)) { + level.setBlock(worldPosition, getBlockState().setValue(SequencedGearshiftBlock.STATE, 0), 3); return; } if (getSpeed() == 0) @@ -113,8 +113,8 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { currentInstructionDuration = -1; currentInstructionProgress = 0; timer = 0; - if (!world.isBlockPowered(pos)) - world.setBlockState(pos, getBlockState().with(SequencedGearshiftBlock.STATE, 0), 3); + if (!level.hasNeighborSignal(worldPosition)) + level.setBlock(worldPosition, getBlockState().setValue(SequencedGearshiftBlock.STATE, 0), 3); else sendData(); return; @@ -125,7 +125,7 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { currentInstruction = instructionIndex; currentInstructionProgress = 0; timer = 0; - world.setBlockState(pos, getBlockState().with(SequencedGearshiftBlock.STATE, instructionIndex + 1), 3); + level.setBlock(worldPosition, getBlockState().setValue(SequencedGearshiftBlock.STATE, instructionIndex + 1), 3); } public Instruction getInstruction(int instructionIndex) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java index 0385ae526..a10935923 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java @@ -76,6 +76,8 @@ import net.minecraftforge.common.Tags; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import net.minecraft.block.AbstractBlock.Properties; + public class BeltBlock extends HorizontalKineticBlock implements ITE, ISpecialBlockItemRequirement { public static final Property SLOPE = EnumProperty.create("slope", BeltSlope.class); @@ -84,19 +86,19 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE p_149666_2_) { + public void fillItemCategory(ItemGroup p_149666_1_, NonNullList p_149666_2_) { p_149666_2_.add(AllItems.BELT_CONNECTOR.asStack()); } @Override protected boolean areStatesKineticallyEquivalent(BlockState oldState, BlockState newState) { - return super.areStatesKineticallyEquivalent(oldState, newState) && oldState.get(PART) == newState.get(PART); + return super.areStatesKineticallyEquivalent(oldState, newState) && oldState.getValue(PART) == newState.getValue(PART); } @Override @@ -109,10 +111,10 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE getDrops(BlockState state, net.minecraft.loot.LootContext.Builder builder) { List drops = super.getDrops(state, builder); - TileEntity tileEntity = builder.get(LootParameters.BLOCK_ENTITY); + TileEntity tileEntity = builder.getOptionalParameter(LootParameters.BLOCK_ENTITY); if (tileEntity instanceof BeltTileEntity && ((BeltTileEntity) tileEntity).hasPulley()) drops.addAll(AllBlocks.SHAFT.getDefaultState() .getDrops(builder)); @@ -143,7 +145,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE 0) + if (entityIn.getDeltaMovement().y > 0) return; if (!entityIn.isAlive()) return; @@ -220,7 +222,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE te.applyColor(DyeColor.getColor(heldItem))); return ActionResultType.SUCCESS; } @@ -263,7 +265,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE te.setCasingType(CasingType.BRASS)); @@ -297,7 +299,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE te.setCasingType(CasingType.ANDESITE)); @@ -309,21 +311,21 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE te.setCasingType(CasingType.NONE)); return ActionResultType.SUCCESS; } - if (state.get(PART) == BeltPart.PULLEY) { - if (world.isRemote) + if (state.getValue(PART) == BeltPart.PULLEY) { + if (world.isClientSide) return ActionResultType.SUCCESS; - KineticTileEntity.switchToBlockState(world, pos, state.with(PART, BeltPart.MIDDLE)); + KineticTileEntity.switchToBlockState(world, pos, state.setValue(PART, BeltPart.MIDDLE)); if (player != null && !player.isCreative()) player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack()); return ActionResultType.SUCCESS; @@ -333,9 +335,9 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(SLOPE, PART, CASING); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override @@ -387,15 +389,15 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE required = new ArrayList<>(); - if (state.get(PART) != BeltPart.MIDDLE) + if (state.getValue(PART) != BeltPart.MIDDLE) required.add(AllBlocks.SHAFT.asStack()); - if (state.get(PART) == BeltPart.START) + if (state.getValue(PART) == BeltPart.START) required.add(AllItems.BELT_CONNECTOR.asStack()); if (required.isEmpty()) return ItemRequirement.NONE; @@ -599,22 +601,22 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - Boolean casing = state.get(BeltBlock.CASING); + Boolean casing = state.getValue(BeltBlock.CASING); if (!casing) return prov.models() .getExistingFile(prov.modLoc("block/belt/particle")); - BeltPart part = state.get(BeltBlock.PART); - Direction direction = state.get(BeltBlock.HORIZONTAL_FACING); - BeltSlope slope = state.get(BeltBlock.SLOPE); + BeltPart part = state.getValue(BeltBlock.PART); + Direction direction = state.getValue(BeltBlock.HORIZONTAL_FACING); + BeltSlope slope = state.getValue(BeltBlock.SLOPE); boolean downward = slope == BeltSlope.DOWNWARD; boolean diagonal = slope == BeltSlope.UPWARD || downward; boolean vertical = slope == BeltSlope.VERTICAL; @@ -63,8 +63,8 @@ public class BeltGenerator extends SpecialBlockStateGen { slope = BeltSlope.SIDEWAYS; String path = "block/" + (casing ? "belt_casing/" : "belt/"); - String slopeName = slope.getString(); - String partName = part.getString(); + String slopeName = slope.getSerializedName(); + String partName = part.getSerializedName(); if (diagonal) slopeName = "diagonal"; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltHelper.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltHelper.java index 9ce688a16..a2a339ba3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltHelper.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltHelper.java @@ -18,13 +18,13 @@ public class BeltHelper { return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) .isPresent() || stack.getItem() - .isIn(AllItemTags.UPRIGHT_ON_BELT.tag); + .is(AllItemTags.UPRIGHT_ON_BELT.tag); } public static BeltTileEntity getSegmentTE(IWorld world, BlockPos pos) { if (!world.isAreaLoaded(pos, 0)) return null; - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (!(tileEntity instanceof BeltTileEntity)) return null; return (BeltTileEntity) tileEntity; @@ -46,36 +46,36 @@ public class BeltHelper { public static BeltTileEntity getBeltAtSegment(BeltTileEntity controller, int segment) { BlockPos pos = getPositionForOffset(controller, segment); - TileEntity te = controller.getWorld() - .getTileEntity(pos); + TileEntity te = controller.getLevel() + .getBlockEntity(pos); if (te == null || !(te instanceof BeltTileEntity)) return null; return (BeltTileEntity) te; } public static BlockPos getPositionForOffset(BeltTileEntity controller, int offset) { - BlockPos pos = controller.getPos(); + BlockPos pos = controller.getBlockPos(); Vector3i vec = controller.getBeltFacing() - .getDirectionVec(); + .getNormal(); BeltSlope slope = controller.getBlockState() - .get(BeltBlock.SLOPE); + .getValue(BeltBlock.SLOPE); int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; - return pos.add(offset * vec.getX(), MathHelper.clamp(offset, 0, controller.beltLength - 1) * verticality, + return pos.offset(offset * vec.getX(), MathHelper.clamp(offset, 0, controller.beltLength - 1) * verticality, offset * vec.getZ()); } public static Vector3d getVectorForOffset(BeltTileEntity controller, float offset) { BeltSlope slope = controller.getBlockState() - .get(BeltBlock.SLOPE); + .getValue(BeltBlock.SLOPE); int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; float verticalMovement = verticality; if (offset < .5) verticalMovement = 0; verticalMovement = verticalMovement * (Math.min(offset, controller.beltLength - .5f) - .5f); - Vector3d vec = VecHelper.getCenterOf(controller.getPos()); - Vector3d horizontalMovement = Vector3d.of(controller.getBeltFacing() - .getDirectionVec()).scale(offset - .5f); + Vector3d vec = VecHelper.getCenterOf(controller.getBlockPos()); + Vector3d horizontalMovement = Vector3d.atLowerCornerOf(controller.getBeltFacing() + .getNormal()).scale(offset - .5f); if (slope == BeltSlope.VERTICAL) horizontalMovement = Vector3d.ZERO; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java index 510e9f125..f30d42e08 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java @@ -43,8 +43,8 @@ public class BeltInstance extends KineticTileInstance { keys = new ArrayList<>(2); - beltSlope = blockState.get(BeltBlock.SLOPE); - facing = blockState.get(BeltBlock.HORIZONTAL_FACING); + beltSlope = blockState.getValue(BeltBlock.SLOPE); + facing = blockState.getValue(BeltBlock.HORIZONTAL_FACING); upward = beltSlope == BeltSlope.UPWARD; diagonal = beltSlope.isDiagonal(); sideways = beltSlope == BeltSlope.SIDEWAYS; @@ -52,7 +52,7 @@ public class BeltInstance extends KineticTileInstance { alongX = facing.getAxis() == Direction.Axis.X; alongZ = facing.getAxis() == Direction.Axis.Z; - BeltPart part = blockState.get(BeltBlock.PART); + BeltPart part = blockState.getValue(BeltBlock.PART); boolean start = part == BeltPart.START; boolean end = part == BeltPart.END; DyeColor color = tile.color.orElse(null); @@ -144,8 +144,8 @@ public class BeltInstance extends KineticTileInstance { } private Direction getOrientation() { - Direction dir = blockState.get(BeltBlock.HORIZONTAL_FACING) - .rotateY(); + Direction dir = blockState.getValue(BeltBlock.HORIZONTAL_FACING) + .getClockWise(); if (beltSlope == BeltSlope.SIDEWAYS) dir = Direction.UP; @@ -155,7 +155,7 @@ public class BeltInstance extends KineticTileInstance { private BeltData setup(BeltData key, boolean bottom, SpriteShiftEntry spriteShift) { boolean downward = beltSlope == BeltSlope.DOWNWARD; float rotX = (!diagonal && beltSlope != BeltSlope.HORIZONTAL ? 90 : 0) + (downward ? 180 : 0) + (sideways ? 90 : 0) + (vertical && alongZ ? 180 : 0); - float rotY = facing.getHorizontalAngle() + ((diagonal ^ alongX) && !downward ? 180 : 0) + (sideways && alongZ ? 180 : 0) + (vertical && alongX ? 90 : 0); + float rotY = facing.toYRot() + ((diagonal ^ alongX) && !downward ? 180 : 0) + (sideways && alongZ ? 180 : 0) + (vertical && alongX ? 90 : 0); float rotZ = (sideways ? 90 : 0) + (vertical && alongX ? 90 : 0); Quaternion q = new Quaternion(rotX, rotY, rotZ, true); @@ -167,8 +167,8 @@ public class BeltInstance extends KineticTileInstance { .setRotationOffset(bottom ? 0.5f : 0f) .setColor(tile) .setPosition(getInstancePosition()) - .setBlockLight(world.getLightLevel(LightType.BLOCK, pos)) - .setSkyLight(world.getLightLevel(LightType.SKY, pos)); + .setBlockLight(world.getBrightness(LightType.BLOCK, pos)) + .setSkyLight(world.getBrightness(LightType.SKY, pos)); return key; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltModel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltModel.java index 668cbad48..5a1539690 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltModel.java @@ -51,7 +51,7 @@ public class BeltModel extends BakedModelWrapper { TextureAtlasSprite original = quad.getSprite(); TextureAtlasSprite target = spriteShift.getTarget(); BakedQuad newQuad = QuadHelper.clone(quad); - int[] vertexData = newQuad.getVertexData(); + int[] vertexData = newQuad.getVertices(); for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) { int uvOffset = 16 / 4; @@ -60,9 +60,9 @@ public class BeltModel extends BakedModelWrapper { float u = Float.intBitsToFloat(vertexData[uIndex]); float v = Float.intBitsToFloat(vertexData[vIndex]); vertexData[uIndex] = - Float.floatToRawIntBits(target.getInterpolatedU(SuperByteBuffer.getUnInterpolatedU(original, u))); + Float.floatToRawIntBits(target.getU(SuperByteBuffer.getUnInterpolatedU(original, u))); vertexData[vIndex] = - Float.floatToRawIntBits(target.getInterpolatedV(SuperByteBuffer.getUnInterpolatedV(original, v))); + Float.floatToRawIntBits(target.getV(SuperByteBuffer.getUnInterpolatedV(original, v))); } quads.set(i, newQuad); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltPart.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltPart.java index 90c20c6eb..d864d7bb8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltPart.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltPart.java @@ -8,7 +8,7 @@ public enum BeltPart implements IStringSerializable { START, MIDDLE, END, PULLEY; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } } \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java index 780de7876..1700ae9bc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java @@ -49,7 +49,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { } @Override - public boolean isGlobalRenderer(BeltTileEntity te) { + public boolean shouldRenderOffScreen(BeltTileEntity te) { return te.isController(); } @@ -57,14 +57,14 @@ public class BeltRenderer extends SafeTileEntityRenderer { protected void renderSafe(BeltTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (!Backend.getInstance().canUseInstancing(te.getWorld())) { + if (!Backend.getInstance().canUseInstancing(te.getLevel())) { BlockState blockState = te.getBlockState(); if (!AllBlocks.BELT.has(blockState)) return; - BeltSlope beltSlope = blockState.get(BeltBlock.SLOPE); - BeltPart part = blockState.get(BeltBlock.PART); - Direction facing = blockState.get(BeltBlock.HORIZONTAL_FACING); + BeltSlope beltSlope = blockState.getValue(BeltBlock.SLOPE); + BeltPart part = blockState.getValue(BeltBlock.PART); + Direction facing = blockState.getValue(BeltBlock.HORIZONTAL_FACING); AxisDirection axisDirection = facing.getAxisDirection(); boolean downward = beltSlope == BeltSlope.DOWNWARD; @@ -77,8 +77,8 @@ public class BeltRenderer extends SafeTileEntityRenderer { MatrixStack localTransforms = new MatrixStack(); MatrixStacker msr = MatrixStacker.of(localTransforms); - IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); - float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()); + IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + float renderTick = AnimationTickHolder.getRenderTime(te.getLevel()); msr.centre(); msr.rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0)); @@ -106,13 +106,13 @@ public class BeltRenderer extends SafeTileEntityRenderer { // UV shift float speed = te.getSpeed(); if (speed != 0 || te.color.isPresent()) { - float time = renderTick * axisDirection.getOffset(); + float time = renderTick * axisDirection.getStep(); if (diagonal && (downward ^ alongX) || !sideways && !diagonal && alongX || sideways && axisDirection == AxisDirection.NEGATIVE) speed = -speed; float scrollMult = diagonal ? 3f / 8f : 0.5f; - float spriteSize = spriteShift.getTarget().getMaxV() - spriteShift.getTarget().getMinV(); + float spriteSize = spriteShift.getTarget().getV1() - spriteShift.getTarget().getV0(); double scroll = speed * time / (31.5 * 16) + (bottom ? 0.5 : 0.0); scroll = scroll - Math.floor(scroll); @@ -130,7 +130,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { } if (te.hasPulley()) { - Direction dir = sideways ? Direction.UP : blockState.get(BeltBlock.HORIZONTAL_FACING).rotateY(); + Direction dir = sideways ? Direction.UP : blockState.getValue(BeltBlock.HORIZONTAL_FACING).getClockWise(); Supplier matrixStackSupplier = () -> { MatrixStack stack = new MatrixStack(); @@ -183,25 +183,25 @@ public class BeltRenderer extends SafeTileEntityRenderer { if (te.beltLength == 0) return; - ms.push(); + ms.pushPose(); Direction beltFacing = te.getBeltFacing(); Vector3i directionVec = beltFacing - .getDirectionVec(); - Vector3d beltStartOffset = Vector3d.of(directionVec).scale(-.5) + .getNormal(); + Vector3d beltStartOffset = Vector3d.atLowerCornerOf(directionVec).scale(-.5) .add(.5, 13 / 16f + .125f, .5); ms.translate(beltStartOffset.x, beltStartOffset.y, beltStartOffset.z); BeltSlope slope = te.getBlockState() - .get(BeltBlock.SLOPE); + .getValue(BeltBlock.SLOPE); int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; boolean slopeAlongX = beltFacing .getAxis() == Axis.X; - boolean onContraption = te.getWorld() instanceof WrappedWorld; + boolean onContraption = te.getLevel() instanceof WrappedWorld; for (TransportedItemStack transported : te.getInventory() .getTransportedItems()) { - ms.push(); + ms.pushPose(); MatrixStacker.of(ms) .nudge(transported.angle); float offset = MathHelper.lerp(partialTicks, transported.prevBeltPosition, transported.beltPosition); @@ -218,7 +218,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { if (offset < .5) verticalMovement = 0; verticalMovement = verticalMovement * (Math.min(offset, te.beltLength - .5f) - .5f); - Vector3d offsetVec = Vector3d.of(directionVec).scale(offset) + Vector3d offsetVec = Vector3d.atLowerCornerOf(directionVec).scale(offset) .add(0, verticalMovement, 0); boolean onSlope = slope != BeltSlope.HORIZONTAL && MathHelper.clamp(offset, .5f, te.beltLength - .5f) == offset; @@ -230,7 +230,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { ms.translate(offsetVec.x, offsetVec.y, offsetVec.z); boolean alongX = beltFacing - .rotateY() + .getClockWise() .getAxis() == Axis.X; if (!alongX) sideOffset *= -1; @@ -239,42 +239,42 @@ public class BeltRenderer extends SafeTileEntityRenderer { ItemRenderer itemRenderer = Minecraft.getInstance() .getItemRenderer(); boolean renderUpright = BeltHelper.isItemUpright(transported.stack); - boolean blockItem = itemRenderer.getItemModelWithOverrides(transported.stack, te.getWorld(), null) + boolean blockItem = itemRenderer.getModel(transported.stack, te.getLevel(), null) .isGui3d(); int count = (int) (MathHelper.log2((int) (transported.stack.getCount()))) / 2; Random r = new Random(transported.angle); - if (Minecraft.getInstance().gameSettings.graphicsMode == GraphicsFanciness.FANCY) { - Vector3d shadowPos = Vector3d.of(te.getPos()).add(beltStartOffset.scale(1) + if (Minecraft.getInstance().options.graphicsMode == GraphicsFanciness.FANCY) { + Vector3d shadowPos = Vector3d.atLowerCornerOf(te.getBlockPos()).add(beltStartOffset.scale(1) .add(offsetVec) .add(alongX ? sideOffset : 0, .39, alongX ? 0 : sideOffset)); ShadowRenderHelper.renderShadow(ms, buffer, shadowPos, .75f, blockItem ? .2f : .2f); } if (renderUpright) { - Entity renderViewEntity = Minecraft.getInstance().renderViewEntity; + Entity renderViewEntity = Minecraft.getInstance().cameraEntity; if (renderViewEntity != null) { - Vector3d positionVec = renderViewEntity.getPositionVec(); + Vector3d positionVec = renderViewEntity.position(); Vector3d vectorForOffset = BeltHelper.getVectorForOffset(te, offset); Vector3d diff = vectorForOffset.subtract(positionVec); float yRot = (float) MathHelper.atan2(diff.z, -diff.x); - ms.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float) (yRot + Math.PI / 2))); + ms.mulPose(Vector3f.YP.rotation((float) (yRot + Math.PI / 2))); } ms.translate(0, 3 / 32d, 1 / 16f); } if (!renderUpright) - ms.multiply(new Vector3f(slopeAlongX ? 0 : 1, 0, slopeAlongX ? 1 : 0).getDegreesQuaternion(slopeAngle)); + ms.mulPose(new Vector3f(slopeAlongX ? 0 : 1, 0, slopeAlongX ? 1 : 0).rotationDegrees(slopeAngle)); if (onSlope) ms.translate(0, 1 / 8f, 0); for (int i = 0; i <= count; i++) { - ms.push(); + ms.pushPose(); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(transported.angle)); + ms.mulPose(Vector3f.YP.rotationDegrees(transported.angle)); if (!blockItem && !renderUpright) { ms.translate(0, -.09375, 0); - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); + ms.mulPose(Vector3f.XP.rotationDegrees(90)); } if (blockItem) { @@ -282,21 +282,21 @@ public class BeltRenderer extends SafeTileEntityRenderer { } ms.scale(.5f, .5f, .5f); - itemRenderer.renderItem(transported.stack, TransformType.FIXED, stackLight, overlay, ms, buffer); - ms.pop(); + itemRenderer.renderStatic(transported.stack, TransformType.FIXED, stackLight, overlay, ms, buffer); + ms.popPose(); if (!renderUpright) { if (!blockItem) - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(10)); + ms.mulPose(Vector3f.YP.rotationDegrees(10)); ms.translate(0, blockItem ? 1 / 64d : 1 / 16d, 0); } else ms.translate(0, 0, -1 / 16f); } - ms.pop(); + ms.popPose(); } - ms.pop(); + ms.popPose(); } protected int getPackedLight(BeltTileEntity controller, float beltPos) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltShapes.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltShapes.java index 572fc124d..aa20a4d02 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltShapes.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltShapes.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.relays.belt; -import static net.minecraft.block.Block.makeCuboidShape; +import static net.minecraft.block.Block.box; import java.util.HashMap; import java.util.Map; @@ -76,27 +76,27 @@ public class BeltShapes { FLAT_FULL_PART = makeFlatFull(), FLAT_END_PART = makeFlatEnding(); - private static final VoxelShape SOUTH_MASK = makeCuboidShape(0,-5,8,16,16+5,16); - private static final VoxelShape NORTH_MASK = makeCuboidShape(0,-5,0,16,16+5,8); + private static final VoxelShape SOUTH_MASK = box(0,-5,8,16,16+5,16); + private static final VoxelShape NORTH_MASK = box(0,-5,0,16,16+5,8); //Vertical Shapes private static final VoxelShaper VERTICAL_FULL = VerticalBeltShaper.make(FLAT_FULL_PART), VERTICAL_END = VerticalBeltShaper.make(compose(FLAT_END_PART, FLAT_FULL_PART)), VERTICAL_START = VerticalBeltShaper.make(compose(FLAT_FULL_PART, FLAT_END_PART)); - + //Flat Shapes private static final VoxelShaper FLAT_FULL = VoxelShaper.forHorizontalAxis(FLAT_FULL_PART, Axis.Z), FLAT_END = VoxelShaper.forHorizontal(compose(FLAT_END_PART, FLAT_FULL_PART), Direction.SOUTH), FLAT_START = VoxelShaper.forHorizontal(compose(FLAT_FULL_PART, FLAT_END_PART), Direction.SOUTH); - + //Sideways Shapes private static final VoxelShaper SIDE_FULL = VoxelShaper.forHorizontalAxis(SIDEWAYS_FULL_PART, Axis.Z), SIDE_END = VoxelShaper.forHorizontal(compose(SIDEWAYS_END_PART, SIDEWAYS_FULL_PART), Direction.SOUTH), SIDE_START = VoxelShaper.forHorizontal(compose(SIDEWAYS_FULL_PART, SIDEWAYS_END_PART), Direction.SOUTH); - + //Sloped Shapes private static final VoxelShaper SLOPE_DESC = VoxelShaper.forHorizontal(SLOPE_DESC_PART, Direction.SOUTH), @@ -107,20 +107,20 @@ public class BeltShapes { SLOPE_ASC_START = VoxelShaper.forHorizontal(compose(SLOPE_ASC_PART, FLAT_END_PART), Direction.SOUTH); private static final VoxelShaper - PARTIAL_CASING = VoxelShaper.forHorizontal(makeCuboidShape(0, 0, 5, 16, 11, 16), Direction.SOUTH); + PARTIAL_CASING = VoxelShaper.forHorizontal(box(0, 0, 5, 16, 11, 16), Direction.SOUTH); static Map cache = new HashMap<>(); static Map collisionCache = new HashMap<>(); private static VoxelShape compose(VoxelShape southPart, VoxelShape northPart){ return VoxelShapes.or( - VoxelShapes.combine(SOUTH_MASK, southPart, IBooleanFunction.AND), - VoxelShapes.combine(NORTH_MASK, northPart, IBooleanFunction.AND) + VoxelShapes.joinUnoptimized(SOUTH_MASK, southPart, IBooleanFunction.AND), + VoxelShapes.joinUnoptimized(NORTH_MASK, northPart, IBooleanFunction.AND) ); } private static VoxelShape makeSlopePart(boolean ascendingInstead) { - VoxelShape slice = makeCuboidShape(1, 0, 16, 15, 11, 15); + VoxelShape slice = box(1, 0, 16, 15, 11, 15); VoxelShape result = VoxelShapes.empty(); for (int i = 0; i < 16; i++) { @@ -129,7 +129,7 @@ public class BeltShapes { result = VoxelShapes.or( result,//move slice i voxels "right" and i-5 voxels "down" - slice.withOffset(0, yOffset / 16f, -i / 16f)); + slice.move(0, yOffset / 16f, -i / 16f)); } return result; @@ -137,24 +137,24 @@ public class BeltShapes { private static VoxelShape makeFlatEnding(){ return VoxelShapes.or( - makeCuboidShape(1,4,0,15,12,16), - makeCuboidShape(1,3,1,15,13,15) + box(1,4,0,15,12,16), + box(1,3,1,15,13,15) ); } private static VoxelShape makeFlatFull(){ - return makeCuboidShape(1,3,0,15,13,16); + return box(1,3,0,15,13,16); } - + private static VoxelShape makeSidewaysEnding(){ return VoxelShapes.or( - makeCuboidShape(4,1,0,12,15,16), - makeCuboidShape(3,1,1,13,15,15) + box(4,1,0,12,15,16), + box(3,1,1,13,15,15) ); } - + private static VoxelShape makeSidewaysFull(){ - return makeCuboidShape(3,1,0,13,15,16); + return box(3,1,0,13,15,16); } public static VoxelShape getShape(BlockState state) { @@ -164,20 +164,20 @@ public class BeltShapes { cache.put(state, createdShape); return createdShape; } - + public static VoxelShape getCollisionShape(BlockState state) { if (collisionCache.containsKey(state)) return collisionCache.get(state); - VoxelShape createdShape = VoxelShapes.combine(AllShapes.BELT_COLLISION_MASK, getShape(state), IBooleanFunction.AND); + VoxelShape createdShape = VoxelShapes.joinUnoptimized(AllShapes.BELT_COLLISION_MASK, getShape(state), IBooleanFunction.AND); collisionCache.put(state, createdShape); return createdShape; } private static VoxelShape getBeltShape(BlockState state) { - Direction facing = state.get(BeltBlock.HORIZONTAL_FACING); + Direction facing = state.getValue(BeltBlock.HORIZONTAL_FACING); Axis axis = facing.getAxis(); - BeltPart part = state.get(BeltBlock.PART); - BeltSlope slope = state.get(BeltBlock.SLOPE); + BeltPart part = state.getValue(BeltBlock.PART); + BeltSlope slope = state.getValue(BeltBlock.SLOPE); //vertical if (slope == BeltSlope.VERTICAL) { @@ -194,7 +194,7 @@ public class BeltShapes { //flat ending return (part == BeltPart.START ? FLAT_START : FLAT_END).get(facing); } - + //sideways part if (slope == BeltSlope.SIDEWAYS) { if (part == BeltPart.MIDDLE || part == BeltPart.PULLEY) @@ -217,12 +217,12 @@ public class BeltShapes { } private static VoxelShape getCasingShape(BlockState state) { - if (!state.get(BeltBlock.CASING)) + if (!state.getValue(BeltBlock.CASING)) return VoxelShapes.empty(); - Direction facing = state.get(BeltBlock.HORIZONTAL_FACING); - BeltPart part = state.get(BeltBlock.PART); - BeltSlope slope = state.get(BeltBlock.SLOPE); + Direction facing = state.getValue(BeltBlock.HORIZONTAL_FACING); + BeltPart part = state.getValue(BeltBlock.PART); + BeltSlope slope = state.getValue(BeltBlock.SLOPE); if (slope == BeltSlope.VERTICAL) return VoxelShapes.empty(); @@ -242,7 +242,7 @@ public class BeltShapes { return slope == BeltSlope.DOWNWARD ? AllShapes.CASING_11PX.get(Direction.UP) : PARTIAL_CASING.get(facing); //something went wrong - return VoxelShapes.fullCube(); + return VoxelShapes.block(); } private static class VerticalBeltShaper extends VoxelShaper { @@ -254,7 +254,7 @@ public class BeltShapes { Direction.Plane.HORIZONTAL,//idk, this can probably be improved :S direction -> new Vector3d( direction.getAxisDirection() == Direction.AxisDirection.POSITIVE ? 0 : 180, - -direction.getHorizontalAngle(), + -direction.toYRot(), 0)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltSlope.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltSlope.java index ba8b4a8f5..16114f955 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltSlope.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltSlope.java @@ -8,7 +8,7 @@ public enum BeltSlope implements IStringSerializable { HORIZONTAL, UPWARD, DOWNWARD, VERTICAL, SIDEWAYS; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java index 5beca0399..30ac4da87 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java @@ -105,8 +105,8 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis // Init belt if (beltLength == 0) - BeltBlock.initBelt(world, pos); - if (!AllBlocks.BELT.has(world.getBlockState(pos))) + BeltBlock.initBelt(level, worldPosition); + if (!AllBlocks.BELT.has(level.getBlockState(worldPosition))) return; initializeItemHandler(); @@ -115,7 +115,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis if (!isController()) return; - if (light == null && world.isRemote) { + if (light == null && level.isClientSide) { initializeLight(); LightUpdater.getInstance() .startListening(getBeltVolume(), this); @@ -134,7 +134,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis passengers.forEach((entity, info) -> { boolean canBeTransported = BeltMovementHandler.canBeTransported(entity); boolean leftTheBelt = - info.getTicksSinceLastCollision() > ((getBlockState().get(BeltBlock.SLOPE) != HORIZONTAL) ? 3 : 1); + info.getTicksSinceLastCollision() > ((getBlockState().getValue(BeltBlock.SLOPE) != HORIZONTAL) ? 3 : 1); if (!canBeTransported || leftTheBelt) { toRemove.add(entity); return; @@ -158,15 +158,15 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis if (!isController()) return super.makeRenderBoundingBox(); else - return super.makeRenderBoundingBox().grow(beltLength + 1); + return super.makeRenderBoundingBox().inflate(beltLength + 1); } protected void initializeItemHandler() { - if (world.isRemote || itemHandler.isPresent()) + if (level.isClientSide || itemHandler.isPresent()) return; - if (!world.isBlockPresent(controller)) + if (!level.isLoaded(controller)) return; - TileEntity te = world.getTileEntity(controller); + TileEntity te = level.getBlockEntity(controller); if (te == null || !(te instanceof BeltTileEntity)) return; BeltInventory inventory = ((BeltTileEntity) te).getInventory(); @@ -187,8 +187,8 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis } @Override - public void remove() { - super.remove(); + public void setRemoved() { + super.setRemoved(); itemHandler.invalidate(); } @@ -214,7 +214,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis super.fromTag(state, compound, clientPacket); if (compound.getBoolean("IsController")) - controller = pos; + controller = worldPosition; color = compound.contains("Dye") ? Optional.of(NBTHelper.readEnum(compound, "Dye", DyeColor.class)) : Optional.empty(); @@ -240,8 +240,8 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis return; if (!isVirtual()) requestModelDataUpdate(); - if (hasWorld()) - world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 16); + if (hasLevel()) + level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), 16); } @Override @@ -260,12 +260,12 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis } else if (color.isPresent() && color.get() == colorIn) return; - for (BlockPos blockPos : BeltBlock.getBeltChain(world, getController())) { - BeltTileEntity belt = BeltHelper.getSegmentTE(world, blockPos); + for (BlockPos blockPos : BeltBlock.getBeltChain(level, getController())) { + BeltTileEntity belt = BeltHelper.getSegmentTE(level, blockPos); if (belt == null) continue; belt.color = Optional.ofNullable(colorIn); - belt.markDirty(); + belt.setChanged(); belt.sendData(); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(belt)); } @@ -274,9 +274,9 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis public BeltTileEntity getControllerTE() { if (controller == null) return null; - if (!world.isBlockPresent(controller)) + if (!level.isLoaded(controller)) return null; - TileEntity te = world.getTileEntity(controller); + TileEntity te = level.getBlockEntity(controller); if (te == null || !(te instanceof BeltTileEntity)) return null; return (BeltTileEntity) te; @@ -287,12 +287,12 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis } public BlockPos getController() { - return controller == null ? pos : controller; + return controller == null ? worldPosition : controller; } public boolean isController() { - return controller != null && pos.getX() == controller.getX() && pos.getY() == controller.getY() - && pos.getZ() == controller.getZ(); + return controller != null && worldPosition.getX() == controller.getX() && worldPosition.getY() == controller.getY() + && worldPosition.getZ() == controller.getZ(); } public float getBeltMovementSpeed() { @@ -301,7 +301,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis public float getDirectionAwareBeltMovementSpeed() { int offset = getBeltFacing().getAxisDirection() - .getOffset(); + .getStep(); if (getBeltFacing().getAxis() == Axis.X) offset *= -1; return getBeltMovementSpeed() * offset; @@ -310,7 +310,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis public boolean hasPulley() { if (!AllBlocks.BELT.has(getBlockState())) return false; - return getBlockState().get(BeltBlock.PART) != MIDDLE; + return getBlockState().getValue(BeltBlock.PART) != MIDDLE; } protected boolean isLastBelt() { @@ -318,15 +318,15 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis return false; Direction direction = getBeltFacing(); - if (getBlockState().get(BeltBlock.SLOPE) == BeltSlope.VERTICAL) + if (getBlockState().getValue(BeltBlock.SLOPE) == BeltSlope.VERTICAL) return false; - BeltPart part = getBlockState().get(BeltBlock.PART); + BeltPart part = getBlockState().getValue(BeltBlock.PART); if (part == MIDDLE) return false; boolean movingPositively = (getSpeed() > 0 == (direction.getAxisDirection() - .getOffset() == 1)) ^ direction.getAxis() == Axis.X; + .getStep() == 1)) ^ direction.getAxis() == Axis.X; return part == BeltPart.START ^ movingPositively; } @@ -343,16 +343,16 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis return BlockPos.ZERO; final BlockState blockState = getBlockState(); - final Direction beltFacing = blockState.get(BlockStateProperties.HORIZONTAL_FACING); - final BeltSlope slope = blockState.get(BeltBlock.SLOPE); - final BeltPart part = blockState.get(BeltBlock.PART); + final Direction beltFacing = blockState.getValue(BlockStateProperties.HORIZONTAL_FACING); + final BeltSlope slope = blockState.getValue(BeltBlock.SLOPE); + final BeltPart part = blockState.getValue(BeltBlock.PART); final Axis axis = beltFacing.getAxis(); - Direction movementFacing = Direction.getFacingFromAxis(axis == Axis.X ? NEGATIVE : POSITIVE, axis); - boolean notHorizontal = blockState.get(BeltBlock.SLOPE) != HORIZONTAL; + Direction movementFacing = Direction.get(axis == Axis.X ? NEGATIVE : POSITIVE, axis); + boolean notHorizontal = blockState.getValue(BeltBlock.SLOPE) != HORIZONTAL; if (getSpeed() < 0) movementFacing = movementFacing.getOpposite(); - Vector3i movement = movementFacing.getDirectionVec(); + Vector3i movement = movementFacing.getNormal(); boolean slopeBeforeHalf = (part == BeltPart.END) == (beltFacing.getAxisDirection() == POSITIVE); boolean onSlope = notHorizontal && (part == MIDDLE || slopeBeforeHalf == firstHalf || ignoreHalves); @@ -366,12 +366,12 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis public Direction getMovementFacing() { Axis axis = getBeltFacing().getAxis(); - return Direction.getFacingFromAxisDirection(axis, + return Direction.fromAxisAndDirection(axis, getBeltMovementSpeed() < 0 ^ axis == Axis.X ? NEGATIVE : POSITIVE); } protected Direction getBeltFacing() { - return getBlockState().get(BlockStateProperties.HORIZONTAL_FACING); + return getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING); } public BeltInventory getInventory() { @@ -408,15 +408,15 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis if (casing == type) return; if (casing != CasingType.NONE) - world.playEvent(2001, pos, - Block.getStateId(casing == CasingType.ANDESITE ? AllBlocks.ANDESITE_CASING.getDefaultState() + level.levelEvent(2001, worldPosition, + Block.getId(casing == CasingType.ANDESITE ? AllBlocks.ANDESITE_CASING.getDefaultState() : AllBlocks.BRASS_CASING.getDefaultState())); casing = type; boolean shouldBlockHaveCasing = type != CasingType.NONE; BlockState blockState = getBlockState(); - if (blockState.get(BeltBlock.CASING) != shouldBlockHaveCasing) - KineticTileEntity.switchToBlockState(world, pos, blockState.with(BeltBlock.CASING, shouldBlockHaveCasing)); - markDirty(); + if (blockState.getValue(BeltBlock.CASING) != shouldBlockHaveCasing) + KineticTileEntity.switchToBlockState(level, worldPosition, blockState.setValue(BeltBlock.CASING, shouldBlockHaveCasing)); + setChanged(); sendData(); } @@ -424,8 +424,8 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis if (getSpeed() == 0) return false; BlockState state = getBlockState(); - if (state.contains(BeltBlock.SLOPE) - && (state.get(BeltBlock.SLOPE) == BeltSlope.SIDEWAYS || state.get(BeltBlock.SLOPE) == BeltSlope.VERTICAL)) + if (state.hasProperty(BeltBlock.SLOPE) + && (state.getValue(BeltBlock.SLOPE) == BeltSlope.SIDEWAYS || state.getValue(BeltBlock.SLOPE) == BeltSlope.VERTICAL)) return false; return getMovementFacing() != side.getOpposite(); } @@ -441,7 +441,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis if (nextInventory == null) return inserted; - TileEntity teAbove = world.getTileEntity(pos.up()); + TileEntity teAbove = level.getBlockEntity(worldPosition.above()); if (teAbove instanceof BrassTunnelTileEntity) { BrassTunnelTileEntity tunnelTE = (BrassTunnelTileEntity) teAbove; if (tunnelTE.hasDistributionBehaviour()) { @@ -475,7 +475,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis .isVertical()) { if (movementFacing != side) { transportedStack.sideOffset = side.getAxisDirection() - .getOffset() * .35f; + .getStep() * .35f; if (side.getAxis() == Axis.X) transportedStack.sideOffset *= -1; } else @@ -490,7 +490,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis BeltTunnelInteractionHandler.flapTunnel(nextInventory, index, side.getOpposite(), true); nextInventory.addItem(transportedStack); - nextBeltController.markDirty(); + nextBeltController.setChanged(); nextBeltController.sendData(); return empty; } @@ -505,8 +505,8 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis @Override protected boolean canPropagateDiagonally(IRotate block, BlockState state) { - return state.contains(BeltBlock.SLOPE) - && (state.get(BeltBlock.SLOPE) == BeltSlope.UPWARD || state.get(BeltBlock.SLOPE) == BeltSlope.DOWNWARD); + return state.hasProperty(BeltBlock.SLOPE) + && (state.getValue(BeltBlock.SLOPE) == BeltSlope.UPWARD || state.getValue(BeltBlock.SLOPE) == BeltSlope.DOWNWARD); } @Override @@ -519,15 +519,15 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis @Override public boolean shouldRenderNormally() { - if (world == null) + if (level == null) return isController(); BlockState state = getBlockState(); - return state != null && state.contains(BeltBlock.PART) && state.get(BeltBlock.PART) == BeltPart.START; + return state != null && state.hasProperty(BeltBlock.PART) && state.getValue(BeltBlock.PART) == BeltPart.START; } @Override public boolean onLightUpdate(IBlockDisplayReader world, LightType type, GridAlignedBB changed) { - if (this.removed) { + if (this.remove) { return true; } @@ -547,7 +547,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis private GridAlignedBB getBeltVolume() { BlockPos endPos = BeltHelper.getPositionForOffset(this, beltLength - 1); - GridAlignedBB bb = GridAlignedBB.from(pos, endPos); + GridAlignedBB bb = GridAlignedBB.from(worldPosition, endPos); bb.fixMinMax(); return bb; } @@ -556,40 +556,40 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis if (beltLength > 0) { light = new byte[beltLength * 2]; - Vector3i vec = getBeltFacing().getDirectionVec(); - BeltSlope slope = getBlockState().get(BeltBlock.SLOPE); + Vector3i vec = getBeltFacing().getNormal(); + BeltSlope slope = getBlockState().getValue(BeltBlock.SLOPE); int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; BlockPos.Mutable pos = new BlockPos.Mutable(controller.getX(), controller.getY(), controller.getZ()); for (int i = 0; i < beltLength * 2; i += 2) { - light[i] = (byte) world.getLightLevel(LightType.BLOCK, pos); - light[i + 1] = (byte) world.getLightLevel(LightType.SKY, pos); + light[i] = (byte) level.getBrightness(LightType.BLOCK, pos); + light[i + 1] = (byte) level.getBrightness(LightType.SKY, pos); pos.move(vec.getX(), verticality, vec.getZ()); } } } private void updateBlockLight() { - Vector3i vec = getBeltFacing().getDirectionVec(); - BeltSlope slope = getBlockState().get(BeltBlock.SLOPE); + Vector3i vec = getBeltFacing().getNormal(); + BeltSlope slope = getBlockState().getValue(BeltBlock.SLOPE); int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; BlockPos.Mutable pos = new BlockPos.Mutable(controller.getX(), controller.getY(), controller.getZ()); for (int i = 0; i < beltLength * 2; i += 2) { - light[i] = (byte) world.getLightLevel(LightType.BLOCK, pos); + light[i] = (byte) level.getBrightness(LightType.BLOCK, pos); pos.move(vec.getX(), verticality, vec.getZ()); } } private void updateSkyLight() { - Vector3i vec = getBeltFacing().getDirectionVec(); - BeltSlope slope = getBlockState().get(BeltBlock.SLOPE); + Vector3i vec = getBeltFacing().getNormal(); + BeltSlope slope = getBlockState().getValue(BeltBlock.SLOPE); int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; BlockPos.Mutable pos = new BlockPos.Mutable(controller.getX(), controller.getY(), controller.getZ()); for (int i = 1; i < beltLength * 2; i += 2) { - light[i] = (byte) world.getLightLevel(LightType.SKY, pos); + light[i] = (byte) level.getBrightness(LightType.SKY, pos); pos.move(vec.getX(), verticality, vec.getZ()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorHandler.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorHandler.java index 420cf78e5..d6c8d2719 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorHandler.java @@ -29,15 +29,15 @@ public class BeltConnectorHandler { public static void tick() { PlayerEntity player = Minecraft.getInstance().player; - World world = Minecraft.getInstance().world; + World world = Minecraft.getInstance().level; if (player == null || world == null) return; - if (Minecraft.getInstance().currentScreen != null) + if (Minecraft.getInstance().screen != null) return; for (Hand hand : Hand.values()) { - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); if (!AllItems.BELT_CONNECTOR.isIn(heldItem)) continue; @@ -50,12 +50,12 @@ public class BeltConnectorHandler { BlockPos first = NBTUtil.readBlockPos(tag.getCompound("FirstPulley")); - if (!world.getBlockState(first).contains(BlockStateProperties.AXIS)) + if (!world.getBlockState(first).hasProperty(BlockStateProperties.AXIS)) continue; Axis axis = world.getBlockState(first) - .get(BlockStateProperties.AXIS); + .getValue(BlockStateProperties.AXIS); - RayTraceResult rayTrace = Minecraft.getInstance().objectMouseOver; + RayTraceResult rayTrace = Minecraft.getInstance().hitResult; if (rayTrace == null || !(rayTrace instanceof BlockRayTraceResult)) { if (r.nextInt(50) == 0) { world.addParticle(new RedstoneParticleData(.3f, .9f, .5f, 1), @@ -65,25 +65,25 @@ public class BeltConnectorHandler { return; } - BlockPos selected = ((BlockRayTraceResult) rayTrace).getPos(); + BlockPos selected = ((BlockRayTraceResult) rayTrace).getBlockPos(); if (world.getBlockState(selected) .getMaterial() .isReplaceable()) return; if (!ShaftBlock.isShaft(world.getBlockState(selected))) - selected = selected.offset(((BlockRayTraceResult) rayTrace).getFace()); - if (!selected.withinDistance(first, AllConfigs.SERVER.kinetics.maxBeltLength.get())) + selected = selected.relative(((BlockRayTraceResult) rayTrace).getDirection()); + if (!selected.closerThan(first, AllConfigs.SERVER.kinetics.maxBeltLength.get())) return; boolean canConnect = BeltConnectorItem.validateAxis(world, selected) && BeltConnectorItem.canConnect(world, first, selected); - Vector3d start = Vector3d.of(first); - Vector3d end = Vector3d.of(selected); + Vector3d start = Vector3d.atLowerCornerOf(first); + Vector3d end = Vector3d.atLowerCornerOf(selected); Vector3d actualDiff = end.subtract(start); - end = end.subtract(axis.getCoordinate(actualDiff.x, 0, 0), axis.getCoordinate(0, actualDiff.y, 0), - axis.getCoordinate(0, 0, actualDiff.z)); + end = end.subtract(axis.choose(actualDiff.x, 0, 0), axis.choose(0, actualDiff.y, 0), + axis.choose(0, 0, actualDiff.z)); Vector3d diff = end.subtract(start); double x = Math.abs(diff.x); @@ -98,7 +98,7 @@ public class BeltConnectorHandler { for (int i = -1; i <= 1; i++) for (int j = -1; j <= 1; j++) for (int k = -1; k <= 1; k++) { - if (axis.getCoordinate(i, j, k) != 0) + if (axis.choose(i, j, k) != 0) continue; if (axis == Axis.Y && i != 0 && k != 0) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java index 442431fa5..733031c90 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java @@ -34,6 +34,8 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.item.Item.Properties; + public class BeltConnectorItem extends BlockItem { public BeltConnectorItem(Properties properties) { @@ -41,44 +43,44 @@ public class BeltConnectorItem extends BlockItem { } @Override - public String getTranslationKey() { - return getDefaultTranslationKey(); + public String getDescriptionId() { + return getOrCreateDescriptionId(); } @Override - public void fillItemGroup(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { if (p_150895_1_ == Create.BASE_CREATIVE_TAB) return; - super.fillItemGroup(p_150895_1_, p_150895_2_); + super.fillItemCategory(p_150895_1_, p_150895_2_); } @Nonnull @Override - public ActionResultType onItemUse(ItemUseContext context) { + public ActionResultType useOn(ItemUseContext context) { PlayerEntity playerEntity = context.getPlayer(); - if (playerEntity != null && playerEntity.isSneaking()) { - context.getItem() + if (playerEntity != null && playerEntity.isShiftKeyDown()) { + context.getItemInHand() .setTag(null); return ActionResultType.SUCCESS; } - World world = context.getWorld(); - BlockPos pos = context.getPos(); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); boolean validAxis = validateAxis(world, pos); - if (world.isRemote) + if (world.isClientSide) return validAxis ? ActionResultType.SUCCESS : ActionResultType.FAIL; - CompoundNBT tag = context.getItem() + CompoundNBT tag = context.getItemInHand() .getOrCreateTag(); BlockPos firstPulley = null; // Remove first if no longer existant or valid if (tag.contains("FirstPulley")) { firstPulley = NBTUtil.readBlockPos(tag.getCompound("FirstPulley")); - if (!validateAxis(world, firstPulley) || !firstPulley.withinDistance(pos, maxLength() * 2)) { + if (!validateAxis(world, firstPulley) || !firstPulley.closerThan(pos, maxLength() * 2)) { tag.remove("FirstPulley"); - context.getItem() + context.getItemInHand() .setTag(tag); } } @@ -95,25 +97,25 @@ public class BeltConnectorItem extends BlockItem { createBelts(world, firstPulley, pos); AllTriggers.triggerFor(AllTriggers.CONNECT_BELT, playerEntity); if (!playerEntity.isCreative()) - context.getItem() + context.getItemInHand() .shrink(1); } - if (!context.getItem() + if (!context.getItemInHand() .isEmpty()) { - context.getItem() + context.getItemInHand() .setTag(null); - playerEntity.getCooldownTracker() - .setCooldown(this, 5); + playerEntity.getCooldowns() + .addCooldown(this, 5); } return ActionResultType.SUCCESS; } tag.put("FirstPulley", NBTUtil.writeBlockPos(pos)); - context.getItem() + context.getItemInHand() .setTag(tag); - playerEntity.getCooldownTracker() - .setCooldown(this, 5); + playerEntity.getCooldowns() + .addCooldown(this, 5); return ActionResultType.SUCCESS; } @@ -124,8 +126,8 @@ public class BeltConnectorItem extends BlockItem { BlockPos diff = end.subtract(start); if (diff.getX() == diff.getZ()) - facing = Direction.getFacingFromAxis(facing.getAxisDirection(), world.getBlockState(start) - .get(BlockStateProperties.AXIS) == Axis.X ? Axis.Z : Axis.X); + facing = Direction.get(facing.getAxisDirection(), world.getBlockState(start) + .getValue(BlockStateProperties.AXIS) == Axis.X ? Axis.Z : Axis.X); List beltsToCreate = getBeltChainBetween(start, end, slope, facing); BlockState beltBlock = AllBlocks.BELT.getDefaultState(); @@ -136,11 +138,11 @@ public class BeltConnectorItem extends BlockItem { boolean pulley = ShaftBlock.isShaft(shaftState); if (part == BeltPart.MIDDLE && pulley) part = BeltPart.PULLEY; - if (pulley && shaftState.get(AbstractShaftBlock.AXIS) == Axis.Y) + if (pulley && shaftState.getValue(AbstractShaftBlock.AXIS) == Axis.Y) slope = BeltSlope.SIDEWAYS; - KineticTileEntity.switchToBlockState(world, pos, beltBlock.with(BeltBlock.SLOPE, slope) - .with(BeltBlock.PART, part) - .with(BeltBlock.HORIZONTAL_FACING, facing)); + KineticTileEntity.switchToBlockState(world, pos, beltBlock.setValue(BeltBlock.SLOPE, slope) + .setValue(BeltBlock.PART, part) + .setValue(BeltBlock.HORIZONTAL_FACING, facing)); } } @@ -152,10 +154,10 @@ public class BeltConnectorItem extends BlockItem { if (diff.getX() == 0 && diff.getZ() == 0) axisDirection = diff.getY() > 0 ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; else - axisDirection = beltAxis.getCoordinate(diff.getX(), 0, diff.getZ()) > 0 ? AxisDirection.POSITIVE + axisDirection = beltAxis.choose(diff.getX(), 0, diff.getZ()) > 0 ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; - return Direction.getFacingFromAxis(axisDirection, beltAxis); + return Direction.get(axisDirection, beltAxis); } private static BeltSlope getSlopeBetween(BlockPos start, BlockPos end) { @@ -178,13 +180,13 @@ public class BeltConnectorItem extends BlockItem { positions.add(current); if (slope == BeltSlope.VERTICAL) { - current = current.up(direction.getAxisDirection() == AxisDirection.POSITIVE ? 1 : -1); + current = current.above(direction.getAxisDirection() == AxisDirection.POSITIVE ? 1 : -1); continue; } - current = current.offset(direction); + current = current.relative(direction); if (slope != BeltSlope.HORIZONTAL) - current = current.up(slope == BeltSlope.UPWARD ? 1 : -1); + current = current.above(slope == BeltSlope.UPWARD ? 1 : -1); } while (!current.equals(end) && limit-- > 0); @@ -197,12 +199,12 @@ public class BeltConnectorItem extends BlockItem { return false; if (!world.isAreaLoaded(second, 1)) return false; - if (!second.withinDistance(first, maxLength())) + if (!second.closerThan(first, maxLength())) return false; BlockPos diff = second.subtract(first); Axis shaftAxis = world.getBlockState(first) - .get(BlockStateProperties.AXIS); + .getValue(BlockStateProperties.AXIS); int x = diff.getX(); int y = diff.getY(); @@ -210,18 +212,18 @@ public class BeltConnectorItem extends BlockItem { int sames = ((Math.abs(x) == Math.abs(y)) ? 1 : 0) + ((Math.abs(y) == Math.abs(z)) ? 1 : 0) + ((Math.abs(z) == Math.abs(x)) ? 1 : 0); - if (shaftAxis.getCoordinate(x, y, z) != 0) + if (shaftAxis.choose(x, y, z) != 0) return false; if (sames != 1) return false; if (shaftAxis != world.getBlockState(second) - .get(BlockStateProperties.AXIS)) + .getValue(BlockStateProperties.AXIS)) return false; if (shaftAxis == Axis.Y && x != 0 && z != 0) return false; - TileEntity tileEntity = world.getTileEntity(first); - TileEntity tileEntity2 = world.getTileEntity(second); + TileEntity tileEntity = world.getBlockEntity(first); + TileEntity tileEntity2 = world.getBlockEntity(second); if (!(tileEntity instanceof KineticTileEntity)) return false; @@ -235,10 +237,10 @@ public class BeltConnectorItem extends BlockItem { BlockPos step = new BlockPos(Math.signum(diff.getX()), Math.signum(diff.getY()), Math.signum(diff.getZ())); int limit = 1000; - for (BlockPos currentPos = first.add(step); !currentPos.equals(second) && limit-- > 0; currentPos = - currentPos.add(step)) { + for (BlockPos currentPos = first.offset(step); !currentPos.equals(second) && limit-- > 0; currentPos = + currentPos.offset(step)) { BlockState blockState = world.getBlockState(currentPos); - if (ShaftBlock.isShaft(blockState) && blockState.get(AbstractShaftBlock.AXIS) == shaftAxis) + if (ShaftBlock.isShaft(blockState) && blockState.getValue(AbstractShaftBlock.AXIS) == shaftAxis) continue; if (!blockState.getMaterial() .isReplaceable()) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltCrusherInteractionHandler.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltCrusherInteractionHandler.java index 39400e412..8399a5788 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltCrusherInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltCrusherInteractionHandler.java @@ -26,12 +26,12 @@ public class BeltCrusherInteractionHandler { for (int segment = firstUpcomingSegment; beltMovementPositive ? segment <= nextOffset : segment + 1 >= nextOffset; segment += step) { BlockPos crusherPos = BeltHelper.getPositionForOffset(beltInventory.belt, segment) - .up(); - World world = beltInventory.belt.getWorld(); + .above(); + World world = beltInventory.belt.getLevel(); BlockState crusherState = world.getBlockState(crusherPos); if (!(crusherState.getBlock() instanceof CrushingWheelControllerBlock)) continue; - Direction crusherFacing = crusherState.get(CrushingWheelControllerBlock.FACING); + Direction crusherFacing = crusherState.getValue(CrushingWheelControllerBlock.FACING); Direction movementFacing = beltInventory.belt.getMovementFacing(); if (crusherFacing != movementFacing) continue; @@ -46,7 +46,7 @@ public class BeltCrusherInteractionHandler { return false; currentItem.beltPosition = crusherEntry; - TileEntity te = world.getTileEntity(crusherPos); + TileEntity te = world.getBlockEntity(crusherPos); if (!(te instanceof CrushingWheelControllerTileEntity)) return true; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltFunnelInteractionHandler.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltFunnelInteractionHandler.java index 8ea4af97f..b2c504191 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltFunnelInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltFunnelInteractionHandler.java @@ -28,21 +28,21 @@ public class BeltFunnelInteractionHandler { for (int segment = firstUpcomingSegment; beltMovementPositive ? segment <= nextOffset : segment + 1 >= nextOffset; segment += step) { BlockPos funnelPos = BeltHelper.getPositionForOffset(beltInventory.belt, segment) - .up(); - World world = beltInventory.belt.getWorld(); + .above(); + World world = beltInventory.belt.getLevel(); BlockState funnelState = world.getBlockState(funnelPos); if (!(funnelState.getBlock() instanceof BeltFunnelBlock)) continue; - Direction funnelFacing = funnelState.get(BeltFunnelBlock.HORIZONTAL_FACING); + Direction funnelFacing = funnelState.getValue(BeltFunnelBlock.HORIZONTAL_FACING); Direction movementFacing = beltInventory.belt.getMovementFacing(); boolean blocking = funnelFacing == movementFacing.getOpposite(); if (funnelFacing == movementFacing) continue; - if (funnelState.get(BeltFunnelBlock.SHAPE) == Shape.PUSHING) + if (funnelState.getValue(BeltFunnelBlock.SHAPE) == Shape.PUSHING) continue; float funnelEntry = segment + .5f; - if (funnelState.get(BeltFunnelBlock.SHAPE) == Shape.EXTENDED) + if (funnelState.getValue(BeltFunnelBlock.SHAPE) == Shape.EXTENDED) funnelEntry += .499f * (beltMovementPositive ? -1 : 1); boolean hasCrossed = nextOffset > funnelEntry && beltMovementPositive @@ -52,13 +52,13 @@ public class BeltFunnelInteractionHandler { if (blocking) currentItem.beltPosition = funnelEntry; - if (world.isRemote || funnelState.method_28500(BeltFunnelBlock.POWERED).orElse(false)) + if (world.isClientSide || funnelState.getOptionalValue(BeltFunnelBlock.POWERED).orElse(false)) if (blocking) return true; else continue; - TileEntity te = world.getTileEntity(funnelPos); + TileEntity te = world.getBlockEntity(funnelPos); if (!(te instanceof FunnelTileEntity)) return true; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java index d445f9567..a7e684e09 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java @@ -55,7 +55,7 @@ public class BeltInventory { toInsert.clear(); items.removeAll(toRemove); toRemove.clear(); - belt.markDirty(); + belt.setChanged(); belt.sendData(); } @@ -66,7 +66,7 @@ public class BeltInventory { if (beltMovementPositive != belt.getDirectionAwareBeltMovementSpeed() > 0) { beltMovementPositive = !beltMovementPositive; Collections.reverse(items); - belt.markDirty(); + belt.setChanged(); belt.sendData(); } @@ -79,10 +79,10 @@ public class BeltInventory { float beltSpeed = belt.getDirectionAwareBeltMovementSpeed(); Direction movementFacing = belt.getMovementFacing(); boolean horizontal = belt.getBlockState() - .get(BeltBlock.SLOPE) == BeltSlope.HORIZONTAL; + .getValue(BeltBlock.SLOPE) == BeltSlope.HORIZONTAL; float spacing = 1; - World world = belt.getWorld(); - boolean onClient = world.isRemote && !belt.isVirtual(); + World world = belt.getLevel(); + boolean onClient = world.isClientSide && !belt.isVirtual(); // resolve ending only when items will reach it this tick Ending ending = Ending.UNRESOLVED; @@ -105,7 +105,7 @@ public class BeltInventory { movement *= ServerSpeedProvider.get(); // Don't move if held by processing (client) - if (world.isRemote && currentItem.locked) + if (world.isClientSide && currentItem.locked) continue; // Don't move if held by external components @@ -256,7 +256,7 @@ public class BeltInventory { continue; if (stackHandlerBehaviour == null) continue; - if (BeltProcessingBehaviour.isBlocked(belt.getWorld(), BeltHelper.getPositionForOffset(belt, segment))) + if (BeltProcessingBehaviour.isBlocked(belt.getLevel(), BeltHelper.getPositionForOffset(belt, segment))) continue; ProcessingResult result = processingBehaviour.handleReceivedItem(currentItem, stackHandlerBehaviour); @@ -276,12 +276,12 @@ public class BeltInventory { } protected BeltProcessingBehaviour getBeltProcessingAtSegment(int segment) { - return TileEntityBehaviour.get(belt.getWorld(), BeltHelper.getPositionForOffset(belt, segment) - .up(2), BeltProcessingBehaviour.TYPE); + return TileEntityBehaviour.get(belt.getLevel(), BeltHelper.getPositionForOffset(belt, segment) + .above(2), BeltProcessingBehaviour.TYPE); } protected TransportedItemStackHandlerBehaviour getTransportedItemStackHandlerAtSegment(int segment) { - return TileEntityBehaviour.get(belt.getWorld(), BeltHelper.getPositionForOffset(belt, segment), + return TileEntityBehaviour.get(belt.getLevel(), BeltHelper.getPositionForOffset(belt, segment), TransportedItemStackHandlerBehaviour.TYPE); } @@ -296,7 +296,7 @@ public class BeltInventory { } private Ending resolveEnding() { - World world = belt.getWorld(); + World world = belt.getLevel(); BlockPos nextPosition = BeltHelper.getPositionForOffset(belt, beltMovementPositive ? belt.beltLength : -1); // if (AllBlocks.BRASS_BELT_FUNNEL.has(world.getBlockState(lastPosition.up()))) @@ -397,15 +397,15 @@ public class BeltInventory { ItemStack ejected = stack.stack; Vector3d outPos = BeltHelper.getVectorForOffset(belt, stack.beltPosition); float movementSpeed = Math.max(Math.abs(belt.getBeltMovementSpeed()), 1 / 8f); - Vector3d outMotion = Vector3d.of(belt.getBeltChainDirection()).scale(movementSpeed) + Vector3d outMotion = Vector3d.atLowerCornerOf(belt.getBeltChainDirection()).scale(movementSpeed) .add(0, 1 / 8f, 0); outPos = outPos.add(outMotion.normalize().scale(0.001)); - ItemEntity entity = new ItemEntity(belt.getWorld(), outPos.x, outPos.y + 6 / 16f, outPos.z, ejected); - entity.setMotion(outMotion); - entity.setDefaultPickupDelay(); - entity.velocityChanged = true; - belt.getWorld() - .addEntity(entity); + ItemEntity entity = new ItemEntity(belt.getLevel(), outPos.x, outPos.y + 6 / 16f, outPos.z, ejected); + entity.setDeltaMovement(outMotion); + entity.setDefaultPickUpDelay(); + entity.hurtMarked = true; + belt.getLevel() + .addFreshEntity(entity); } public void ejectAll() { @@ -434,7 +434,7 @@ public class BeltInventory { toRemove.add(transported); } if (dirty) { - belt.markDirty(); + belt.setChanged(); belt.sendData(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltMovementHandler.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltMovementHandler.java index e96ebabdf..6983ce99b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltMovementHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltMovementHandler.java @@ -43,7 +43,7 @@ public class BeltMovementHandler { public void refresh(BlockPos collision, BlockState belt) { ticksSinceLastCollision = 0; - lastCollidedPos = new BlockPos(collision).toImmutable(); + lastCollidedPos = new BlockPos(collision).immutable(); lastCollidedState = belt; } @@ -60,19 +60,19 @@ public class BeltMovementHandler { public static boolean canBeTransported(Entity entity) { if (!entity.isAlive()) return false; - if (entity instanceof PlayerEntity && ((PlayerEntity) entity).isSneaking()) + if (entity instanceof PlayerEntity && ((PlayerEntity) entity).isShiftKeyDown()) return false; return true; } public static void transportEntity(BeltTileEntity beltTe, Entity entityIn, TransportedEntityInfo info) { BlockPos pos = info.lastCollidedPos; - World world = beltTe.getWorld(); - TileEntity te = world.getTileEntity(pos); - TileEntity tileEntityBelowPassenger = world.getTileEntity(entityIn.getBlockPos()); + World world = beltTe.getLevel(); + TileEntity te = world.getBlockEntity(pos); + TileEntity tileEntityBelowPassenger = world.getBlockEntity(entityIn.blockPosition()); BlockState blockState = info.lastCollidedState; Direction movementFacing = - Direction.getFacingFromAxisDirection(blockState.get(BlockStateProperties.HORIZONTAL_FACING) + Direction.fromAxisAndDirection(blockState.getValue(BlockStateProperties.HORIZONTAL_FACING) .getAxis(), beltTe.getSpeed() < 0 ? POSITIVE : NEGATIVE); boolean collidedWithBelt = te instanceof BeltTileEntity; @@ -85,7 +85,7 @@ public class BeltMovementHandler { // Too slow boolean notHorizontal = beltTe.getBlockState() - .get(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL; + .getValue(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL; if (Math.abs(beltTe.getSpeed()) < 1) return; @@ -96,18 +96,18 @@ public class BeltMovementHandler { // Lock entities in place boolean isPlayer = entityIn instanceof PlayerEntity; if (entityIn instanceof LivingEntity && !isPlayer) - ((LivingEntity) entityIn).addPotionEffect(new EffectInstance(Effects.SLOWNESS, 10, 1, false, false)); + ((LivingEntity) entityIn).addEffect(new EffectInstance(Effects.MOVEMENT_SLOWDOWN, 10, 1, false, false)); - final Direction beltFacing = blockState.get(BlockStateProperties.HORIZONTAL_FACING); - final BeltSlope slope = blockState.get(BeltBlock.SLOPE); + final Direction beltFacing = blockState.getValue(BlockStateProperties.HORIZONTAL_FACING); + final BeltSlope slope = blockState.getValue(BeltBlock.SLOPE); final Axis axis = beltFacing.getAxis(); float movementSpeed = beltTe.getBeltMovementSpeed(); - final Direction movementDirection = Direction.getFacingFromAxis(axis == Axis.X ? NEGATIVE : POSITIVE, axis); + final Direction movementDirection = Direction.get(axis == Axis.X ? NEGATIVE : POSITIVE, axis); - Vector3i centeringDirection = Direction.getFacingFromAxis(POSITIVE, beltFacing.rotateY() + Vector3i centeringDirection = Direction.get(POSITIVE, beltFacing.getClockWise() .getAxis()) - .getDirectionVec(); - Vector3d movement = Vector3d.of(movementDirection.getDirectionVec()) + .getNormal(); + Vector3d movement = Vector3d.atLowerCornerOf(movementDirection.getNormal()) .scale(movementSpeed); double diffCenter = @@ -115,7 +115,7 @@ public class BeltMovementHandler { if (Math.abs(diffCenter) > 48 / 64f) return; - BeltPart part = blockState.get(BeltBlock.PART); + BeltPart part = blockState.getValue(BeltBlock.PART); float top = 13 / 16f; boolean onSlope = notHorizontal && (part == BeltPart.MIDDLE || part == BeltPart.PULLEY || part == (slope == BeltSlope.UPWARD ? BeltPart.END : BeltPart.START) && entityIn.getY() - pos.getY() < top @@ -132,19 +132,19 @@ public class BeltMovementHandler { } if (movingUp) - movement = movement.add(0, Math.abs(axis.getCoordinate(movement.x, movement.y, movement.z)), 0); + movement = movement.add(0, Math.abs(axis.choose(movement.x, movement.y, movement.z)), 0); if (movingDown) - movement = movement.add(0, -Math.abs(axis.getCoordinate(movement.x, movement.y, movement.z)), 0); + movement = movement.add(0, -Math.abs(axis.choose(movement.x, movement.y, movement.z)), 0); - Vector3d centering = Vector3d.of(centeringDirection).scale(diffCenter * Math.min(Math.abs(movementSpeed), .1f) * 4); + Vector3d centering = Vector3d.atLowerCornerOf(centeringDirection).scale(diffCenter * Math.min(Math.abs(movementSpeed), .1f) * 4); if (!(entityIn instanceof LivingEntity) - || ((LivingEntity) entityIn).moveForward == 0 && ((LivingEntity) entityIn).moveStrafing == 0) + || ((LivingEntity) entityIn).zza == 0 && ((LivingEntity) entityIn).xxa == 0) movement = movement.add(centering); - float step = entityIn.stepHeight; + float step = entityIn.maxUpStep; if (!isPlayer) - entityIn.stepHeight = 1; + entityIn.maxUpStep = 1; // Entity Collisions if (Math.abs(movementSpeed) < .5f) { @@ -152,12 +152,12 @@ public class BeltMovementHandler { .scale(0.5); AxisAlignedBB bb = entityIn.getBoundingBox(); AxisAlignedBB checkBB = new AxisAlignedBB(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); - checkBB = checkBB.offset(checkDistance) - .grow(-Math.abs(checkDistance.x), -Math.abs(checkDistance.y), -Math.abs(checkDistance.z)); - List list = world.getEntitiesWithinAABBExcludingEntity(entityIn, checkBB); + checkBB = checkBB.move(checkDistance) + .inflate(-Math.abs(checkDistance.x), -Math.abs(checkDistance.y), -Math.abs(checkDistance.z)); + List list = world.getEntities(entityIn, checkBB); list.removeIf(e -> shouldIgnoreBlocking(entityIn, e)); if (!list.isEmpty()) { - entityIn.setMotion(0, 0, 0); + entityIn.setDeltaMovement(0, 0, 0); info.ticksSinceLastCollision--; return; } @@ -169,10 +169,10 @@ public class BeltMovementHandler { float minVelocity = .13f; float yMovement = (float) -(Math.max(Math.abs(movement.y), minVelocity)); entityIn.move(SELF, new Vector3d(0, yMovement, 0)); - entityIn.move(SELF, movement.mul(1, 0, 1)); + entityIn.move(SELF, movement.multiply(1, 0, 1)); } else if (movingDown) { - entityIn.move(SELF, movement.mul(1, 0, 1)); - entityIn.move(SELF, movement.mul(0, 1, 0)); + entityIn.move(SELF, movement.multiply(1, 0, 1)); + entityIn.move(SELF, movement.multiply(0, 1, 0)); } else { entityIn.move(SELF, movement); } @@ -180,17 +180,17 @@ public class BeltMovementHandler { entityIn.onGround = true; if (!isPlayer) - entityIn.stepHeight = step; + entityIn.maxUpStep = step; - boolean movedPastEndingSlope = onSlope && (AllBlocks.BELT.has(world.getBlockState(entityIn.getBlockPos())) - || AllBlocks.BELT.has(world.getBlockState(entityIn.getBlockPos() - .down()))); + boolean movedPastEndingSlope = onSlope && (AllBlocks.BELT.has(world.getBlockState(entityIn.blockPosition())) + || AllBlocks.BELT.has(world.getBlockState(entityIn.blockPosition() + .below()))); if (movedPastEndingSlope && !movingDown && Math.abs(movementSpeed) > 0) - entityIn.setPosition(entityIn.getX(), entityIn.getY() + movement.y, entityIn.getZ()); + entityIn.setPos(entityIn.getX(), entityIn.getY() + movement.y, entityIn.getZ()); if (movedPastEndingSlope) { - entityIn.setMotion(movement); - entityIn.velocityChanged = true; + entityIn.setDeltaMovement(movement); + entityIn.hurtMarked = true; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltTunnelInteractionHandler.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltTunnelInteractionHandler.java index 6ff160496..4dee31a2e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltTunnelInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltTunnelInteractionHandler.java @@ -40,8 +40,8 @@ public class BeltTunnelInteractionHandler { return true; } - World world = beltInventory.belt.getWorld(); - boolean onServer = !world.isRemote || beltInventory.belt.isVirtual(); + World world = beltInventory.belt.getLevel(); + boolean onServer = !world.isClientSide || beltInventory.belt.isVirtual(); boolean removed = false; BeltTunnelTileEntity nextTunnel = getTunnelOnSegment(beltInventory, upcomingSegment); @@ -54,7 +54,7 @@ public class BeltTunnelInteractionHandler { brassTunnel.setStackToDistribute(current.stack); current.stack = ItemStack.EMPTY; beltInventory.belt.sendData(); - beltInventory.belt.markDirty(); + beltInventory.belt.setChanged(); } removed = true; } @@ -62,17 +62,17 @@ public class BeltTunnelInteractionHandler { BlockState blockState = nextTunnel.getBlockState(); if (current.stack.getCount() > 1 && AllBlocks.ANDESITE_TUNNEL.has(blockState) && BeltTunnelBlock.isJunction(blockState) - && movementFacing.getAxis() == blockState.get(BeltTunnelBlock.HORIZONTAL_AXIS)) { + && movementFacing.getAxis() == blockState.getValue(BeltTunnelBlock.HORIZONTAL_AXIS)) { for (Direction d : Iterate.horizontalDirections) { - if (d.getAxis() == blockState.get(BeltTunnelBlock.HORIZONTAL_AXIS)) + if (d.getAxis() == blockState.getValue(BeltTunnelBlock.HORIZONTAL_AXIS)) continue; if (!nextTunnel.flaps.containsKey(d)) continue; - BlockPos outpos = nextTunnel.getPos() - .down() - .offset(d); - if (!world.isBlockPresent(outpos)) + BlockPos outpos = nextTunnel.getBlockPos() + .below() + .relative(d); + if (!world.isLoaded(outpos)) return true; DirectBeltInputBehaviour behaviour = TileEntityBehaviour.get(world, outpos, DirectBeltInputBehaviour.TYPE); @@ -110,13 +110,13 @@ public class BeltTunnelInteractionHandler { Direction movementDirection) { BeltTileEntity belt = beltInventory.belt; BlockPos pos = BeltHelper.getPositionForOffset(belt, offset) - .up(); - if (!(belt.getWorld() + .above(); + if (!(belt.getLevel() .getBlockState(pos) .getBlock() instanceof BrassTunnelBlock)) return false; - TileEntity te = belt.getWorld() - .getTileEntity(pos); + TileEntity te = belt.getLevel() + .getBlockEntity(pos); if (te == null || !(te instanceof BrassTunnelTileEntity)) return false; BrassTunnelTileEntity tunnel = (BrassTunnelTileEntity) te; @@ -133,16 +133,16 @@ public class BeltTunnelInteractionHandler { protected static BeltTunnelTileEntity getTunnelOnSegment(BeltInventory beltInventory, int offset) { BeltTileEntity belt = beltInventory.belt; if (belt.getBlockState() - .get(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL) + .getValue(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL) return null; - return getTunnelOnPosition(belt.getWorld(), BeltHelper.getPositionForOffset(belt, offset)); + return getTunnelOnPosition(belt.getLevel(), BeltHelper.getPositionForOffset(belt, offset)); } public static BeltTunnelTileEntity getTunnelOnPosition(World world, BlockPos pos) { - pos = pos.up(); + pos = pos.above(); if (!(world.getBlockState(pos).getBlock() instanceof BeltTunnelBlock)) return null; - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (te == null || !(te instanceof BeltTunnelTileEntity)) return null; return ((BeltTunnelTileEntity) te); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/ItemHandlerBeltSegment.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/ItemHandlerBeltSegment.java index 896051089..c29866810 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/ItemHandlerBeltSegment.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/ItemHandlerBeltSegment.java @@ -35,7 +35,7 @@ public class ItemHandlerBeltSegment implements IItemHandler { newStack.beltPosition = offset + .5f + (beltInventory.beltMovementPositive ? -1 : 1) / 16f; newStack.prevBeltPosition = newStack.beltPosition; this.beltInventory.addItem(newStack); - this.beltInventory.belt.markDirty(); + this.beltInventory.belt.setChanged(); this.beltInventory.belt.sendData(); } return ItemStack.EMPTY; @@ -52,7 +52,7 @@ public class ItemHandlerBeltSegment implements IItemHandler { amount = Math.min(amount, transported.stack.getCount()); ItemStack extracted = simulate ? transported.stack.copy().split(amount) : transported.stack.split(amount); if (!simulate) { - this.beltInventory.belt.markDirty(); + this.beltInventory.belt.setChanged(); this.beltInventory.belt.sendData(); } return extracted; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/TransportedItemStack.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/TransportedItemStack.java index 85cea6d9a..522d43fb2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/TransportedItemStack.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/TransportedItemStack.java @@ -73,7 +73,7 @@ public class TransportedItemStack implements Comparable { nbt.putFloat("PrevOffset", prevSideOffset); nbt.putInt("InSegment", insertedAt); nbt.putInt("Angle", angle); - nbt.putInt("InDirection", insertedFrom.getIndex()); + nbt.putInt("InDirection", insertedFrom.get3DDataValue()); if (locked) nbt.putBoolean("Locked", locked); if (lockedExternally) @@ -82,14 +82,14 @@ public class TransportedItemStack implements Comparable { } public static TransportedItemStack read(CompoundNBT nbt) { - TransportedItemStack stack = new TransportedItemStack(ItemStack.read(nbt.getCompound("Item"))); + TransportedItemStack stack = new TransportedItemStack(ItemStack.of(nbt.getCompound("Item"))); stack.beltPosition = nbt.getFloat("Pos"); stack.prevBeltPosition = nbt.getFloat("PrevPos"); stack.sideOffset = nbt.getFloat("Offset"); stack.prevSideOffset = nbt.getFloat("PrevOffset"); stack.insertedAt = nbt.getInt("InSegment"); stack.angle = nbt.getInt("Angle"); - stack.insertedFrom = Direction.byIndex(nbt.getInt("InDirection")); + stack.insertedFrom = Direction.from3DDataValue(nbt.getInt("InDirection")); stack.locked = nbt.getBoolean("Locked"); stack.lockedExternally = nbt.getBoolean("LockedExternally"); return stack; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java index ec3e1aff9..6e74032a9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java @@ -30,12 +30,14 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock implements IWaterLoggable, IWrenchableWithBracket { public AbstractShaftBlock(Properties properties) { super(properties); - setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false)); + registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false)); } @Override @@ -44,7 +46,7 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock } @Override - public PushReaction getPushReaction(BlockState state) { + public PushReaction getPistonPushReaction(BlockState state) { return PushReaction.NORMAL; } @@ -55,52 +57,52 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock @Override @SuppressWarnings("deprecation") - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { if (state != newState && !isMoving) - removeBracket(world, pos, true).ifPresent(stack -> Block.spawnAsEntity(world, pos, stack)); - super.onReplaced(state, world, pos, newState, isMoving); + removeBracket(world, pos, true).ifPresent(stack -> Block.popResource(world, pos, stack)); + super.onRemove(state, world, pos, newState, isMoving); } // IRotate: @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face.getAxis() == state.get(AXIS); + return face.getAxis() == state.getValue(AXIS); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(AXIS); + return state.getValue(AXIS); } @Override public FluidState getFluidState(BlockState state) { - return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) - : Fluids.EMPTY.getDefaultState(); + return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) + : Fluids.EMPTY.defaultFluidState(); } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(BlockStateProperties.WATERLOGGED); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, BlockPos pos, BlockPos neighbourPos) { - if (state.get(BlockStateProperties.WATERLOGGED)) { - world.getPendingFluidTicks() - .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if (state.getValue(BlockStateProperties.WATERLOGGED)) { + world.getLiquidTicks() + .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } return state; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - FluidState ifluidstate = context.getWorld() - .getFluidState(context.getPos()); - return super.getStateForPlacement(context).with(BlockStateProperties.WATERLOGGED, - Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER)); + FluidState ifluidstate = context.getLevel() + .getFluidState(context.getClickedPos()); + return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, + Boolean.valueOf(ifluidstate.getType() == Fluids.WATER)); } @Override @@ -110,13 +112,13 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock return Optional.empty(); BlockState bracket = behaviour.getBracket(); behaviour.removeBracket(inOnReplacedContext); - if (bracket == Blocks.AIR.getDefaultState()) + if (bracket == Blocks.AIR.defaultBlockState()) return Optional.empty(); return Optional.of(new ItemStack(bracket.getBlock())); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java index 390a3ed1d..e4a432b7f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java @@ -67,8 +67,8 @@ public class BracketedKineticBlockModel extends BakedModelWrapper { public void putBracket(BlockState state) { this.bracket = Minecraft.getInstance() - .getBlockRendererDispatcher() - .getModelForState(state); + .getBlockRenderer() + .getBlockModel(state); } public IBakedModel getBracket() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java index c926acd2f..1e677317c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java @@ -64,8 +64,8 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { public void removeBracket(boolean inOnReplacedContext) { World world = getWorld(); - if (!world.isRemote) - world.playEvent(2001, getPos(), Block.getStateId(getBracket())); + if (!world.isClientSide) + world.levelEvent(2001, getPos(), Block.getId(getBracket())); this.bracket = Optional.empty(); reRender = true; if (inOnReplacedContext) @@ -75,11 +75,11 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { } public boolean isBracketPresent() { - return getBracket() != Blocks.AIR.getDefaultState(); + return getBracket() != Blocks.AIR.defaultBlockState(); } public BlockState getBracket() { - return bracket.orElse(Blocks.AIR.getDefaultState()); + return bracket.orElse(Blocks.AIR.defaultBlockState()); } @Override @@ -108,7 +108,7 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { if (nbt.contains("Bracket")) bracket = Optional.of(NBTUtil.readBlockState(nbt.getCompound("Bracket"))); if (clientPacket && nbt.contains("Redraw")) - getWorld().notifyBlockUpdate(getPos(), tileEntity.getBlockState(), tileEntity.getBlockState(), 16); + getWorld().sendBlockUpdated(getPos(), tileEntity.getBlockState(), tileEntity.getBlockState(), 16); super.read(nbt, clientPacket); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogWheelBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogWheelBlock.java index 7662c10f5..7df1faa2f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogWheelBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogWheelBlock.java @@ -23,6 +23,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @SuppressWarnings("deprecation") @@ -54,12 +56,12 @@ public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel { @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return (isLarge ? AllShapes.LARGE_GEAR : AllShapes.SMALL_GEAR).get(state.get(AXIS)); + return (isLarge ? AllShapes.LARGE_GEAR : AllShapes.SMALL_GEAR).get(state.getValue(AXIS)); } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - return isValidCogwheelPosition(ICogWheel.isLargeCog(state), worldIn, pos, state.get(AXIS)); + public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + return isValidCogwheelPosition(ICogWheel.isLargeCog(state), worldIn, pos, state.getValue(AXIS)); } public static boolean isValidCogwheelPosition(boolean large, IWorldReader worldIn, BlockPos pos, Axis cogAxis) { @@ -67,9 +69,9 @@ public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel { if (facing.getAxis() == cogAxis) continue; - BlockPos offsetPos = pos.offset(facing); + BlockPos offsetPos = pos.relative(facing); BlockState blockState = worldIn.getBlockState(offsetPos); - if (blockState.contains(AXIS) && facing.getAxis() == blockState.get(AXIS)) + if (blockState.hasProperty(AXIS) && facing.getAxis() == blockState.getValue(AXIS)) continue; if (ICogWheel.isLargeCog(blockState) || large && ICogWheel.isSmallCog(blockState)) @@ -79,16 +81,16 @@ public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel { } protected Axis getAxisForPlacement(BlockItemUseContext context) { - if (context.getPlayer() != null && context.getPlayer().isSneaking()) - return context.getFace().getAxis(); + if (context.getPlayer() != null && context.getPlayer().isShiftKeyDown()) + return context.getClickedFace().getAxis(); - World world = context.getWorld(); - BlockState stateBelow = world.getBlockState(context.getPos().down()); + World world = context.getLevel(); + BlockState stateBelow = world.getBlockState(context.getClickedPos().below()); if (AllBlocks.ROTATION_SPEED_CONTROLLER.has(stateBelow) && isLargeCog()) - return stateBelow.get(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X ? Axis.Z : Axis.X; + return stateBelow.getValue(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X ? Axis.Z : Axis.X; - BlockPos placedOnPos = context.getPos().offset(context.getFace().getOpposite()); + BlockPos placedOnPos = context.getClickedPos().relative(context.getClickedFace().getOpposite()); BlockState placedAgainst = world.getBlockState(placedOnPos); Block block = placedAgainst.getBlock(); @@ -96,15 +98,15 @@ public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel { return ((IRotate) block).getRotationAxis(placedAgainst); Axis preferredAxis = getPreferredAxis(context); - return preferredAxis != null ? preferredAxis : context.getFace().getAxis(); + return preferredAxis != null ? preferredAxis : context.getClickedFace().getAxis(); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - boolean shouldWaterlog = context.getWorld().getFluidState(context.getPos()).getFluid() == Fluids.WATER; - return this.getDefaultState() - .with(AXIS, getAxisForPlacement(context)) - .with(BlockStateProperties.WATERLOGGED, shouldWaterlog); + boolean shouldWaterlog = context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER; + return this.defaultBlockState() + .setValue(AXIS, getAxisForPlacement(context)) + .setValue(BlockStateProperties.WATERLOGGED, shouldWaterlog); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogwheelBlockItem.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogwheelBlockItem.java index a1e96d272..60b44226c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogwheelBlockItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/CogwheelBlockItem.java @@ -29,6 +29,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; +import net.minecraft.item.Item.Properties; + public class CogwheelBlockItem extends BlockItem { boolean large; @@ -46,21 +48,21 @@ public class CogwheelBlockItem extends BlockItem { @Override public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { - World world = context.getWorld(); - BlockPos pos = context.getPos(); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); BlockState state = world.getBlockState(pos); IPlacementHelper helper = PlacementHelpers.get(placementHelperId); PlayerEntity player = context.getPlayer(); - BlockRayTraceResult ray = new BlockRayTraceResult(context.getHitVec(), context.getFace(), pos, true); - if (helper.matchesState(state) && player != null && !player.isSneaking()) { + BlockRayTraceResult ray = new BlockRayTraceResult(context.getClickLocation(), context.getClickedFace(), pos, true); + if (helper.matchesState(state) && player != null && !player.isShiftKeyDown()) { return helper.getOffset(player, world, state, pos, ray).placeInWorld(world, this, player, context.getHand(), ray); } if (integratedCogHelperId != -1) { helper = PlacementHelpers.get(integratedCogHelperId); - if (helper.matchesState(state) && player != null && !player.isSneaking()) { + if (helper.matchesState(state) && player != null && !player.isShiftKeyDown()) { return helper.getOffset(player, world, state, pos, ray).placeInWorld(world, this, player, context.getHand(), ray); } } @@ -71,33 +73,33 @@ public class CogwheelBlockItem extends BlockItem { @Override // Trigger cogwheel criterion protected boolean placeBlock(BlockItemUseContext context, BlockState state) { - triggerShiftingGearsAdvancement(context.getWorld(), context.getPos(), state, context.getPlayer()); + triggerShiftingGearsAdvancement(context.getLevel(), context.getClickedPos(), state, context.getPlayer()); return super.placeBlock(context, state); } protected void triggerShiftingGearsAdvancement(World world, BlockPos pos, BlockState state, PlayerEntity player) { - if (world.isRemote || player == null) + if (world.isClientSide || player == null) return; - Axis axis = state.get(CogWheelBlock.AXIS); + Axis axis = state.getValue(CogWheelBlock.AXIS); for (Axis perpendicular1 : Iterate.axes) { if (perpendicular1 == axis) continue; - Direction d1 = Direction.getFacingFromAxis(AxisDirection.POSITIVE, perpendicular1); + Direction d1 = Direction.get(AxisDirection.POSITIVE, perpendicular1); for (Axis perpendicular2 : Iterate.axes) { if (perpendicular1 == perpendicular2) continue; if (axis == perpendicular2) continue; - Direction d2 = Direction.getFacingFromAxis(AxisDirection.POSITIVE, perpendicular2); + Direction d2 = Direction.get(AxisDirection.POSITIVE, perpendicular2); for (int offset1 : Iterate.positiveAndNegative) { for (int offset2 : Iterate.positiveAndNegative) { - BlockPos connectedPos = pos.offset(d1, offset1) - .offset(d2, offset2); + BlockPos connectedPos = pos.relative(d1, offset1) + .relative(d2, offset2); BlockState blockState = world.getBlockState(connectedPos); if (!(blockState.getBlock() instanceof CogWheelBlock)) continue; - if (blockState.get(CogWheelBlock.AXIS) != axis) + if (blockState.getValue(CogWheelBlock.AXIS) != axis) continue; if (ICogWheel.isLargeCog(blockState) == large) continue; @@ -123,12 +125,12 @@ public class CogwheelBlockItem extends BlockItem { if (!((CogWheelBlock) state.getBlock()).isLarge) { List directions = - IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getHitVec(), state.get(AXIS)); + IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), state.getValue(AXIS)); for (Direction dir : directions) { - BlockPos newPos = pos.offset(dir); + BlockPos newPos = pos.relative(dir); - if (!CogWheelBlock.isValidCogwheelPosition(false, world, newPos, state.get(AXIS))) + if (!CogWheelBlock.isValidCogwheelPosition(false, world, newPos, state.getValue(AXIS))) continue; if (!world.getBlockState(newPos) @@ -136,7 +138,7 @@ public class CogwheelBlockItem extends BlockItem { .isReplaceable()) continue; - return PlacementOffset.success(newPos, s -> s.with(AXIS, state.get(AXIS))); + return PlacementOffset.success(newPos, s -> s.setValue(AXIS, state.getValue(AXIS))); } @@ -161,13 +163,13 @@ public class CogwheelBlockItem extends BlockItem { return PlacementOffset.fail(); if (((CogWheelBlock) state.getBlock()).isLarge) { - Direction side = IPlacementHelper.orderedByDistanceOnlyAxis(pos, ray.getHitVec(), state.get(AXIS)) + Direction side = IPlacementHelper.orderedByDistanceOnlyAxis(pos, ray.getLocation(), state.getValue(AXIS)) .get(0); List directions = - IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getHitVec(), state.get(AXIS)); + IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), state.getValue(AXIS)); for (Direction dir : directions) { - BlockPos newPos = pos.offset(dir) - .offset(side); + BlockPos newPos = pos.relative(dir) + .relative(side); if (!CogWheelBlock.isValidCogwheelPosition(true, world, newPos, dir.getAxis())) continue; @@ -177,7 +179,7 @@ public class CogwheelBlockItem extends BlockItem { .isReplaceable()) continue; - return PlacementOffset.success(newPos, s -> s.with(AXIS, dir.getAxis())); + return PlacementOffset.success(newPos, s -> s.setValue(AXIS, dir.getAxis())); } return PlacementOffset.fail(); @@ -198,34 +200,34 @@ public class CogwheelBlockItem extends BlockItem { @Override public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { // diagonal gears of different size - Direction closest = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getHitVec(), state.get(AXIS)) + Direction closest = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), state.getValue(AXIS)) .get(0); - List directions = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getHitVec(), - state.get(AXIS), d -> d.getAxis() != closest.getAxis()); + List directions = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), + state.getValue(AXIS), d -> d.getAxis() != closest.getAxis()); for (Direction dir : directions) { - BlockPos newPos = pos.offset(dir) - .offset(closest); + BlockPos newPos = pos.relative(dir) + .relative(closest); if (!world.getBlockState(newPos) .getMaterial() .isReplaceable()) continue; - if (!CogWheelBlock.isValidCogwheelPosition(ICogWheel.isLargeCog(state), world, newPos, state.get(AXIS))) + if (!CogWheelBlock.isValidCogwheelPosition(ICogWheel.isLargeCog(state), world, newPos, state.getValue(AXIS))) continue; - return PlacementOffset.success(newPos, s -> s.with(AXIS, state.get(AXIS))); + return PlacementOffset.success(newPos, s -> s.setValue(AXIS, state.getValue(AXIS))); } return PlacementOffset.fail(); } protected boolean hitOnShaft(BlockState state, BlockRayTraceResult ray) { - return AllShapes.SIX_VOXEL_POLE.get(state.get(AXIS)) - .getBoundingBox() - .grow(0.001) - .contains(ray.getHitVec() - .subtract(ray.getHitVec() + return AllShapes.SIX_VOXEL_POLE.get(state.getValue(AXIS)) + .bounds() + .inflate(0.001) + .contains(ray.getLocation() + .subtract(ray.getLocation() .align(Iterate.axisSet))); } } @@ -245,14 +247,14 @@ public class CogwheelBlockItem extends BlockItem { @Override public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { - Direction face = ray.getFace(); + Direction face = ray.getDirection(); Axis newAxis; - if (state.contains(HorizontalKineticBlock.HORIZONTAL_FACING)) - newAxis = state.get(HorizontalKineticBlock.HORIZONTAL_FACING) + if (state.hasProperty(HorizontalKineticBlock.HORIZONTAL_FACING)) + newAxis = state.getValue(HorizontalKineticBlock.HORIZONTAL_FACING) .getAxis(); - else if (state.contains(DirectionalKineticBlock.FACING)) - newAxis = state.get(DirectionalKineticBlock.FACING) + else if (state.hasProperty(DirectionalKineticBlock.FACING)) + newAxis = state.getValue(DirectionalKineticBlock.FACING) .getAxis(); else newAxis = Axis.Y; @@ -261,11 +263,11 @@ public class CogwheelBlockItem extends BlockItem { return PlacementOffset.fail(); List directions = - IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getHitVec(), face.getAxis(), newAxis); + IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), face.getAxis(), newAxis); for (Direction d : directions) { - BlockPos newPos = pos.offset(face) - .offset(d); + BlockPos newPos = pos.relative(face) + .relative(d); if (!world.getBlockState(newPos) .getMaterial() @@ -275,7 +277,7 @@ public class CogwheelBlockItem extends BlockItem { if (!CogWheelBlock.isValidCogwheelPosition(false, world, newPos, newAxis)) return PlacementOffset.fail(); - return PlacementOffset.success(newPos, s -> s.with(CogWheelBlock.AXIS, newAxis)); + return PlacementOffset.success(newPos, s -> s.setValue(CogWheelBlock.AXIS, newAxis)); } return PlacementOffset.fail(); @@ -298,14 +300,14 @@ public class CogwheelBlockItem extends BlockItem { @Override public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { - Direction face = ray.getFace(); + Direction face = ray.getDirection(); Axis newAxis; - if (state.contains(HorizontalKineticBlock.HORIZONTAL_FACING)) - newAxis = state.get(HorizontalKineticBlock.HORIZONTAL_FACING) + if (state.hasProperty(HorizontalKineticBlock.HORIZONTAL_FACING)) + newAxis = state.getValue(HorizontalKineticBlock.HORIZONTAL_FACING) .getAxis(); - else if (state.contains(DirectionalKineticBlock.FACING)) - newAxis = state.get(DirectionalKineticBlock.FACING) + else if (state.hasProperty(DirectionalKineticBlock.FACING)) + newAxis = state.getValue(DirectionalKineticBlock.FACING) .getAxis(); else newAxis = Axis.Y; @@ -313,10 +315,10 @@ public class CogwheelBlockItem extends BlockItem { if (face.getAxis() == newAxis) return PlacementOffset.fail(); - List directions = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getHitVec(), newAxis); + List directions = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), newAxis); for (Direction d : directions) { - BlockPos newPos = pos.offset(d); + BlockPos newPos = pos.relative(d); if (!world.getBlockState(newPos) .getMaterial() @@ -328,7 +330,7 @@ public class CogwheelBlockItem extends BlockItem { return PlacementOffset.success() .at(newPos) - .withTransform(s -> s.with(CogWheelBlock.AXIS, newAxis)); + .withTransform(s -> s.setValue(CogWheelBlock.AXIS, newAxis)); } return PlacementOffset.fail(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ShaftBlock.java index 51c02d3af..e169a93e8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ShaftBlock.java @@ -26,6 +26,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class ShaftBlock extends AbstractShaftBlock { private static final int placementHelperId = PlacementHelpers.register(new PlacementHelper()); @@ -40,7 +42,7 @@ public class ShaftBlock extends AbstractShaftBlock { @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return AllShapes.SIX_VOXEL_POLE.get(state.get(AXIS)); + return AllShapes.SIX_VOXEL_POLE.get(state.getValue(AXIS)); } @Override @@ -54,12 +56,12 @@ public class ShaftBlock extends AbstractShaftBlock { } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { - if (player.isSneaking() || !player.isAllowEdit()) + if (player.isShiftKeyDown() || !player.mayBuild()) return ActionResultType.PASS; - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); for (EncasedShaftBlock encasedShaft : new EncasedShaftBlock[] { AllBlocks.ANDESITE_ENCASED_SHAFT.get(), AllBlocks.BRASS_ENCASED_SHAFT.get() }) { @@ -67,12 +69,12 @@ public class ShaftBlock extends AbstractShaftBlock { .isIn(heldItem)) continue; - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; AllTriggers.triggerFor(AllTriggers.CASING_SHAFT, player); - KineticTileEntity.switchToBlockState(world, pos, encasedShaft.getDefaultState() - .with(AXIS, state.get(AXIS))); + KineticTileEntity.switchToBlockState(world, pos, encasedShaft.defaultBlockState() + .setValue(AXIS, state.getValue(AXIS))); return ActionResultType.SUCCESS; } @@ -90,7 +92,7 @@ public class ShaftBlock extends AbstractShaftBlock { private PlacementHelper(){ super( state -> state.getBlock() instanceof AbstractShaftBlock, - state -> state.get(AXIS), + state -> state.getValue(AXIS), AXIS ); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/SimpleKineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/SimpleKineticTileEntity.java index 5c651a8a7..4545e3f4a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/SimpleKineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/SimpleKineticTileEntity.java @@ -27,7 +27,7 @@ public class SimpleKineticTileEntity extends KineticTileEntity { @Override public AxisAlignedBB makeRenderBoundingBox() { - return new AxisAlignedBB(pos).grow(1); + return new AxisAlignedBB(worldPosition).inflate(1); } @Override @@ -35,10 +35,10 @@ public class SimpleKineticTileEntity extends KineticTileEntity { if (!ICogWheel.isLargeCog(state)) return super.addPropagationLocations(block, state, neighbours); - BlockPos.getAllInBox(new BlockPos(-1, -1, -1), new BlockPos(1, 1, 1)) + BlockPos.betweenClosedStream(new BlockPos(-1, -1, -1), new BlockPos(1, 1, 1)) .forEach(offset -> { - if (offset.distanceSq(0, 0, 0, false) == BlockPos.ZERO.distanceSq(1, 1, 0, false)) - neighbours.add(pos.add(offset)); + if (offset.distSqr(0, 0, 0, false) == BlockPos.ZERO.distSqr(1, 1, 0, false)) + neighbours.add(worldPosition.offset(offset)); }); return neighbours; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/AbstractEncasedShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/AbstractEncasedShaftBlock.java index df29e6e41..7c7c7ea29 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/AbstractEncasedShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/AbstractEncasedShaftBlock.java @@ -14,6 +14,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorldReader; +import net.minecraft.block.AbstractBlock.Properties; + @MethodsReturnNonnullByDefault public abstract class AbstractEncasedShaftBlock extends RotatedPillarKineticBlock { public AbstractEncasedShaftBlock(Properties properties) { @@ -21,8 +23,8 @@ public abstract class AbstractEncasedShaftBlock extends RotatedPillarKineticBloc } @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); + protected void createBlockStateDefinition(StateContainer.Builder builder) { + super.createBlockStateDefinition(builder); } @Override @@ -31,28 +33,28 @@ public abstract class AbstractEncasedShaftBlock extends RotatedPillarKineticBloc } @Override - public PushReaction getPushReaction(@Nullable BlockState state) { + public PushReaction getPistonPushReaction(@Nullable BlockState state) { return PushReaction.NORMAL; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { if (context.getPlayer() != null && context.getPlayer() - .isSneaking()) + .isShiftKeyDown()) return super.getStateForPlacement(context); Direction.Axis preferredAxis = getPreferredAxis(context); - return this.getDefaultState() - .with(AXIS, preferredAxis == null ? context.getNearestLookingDirection() + return this.defaultBlockState() + .setValue(AXIS, preferredAxis == null ? context.getNearestLookingDirection() .getAxis() : preferredAxis); } @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face.getAxis() == state.get(AXIS); + return face.getAxis() == state.getValue(AXIS); } @Override public Direction.Axis getRotationAxis(BlockState state) { - return state.get(AXIS); + return state.getValue(AXIS); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/AdjustablePulleyBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/AdjustablePulleyBlock.java index 5ecd6ee43..e2f5b841f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/AdjustablePulleyBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/AdjustablePulleyBlock.java @@ -14,18 +14,20 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class AdjustablePulleyBlock extends EncasedBeltBlock implements ITE { public static BooleanProperty POWERED = BlockStateProperties.POWERED; public AdjustablePulleyBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(POWERED, false)); + registerDefaultState(defaultBlockState().setValue(POWERED, false)); } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(POWERED)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(POWERED)); } @Override @@ -34,8 +36,8 @@ public class AdjustablePulleyBlock extends EncasedBeltBlock implements ITE PART = EnumProperty.create("part", Part.class); @@ -35,7 +37,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { public EncasedBeltBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(PART, Part.NONE)); + registerDefaultState(defaultBlockState().setValue(PART, Part.NONE)); } @Override @@ -44,13 +46,13 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { } @Override - public PushReaction getPushReaction(BlockState state) { + public PushReaction getPistonPushReaction(BlockState state) { return PushReaction.NORMAL; } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(PART, CONNECTED_ALONG_FIRST_COORDINATE)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(PART, CONNECTED_ALONG_FIRST_COORDINATE)); } @Override @@ -58,28 +60,28 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { Axis placedAxis = context.getNearestLookingDirection() .getAxis(); Axis axis = context.getPlayer() != null && context.getPlayer() - .isSneaking() ? placedAxis : getPreferredAxis(context); + .isShiftKeyDown() ? placedAxis : getPreferredAxis(context); if (axis == null) axis = placedAxis; - BlockState state = getDefaultState().with(AXIS, axis); + BlockState state = defaultBlockState().setValue(AXIS, axis); for (Direction facing : Iterate.directions) { if (facing.getAxis() == axis) continue; - BlockPos pos = context.getPos(); - BlockPos offset = pos.offset(facing); - state = updatePostPlacement(state, facing, context.getWorld() - .getBlockState(offset), context.getWorld(), pos, offset); + BlockPos pos = context.getClickedPos(); + BlockPos offset = pos.relative(facing); + state = updateShape(state, facing, context.getLevel() + .getBlockState(offset), context.getLevel(), pos, offset); } return state; } @Override - public BlockState updatePostPlacement(BlockState stateIn, Direction face, BlockState neighbour, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction face, BlockState neighbour, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { - Part part = stateIn.get(PART); - Axis axis = stateIn.get(AXIS); - boolean connectionAlongFirst = stateIn.get(CONNECTED_ALONG_FIRST_COORDINATE); + Part part = stateIn.getValue(PART); + Axis axis = stateIn.getValue(AXIS); + boolean connectionAlongFirst = stateIn.getValue(CONNECTED_ALONG_FIRST_COORDINATE); Axis connectionAxis = connectionAlongFirst ? (axis == Axis.X ? Axis.Y : Axis.X) : (axis == Axis.Z ? Axis.Y : Axis.Z); @@ -94,19 +96,19 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { if (facingAlongFirst != connectionAlongFirst || part == Part.NONE) return stateIn; if (part == Part.MIDDLE) - return stateIn.with(PART, positive ? Part.END : Part.START); + return stateIn.setValue(PART, positive ? Part.END : Part.START); if ((part == Part.START) == positive) - return stateIn.with(PART, Part.NONE); + return stateIn.setValue(PART, Part.NONE); return stateIn; } - Part otherPart = neighbour.get(PART); - Axis otherAxis = neighbour.get(AXIS); - boolean otherConnection = neighbour.get(CONNECTED_ALONG_FIRST_COORDINATE); + Part otherPart = neighbour.getValue(PART); + Axis otherAxis = neighbour.getValue(AXIS); + boolean otherConnection = neighbour.getValue(CONNECTED_ALONG_FIRST_COORDINATE); Axis otherConnectionAxis = otherConnection ? (otherAxis == Axis.X ? Axis.Y : Axis.X) : (otherAxis == Axis.Z ? Axis.Y : Axis.Z); - if (neighbour.get(AXIS) == faceAxis) + if (neighbour.getValue(AXIS) == faceAxis) return stateIn; if (otherPart != Part.NONE && otherConnectionAxis != faceAxis) return stateIn; @@ -121,34 +123,34 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { if ((part == Part.START) != positive) part = Part.MIDDLE; - return stateIn.with(PART, part) - .with(CONNECTED_ALONG_FIRST_COORDINATE, connectionAlongFirst); + return stateIn.setValue(PART, part) + .setValue(CONNECTED_ALONG_FIRST_COORDINATE, connectionAlongFirst); } @Override public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) { - if (originalState.get(PART) == Part.NONE) + if (originalState.getValue(PART) == Part.NONE) return super.getRotatedBlockState(originalState, targetedFace); return super.getRotatedBlockState(originalState, - Direction.getFacingFromAxis(AxisDirection.POSITIVE, getConnectionAxis(originalState))); + Direction.get(AxisDirection.POSITIVE, getConnectionAxis(originalState))); } @Override public BlockState updateAfterWrenched(BlockState newState, ItemUseContext context) { // Blocks.AIR.getDefaultState() // .updateNeighbors(context.getWorld(), context.getPos(), 1); - Axis axis = newState.get(AXIS); - newState = getDefaultState().with(AXIS, axis); - if (newState.contains(BlockStateProperties.POWERED)) - newState = newState.with(BlockStateProperties.POWERED, context.getWorld() - .isBlockPowered(context.getPos())); + Axis axis = newState.getValue(AXIS); + newState = defaultBlockState().setValue(AXIS, axis); + if (newState.hasProperty(BlockStateProperties.POWERED)) + newState = newState.setValue(BlockStateProperties.POWERED, context.getLevel() + .hasNeighborSignal(context.getClickedPos())); for (Direction facing : Iterate.directions) { if (facing.getAxis() == axis) continue; - BlockPos pos = context.getPos(); - BlockPos offset = pos.offset(facing); - newState = updatePostPlacement(newState, facing, context.getWorld() - .getBlockState(offset), context.getWorld(), pos, offset); + BlockPos pos = context.getClickedPos(); + BlockPos offset = pos.relative(facing); + newState = updateShape(newState, facing, context.getLevel() + .getBlockState(offset), context.getLevel(), pos, offset); } // newState.updateNeighbors(context.getWorld(), context.getPos(), 1 | 2); return newState; @@ -156,16 +158,16 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face.getAxis() == state.get(AXIS); + return face.getAxis() == state.getValue(AXIS); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(AXIS); + return state.getValue(AXIS); } public static boolean areBlocksConnected(BlockState state, BlockState other, Direction facing) { - Part part = state.get(PART); + Part part = state.getValue(PART); Axis connectionAxis = getConnectionAxis(state); Axis otherConnectionAxis = getConnectionAxis(other); @@ -182,8 +184,8 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { } protected static Axis getConnectionAxis(BlockState state) { - Axis axis = state.get(AXIS); - boolean connectionAlongFirst = state.get(CONNECTED_ALONG_FIRST_COORDINATE); + Axis axis = state.getValue(AXIS); + boolean connectionAlongFirst = state.getValue(CONNECTED_ALONG_FIRST_COORDINATE); Axis connectionAxis = connectionAlongFirst ? (axis == Axis.X ? Axis.Y : Axis.X) : (axis == Axis.Z ? Axis.Y : Axis.Z); return connectionAxis; @@ -208,7 +210,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { START, MIDDLE, END, NONE; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltGenerator.java index 5ef334001..0e75bbb16 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltGenerator.java @@ -22,9 +22,9 @@ public class EncasedBeltGenerator extends SpecialBlockStateGen { @Override protected int getXRotation(BlockState state) { - EncasedBeltBlock.Part part = state.get(EncasedBeltBlock.PART); - boolean connectedAlongFirst = state.get(EncasedBeltBlock.CONNECTED_ALONG_FIRST_COORDINATE); - Axis axis = state.get(EncasedBeltBlock.AXIS); + EncasedBeltBlock.Part part = state.getValue(EncasedBeltBlock.PART); + boolean connectedAlongFirst = state.getValue(EncasedBeltBlock.CONNECTED_ALONG_FIRST_COORDINATE); + Axis axis = state.getValue(EncasedBeltBlock.AXIS); if (part == Part.NONE) return axis == Axis.Y ? 90 : 0; @@ -37,9 +37,9 @@ public class EncasedBeltGenerator extends SpecialBlockStateGen { @Override protected int getYRotation(BlockState state) { - EncasedBeltBlock.Part part = state.get(EncasedBeltBlock.PART); - boolean connectedAlongFirst = state.get(EncasedBeltBlock.CONNECTED_ALONG_FIRST_COORDINATE); - Axis axis = state.get(EncasedBeltBlock.AXIS); + EncasedBeltBlock.Part part = state.getValue(EncasedBeltBlock.PART); + boolean connectedAlongFirst = state.getValue(EncasedBeltBlock.CONNECTED_ALONG_FIRST_COORDINATE); + Axis axis = state.getValue(EncasedBeltBlock.AXIS); if (part == Part.NONE) return axis == Axis.X ? 90 : 0; @@ -58,8 +58,8 @@ public class EncasedBeltGenerator extends SpecialBlockStateGen { } protected String getModelSuffix(BlockState state) { - EncasedBeltBlock.Part part = state.get(EncasedBeltBlock.PART); - Axis axis = state.get(EncasedBeltBlock.AXIS); + EncasedBeltBlock.Part part = state.getValue(EncasedBeltBlock.PART); + Axis axis = state.getValue(EncasedBeltBlock.AXIS); if (part == Part.NONE) return "single"; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java index 09e6749a7..f4a3ed011 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java @@ -15,6 +15,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.world.IBlockReader; +import net.minecraft.block.AbstractBlock.Properties; + public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpecialBlockItemRequirement { private BlockEntry casing; @@ -43,10 +45,10 @@ public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpe @Override public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) { - if (context.getWorld().isRemote) + if (context.getLevel().isClientSide) return ActionResultType.SUCCESS; - context.getWorld().playEvent(2001, context.getPos(), Block.getStateId(state)); - KineticTileEntity.switchToBlockState(context.getWorld(), context.getPos(), AllBlocks.SHAFT.getDefaultState().with(AXIS, state.get(AXIS))); + context.getLevel().levelEvent(2001, context.getClickedPos(), Block.getId(state)); + KineticTileEntity.switchToBlockState(context.getLevel(), context.getClickedPos(), AllBlocks.SHAFT.getDefaultState().setValue(AXIS, state.getValue(AXIS))); return ActionResultType.SUCCESS; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/GearshiftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/GearshiftBlock.java index 9e381f491..c907cbbd0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/GearshiftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/GearshiftBlock.java @@ -21,13 +21,15 @@ import net.minecraft.world.TickPriority; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class GearshiftBlock extends AbstractEncasedShaftBlock implements ITE { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; public GearshiftBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(POWERED, false)); + registerDefaultState(defaultBlockState().setValue(POWERED, false)); } @Override @@ -36,27 +38,27 @@ public class GearshiftBlock extends AbstractEncasedShaftBlock implements ITE builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(POWERED); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return super.getStateForPlacement(context).with(POWERED, - context.getWorld().isBlockPowered(context.getPos())); + return super.getStateForPlacement(context).setValue(POWERED, + context.getLevel().hasNeighborSignal(context.getClickedPos())); } @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - boolean previouslyPowered = state.get(POWERED); - if (previouslyPowered != worldIn.isBlockPowered(pos)) { + boolean previouslyPowered = state.getValue(POWERED); + if (previouslyPowered != worldIn.hasNeighborSignal(pos)) { detachKinetics(worldIn, pos, true); - worldIn.setBlockState(pos, state.cycle(POWERED), 2); + worldIn.setBlock(pos, state.cycle(POWERED), 2); } } @@ -66,19 +68,19 @@ public class GearshiftBlock extends AbstractEncasedShaftBlock implements ITE 1 ? 4 : 1; if (particleCount == 1 && rand.nextFloat() > 1 / 4f) @@ -163,7 +165,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { for (int i = 0; i < particleCount; i++) { Vector3d mul = VecHelper.offsetRandomly(Vector3d.ZERO, rand, .25f) - .mul(new Vector3d(1, 1, 1).subtract(positiveFaceVec)) + .multiply(new Vector3d(1, 1, 1).subtract(positiveFaceVec)) .normalize() .scale(.3f); Vector3d offset = VecHelper.getCenterOf(pos) @@ -179,17 +181,17 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return GAUGE.get(state.get(FACING), state.get(AXIS_ALONG_FIRST_COORDINATE)); + return GAUGE.get(state.getValue(FACING), state.getValue(AXIS_ALONG_FIRST_COORDINATE)); } @Override - public boolean hasComparatorInputOverride(BlockState state) { + public boolean hasAnalogOutputSignal(BlockState state) { return true; } @Override - public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { - TileEntity te = worldIn.getTileEntity(pos); + public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { + TileEntity te = worldIn.getBlockEntity(pos); if (te instanceof GaugeTileEntity) { GaugeTileEntity gaugeTileEntity = (GaugeTileEntity) te; return MathHelper.ceil(MathHelper.clamp(gaugeTileEntity.dialTarget * 14, 0, 15)); @@ -198,7 +200,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java index de3a27ed8..b19d48f37 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java @@ -61,7 +61,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns public void beginFrame() { GaugeTileEntity gaugeTile = (GaugeTileEntity) tile; - if (MathHelper.epsilonEquals(gaugeTile.prevDialState, gaugeTile.dialState)) + if (MathHelper.equal(gaugeTile.prevDialState, gaugeTile.dialState)) return; float progress = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), gaugeTile.prevDialState, gaugeTile.dialState); @@ -102,7 +102,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns private void setupTransform(MatrixStacker msr, float progress) { float dialPivot = 5.75f / 16; - ms.push(); + ms.pushPose(); rotateToFace(msr); getSecond().setTransform(ms); @@ -113,13 +113,13 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns getFirst().setTransform(ms); - ms.pop(); + ms.popPose(); } private void updateTransform(MatrixStacker msr, float progress) { float dialPivot = 5.75f / 16; - ms.push(); + ms.pushPose(); rotateToFace(msr) .translate(0, dialPivot, dialPivot) @@ -128,12 +128,12 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns getFirst().setTransform(ms); - ms.pop(); + ms.popPose(); } protected MatrixStacker rotateToFace(MatrixStacker msr) { return msr.centre() - .rotate(Direction.UP, (float) ((-face.getHorizontalAngle() - 90) / 180 * Math.PI)) + .rotate(Direction.UP, (float) ((-face.toYRot() - 90) / 180 * Math.PI)) .unCentre(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java index 442cb9bdf..182c75728 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java @@ -40,12 +40,12 @@ public class GaugeRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); BlockState gaugeState = te.getBlockState(); GaugeTileEntity gaugeTE = (GaugeTileEntity) te; - int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), gaugeState, te.getPos()); + int lightCoords = WorldRenderer.getLightColor(te.getLevel(), gaugeState, te.getBlockPos()); PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS); SuperByteBuffer headBuffer = @@ -56,11 +56,11 @@ public class GaugeRenderer extends KineticTileEntityRenderer { float progress = MathHelper.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState); for (Direction facing : Iterate.directions) { - if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getWorld(), te.getPos(), gaugeState, + if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getLevel(), te.getBlockPos(), gaugeState, facing)) continue; - IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); + IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot) .rotate(Direction.EAST, (float) (Math.PI / 2 * -progress)) .translate(0, -dialPivot, -dialPivot) @@ -78,7 +78,7 @@ public class GaugeRenderer extends KineticTileEntityRenderer { } protected SuperByteBuffer rotateBufferTowards(SuperByteBuffer buffer, Direction target) { - return buffer.rotateCentered(Direction.UP, (float) ((-target.getHorizontalAngle() - 90) / 180 * Math.PI)); + return buffer.rotateCentered(Direction.UP, (float) ((-target.toYRot() - 90) / 180 * Math.PI)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeTileEntity.java index 1a1c4a8b2..dfe96cf3c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeTileEntity.java @@ -41,13 +41,13 @@ public class GaugeTileEntity extends KineticTileEntity implements IHaveGoggleInf super.tick(); prevDialState = dialState; dialState += (dialTarget - dialState) * .125f; - if (dialState > 1 && world.rand.nextFloat() < 1 / 2f) - dialState -= (dialState - 1) * world.rand.nextFloat(); + if (dialState > 1 && level.random.nextFloat() < 1 / 2f) + dialState -= (dialState - 1) * level.random.nextFloat(); } @Override public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { - tooltip.add(componentSpacing.copy().append(Lang.translate("gui.gauge.info_header"))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.gauge.info_header"))); return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/SpeedGaugeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/SpeedGaugeTileEntity.java index 1bdb7b191..391949d6e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/SpeedGaugeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/SpeedGaugeTileEntity.java @@ -29,10 +29,10 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity { : ColorHelper.mixColors(SpeedLevel.of(speed) .getColor(), 0xffffff, .25f); if (speed == 69) - AllTriggers.triggerForNearbyPlayers(AllTriggers.SPEED_READ, world, pos, 6, GogglesItem::canSeeParticles); + AllTriggers.triggerForNearbyPlayers(AllTriggers.SPEED_READ, level, worldPosition, 6, GogglesItem::canSeeParticles); dialTarget = getDialTarget(speed); - markDirty(); + setChanged(); } public static float getDialTarget(float speed) { @@ -59,8 +59,8 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity { public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { super.addToGoggleTooltip(tooltip, isPlayerSneaking); - tooltip.add(componentSpacing.copy().append(Lang.translate("gui.speedometer.title").formatted(TextFormatting.GRAY))); - tooltip.add(componentSpacing.copy().append(SpeedLevel.getFormattedSpeedText(speed, isOverStressed()))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.speedometer.title").withStyle(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy().append(SpeedLevel.getFormattedSpeedText(speed, isOverStressed()))); return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/StressGaugeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/StressGaugeTileEntity.java index 470522dff..1ea44cb46 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/StressGaugeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/StressGaugeTileEntity.java @@ -43,7 +43,7 @@ public class StressGaugeTileEntity extends GaugeTileEntity { } sendData(); - markDirty(); + setChanged(); } @Override @@ -51,7 +51,7 @@ public class StressGaugeTileEntity extends GaugeTileEntity { super.onSpeedChanged(prevSpeed); if (getSpeed() == 0) { dialTarget = 0; - markDirty(); + setChanged(); return; } @@ -68,30 +68,30 @@ public class StressGaugeTileEntity extends GaugeTileEntity { double capacity = getNetworkCapacity(); double stressFraction = getNetworkStress() / (capacity == 0 ? 1 : capacity); - tooltip.add(componentSpacing.copy().append(Lang.translate("gui.stressometer.title").formatted(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.stressometer.title").withStyle(TextFormatting.GRAY))); if (getTheoreticalSpeed() == 0) - tooltip.add(new StringTextComponent(spacing + ItemDescription.makeProgressBar(3, -1)).append(Lang.translate("gui.stressometer.no_rotation")).formatted(TextFormatting.DARK_GRAY)); + tooltip.add(new StringTextComponent(spacing + ItemDescription.makeProgressBar(3, -1)).append(Lang.translate("gui.stressometer.no_rotation")).withStyle(TextFormatting.DARK_GRAY)); // tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + ItemDescription.makeProgressBar(3, -1) // + Lang.translate("gui.stressometer.no_rotation"))); else { - tooltip.add(componentSpacing.copy().append(StressImpact.getFormattedStressText(stressFraction))); + tooltip.add(componentSpacing.plainCopy().append(StressImpact.getFormattedStressText(stressFraction))); - tooltip.add(componentSpacing.copy().append(Lang.translate("gui.stressometer.capacity").formatted(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.stressometer.capacity").withStyle(TextFormatting.GRAY))); double remainingCapacity = capacity - getNetworkStress(); ITextComponent su = Lang.translate("generic.unit.stress"); - IFormattableTextComponent stressTooltip = componentSpacing.copy() + IFormattableTextComponent stressTooltip = componentSpacing.plainCopy() .append(new StringTextComponent(" " + IHaveGoggleInformation.format(remainingCapacity)) - .append(su.copy()) - .formatted(StressImpact.of(stressFraction).getRelativeColor())); + .append(su.plainCopy()) + .withStyle(StressImpact.of(stressFraction).getRelativeColor())); if (remainingCapacity != capacity) { stressTooltip - .append(new StringTextComponent(" / ").formatted(TextFormatting.GRAY)) + .append(new StringTextComponent(" / ").withStyle(TextFormatting.GRAY)) .append(new StringTextComponent(IHaveGoggleInformation.format(capacity)) - .append(su.copy()) - .formatted(TextFormatting.DARK_GRAY)); + .append(su.plainCopy()) + .withStyle(TextFormatting.DARK_GRAY)); } tooltip.add(stressTooltip); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxBlock.java index bb867e1a0..bf75f70ed 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxBlock.java @@ -23,6 +23,8 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; +import net.minecraft.block.AbstractBlock.Properties; + public class GearboxBlock extends RotatedPillarKineticBlock { public GearboxBlock(Properties properties) { @@ -35,20 +37,20 @@ public class GearboxBlock extends RotatedPillarKineticBlock { } @Override - public PushReaction getPushReaction(BlockState state) { + public PushReaction getPistonPushReaction(BlockState state) { return PushReaction.PUSH_ONLY; } @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - super.fillItemGroup(group, items); + public void fillItemCategory(ItemGroup group, NonNullList items) { + super.fillItemCategory(group, items); items.add(AllItems.VERTICAL_GEARBOX.asStack()); } @SuppressWarnings("deprecation") @Override public List getDrops(BlockState state, Builder builder) { - if (state.get(AXIS).isVertical()) + if (state.getValue(AXIS).isVertical()) return super.getDrops(state, builder); return Arrays.asList(new ItemStack(AllItems.VERTICAL_GEARBOX.get())); } @@ -56,25 +58,25 @@ public class GearboxBlock extends RotatedPillarKineticBlock { @Override public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) { - if (state.get(AXIS).isVertical()) + if (state.getValue(AXIS).isVertical()) return super.getPickBlock(state, target, world, pos, player); return new ItemStack(AllItems.VERTICAL_GEARBOX.get()); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return getDefaultState().with(AXIS, Axis.Y); + return defaultBlockState().setValue(AXIS, Axis.Y); } // IRotate: @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { - return face.getAxis() != state.get(AXIS); + return face.getAxis() != state.getValue(AXIS); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(AXIS); + return state.getValue(AXIS); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java index fc795f92e..35e266927 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java @@ -27,10 +27,10 @@ public class GearboxInstance extends KineticTileInstance { keys = new EnumMap<>(Direction.class); - final Direction.Axis boxAxis = blockState.get(BlockStateProperties.AXIS); + final Direction.Axis boxAxis = blockState.getValue(BlockStateProperties.AXIS); - int blockLight = world.getLightLevel(LightType.BLOCK, pos); - int skyLight = world.getLightLevel(LightType.SKY, pos); + int blockLight = world.getBrightness(LightType.BLOCK, pos); + int skyLight = world.getBrightness(LightType.SKY, pos); updateSourceFacing(); InstanceMaterial rotatingMaterial = getRotatingMaterial(); @@ -44,7 +44,7 @@ public class GearboxInstance extends KineticTileInstance { RotatingData key = shaft.createInstance(); - key.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector()) + key.setRotationAxis(Direction.get(Direction.AxisDirection.POSITIVE, axis).step()) .setRotationalSpeed(getSpeed(direction)) .setRotationOffset(getRotationOffset(axis)).setColor(tile) .setPosition(getInstancePosition()) @@ -70,7 +70,7 @@ public class GearboxInstance extends KineticTileInstance { protected void updateSourceFacing() { if (tile.hasSource()) { BlockPos source = tile.source.subtract(pos); - sourceFacing = Direction.getFacingFromVector(source.getX(), source.getY(), source.getZ()); + sourceFacing = Direction.getNearest(source.getX(), source.getY(), source.getZ()); } else { sourceFacing = null; } 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 0c9313b2f..2bd534af4 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 @@ -27,11 +27,11 @@ public class GearboxRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; - final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS); - final BlockPos pos = te.getPos(); - float time = AnimationTickHolder.getRenderTime(te.getWorld()); + final Axis boxAxis = te.getBlockState().getValue(BlockStateProperties.AXIS); + final BlockPos pos = te.getBlockPos(); + float time = AnimationTickHolder.getRenderTime(te.getLevel()); for (Direction direction : Iterate.directions) { final Axis axis = direction.getAxis(); @@ -43,8 +43,8 @@ public class GearboxRenderer extends KineticTileEntityRenderer { float angle = (time * te.getSpeed() * 3f / 10) % 360; if (te.getSpeed() != 0 && te.hasSource()) { - BlockPos source = te.source.subtract(te.getPos()); - Direction sourceFacing = Direction.getFacingFromVector(source.getX(), source.getY(), source.getZ()); + BlockPos source = te.source.subtract(te.getBlockPos()); + Direction sourceFacing = Direction.getNearest(source.getX(), source.getY(), source.getZ()); if (sourceFacing.getAxis() == direction.getAxis()) angle *= sourceFacing == direction ? 1 : -1; else if (sourceFacing.getAxisDirection() == direction.getAxisDirection()) @@ -55,7 +55,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer { angle = angle / 180f * (float) Math.PI; kineticRotationTransform(shaft, te, axis, angle, light); - shaft.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + shaft.renderInto(ms, buffer.getBuffer(RenderType.solid())); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearshiftTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearshiftTileEntity.java index a819022c1..2e4b6cf62 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearshiftTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearshiftTileEntity.java @@ -15,7 +15,7 @@ public class GearshiftTileEntity extends SplitShaftTileEntity { @Override public float getRotationSpeedModifier(Direction face) { if (hasSource()) { - if (face != getSourceFacing() && getBlockState().get(BlockStateProperties.POWERED)) + if (face != getSourceFacing() && getBlockState().getValue(BlockStateProperties.POWERED)) return -1; } return 1; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/VerticalGearboxItem.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/VerticalGearboxItem.java index 153b85154..5fea417ea 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/VerticalGearboxItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/VerticalGearboxItem.java @@ -20,6 +20,8 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.item.Item.Properties; + public class VerticalGearboxItem extends BlockItem { public VerticalGearboxItem(Properties builder) { @@ -27,25 +29,25 @@ public class VerticalGearboxItem extends BlockItem { } @Override - public void fillItemGroup(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { } @Override - public String getTranslationKey() { + public String getDescriptionId() { return "item.create.vertical_gearbox"; } @Override - public void addToBlockToItemMap(Map p_195946_1_, Item p_195946_2_) { + public void registerBlocks(Map p_195946_1_, Item p_195946_2_) { } @Override - protected boolean onBlockPlaced(BlockPos pos, World world, PlayerEntity player, ItemStack stack, BlockState state) { + protected boolean updateCustomBlockEntityTag(BlockPos pos, World world, PlayerEntity player, ItemStack stack, BlockState state) { Axis prefferedAxis = null; for (Direction side : Iterate.horizontalDirections) { - BlockState blockState = world.getBlockState(pos.offset(side)); + BlockState blockState = world.getBlockState(pos.relative(side)); if (blockState.getBlock() instanceof IRotate) { - if (((IRotate) blockState.getBlock()).hasShaftTowards(world, pos.offset(side), blockState, + if (((IRotate) blockState.getBlock()).hasShaftTowards(world, pos.relative(side), blockState, side.getOpposite())) if (prefferedAxis != null && prefferedAxis != side.getAxis()) { prefferedAxis = null; @@ -56,11 +58,11 @@ public class VerticalGearboxItem extends BlockItem { } } - Axis axis = prefferedAxis == null ? player.getHorizontalFacing() - .rotateY() + Axis axis = prefferedAxis == null ? player.getDirection() + .getClockWise() .getAxis() : prefferedAxis == Axis.X ? Axis.Z : Axis.X; - world.setBlockState(pos, state.with(BlockStateProperties.AXIS, axis)); - return super.onBlockPlaced(pos, world, player, stack, state); + world.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.AXIS, axis)); + return super.updateCustomBlockEntityTag(pos, world, player, stack, state); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchable.java b/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchable.java index 68b5365a5..7c6102815 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchable.java +++ b/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchable.java @@ -27,43 +27,43 @@ import net.minecraft.world.server.ServerWorld; public interface IWrenchable { default ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getWorld(); - BlockState rotated = getRotatedBlockState(state, context.getFace()); - if (!rotated.isValidPosition(world, context.getPos())) + World world = context.getLevel(); + BlockState rotated = getRotatedBlockState(state, context.getClickedFace()); + if (!rotated.canSurvive(world, context.getClickedPos())) return ActionResultType.PASS; - KineticTileEntity.switchToBlockState(world, context.getPos(), updateAfterWrenched(rotated, context)); + KineticTileEntity.switchToBlockState(world, context.getClickedPos(), updateAfterWrenched(rotated, context)); - TileEntity te = context.getWorld() - .getTileEntity(context.getPos()); + TileEntity te = context.getLevel() + .getBlockEntity(context.getClickedPos()); if (te != null) - te.updateContainingBlockInfo(); + te.clearCache(); if (te instanceof GeneratingKineticTileEntity) { ((GeneratingKineticTileEntity) te).reActivateSource = true; } - if (world.getBlockState(context.getPos()) != state) - playRotateSound(world, context.getPos()); + if (world.getBlockState(context.getClickedPos()) != state) + playRotateSound(world, context.getClickedPos()); return ActionResultType.SUCCESS; } default BlockState updateAfterWrenched(BlockState newState, ItemUseContext context) { // return newState; - return Block.getValidBlockForPosition(newState, context.getWorld(), context.getPos()); + return Block.updateFromNeighbourShapes(newState, context.getLevel(), context.getClickedPos()); } default ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) { - World world = context.getWorld(); - BlockPos pos = context.getPos(); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); PlayerEntity player = context.getPlayer(); if (world instanceof ServerWorld) { if (player != null && !player.isCreative()) - Block.getDrops(state, (ServerWorld) world, pos, world.getTileEntity(pos), player, context.getItem()) + Block.getDrops(state, (ServerWorld) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) .forEach(itemStack -> { player.inventory.placeItemBackInInventory(world, itemStack); }); - state.spawnAdditionalDrops((ServerWorld) world, pos, ItemStack.EMPTY); + state.spawnAfterBreak((ServerWorld) world, pos, ItemStack.EMPTY); world.destroyBlock(pos, false); playRemoveSound(world, pos); } @@ -82,42 +82,42 @@ public interface IWrenchable { BlockState newState = originalState; if (targetedFace.getAxis() == Direction.Axis.Y) { - if (originalState.contains(HorizontalAxisKineticBlock.HORIZONTAL_AXIS)) - return originalState.with(HorizontalAxisKineticBlock.HORIZONTAL_AXIS, DirectionHelper - .rotateAround(VoxelShaper.axisAsFace(originalState.get(HorizontalAxisKineticBlock.HORIZONTAL_AXIS)), + if (originalState.hasProperty(HorizontalAxisKineticBlock.HORIZONTAL_AXIS)) + return originalState.setValue(HorizontalAxisKineticBlock.HORIZONTAL_AXIS, DirectionHelper + .rotateAround(VoxelShaper.axisAsFace(originalState.getValue(HorizontalAxisKineticBlock.HORIZONTAL_AXIS)), targetedFace.getAxis()) .getAxis()); - if (originalState.contains(HorizontalKineticBlock.HORIZONTAL_FACING)) - return originalState.with(HorizontalKineticBlock.HORIZONTAL_FACING, DirectionHelper - .rotateAround(originalState.get(HorizontalKineticBlock.HORIZONTAL_FACING), targetedFace.getAxis())); + if (originalState.hasProperty(HorizontalKineticBlock.HORIZONTAL_FACING)) + return originalState.setValue(HorizontalKineticBlock.HORIZONTAL_FACING, DirectionHelper + .rotateAround(originalState.getValue(HorizontalKineticBlock.HORIZONTAL_FACING), targetedFace.getAxis())); } - if (originalState.contains(RotatedPillarKineticBlock.AXIS)) - return originalState.with(RotatedPillarKineticBlock.AXIS, + if (originalState.hasProperty(RotatedPillarKineticBlock.AXIS)) + return originalState.setValue(RotatedPillarKineticBlock.AXIS, DirectionHelper - .rotateAround(VoxelShaper.axisAsFace(originalState.get(RotatedPillarKineticBlock.AXIS)), + .rotateAround(VoxelShaper.axisAsFace(originalState.getValue(RotatedPillarKineticBlock.AXIS)), targetedFace.getAxis()) .getAxis()); - if (!originalState.contains(DirectionalKineticBlock.FACING)) + if (!originalState.hasProperty(DirectionalKineticBlock.FACING)) return originalState; - Direction stateFacing = originalState.get(DirectionalKineticBlock.FACING); + Direction stateFacing = originalState.getValue(DirectionalKineticBlock.FACING); if (stateFacing.getAxis() .equals(targetedFace.getAxis())) { - if (originalState.contains(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE)) + if (originalState.hasProperty(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE)) return originalState.cycle(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE); else return originalState; } else { do { - newState = newState.with(DirectionalKineticBlock.FACING, - DirectionHelper.rotateAround(newState.get(DirectionalKineticBlock.FACING), targetedFace.getAxis())); + newState = newState.setValue(DirectionalKineticBlock.FACING, + DirectionHelper.rotateAround(newState.getValue(DirectionalKineticBlock.FACING), targetedFace.getAxis())); if (targetedFace.getAxis() == Direction.Axis.Y - && newState.contains(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE)) + && newState.hasProperty(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE)) newState = newState.cycle(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE); - } while (newState.get(DirectionalKineticBlock.FACING) + } while (newState.getValue(DirectionalKineticBlock.FACING) .getAxis() .equals(targetedFace.getAxis())); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchableWithBracket.java b/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchableWithBracket.java index e2c79126c..9161d4309 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchableWithBracket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchableWithBracket.java @@ -29,22 +29,22 @@ public interface IWrenchableWithBracket extends IWrenchable { } default boolean tryRemoveBracket(ItemUseContext context) { - World world = context.getWorld(); - BlockPos pos = context.getPos(); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); Optional bracket = removeBracket(world, pos, false); BlockState blockState = world.getBlockState(pos); if (bracket.isPresent()) { PlayerEntity player = context.getPlayer(); - if (!world.isRemote && !player.isCreative()) + if (!world.isClientSide && !player.isCreative()) player.inventory.placeItemBackInInventory(world, bracket.get()); - if (!world.isRemote && AllBlocks.FLUID_PIPE.has(blockState)) { + if (!world.isClientSide && AllBlocks.FLUID_PIPE.has(blockState)) { Axis preferred = FluidPropagator.getStraightPipeAxis(blockState); Direction preferredDirection = - preferred == null ? Direction.UP : Direction.getFacingFromAxis(AxisDirection.POSITIVE, preferred); + preferred == null ? Direction.UP : Direction.get(AxisDirection.POSITIVE, preferred); BlockState updated = AllBlocks.FLUID_PIPE.get() .updateBlockState(blockState, preferredDirection, null, world, pos); if (updated != blockState) - world.setBlockState(pos, updated); + world.setBlockAndUpdate(pos, updated); } return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItem.java b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItem.java index 190156a87..057738739 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItem.java @@ -22,6 +22,8 @@ import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.event.entity.player.AttackEntityEvent; +import net.minecraft.item.Item.Properties; + public class WrenchItem extends Item { public WrenchItem(Properties properties) { @@ -30,23 +32,23 @@ public class WrenchItem extends Item { @Nonnull @Override - public ActionResultType onItemUse(ItemUseContext context) { + public ActionResultType useOn(ItemUseContext context) { PlayerEntity player = context.getPlayer(); - if (player == null || !player.isAllowEdit()) - return super.onItemUse(context); + if (player == null || !player.mayBuild()) + return super.useOn(context); - BlockState state = context.getWorld() - .getBlockState(context.getPos()); + BlockState state = context.getLevel() + .getBlockState(context.getClickedPos()); Block block = state.getBlock(); if (!(block instanceof IWrenchable)) { if (canWrenchPickup(state)) return onItemUseOnOther(context); - return super.onItemUse(context); + return super.useOn(context); } IWrenchable actor = (IWrenchable) block; - if (player.isSneaking()) + if (player.isShiftKeyDown()) return actor.onSneakWrenched(state, context); return actor.onWrenched(state, context); } @@ -57,15 +59,15 @@ public class WrenchItem extends Item { private ActionResultType onItemUseOnOther(ItemUseContext context) { PlayerEntity player = context.getPlayer(); - World world = context.getWorld(); - BlockPos pos = context.getPos(); + World world = context.getLevel(); + BlockPos pos = context.getClickedPos(); BlockState state = world.getBlockState(pos); if (!(world instanceof ServerWorld)) return ActionResultType.SUCCESS; if (player != null && !player.isCreative()) - Block.getDrops(state, (ServerWorld) world, pos, world.getTileEntity(pos), player, context.getItem()) + Block.getDrops(state, (ServerWorld) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) .forEach(itemStack -> player.inventory.placeItemBackInInventory(world, itemStack)); - state.spawnAdditionalDrops((ServerWorld) world, pos, ItemStack.EMPTY); + state.spawnAfterBreak((ServerWorld) world, pos, ItemStack.EMPTY); world.destroyBlock(pos, false); AllSoundEvents.WRENCH_REMOVE.playOnServer(world, pos, 1, Create.RANDOM.nextFloat() * .5f + .5f); return ActionResultType.SUCCESS; @@ -76,13 +78,13 @@ public class WrenchItem extends Item { if (!(target instanceof AbstractMinecartEntity)) return; PlayerEntity player = event.getPlayer(); - ItemStack heldItem = player.getHeldItemMainhand(); + ItemStack heldItem = player.getMainHandItem(); if (!AllItems.WRENCH.isIn(heldItem)) return; if (player.isCreative()) return; AbstractMinecartEntity minecart = (AbstractMinecartEntity) target; - minecart.attackEntityFrom(DamageSource.causePlayerDamage(player), 100); + minecart.hurt(DamageSource.playerAttack(player), 100); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java index 7b9e15cda..41ae4fec9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java @@ -20,7 +20,7 @@ public class WrenchItemRenderer extends CustomRenderedItemModelRenderer onItemRightClick(World p_77659_1_, PlayerEntity p_77659_2_, Hand p_77659_3_) { - p_77659_2_.setActiveHand(p_77659_3_); - return ActionResult.success(p_77659_2_.getHeldItem(p_77659_3_)); + public ActionResult use(World p_77659_1_, PlayerEntity p_77659_2_, Hand p_77659_3_) { + p_77659_2_.startUsingItem(p_77659_3_); + return ActionResult.success(p_77659_2_.getItemInHand(p_77659_3_)); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundColor.java b/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundColor.java index 60c3e3754..92957ffc5 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundColor.java +++ b/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundColor.java @@ -14,7 +14,7 @@ public class ChromaticCompoundColor implements IItemColor { public int getColor(ItemStack stack, int layer) { Minecraft mc = Minecraft.getInstance(); float pt = AnimationTickHolder.getPartialTicks(); - float progress = (float) ((mc.player.getYaw(pt)) / 180 * Math.PI) + (AnimationTickHolder.getRenderTime() / 10f); + float progress = (float) ((mc.player.getViewYRot(pt)) / 180 * Math.PI) + (AnimationTickHolder.getRenderTime() / 10f); if (layer == 0) return ColorHelper.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2); if (layer == 1) diff --git a/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundItem.java b/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundItem.java index 3b7d0ae2d..0c32dbb7a 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundItem.java @@ -27,6 +27,8 @@ import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraft.world.gen.Heightmap; +import net.minecraft.item.Item.Properties; + public class ChromaticCompoundItem extends Item { public ChromaticCompoundItem(Properties properties) { @@ -34,7 +36,7 @@ public class ChromaticCompoundItem extends Item { } @Override - public boolean shouldSyncTag() { + public boolean shouldOverrideMultiplayerNbt() { return true; } @@ -65,15 +67,15 @@ public class ChromaticCompoundItem extends Item { @Override public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { double y = entity.getY(); - double yMotion = entity.getMotion().y; - World world = entity.world; + double yMotion = entity.getDeltaMovement().y; + World world = entity.level; CompoundNBT data = entity.getPersistentData(); CompoundNBT itemData = entity.getItem() .getOrCreateTag(); - Vector3d positionVec = entity.getPositionVec(); + Vector3d positionVec = entity.position(); CRecipes config = AllConfigs.SERVER.recipes; - if (world.isRemote) { + if (world.isClientSide) { int light = itemData.getInt("CollectingLight"); if (random.nextInt(config.lightSourceCountForRefinedRadiance.get() + 20) < light) { Vector3d start = VecHelper.offsetRandomly(positionVec, random, 3); @@ -100,11 +102,11 @@ public class ChromaticCompoundItem extends Item { if (itemData.getInt("CollectingLight") >= config.lightSourceCountForRefinedRadiance.get()) { ItemStack newStack = AllItems.REFINED_RADIANCE.asStack(); ItemEntity newEntity = new ItemEntity(world, entity.getX(), entity.getY(), entity.getZ(), newStack); - newEntity.setMotion(entity.getMotion()); + newEntity.setDeltaMovement(entity.getDeltaMovement()); newEntity.getPersistentData() .putBoolean("JustCreated", true); itemData.remove("CollectingLight"); - world.addEntity(newEntity); + world.addFreshEntity(newEntity); stack.split(1); entity.setItem(stack); @@ -125,17 +127,17 @@ public class ChromaticCompoundItem extends Item { while (testPos.getY() > 0) { testPos.move(Direction.DOWN); BlockState state = world.getBlockState(testPos); - if (state.getOpacity(world, testPos) >= 15 && state.getBlock() != Blocks.BEDROCK) + if (state.getLightBlock(world, testPos) >= 15 && state.getBlock() != Blocks.BEDROCK) break; if (state.getBlock() == Blocks.BEACON) { - TileEntity te = world.getTileEntity(testPos); + TileEntity te = world.getBlockEntity(testPos); if (!(te instanceof BeaconTileEntity)) break; BeaconTileEntity bte = (BeaconTileEntity) te; - if (bte.getLevels() != 0 && !bte.beamSegments.isEmpty()) + if (bte.getLevels() != 0 && !bte.beamSections.isEmpty()) isOverBeacon = true; break; @@ -151,7 +153,7 @@ public class ChromaticCompoundItem extends Item { } // Find a light source and eat it. - Random r = world.rand; + Random r = world.random; int range = 3; float rate = 1 / 2f; if (r.nextFloat() > rate) @@ -161,15 +163,15 @@ public class ChromaticCompoundItem extends Item { BlockState state = world.getBlockState(randomOffset); if (state.getLightValue(world, randomOffset) == 0) return false; - if (state.getBlockHardness(world, randomOffset) == -1) + if (state.getDestroySpeed(world, randomOffset) == -1) return false; if (state.getBlock() == Blocks.BEACON) return false; RayTraceContext context = new RayTraceContext(positionVec, VecHelper.getCenterOf(randomOffset), BlockMode.COLLIDER, FluidMode.NONE, entity); - if (!randomOffset.equals(world.rayTraceBlocks(context) - .getPos())) + if (!randomOffset.equals(world.clip(context) + .getBlockPos())) return false; world.destroyBlock(randomOffset, false); @@ -178,9 +180,9 @@ public class ChromaticCompoundItem extends Item { newStack.getOrCreateTag() .putInt("CollectingLight", itemData.getInt("CollectingLight") + 1); ItemEntity newEntity = new ItemEntity(world, entity.getX(), entity.getY(), entity.getZ(), newStack); - newEntity.setMotion(entity.getMotion()); - newEntity.setDefaultPickupDelay(); - world.addEntity(newEntity); + newEntity.setDeltaMovement(entity.getDeltaMovement()); + newEntity.setDefaultPickUpDelay(); + world.addFreshEntity(newEntity); entity.lifespan = 6000; if (stack.isEmpty()) entity.remove(); diff --git a/src/main/java/com/simibubi/create/content/curiosities/CombustibleItem.java b/src/main/java/com/simibubi/create/content/curiosities/CombustibleItem.java index a92cb727d..caaed78ae 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/CombustibleItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/CombustibleItem.java @@ -3,6 +3,8 @@ package com.simibubi.create.content.curiosities; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Item.Properties; + public class CombustibleItem extends Item { private int burnTime = -1; diff --git a/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java b/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java index 2921241d3..0a41070cf 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java @@ -11,6 +11,8 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; +import net.minecraft.item.Item.Properties; + public class NoGravMagicalDohickyItem extends Item { public NoGravMagicalDohickyItem(Properties p_i48487_1_) { @@ -19,13 +21,13 @@ public class NoGravMagicalDohickyItem extends Item { @Override public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { - World world = entity.world; - Vector3d pos = entity.getPositionVec(); + World world = entity.level; + Vector3d pos = entity.position(); CompoundNBT persistentData = entity.getPersistentData(); - if (world.isRemote) { - if (world.rand.nextFloat() < getIdleParticleChance(entity)) { - Vector3d ppos = VecHelper.offsetRandomly(pos, world.rand, .5f); + if (world.isClientSide) { + if (world.random.nextFloat() < getIdleParticleChance(entity)) { + Vector3d ppos = VecHelper.offsetRandomly(pos, world.random, .5f); world.addParticle(ParticleTypes.END_ROD, ppos.x, pos.y, ppos.z, 0, -.1f, 0); } @@ -33,7 +35,7 @@ public class NoGravMagicalDohickyItem extends Item { Vector3d basemotion = new Vector3d(0, 1, 0); world.addParticle(ParticleTypes.FLASH, pos.x, pos.y, pos.z, 0, 0, 0); for (int i = 0; i < 20; i++) { - Vector3d motion = VecHelper.offsetRandomly(basemotion, world.rand, 1); + Vector3d motion = VecHelper.offsetRandomly(basemotion, world.random, 1); world.addParticle(ParticleTypes.WITCH, pos.x, pos.y, pos.z, motion.x, motion.y, motion.z); world.addParticle(ParticleTypes.END_ROD, pos.x, pos.y, pos.z, motion.x, motion.y, motion.z); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/RefinedRadianceItem.java b/src/main/java/com/simibubi/create/content/curiosities/RefinedRadianceItem.java index c853d6be7..1712ae8d0 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/RefinedRadianceItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/RefinedRadianceItem.java @@ -4,6 +4,8 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.item.Item.Properties; + public class RefinedRadianceItem extends NoGravMagicalDohickyItem { public RefinedRadianceItem(Properties properties) { @@ -11,14 +13,14 @@ public class RefinedRadianceItem extends NoGravMagicalDohickyItem { } @Override - public boolean hasEffect(ItemStack stack) { + public boolean isFoil(ItemStack stack) { return true; } @Override protected void onCreated(ItemEntity entity, CompoundNBT persistentData) { super.onCreated(entity, persistentData); - entity.setMotion(entity.getMotion() + entity.setDeltaMovement(entity.getDeltaMovement() .add(0, .15f, 0)); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/ShadowSteelItem.java b/src/main/java/com/simibubi/create/content/curiosities/ShadowSteelItem.java index 007e0f627..96b1c5548 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/ShadowSteelItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/ShadowSteelItem.java @@ -4,6 +4,8 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.math.MathHelper; +import net.minecraft.item.Item.Properties; + public class ShadowSteelItem extends NoGravMagicalDohickyItem { public ShadowSteelItem(Properties properties) { @@ -14,13 +16,13 @@ public class ShadowSteelItem extends NoGravMagicalDohickyItem { protected void onCreated(ItemEntity entity, CompoundNBT persistentData) { super.onCreated(entity, persistentData); float yMotion = (entity.fallDistance + 3) / 50f; - entity.setMotion(0, yMotion, 0); + entity.setDeltaMovement(0, yMotion, 0); } @Override protected float getIdleParticleChance(ItemEntity entity) { return (float) (MathHelper.clamp(entity.getItem() - .getCount() - 10, MathHelper.clamp(entity.getMotion().y * 20, 5, 20), 100) / 64f); + .getCount() - 10, MathHelper.clamp(entity.getDeltaMovement().y * 20, 5, 20), 100) / 64f); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java b/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java index 65768046d..f9bdccf0f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java @@ -13,6 +13,8 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.server.ServerWorld; +import net.minecraft.item.Item.Properties; + public class TreeFertilizerItem extends Item { public TreeFertilizerItem(Properties properties) { @@ -20,60 +22,60 @@ public class TreeFertilizerItem extends Item { } @Override - public ActionResultType onItemUse(ItemUseContext context) { - BlockState state = context.getWorld() - .getBlockState(context.getPos()); + public ActionResultType useOn(ItemUseContext context) { + BlockState state = context.getLevel() + .getBlockState(context.getClickedPos()); Block block = state.getBlock(); if (block instanceof SaplingBlock) { - if (context.getWorld().isRemote) { - BoneMealItem.spawnBonemealParticles(context.getWorld(), context.getPos(), 100); + if (context.getLevel().isClientSide) { + BoneMealItem.addGrowthParticles(context.getLevel(), context.getClickedPos(), 100); return ActionResultType.SUCCESS; } - BlockPos saplingPos = context.getPos(); - TreesDreamWorld world = new TreesDreamWorld((ServerWorld) context.getWorld(), saplingPos); + BlockPos saplingPos = context.getClickedPos(); + TreesDreamWorld world = new TreesDreamWorld((ServerWorld) context.getLevel(), saplingPos); - for (BlockPos pos : BlockPos.getAllInBoxMutable(-1, 0, -1, 1, 0, 1)) { - if (context.getWorld() - .getBlockState(saplingPos.add(pos)) + for (BlockPos pos : BlockPos.betweenClosed(-1, 0, -1, 1, 0, 1)) { + if (context.getLevel() + .getBlockState(saplingPos.offset(pos)) .getBlock() == block) - world.setBlockState(pos.up(10), state.with(SaplingBlock.STAGE, 1)); + world.setBlockAndUpdate(pos.above(10), state.setValue(SaplingBlock.STAGE, 1)); } - ((SaplingBlock) block).grow(world, world.getRandom(), BlockPos.ZERO.up(10), - state.with(SaplingBlock.STAGE, 1)); + ((SaplingBlock) block).performBonemeal(world, world.getRandom(), BlockPos.ZERO.above(10), + state.setValue(SaplingBlock.STAGE, 1)); for (BlockPos pos : world.blocksAdded.keySet()) { - BlockPos actualPos = pos.add(saplingPos).down(10); + BlockPos actualPos = pos.offset(saplingPos).below(10); BlockState newState = world.blocksAdded.get(pos); // Don't replace Bedrock - if (context.getWorld() + if (context.getLevel() .getBlockState(actualPos) - .getBlockHardness(context.getWorld(), actualPos) == -1) + .getDestroySpeed(context.getLevel(), actualPos) == -1) continue; // Don't replace solid blocks with leaves - if (!newState.isNormalCube(world, pos) - && !context.getWorld() + if (!newState.isRedstoneConductor(world, pos) + && !context.getLevel() .getBlockState(actualPos) - .getCollisionShape(context.getWorld(), actualPos) + .getCollisionShape(context.getLevel(), actualPos) .isEmpty()) continue; - context.getWorld() - .setBlockState(actualPos, newState); + context.getLevel() + .setBlockAndUpdate(actualPos, newState); } if (context.getPlayer() != null && !context.getPlayer() .isCreative()) - context.getItem() + context.getItemInHand() .shrink(1); return ActionResultType.SUCCESS; } - return super.onItemUse(context); + return super.useOn(context); } private class TreesDreamWorld extends PlacementSimulationServerWorld { @@ -83,7 +85,7 @@ public class TreeFertilizerItem extends Item { protected TreesDreamWorld(ServerWorld wrapped, BlockPos saplingPos) { super(wrapped); this.saplingPos = saplingPos; - soil = wrapped.getBlockState(saplingPos.down()); + soil = wrapped.getBlockState(saplingPos.below()); } @Override @@ -94,10 +96,10 @@ public class TreeFertilizerItem extends Item { } @Override - public boolean setBlockState(BlockPos pos, BlockState newState, int flags) { + public boolean setBlock(BlockPos pos, BlockState newState, int flags) { if (newState.getBlock() == Blocks.PODZOL) return true; - return super.setBlockState(pos, newState, flags); + return super.setBlock(pos, newState, flags); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/AllArmorMaterials.java b/src/main/java/com/simibubi/create/content/curiosities/armor/AllArmorMaterials.java index 1b0f7f6e1..5129dbbdf 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/AllArmorMaterials.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/AllArmorMaterials.java @@ -16,7 +16,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public enum AllArmorMaterials implements IArmorMaterial { COPPER("copper", 7, new int[] { 1, 3, 4, 2 }, 25, AllSoundEvents.COPPER_ARMOR_EQUIP.getMainEvent(), 0.0F, 0.0F, - () -> Ingredient.fromItems(AllItems.COPPER_INGOT.get())) + () -> Ingredient.of(AllItems.COPPER_INGOT.get())) ; @@ -42,24 +42,24 @@ public enum AllArmorMaterials implements IArmorMaterial { this.repairMaterial = new LazyValue<>(p_i231593_10_); } - public int getDurability(EquipmentSlotType p_200896_1_) { + public int getDurabilityForSlot(EquipmentSlotType p_200896_1_) { return MAX_DAMAGE_ARRAY[p_200896_1_.getIndex()] * this.maxDamageFactor; } - public int getDamageReductionAmount(EquipmentSlotType p_200902_1_) { + public int getDefenseForSlot(EquipmentSlotType p_200902_1_) { return this.damageReductionAmountArray[p_200902_1_.getIndex()]; } - public int getEnchantability() { + public int getEnchantmentValue() { return this.enchantability; } - public SoundEvent getSoundEvent() { + public SoundEvent getEquipSound() { return this.soundEvent; } - public Ingredient getRepairMaterial() { - return this.repairMaterial.getValue(); + public Ingredient getRepairIngredient() { + return this.repairMaterial.get(); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java b/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java index 6310de114..a53b0d477 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java @@ -18,7 +18,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BackTankUtil { public static ItemStack get(LivingEntity entity) { - for (ItemStack itemStack : entity.getArmorInventoryList()) + for (ItemStack itemStack : entity.getArmorSlots()) if (AllItems.COPPER_BACKTANK.isIn(itemStack)) return itemStack; return ItemStack.EMPTY; @@ -40,7 +40,7 @@ public class BackTankUtil { } public static int maxAir(ItemStack backtank) { - return maxAir(EnchantmentHelper.getEnchantmentLevel(AllEnchantments.CAPACITY.get(), backtank)); + return maxAir(EnchantmentHelper.getItemEnchantmentLevel(AllEnchantments.CAPACITY.get(), backtank)); } public static int maxAir(int enchantLevel) { @@ -78,7 +78,7 @@ public class BackTankUtil { return 0; ItemStack backtank = get(player); if (backtank.isEmpty() || !hasAirRemaining(backtank)) - return MathHelper.hsvToRGB( + return MathHelper.hsvToRgb( Math.max(0.0F, (float) (1.0F - getDurabilityForDisplay(stack, usesPerTank))) / 3.0F, 1.0F, 1.0F); return backtank.getItem() .getRGBDurabilityForDisplay(backtank); @@ -93,7 +93,7 @@ public class BackTankUtil { return 0; ItemStack backtank = get(player); if (backtank.isEmpty() || !hasAirRemaining(backtank)) - return (double) stack.getDamage() / (double) stack.getMaxDamage(); + return (double) stack.getDamageValue() / (double) stack.getMaxDamage(); return backtank.getItem() .getDurabilityForDisplay(backtank); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CapacityEnchantment.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CapacityEnchantment.java index 49b31df0d..da5c2dc37 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CapacityEnchantment.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CapacityEnchantment.java @@ -5,6 +5,8 @@ import net.minecraft.enchantment.EnchantmentType; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; +import net.minecraft.enchantment.Enchantment.Rarity; + public class CapacityEnchantment extends Enchantment { public CapacityEnchantment(Rarity p_i46731_1_, EnchantmentType p_i46731_2_, EquipmentSlotType[] p_i46731_3_) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperArmorItem.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperArmorItem.java index 8825db1c5..df735ef18 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperArmorItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperArmorItem.java @@ -7,14 +7,16 @@ import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ArmorItem; import net.minecraft.item.ItemStack; +import net.minecraft.item.Item.Properties; + public class CopperArmorItem extends ArmorItem { public CopperArmorItem(EquipmentSlotType p_i48534_2_, Properties p_i48534_3_) { - super(AllArmorMaterials.COPPER, p_i48534_2_, p_i48534_3_.maxStackSize(1)); + super(AllArmorMaterials.COPPER, p_i48534_2_, p_i48534_3_.stacksTo(1)); } public boolean isWornBy(Entity entity) { - for (ItemStack itemStack : entity.getArmorInventoryList()) + for (ItemStack itemStack : entity.getArmorSlots()) if (itemStack.getItem() == this) return true; return false; diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java index 2d97378b4..851ce18cc 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java @@ -53,21 +53,21 @@ public class CopperBacktankArmorLayer model = (BipedModel) entityModel; BlockState renderedState = AllBlocks.COPPER_BACKTANK.getDefaultState() - .with(CopperBacktankBlock.HORIZONTAL_FACING, Direction.SOUTH); - RenderType renderType = Atlases.getEntityCutout(); + .setValue(CopperBacktankBlock.HORIZONTAL_FACING, Direction.SOUTH); + RenderType renderType = Atlases.cutoutBlockSheet(); SuperByteBuffer backtank = CreateClient.BUFFER_CACHE.renderBlock(renderedState); SuperByteBuffer cogs = CreateClient.BUFFER_CACHE.renderPartial(AllBlockPartials.COPPER_BACKTANK_COGS, renderedState); - model.bipedBody.rotate(ms); + model.body.translateAndRotate(ms); ms.translate(-1 / 2f, 10 / 16f, 1f); ms.scale(1, -1, -1); backtank.forEntityRender() @@ -79,20 +79,20 @@ public class CopperBacktankArmorLayer renderer : renderManager.renderers.values()) registerOn(renderer); } @@ -112,19 +112,19 @@ public class CopperBacktankArmorLayer, IWaterLoggable { public CopperBacktankBlock(Properties properties) { super(properties); - setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false)); + registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false)); } @Override public FluidState getFluidState(BlockState state) { - return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) - : Fluids.EMPTY.getDefaultState(); + return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) + : Fluids.EMPTY.defaultFluidState(); } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(BlockStateProperties.WATERLOGGED); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override - public boolean hasComparatorInputOverride(BlockState p_149740_1_) { + public boolean hasAnalogOutputSignal(BlockState p_149740_1_) { return true; } @Override - public int getComparatorInputOverride(BlockState p_180641_1_, World world, BlockPos pos) { + public int getAnalogOutputSignal(BlockState p_180641_1_, World world, BlockPos pos) { return getTileEntityOptional(world, pos).map(CopperBacktankTileEntity::getComparatorOutput) .orElse(0); } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbourState, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, BlockPos pos, BlockPos neighbourPos) { - if (state.get(BlockStateProperties.WATERLOGGED)) { - world.getPendingFluidTicks() - .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if (state.getValue(BlockStateProperties.WATERLOGGED)) { + world.getLiquidTicks() + .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } return state; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - FluidState ifluidstate = context.getWorld() - .getFluidState(context.getPos()); - return super.getStateForPlacement(context).with(BlockStateProperties.WATERLOGGED, - Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER)); + FluidState ifluidstate = context.getLevel() + .getFluidState(context.getClickedPos()); + return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, + Boolean.valueOf(ifluidstate.getType() == Fluids.WATER)); } @Override @@ -104,48 +106,48 @@ public class CopperBacktankBlock extends HorizontalKineticBlock } @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { - super.onBlockPlacedBy(worldIn, pos, state, placer, stack); - if (worldIn.isRemote) + public void setPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { + super.setPlacedBy(worldIn, pos, state, placer, stack); + if (worldIn.isClientSide) return; if (stack == null) return; withTileEntityDo(worldIn, pos, te -> { - te.setCapacityEnchantLevel(EnchantmentHelper.getEnchantmentLevel(AllEnchantments.CAPACITY.get(), stack)); + te.setCapacityEnchantLevel(EnchantmentHelper.getItemEnchantmentLevel(AllEnchantments.CAPACITY.get(), stack)); te.setAirLevel(stack.getOrCreateTag() .getInt("Air")); if (stack.isEnchanted()) - te.setEnchantmentTag(stack.getEnchantmentTagList()); - if (stack.hasDisplayName()) - te.setCustomName(stack.getDisplayName()); + te.setEnchantmentTag(stack.getEnchantmentTags()); + if (stack.hasCustomHoverName()) + te.setCustomName(stack.getHoverName()); }); } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand p_225533_5_, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand p_225533_5_, BlockRayTraceResult p_225533_6_) { if (player == null) return ActionResultType.PASS; if (player instanceof FakePlayer) return ActionResultType.PASS; - if (player.isSneaking()) + if (player.isShiftKeyDown()) return ActionResultType.PASS; - if (player.getHeldItemMainhand() + if (player.getMainHandItem() .getItem() instanceof BlockItem) return ActionResultType.PASS; - if (!player.getItemStackFromSlot(EquipmentSlotType.CHEST) + if (!player.getItemBySlot(EquipmentSlotType.CHEST) .isEmpty()) return ActionResultType.PASS; - if (!world.isRemote) { - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, .75f, 1); - player.setItemStackToSlot(EquipmentSlotType.CHEST, getItem(world, pos, state)); + if (!world.isClientSide) { + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .75f, 1); + player.setItemSlot(EquipmentSlotType.CHEST, getCloneItemStack(world, pos, state)); world.destroyBlock(pos, false); } return ActionResultType.SUCCESS; } @Override - public ItemStack getItem(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { + public ItemStack getCloneItemStack(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { ItemStack item = AllItems.COPPER_BACKTANK.asStack(); Optional tileEntityOptional = getTileEntityOptional(p_185473_1_, p_185473_2_); @@ -157,7 +159,7 @@ public class CopperBacktankBlock extends HorizontalKineticBlock ListNBT enchants = tileEntityOptional.map(CopperBacktankTileEntity::getEnchantmentTag) .orElse(new ListNBT()); if (!enchants.isEmpty()) { - ListNBT enchantmentTagList = item.getEnchantmentTagList(); + ListNBT enchantmentTagList = item.getEnchantmentTags(); enchantmentTagList.addAll(enchants); tag.put("Enchantments", enchantmentTagList); } @@ -165,7 +167,7 @@ public class CopperBacktankBlock extends HorizontalKineticBlock ITextComponent customName = tileEntityOptional.map(CopperBacktankTileEntity::getCustomName) .orElse(null); if (customName != null) - item.setDisplayName(customName); + item.setHoverName(customName); return item; } @@ -186,7 +188,7 @@ public class CopperBacktankBlock extends HorizontalKineticBlock } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankItem.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankItem.java index d01a1cda2..3fa0f3065 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankItem.java @@ -12,6 +12,8 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; +import net.minecraft.item.Item.Properties; + public class CopperBacktankItem extends CopperArmorItem implements ICapacityEnchantable { public static final int DURABILITY_BAR = 0xefefef; @@ -23,12 +25,12 @@ public class CopperBacktankItem extends CopperArmorItem implements ICapacityEnch } @Override - public ActionResultType onItemUse(ItemUseContext p_195939_1_) { - return blockItem.onItemUse(p_195939_1_); + public ActionResultType useOn(ItemUseContext p_195939_1_) { + return blockItem.useOn(p_195939_1_); } @Override - public boolean isDamageable() { + public boolean canBeDepleted() { return false; } @@ -43,8 +45,8 @@ public class CopperBacktankItem extends CopperArmorItem implements ICapacityEnch } @Override - public void fillItemGroup(ItemGroup p_150895_1_, NonNullList p_150895_2_) { - if (!isInGroup(p_150895_1_)) + public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + if (!allowdedIn(p_150895_1_)) return; ItemStack stack = new ItemStack(this); diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java index 1fe8b76a6..c9075a4ae 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java @@ -31,14 +31,14 @@ public class CopperBacktankRenderer extends KineticTileEntityRenderer { cogs.matrixStacker() .centre() .rotateY(180 + AngleHelper.horizontalAngle(te.getBlockState() - .get(CopperBacktankBlock.HORIZONTAL_FACING))) + .getValue(CopperBacktankBlock.HORIZONTAL_FACING))) .unCentre() .translate(0, 6.5f / 16, 11f / 16) .rotate(Direction.EAST, - AngleHelper.rad(te.getSpeed() / 4f * AnimationTickHolder.getRenderTime(te.getWorld()) % 360)) + AngleHelper.rad(te.getSpeed() / 4f * AnimationTickHolder.getRenderTime(te.getLevel()) % 360)) .translate(0, -6.5f / 16, -11f / 16); cogs.light(light) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .renderInto(ms, buffer.getBuffer(RenderType.solid())); } @Override diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java index 22c3e2f2e..b03b79038 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java @@ -45,7 +45,7 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName BlockState state = getBlockState(); BooleanProperty waterProperty = BlockStateProperties.WATERLOGGED; - if (state.contains(waterProperty) && state.get(waterProperty)) + if (state.hasProperty(waterProperty) && state.getValue(waterProperty)) return; if (airLevelTimer > 0) { @@ -54,12 +54,12 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName } int max = BackTankUtil.maxAir(capacityEnchantLevel); - if (world.isRemote) { - Vector3d centerOf = VecHelper.getCenterOf(pos); + if (level.isClientSide) { + Vector3d centerOf = VecHelper.getCenterOf(worldPosition); Vector3d v = VecHelper.offsetRandomly(centerOf, Create.RANDOM, .65f); Vector3d m = centerOf.subtract(v); if (airLevel != max) - world.addParticle(new AirParticleData(1, .05f), v.x, v.y, v.z, m.x, m.y, m.z); + level.addParticle(new AirParticleData(1, .05f), v.x, v.y, v.z, m.x, m.y, m.z); return; } @@ -70,8 +70,8 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName float abs = Math.abs(getSpeed()); int increment = MathHelper.clamp(((int) abs - 100) / 20, 1, 5); airLevel = Math.min(max, airLevel + increment); - if (getComparatorOutput() != prevComparatorLevel && !world.isRemote) - world.updateComparatorOutputLevel(pos, state.getBlock()); + if (getComparatorOutput() != prevComparatorLevel && !level.isClientSide) + level.updateNeighbourForOutputSignal(worldPosition, state.getBlock()); if (airLevel == max) sendData(); airLevelTimer = MathHelper.clamp((int) (128f - abs / 5f) - 108, 0, 20); @@ -108,15 +108,15 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName } protected void playFilledEffect() { - AllSoundEvents.CONFIRM.playAt(world, pos, 0.4f, 1, true); + AllSoundEvents.CONFIRM.playAt(level, worldPosition, 0.4f, 1, true); Vector3d baseMotion = new Vector3d(.25, 0.1, 0); - Vector3d baseVec = VecHelper.getCenterOf(pos); + Vector3d baseVec = VecHelper.getCenterOf(worldPosition); for (int i = 0; i < 360; i += 10) { Vector3d m = VecHelper.rotate(baseMotion, i, Axis.Y); Vector3d v = baseVec.add(m.normalize() .scale(.25f)); - world.addParticle(ParticleTypes.SPIT, v.x, v.y, v.z, m.x, m.y, m.z); + level.addParticle(ParticleTypes.SPIT, v.x, v.y, v.z, m.x, m.y, m.z); } } @@ -124,7 +124,7 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName public ITextComponent getName() { return this.customName != null ? this.customName : new TranslationTextComponent(AllItems.COPPER_BACKTANK.get() - .getTranslationKey()); + .getDescriptionId()); } @Override diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/DivingBootsItem.java b/src/main/java/com/simibubi/create/content/curiosities/armor/DivingBootsItem.java index 9b83bbb72..2b69e2950 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/DivingBootsItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/DivingBootsItem.java @@ -13,6 +13,8 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import net.minecraft.item.Item.Properties; + @EventBusSubscriber public class DivingBootsItem extends CopperArmorItem { @@ -26,9 +28,9 @@ public class DivingBootsItem extends CopperArmorItem { if (!affects(entity)) return; - Vector3d motion = entity.getMotion(); - Boolean isJumping = ObfuscationReflectionHelper.getPrivateValue(LivingEntity.class, entity, "field_70703_bu"); - entity.onGround |= entity.collidedVertically; + Vector3d motion = entity.getDeltaMovement(); + Boolean isJumping = ObfuscationReflectionHelper.getPrivateValue(LivingEntity.class, entity, "jumping"); // jumping + entity.onGround |= entity.verticalCollision; if (isJumping && entity.onGround) { motion = motion.add(0, .5f, 0); @@ -38,10 +40,10 @@ public class DivingBootsItem extends CopperArmorItem { } float multiplier = 1.3f; - if (motion.mul(1, 0, 1) - .length() < 0.145f && (entity.moveForward > 0 || entity.moveStrafing != 0) && !entity.isSneaking()) - motion = motion.mul(multiplier, 1, multiplier); - entity.setMotion(motion); + if (motion.multiply(1, 0, 1) + .length() < 0.145f && (entity.zza > 0 || entity.xxa != 0) && !entity.isShiftKeyDown()) + motion = motion.multiply(multiplier, 1, multiplier); + entity.setDeltaMovement(motion); } protected static boolean affects(LivingEntity entity) { @@ -59,7 +61,7 @@ public class DivingBootsItem extends CopperArmorItem { return false; if (entity instanceof PlayerEntity) { PlayerEntity playerEntity = (PlayerEntity) entity; - if (playerEntity.abilities.isFlying) + if (playerEntity.abilities.flying) return false; } return true; diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/DivingHelmetItem.java b/src/main/java/com/simibubi/create/content/curiosities/armor/DivingHelmetItem.java index dae5e477a..e0d14b13c 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/DivingHelmetItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/DivingHelmetItem.java @@ -14,6 +14,8 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.item.Item.Properties; + @EventBusSubscriber public class DivingHelmetItem extends CopperArmorItem { @@ -24,18 +26,18 @@ public class DivingHelmetItem extends CopperArmorItem { @SubscribeEvent public static void breatheUnderwater(LivingUpdateEvent event) { LivingEntity entity = event.getEntityLiving(); - World world = entity.world; + World world = entity.level; boolean second = world.getGameTime() % 20 == 0; - boolean drowning = entity.getAir() == 0; + boolean drowning = entity.getAirSupply() == 0; - if (world.isRemote) + if (world.isClientSide) entity.getPersistentData() .remove("VisualBacktankAir"); if (!AllItems.DIVING_HELMET.get() .isWornBy(entity)) return; - if (!entity.areEyesInFluid(FluidTags.WATER)) + if (!entity.isEyeInFluid(FluidTags.WATER)) return; if (entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative()) return; @@ -47,17 +49,17 @@ public class DivingHelmetItem extends CopperArmorItem { return; if (drowning) - entity.setAir(10); + entity.setAirSupply(10); - if (world.isRemote) + if (world.isClientSide) entity.getPersistentData() .putInt("VisualBacktankAir", (int) BackTankUtil.getAir(backtank)); if (!second) return; - entity.setAir(Math.min(entity.getMaxAir(), entity.getAir() + 10)); - entity.addPotionEffect(new EffectInstance(Effects.WATER_BREATHING, 30, 0, true, false, true)); + entity.setAirSupply(Math.min(entity.getMaxAirSupply(), entity.getAirSupply() + 10)); + entity.addEffect(new EffectInstance(Effects.WATER_BREATHING, 30, 0, true, false, true)); BackTankUtil.consumeAir(backtank, 1); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellBlock.java b/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellBlock.java index 2b74cdd75..e8a446804 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellBlock.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellBlock.java @@ -20,6 +20,8 @@ import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class AbstractBellBlock extends BellBlock implements ITE { public AbstractBellBlock(Properties properties) { @@ -28,14 +30,14 @@ public abstract class AbstractBellBlock exten @Override @Nullable - public TileEntity createNewTileEntity(IBlockReader block) { + public TileEntity newBlockEntity(IBlockReader block) { return null; } @Override public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext selection) { - Direction facing = state.get(field_220133_a); - switch (state.get(field_220134_b)) { + Direction facing = state.getValue(FACING); + switch (state.getValue(ATTACHMENT)) { case CEILING: return AllShapes.BELL_CEILING.get(facing); case DOUBLE_WALL: @@ -45,30 +47,30 @@ public abstract class AbstractBellBlock exten case SINGLE_WALL: return AllShapes.BELL_WALL.get(facing); default: - return VoxelShapes.fullCube(); + return VoxelShapes.block(); } } @Override - public boolean ring(World world, BlockState state, BlockRayTraceResult hit, @Nullable PlayerEntity player, + public boolean onHit(World world, BlockState state, BlockRayTraceResult hit, @Nullable PlayerEntity player, boolean flag) { - BlockPos pos = hit.getPos(); - Direction direction = hit.getFace(); + BlockPos pos = hit.getBlockPos(); + Direction direction = hit.getDirection(); if (direction == null) direction = world.getBlockState(pos) - .get(field_220133_a); + .getValue(FACING); - if (!this.canRingFrom(state, direction, hit.getHitVec().y - pos.getY())) + if (!this.canRingFrom(state, direction, hit.getLocation().y - pos.getY())) return false; TE te = getTileEntity(world, pos); if (te == null || !te.ring(world, pos, direction)) return false; - if (!world.isRemote) { + if (!world.isClientSide) { playSound(world, pos); if (player != null) - player.addStat(Stats.BELL_RING); + player.awardStat(Stats.BELL_RING); } return true; @@ -80,8 +82,8 @@ public abstract class AbstractBellBlock exten if (heightChange > 0.8124) return false; - Direction direction = state.get(field_220133_a); - BellAttachment bellAttachment = state.get(field_220134_b); + Direction direction = state.getValue(FACING); + BellAttachment bellAttachment = state.getValue(ATTACHMENT); switch (bellAttachment) { case FLOOR: case CEILING: diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/BasicParticleData.java b/src/main/java/com/simibubi/create/content/curiosities/bell/BasicParticleData.java index 9f6374e97..2eecfd4d7 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/BasicParticleData.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/BasicParticleData.java @@ -18,6 +18,8 @@ import net.minecraft.util.registry.Registry; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.particles.IParticleData.IDeserializer; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public abstract class BasicParticleData implements IParticleData, ICustomParticleDataWithSprite> { @@ -29,12 +31,12 @@ public abstract class BasicParticleData implements IParticle BasicParticleData data = this; return new IParticleData.IDeserializer>() { @Override - public BasicParticleData deserialize(ParticleType> arg0, StringReader reader) { + public BasicParticleData fromCommand(ParticleType> arg0, StringReader reader) { return data; } @Override - public BasicParticleData read(ParticleType> type, PacketBuffer buffer) { + public BasicParticleData fromNetwork(ParticleType> type, PacketBuffer buffer) { return data; } }; @@ -60,10 +62,10 @@ public abstract class BasicParticleData implements IParticle } @Override - public String getParameters() { + public String writeToString() { return Registry.PARTICLE_TYPE.getKey(getType()).toString(); } @Override - public void write(PacketBuffer buffer) { } + public void writeToNetwork(PacketBuffer buffer) { } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/BellRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/bell/BellRenderer.java index 1b68c75a4..37d12a927 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/BellRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/BellRenderer.java @@ -26,21 +26,21 @@ public class BellRenderer extends SafeTileEnt @Override protected void renderSafe(TE te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { BlockState state = te.getBlockState(); - Direction facing = state.get(BellBlock.field_220133_a); - BellAttachment attachment = state.get(BellBlock.field_220134_b); + Direction facing = state.getValue(BellBlock.FACING); + BellAttachment attachment = state.getValue(BellBlock.ATTACHMENT); SuperByteBuffer bell = PartialBufferer.get(te.getBellModel(), state); if (te.isRinging) - bell.rotateCentered(te.ringDirection.rotateYCCW(), getSwingAngle(te.ringingTicks + partialTicks)); + bell.rotateCentered(te.ringDirection.getCounterClockWise(), getSwingAngle(te.ringingTicks + partialTicks)); float rY = AngleHelper.horizontalAngle(facing); if (attachment == BellAttachment.SINGLE_WALL || attachment == BellAttachment.DOUBLE_WALL) rY += 90; bell.rotateCentered(Direction.UP, AngleHelper.rad(rY)); - IVertexBuilder vb = buffer.getBuffer(RenderType.getCutout()); - int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), state, te.getPos()); + IVertexBuilder vb = buffer.getBuffer(RenderType.cutout()); + int lightCoords = WorldRenderer.getLightColor(te.getLevel(), state, te.getBlockPos()); bell.light(lightCoords).renderInto(ms, vb); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/CustomRotationParticle.java b/src/main/java/com/simibubi/create/content/curiosities/bell/CustomRotationParticle.java index 21bc73de8..66e708d8d 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/CustomRotationParticle.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/CustomRotationParticle.java @@ -28,20 +28,20 @@ public class CustomRotationParticle extends SimpleAnimatedParticle { } public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) { - Quaternion quaternion = new Quaternion(camera.getRotation()); - if (particleAngle != 0.0F) { - float angle = MathHelper.lerp(partialTicks, prevParticleAngle, particleAngle); - quaternion.multiply(Vector3f.POSITIVE_Z.getRadialQuaternion(angle)); + Quaternion quaternion = new Quaternion(camera.rotation()); + if (roll != 0.0F) { + float angle = MathHelper.lerp(partialTicks, oRoll, roll); + quaternion.mul(Vector3f.ZP.rotation(angle)); } return quaternion; } @Override - public void buildGeometry(IVertexBuilder builder, ActiveRenderInfo camera, float partialTicks) { - Vector3d cameraPos = camera.getProjectedView(); - float originX = (float) (MathHelper.lerp(partialTicks, prevPosX, posX) - cameraPos.getX()); - float originY = (float) (MathHelper.lerp(partialTicks, prevPosY, posY) - cameraPos.getY()); - float originZ = (float) (MathHelper.lerp(partialTicks, prevPosZ, posZ) - cameraPos.getZ()); + public void render(IVertexBuilder builder, ActiveRenderInfo camera, float partialTicks) { + Vector3d cameraPos = camera.getPosition(); + float originX = (float) (MathHelper.lerp(partialTicks, xo, x) - cameraPos.x()); + float originY = (float) (MathHelper.lerp(partialTicks, yo, y) - cameraPos.y()); + float originZ = (float) (MathHelper.lerp(partialTicks, zo, z) - cameraPos.z()); Vector3f[] vertices = new Vector3f[] { new Vector3f(-1.0F, -1.0F, 0.0F), @@ -49,24 +49,24 @@ public class CustomRotationParticle extends SimpleAnimatedParticle { new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F) }; - float scale = getScale(partialTicks); + float scale = getQuadSize(partialTicks); Quaternion rotation = getCustomRotation(camera, partialTicks); for(int i = 0; i < 4; ++i) { Vector3f vertex = vertices[i]; - vertex.func_214905_a(rotation); + vertex.transform(rotation); vertex.mul(scale); vertex.add(originX, originY, originZ); } - float minU = mirror ? getMaxU() : getMinU(); - float maxU = mirror ? getMinU() : getMaxU(); - float minV = getMinV(); - float maxV = getMaxV(); - int brightness = OptifineHandler.usingShaders() ? LightTexture.pack(12, 15 ) : getBrightnessForRender(partialTicks); - builder.vertex(vertices[0].getX(), vertices[0].getY(), vertices[0].getZ()).texture(maxU, maxV).color(particleRed, particleGreen, particleBlue, particleAlpha).light(brightness).endVertex(); - builder.vertex(vertices[1].getX(), vertices[1].getY(), vertices[1].getZ()).texture(maxU, minV).color(particleRed, particleGreen, particleBlue, particleAlpha).light(brightness).endVertex(); - builder.vertex(vertices[2].getX(), vertices[2].getY(), vertices[2].getZ()).texture(minU, minV).color(particleRed, particleGreen, particleBlue, particleAlpha).light(brightness).endVertex(); - builder.vertex(vertices[3].getX(), vertices[3].getY(), vertices[3].getZ()).texture(minU, maxV).color(particleRed, particleGreen, particleBlue, particleAlpha).light(brightness).endVertex(); + float minU = mirror ? getU1() : getU0(); + float maxU = mirror ? getU0() : getU1(); + float minV = getV0(); + float maxV = getV1(); + int brightness = OptifineHandler.usingShaders() ? LightTexture.pack(12, 15 ) : getLightColor(partialTicks); + builder.vertex(vertices[0].x(), vertices[0].y(), vertices[0].z()).uv(maxU, maxV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex(); + builder.vertex(vertices[1].x(), vertices[1].y(), vertices[1].z()).uv(maxU, minV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex(); + builder.vertex(vertices[2].x(), vertices[2].y(), vertices[2].z()).uv(minU, minV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex(); + builder.vertex(vertices[3].x(), vertices[3].y(), vertices[3].z()).uv(minU, maxV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex(); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellBlock.java b/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellBlock.java index 5bcc703d5..bb4df62fd 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellBlock.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellBlock.java @@ -9,6 +9,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class HauntedBellBlock extends AbstractBellBlock { public HauntedBellBlock(Properties properties) { @@ -31,7 +33,7 @@ public class HauntedBellBlock extends AbstractBellBlock { } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { if (oldState.getBlock() != this) withTileEntityDo(world, pos, HauntedBellTileEntity::startEffect); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellMovementBehaviour.java b/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellMovementBehaviour.java index e54d29d73..bbd46e191 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellMovementBehaviour.java @@ -18,7 +18,7 @@ public class HauntedBellMovementBehaviour extends BellMovementBehaviour { @Override public void visitNewPosition(MovementContext context, BlockPos pos) { - if (!context.world.isRemote && getRecharge(context) == 0) { + if (!context.world.isClientSide && getRecharge(context) == 0) { HauntedBellPulser.sendPulse(context.world, pos, DISTANCE, false); setRecharge(context, HauntedBellTileEntity.RECHARGE_TICKS); playSound(context); diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellPulser.java b/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellPulser.java index 626089218..a26c96c1f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellPulser.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellPulser.java @@ -46,7 +46,7 @@ public class HauntedBellPulser { boolean firstPulse = false; try { - IntAttached ticker = WARMUP.get(player.getUniqueID(), () -> IntAttached.with(WARMUP_TICKS, player)); + IntAttached ticker = WARMUP.get(player.getUUID(), () -> IntAttached.with(WARMUP_TICKS, player)); firstPulse = ticker.getFirst() .intValue() == 1; ticker.decrement(); @@ -55,9 +55,9 @@ public class HauntedBellPulser { } catch (ExecutionException e) { } - long gameTime = player.world.getGameTime(); + long gameTime = player.level.getGameTime(); if (firstPulse || gameTime % RECHARGE_TICKS != 0) - sendPulse(player.world, event.player.getBlockPos(), DISTANCE, false); + sendPulse(player.level, event.player.blockPosition(), DISTANCE, false); } public static void sendPulse(World world, BlockPos pos, int distance, boolean canOverlap) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellTileEntity.java index d55823ec0..4847c815e 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/HauntedBellTileEntity.java @@ -45,7 +45,7 @@ public class HauntedBellTileEntity extends AbstractBellTileEntity { if (!super.ring(world, pos, direction)) return false; - if (!world.isRemote) + if (!world.isClientSide) HauntedBellPulser.sendPulse(world, pos, DISTANCE, false); startEffect(); @@ -78,10 +78,10 @@ public class HauntedBellTileEntity extends AbstractBellTileEntity { return; effectTicks--; - if (!world.isRemote) + if (!level.isClientSide) return; - Random rand = world.getRandom(); + Random rand = level.getRandom(); if (rand.nextFloat() > 0.25f) return; @@ -90,19 +90,19 @@ public class HauntedBellTileEntity extends AbstractBellTileEntity { } protected void spawnParticle(Random rand) { - double x = pos.getX() + rand.nextDouble(); - double y = pos.getY() + 0.5; - double z = pos.getZ() + rand.nextDouble(); + double x = worldPosition.getX() + rand.nextDouble(); + double y = worldPosition.getY() + 0.5; + double z = worldPosition.getZ() + rand.nextDouble(); double vx = rand.nextDouble() * 0.04 - 0.02; double vy = 0.1; double vz = rand.nextDouble() * 0.04 - 0.02; - world.addParticle(ParticleTypes.SOUL, x, y, z, vx, vy, vz); + level.addParticle(ParticleTypes.SOUL, x, y, z, vx, vy, vz); } protected void playSound(Random rand) { float vol = rand.nextFloat() * 0.4F + rand.nextFloat() > 0.9F ? 0.6F : 0.0F; float pitch = 0.6F + rand.nextFloat() * 0.4F; - world.playSound(null, pos, SoundEvents.PARTICLE_SOUL_ESCAPE, SoundCategory.BLOCKS, vol, pitch); + level.playSound(null, worldPosition, SoundEvents.SOUL_ESCAPE, SoundCategory.BLOCKS, vol, pitch); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/PeculiarBellBlock.java b/src/main/java/com/simibubi/create/content/curiosities/bell/PeculiarBellBlock.java index 8033bc7b6..32bf92fd6 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/PeculiarBellBlock.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/PeculiarBellBlock.java @@ -19,6 +19,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class PeculiarBellBlock extends AbstractBellBlock { public PeculiarBellBlock(Properties properties) { @@ -46,15 +48,15 @@ public class PeculiarBellBlock extends AbstractBellBlock if (newState == null) return null; - World world = ctx.getWorld(); - BlockPos pos = ctx.getPos(); - return tryConvert(world, pos, newState, world.getBlockState(pos.offset(Direction.DOWN))); + World world = ctx.getLevel(); + BlockPos pos = ctx.getClickedPos(); + return tryConvert(world, pos, newState, world.getBlockState(pos.relative(Direction.DOWN))); } @Override - public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, + public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) { - BlockState newState = super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos); + BlockState newState = super.updateShape(state, facing, facingState, world, currentPos, facingPos); if (facing != Direction.DOWN) return newState; @@ -66,16 +68,16 @@ public class PeculiarBellBlock extends AbstractBellBlock if (!(Blocks.SOUL_FIRE.is(underBlock) || Blocks.SOUL_CAMPFIRE.is(underBlock))) return state; - if (world.isRemote()) { + if (world.isClientSide()) { spawnConversionParticles(world, pos); } else if (world instanceof World) { AllSoundEvents.HAUNTED_BELL_CONVERT.playOnServer((World) world, pos); } return AllBlocks.HAUNTED_BELL.getDefaultState() - .with(HauntedBellBlock.field_220133_a, state.get(field_220133_a)) - .with(HauntedBellBlock.field_220134_b, state.get(field_220134_b)) - .with(HauntedBellBlock.POWERED, state.get(POWERED)); + .setValue(HauntedBellBlock.FACING, state.getValue(FACING)) + .setValue(HauntedBellBlock.ATTACHMENT, state.getValue(ATTACHMENT)) + .setValue(HauntedBellBlock.POWERED, state.getValue(POWERED)); } public void spawnConversionParticles(IWorld world, BlockPos blockPos) { @@ -84,8 +86,8 @@ public class PeculiarBellBlock extends AbstractBellBlock for (int i = 0; i < num; i++) { float pitch = random.nextFloat() * 120 - 90; float yaw = random.nextFloat() * 360; - Vector3d vel = Vector3d.fromPitchYaw(pitch, yaw).scale(random.nextDouble() * 0.1 + 0.1); - Vector3d pos = Vector3d.ofCenter(blockPos); + Vector3d vel = Vector3d.directionFromRotation(pitch, yaw).scale(random.nextDouble() * 0.1 + 0.1); + Vector3d pos = Vector3d.atCenterOf(blockPos); world.addParticle(ParticleTypes.SOUL_FIRE_FLAME, pos.x, pos.y, pos.z, vel.x, vel.y, vel.z); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulBaseParticle.java b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulBaseParticle.java index 232c4211c..b55cf3908 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulBaseParticle.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulBaseParticle.java @@ -10,6 +10,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Quaternion; import net.minecraft.util.math.vector.Vector3f; +import com.simibubi.create.content.curiosities.bell.BasicParticleData.IBasicParticleFactory; + public class SoulBaseParticle extends CustomRotationParticle { private final IAnimatedSprite animatedSprite; @@ -18,26 +20,26 @@ public class SoulBaseParticle extends CustomRotationParticle { IAnimatedSprite spriteSet) { super(worldIn, x, y, z, spriteSet, 0); this.animatedSprite = spriteSet; - this.particleScale = 0.5f; - this.setSize(this.particleScale, this.particleScale); - this.loopLength = 16 + (int) (this.rand.nextFloat() * 2f - 1f); - this.maxAge = (int) (90.0F / (this.rand.nextFloat() * 0.36F + 0.64F)); + this.quadSize = 0.5f; + this.setSize(this.quadSize, this.quadSize); + this.loopLength = 16 + (int) (this.random.nextFloat() * 2f - 1f); + this.lifetime = (int) (90.0F / (this.random.nextFloat() * 0.36F + 0.64F)); this.selectSpriteLoopingWithAge(animatedSprite); - this.field_21507 = true; // disable movement + this.stoppedByCollision = true; // disable movement } @Override public void tick() { selectSpriteLoopingWithAge(animatedSprite); - BlockPos pos = new BlockPos(posX, posY, posZ); - if (age++ >= maxAge || !SoulPulseEffect.isDark(world, pos)) - setExpired(); + BlockPos pos = new BlockPos(x, y, z); + if (age++ >= lifetime || !SoulPulseEffect.isDark(level, pos)) + remove(); } @Override public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) { - return Vector3f.POSITIVE_X.getDegreesQuaternion(90); + return Vector3f.XP.rotationDegrees(90); } public static class Data extends BasicParticleData { diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulParticle.java b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulParticle.java index d2abd7336..2fb9d4c76 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulParticle.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulParticle.java @@ -12,6 +12,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Quaternion; import net.minecraft.util.math.vector.Vector3f; +import com.simibubi.create.content.curiosities.bell.BasicParticleData.IBasicParticleFactory; + public class SoulParticle extends CustomRotationParticle { private final IAnimatedSprite animatedSprite; @@ -43,23 +45,23 @@ public class SoulParticle extends CustomRotationParticle { IAnimatedSprite spriteSet, IParticleData data) { super(worldIn, x, y, z, spriteSet, 0); this.animatedSprite = spriteSet; - this.particleScale = 0.5f; - this.setSize(this.particleScale, this.particleScale); + this.quadSize = 0.5f; + this.setSize(this.quadSize, this.quadSize); - this.loopLength = loopFrames + (int) (this.rand.nextFloat() * 5f - 4f); - this.startTicks = startFrames + (int) (this.rand.nextFloat() * 5f - 4f); - this.endTicks = endFrames + (int) (this.rand.nextFloat() * 5f - 4f); - this.numLoops = (int) (1f + this.rand.nextFloat() * 2f); + this.loopLength = loopFrames + (int) (this.random.nextFloat() * 5f - 4f); + this.startTicks = startFrames + (int) (this.random.nextFloat() * 5f - 4f); + this.endTicks = endFrames + (int) (this.random.nextFloat() * 5f - 4f); + this.numLoops = (int) (1f + this.random.nextFloat() * 2f); this.setFrame(0); - this.field_21507 = true; // disable movement - this.mirror = this.rand.nextBoolean(); + this.stoppedByCollision = true; // disable movement + this.mirror = this.random.nextBoolean(); this.isPerimeter = data instanceof PerimeterData; this.isExpandingPerimeter = data instanceof ExpandingPerimeterData; this.animationStage = !isPerimeter ? new StartAnimation(this) : new PerimeterAnimation(this); if (isPerimeter) { - prevPosY = posY -= .5f - 1 / 128f; + yo = y -= .5f - 1 / 128f; totalFrames = perimeterFrames; isVisible = false; } @@ -70,22 +72,22 @@ public class SoulParticle extends CustomRotationParticle { animationStage.tick(); animationStage = animationStage.getNext(); - BlockPos pos = new BlockPos(posX, posY, posZ); + BlockPos pos = new BlockPos(x, y, z); if (animationStage == null) - setExpired(); - if (!SoulPulseEffect.isDark(world, pos)) { + remove(); + if (!SoulPulseEffect.isDark(level, pos)) { isVisible = true; if (!isPerimeter) - setExpired(); + remove(); } else if (isPerimeter) isVisible = false; } @Override - public void buildGeometry(IVertexBuilder builder, ActiveRenderInfo camera, float partialTicks) { + public void render(IVertexBuilder builder, ActiveRenderInfo camera, float partialTicks) { if (!isVisible) return; - super.buildGeometry(builder, camera, partialTicks); + super.render(builder, camera, partialTicks); } public void setFrame(int frame) { @@ -96,8 +98,8 @@ public class SoulParticle extends CustomRotationParticle { @Override public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) { if (isPerimeter) - return Vector3f.POSITIVE_X.getDegreesQuaternion(90); - return new Quaternion(0, -camera.getYaw(), 0, true); + return Vector3f.XP.rotationDegrees(90); + return new Quaternion(0, -camera.getYRot(), 0, true); } public static class Data extends BasicParticleData { diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffect.java b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffect.java index a4ba9164d..437555c64 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffect.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffect.java @@ -69,13 +69,13 @@ public class SoulPulseEffect { if (world == null) return new ArrayList<>(); - return getLayer(currentLayerIdx()).map(p -> p.add(pos)) + return getLayer(currentLayerIdx()).map(p -> p.offset(pos)) .filter(p -> canSpawnSoulAt(world, p, true)) .collect(Collectors.toList()); } public static boolean isDark(World world, BlockPos at) { - return world.getLightLevel(LightType.BLOCK, at) < 8; + return world.getBrightness(LightType.BLOCK, at) < 8; } public static boolean canSpawnSoulAt(World world, BlockPos at, boolean ignoreLight) { @@ -85,7 +85,7 @@ public class SoulPulseEffect { return world != null && WorldEntitySpawner - .canCreatureTypeSpawnAtLocation(EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, world, at, dummy) + .isSpawnPositionOk(EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, world, at, dummy) && (ignoreLight || isDark(world, at)) && world .getBlockCollisions(null, @@ -96,17 +96,17 @@ public class SoulPulseEffect { } public void spawnParticles(World world, BlockPos at) { - if (world == null || !world.isRemote) + if (world == null || !world.isClientSide) return; - Vector3d p = Vector3d.of(at); + Vector3d p = Vector3d.atLowerCornerOf(at); if (canOverlap()) - world.addOptionalParticle(((int) Math.round(VecHelper.getCenterOf(pos) + world.addAlwaysVisibleParticle(((int) Math.round(VecHelper.getCenterOf(pos) .distanceTo(VecHelper.getCenterOf(at)))) >= distance ? new SoulParticle.PerimeterData() : new ExpandingPerimeterData(), p.x + 0.5, p.y + 0.5, p.z + 0.5, 0, 0, 0); - if (world.getLightLevel(LightType.BLOCK, at) < 8) { - world.addOptionalParticle(new SoulParticle.Data(), p.x + 0.5, p.y + 0.5, p.z + 0.5, 0, 0, 0); + if (world.getBrightness(LightType.BLOCK, at) < 8) { + world.addAlwaysVisibleParticle(new SoulParticle.Data(), p.x + 0.5, p.y + 0.5, p.z + 0.5, 0, 0, 0); world.addParticle(new SoulBaseParticle.Data(), p.x + 0.5, p.y + 0.01, p.z + 0.5, 0, 0, 0); } } @@ -121,7 +121,7 @@ public class SoulPulseEffect { for (int z = 0; z < MAX_DISTANCE; z++) { BlockPos candidate = new BlockPos(x, y, z); - int dist = (int) Math.round(Math.sqrt(candidate.distanceSq(0, 0, 0, false))); + int dist = (int) Math.round(Math.sqrt(candidate.distSqr(0, 0, 0, false))); if (dist > MAX_DISTANCE) continue; if (dist <= 0) diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryEffectPacket.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryEffectPacket.java index 5ad5d2c63..90609b6a3 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryEffectPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryEffectPacket.java @@ -43,7 +43,7 @@ public class SymmetryEffectPacket extends SimplePacketBase { public void handle(Supplier ctx) { ctx.get().enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { - if (Minecraft.getInstance().player.getPositionVec().distanceTo(Vector3d.of(mirror)) > 100) + if (Minecraft.getInstance().player.position().distanceTo(Vector3d.atLowerCornerOf(mirror)) > 100) return; for (BlockPos to : positions) SymmetryHandler.drawEffect(mirror, to); diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryHandler.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryHandler.java index d21926abf..644999081 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryHandler.java @@ -46,19 +46,19 @@ public class SymmetryHandler { @SubscribeEvent(priority = EventPriority.LOWEST) public static void onBlockPlaced(EntityPlaceEvent event) { if (event.getWorld() - .isRemote()) + .isClientSide()) return; if (!(event.getEntity() instanceof PlayerEntity)) return; PlayerEntity player = (PlayerEntity) event.getEntity(); PlayerInventory inv = player.inventory; - for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) { - if (!inv.getStackInSlot(i) + for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + if (!inv.getItem(i) .isEmpty() - && inv.getStackInSlot(i) + && inv.getItem(i) .getItem() == AllItems.WAND_OF_SYMMETRY.get()) { - SymmetryWandItem.apply(player.world, inv.getStackInSlot(i), player, event.getPos(), + SymmetryWandItem.apply(player.level, inv.getItem(i), player, event.getPos(), event.getPlacedBlock()); } } @@ -67,15 +67,15 @@ public class SymmetryHandler { @SubscribeEvent(priority = EventPriority.LOWEST) public static void onBlockDestroyed(BreakEvent event) { if (event.getWorld() - .isRemote()) + .isClientSide()) return; PlayerEntity player = event.getPlayer(); PlayerInventory inv = player.inventory; - for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) { - if (!inv.getStackInSlot(i) - .isEmpty() && AllItems.WAND_OF_SYMMETRY.isIn(inv.getStackInSlot(i))) { - SymmetryWandItem.remove(player.world, inv.getStackInSlot(i), player, event.getPos()); + for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + if (!inv.getItem(i) + .isEmpty() && AllItems.WAND_OF_SYMMETRY.isIn(inv.getItem(i))) { + SymmetryWandItem.remove(player.level, inv.getItem(i), player, event.getPos()); } } } @@ -86,8 +86,8 @@ public class SymmetryHandler { Minecraft mc = Minecraft.getInstance(); ClientPlayerEntity player = mc.player; - for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) { - ItemStack stackInSlot = player.inventory.getStackInSlot(i); + for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + ItemStack stackInSlot = player.inventory.getItem(i); if (!AllItems.WAND_OF_SYMMETRY.isIn(stackInSlot)) continue; if (!SymmetryWandItem.isEnabled(stackInSlot)) @@ -103,29 +103,29 @@ public class SymmetryHandler { yShift = MathHelper.sin((float) (AnimationTickHolder.getRenderTime() * speed)) / 5f; IRenderTypeBuffer.Impl buffer = Minecraft.getInstance() - .getBufferBuilders() - .getEntityVertexConsumers(); - ActiveRenderInfo info = mc.gameRenderer.getActiveRenderInfo(); - Vector3d view = info.getProjectedView(); + .renderBuffers() + .bufferSource(); + ActiveRenderInfo info = mc.gameRenderer.getMainCamera(); + Vector3d view = info.getPosition(); MatrixStack ms = event.getMatrixStack(); - ms.push(); - ms.translate(-view.getX(), -view.getY(), -view.getZ()); + ms.pushPose(); + ms.translate(-view.x(), -view.y(), -view.z()); ms.translate(pos.getX(), pos.getY(), pos.getZ()); ms.translate(0, yShift + .2f, 0); mirror.applyModelTransform(ms); IBakedModel model = mirror.getModel() .get(); - IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid()); + IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); - mc.getBlockRendererDispatcher() - .getBlockModelRenderer() - .renderModel(player.world, model, Blocks.AIR.getDefaultState(), pos, ms, builder, true, - player.world.getRandom(), MathHelper.getPositionRandom(pos), OverlayTexture.DEFAULT_UV, + mc.getBlockRenderer() + .getModelRenderer() + .renderModel(player.level, model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true, + player.level.getRandom(), MathHelper.getSeed(pos), OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE); - buffer.draw(); - ms.pop(); + buffer.endBatch(); + ms.popPose(); } } @@ -137,16 +137,16 @@ public class SymmetryHandler { Minecraft mc = Minecraft.getInstance(); ClientPlayerEntity player = mc.player; - if (mc.world == null) + if (mc.level == null) return; - if (mc.isGamePaused()) + if (mc.isPaused()) return; tickCounter++; if (tickCounter % 10 == 0) { - for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) { - ItemStack stackInSlot = player.inventory.getStackInSlot(i); + for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + ItemStack stackInSlot = player.inventory.getItem(i); if (stackInSlot != null && AllItems.WAND_OF_SYMMETRY.isIn(stackInSlot) && SymmetryWandItem.isEnabled(stackInSlot)) { @@ -162,7 +162,7 @@ public class SymmetryHandler { Vector3d pos = mirror.getPosition() .add(0.5 + offsetX, 1 / 4d, 0.5 + offsetZ); Vector3d speed = new Vector3d(0, r.nextDouble() * 1 / 8f, 0); - mc.world.addParticle(ParticleTypes.END_ROD, pos.x, pos.y, pos.z, speed.x, speed.y, speed.z); + mc.level.addParticle(ParticleTypes.END_ROD, pos.x, pos.y, pos.z, speed.x, speed.y, speed.z); } } } @@ -171,8 +171,8 @@ public class SymmetryHandler { public static void drawEffect(BlockPos from, BlockPos to) { double density = 0.8f; - Vector3d start = Vector3d.of(from).add(0.5, 0.5, 0.5); - Vector3d end = Vector3d.of(to).add(0.5, 0.5, 0.5); + Vector3d start = Vector3d.atLowerCornerOf(from).add(0.5, 0.5, 0.5); + Vector3d end = Vector3d.atLowerCornerOf(to).add(0.5, 0.5, 0.5); Vector3d diff = end.subtract(start); Vector3d step = diff.normalize() @@ -184,18 +184,18 @@ public class SymmetryHandler { Vector3d pos = start.add(step.scale(i)); Vector3d speed = new Vector3d(0, r.nextDouble() * -40f, 0); - Minecraft.getInstance().world.addParticle(new RedstoneParticleData(1, 1, 1, 1), pos.x, pos.y, pos.z, + Minecraft.getInstance().level.addParticle(new RedstoneParticleData(1, 1, 1, 1), pos.x, pos.y, pos.z, speed.x, speed.y, speed.z); } Vector3d speed = new Vector3d(0, r.nextDouble() * 1 / 32f, 0); Vector3d pos = start.add(step.scale(2)); - Minecraft.getInstance().world.addParticle(ParticleTypes.END_ROD, pos.x, pos.y, pos.z, speed.x, speed.y, + Minecraft.getInstance().level.addParticle(ParticleTypes.END_ROD, pos.x, pos.y, pos.z, speed.x, speed.y, speed.z); speed = new Vector3d(0, r.nextDouble() * 1 / 32f, 0); pos = start.add(step.scale(steps)); - Minecraft.getInstance().world.addParticle(ParticleTypes.END_ROD, pos.x, pos.y, pos.z, speed.x, speed.y, + Minecraft.getInstance().level.addParticle(ParticleTypes.END_ROD, pos.x, pos.y, pos.z, speed.x, speed.y, speed.z); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandItem.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandItem.java index 9ef60eaa1..b127efcb4 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandItem.java @@ -48,46 +48,48 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.PacketDistributor; +import net.minecraft.item.Item.Properties; + public class SymmetryWandItem extends Item { public static final String SYMMETRY = "symmetry"; private static final String ENABLE = "enable"; public SymmetryWandItem(Properties properties) { - super(properties.maxStackSize(1) + super(properties.stacksTo(1) .rarity(Rarity.UNCOMMON)); } @Nonnull @Override - public ActionResultType onItemUse(ItemUseContext context) { + public ActionResultType useOn(ItemUseContext context) { PlayerEntity player = context.getPlayer(); - BlockPos pos = context.getPos(); + BlockPos pos = context.getClickedPos(); if (player == null) return ActionResultType.PASS; - player.getCooldownTracker() - .setCooldown(this, 5); - ItemStack wand = player.getHeldItem(context.getHand()); + player.getCooldowns() + .addCooldown(this, 5); + ItemStack wand = player.getItemInHand(context.getHand()); checkNBT(wand); // Shift -> open GUI - if (player.isSneaking()) { - if (player.world.isRemote) { + if (player.isShiftKeyDown()) { + if (player.level.isClientSide) { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { openWandGUI(wand, context.getHand()); }); - player.getCooldownTracker() - .setCooldown(this, 5); + player.getCooldowns() + .addCooldown(this, 5); } return ActionResultType.SUCCESS; } - if (context.getWorld().isRemote || context.getHand() != Hand.MAIN_HAND) + if (context.getLevel().isClientSide || context.getHand() != Hand.MAIN_HAND) return ActionResultType.SUCCESS; CompoundNBT compound = wand.getTag() .getCompound(SYMMETRY); - pos = pos.offset(context.getFace()); + pos = pos.relative(context.getClickedFace()); SymmetryMirror previousElement = SymmetryMirror.fromNBT(compound); // No Shift -> Make / Move Mirror @@ -98,7 +100,7 @@ public class SymmetryWandItem extends Item { if (previousElement instanceof EmptyMirror) { newElement.setOrientation( - (player.getHorizontalFacing() == Direction.NORTH || player.getHorizontalFacing() == Direction.SOUTH) + (player.getDirection() == Direction.NORTH || player.getDirection() == Direction.SOUTH) ? PlaneMirror.Align.XY.ordinal() : PlaneMirror.Align.YZ.ordinal()); newElement.enable = true; @@ -110,13 +112,13 @@ public class SymmetryWandItem extends Item { if (previousElement instanceof PlaneMirror) { previousElement.setOrientation( - (player.getHorizontalFacing() == Direction.NORTH || player.getHorizontalFacing() == Direction.SOUTH) + (player.getDirection() == Direction.NORTH || player.getDirection() == Direction.SOUTH) ? PlaneMirror.Align.XY.ordinal() : PlaneMirror.Align.YZ.ordinal()); } if (previousElement instanceof CrossPlaneMirror) { - float rotation = player.getRotationYawHead(); + float rotation = player.getYHeadRot(); float abs = Math.abs(rotation % 90); boolean diagonal = abs > 22 && abs < 45 + 22; previousElement @@ -130,23 +132,23 @@ public class SymmetryWandItem extends Item { wand.getTag() .put(SYMMETRY, compound); - player.setHeldItem(context.getHand(), wand); + player.setItemInHand(context.getHand(), wand); return ActionResultType.SUCCESS; } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { - ItemStack wand = playerIn.getHeldItem(handIn); + public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { + ItemStack wand = playerIn.getItemInHand(handIn); checkNBT(wand); // Shift -> Open GUI - if (playerIn.isSneaking()) { - if (worldIn.isRemote) { + if (playerIn.isShiftKeyDown()) { + if (worldIn.isClientSide) { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { - openWandGUI(playerIn.getHeldItem(handIn), handIn); + openWandGUI(playerIn.getItemInHand(handIn), handIn); }); - playerIn.getCooldownTracker() - .setCooldown(this, 5); + playerIn.getCooldowns() + .addCooldown(this, 5); } return new ActionResult(ActionResultType.SUCCESS, wand); } @@ -189,7 +191,7 @@ public class SymmetryWandItem extends Item { checkNBT(wand); if (!isEnabled(wand)) return; - if (!BlockItem.BLOCK_TO_ITEM.containsKey(block.getBlock())) + if (!BlockItem.BY_BLOCK.containsKey(block.getBlock())) return; Map blockSet = new HashMap<>(); @@ -198,7 +200,7 @@ public class SymmetryWandItem extends Item { .getCompound(SYMMETRY)); Vector3d mirrorPos = symmetry.getPosition(); - if (mirrorPos.distanceTo(Vector3d.of(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) + if (mirrorPos.distanceTo(Vector3d.atLowerCornerOf(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) return; if (!player.isCreative() && isHoldingBlock(player, block) && BlockHelper.findAndRemoveInInventory(block, player, 1) == 0) @@ -213,14 +215,14 @@ public class SymmetryWandItem extends Item { if (position.equals(pos)) continue; - if (world.canPlace(block, position, ISelectionContext.forEntity(player))) { + if (world.isUnobstructed(block, position, ISelectionContext.of(player))) { BlockState blockState = blockSet.get(position); for (Direction face : Iterate.directions) - blockState = blockState.updatePostPlacement(face, world.getBlockState(position.offset(face)), world, - position, position.offset(face)); + blockState = blockState.updateShape(face, world.getBlockState(position.relative(face)), world, + position, position.relative(face)); if (player.isCreative()) { - world.setBlockState(position, blockState); + world.setBlockAndUpdate(position, blockState); targets.add(position); continue; } @@ -229,7 +231,7 @@ public class SymmetryWandItem extends Item { if (!toReplace.getMaterial() .isReplaceable()) continue; - if (toReplace.getBlockHardness(world, position) == -1) + if (toReplace.getDestroySpeed(world, position) == -1) continue; if (AllBlocks.CART_ASSEMBLER.has(blockState)) { @@ -243,10 +245,10 @@ public class SymmetryWandItem extends Item { continue; } - BlockSnapshot blocksnapshot = BlockSnapshot.create(world.getRegistryKey(), world, position); + BlockSnapshot blocksnapshot = BlockSnapshot.create(world.dimension(), world, position); FluidState ifluidstate = world.getFluidState(position); - world.setBlockState(position, ifluidstate.getBlockState(), BlockFlags.UPDATE_NEIGHBORS); - world.setBlockState(position, blockState); + world.setBlock(position, ifluidstate.createLegacyBlock(), BlockFlags.UPDATE_NEIGHBORS); + world.setBlockAndUpdate(position, blockState); CompoundNBT wandNbt = wand.getOrCreateTag(); wandNbt.putBoolean("Simulate", true); @@ -267,14 +269,14 @@ public class SymmetryWandItem extends Item { private static boolean isHoldingBlock(PlayerEntity player, BlockState block) { ItemStack itemBlock = BlockHelper.getRequiredItem(block); - return player.getHeldItemMainhand() - .isItemEqual(itemBlock) - || player.getHeldItemOffhand() - .isItemEqual(itemBlock); + return player.getMainHandItem() + .sameItem(itemBlock) + || player.getOffhandItem() + .sameItem(itemBlock); } public static void remove(World world, ItemStack wand, PlayerEntity player, BlockPos pos) { - BlockState air = Blocks.AIR.getDefaultState(); + BlockState air = Blocks.AIR.defaultBlockState(); BlockState ogBlock = world.getBlockState(pos); checkNBT(wand); if (!isEnabled(wand)) @@ -286,7 +288,7 @@ public class SymmetryWandItem extends Item { .getCompound(SYMMETRY)); Vector3d mirrorPos = symmetry.getPosition(); - if (mirrorPos.distanceTo(Vector3d.of(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) + if (mirrorPos.distanceTo(Vector3d.atLowerCornerOf(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) return; symmetry.process(blockSet); @@ -305,16 +307,16 @@ public class SymmetryWandItem extends Item { BlockState blockstate = world.getBlockState(position); if (blockstate.getMaterial() != Material.AIR) { targets.add(position); - world.playEvent(2001, position, Block.getStateId(blockstate)); - world.setBlockState(position, air, 3); + world.levelEvent(2001, position, Block.getId(blockstate)); + world.setBlock(position, air, 3); if (!player.isCreative()) { - if (!player.getHeldItemMainhand() + if (!player.getMainHandItem() .isEmpty()) - player.getHeldItemMainhand() - .onBlockDestroyed(world, blockstate, position, player); - TileEntity tileentity = blockstate.hasTileEntity() ? world.getTileEntity(position) : null; - Block.spawnDrops(blockstate, world, pos, tileentity, player, player.getHeldItemMainhand()); // Add fortune, silk touch and other loot modifiers + player.getMainHandItem() + .mineBlock(world, blockstate, position, player); + TileEntity tileentity = blockstate.hasTileEntity() ? world.getBlockEntity(position) : null; + Block.dropResources(blockstate, world, pos, tileentity, player, player.getMainHandItem()); // Add fortune, silk touch and other loot modifiers } } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandScreen.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandScreen.java index dd9a4d638..7760f56b2 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandScreen.java @@ -75,7 +75,7 @@ public class SymmetryWandScreen extends AbstractSimiScreen { int state = currentElement instanceof TriplePlaneMirror ? 2 : currentElement instanceof CrossPlaneMirror ? 1 : 0; areaType = new SelectionScrollInput(x + 45, y + 21, 109, 18).forOptions(SymmetryMirror.getMirrors()) - .titled(mirrorType.copy()) + .titled(mirrorType.plainCopy()) .writingTo(labelType) .setState(state); @@ -111,7 +111,7 @@ public class SymmetryWandScreen extends AbstractSimiScreen { widgets.remove(areaAlign); areaAlign = new SelectionScrollInput(x + 45, y + 43, 109, 18).forOptions(element.getAlignToolTips()) - .titled(orientation.copy()) + .titled(orientation.plainCopy()) .writingTo(labelAlign) .setState(element.getOrientationIndex()) .calling(element::setOrientation); @@ -125,7 +125,7 @@ public class SymmetryWandScreen extends AbstractSimiScreen { int y = guiTop; background.draw(ms, this, x, y); - textRenderer.draw(ms, wand.getDisplayName(), x + 11, y + 4, 0x6B3802); + font.draw(ms, wand.getHoverName(), x + 11, y + 4, 0x6B3802); renderBlock(ms, x, y); GuiGameElement.of(wand) @@ -136,33 +136,33 @@ public class SymmetryWandScreen extends AbstractSimiScreen { } protected void renderBlock(MatrixStack ms, int x, int y) { - ms.push(); + ms.pushPose(); ms.translate(x + 26, y + 39, 20); ms.scale(16, 16, 16); - ms.multiply(new Vector3f(.3f, 1f, 0f).getDegreesQuaternion(-22.5f)); + ms.mulPose(new Vector3f(.3f, 1f, 0f).rotationDegrees(-22.5f)); currentElement.applyModelTransform(ms); // RenderSystem.multMatrix(ms.peek().getModel()); GuiGameElement.of(currentElement.getModel()) .render(ms); - ms.pop(); + ms.popPose(); } @Override public void removed() { - ItemStack heldItem = client.player.getHeldItem(hand); + ItemStack heldItem = minecraft.player.getItemInHand(hand); CompoundNBT compound = heldItem.getTag(); compound.put(SymmetryWandItem.SYMMETRY, currentElement.writeToNbt()); heldItem.setTag(compound); AllPackets.channel.send(PacketDistributor.SERVER.noArg(), new NbtPacket(heldItem, hand)); - client.player.setHeldItem(hand, heldItem); + minecraft.player.setItemInHand(hand, heldItem); super.removed(); } @Override public boolean mouseClicked(double x, double y, int button) { if (confirmButton.isHovered()) { - client.player.closeScreen(); + minecraft.player.closeContainer(); return true; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandItemRenderer.java index 0c0461daf..0f71a9cde 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandItemRenderer.java @@ -27,7 +27,7 @@ public class SymmetryWandItemRenderer extends CustomRenderedItemModelRenderer BlueprintItem.assignCompleteRecipe(c.ghostInventory, r)); } }); diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintContainer.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintContainer.java index eb71d907a..bf08dde69 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintContainer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintContainer.java @@ -60,14 +60,14 @@ public class BlueprintContainer extends GhostItemContainer { } public void onCraftMatrixChanged() { - if (contentHolder.getBlueprintWorld().isRemote) + if (contentHolder.getBlueprintWorld().isClientSide) return; ServerPlayerEntity serverplayerentity = (ServerPlayerEntity) player; CraftingInventory craftingInventory = new BlueprintCraftingInventory(this, ghostInventory); Optional optional = player.getServer() .getRecipeManager() - .getRecipe(IRecipeType.CRAFTING, craftingInventory, player.getEntityWorld()); + .getRecipeFor(IRecipeType.CRAFTING, craftingInventory, player.getCommandSenderWorld()); if (!optional.isPresent()) { if (ghostInventory.getStackInSlot(9) @@ -77,23 +77,23 @@ public class BlueprintContainer extends GhostItemContainer { return; ghostInventory.setStackInSlot(9, ItemStack.EMPTY); - serverplayerentity.connection.sendPacket(new SSetSlotPacket(windowId, 36 + 9, ItemStack.EMPTY)); + serverplayerentity.connection.send(new SSetSlotPacket(containerId, 36 + 9, ItemStack.EMPTY)); contentHolder.inferredIcon = false; return; } ICraftingRecipe icraftingrecipe = optional.get(); - ItemStack itemstack = icraftingrecipe.getCraftingResult(craftingInventory); + ItemStack itemstack = icraftingrecipe.assemble(craftingInventory); ghostInventory.setStackInSlot(9, itemstack); contentHolder.inferredIcon = true; ItemStack toSend = itemstack.copy(); toSend.getOrCreateTag() .putBoolean("InferredFromRecipe", true); - serverplayerentity.connection.sendPacket(new SSetSlotPacket(windowId, 36 + 9, toSend)); + serverplayerentity.connection.send(new SSetSlotPacket(containerId, 36 + 9, toSend)); } @Override - public void putStackInSlot(int p_75141_1_, ItemStack p_75141_2_) { + public void setItem(int p_75141_1_, ItemStack p_75141_2_) { if (p_75141_1_ == 36 + 9) { if (p_75141_2_.hasTag()) { contentHolder.inferredIcon = p_75141_2_.getTag() @@ -103,7 +103,7 @@ public class BlueprintContainer extends GhostItemContainer { } else contentHolder.inferredIcon = false; } - super.putStackInSlot(p_75141_1_, p_75141_2_); + super.setItem(p_75141_1_, p_75141_2_); } @Override @@ -125,7 +125,7 @@ public class BlueprintContainer extends GhostItemContainer { protected BlueprintSection createOnClient(PacketBuffer extraData) { int entityID = extraData.readVarInt(); int section = extraData.readVarInt(); - Entity entityByID = Minecraft.getInstance().world.getEntityByID(entityID); + Entity entityByID = Minecraft.getInstance().level.getEntity(entityID); if (!(entityByID instanceof BlueprintEntity)) return null; BlueprintEntity blueprintEntity = (BlueprintEntity) entityByID; @@ -134,7 +134,7 @@ public class BlueprintContainer extends GhostItemContainer { } @Override - public boolean canInteractWith(PlayerEntity player) { + public boolean stillValid(PlayerEntity player) { return contentHolder != null && contentHolder.canPlayerUse(player); } @@ -145,7 +145,7 @@ public class BlueprintContainer extends GhostItemContainer { for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { ItemStack stack = items.getStackInSlot(y * 3 + x); - setInventorySlotContents(y * 3 + x, stack == null ? ItemStack.EMPTY : stack.copy()); + setItem(y * 3 + x, stack == null ? ItemStack.EMPTY : stack.copy()); } } } @@ -162,12 +162,12 @@ public class BlueprintContainer extends GhostItemContainer { } @Override - public void onSlotChanged() { - super.onSlotChanged(); - if (index == 9 && getHasStack() && !contentHolder.getBlueprintWorld().isRemote) { + public void setChanged() { + super.setChanged(); + if (index == 9 && hasItem() && !contentHolder.getBlueprintWorld().isClientSide) { contentHolder.inferredIcon = false; ServerPlayerEntity serverplayerentity = (ServerPlayerEntity) player; - serverplayerentity.connection.sendPacket(new SSetSlotPacket(windowId, 36 + 9, getStack())); + serverplayerentity.connection.send(new SSetSlotPacket(containerId, 36 + 9, getItem())); } if (index < 9) onCraftMatrixChanged(); diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintEntity.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintEntity.java index fad37fd64..233848c4a 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintEntity.java @@ -87,7 +87,7 @@ public class BlueprintEntity extends HangingEntity for (int size = 3; size > 0; size--) { this.size = size; this.updateFacingWithBoundingBox(facing, verticalOrientation); - if (this.onValidSurface()) + if (this.survives()) break; } } @@ -99,45 +99,45 @@ public class BlueprintEntity extends HangingEntity } @Override - public IPacket createSpawnPacket() { + public IPacket getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override - public void writeAdditional(CompoundNBT p_213281_1_) { - p_213281_1_.putByte("Facing", (byte) this.facingDirection.getIndex()); - p_213281_1_.putByte("Orientation", (byte) this.verticalOrientation.getIndex()); + public void addAdditionalSaveData(CompoundNBT p_213281_1_) { + p_213281_1_.putByte("Facing", (byte) this.direction.get3DDataValue()); + p_213281_1_.putByte("Orientation", (byte) this.verticalOrientation.get3DDataValue()); p_213281_1_.putInt("Size", size); - super.writeAdditional(p_213281_1_); + super.addAdditionalSaveData(p_213281_1_); } @Override - public void readAdditional(CompoundNBT p_70037_1_) { - this.facingDirection = Direction.byIndex(p_70037_1_.getByte("Facing")); - this.verticalOrientation = Direction.byIndex(p_70037_1_.getByte("Orientation")); + public void readAdditionalSaveData(CompoundNBT p_70037_1_) { + this.direction = Direction.from3DDataValue(p_70037_1_.getByte("Facing")); + this.verticalOrientation = Direction.from3DDataValue(p_70037_1_.getByte("Orientation")); this.size = p_70037_1_.getInt("Size"); - super.readAdditional(p_70037_1_); - this.updateFacingWithBoundingBox(this.facingDirection, this.verticalOrientation); + super.readAdditionalSaveData(p_70037_1_); + this.updateFacingWithBoundingBox(this.direction, this.verticalOrientation); } protected void updateFacingWithBoundingBox(Direction facing, Direction verticalOrientation) { Validate.notNull(facing); - this.facingDirection = facing; + this.direction = facing; this.verticalOrientation = verticalOrientation; if (facing.getAxis() .isHorizontal()) { - this.rotationPitch = 0.0F; - this.rotationYaw = (float) (this.facingDirection.getHorizontalIndex() * 90); + this.xRot = 0.0F; + this.yRot = (float) (this.direction.get2DDataValue() * 90); } else { - this.rotationPitch = (float) (-90 * facing.getAxisDirection() - .getOffset()); - this.rotationYaw = verticalOrientation.getAxis() - .isHorizontal() ? 180 + verticalOrientation.getHorizontalAngle() : 0; + this.xRot = (float) (-90 * facing.getAxisDirection() + .getStep()); + this.yRot = verticalOrientation.getAxis() + .isHorizontal() ? 180 + verticalOrientation.toYRot() : 0; } - this.prevRotationPitch = this.rotationPitch; - this.prevRotationYaw = this.rotationYaw; - this.updateBoundingBox(); + this.xRotO = this.xRot; + this.yRotO = this.yRot; + this.recalculateBoundingBox(); } @Override @@ -146,43 +146,43 @@ public class BlueprintEntity extends HangingEntity } @Override - protected void updateBoundingBox() { - if (this.facingDirection == null) + protected void recalculateBoundingBox() { + if (this.direction == null) return; if (this.verticalOrientation == null) return; - Vector3d pos = Vector3d.of(hangingPosition) + Vector3d pos = Vector3d.atLowerCornerOf(blockPosition()) .add(.5, .5, .5) - .subtract(Vector3d.of(facingDirection.getDirectionVec()) + .subtract(Vector3d.atLowerCornerOf(direction.getNormal()) .scale(0.46875)); double d1 = pos.x; double d2 = pos.y; double d3 = pos.z; - this.setPos(d1, d2, d3); + this.setPosRaw(d1, d2, d3); - Axis axis = facingDirection.getAxis(); + Axis axis = direction.getAxis(); if (size == 2) - pos = pos.add(Vector3d.of(axis.isHorizontal() ? facingDirection.rotateYCCW() - .getDirectionVec() - : verticalOrientation.rotateY() - .getDirectionVec()) + pos = pos.add(Vector3d.atLowerCornerOf(axis.isHorizontal() ? direction.getCounterClockWise() + .getNormal() + : verticalOrientation.getClockWise() + .getNormal()) .scale(0.5)) .add(Vector3d - .of(axis.isHorizontal() ? Direction.UP.getDirectionVec() - : facingDirection == Direction.UP ? verticalOrientation.getDirectionVec() + .atLowerCornerOf(axis.isHorizontal() ? Direction.UP.getNormal() + : direction == Direction.UP ? verticalOrientation.getNormal() : verticalOrientation.getOpposite() - .getDirectionVec()) + .getNormal()) .scale(0.5)); d1 = pos.x; d2 = pos.y; d3 = pos.z; - double d4 = (double) this.getWidthPixels(); - double d5 = (double) this.getHeightPixels(); - double d6 = (double) this.getWidthPixels(); - Direction.Axis direction$axis = this.facingDirection.getAxis(); + double d4 = (double) this.getWidth(); + double d5 = (double) this.getHeight(); + double d6 = (double) this.getWidth(); + Direction.Axis direction$axis = this.direction.getAxis(); switch (direction$axis) { case X: d4 = 1.0D; @@ -200,29 +200,30 @@ public class BlueprintEntity extends HangingEntity this.setBoundingBox(new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6)); } - public boolean onValidSurface() { - if (!world.isSpaceEmpty(this)) + @Override + public boolean survives() { + if (!level.noCollision(this)) return false; - int i = Math.max(1, this.getWidthPixels() / 16); - int j = Math.max(1, this.getHeightPixels() / 16); - BlockPos blockpos = this.hangingPosition.offset(this.facingDirection.getOpposite()); - Direction upDirection = facingDirection.getAxis() + int i = Math.max(1, this.getWidth() / 16); + int j = Math.max(1, this.getHeight() / 16); + BlockPos blockpos = this.pos.relative(this.direction.getOpposite()); + Direction upDirection = direction.getAxis() .isHorizontal() ? Direction.UP - : facingDirection == Direction.UP ? verticalOrientation : verticalOrientation.getOpposite(); - Direction direction = facingDirection.getAxis() - .isVertical() ? verticalOrientation.rotateY() : facingDirection.rotateYCCW(); + : direction == Direction.UP ? verticalOrientation : verticalOrientation.getOpposite(); + Direction newDirection = direction.getAxis() + .isVertical() ? verticalOrientation.getClockWise() : direction.getCounterClockWise(); BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(); for (int k = 0; k < i; ++k) { for (int l = 0; l < j; ++l) { int i1 = (i - 1) / -2; int j1 = (j - 1) / -2; - blockpos$mutable.setPos(blockpos) - .move(direction, k + i1) + blockpos$mutable.set(blockpos) + .move(newDirection, k + i1) .move(upDirection, l + j1); - BlockState blockstate = this.world.getBlockState(blockpos$mutable); - if (Block.hasEnoughSolidSide(this.world, blockpos$mutable, this.facingDirection)) + BlockState blockstate = this.level.getBlockState(blockpos$mutable); + if (Block.canSupportCenter(this.level, blockpos$mutable, this.direction)) continue; if (!blockstate.getMaterial() .isSolid() && !RedstoneDiodeBlock.isDiode(blockstate)) { @@ -231,44 +232,44 @@ public class BlueprintEntity extends HangingEntity } } - return this.world.getEntitiesInAABBexcluding(this, this.getBoundingBox(), IS_HANGING_ENTITY) + return this.level.getEntities(this, this.getBoundingBox(), HANGING_ENTITY) .isEmpty(); } @Override - public int getWidthPixels() { + public int getWidth() { return 16 * size; } @Override - public int getHeightPixels() { + public int getHeight() { return 16 * size; } @Override - public boolean hitByEntity(Entity source) { - if (!(source instanceof PlayerEntity) || world.isRemote) - return super.hitByEntity(source); + public boolean skipAttackInteraction(Entity source) { + if (!(source instanceof PlayerEntity) || level.isClientSide) + return super.skipAttackInteraction(source); PlayerEntity player = (PlayerEntity) source; double attrib = player.getAttribute(ForgeMod.REACH_DISTANCE.get()) .getValue() + (player.isCreative() ? 0 : -0.5F); Vector3d eyePos = source.getEyePosition(1); - Vector3d look = source.getLook(1); + Vector3d look = source.getViewVector(1); Vector3d target = eyePos.add(look.scale(attrib)); - - Optional rayTrace = getBoundingBox().rayTrace(eyePos, target); + + Optional rayTrace = getBoundingBox().clip(eyePos, target); if (!rayTrace.isPresent()) - return super.hitByEntity(source); - + return super.skipAttackInteraction(source); + Vector3d hitVec = rayTrace.get(); - BlueprintSection sectionAt = getSectionAt(hitVec.subtract(getPositionVec())); + BlueprintSection sectionAt = getSectionAt(hitVec.subtract(position())); ItemStackHandler items = sectionAt.getItems(); if (items.getStackInSlot(9) .isEmpty()) - return super.hitByEntity(source); + return super.skipAttackInteraction(source); for (int i = 0; i < items.getSlots(); i++) items.setStackInSlot(i, ItemStack.EMPTY); sectionAt.save(items); @@ -276,20 +277,20 @@ public class BlueprintEntity extends HangingEntity } @Override - public void onBroken(@Nullable Entity p_110128_1_) { - if (!world.getGameRules() - .getBoolean(GameRules.DO_ENTITY_DROPS)) + public void dropItem(@Nullable Entity p_110128_1_) { + if (!level.getGameRules() + .getBoolean(GameRules.RULE_DOENTITYDROPS)) return; - playSound(SoundEvents.ENTITY_PAINTING_BREAK, 1.0F, 1.0F); + playSound(SoundEvents.PAINTING_BREAK, 1.0F, 1.0F); if (p_110128_1_ instanceof PlayerEntity) { PlayerEntity playerentity = (PlayerEntity) p_110128_1_; - if (playerentity.abilities.isCreativeMode) { + if (playerentity.abilities.instabuild) { return; } } - entityDropItem(AllItems.CRAFTING_BLUEPRINT.asStack()); + spawnAtLocation(AllItems.CRAFTING_BLUEPRINT.asStack()); } @Override @@ -303,49 +304,49 @@ public class BlueprintEntity extends HangingEntity } @Override - public void playPlaceSound() { - this.playSound(SoundEvents.ENTITY_PAINTING_PLACE, 1.0F, 1.0F); + public void playPlacementSound() { + this.playSound(SoundEvents.PAINTING_PLACE, 1.0F, 1.0F); } @Override - public void setLocationAndAngles(double p_70012_1_, double p_70012_3_, double p_70012_5_, float p_70012_7_, + public void moveTo(double p_70012_1_, double p_70012_3_, double p_70012_5_, float p_70012_7_, float p_70012_8_) { - this.setPosition(p_70012_1_, p_70012_3_, p_70012_5_); + this.setPos(p_70012_1_, p_70012_3_, p_70012_5_); } @Override @OnlyIn(Dist.CLIENT) - public void setPositionAndRotationDirect(double p_180426_1_, double p_180426_3_, double p_180426_5_, + public void lerpTo(double p_180426_1_, double p_180426_3_, double p_180426_5_, float p_180426_7_, float p_180426_8_, int p_180426_9_, boolean p_180426_10_) { BlockPos blockpos = - this.hangingPosition.add(p_180426_1_ - this.getX(), p_180426_3_ - this.getY(), p_180426_5_ - this.getZ()); - this.setPosition((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ()); + this.pos.offset(p_180426_1_ - this.getX(), p_180426_3_ - this.getY(), p_180426_5_ - this.getZ()); + this.setPos((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ()); } @Override public void writeSpawnData(PacketBuffer buffer) { CompoundNBT compound = new CompoundNBT(); - writeAdditional(compound); - buffer.writeCompoundTag(compound); - buffer.writeCompoundTag(getPersistentData()); + addAdditionalSaveData(compound); + buffer.writeNbt(compound); + buffer.writeNbt(getPersistentData()); } @Override public void readSpawnData(PacketBuffer additionalData) { - readAdditional(additionalData.readCompoundTag()); - getPersistentData().merge(additionalData.readCompoundTag()); + readAdditionalSaveData(additionalData.readNbt()); + getPersistentData().merge(additionalData.readNbt()); } @Override - public ActionResultType applyPlayerInteraction(PlayerEntity player, Vector3d vec, Hand hand) { + public ActionResultType interactAt(PlayerEntity player, Vector3d vec, Hand hand) { if (player instanceof FakePlayer) return ActionResultType.PASS; - boolean holdingWrench = AllItems.WRENCH.isIn(player.getHeldItem(hand)); + boolean holdingWrench = AllItems.WRENCH.isIn(player.getItemInHand(hand)); BlueprintSection section = getSectionAt(vec); ItemStackHandler items = section.getItems(); - if (!holdingWrench && !world.isRemote && !items.getStackInSlot(9) + if (!holdingWrench && !level.isClientSide && !items.getStackInSlot(9) .isEmpty()) { IItemHandlerModifiable playerInv = new InvWrapper(player.inventory); @@ -367,7 +368,7 @@ public class BlueprintEntity extends HangingEntity } for (int slot = 0; slot < playerInv.getSlots(); slot++) { - if (!FilterItem.test(world, playerInv.getStackInSlot(slot), requestedItem)) + if (!FilterItem.test(level, playerInv.getStackInSlot(slot), requestedItem)) continue; ItemStack currentItem = playerInv.extractItem(slot, 1, false); if (stacksTaken.containsKey(slot)) @@ -387,10 +388,10 @@ public class BlueprintEntity extends HangingEntity CraftingInventory craftingInventory = new BlueprintCraftingInventory(craftingGrid); if (!recipe.isPresent()) - recipe = world.getRecipeManager() - .getRecipe(IRecipeType.CRAFTING, craftingInventory, world); - ItemStack result = recipe.filter(r -> r.matches(craftingInventory, world)) - .map(r -> r.getCraftingResult(craftingInventory)) + recipe = level.getRecipeManager() + .getRecipeFor(IRecipeType.CRAFTING, craftingInventory, level); + ItemStack result = recipe.filter(r -> r.matches(craftingInventory, level)) + .map(r -> r.assemble(craftingInventory)) .orElse(ItemStack.EMPTY); if (result.isEmpty()) { @@ -399,17 +400,17 @@ public class BlueprintEntity extends HangingEntity success = false; } else { amountCrafted += result.getCount(); - result.onCrafting(player.world, player, 1); + result.onCraftedBy(player.level, player, 1); BasicEventHooks.firePlayerCraftingEvent(player, result, craftingInventory); - NonNullList nonnulllist = world.getRecipeManager() - .getRecipeNonNull(IRecipeType.CRAFTING, craftingInventory, world); + NonNullList nonnulllist = level.getRecipeManager() + .getRemainingItemsFor(IRecipeType.CRAFTING, craftingInventory, level); if (firstPass) - world.playSound(null, player.getBlockPos(), SoundEvents.ENTITY_ITEM_PICKUP, + level.playSound(null, player.blockPosition(), SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .2f, 1f + Create.RANDOM.nextFloat()); - player.inventory.placeItemBackInInventory(world, result); + player.inventory.placeItemBackInInventory(level, result); for (ItemStack itemStack : nonnulllist) - player.inventory.placeItemBackInInventory(world, itemStack); + player.inventory.placeItemBackInInventory(level, itemStack); firstPass = false; } } @@ -420,15 +421,15 @@ public class BlueprintEntity extends HangingEntity break; } - } while (player.isSneaking()); + } while (player.isShiftKeyDown()); ForgeHooks.setCraftingPlayer(null); return ActionResultType.SUCCESS; } int i = section.index; - if (!world.isRemote && player instanceof ServerPlayerEntity) { + if (!level.isClientSide && player instanceof ServerPlayerEntity) { NetworkHooks.openGui((ServerPlayerEntity) player, section, buf -> { - buf.writeVarInt(getEntityId()); + buf.writeVarInt(getId()); buf.writeVarInt(i); }); } @@ -439,8 +440,8 @@ public class BlueprintEntity extends HangingEntity public BlueprintSection getSectionAt(Vector3d vec) { int index = 0; if (size > 1) { - vec = VecHelper.rotate(vec, rotationYaw, Axis.Y); - vec = VecHelper.rotate(vec, -rotationPitch, Axis.X); + vec = VecHelper.rotate(vec, yRot, Axis.Y); + vec = VecHelper.rotate(vec, -xRot, Axis.X); vec = vec.add(0.5, 0.5, 0); if (size == 3) vec = vec.add(1, 1, 0); @@ -456,7 +457,7 @@ public class BlueprintEntity extends HangingEntity static class BlueprintCraftingInventory extends CraftingInventory { private static Container dummyContainer = new Container(null, -1) { - public boolean canInteractWith(PlayerEntity playerIn) { + public boolean stillValid(PlayerEntity playerIn) { return false; } }; @@ -466,7 +467,7 @@ public class BlueprintEntity extends HangingEntity for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { ItemStack stack = items.get(y * 3 + x); - setInventorySlotContents(y * 3 + x, stack == null ? ItemStack.EMPTY : stack.copy()); + setItem(y * 3 + x, stack == null ? ItemStack.EMPTY : stack.copy()); } } } @@ -517,7 +518,7 @@ public class BlueprintEntity extends HangingEntity list.put(index + "", inventory.serializeNBT()); list.putBoolean("InferredIcon", inferredIcon); cachedDisplayItems = null; - if (!world.isRemote) + if (!level.isClientSide) syncPersistentDataWithTracking(BlueprintEntity.this); } @@ -526,7 +527,7 @@ public class BlueprintEntity extends HangingEntity } public World getBlueprintWorld() { - return world; + return level; } @Override @@ -537,7 +538,7 @@ public class BlueprintEntity extends HangingEntity @Override public ITextComponent getDisplayName() { return new TranslationTextComponent(AllItems.CRAFTING_BLUEPRINT.get() - .getTranslationKey()); + .getDescriptionId()); } @Override diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java index 355df3b30..9846c36b9 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java @@ -32,6 +32,8 @@ import net.minecraftforge.common.crafting.StackList; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.items.ItemStackHandler; +import net.minecraft.item.Item.Properties; + public class BlueprintItem extends Item { public BlueprintItem(Properties p_i48487_1_) { @@ -39,37 +41,37 @@ public class BlueprintItem extends Item { } @Override - public ActionResultType onItemUse(ItemUseContext ctx) { - Direction face = ctx.getFace(); + public ActionResultType useOn(ItemUseContext ctx) { + Direction face = ctx.getClickedFace(); PlayerEntity player = ctx.getPlayer(); - ItemStack stack = ctx.getItem(); - BlockPos pos = ctx.getPos() - .offset(face); + ItemStack stack = ctx.getItemInHand(); + BlockPos pos = ctx.getClickedPos() + .relative(face); - if (player != null && !player.canPlayerEdit(pos, face, stack)) + if (player != null && !player.mayUseItemAt(pos, face, stack)) return ActionResultType.FAIL; - World world = ctx.getWorld(); + World world = ctx.getLevel(); HangingEntity hangingentity = new BlueprintEntity(world, pos, face, face.getAxis() - .isHorizontal() ? Direction.DOWN : ctx.getPlacementHorizontalFacing()); + .isHorizontal() ? Direction.DOWN : ctx.getHorizontalDirection()); CompoundNBT compoundnbt = stack.getTag(); if (compoundnbt != null) - EntityType.applyItemNBT(world, player, hangingentity, compoundnbt); - if (!hangingentity.onValidSurface()) + EntityType.updateCustomEntityTag(world, player, hangingentity, compoundnbt); + if (!hangingentity.survives()) return ActionResultType.CONSUME; - if (!world.isRemote) { - hangingentity.playPlaceSound(); - world.addEntity(hangingentity); + if (!world.isClientSide) { + hangingentity.playPlacementSound(); + world.addFreshEntity(hangingentity); } stack.shrink(1); - return ActionResultType.success(world.isRemote); + return ActionResultType.sidedSuccess(world.isClientSide); } protected boolean canPlace(PlayerEntity p_200127_1_, Direction p_200127_2_, ItemStack p_200127_3_, BlockPos p_200127_4_) { - return p_200127_1_.canPlayerEdit(p_200127_4_, p_200127_2_, p_200127_3_); + return p_200127_1_.mayUseItemAt(p_200127_4_, p_200127_2_, p_200127_3_); } public static void assignCompleteRecipe(ItemStackHandler inv, IRecipe recipe) { @@ -77,7 +79,7 @@ public class BlueprintItem extends Item { for (int i = 0; i < 9; i++) inv.setStackInSlot(i, ItemStack.EMPTY); - inv.setStackInSlot(9, recipe.getRecipeOutput()); + inv.setStackInSlot(9, recipe.getResultItem()); if (recipe instanceof ShapedRecipe) { ShapedRecipe shapedRecipe = (ShapedRecipe) recipe; @@ -93,7 +95,7 @@ public class BlueprintItem extends Item { private static ItemStack convertIngredientToFilter(Ingredient ingredient) { Ingredient.IItemList[] acceptedItems = - ObfuscationReflectionHelper.getPrivateValue(Ingredient.class, ingredient, "field_199807_b"); + ObfuscationReflectionHelper.getPrivateValue(Ingredient.class, ingredient, "values"); // values if (acceptedItems == null || acceptedItems.length > 18) return ItemStack.EMPTY; if (acceptedItems.length == 0) @@ -111,14 +113,14 @@ public class BlueprintItem extends Item { } private static ItemStack convertIItemListToFilter(IItemList itemList) { - Collection stacks = itemList.getStacks(); + Collection stacks = itemList.getItems(); if (itemList instanceof SingleItemList) { for (ItemStack itemStack : stacks) return itemStack; } if (itemList instanceof TagList) { - ResourceLocation resourcelocation = new ResourceLocation(JSONUtils.getString(itemList.serialize(), "tag")); + ResourceLocation resourcelocation = new ResourceLocation(JSONUtils.getAsString(itemList.serialize(), "tag")); ItemStack filterItem = AllItems.ATTRIBUTE_FILTER.asStack(); filterItem.getOrCreateTag() .putInt("WhitelistMode", WhitelistMode.WHITELIST_DISJ.ordinal()); diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintOverlayRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintOverlayRenderer.java index da38ffb60..f52ad6750 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintOverlayRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintOverlayRenderer.java @@ -55,9 +55,9 @@ public class BlueprintOverlayRenderer { public static void tick() { Minecraft mc = Minecraft.getInstance(); - RayTraceResult mouseOver = mc.objectMouseOver; + RayTraceResult mouseOver = mc.hitResult; BlueprintSection last = lastTargetedSection; - boolean sneak = mc.player.isSneaking(); + boolean sneak = mc.player.isShiftKeyDown(); lastTargetedSection = null; active = false; if (mouseOver == null) @@ -70,8 +70,8 @@ public class BlueprintOverlayRenderer { return; BlueprintEntity blueprintEntity = (BlueprintEntity) entityRay.getEntity(); - BlueprintSection sectionAt = blueprintEntity.getSectionAt(entityRay.getHitVec() - .subtract(blueprintEntity.getPositionVec())); + BlueprintSection sectionAt = blueprintEntity.getSectionAt(entityRay.getLocation() + .subtract(blueprintEntity.position())); lastTargetedSection = last; active = true; @@ -104,9 +104,9 @@ public class BlueprintOverlayRenderer { boolean firstPass = true; boolean success = true; Minecraft mc = Minecraft.getInstance(); - ItemStackHandler playerInv = new ItemStackHandler(mc.player.inventory.getSizeInventory()); + ItemStackHandler playerInv = new ItemStackHandler(mc.player.inventory.getContainerSize()); for (int i = 0; i < playerInv.getSlots(); i++) - playerInv.setStackInSlot(i, mc.player.inventory.getStackInSlot(i) + playerInv.setStackInSlot(i, mc.player.inventory.getItem(i) .copy()); int amountCrafted = 0; @@ -132,7 +132,7 @@ public class BlueprintOverlayRenderer { } for (int slot = 0; slot < playerInv.getSlots(); slot++) { - if (!FilterItem.test(mc.world, playerInv.getStackInSlot(slot), requestedItem)) + if (!FilterItem.test(mc.level, playerInv.getStackInSlot(slot), requestedItem)) continue; ItemStack currentItem = playerInv.extractItem(slot, 1, false); craftingGrid.put(i, currentItem); @@ -147,10 +147,10 @@ public class BlueprintOverlayRenderer { if (success) { CraftingInventory craftingInventory = new BlueprintCraftingInventory(craftingGrid); if (!recipe.isPresent()) - recipe = mc.world.getRecipeManager() - .getRecipe(IRecipeType.CRAFTING, craftingInventory, mc.world); - ItemStack resultFromRecipe = recipe.filter(r -> r.matches(craftingInventory, mc.world)) - .map(r -> r.getCraftingResult(craftingInventory)) + recipe = mc.level.getRecipeManager() + .getRecipeFor(IRecipeType.CRAFTING, craftingInventory, mc.level); + ItemStack resultFromRecipe = recipe.filter(r -> r.matches(craftingInventory, mc.level)) + .map(r -> r.assemble(craftingInventory)) .orElse(ItemStack.EMPTY); if (resultFromRecipe.isEmpty()) { @@ -211,9 +211,9 @@ public class BlueprintOverlayRenderer { int w = 30 + 21 * ingredients.size() + 21; int x = (mc.getWindow() - .getScaledWidth() - w) / 2; + .getGuiScaledWidth() - w) / 2; int y = (int) (mc.getWindow() - .getScaledHeight() / 3f * 2); + .getGuiScaledHeight() / 3f * 2); for (Pair pair : ingredients) { RenderSystem.enableBlend(); @@ -243,7 +243,7 @@ public class BlueprintOverlayRenderer { public static void drawItemStack(MatrixStack ms, Minecraft mc, int x, int y, ItemStack itemStack, String count) { if (itemStack.getItem() instanceof FilterItem) { - int step = AnimationTickHolder.getTicks(mc.world) / 10; + int step = AnimationTickHolder.getTicks(mc.level) / 10; ItemStack[] itemsMatchingFilter = getItemsMatchingFilter(itemStack); if (itemsMatchingFilter.length > 0) itemStack = itemsMatchingFilter[step % itemsMatchingFilter.length]; @@ -253,7 +253,7 @@ public class BlueprintOverlayRenderer { .at(x + 3, y + 3) .render(ms); mc.getItemRenderer() - .renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x + 3, y + 3, count); + .renderGuiItemDecorations(mc.font, itemStack, x + 3, y + 3, count); } private static ItemStack[] getItemsMatchingFilter(ItemStack filter) { @@ -278,12 +278,12 @@ public class BlueprintOverlayRenderer { ItemAttribute fromNBT = ItemAttribute.fromNBT((CompoundNBT) attributes.get(0)); if (fromNBT instanceof ItemAttribute.InTag) { ItemAttribute.InTag inTag = (ItemAttribute.InTag) fromNBT; - ITag itag = TagCollectionManager.getTagManager() + ITag itag = TagCollectionManager.getInstance() .getItems() - .get(inTag.tagName); + .getTag(inTag.tagName); if (itag != null) - return Ingredient.fromTag(itag) - .getMatchingStacks(); + return Ingredient.of(itag) + .getItems(); } } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintRenderer.java index 96b25e805..3055488db 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintRenderer.java @@ -33,28 +33,28 @@ public class BlueprintRenderer extends EntityRenderer { int light) { PartialModel partialModel = entity.size == 3 ? AllBlockPartials.CRAFTING_BLUEPRINT_3x3 : entity.size == 2 ? AllBlockPartials.CRAFTING_BLUEPRINT_2x2 : AllBlockPartials.CRAFTING_BLUEPRINT_1x1; - SuperByteBuffer sbb = PartialBufferer.get(partialModel, Blocks.AIR.getDefaultState()); + SuperByteBuffer sbb = PartialBufferer.get(partialModel, Blocks.AIR.defaultBlockState()); sbb.matrixStacker() .rotateY(-yaw) - .rotateX(90.0F + entity.rotationPitch) + .rotateX(90.0F + entity.xRot) .translate(-.5, -1 / 32f, -.5); if (entity.size == 2) sbb.translate(.5, 0, -.5); sbb.forEntityRender() .light(light) - .renderInto(ms, buffer.getBuffer(Atlases.getEntitySolid())); + .renderInto(ms, buffer.getBuffer(Atlases.solidBlockSheet())); super.render(entity, yaw, pt, ms, buffer, light); - ms.push(); + ms.pushPose(); float fakeNormalXRotation = -15; int bl = light >> 4 & 0xf; int sl = light >> 20 & 0xf; - boolean vertical = entity.rotationPitch != 0; - if (entity.rotationPitch == -90) + boolean vertical = entity.xRot != 0; + if (entity.xRot == -90) fakeNormalXRotation = -45; - else if (entity.rotationPitch == 90 || yaw % 180 != 0) { + else if (entity.xRot == 90 || yaw % 180 != 0) { bl /= 1.35; sl /= 1.35; } @@ -63,73 +63,73 @@ public class BlueprintRenderer extends EntityRenderer { MatrixStacker.of(ms) .rotateY(vertical ? 0 : -yaw) .rotateX(fakeNormalXRotation); - Matrix3f copy = ms.peek() - .getNormal() + Matrix3f copy = ms.last() + .normal() .copy(); - ms.pop(); - ms.push(); + ms.popPose(); + ms.pushPose(); MatrixStacker.of(ms) .rotateY(-yaw) - .rotateX(entity.rotationPitch) + .rotateX(entity.xRot) .translate(0, 0, 1 / 32f + .001); if (entity.size == 3) ms.translate(-1, -1, 0); MatrixStack squashedMS = new MatrixStack(); - squashedMS.peek() - .getModel() - .multiply(ms.peek() - .getModel()); + squashedMS.last() + .pose() + .multiply(ms.last() + .pose()); for (int x = 0; x < entity.size; x++) { - squashedMS.push(); + squashedMS.pushPose(); for (int y = 0; y < entity.size; y++) { BlueprintSection section = entity.getSection(x * entity.size + y); Couple displayItems = section.getDisplayItems(); - squashedMS.push(); + squashedMS.pushPose(); squashedMS.scale(.5f, .5f, 1 / 1024f); displayItems.forEachWithContext((stack, primary) -> { if (stack.isEmpty()) return; - squashedMS.push(); + squashedMS.pushPose(); if (!primary) { squashedMS.translate(0.325f, -0.325f, 1); squashedMS.scale(.625f, .625f, 1); } - Matrix3f n = squashedMS.peek() - .getNormal(); - n.a00 = copy.a00; - n.a01 = copy.a01; - n.a02 = copy.a02; - n.a10 = copy.a10; - n.a11 = copy.a11; - n.a12 = copy.a12; - n.a20 = copy.a20; - n.a21 = copy.a21; - n.a22 = copy.a22; + Matrix3f n = squashedMS.last() + .normal(); + n.m00 = copy.m00; + n.m01 = copy.m01; + n.m02 = copy.m02; + n.m10 = copy.m10; + n.m11 = copy.m11; + n.m12 = copy.m12; + n.m20 = copy.m20; + n.m21 = copy.m21; + n.m22 = copy.m22; Minecraft.getInstance() .getItemRenderer() - .renderItem(stack, TransformType.GUI, itemLight, OverlayTexture.DEFAULT_UV, squashedMS, buffer); - squashedMS.pop(); + .renderStatic(stack, TransformType.GUI, itemLight, OverlayTexture.NO_OVERLAY, squashedMS, buffer); + squashedMS.popPose(); }); - squashedMS.pop(); + squashedMS.popPose(); squashedMS.translate(1, 0, 0); } - squashedMS.pop(); + squashedMS.popPose(); squashedMS.translate(0, 1, 0); } - ms.pop(); + ms.popPose(); } @Override - public ResourceLocation getEntityTexture(BlueprintEntity p_110775_1_) { + public ResourceLocation getTextureLocation(BlueprintEntity p_110775_1_) { return null; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintScreen.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintScreen.java index 5c7150818..5fba8bbbc 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintScreen.java @@ -45,8 +45,8 @@ public class BlueprintScreen extends AbstractSimiContainerScreenat(x + background.width + 20, y + background.height - 32, 0) @@ -79,21 +79,21 @@ public class BlueprintScreen extends AbstractSimiContainerScreen(), hoveredSlot.getSlotIndex(), true), x, y, - textRenderer); + font); } @Override public List getTooltipFromItem(ItemStack stack) { List list = super.getTooltipFromItem(stack); - if (hoveredSlot.inventory == container.playerInventory) + if (hoveredSlot.container == menu.playerInventory) return list; return hoveredSlot != null ? addToTooltip(list, hoveredSlot.getSlotIndex(), false) : list; } @@ -104,26 +104,26 @@ public class BlueprintScreen extends AbstractSimiContainerScreen d) { + if (sender.distanceToSqr(entityByID) > d) { // TODO log? return; } if (interactionHand == null) - sender.attackTargetEntityWithCurrentItem(entityByID); + sender.attack(entityByID); else if (specificPoint == null) sender.interactOn(entityByID, interactionHand); else - entityByID.applyPlayerInteraction(sender, specificPoint, interactionHand); + entityByID.interactAt(sender, specificPoint, interactionHand); } }); context.get().setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItem.java b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItem.java index 1cf868e5a..c833042b6 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItem.java @@ -49,6 +49,8 @@ import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.item.Item.Properties; + @EventBusSubscriber public class ExtendoGripItem extends Item { private static DamageSource lastActiveDamageSource; @@ -71,7 +73,7 @@ public class ExtendoGripItem extends Item { ImmutableMultimap.of(ForgeMod.REACH_DISTANCE.get(), doubleRangeAttributeModifier)); public ExtendoGripItem(Properties properties) { - super(properties.maxStackSize(1) + super(properties.stacksTo(1) .rarity(Rarity.UNCOMMON)); } @@ -86,8 +88,8 @@ public class ExtendoGripItem extends Item { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); CompoundNBT persistentData = player.getPersistentData(); - boolean inOff = AllItems.EXTENDO_GRIP.isIn(player.getHeldItemOffhand()); - boolean inMain = AllItems.EXTENDO_GRIP.isIn(player.getHeldItemMainhand()); + boolean inOff = AllItems.EXTENDO_GRIP.isIn(player.getOffhandItem()); + boolean inMain = AllItems.EXTENDO_GRIP.isIn(player.getMainHandItem()); boolean holdingDualExtendo = inOff && inMain; boolean holdingExtendo = inOff ^ inMain; holdingExtendo &= !holdingDualExtendo; @@ -97,13 +99,13 @@ public class ExtendoGripItem extends Item { if (holdingExtendo != wasHoldingExtendo) { if (!holdingExtendo) { player.getAttributes() - .removeModifiers(rangeModifier.getValue()); + .removeAttributeModifiers(rangeModifier.get()); persistentData.remove(EXTENDO_MARKER); } else { if (player instanceof ServerPlayerEntity) AllTriggers.EXTENDO.trigger((ServerPlayerEntity) player); player.getAttributes() - .addTemporaryModifiers(rangeModifier.getValue()); + .addTransientAttributeModifiers(rangeModifier.get()); persistentData.putBoolean(EXTENDO_MARKER, true); } } @@ -111,13 +113,13 @@ public class ExtendoGripItem extends Item { if (holdingDualExtendo != wasHoldingDualExtendo) { if (!holdingDualExtendo) { player.getAttributes() - .removeModifiers(doubleRangeModifier.getValue()); + .removeAttributeModifiers(doubleRangeModifier.get()); persistentData.remove(DUAL_EXTENDO_MARKER); } else { if (player instanceof ServerPlayerEntity) AllTriggers.GIGA_EXTENDO.trigger((ServerPlayerEntity) player); player.getAttributes() - .addTemporaryModifiers(doubleRangeModifier.getValue()); + .addTransientAttributeModifiers(doubleRangeModifier.get()); persistentData.putBoolean(DUAL_EXTENDO_MARKER, true); } } @@ -131,10 +133,10 @@ public class ExtendoGripItem extends Item { if (persistentData.contains(DUAL_EXTENDO_MARKER)) player.getAttributes() - .addTemporaryModifiers(doubleRangeModifier.getValue()); + .addTransientAttributeModifiers(doubleRangeModifier.get()); else if (persistentData.contains(EXTENDO_MARKER)) player.getAttributes() - .addTemporaryModifiers(rangeModifier.getValue()); + .addTransientAttributeModifiers(rangeModifier.get()); } @SubscribeEvent @@ -142,11 +144,11 @@ public class ExtendoGripItem extends Item { public static void dontMissEntitiesWhenYouHaveHighReachDistance(ClickInputEvent event) { Minecraft mc = Minecraft.getInstance(); ClientPlayerEntity player = mc.player; - if (mc.world == null || player == null) + if (mc.level == null || player == null) return; if (!isHoldingExtendoGrip(player)) return; - if (mc.objectMouseOver instanceof BlockRayTraceResult && mc.objectMouseOver.getType() != Type.MISS) + if (mc.hitResult instanceof BlockRayTraceResult && mc.hitResult.getType() != Type.MISS) return; // Modified version of GameRenderer#getMouseOver @@ -155,23 +157,23 @@ public class ExtendoGripItem extends Item { if (!player.isCreative()) d0 -= 0.5f; Vector3d Vector3d = player.getEyePosition(AnimationTickHolder.getPartialTicks()); - Vector3d Vector3d1 = player.getLook(1.0F); + Vector3d Vector3d1 = player.getViewVector(1.0F); Vector3d Vector3d2 = Vector3d.add(Vector3d1.x * d0, Vector3d1.y * d0, Vector3d1.z * d0); AxisAlignedBB axisalignedbb = player.getBoundingBox() - .expand(Vector3d1.scale(d0)) - .grow(1.0D, 1.0D, 1.0D); + .expandTowards(Vector3d1.scale(d0)) + .inflate(1.0D, 1.0D, 1.0D); EntityRayTraceResult entityraytraceresult = - ProjectileHelper.rayTraceEntities(player, Vector3d, Vector3d2, axisalignedbb, (e) -> { - return !e.isSpectator() && e.canBeCollidedWith(); + ProjectileHelper.getEntityHitResult(player, Vector3d, Vector3d2, axisalignedbb, (e) -> { + return !e.isSpectator() && e.isPickable(); }, d0 * d0); if (entityraytraceresult != null) { Entity entity1 = entityraytraceresult.getEntity(); - Vector3d Vector3d3 = entityraytraceresult.getHitVec(); - double d2 = Vector3d.squareDistanceTo(Vector3d3); - if (d2 < d0 * d0 || mc.objectMouseOver == null || mc.objectMouseOver.getType() == Type.MISS) { - mc.objectMouseOver = entityraytraceresult; + Vector3d Vector3d3 = entityraytraceresult.getLocation(); + double d2 = Vector3d.distanceToSqr(Vector3d3); + if (d2 < d0 * d0 || mc.hitResult == null || mc.hitResult.getType() == Type.MISS) { + mc.hitResult = entityraytraceresult; if (entity1 instanceof LivingEntity || entity1 instanceof ItemFrameEntity) - mc.pointedEntity = entity1; + mc.crosshairPickEntity = entity1; } } } @@ -196,19 +198,19 @@ public class ExtendoGripItem extends Item { private static void findAndDamageExtendoGrip(PlayerEntity player) { if (player == null) return; - if (player.world.isRemote) + if (player.level.isClientSide) return; Hand hand = Hand.MAIN_HAND; - ItemStack extendo = player.getHeldItemMainhand(); + ItemStack extendo = player.getMainHandItem(); if (!AllItems.EXTENDO_GRIP.isIn(extendo)) { - extendo = player.getHeldItemOffhand(); + extendo = player.getOffhandItem(); hand = Hand.OFF_HAND; } if (!AllItems.EXTENDO_GRIP.isIn(extendo)) return; final Hand h = hand; if (!BackTankUtil.canAbsorbDamage(player, maxUses())) - extendo.damageItem(1, player, p -> p.sendBreakAnimation(h)); + extendo.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(h)); } @Override @@ -231,7 +233,7 @@ public class ExtendoGripItem extends Item { } @Override - public boolean isDamageable() { + public boolean canBeDepleted() { return true; } @@ -248,7 +250,7 @@ public class ExtendoGripItem extends Item { DamageSource source = event.getSource(); if (source == null) return; - Entity trueSource = source.getTrueSource(); + Entity trueSource = source.getEntity(); if (trueSource instanceof PlayerEntity) findAndDamageExtendoGrip((PlayerEntity) trueSource); } @@ -257,7 +259,7 @@ public class ExtendoGripItem extends Item { public static void attacksByExtendoGripHaveMoreKnockback(LivingKnockBackEvent event) { if (lastActiveDamageSource == null) return; - Entity entity = lastActiveDamageSource.getImmediateSource(); + Entity entity = lastActiveDamageSource.getDirectEntity(); if (!(entity instanceof PlayerEntity)) return; PlayerEntity player = (PlayerEntity) entity; @@ -268,9 +270,9 @@ public class ExtendoGripItem extends Item { private static boolean isUncaughtClientInteraction(Entity entity, Entity target) { // Server ignores entity interaction further than 6m - if (entity.getDistanceSq(target) < 36) + if (entity.distanceToSqr(target) < 36) return false; - if (!entity.world.isRemote) + if (!entity.level.isClientSide) return false; if (!(entity instanceof PlayerEntity)) return false; @@ -315,8 +317,8 @@ public class ExtendoGripItem extends Item { } public static boolean isHoldingExtendoGrip(PlayerEntity player) { - boolean inOff = AllItems.EXTENDO_GRIP.isIn(player.getHeldItemOffhand()); - boolean inMain = AllItems.EXTENDO_GRIP.isIn(player.getHeldItemMainhand()); + boolean inOff = AllItems.EXTENDO_GRIP.isIn(player.getOffhandItem()); + boolean inMain = AllItems.EXTENDO_GRIP.isIn(player.getMainHandItem()); boolean holdingGrip = inOff || inMain; return holdingGrip; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItemRenderer.java index c604eeb3a..522afa1cf 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItemRenderer.java @@ -39,10 +39,10 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer mainHandAnimation && swingProgress > 0) @@ -86,7 +86,7 @@ public class ExtendoGripRenderHandler { ms.translate(flip * (0.64000005F - .1f), -0.4F + equipProgress * -0.6F, -0.71999997F + .3f); - ms.push(); + ms.pushPose(); msr.rotateY(flip * 75.0F); ms.translate(flip * -1.0F, 3.6F, 3.5F); msr.rotateZ(flip * 120) @@ -96,18 +96,18 @@ public class ExtendoGripRenderHandler { msr.rotateY(flip * 40.0F); ms.translate(flip * 0.05f, -0.3f, -0.3f); - PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager() + PlayerRenderer playerrenderer = (PlayerRenderer) mc.getEntityRenderDispatcher() .getRenderer(player); if (rightHand) - playerrenderer.renderRightArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), player); + playerrenderer.renderRightHand(event.getMatrixStack(), event.getBuffers(), event.getLight(), player); else - playerrenderer.renderLeftArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), player); - ms.pop(); + playerrenderer.renderLeftHand(event.getMatrixStack(), event.getBuffers(), event.getLight(), player); + ms.popPose(); // Render gun - ms.push(); + ms.pushPose(); ms.translate(flip * -0.1f, 0, -0.3f); - FirstPersonRenderer firstPersonRenderer = mc.getFirstPersonRenderer(); + FirstPersonRenderer firstPersonRenderer = mc.getItemInHandRenderer(); TransformType transform = rightHand ? TransformType.FIRST_PERSON_RIGHT_HAND : TransformType.FIRST_PERSON_LEFT_HAND; firstPersonRenderer.renderItem(mc.player, notInOffhand ? heldItem : offhandItem, transform, !rightHand, @@ -115,11 +115,11 @@ public class ExtendoGripRenderHandler { if (!notInOffhand) { ForgeHooksClient.handleCameraTransforms(ms, mc.getItemRenderer() - .getItemModelWithOverrides(offhandItem, null, null), transform, !rightHand); + .getModel(offhandItem, null, null), transform, !rightHand); ms.translate(flip * -.05f, .15f, -1.2f); ms.translate(0, 0, -animation * 2.25f); if (blockItem && mc.getItemRenderer() - .getItemModelWithOverrides(heldItem, null, null) + .getModel(heldItem, null, null) .isGui3d()) { msr.rotateY(flip * 45); ms.translate(flip * 0.15f, -0.15f, -.05f); @@ -130,18 +130,18 @@ public class ExtendoGripRenderHandler { event.getBuffers(), event.getLight()); } - ms.pop(); + ms.popPose(); } - ms.pop(); + ms.popPose(); event.setCanceled(true); } private static ItemStack getRenderedMainHandStack() { - return Minecraft.getInstance().getFirstPersonRenderer().itemStackMainHand; + return Minecraft.getInstance().getItemInHandRenderer().mainHandItem; } private static ItemStack getRenderedOffHandStack() { - return Minecraft.getInstance().getFirstPersonRenderer().itemStackOffHand; + return Minecraft.getInstance().getItemInHandRenderer().offHandItem; } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItem.java b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItem.java index 676b36d80..b35d16750 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItem.java @@ -27,60 +27,62 @@ import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; +import net.minecraft.item.Item.Properties; + @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class SandPaperItem extends Item { public SandPaperItem(Properties properties) { - super(properties.maxDamage(8)); + super(properties.durability(8)); } @Override - public UseAction getUseAction(ItemStack stack) { + public UseAction getUseAnimation(ItemStack stack) { return UseAction.EAT; } @Override - public ActionResultType onItemUse(ItemUseContext context) { + public ActionResultType useOn(ItemUseContext context) { return ActionResultType.PASS; } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { - ItemStack itemstack = playerIn.getHeldItem(handIn); + public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { + ItemStack itemstack = playerIn.getItemInHand(handIn); ActionResult FAIL = new ActionResult<>(ActionResultType.FAIL, itemstack); if (itemstack.getOrCreateTag() .contains("Polishing")) { - playerIn.setActiveHand(handIn); + playerIn.startUsingItem(handIn); return new ActionResult<>(ActionResultType.PASS, itemstack); } Hand otherHand = handIn == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND; - ItemStack itemInOtherHand = playerIn.getHeldItem(otherHand); + ItemStack itemInOtherHand = playerIn.getItemInHand(otherHand); if (SandPaperPolishingRecipe.canPolish(worldIn, itemInOtherHand)) { ItemStack item = itemInOtherHand.copy(); ItemStack toPolish = item.split(1); - playerIn.setActiveHand(handIn); + playerIn.startUsingItem(handIn); itemstack.getOrCreateTag() .put("Polishing", toPolish.serializeNBT()); - playerIn.setHeldItem(otherHand, item); + playerIn.setItemInHand(otherHand, item); return new ActionResult<>(ActionResultType.SUCCESS, itemstack); } - RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.NONE); + RayTraceResult raytraceresult = getPlayerPOVHitResult(worldIn, playerIn, RayTraceContext.FluidMode.NONE); if (!(raytraceresult instanceof BlockRayTraceResult)) return FAIL; BlockRayTraceResult ray = (BlockRayTraceResult) raytraceresult; - Vector3d hitVec = ray.getHitVec(); + Vector3d hitVec = ray.getLocation(); - AxisAlignedBB bb = new AxisAlignedBB(hitVec, hitVec).grow(1f); + AxisAlignedBB bb = new AxisAlignedBB(hitVec, hitVec).inflate(1f); ItemEntity pickUp = null; - for (ItemEntity itemEntity : worldIn.getEntitiesWithinAABB(ItemEntity.class, bb)) { + for (ItemEntity itemEntity : worldIn.getEntitiesOfClass(ItemEntity.class, bb)) { if (!itemEntity.isAlive()) continue; - if (itemEntity.getPositionVec() - .distanceTo(playerIn.getPositionVec()) > 3) + if (itemEntity.position() + .distanceTo(playerIn.position()) > 3) continue; ItemStack stack = itemEntity.getItem(); if (!SandPaperPolishingRecipe.canPolish(worldIn, stack)) @@ -96,9 +98,9 @@ public class SandPaperItem extends Item { .copy(); ItemStack toPolish = item.split(1); - playerIn.setActiveHand(handIn); + playerIn.startUsingItem(handIn); - if (!worldIn.isRemote) { + if (!worldIn.isClientSide) { itemstack.getOrCreateTag() .put("Polishing", toPolish.serializeNBT()); if (item.isEmpty()) @@ -121,19 +123,19 @@ public class SandPaperItem extends Item { } @Override - public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) { + public ItemStack finishUsingItem(ItemStack stack, World worldIn, LivingEntity entityLiving) { if (!(entityLiving instanceof PlayerEntity)) return stack; PlayerEntity player = (PlayerEntity) entityLiving; CompoundNBT tag = stack.getOrCreateTag(); if (tag.contains("Polishing")) { - ItemStack toPolish = ItemStack.read(tag.getCompound("Polishing")); + ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing")); ItemStack polished = - SandPaperPolishingRecipe.applyPolish(worldIn, entityLiving.getPositionVec(), toPolish, stack); + SandPaperPolishingRecipe.applyPolish(worldIn, entityLiving.position(), toPolish, stack); - if (worldIn.isRemote) { + if (worldIn.isClientSide) { spawnParticles(entityLiving.getEyePosition(1) - .add(entityLiving.getLookVec() + .add(entityLiving.getLookAngle() .scale(.5f)), toPolish, worldIn); return stack; @@ -141,13 +143,13 @@ public class SandPaperItem extends Item { if (!polished.isEmpty()) { if (player instanceof FakePlayer) { - player.dropItem(polished, false, false); + player.drop(polished, false, false); } else { player.inventory.placeItemBackInInventory(worldIn, polished); } } tag.remove("Polishing"); - stack.damageItem(1, entityLiving, p -> p.sendBreakAnimation(p.getActiveHand())); + stack.hurtAndBreak(1, entityLiving, p -> p.broadcastBreakEvent(p.getUsedItemHand())); } return stack; @@ -155,20 +157,20 @@ public class SandPaperItem extends Item { public static void spawnParticles(Vector3d location, ItemStack polishedStack, World world) { for (int i = 0; i < 20; i++) { - Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, world.rand, 1 / 8f); + Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, world.random, 1 / 8f); world.addParticle(new ItemParticleData(ParticleTypes.ITEM, polishedStack), location.x, location.y, location.z, motion.x, motion.y, motion.z); } } @Override - public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) { + public void releaseUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) { if (!(entityLiving instanceof PlayerEntity)) return; PlayerEntity player = (PlayerEntity) entityLiving; CompoundNBT tag = stack.getOrCreateTag(); if (tag.contains("Polishing")) { - ItemStack toPolish = ItemStack.read(tag.getCompound("Polishing")); + ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing")); player.inventory.placeItemBackInInventory(worldIn, toPolish); tag.remove("Polishing"); } @@ -180,7 +182,7 @@ public class SandPaperItem extends Item { } @Override - public int getItemEnchantability() { + public int getEnchantmentValue() { return 5; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItemRenderer.java index fca6a5c45..bdc8946f5 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItemRenderer.java @@ -19,34 +19,34 @@ import net.minecraft.util.math.vector.Vector3f; public class SandPaperItemRenderer extends ItemStackTileEntityRenderer { @Override - public void render(ItemStack stack, TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + public void renderByItem(ItemStack stack, TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); ClientPlayerEntity player = Minecraft.getInstance().player; - SandPaperModel mainModel = (SandPaperModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, null); + SandPaperModel mainModel = (SandPaperModel) itemRenderer.getModel(stack, Minecraft.getInstance().level, null); float partialTicks = AnimationTickHolder.getPartialTicks(); boolean leftHand = transformType == TransformType.FIRST_PERSON_LEFT_HAND; boolean firstPerson = leftHand || transformType == TransformType.FIRST_PERSON_RIGHT_HAND; - ms.push(); + ms.pushPose(); ms.translate(.5f, .5f, .5f); CompoundNBT tag = stack.getOrCreateTag(); boolean jeiMode = tag.contains("JEI"); if (tag.contains("Polishing")) { - ms.push(); + ms.pushPose(); if (transformType == TransformType.GUI) { ms.translate(0.0F, .2f, 1.0F); ms.scale(.75f, .75f, .75f); } else { int modifier = leftHand ? -1 : 1; - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(modifier * 40)); + ms.mulPose(Vector3f.YP.rotationDegrees(modifier * 40)); } // Reverse bobbing - float time = (float) (!jeiMode ? player.getItemInUseCount() + float time = (float) (!jeiMode ? player.getUseItemRemainingTicks() : (-AnimationTickHolder.getTicks()) % stack.getUseDuration()) - partialTicks + 1.0F; if (time / (float) stack.getUseDuration() < 0.8F) { float bobbing = -MathHelper.abs(MathHelper.cos(time / 4.0F * (float) Math.PI) * 0.1F); @@ -57,26 +57,26 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer { ms.translate(0.0f, bobbing, 0.0F); } - ItemStack toPolish = ItemStack.read(tag.getCompound("Polishing")); - itemRenderer.renderItem(toPolish, TransformType.NONE, light, overlay, ms, buffer); + ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing")); + itemRenderer.renderStatic(toPolish, TransformType.NONE, light, overlay, ms, buffer); - ms.pop(); + ms.popPose(); } if (firstPerson) { - int itemInUseCount = player.getItemInUseCount(); + int itemInUseCount = player.getUseItemRemainingTicks(); if (itemInUseCount > 0) { int modifier = leftHand ? -1 : 1; ms.translate(modifier * .5f, 0, -.25f); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(modifier * 40)); - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(modifier * 10)); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(modifier * 90)); + ms.mulPose(Vector3f.ZP.rotationDegrees(modifier * 40)); + ms.mulPose(Vector3f.XP.rotationDegrees(modifier * 10)); + ms.mulPose(Vector3f.YP.rotationDegrees(modifier * 90)); } } - itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getOriginalModel()); + itemRenderer.render(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getOriginalModel()); - ms.pop(); + ms.popPose(); } public static class SandPaperModel extends CustomRenderedItemModel { diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperPolishingRecipe.java b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperPolishingRecipe.java index b949f1f94..8ef830a4f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperPolishingRecipe.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperPolishingRecipe.java @@ -26,7 +26,7 @@ public class SandPaperPolishingRecipe extends ProcessingRecipe { @Override public boolean matches(SandPaperInv inv, World worldIn) { return ingredients.get(0) - .test(inv.getStackInSlot(0)); + .test(inv.getItem(0)); } @Override @@ -47,14 +47,14 @@ public class SandPaperPolishingRecipe extends ProcessingRecipe { List> matchingRecipes = getMatchingRecipes(world, stack); if (!matchingRecipes.isEmpty()) return matchingRecipes.get(0) - .getCraftingResult(new SandPaperInv(stack)) + .assemble(new SandPaperInv(stack)) .copy(); return stack; } public static List> getMatchingRecipes(World world, ItemStack stack) { return world.getRecipeManager() - .getRecipes(AllRecipeTypes.SANDPAPER_POLISHING.getType(), new SandPaperInv(stack), world); + .getRecipesFor(AllRecipeTypes.SANDPAPER_POLISHING.getType(), new SandPaperInv(stack), world); } public static class SandPaperInv extends RecipeWrapper { diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItem.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItem.java index 480f44329..7ccfc3b00 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItem.java @@ -44,6 +44,8 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.Item.Properties; + public class PotatoCannonItem extends ShootableItem { public static ItemStack CLIENT_CURRENT_AMMO = ItemStack.EMPTY; @@ -54,20 +56,20 @@ public class PotatoCannonItem extends ShootableItem { } @Override - public boolean canPlayerBreakBlockWhileHolding(BlockState p_195938_1_, World p_195938_2_, BlockPos p_195938_3_, + public boolean canAttackBlock(BlockState p_195938_1_, World p_195938_2_, BlockPos p_195938_3_, PlayerEntity p_195938_4_) { return false; } @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { - if (enchantment == Enchantments.POWER) + if (enchantment == Enchantments.POWER_ARROWS) return true; - if (enchantment == Enchantments.PUNCH) + if (enchantment == Enchantments.PUNCH_ARROWS) return true; - if (enchantment == Enchantments.FLAME) + if (enchantment == Enchantments.FLAMING_ARROWS) return true; - if (enchantment == Enchantments.LOOTING) + if (enchantment == Enchantments.MOB_LOOTING) return true; if (enchantment == AllEnchantments.POTATO_RECOVERY.get()) return true; @@ -75,8 +77,8 @@ public class PotatoCannonItem extends ShootableItem { } @Override - public ActionResultType onItemUse(ItemUseContext context) { - return onItemRightClick(context.getWorld(), context.getPlayer(), context.getHand()).getType(); + public ActionResultType useOn(ItemUseContext context) { + return use(context.getLevel(), context.getPlayer(), context.getHand()).getResult(); } @Override @@ -104,7 +106,7 @@ public class PotatoCannonItem extends ShootableItem { } @Override - public boolean isDamageable() { + public boolean canBeDepleted() { return true; } @@ -118,14 +120,14 @@ public class PotatoCannonItem extends ShootableItem { } @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { - ItemStack stack = player.getHeldItem(hand); + public ActionResult use(World world, PlayerEntity player, Hand hand) { + ItemStack stack = player.getItemInHand(hand); return findAmmoInInventory(world, player, stack).map(itemStack -> { if (ShootableGadgetItemMethods.shouldSwap(player, stack, hand, this::isCannon)) return ActionResult.fail(stack); - if (world.isRemote) { + if (world.isClientSide) { CreateClient.POTATO_CANNON_RENDER_HANDLER.dontAnimateItem(hand); return ActionResult.success(stack); } @@ -134,12 +136,12 @@ public class PotatoCannonItem extends ShootableItem { new Vector3d(.75f, -0.15f, 1.5f)); Vector3d correction = ShootableGadgetItemMethods.getGunBarrelVec(player, hand == Hand.MAIN_HAND, new Vector3d(-.05f, 0, 0)) - .subtract(player.getPositionVec() + .subtract(player.position() .add(0, player.getEyeHeight(), 0)); PotatoCannonProjectileTypes projectileType = PotatoCannonProjectileTypes.getProjectileTypeOf(itemStack) .orElse(PotatoCannonProjectileTypes.FALLBACK); - Vector3d lookVec = player.getLookVec(); + Vector3d lookVec = player.getLookAngle(); Vector3d motion = lookVec.add(correction) .normalize() .scale(projectileType.getVelocityMultiplier()); @@ -165,20 +167,20 @@ public class PotatoCannonItem extends ShootableItem { if (i != 0) projectile.recoveryChance = 0; - projectile.setPosition(barrelPos.x, barrelPos.y, barrelPos.z); - projectile.setMotion(splitMotion); - projectile.setShooter(player); - world.addEntity(projectile); + projectile.setPos(barrelPos.x, barrelPos.y, barrelPos.z); + projectile.setDeltaMovement(splitMotion); + projectile.setOwner(player); + world.addFreshEntity(projectile); } if (!player.isCreative()) { itemStack.shrink(1); if (itemStack.isEmpty()) - player.inventory.deleteStack(itemStack); + player.inventory.removeItem(itemStack); } if (!BackTankUtil.canAbsorbDamage(player, maxUses())) - stack.damageItem(1, player, p -> p.sendBreakAnimation(hand)); + stack.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(hand)); Integer cooldown = findAmmoInInventory(world, player, stack).flatMap(PotatoCannonProjectileTypes::getProjectileTypeOf) @@ -199,7 +201,7 @@ public class PotatoCannonItem extends ShootableItem { } private Optional findAmmoInInventory(World world, PlayerEntity player, ItemStack held) { - ItemStack findAmmo = player.findAmmo(held); + ItemStack findAmmo = player.getProjectile(held); return PotatoCannonProjectileTypes.getProjectileTypeOf(findAmmo) .map($ -> findAmmo); } @@ -214,7 +216,7 @@ public class PotatoCannonItem extends ShootableItem { CLIENT_CURRENT_AMMO = ItemStack.EMPTY; if (player == null) return Optional.empty(); - ItemStack findAmmo = player.findAmmo(cannon); + ItemStack findAmmo = player.getProjectile(cannon); Optional found = PotatoCannonProjectileTypes.getProjectileTypeOf(findAmmo) .map($ -> findAmmo); found.ifPresent(stack -> CLIENT_CURRENT_AMMO = stack); @@ -223,9 +225,9 @@ public class PotatoCannonItem extends ShootableItem { @Override @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { - int power = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack); - int punch = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); + public void appendHoverText(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { + int power = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, stack); + int punch = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.PUNCH_ARROWS, stack); final float additionalDamage = power * 2; final float additionalKnockback = punch * .5f; @@ -235,8 +237,8 @@ public class PotatoCannonItem extends ShootableItem { String _knockback = "potato_cannon.ammo.knockback"; tooltip.add(new StringTextComponent("")); - tooltip.add(new TranslationTextComponent(ammo.getTranslationKey()).append(new StringTextComponent(":")) - .formatted(TextFormatting.GRAY)); + tooltip.add(new TranslationTextComponent(ammo.getDescriptionId()).append(new StringTextComponent(":")) + .withStyle(TextFormatting.GRAY)); PotatoCannonProjectileTypes type = PotatoCannonProjectileTypes.getProjectileTypeOf(ammo) .get(); StringTextComponent spacing = new StringTextComponent(" "); @@ -250,31 +252,31 @@ public class PotatoCannonItem extends ShootableItem { IFormattableTextComponent knockback = new StringTextComponent("" + (type.getKnockback() + additionalKnockback)); - damage = damage.formatted(additionalDamage > 0 ? green : darkGreen); - knockback = knockback.formatted(additionalKnockback > 0 ? green : darkGreen); - reloadTicks = reloadTicks.formatted(darkGreen); + damage = damage.withStyle(additionalDamage > 0 ? green : darkGreen); + knockback = knockback.withStyle(additionalKnockback > 0 ? green : darkGreen); + reloadTicks = reloadTicks.withStyle(darkGreen); - tooltip.add(spacing.copy() + tooltip.add(spacing.plainCopy() .append(Lang.translate(_attack, damage) - .formatted(darkGreen))); - tooltip.add(spacing.copy() + .withStyle(darkGreen))); + tooltip.add(spacing.plainCopy() .append(Lang.translate(_reload, reloadTicks) - .formatted(darkGreen))); - tooltip.add(spacing.copy() + .withStyle(darkGreen))); + tooltip.add(spacing.plainCopy() .append(Lang.translate(_knockback, knockback) - .formatted(darkGreen))); + .withStyle(darkGreen))); }); - super.addInformation(stack, world, tooltip, flag); + super.appendHoverText(stack, world, tooltip, flag); } @Override - public Predicate getInventoryAmmoPredicate() { + public Predicate getAllSupportedProjectiles() { return stack -> PotatoCannonProjectileTypes.getProjectileTypeOf(stack) .isPresent(); } @Override - public int getItemEnchantability() { + public int getEnchantmentValue() { return 1; } @@ -284,12 +286,12 @@ public class PotatoCannonItem extends ShootableItem { } @Override - public UseAction getUseAction(ItemStack stack) { + public UseAction getUseAnimation(ItemStack stack) { return UseAction.NONE; } @Override - public int getRange() { + public int getDefaultProjectileRange() { return 15; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItemRenderer.java index 35ad66a50..520c2911e 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItemRenderer.java @@ -27,9 +27,9 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer { Entity entity = ray.getEntity(); - World world = entity.world; + World world = entity.level; if (!(entity instanceof ZombieVillagerEntity) - || !((ZombieVillagerEntity) entity).isPotionActive(Effects.WEAKNESS)) + || !((ZombieVillagerEntity) entity).hasEffect(Effects.WEAKNESS)) return foodEffects(Foods.GOLDEN_APPLE, false).test(ray); - if (world.isRemote) + if (world.isClientSide) return false; FakePlayer dummy = ZOMBIE_CONVERTERS.get(world); - dummy.setHeldItem(Hand.MAIN_HAND, new ItemStack(Items.GOLDEN_APPLE, 1)); - ((ZombieVillagerEntity) entity).interactMob(dummy, Hand.MAIN_HAND); + dummy.setItemInHand(Hand.MAIN_HAND, new ItemStack(Items.GOLDEN_APPLE, 1)); + ((ZombieVillagerEntity) entity).mobInteract(dummy, Hand.MAIN_HAND); return true; }) .registerAndAssign(Items.GOLDEN_APPLE), @@ -331,7 +331,7 @@ public class PotatoCannonProjectileTypes { private static Predicate setFire(int seconds) { return ray -> { - ray.getEntity().setFire(seconds); + ray.getEntity().setSecondsOnFire(seconds); return false; }; } @@ -339,7 +339,7 @@ public class PotatoCannonProjectileTypes { private static Predicate potion(Effect effect, int level, int ticks, boolean recoverable) { return ray -> { Entity entity = ray.getEntity(); - if (entity.world.isRemote) + if (entity.level.isClientSide) return true; if (entity instanceof LivingEntity) applyEffect((LivingEntity) entity, new EffectInstance(effect, ticks, level - 1)); @@ -350,7 +350,7 @@ public class PotatoCannonProjectileTypes { private static Predicate foodEffects(Food food, boolean recoverable) { return ray -> { Entity entity = ray.getEntity(); - if (entity.world.isRemote) + if (entity.level.isClientSide) return true; if (entity instanceof LivingEntity) { @@ -364,22 +364,22 @@ public class PotatoCannonProjectileTypes { } public static void applyEffect(LivingEntity entity, EffectInstance effect) { - if (effect.getPotion().isInstant()) - effect.getPotion().affectEntity(null, null, entity, effect.getDuration(), 1.0); + if (effect.getEffect().isInstantenous()) + effect.getEffect().applyInstantenousEffect(null, null, entity, effect.getDuration(), 1.0); else - entity.addPotionEffect(effect); + entity.addEffect(effect); } private static BiPredicate plantCrop(IRegistryDelegate cropBlock) { return (world, ray) -> { - if (world.isRemote()) + if (world.isClientSide()) return true; - BlockPos hitPos = ray.getPos(); + BlockPos hitPos = ray.getBlockPos(); if (!world.isAreaLoaded(hitPos, 1)) return true; - Direction face = ray.getFace(); - BlockPos placePos = hitPos.offset(face); + Direction face = ray.getDirection(); + BlockPos placePos = hitPos.relative(face); if (!world.getBlockState(placePos) .getMaterial() .isReplaceable()) @@ -389,39 +389,39 @@ public class PotatoCannonProjectileTypes { BlockState blockState = world.getBlockState(hitPos); if (!blockState.canSustainPlant(world, hitPos, face, (IPlantable) cropBlock.get())) return false; - world.setBlockState(placePos, cropBlock.get().getDefaultState(), 3); + world.setBlock(placePos, cropBlock.get().defaultBlockState(), 3); return true; }; } private static BiPredicate placeBlockOnGround(IRegistryDelegate block) { return (world, ray) -> { - if (world.isRemote()) + if (world.isClientSide()) return true; - BlockPos hitPos = ray.getPos(); + BlockPos hitPos = ray.getBlockPos(); if (!world.isAreaLoaded(hitPos, 1)) return true; - Direction face = ray.getFace(); - BlockPos placePos = hitPos.offset(face); + Direction face = ray.getDirection(); + BlockPos placePos = hitPos.relative(face); if (!world.getBlockState(placePos) .getMaterial() .isReplaceable()) return false; if (face == Direction.UP) { - world.setBlockState(placePos, block.get().getDefaultState(), 3); + world.setBlock(placePos, block.get().defaultBlockState(), 3); } else if (world instanceof World) { - double y = ray.getHitVec().y - 0.5; - if (!world.isAirBlock(placePos.up())) + double y = ray.getLocation().y - 0.5; + if (!world.isEmptyBlock(placePos.above())) y = Math.min(y, placePos.getY()); - if (!world.isAirBlock(placePos.down())) + if (!world.isEmptyBlock(placePos.below())) y = Math.max(y, placePos.getY()); FallingBlockEntity falling = new FallingBlockEntity((World) world, placePos.getX() + 0.5, y, - placePos.getZ() + 0.5, block.get().getDefaultState()); - falling.fallTime = 1; - world.addEntity(falling); + placePos.getZ() + 0.5, block.get().defaultBlockState()); + falling.time = 1; + world.addFreshEntity(falling); } return true; @@ -431,8 +431,8 @@ public class PotatoCannonProjectileTypes { private static Predicate chorusTeleport(double teleportDiameter) { return ray -> { Entity entity = ray.getEntity(); - World world = entity.getEntityWorld(); - if (world.isRemote) + World world = entity.getCommandSenderWorld(); + if (world.isClientSide) return true; if (!(entity instanceof LivingEntity)) return false; @@ -443,9 +443,9 @@ public class PotatoCannonProjectileTypes { double entityZ = livingEntity.getZ(); for (int teleportTry = 0; teleportTry < 16; ++teleportTry) { - double teleportX = entityX + (livingEntity.getRNG().nextDouble() - 0.5D) * teleportDiameter; - double teleportY = MathHelper.clamp(entityY + (livingEntity.getRNG().nextInt((int) teleportDiameter) - (int) (teleportDiameter / 2)), 0.0D, world.getDimensionHeight() - 1); - double teleportZ = entityZ + (livingEntity.getRNG().nextDouble() - 0.5D) * teleportDiameter; + double teleportX = entityX + (livingEntity.getRandom().nextDouble() - 0.5D) * teleportDiameter; + double teleportY = MathHelper.clamp(entityY + (livingEntity.getRandom().nextInt((int) teleportDiameter) - (int) (teleportDiameter / 2)), 0.0D, world.getHeight() - 1); + double teleportZ = entityZ + (livingEntity.getRandom().nextDouble() - 0.5D) * teleportDiameter; /* Usable as soon as lowest supported forge > 36.1.3 */ @@ -454,14 +454,14 @@ public class PotatoCannonProjectileTypes { // return; // if (livingEntity.attemptTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { - if (livingEntity.attemptTeleport(teleportX, teleportY, teleportZ, true)) { + if (livingEntity.randomTeleport(teleportX, teleportY, teleportZ, true)) { if (livingEntity.isPassenger()) livingEntity.stopRiding(); - SoundEvent soundevent = livingEntity instanceof FoxEntity ? SoundEvents.ENTITY_FOX_TELEPORT : SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT; + SoundEvent soundevent = livingEntity instanceof FoxEntity ? SoundEvents.FOX_TELEPORT : SoundEvents.CHORUS_FRUIT_TELEPORT; world.playSound(null, entityX, entityY, entityZ, soundevent, SoundCategory.PLAYERS, 1.0F, 1.0F); livingEntity.playSound(soundevent, 1.0F, 1.0F); - livingEntity.setMotion(Vector3d.ZERO); + livingEntity.setDeltaMovement(Vector3d.ZERO); return true; } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonRenderHandler.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonRenderHandler.java index 0cdf10d4a..3f5affbb6 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonRenderHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonRenderHandler.java @@ -22,7 +22,7 @@ public class PotatoCannonRenderHandler extends ShootableGadgetRenderHandler { @Override protected void playSound(Hand hand, Vector3d position) { - PotatoProjectileEntity.playLaunchSound(Minecraft.getInstance().world, position, nextPitch); + PotatoProjectileEntity.playLaunchSound(Minecraft.getInstance().level, position, nextPitch); } @Override @@ -35,7 +35,7 @@ public class PotatoCannonRenderHandler extends ShootableGadgetRenderHandler { this.nextPitch = nextPitch; if (stack.isEmpty()) return; - ClientWorld world = Minecraft.getInstance().world; + ClientWorld world = Minecraft.getInstance().level; for (int i = 0; i < 2; i++) { Vector3d m = VecHelper.offsetRandomly(motion.scale(0.1f), Create.RANDOM, .025f); world.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), location.x, location.y, location.z, m.x, diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileEntity.java index a9faeca72..7de9a3a00 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileEntity.java @@ -72,37 +72,37 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements } public void setEnchantmentEffectsFromCannon(ItemStack cannon) { - int power = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, cannon); - int punch = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, cannon); - int flame = EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, cannon); - int recovery = EnchantmentHelper.getEnchantmentLevel(AllEnchantments.POTATO_RECOVERY.get(), cannon); + int power = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, cannon); + int punch = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.PUNCH_ARROWS, cannon); + int flame = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.FLAMING_ARROWS, cannon); + int recovery = EnchantmentHelper.getItemEnchantmentLevel(AllEnchantments.POTATO_RECOVERY.get(), cannon); if (power > 0) additionalDamageMult = 1 + power * .2f; if (punch > 0) additionalKnockback = punch * .5f; if (flame > 0) - setFire(100); + setSecondsOnFire(100); if (recovery > 0) recoveryChance = .125f + recovery * .125f; } @Override - public void readAdditional(CompoundNBT nbt) { - stack = ItemStack.read(nbt.getCompound("Item")); + public void readAdditionalSaveData(CompoundNBT nbt) { + stack = ItemStack.of(nbt.getCompound("Item")); additionalDamageMult = nbt.getFloat("AdditionalDamage"); additionalKnockback = nbt.getFloat("AdditionalKnockback"); recoveryChance = nbt.getFloat("Recovery"); - super.readAdditional(nbt); + super.readAdditionalSaveData(nbt); } @Override - public void writeAdditional(CompoundNBT nbt) { + public void addAdditionalSaveData(CompoundNBT nbt) { nbt.put("Item", stack.serializeNBT()); nbt.putFloat("AdditionalDamage", additionalDamageMult); nbt.putFloat("AdditionalKnockback", additionalKnockback); nbt.putFloat("Recovery", recoveryChance); - super.writeAdditional(nbt); + super.addAdditionalSaveData(nbt); } public Entity getStuckEntity() { @@ -115,10 +115,10 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements public void setStuckEntity(Entity stuckEntity) { this.stuckEntity = stuckEntity; - this.stuckOffset = getPositionVec().subtract(stuckEntity.getPositionVec()); + this.stuckOffset = position().subtract(stuckEntity.position()); this.stuckRenderer = new PotatoProjectileRenderMode.StuckToEntity(stuckOffset); this.stuckFallSpeed = 0.0; - setMotion(Vector3d.ZERO); + setDeltaMovement(Vector3d.ZERO); } public PotatoProjectileRenderMode getRenderMode() { @@ -134,17 +134,17 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements Entity stuckEntity = getStuckEntity(); if (stuckEntity != null) { if (getY() < stuckEntity.getY() - 0.1) { - pop(getPositionVec()); + pop(position()); remove(); } else { stuckFallSpeed += 0.007 * projectileType.getGravityMultiplier(); stuckOffset = stuckOffset.add(0, -stuckFallSpeed, 0); - Vector3d pos = stuckEntity.getPositionVec() + Vector3d pos = stuckEntity.position() .add(stuckOffset); - setPosition(pos.x, pos.y, pos.z); + setPos(pos.x, pos.y, pos.z); } } else { - setMotion(getMotion().add(0, -0.05 * projectileType.getGravityMultiplier(), 0) + setDeltaMovement(getDeltaMovement().add(0, -0.05 * projectileType.getGravityMultiplier(), 0) .scale(projectileType.getDrag())); } @@ -152,28 +152,28 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements } @Override - protected float getMotionFactor() { + protected float getInertia() { return 1; } @Override - protected IParticleData getParticle() { + protected IParticleData getTrailParticle() { return new AirParticleData(1, 10); } @Override - protected boolean isFireballFiery() { + protected boolean shouldBurn() { return false; } @Override - protected void onEntityHit(EntityRayTraceResult ray) { - super.onEntityHit(ray); + protected void onHitEntity(EntityRayTraceResult ray) { + super.onHitEntity(ray); if (getStuckEntity() != null) return; - Vector3d hit = ray.getHitVec(); + Vector3d hit = ray.getLocation(); Entity target = ray.getEntity(); PotatoCannonProjectileTypes projectileType = getProjectileType(); float damage = MathHelper.floor(projectileType.getDamage() * additionalDamageMult); @@ -183,23 +183,23 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements if (!target.isAlive()) return; if (owner instanceof LivingEntity) - ((LivingEntity) owner).setLastAttackedEntity(target); - if (target instanceof PotatoProjectileEntity && ticksExisted < 10 && target.ticksExisted < 10) + ((LivingEntity) owner).setLastHurtMob(target); + if (target instanceof PotatoProjectileEntity && tickCount < 10 && target.tickCount < 10) return; pop(hit); - if (target instanceof WitherEntity && ((WitherEntity) target).shouldRenderOverlay()) + if (target instanceof WitherEntity && ((WitherEntity) target).isPowered()) return; boolean targetIsEnderman = target.getType() == EntityType.ENDERMAN; - int k = target.getFireTimer(); - if (this.isBurning() && !targetIsEnderman) - target.setFire(5); + int k = target.getRemainingFireTicks(); + if (this.isOnFire() && !targetIsEnderman) + target.setSecondsOnFire(5); - boolean onServer = !world.isRemote; - if (onServer && !target.attackEntityFrom(causePotatoDamage(), damage)) { - target.setFireTicks(k); + boolean onServer = !level.isClientSide; + if (onServer && !target.hurt(causePotatoDamage(), damage)) { + target.setRemainingFireTicks(k); remove(); return; } @@ -208,11 +208,11 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements return; if (!projectileType.onEntityHit(ray) && onServer) - if (rand.nextDouble() <= recoveryChance) + if (random.nextDouble() <= recoveryChance) recoverItem(); if (!(target instanceof LivingEntity)) { - playHitSound(world, getPositionVec()); + playHitSound(level, position()); remove(); return; } @@ -220,32 +220,32 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements LivingEntity livingentity = (LivingEntity) target; if (type.getReloadTicks() < 10) - livingentity.hurtResistantTime = type.getReloadTicks() + 10; + livingentity.invulnerableTime = type.getReloadTicks() + 10; if (knockback > 0) { - Vector3d appliedMotion = this.getMotion() - .mul(1.0D, 0.0D, 1.0D) + Vector3d appliedMotion = this.getDeltaMovement() + .multiply(1.0D, 0.0D, 1.0D) .normalize() .scale(knockback * 0.6); - if (appliedMotion.lengthSquared() > 0.0D) - livingentity.addVelocity(appliedMotion.x, 0.1D, appliedMotion.z); + if (appliedMotion.lengthSqr() > 0.0D) + livingentity.push(appliedMotion.x, 0.1D, appliedMotion.z); } if (onServer && owner instanceof LivingEntity) { - EnchantmentHelper.applyThornEnchantments(livingentity, owner); - EnchantmentHelper.applyArthropodEnchantments((LivingEntity) owner, livingentity); + EnchantmentHelper.doPostHurtEffects(livingentity, owner); + EnchantmentHelper.doPostDamageEffects((LivingEntity) owner, livingentity); } if (livingentity != owner && livingentity instanceof PlayerEntity && owner instanceof ServerPlayerEntity && !this.isSilent()) { ((ServerPlayerEntity) owner).connection - .sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.PROJECTILE_HIT_PLAYER, 0.0F)); + .send(new SChangeGameStatePacket(SChangeGameStatePacket.ARROW_HIT_PLAYER, 0.0F)); } if (onServer && owner instanceof ServerPlayerEntity) { ServerPlayerEntity serverplayerentity = (ServerPlayerEntity) owner; if (!target.isAlive() && target.getType() - .getClassification() == EntityClassification.MONSTER + .getCategory() == EntityClassification.MONSTER || (target instanceof PlayerEntity && target != owner)) AllTriggers.POTATO_KILL.trigger(serverplayerentity); } @@ -260,7 +260,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements private void recoverItem() { if (!stack.isEmpty()) - entityDropItem(ItemHandlerHelper.copyStackWithSize(stack, 1)); + spawnAtLocation(ItemHandlerHelper.copyStackWithSize(stack, 1)); } public static void playHitSound(World world, Vector3d location) { @@ -272,23 +272,23 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements } @Override - protected void onBlockHit(BlockRayTraceResult ray) { - Vector3d hit = ray.getHitVec(); + protected void onHitBlock(BlockRayTraceResult ray) { + Vector3d hit = ray.getLocation(); pop(hit); - if (!getProjectileType().onBlockHit(world, ray) && !world.isRemote) - if (rand.nextDouble() <= recoveryChance) + if (!getProjectileType().onBlockHit(level, ray) && !level.isClientSide) + if (random.nextDouble() <= recoveryChance) recoverItem(); - super.onBlockHit(ray); + super.onHitBlock(ray); remove(); } @Override - public boolean attackEntityFrom(DamageSource source, float amt) { + public boolean hurt(DamageSource source, float amt) { if (source == DamageSource.IN_FIRE || source == DamageSource.ON_FIRE) return false; if (this.isInvulnerableTo(source)) return false; - pop(getPositionVec()); + pop(position()); remove(); return true; } @@ -296,12 +296,12 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements private void pop(Vector3d hit) { if (!stack.isEmpty()) { for (int i = 0; i < 7; i++) { - Vector3d m = VecHelper.offsetRandomly(Vector3d.ZERO, this.rand, .25f); - world.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), hit.x, hit.y, hit.z, m.x, m.y, m.z); + Vector3d m = VecHelper.offsetRandomly(Vector3d.ZERO, this.random, .25f); + level.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), hit.x, hit.y, hit.z, m.x, m.y, m.z); } } - if (!world.isRemote) - playHitSound(world, getPositionVec()); + if (!level.isClientSide) + playHitSound(level, position()); } private DamageSource causePotatoDamage() { @@ -319,24 +319,24 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements @SuppressWarnings("unchecked") public static EntityType.Builder build(EntityType.Builder builder) { EntityType.Builder entityBuilder = (EntityType.Builder) builder; - return entityBuilder.size(.25f, .25f); + return entityBuilder.sized(.25f, .25f); } @Override - public IPacket createSpawnPacket() { + public IPacket getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override public void writeSpawnData(PacketBuffer buffer) { CompoundNBT compound = new CompoundNBT(); - writeAdditional(compound); - buffer.writeCompoundTag(compound); + addAdditionalSaveData(compound); + buffer.writeNbt(compound); } @Override public void readSpawnData(PacketBuffer additionalData) { - readAdditional(additionalData.readCompoundTag()); + readAdditionalSaveData(additionalData.readNbt()); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderMode.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderMode.java index 56c23cc01..40888f2d1 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderMode.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderMode.java @@ -22,7 +22,7 @@ public abstract class PotatoProjectileRenderMode { @OnlyIn(Dist.CLIENT) public void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt) { Minecraft mc = Minecraft.getInstance(); - Vector3d p1 = mc.getRenderViewEntity() + Vector3d p1 = mc.getCameraEntity() .getEyePosition(pt); Vector3d diff = entity.getBoundingBox() .getCenter() @@ -42,8 +42,8 @@ public abstract class PotatoProjectileRenderMode { public void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt) { super.transform(ms, entity, pt); MatrixStacker.of(ms) - .rotateZ((entity.ticksExisted + pt) * 2 * entityRandom(entity, 16)) - .rotateX((entity.ticksExisted + pt) * entityRandom(entity, 32)); + .rotateZ((entity.tickCount + pt) * 2 * entityRandom(entity, 16)) + .rotateX((entity.tickCount + pt) * entityRandom(entity, 32)); } } @@ -60,13 +60,13 @@ public abstract class PotatoProjectileRenderMode { @Override @OnlyIn(Dist.CLIENT) public void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt) { - Vector3d diff = entity.getMotion(); + Vector3d diff = entity.getDeltaMovement(); MatrixStacker.of(ms) .rotateY(AngleHelper.deg(MathHelper.atan2(diff.x, diff.z))) .rotateX(270 + AngleHelper.deg(MathHelper.atan2(diff.y, -MathHelper.sqrt(diff.x * diff.x + diff.z * diff.z)))); MatrixStacker.of(ms) - .rotateY((entity.ticksExisted + pt) * 20 * spin + entityRandom(entity, 360)) + .rotateY((entity.tickCount + pt) * 20 * spin + entityRandom(entity, 360)) .rotateZ(-spriteAngleOffset); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderer.java index 01d2ee95b..48138d20b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileRenderer.java @@ -23,20 +23,20 @@ public class PotatoProjectileRenderer extends EntityRenderer createSpawnPacket() { + public IPacket getAddEntityPacket() { // TODO Auto-generated method stub return null; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootGadgetPacket.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootGadgetPacket.java index 12a204775..8226cc221 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootGadgetPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootGadgetPacket.java @@ -57,10 +57,10 @@ public abstract class ShootGadgetPacket extends SimplePacketBase { context.get() .enqueueWork(() -> { Entity renderViewEntity = Minecraft.getInstance() - .getRenderViewEntity(); + .getCameraEntity(); if (renderViewEntity == null) return; - if (renderViewEntity.getPositionVec() + if (renderViewEntity.position() .distanceTo(location) > 100) return; diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootableGadgetItemMethods.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootableGadgetItemMethods.java index cefdd485f..a403f6ef0 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootableGadgetItemMethods.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootableGadgetItemMethods.java @@ -18,9 +18,9 @@ public class ShootableGadgetItemMethods { public static void applyCooldown(PlayerEntity player, ItemStack item, Hand hand, Predicate predicate, int cooldown) { boolean gunInOtherHand = - predicate.test(player.getHeldItem(hand == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND)); - player.getCooldownTracker() - .setCooldown(item.getItem(), gunInOtherHand ? cooldown * 2 / 3 : cooldown); + predicate.test(player.getItemInHand(hand == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND)); + player.getCooldowns() + .addCooldown(item.getItem(), gunInOtherHand ? cooldown * 2 / 3 : cooldown); } public static void sendPackets(PlayerEntity player, Function factory) { @@ -34,7 +34,7 @@ public class ShootableGadgetItemMethods { boolean isSwap = item.getTag() .contains("_Swap"); boolean mainHand = hand == Hand.MAIN_HAND; - boolean gunInOtherHand = predicate.test(player.getHeldItem(mainHand ? Hand.OFF_HAND : Hand.MAIN_HAND)); + boolean gunInOtherHand = predicate.test(player.getItemInHand(mainHand ? Hand.OFF_HAND : Hand.MAIN_HAND)); // Pass To Offhand if (mainHand && isSwap && gunInOtherHand) @@ -46,22 +46,22 @@ public class ShootableGadgetItemMethods { item.getTag() .remove("_Swap"); if (!mainHand && gunInOtherHand) - player.getHeldItem(Hand.MAIN_HAND) + player.getItemInHand(Hand.MAIN_HAND) .getTag() .remove("_Swap"); - player.setActiveHand(hand); + player.startUsingItem(hand); return false; } public static Vector3d getGunBarrelVec(PlayerEntity player, boolean mainHand, Vector3d rightHandForward) { - Vector3d start = player.getPositionVec() + Vector3d start = player.position() .add(0, player.getEyeHeight(), 0); - float yaw = (float) ((player.rotationYaw) / -180 * Math.PI); - float pitch = (float) ((player.rotationPitch) / -180 * Math.PI); - int flip = mainHand == (player.getPrimaryHand() == HandSide.RIGHT) ? -1 : 1; + float yaw = (float) ((player.yRot) / -180 * Math.PI); + float pitch = (float) ((player.xRot) / -180 * Math.PI); + int flip = mainHand == (player.getMainArm() == HandSide.RIGHT) ? -1 : 1; Vector3d barrelPosNoTransform = new Vector3d(flip * rightHandForward.x, rightHandForward.y, rightHandForward.z); - Vector3d barrelPos = start.add(barrelPosNoTransform.rotatePitch(pitch) - .rotateYaw(yaw)); + Vector3d barrelPos = start.add(barrelPosNoTransform.xRot(pitch) + .yRot(yaw)); return barrelPos; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootableGadgetRenderHandler.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootableGadgetRenderHandler.java index 11b7c2b5e..ae67e4cfd 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootableGadgetRenderHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ShootableGadgetRenderHandler.java @@ -46,7 +46,7 @@ public abstract class ShootableGadgetRenderHandler { public void shoot(Hand hand, Vector3d location) { ClientPlayerEntity player = Minecraft.getInstance().player; - boolean rightHand = hand == Hand.MAIN_HAND ^ player.getPrimaryHand() == HandSide.LEFT; + boolean rightHand = hand == Hand.MAIN_HAND ^ player.getMainArm() == HandSide.LEFT; if (rightHand) { rightHandAnimation = .2f; dontReequipRight = false; @@ -77,16 +77,16 @@ public abstract class ShootableGadgetRenderHandler { Minecraft mc = Minecraft.getInstance(); AbstractClientPlayerEntity player = mc.player; TextureManager textureManager = mc.getTextureManager(); - PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager() + PlayerRenderer playerrenderer = (PlayerRenderer) mc.getEntityRenderDispatcher() .getRenderer(player); - FirstPersonRenderer firstPersonRenderer = mc.getFirstPersonRenderer(); + FirstPersonRenderer firstPersonRenderer = mc.getItemInHandRenderer(); MatrixStack ms = event.getMatrixStack(); IRenderTypeBuffer buffer = event.getBuffers(); int light = event.getLight(); float pt = event.getPartialTicks(); - boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ mc.player.getPrimaryHand() == HandSide.LEFT; + boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ mc.player.getMainArm() == HandSide.LEFT; float recoil = rightHand ? MathHelper.lerp(pt, lastRightHandAnimation, rightHandAnimation) : MathHelper.lerp(pt, lastLeftHandAnimation, leftHandAnimation); float equipProgress = event.getEquipProgress(); @@ -97,8 +97,8 @@ public abstract class ShootableGadgetRenderHandler { equipProgress = 0; // Render arm - ms.push(); - textureManager.bindTexture(player.getLocationSkin()); + ms.pushPose(); + textureManager.bind(player.getSkinTextureLocation()); float flip = rightHand ? 1.0F : -1.0F; float f1 = MathHelper.sqrt(event.getSwingProgress()); @@ -109,40 +109,40 @@ public abstract class ShootableGadgetRenderHandler { float f6 = MathHelper.sin(f1 * (float) Math.PI); ms.translate(flip * (f2 + 0.64F - .1f), f3 + -0.4F + equipProgress * -0.6F, f4 + -0.72F + .3f + recoil); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(flip * 75.0F)); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(flip * f6 * 70.0F)); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(flip * f5 * -20.0F)); + ms.mulPose(Vector3f.YP.rotationDegrees(flip * 75.0F)); + ms.mulPose(Vector3f.YP.rotationDegrees(flip * f6 * 70.0F)); + ms.mulPose(Vector3f.ZP.rotationDegrees(flip * f5 * -20.0F)); ms.translate(flip * -1.0F, 3.6F, 3.5F); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(flip * 120.0F)); - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(200.0F)); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(flip * -135.0F)); + ms.mulPose(Vector3f.ZP.rotationDegrees(flip * 120.0F)); + ms.mulPose(Vector3f.XP.rotationDegrees(200.0F)); + ms.mulPose(Vector3f.YP.rotationDegrees(flip * -135.0F)); ms.translate(flip * 5.6F, 0.0F, 0.0F); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(flip * 40.0F)); + ms.mulPose(Vector3f.YP.rotationDegrees(flip * 40.0F)); transformHand(ms, flip, equipProgress, recoil, pt); if (rightHand) - playerrenderer.renderRightArm(ms, buffer, light, player); + playerrenderer.renderRightHand(ms, buffer, light, player); else - playerrenderer.renderLeftArm(ms, buffer, light, player); - ms.pop(); + playerrenderer.renderLeftHand(ms, buffer, light, player); + ms.popPose(); // Render gadget - ms.push(); + ms.pushPose(); ms.translate(flip * (f2 + 0.64F - .1f), f3 + -0.4F + equipProgress * -0.6F, f4 + -0.72F - 0.1f + recoil); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(flip * f6 * 70.0F)); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(flip * f5 * -20.0F)); + ms.mulPose(Vector3f.YP.rotationDegrees(flip * f6 * 70.0F)); + ms.mulPose(Vector3f.ZP.rotationDegrees(flip * f5 * -20.0F)); transformTool(ms, flip, equipProgress, recoil, pt); firstPersonRenderer.renderItem(mc.player, heldItem, rightHand ? ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND : ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !rightHand, ms, buffer, light); - ms.pop(); + ms.popPose(); event.setCanceled(true); } public void dontAnimateItem(Hand hand) { ClientPlayerEntity player = Minecraft.getInstance().player; - boolean rightHand = hand == Hand.MAIN_HAND ^ player.getPrimaryHand() == HandSide.LEFT; + boolean rightHand = hand == Hand.MAIN_HAND ^ player.getMainArm() == HandSide.LEFT; dontReequipRight |= rightHand; dontReequipLeft |= !rightHand; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java index c56d86a0e..7a7ba0e59 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java @@ -30,10 +30,10 @@ public class ZapperInteractionHandler { @SubscribeEvent public static void leftClickingBlocksWithTheZapperSelectsTheBlock(PlayerInteractEvent.LeftClickBlock event) { - if (event.getWorld().isRemote) + if (event.getWorld().isClientSide) return; ItemStack heldItem = event.getPlayer() - .getHeldItemMainhand(); + .getMainHandItem(); if (heldItem.getItem() instanceof ZapperItem && trySelect(heldItem, event.getPlayer())) { event.setCancellationResult(ActionResultType.FAIL); event.setCanceled(true); @@ -41,46 +41,46 @@ public class ZapperInteractionHandler { } public static boolean trySelect(ItemStack stack, PlayerEntity player) { - if (player.isSneaking()) + if (player.isShiftKeyDown()) return false; - Vector3d start = player.getPositionVec() + Vector3d start = player.position() .add(0, player.getEyeHeight(), 0); - Vector3d range = player.getLookVec() + Vector3d range = player.getLookAngle() .scale(getRange(stack)); - BlockRayTraceResult raytrace = player.world - .rayTraceBlocks(new RayTraceContext(start, start.add(range), BlockMode.OUTLINE, FluidMode.NONE, player)); - BlockPos pos = raytrace.getPos(); + BlockRayTraceResult raytrace = player.level + .clip(new RayTraceContext(start, start.add(range), BlockMode.OUTLINE, FluidMode.NONE, player)); + BlockPos pos = raytrace.getBlockPos(); if (pos == null) return false; - player.world.sendBlockBreakProgress(player.getEntityId(), pos, -1); - BlockState newState = player.world.getBlockState(pos); + player.level.destroyBlockProgress(player.getId(), pos, -1); + BlockState newState = player.level.getBlockState(pos); if (BlockHelper.getRequiredItem(newState) .isEmpty()) return false; if (newState.hasTileEntity() && !AllBlockTags.SAFE_NBT.matches(newState)) return false; - if (newState.contains(BlockStateProperties.DOUBLE_BLOCK_HALF)) + if (newState.hasProperty(BlockStateProperties.DOUBLE_BLOCK_HALF)) return false; - if (newState.contains(BlockStateProperties.ATTACHED)) + if (newState.hasProperty(BlockStateProperties.ATTACHED)) return false; - if (newState.contains(BlockStateProperties.HANGING)) + if (newState.hasProperty(BlockStateProperties.HANGING)) return false; - if (newState.contains(BlockStateProperties.BED_PART)) + if (newState.hasProperty(BlockStateProperties.BED_PART)) return false; - if (newState.contains(BlockStateProperties.STAIRS_SHAPE)) - newState = newState.with(BlockStateProperties.STAIRS_SHAPE, StairsShape.STRAIGHT); - if (newState.contains(BlockStateProperties.PERSISTENT)) - newState = newState.with(BlockStateProperties.PERSISTENT, true); - if (newState.contains(BlockStateProperties.WATERLOGGED)) - newState = newState.with(BlockStateProperties.WATERLOGGED, false); + if (newState.hasProperty(BlockStateProperties.STAIRS_SHAPE)) + newState = newState.setValue(BlockStateProperties.STAIRS_SHAPE, StairsShape.STRAIGHT); + if (newState.hasProperty(BlockStateProperties.PERSISTENT)) + newState = newState.setValue(BlockStateProperties.PERSISTENT, true); + if (newState.hasProperty(BlockStateProperties.WATERLOGGED)) + newState = newState.setValue(BlockStateProperties.WATERLOGGED, false); CompoundNBT data = null; - TileEntity tile = player.world.getTileEntity(pos); + TileEntity tile = player.level.getBlockEntity(pos); if (tile != null) { - data = tile.write(new CompoundNBT()); + data = tile.save(new CompoundNBT()); data.remove("x"); data.remove("y"); data.remove("z"); @@ -98,7 +98,7 @@ public class ZapperInteractionHandler { else tag.put("BlockData", data); - AllSoundEvents.CONFIRM.playOnServer(player.world, player.getBlockPos()); + AllSoundEvents.CONFIRM.playOnServer(player.level, player.blockPosition()); return true; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java index 3d2f209e4..54f954931 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java @@ -42,25 +42,27 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fml.DistExecutor; +import net.minecraft.item.Item.Properties; + public abstract class ZapperItem extends Item { public ZapperItem(Properties properties) { - super(properties.maxStackSize(1)); + super(properties.stacksTo(1)); } @Override @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + public void appendHoverText(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { if (stack.hasTag() && stack.getTag() .contains("BlockUsed")) { String usedblock = NBTUtil.readBlockState(stack.getTag() .getCompound("BlockUsed")) .getBlock() - .getTranslationKey(); + .getDescriptionId(); ItemDescription.add(tooltip, Lang.translate("terrainzapper.usingBlock", - new TranslationTextComponent(usedblock).formatted(TextFormatting.GRAY)) - .formatted(TextFormatting.DARK_GRAY)); + new TranslationTextComponent(usedblock).withStyle(TextFormatting.GRAY)) + .withStyle(TextFormatting.DARK_GRAY)); } } @@ -84,38 +86,38 @@ public abstract class ZapperItem extends Item { @Nonnull @Override - public ActionResultType onItemUse(ItemUseContext context) { + public ActionResultType useOn(ItemUseContext context) { // Shift -> open GUI if (context.getPlayer() != null && context.getPlayer() - .isSneaking()) { - if (context.getWorld().isRemote) { + .isShiftKeyDown()) { + if (context.getLevel().isClientSide) { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { - openHandgunGUI(context.getItem(), context.getHand() == Hand.OFF_HAND); + openHandgunGUI(context.getItemInHand(), context.getHand() == Hand.OFF_HAND); }); context.getPlayer() - .getCooldownTracker() - .setCooldown(context.getItem() + .getCooldowns() + .addCooldown(context.getItemInHand() .getItem(), 10); } return ActionResultType.SUCCESS; } - return super.onItemUse(context); + return super.useOn(context); } @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { - ItemStack item = player.getHeldItem(hand); + public ActionResult use(World world, PlayerEntity player, Hand hand) { + ItemStack item = player.getItemInHand(hand); CompoundNBT nbt = item.getOrCreateTag(); boolean mainHand = hand == Hand.MAIN_HAND; // Shift -> Open GUI - if (player.isSneaking()) { - if (world.isRemote) { + if (player.isShiftKeyDown()) { + if (world.isClientSide) { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { openHandgunGUI(item, hand == Hand.OFF_HAND); }); - player.getCooldownTracker() - .setCooldown(item.getItem(), 10); + player.getCooldowns() + .addCooldown(item.getItem(), 10); } return new ActionResult<>(ActionResultType.SUCCESS, item); } @@ -126,13 +128,13 @@ public abstract class ZapperItem extends Item { // Check if can be used ITextComponent msg = validateUsage(item); if (msg != null) { - AllSoundEvents.DENY.play(world, player, player.getBlockPos()); - player.sendStatusMessage(msg.copy() - .formatted(TextFormatting.RED), true); + AllSoundEvents.DENY.play(world, player, player.blockPosition()); + player.displayClientMessage(msg.plainCopy() + .withStyle(TextFormatting.RED), true); return new ActionResult<>(ActionResultType.FAIL, item); } - BlockState stateToUse = Blocks.AIR.getDefaultState(); + BlockState stateToUse = Blocks.AIR.defaultBlockState(); if (nbt.contains("BlockUsed")) stateToUse = NBTUtil.readBlockState(nbt.getCompound("BlockUsed")); stateToUse = BlockHelper.setZeroAge(stateToUse); @@ -142,13 +144,13 @@ public abstract class ZapperItem extends Item { } // Raytrace - Find the target - Vector3d start = player.getPositionVec() + Vector3d start = player.position() .add(0, player.getEyeHeight(), 0); - Vector3d range = player.getLookVec() + Vector3d range = player.getLookAngle() .scale(getZappingRange(item)); BlockRayTraceResult raytrace = world - .rayTraceBlocks(new RayTraceContext(start, start.add(range), BlockMode.OUTLINE, FluidMode.NONE, player)); - BlockPos pos = raytrace.getPos(); + .clip(new RayTraceContext(start, start.add(range), BlockMode.OUTLINE, FluidMode.NONE, player)); + BlockPos pos = raytrace.getBlockPos(); BlockState stateReplaced = world.getBlockState(pos); // No target @@ -161,7 +163,7 @@ public abstract class ZapperItem extends Item { Vector3d barrelPos = ShootableGadgetItemMethods.getGunBarrelVec(player, mainHand, new Vector3d(.35f, -0.1f, 1)); // Client side - if (world.isRemote) { + if (world.isClientSide) { CreateClient.ZAPPER_RENDER_HANDLER.dontAnimateItem(hand); return new ActionResult<>(ActionResultType.SUCCESS, item); } @@ -170,7 +172,7 @@ public abstract class ZapperItem extends Item { if (activate(world, player, item, stateToUse, raytrace, data)) { ShootableGadgetItemMethods.applyCooldown(player, item, hand, this::isZapper, getCooldownDelay(item)); ShootableGadgetItemMethods.sendPackets(player, - b -> new ZapperBeamPacket(barrelPos, raytrace.getHitVec(), hand, b)); + b -> new ZapperBeamPacket(barrelPos, raytrace.getLocation(), hand, b)); } return new ActionResult<>(ActionResultType.SUCCESS, item); @@ -203,18 +205,18 @@ public abstract class ZapperItem extends Item { } @Override - public boolean canPlayerBreakBlockWhileHolding(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { + public boolean canAttackBlock(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { return false; } @Override - public UseAction getUseAction(ItemStack stack) { + public UseAction getUseAnimation(ItemStack stack) { return UseAction.NONE; } public static void setTileData(World world, BlockPos pos, BlockState state, CompoundNBT data, PlayerEntity player) { if (data != null && AllBlockTags.SAFE_NBT.matches(state)) { - TileEntity tile = world.getTileEntity(pos); + TileEntity tile = world.getBlockEntity(pos); if (tile != null) { data = NBTProcessors.process(tile, data, !player.isCreative()); if (data == null) @@ -222,7 +224,7 @@ public abstract class ZapperItem extends Item { data.putInt("x", pos.getX()); data.putInt("y", pos.getY()); data.putInt("z", pos.getZ()); - tile.fromTag(state, data); + tile.load(state, data); } } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItemRenderer.java index 91f05d0b0..4b6aa2dcc 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItemRenderer.java @@ -31,23 +31,23 @@ public abstract class ZapperItemRenderer exte BlockState state = NBTUtil.readBlockState(stack.getTag() .getCompound("BlockUsed")); - ms.push(); + ms.pushPose(); ms.translate(-0.3F, -0.45F, -0.0F); ms.scale(0.25F, 0.25F, 0.25F); IBakedModel modelForState = Minecraft.getInstance() - .getBlockRendererDispatcher() - .getModelForState(state); + .getBlockRenderer() + .getBlockModel(state); if (state.getBlock() instanceof FourWayBlock) modelForState = Minecraft.getInstance() .getItemRenderer() - .getItemModelWithOverrides(new ItemStack(state.getBlock()), Minecraft.getInstance().world, null); + .getModel(new ItemStack(state.getBlock()), Minecraft.getInstance().level, null); Minecraft.getInstance() .getItemRenderer() - .renderItem(new ItemStack(state.getBlock()), TransformType.NONE, false, ms, buffer, light, overlay, + .render(new ItemStack(state.getBlock()), TransformType.NONE, false, ms, buffer, light, overlay, modelForState); - ms.pop(); + ms.popPose(); } protected float getAnimationProgress(float pt, boolean leftHanded, boolean mainHand) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperLog.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperLog.java index 99955c390..6aa5be7bc 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperLog.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperLog.java @@ -35,7 +35,7 @@ public class ZapperLog { activeWorld = world; List blocks = positions.stream().map(pos -> { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); return new BlockInfo(pos, world.getBlockState(pos), tileEntity == null ? null : tileEntity.serializeNBT()); }).collect(Collectors.toList()); diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperRenderHandler.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperRenderHandler.java index 5d370e8de..d04acb1e4 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperRenderHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperRenderHandler.java @@ -50,7 +50,7 @@ public class ZapperRenderHandler extends ShootableGadgetRenderHandler { @Override protected void transformTool(MatrixStack ms, float flip, float equipProgress, float recoil, float pt) { ms.translate(flip * -0.1f, 0.1f, -0.4f); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(flip * 5.0F)); + ms.mulPose(Vector3f.YP.rotationDegrees(flip * 5.0F)); } @Override @@ -60,7 +60,7 @@ public class ZapperRenderHandler extends ShootableGadgetRenderHandler { protected void playSound(Hand hand, Vector3d position) { float pitch = hand == Hand.MAIN_HAND ? 0.1f : 0.9f; Minecraft mc = Minecraft.getInstance(); - AllSoundEvents.WORLDSHAPER_PLACE.play(mc.world, mc.player, position, 0.1f, pitch); + AllSoundEvents.WORLDSHAPER_PLACE.play(mc.level, mc.player, position, 0.1f, pitch); } public void addBeam(LaserBeam beam) { @@ -68,7 +68,7 @@ public class ZapperRenderHandler extends ShootableGadgetRenderHandler { double x = beam.end.x; double y = beam.end.y; double z = beam.end.z; - ClientWorld world = Minecraft.getInstance().world; + ClientWorld world = Minecraft.getInstance().level; Supplier randomSpeed = () -> (r.nextDouble() - .5d) * .2f; Supplier randomOffset = () -> (r.nextDouble() - .5d) * .2f; for (int i = 0; i < 10; i++) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperScreen.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperScreen.java index 58b43fe45..a546067d2 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperScreen.java @@ -97,7 +97,7 @@ public class ZapperScreen extends AbstractSimiScreen { } protected void drawOnBackground(MatrixStack ms, int x, int y) { - textRenderer.draw(ms, title, x + 11, y + 4, 0x54214F); + font.draw(ms, title, x + 11, y + 4, 0x54214F); } @Override @@ -121,7 +121,7 @@ public class ZapperScreen extends AbstractSimiScreen { if (patternButton.isHovered()) { patternButtons.forEach(b -> b.active = true); patternButton.active = false; - patternButton.playDownSound(client.getSoundHandler()); + patternButton.playDownSound(minecraft.getSoundManager()); nbt.putString("Pattern", PlacementPatterns.values()[patternButtons.indexOf(patternButton)].name()); } } @@ -142,13 +142,13 @@ public class ZapperScreen extends AbstractSimiScreen { } protected void renderBlock(MatrixStack ms, int x, int y) { - ms.push(); + ms.pushPose(); ms.translate(x + 32, y + 42, 120); - ms.multiply(new Vector3f(1f, 0, 0).getDegreesQuaternion(-25f)); - ms.multiply(new Vector3f(0, 1f, 0).getDegreesQuaternion(-45f)); + ms.mulPose(new Vector3f(1f, 0, 0).rotationDegrees(-25f)); + ms.mulPose(new Vector3f(0, 1f, 0).rotationDegrees(-45f)); ms.scale(20, 20, 20); - BlockState state = Blocks.AIR.getDefaultState(); + BlockState state = Blocks.AIR.defaultBlockState(); if (zapper.hasTag() && zapper.getTag() .contains("BlockUsed")) state = NBTUtil.readBlockState(zapper.getTag() @@ -156,7 +156,7 @@ public class ZapperScreen extends AbstractSimiScreen { GuiGameElement.of(state) .render(ms); - ms.pop(); + ms.popPose(); } protected void writeAdditionalOptions(CompoundNBT nbt) {} diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/CuboidBrush.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/CuboidBrush.java index af409cc5a..f7c5d7f45 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/CuboidBrush.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/CuboidBrush.java @@ -26,8 +26,8 @@ public class CuboidBrush extends ShapedBrush { if (updateShape) { BlockPos zero = BlockPos.ZERO; positions = BlockPos - .getAllInBox(zero.add((param0 - 1) / -2, (param1 - 1) / -2, (param2 - 1) / -2), - zero.add((param0) / 2, (param1) / 2, (param2) / 2)) + .betweenClosedStream(zero.offset((param0 - 1) / -2, (param1 - 1) / -2, (param2 - 1) / -2), + zero.offset((param0) / 2, (param1) / 2, (param2) / 2)) .map(BlockPos::new) .collect(Collectors.toList()); } @@ -54,8 +54,8 @@ public class CuboidBrush extends ShapedBrush { int y = (param1 + (param1 == 0 ? 0 : offset)) / 2; int z = (param2 + (param2 == 0 ? 0 : offset)) / 2; - return BlockPos.ZERO.offset(face, face.getAxis() - .getCoordinate(x, y, z) * (option == PlacementOptions.Attached ? 1 : -1)); + return BlockPos.ZERO.relative(face, face.getAxis() + .choose(x, y, z) * (option == PlacementOptions.Attached ? 1 : -1)); } @Override diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/CylinderBrush.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/CylinderBrush.java index 0ec8b4f99..9ca87ced9 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/CylinderBrush.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/CylinderBrush.java @@ -30,7 +30,7 @@ public class CylinderBrush extends ShapedBrush { for (int i = 0; i <= MAX_RADIUS; i++) { int radius = i; List positions = - BlockPos.getAllInBox(BlockPos.ZERO.add(-i - 1, 0, -i - 1), BlockPos.ZERO.add(i + 1, 0, i + 1)) + BlockPos.betweenClosedStream(BlockPos.ZERO.offset(-i - 1, 0, -i - 1), BlockPos.ZERO.offset(i + 1, 0, i + 1)) .map(BlockPos::new) .filter(p -> VecHelper.getCenterOf(p) .distanceTo(VecHelper.getCenterOf(BlockPos.ZERO)) < radius + .42f) @@ -40,7 +40,7 @@ public class CylinderBrush extends ShapedBrush { for (int layer = 0; layer < h; layer++) { int yOffset = layer - h / 2; for (BlockPos p : positions) - stackedPositions.add(p.up(yOffset)); + stackedPositions.add(p.above(yOffset)); } cachedBrushes.put(Pair.of(i, h), stackedPositions); } @@ -58,7 +58,7 @@ public class CylinderBrush extends ShapedBrush { int r = (param0 + 1 + offset); int y = (param1 + (param1 == 0 ? 0 : yOffset)) / 2; - return BlockPos.ZERO.offset(face, (face.getAxis() + return BlockPos.ZERO.relative(face, (face.getAxis() .isVertical() ? y : r) * (option == PlacementOptions.Attached ? 1 : -1)); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/DynamicBrush.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/DynamicBrush.java index 5305a65e5..7e262093d 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/DynamicBrush.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/DynamicBrush.java @@ -83,10 +83,10 @@ public class DynamicBrush extends Brush { for (int z = -1; z <= 1; z++) if (Math.abs(x) + Math.abs(y) + Math.abs(z) < 2 || searchDiagonals) if (targetFace.getAxis() - .getCoordinate(x, y, z) == 0 || !surface) + .choose(x, y, z) == 0 || !surface) offsets.add(new BlockPos(x, y, z)); - BlockPos startPos = replace ? targetPos : targetPos.offset(targetFace); + BlockPos startPos = replace ? targetPos : targetPos.relative(targetFace); frontier.add(startPos); while (!frontier.isEmpty()) { @@ -94,36 +94,36 @@ public class DynamicBrush extends Brush { if (visited.contains(currentPos)) continue; visited.add(currentPos); - if (!currentPos.withinDistance(startPos, searchRange)) + if (!currentPos.closerThan(startPos, searchRange)) continue; // Replace Mode if (replace) { BlockState stateToReplace = world.getBlockState(currentPos); - BlockState stateAboveStateToReplace = world.getBlockState(currentPos.offset(targetFace)); + BlockState stateAboveStateToReplace = world.getBlockState(currentPos.relative(targetFace)); // Criteria - if (stateToReplace.getBlockHardness(world, currentPos) == -1) + if (stateToReplace.getDestroySpeed(world, currentPos) == -1) continue; if (stateToReplace.getBlock() != state.getBlock() && !fuzzy) continue; if (stateToReplace.getMaterial() .isReplaceable()) continue; - if (BlockHelper.hasBlockSolidSide(stateAboveStateToReplace, world, currentPos.offset(targetFace), + if (BlockHelper.hasBlockSolidSide(stateAboveStateToReplace, world, currentPos.relative(targetFace), targetFace.getOpposite()) && surface) continue; affectedPositions.add(currentPos); // Search adjacent spaces for (BlockPos offset : offsets) - frontier.add(currentPos.add(offset)); + frontier.add(currentPos.offset(offset)); continue; } // Place Mode BlockState stateToPlaceAt = world.getBlockState(currentPos); - BlockState stateToPlaceOn = world.getBlockState(currentPos.offset(targetFace.getOpposite())); + BlockState stateToPlaceOn = world.getBlockState(currentPos.relative(targetFace.getOpposite())); // Criteria if (stateToPlaceOn.getMaterial() @@ -138,7 +138,7 @@ public class DynamicBrush extends Brush { // Search adjacent spaces for (BlockPos offset : offsets) - frontier.add(currentPos.add(offset)); + frontier.add(currentPos.offset(offset)); continue; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/FlattenTool.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/FlattenTool.java index eb11bd942..fc7287ca7 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/FlattenTool.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/FlattenTool.java @@ -56,7 +56,7 @@ public class FlattenTool { public static void apply(World world, List targetPositions, Direction facing) { List surfaces = new ArrayList<>(); Map, Integer> heightMap = new HashMap<>(); - int offset = facing.getAxisDirection().getOffset(); + int offset = facing.getAxisDirection().getStep(); int minEntry = Integer.MAX_VALUE; int minCoord1 = Integer.MAX_VALUE; @@ -80,7 +80,7 @@ public class FlattenTool { continue; } - p = p.offset(facing); + p = p.relative(facing); BlockState surface = world.getBlockState(p); if (!TerrainTools.isReplaceable(surface)) { @@ -90,7 +90,7 @@ public class FlattenTool { } surfaces.add(p); - int coordinate = facing.getAxis().getCoordinate(p.getX(), p.getY(), p.getZ()); + int coordinate = facing.getAxis().choose(p.getX(), p.getY(), p.getZ()); if (!heightMap.containsKey(coords) || heightMap.get(coords).equals(Integer.MAX_VALUE) || heightMap.get(coords).equals(Integer.MIN_VALUE) || heightMap.get(coords) * offset < coordinate * offset) { @@ -130,7 +130,7 @@ public class FlattenTool { for (BlockPos p : surfaces) { Pair coords = getCoords(p, facing); - int surfaceCoord = facing.getAxis().getCoordinate(p.getX(), p.getY(), p.getZ()) * offset; + int surfaceCoord = facing.getAxis().choose(p.getX(), p.getY(), p.getZ()) * offset; int targetCoord = heightMapArray[coords.getKey() - minCoord1][coords.getValue() - minCoord2] * offset; // Keep surface @@ -141,10 +141,10 @@ public class FlattenTool { BlockState blockState = world.getBlockState(p); int timeOut = 1000; while (surfaceCoord > targetCoord) { - BlockPos below = p.offset(facing.getOpposite()); - world.setBlockState(below, blockState); - world.setBlockState(p, blockState.getFluidState().getBlockState()); - p = p.offset(facing.getOpposite()); + BlockPos below = p.relative(facing.getOpposite()); + world.setBlockAndUpdate(below, blockState); + world.setBlockAndUpdate(p, blockState.getFluidState().createLegacyBlock()); + p = p.relative(facing.getOpposite()); surfaceCoord--; if (timeOut-- <= 0) break; @@ -152,11 +152,11 @@ public class FlattenTool { // Raise surface while (surfaceCoord < targetCoord) { - BlockPos above = p.offset(facing); + BlockPos above = p.relative(facing); if (!(blockState.getBlock() instanceof FlowingFluidBlock)) - world.setBlockState(above, blockState); - world.setBlockState(p, world.getBlockState(p.offset(facing.getOpposite()))); - p = p.offset(facing); + world.setBlockAndUpdate(above, blockState); + world.setBlockAndUpdate(p, world.getBlockState(p.relative(facing.getOpposite()))); + p = p.relative(facing); surfaceCoord++; if (timeOut-- <= 0) break; diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/ShapedBrush.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/ShapedBrush.java index f0e67f3c2..c89e5c7a3 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/ShapedBrush.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/ShapedBrush.java @@ -20,7 +20,7 @@ public abstract class ShapedBrush extends Brush { if (includedPositions == null) return affectedPositions; for (BlockPos blockPos : includedPositions) - affectedPositions.add(targetPos.add(blockPos)); + affectedPositions.add(targetPos.offset(blockPos)); return affectedPositions; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/SphereBrush.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/SphereBrush.java index be7657398..544e70d1d 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/SphereBrush.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/SphereBrush.java @@ -25,7 +25,7 @@ public class SphereBrush extends ShapedBrush { for (int i = 0; i <= MAX_RADIUS; i++) { int radius = i; List positions = - BlockPos.getAllInBox(BlockPos.ZERO.add(-i - 1, -i - 1, -i - 1), BlockPos.ZERO.add(i + 1, i + 1, i + 1)) + BlockPos.betweenClosedStream(BlockPos.ZERO.offset(-i - 1, -i - 1, -i - 1), BlockPos.ZERO.offset(i + 1, i + 1, i + 1)) .map(BlockPos::new).filter(p -> VecHelper.getCenterOf(p) .distanceTo(VecHelper.getCenterOf(BlockPos.ZERO)) < radius + .5f) .collect(Collectors.toList()); @@ -41,7 +41,7 @@ public class SphereBrush extends ShapedBrush { int offset = option == PlacementOptions.Attached ? 0 : -1; int r = (param0 + 1 + offset); - return BlockPos.ZERO.offset(face, r * (option == PlacementOptions.Attached ? 1 : -1)); + return BlockPos.ZERO.relative(face, r * (option == PlacementOptions.Attached ? 1 : -1)); } @Override diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/TerrainTools.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/TerrainTools.java index 43ba4e9f5..1c51a6883 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/TerrainTools.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/TerrainTools.java @@ -42,14 +42,14 @@ public enum TerrainTools { public void run(World world, List targetPositions, Direction facing, @Nullable BlockState paintedState, @Nullable CompoundNBT data, PlayerEntity player) { switch (this) { case Clear: - targetPositions.forEach(p -> world.setBlockState(p, Blocks.AIR.getDefaultState())); + targetPositions.forEach(p -> world.setBlockAndUpdate(p, Blocks.AIR.defaultBlockState())); break; case Fill: targetPositions.forEach(p -> { BlockState toReplace = world.getBlockState(p); if (!isReplaceable(toReplace)) return; - world.setBlockState(p, paintedState); + world.setBlockAndUpdate(p, paintedState); ZapperItem.setTileData(world, p, paintedState, data, player); }); break; @@ -64,18 +64,18 @@ public enum TerrainTools { if (toOverlay == paintedState) return; - p = p.up(); + p = p.above(); BlockState toReplace = world.getBlockState(p); if (!isReplaceable(toReplace)) return; - world.setBlockState(p, paintedState); + world.setBlockAndUpdate(p, paintedState); ZapperItem.setTileData(world, p, paintedState, data, player); }); break; case Place: targetPositions.forEach(p -> { - world.setBlockState(p, paintedState); + world.setBlockAndUpdate(p, paintedState); ZapperItem.setTileData(world, p, paintedState, data, player); }); break; @@ -84,7 +84,7 @@ public enum TerrainTools { BlockState toReplace = world.getBlockState(p); if (isReplaceable(toReplace)) return; - world.setBlockState(p, paintedState); + world.setBlockAndUpdate(p, paintedState); ZapperItem.setTileData(world, p, paintedState, data, player); }); break; diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java index 86d74a5c6..9b7a1ce2a 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java @@ -21,6 +21,8 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.Item.Properties; + public class WorldshaperItem extends ZapperItem { public WorldshaperItem(Properties properties) { @@ -62,7 +64,7 @@ public class WorldshaperItem extends ZapperItem { protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState stateToUse, BlockRayTraceResult raytrace, CompoundNBT data) { - BlockPos targetPos = raytrace.getPos(); + BlockPos targetPos = raytrace.getBlockPos(); List affectedPositions = new ArrayList<>(); CompoundNBT tag = stack.getOrCreateTag(); @@ -73,11 +75,11 @@ public class WorldshaperItem extends ZapperItem { TerrainTools tool = NBTHelper.readEnum(tag, "Tool", TerrainTools.class); brush.set(params.getX(), params.getY(), params.getZ()); - targetPos = targetPos.add(brush.getOffset(player.getLookVec(), raytrace.getFace(), option)); - brush.addToGlobalPositions(world, targetPos, raytrace.getFace(), affectedPositions, tool); + targetPos = targetPos.offset(brush.getOffset(player.getLookAngle(), raytrace.getDirection(), option)); + brush.addToGlobalPositions(world, targetPos, raytrace.getDirection(), affectedPositions, tool); PlacementPatterns.applyPattern(affectedPositions, stack); brush.redirectTool(tool) - .run(world, affectedPositions, raytrace.getFace(), stateToUse, data, player); + .run(world, affectedPositions, raytrace.getDirection(), stateToUse, data, player); return true; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java index 3b5886bab..d7f6fb113 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java @@ -31,9 +31,9 @@ public class WorldshaperItemRenderer extends ZapperItemRenderer brush.addToGlobalPositions(player.world, pos, raytrace.getFace(), new ArrayList<>(), tool); + () -> brush.addToGlobalPositions(player.level, pos, raytrace.getDirection(), new ArrayList<>(), tool); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java index d578b551a..2203efdca 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java @@ -48,7 +48,7 @@ public class WorldshaperScreen extends ZapperScreen { public WorldshaperScreen(ItemStack zapper, boolean offhand) { super(AllGuiTextures.TERRAINZAPPER, zapper, offhand); fontColor = 0x767676; - title = zapper.getDisplayName(); + title = zapper.getHoverName(); nbt = zapper.getOrCreateTag(); } @@ -100,9 +100,9 @@ public class WorldshaperScreen extends ZapperScreen { .withRange(currentBrush.getMin(index), currentBrush.getMax(index) + 1) .writingTo(label) .titled(currentBrush.getParamLabel(index) - .copy()) + .plainCopy()) .calling(state -> { - label.x = x + 65 + 20 * indexFinal - textRenderer.getWidth(label.text) / 2; + label.x = x + 65 + 20 * indexFinal - font.width(label.text) / 2; }); input.setState(params[index]); input.onChanged(); @@ -218,7 +218,7 @@ public class WorldshaperScreen extends ZapperScreen { placementButtons.forEach(b -> b.active = true); placementButton.active = false; placementButton.playDownSound(Minecraft.getInstance() - .getSoundHandler()); + .getSoundManager()); nbt.putString("Placement", PlacementOptions.values()[placementButtons.indexOf(placementButton)].name()); } @@ -230,7 +230,7 @@ public class WorldshaperScreen extends ZapperScreen { toolButtons.forEach(b -> b.active = true); toolButton.active = false; toolButton.playDownSound(Minecraft.getInstance() - .getSoundHandler()); + .getSoundManager()); nbt.putString("Tool", supportedTools[toolButtons.indexOf(toolButton)].name()); } } @@ -251,9 +251,9 @@ public class WorldshaperScreen extends ZapperScreen { for (int index = 2; index >= currentBrush.amtParams; index--) AllGuiTextures.TERRAINZAPPER_INACTIVE_PARAM.draw(matrixStack, x + 56 + 20 * index, y + 40); - textRenderer.draw(matrixStack, toolSection, x + 7, y + 69, fontColor); + font.draw(matrixStack, toolSection, x + 7, y + 69, fontColor); if (currentBrush.hasPlacementOptions()) - textRenderer.draw(matrixStack, placementSection, x + 136, y + 69, fontColor); + font.draw(matrixStack, placementSection, x + 136, y + 69, fontColor); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java b/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java index 38ab8b08c..d16baef0e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java @@ -42,7 +42,7 @@ public class RedstoneLinkNetworkHandler { private Frequency(ItemStack stack) { this.stack = stack; item = stack.getItem(); - CompoundNBT displayTag = stack.getChildTag("display"); + CompoundNBT displayTag = stack.getTagElement("display"); color = displayTag != null && displayTag.contains("color") ? displayTag.getInt("color") : -1; } @@ -138,7 +138,7 @@ public class RedstoneLinkNetworkHandler { if (from == to) return true; return from.getLocation() - .withinDistance(to.getLocation(), AllConfigs.SERVER.logistics.linkRange.get()); + .closerThan(to.getLocation(), AllConfigs.SERVER.logistics.linkRange.get()); } public Map, Set> networksIn(IWorld world) { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java index 73ca73d70..660b61b42 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java @@ -40,7 +40,7 @@ public class FlapData extends InstanceData implements IFlatLight { } public FlapData setPosition(Vector3f pos) { - return setPosition(pos.getX(), pos.getY(), pos.getZ()); + return setPosition(pos.x(), pos.y(), pos.z()); } public FlapData setPosition(int x, int y, int z) { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelBlock.java index b16763bf2..3fc108e7b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelBlock.java @@ -35,6 +35,8 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class BeltTunnelBlock extends Block implements ITE, IWrenchable { public static final Property SHAPE = EnumProperty.create("shape", Shape.class); @@ -42,14 +44,14 @@ public class BeltTunnelBlock extends Block implements ITE, public BeltTunnelBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(SHAPE, Shape.STRAIGHT)); + registerDefaultState(defaultBlockState().setValue(SHAPE, Shape.STRAIGHT)); } public enum Shape implements IStringSerializable { STRAIGHT, WINDOW, CLOSED, T_LEFT, T_RIGHT, CROSS; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } } @@ -70,58 +72,58 @@ public class BeltTunnelBlock extends Block implements ITE, } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - BlockState blockState = worldIn.getBlockState(pos.down()); + public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + BlockState blockState = worldIn.getBlockState(pos.below()); if (!isValidPositionForPlacement(state, worldIn, pos)) return false; - if (!blockState.get(BeltBlock.CASING)) + if (!blockState.getValue(BeltBlock.CASING)) return false; return true; } public boolean isValidPositionForPlacement(BlockState state, IWorldReader worldIn, BlockPos pos) { - BlockState blockState = worldIn.getBlockState(pos.down()); + BlockState blockState = worldIn.getBlockState(pos.below()); if (!AllBlocks.BELT.has(blockState)) return false; - if (blockState.get(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL) + if (blockState.getValue(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL) return false; return true; } public static boolean hasWindow(BlockState state) { - return state.get(SHAPE) == Shape.WINDOW || state.get(SHAPE) == Shape.CLOSED; + return state.getValue(SHAPE) == Shape.WINDOW || state.getValue(SHAPE) == Shape.CLOSED; } public static boolean isStraight(BlockState state) { - return hasWindow(state) || state.get(SHAPE) == Shape.STRAIGHT; + return hasWindow(state) || state.getValue(SHAPE) == Shape.STRAIGHT; } public static boolean isJunction(BlockState state) { - Shape shape = state.get(SHAPE); + Shape shape = state.getValue(SHAPE); return shape == Shape.CROSS || shape == Shape.T_LEFT || shape == Shape.T_RIGHT; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return getTunnelState(context.getWorld(), context.getPos()); + return getTunnelState(context.getLevel(), context.getClickedPos()); } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) { - if (!(world instanceof WrappedWorld) && !world.isRemote()) + public void onPlace(BlockState state, World world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) { + if (!(world instanceof WrappedWorld) && !world.isClientSide()) withTileEntityDo(world, pos, BeltTunnelTileEntity::updateTunnelConnections); } @Override - public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { if (facing.getAxis() .isVertical()) return state; - if (!(worldIn instanceof WrappedWorld) && !worldIn.isRemote()) + if (!(worldIn instanceof WrappedWorld) && !worldIn.isClientSide()) withTileEntityDo(worldIn, currentPos, BeltTunnelTileEntity::updateTunnelConnections); BlockState tunnelState = getTunnelState(worldIn, currentPos); - if (tunnelState.get(HORIZONTAL_AXIS) == state.get(HORIZONTAL_AXIS)) { + if (tunnelState.getValue(HORIZONTAL_AXIS) == state.getValue(HORIZONTAL_AXIS)) { if (hasWindow(tunnelState) == hasWindow(state)) return state; } @@ -132,55 +134,55 @@ public class BeltTunnelBlock extends Block implements ITE, public void updateTunnel(IWorld world, BlockPos pos) { BlockState tunnel = world.getBlockState(pos); BlockState newTunnel = getTunnelState(world, pos); - if (tunnel != newTunnel && !world.isRemote()) { - world.setBlockState(pos, newTunnel, 3); - TileEntity te = world.getTileEntity(pos); + if (tunnel != newTunnel && !world.isClientSide()) { + world.setBlock(pos, newTunnel, 3); + TileEntity te = world.getBlockEntity(pos); if (te != null && (te instanceof BeltTunnelTileEntity)) ((BeltTunnelTileEntity) te).updateTunnelConnections(); } } private BlockState getTunnelState(IBlockReader reader, BlockPos pos) { - BlockState state = getDefaultState(); - BlockState belt = reader.getBlockState(pos.down()); + BlockState state = defaultBlockState(); + BlockState belt = reader.getBlockState(pos.below()); if (AllBlocks.BELT.has(belt)) - state = state.with(HORIZONTAL_AXIS, belt.get(BeltBlock.HORIZONTAL_FACING) + state = state.setValue(HORIZONTAL_AXIS, belt.getValue(BeltBlock.HORIZONTAL_FACING) .getAxis()); - Axis axis = state.get(HORIZONTAL_AXIS); + Axis axis = state.getValue(HORIZONTAL_AXIS); // T and Cross - Direction left = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis) - .rotateY(); - boolean onLeft = hasValidOutput(reader, pos.down(), left); - boolean onRight = hasValidOutput(reader, pos.down(), left.getOpposite()); + Direction left = Direction.get(AxisDirection.POSITIVE, axis) + .getClockWise(); + boolean onLeft = hasValidOutput(reader, pos.below(), left); + boolean onRight = hasValidOutput(reader, pos.below(), left.getOpposite()); if (onLeft && onRight) - state = state.with(SHAPE, Shape.CROSS); + state = state.setValue(SHAPE, Shape.CROSS); else if (onLeft) - state = state.with(SHAPE, Shape.T_LEFT); + state = state.setValue(SHAPE, Shape.T_LEFT); else if (onRight) - state = state.with(SHAPE, Shape.T_RIGHT); + state = state.setValue(SHAPE, Shape.T_RIGHT); - if (state.get(SHAPE) == Shape.STRAIGHT) { + if (state.getValue(SHAPE) == Shape.STRAIGHT) { boolean canHaveWindow = canHaveWindow(reader, pos, axis); if (canHaveWindow) - state = state.with(SHAPE, Shape.WINDOW); + state = state.setValue(SHAPE, Shape.WINDOW); } return state; } protected boolean canHaveWindow(IBlockReader reader, BlockPos pos, Axis axis) { - Direction fw = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); - BlockState blockState1 = reader.getBlockState(pos.offset(fw)); - BlockState blockState2 = reader.getBlockState(pos.offset(fw.getOpposite())); + Direction fw = Direction.get(AxisDirection.POSITIVE, axis); + BlockState blockState1 = reader.getBlockState(pos.relative(fw)); + BlockState blockState2 = reader.getBlockState(pos.relative(fw.getOpposite())); boolean funnel1 = blockState1.getBlock() instanceof BeltFunnelBlock - && blockState1.get(BeltFunnelBlock.SHAPE) == BeltFunnelBlock.Shape.EXTENDED - && blockState1.get(BeltFunnelBlock.HORIZONTAL_FACING) == fw.getOpposite(); + && blockState1.getValue(BeltFunnelBlock.SHAPE) == BeltFunnelBlock.Shape.EXTENDED + && blockState1.getValue(BeltFunnelBlock.HORIZONTAL_FACING) == fw.getOpposite(); boolean funnel2 = blockState2.getBlock() instanceof BeltFunnelBlock - && blockState2.get(BeltFunnelBlock.SHAPE) == BeltFunnelBlock.Shape.EXTENDED - && blockState2.get(BeltFunnelBlock.HORIZONTAL_FACING) == fw; + && blockState2.getValue(BeltFunnelBlock.SHAPE) == BeltFunnelBlock.Shape.EXTENDED + && blockState2.getValue(BeltFunnelBlock.HORIZONTAL_FACING) == fw; boolean valid1 = blockState1.getBlock() instanceof BeltTunnelBlock || funnel1; boolean valid2 = blockState2.getBlock() instanceof BeltTunnelBlock || funnel2; @@ -189,12 +191,12 @@ public class BeltTunnelBlock extends Block implements ITE, } private boolean hasValidOutput(IBlockReader world, BlockPos pos, Direction side) { - BlockState blockState = world.getBlockState(pos.offset(side)); + BlockState blockState = world.getBlockState(pos.relative(side)); if (AllBlocks.BELT.has(blockState)) - return blockState.get(BeltBlock.HORIZONTAL_FACING) + return blockState.getValue(BeltBlock.HORIZONTAL_FACING) .getAxis() == side.getAxis(); DirectBeltInputBehaviour behaviour = - TileEntityBehaviour.get(world, pos.offset(side), DirectBeltInputBehaviour.TYPE); + TileEntityBehaviour.get(world, pos.relative(side), DirectBeltInputBehaviour.TYPE); return behaviour != null && behaviour.canInsertFromSide(side); } @@ -204,30 +206,30 @@ public class BeltTunnelBlock extends Block implements ITE, return ActionResultType.PASS; // Toggle windows - Shape shape = state.get(SHAPE); + Shape shape = state.getValue(SHAPE); shape = shape == Shape.CLOSED ? Shape.WINDOW : Shape.CLOSED; - World world = context.getWorld(); - if (!world.isRemote) - world.setBlockState(context.getPos(), state.with(SHAPE, shape), 2); + World world = context.getLevel(); + if (!world.isClientSide) + world.setBlock(context.getClickedPos(), state.setValue(SHAPE, shape), 2); return ActionResultType.SUCCESS; } @Override public BlockState rotate(BlockState state, Rotation rotation) { - Direction fromAxis = Direction.getFacingFromAxis(AxisDirection.POSITIVE, state.get(HORIZONTAL_AXIS)); + Direction fromAxis = Direction.get(AxisDirection.POSITIVE, state.getValue(HORIZONTAL_AXIS)); Direction rotated = rotation.rotate(fromAxis); - return state.with(HORIZONTAL_AXIS, rotated.getAxis()); + return state.setValue(HORIZONTAL_AXIS, rotated.getAxis()); } @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - if (fromPos.equals(pos.down())) { - if (!isValidPosition(state, worldIn, pos)) { + if (fromPos.equals(pos.below())) { + if (!canSurvive(state, worldIn, pos)) { worldIn.destroyBlock(pos, true); return; } @@ -235,9 +237,9 @@ public class BeltTunnelBlock extends Block implements ITE, } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(HORIZONTAL_AXIS, SHAPE); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java index e40dfdff0..beeb853fd 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java @@ -31,14 +31,14 @@ public class BeltTunnelInstance extends TileEntityInstance Instancer model = modelManager.getMaterial(AllMaterialSpecs.FLAPS) .getModel(AllBlockPartials.BELT_TUNNEL_FLAP, blockState); - int blockLight = world.getLightLevel(LightType.BLOCK, pos); - int skyLight = world.getLightLevel(LightType.SKY, pos); + int blockLight = world.getBrightness(LightType.BLOCK, pos); + int skyLight = world.getBrightness(LightType.SKY, pos); tile.flaps.forEach((direction, flapValue) -> { float flapness = flapValue.get(AnimationTickHolder.getPartialTicks()); - float horizontalAngle = direction.getOpposite().getHorizontalAngle(); + float horizontalAngle = direction.getOpposite().toYRot(); float flapScale = direction.getAxis() == Direction.Axis.X ? 1 : -1; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java index 3f7a44fc5..ea38d5455 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java @@ -16,6 +16,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.world.World; +import net.minecraft.item.Item.Properties; + public class BeltTunnelItem extends BlockItem { public BeltTunnelItem(Block p_i48527_1_, Properties p_i48527_2_) { @@ -26,19 +28,19 @@ public class BeltTunnelItem extends BlockItem { protected boolean canPlace(BlockItemUseContext ctx, BlockState state) { PlayerEntity playerentity = ctx.getPlayer(); ISelectionContext iselectioncontext = - playerentity == null ? ISelectionContext.dummy() : ISelectionContext.forEntity(playerentity); - World world = ctx.getWorld(); - BlockPos pos = ctx.getPos(); - return (!this.checkPosition() || AllBlocks.ANDESITE_TUNNEL.get() - .isValidPositionForPlacement(state, world, pos)) && world.canPlace(state, pos, iselectioncontext); + playerentity == null ? ISelectionContext.empty() : ISelectionContext.of(playerentity); + World world = ctx.getLevel(); + BlockPos pos = ctx.getClickedPos(); + return (!this.mustSurvive() || AllBlocks.ANDESITE_TUNNEL.get() + .isValidPositionForPlacement(state, world, pos)) && world.isUnobstructed(state, pos, iselectioncontext); } @Override - protected boolean onBlockPlaced(BlockPos pos, World world, PlayerEntity p_195943_3_, ItemStack p_195943_4_, + protected boolean updateCustomBlockEntityTag(BlockPos pos, World world, PlayerEntity p_195943_3_, ItemStack p_195943_4_, BlockState state) { - boolean flag = super.onBlockPlaced(pos, world, p_195943_3_, p_195943_4_, state); - if (!world.isRemote) { - BeltTileEntity belt = BeltHelper.getSegmentTE(world, pos.down()); + boolean flag = super.updateCustomBlockEntityTag(pos, world, p_195943_3_, p_195943_4_, state); + if (!world.isClientSide) { + BeltTileEntity belt = BeltHelper.getSegmentTE(world, pos.below()); if (belt != null) { AllTriggers.triggerFor(AllTriggers.PLACE_TUNNEL, p_195943_3_); if (belt.casing == CasingType.NONE) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java index 920d64259..a94e15361 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java @@ -31,10 +31,10 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer { if (!(te instanceof BrassTunnelTileEntity)) return ActionResultType.PASS; BrassTunnelTileEntity bte = (BrassTunnelTileEntity) te; - List stacksOfGroup = bte.grabAllStacksOfGroup(world.isRemote); + List stacksOfGroup = bte.grabAllStacksOfGroup(world.isClientSide); if (stacksOfGroup.isEmpty()) return ActionResultType.PASS; - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; for (ItemStack itemStack : stacksOfGroup) player.inventory.placeItemBackInInventory(world, itemStack.copy()); - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, .2f, + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .2f, 1f + Create.RANDOM.nextFloat()); return ActionResultType.SUCCESS; }); @@ -56,22 +56,22 @@ public class BrassTunnelBlock extends BeltTunnelBlock { } @Override - public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { - return super.updatePostPlacement(state, facing, facingState, worldIn, currentPos, facingPos); + return super.updateShape(state, facing, facingState, worldIn, currentPos, facingPos); } @Override - public void onReplaced(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, + public void onRemove(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, boolean p_196243_5_) { if (p_196243_1_.hasTileEntity() && (p_196243_1_.getBlock() != p_196243_4_.getBlock() || !p_196243_4_.hasTileEntity())) { TileEntityBehaviour.destroy(p_196243_2_, p_196243_3_, FilteringBehaviour.TYPE); withTileEntityDo(p_196243_2_, p_196243_3_, te -> { if (te instanceof BrassTunnelTileEntity) - Block.spawnAsEntity(p_196243_2_, p_196243_3_, ((BrassTunnelTileEntity) te).stackToDistribute); + Block.popResource(p_196243_2_, p_196243_3_, ((BrassTunnelTileEntity) te).stackToDistribute); }); - p_196243_2_.removeTileEntity(p_196243_3_); + p_196243_2_.removeBlockEntity(p_196243_3_); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelCTBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelCTBehaviour.java index ede331c95..2f5f70a03 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelCTBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelCTBehaviour.java @@ -10,6 +10,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockDisplayReader; +import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour.CTContext; + public class BrassTunnelCTBehaviour extends ConnectedTextureBehaviour { @Override @@ -25,7 +27,7 @@ public class BrassTunnelCTBehaviour extends ConnectedTextureBehaviour { if (yDiff != 0) return false; - TileEntity te = reader.getTileEntity(pos); + TileEntity te = reader.getBlockEntity(pos); if (!(te instanceof BrassTunnelTileEntity)) return false; BrassTunnelTileEntity tunnelTE = (BrassTunnelTileEntity) te; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java index 62e7ca059..e86042119 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java @@ -111,7 +111,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave @Override public void tick() { super.tick(); - BeltTileEntity beltBelow = BeltHelper.getSegmentTE(world, pos.down()); + BeltTileEntity beltBelow = BeltHelper.getSegmentTE(level, worldPosition.below()); if (distributionProgress > 0) distributionProgress--; @@ -119,7 +119,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave return; if (stackToDistribute.isEmpty() && !syncedOutputActive) return; - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) return; if (distributionProgress == -1) { @@ -153,8 +153,8 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave if (insertIntoTunnel(tunnel, output, stackToDistribute, true) == null) continue; distributionTargets.get(!tunnel.flapFilterEmpty(output)) - .add(Pair.of(tunnel.pos, output)); - int distance = tunnel.pos.getX() + tunnel.pos.getZ() - pos.getX() - pos.getZ(); + .add(Pair.of(tunnel.worldPosition, output)); + int distance = tunnel.worldPosition.getX() + tunnel.worldPosition.getZ() - worldPosition.getX() - worldPosition.getZ(); if (distance < 0) distributionDistanceLeft = Math.max(distributionDistanceLeft, -distance); else @@ -184,7 +184,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave for (Pair pair : list) { BlockPos tunnelPos = pair.getKey(); Direction output = pair.getValue(); - TileEntity te = world.getTileEntity(tunnelPos); + TileEntity te = level.getBlockEntity(tunnelPos); if (!(te instanceof BrassTunnelTileEntity)) continue; validTargets.add(Pair.of((BrassTunnelTileEntity) te, output)); @@ -316,7 +316,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave stackToDistribute = stack; distributionProgress = -1; sendData(); - markDirty(); + setChanged(); } public ItemStack getStackToDistribute() { @@ -336,7 +336,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave for (boolean left : Iterate.trueAndFalse) { BrassTunnelTileEntity adjacent = this; while (adjacent != null) { - if (!world.isAreaLoaded(adjacent.getPos(), 1)) + if (!level.isAreaLoaded(adjacent.getBlockPos(), 1)) return null; adjacent = adjacent.getAdjacent(left); if (adjacent == null) @@ -361,13 +361,13 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave if (!tunnel.testFlapFilter(side, stack)) return null; - BeltTileEntity below = BeltHelper.getSegmentTE(world, tunnel.pos.down()); + BeltTileEntity below = BeltHelper.getSegmentTE(level, tunnel.worldPosition.below()); if (below == null) return null; - BlockPos offset = tunnel.getPos() - .down() - .offset(side); - DirectBeltInputBehaviour sideOutput = TileEntityBehaviour.get(world, offset, DirectBeltInputBehaviour.TYPE); + BlockPos offset = tunnel.getBlockPos() + .below() + .relative(side); + DirectBeltInputBehaviour sideOutput = TileEntityBehaviour.get(level, offset, DirectBeltInputBehaviour.TYPE); if (sideOutput != null) { if (!sideOutput.canInsertFromSide(side)) return null; @@ -379,7 +379,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave Direction movementFacing = below.getMovementFacing(); if (side == movementFacing) - if (!BlockHelper.hasBlockSolidSide(world.getBlockState(offset), world, offset, side.getOpposite())) { + if (!BlockHelper.hasBlockSolidSide(level.getBlockState(offset), level, offset, side.getOpposite())) { BeltTileEntity controllerTE = below.getControllerTE(); if (controllerTE == null) return null; @@ -391,15 +391,15 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave float movementSpeed = Math.max(Math.abs(beltMovementSpeed), 1 / 8f); int additionalOffset = beltMovementSpeed > 0 ? 1 : 0; Vector3d outPos = BeltHelper.getVectorForOffset(controllerTE, below.index + additionalOffset); - Vector3d outMotion = Vector3d.of(side.getDirectionVec()) + Vector3d outMotion = Vector3d.atLowerCornerOf(side.getNormal()) .scale(movementSpeed) .add(0, 1 / 8f, 0); outPos.add(outMotion.normalize()); - ItemEntity entity = new ItemEntity(world, outPos.x, outPos.y + 6 / 16f, outPos.z, ejected); - entity.setMotion(outMotion); - entity.setDefaultPickupDelay(); - entity.velocityChanged = true; - world.addEntity(entity); + ItemEntity entity = new ItemEntity(level, outPos.x, outPos.y + 6 / 16f, outPos.z, ejected); + entity.setDeltaMovement(outMotion); + entity.setDefaultPickUpDelay(); + entity.hurtMarked = true; + level.addFreshEntity(entity); } return ItemStack.EMPTY; @@ -413,7 +413,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave return false; if (filtering.get(side) == null) { FilteringBehaviour adjacentFilter = - TileEntityBehaviour.get(world, pos.offset(side), FilteringBehaviour.TYPE); + TileEntityBehaviour.get(level, worldPosition.relative(side), FilteringBehaviour.TYPE); if (adjacentFilter == null) return true; return adjacentFilter.test(stack); @@ -426,7 +426,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave return false; if (filtering.get(side) == null) { FilteringBehaviour adjacentFilter = - TileEntityBehaviour.get(world, pos.offset(side), FilteringBehaviour.TYPE); + TileEntityBehaviour.get(level, worldPosition.relative(side), FilteringBehaviour.TYPE); if (adjacentFilter == null) return true; return adjacentFilter.getFilter() @@ -463,7 +463,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave BlockState blockState = getBlockState(); if (!AllBlocks.BRASS_TUNNEL.has(blockState)) return false; - Axis axis = blockState.get(BrassTunnelBlock.HORIZONTAL_AXIS); + Axis axis = blockState.getValue(BrassTunnelBlock.HORIZONTAL_AXIS); for (Direction direction : flaps.keySet()) if (direction.getAxis() != axis) return true; @@ -478,7 +478,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave for (boolean left : Iterate.trueAndFalse) { BrassTunnelTileEntity adjacent = this; while (adjacent != null) { - if (!world.isAreaLoaded(adjacent.getPos(), 1)) + if (!level.isAreaLoaded(adjacent.getBlockPos(), 1)) return null; adjacent = adjacent.getAdjacent(left); if (adjacent == null) @@ -495,7 +495,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave private void addValidOutputsOf(BrassTunnelTileEntity tunnelTE, List> validOutputs) { syncSet.add(tunnelTE); - BeltTileEntity below = BeltHelper.getSegmentTE(world, tunnelTE.pos.down()); + BeltTileEntity below = BeltHelper.getSegmentTE(level, tunnelTE.worldPosition.below()); if (below == null) return; Direction movementFacing = below.getMovementFacing(); @@ -516,13 +516,13 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave if (direction == movementFacing.getOpposite()) continue; if (tunnelTE.sides.contains(direction)) { - BlockPos offset = tunnelTE.pos.down() - .offset(direction); + BlockPos offset = tunnelTE.worldPosition.below() + .relative(direction); DirectBeltInputBehaviour inputBehaviour = - TileEntityBehaviour.get(world, offset, DirectBeltInputBehaviour.TYPE); + TileEntityBehaviour.get(level, offset, DirectBeltInputBehaviour.TYPE); if (inputBehaviour == null) { if (direction == movementFacing) - if (!BlockHelper.hasBlockSolidSide(world.getBlockState(offset), world, offset, + if (!BlockHelper.hasBlockSolidSide(level.getBlockState(offset), level, offset, direction.getOpposite())) validOutputs.add(Pair.of(tunnelTE, direction)); continue; @@ -572,7 +572,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave CompoundNBT nbt = new CompoundNBT(); nbt.put("Pos", NBTUtil.writeBlockPos(pair.getKey())); nbt.putInt("Face", pair.getValue() - .getIndex()); + .get3DDataValue()); return nbt; })); } @@ -588,7 +588,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave syncedOutputActive = compound.getBoolean("SyncedOutput"); connectedLeft = compound.getBoolean("ConnectedLeft"); connectedRight = compound.getBoolean("ConnectedRight"); - stackToDistribute = ItemStack.read(compound.getCompound("StackToDistribute")); + stackToDistribute = ItemStack.of(compound.getCompound("StackToDistribute")); distributionProgress = compound.getFloat("DistributionProgress"); previousOutputIndex = compound.getInt("PreviousIndex"); distributionDistanceLeft = compound.getInt("DistanceLeft"); @@ -598,7 +598,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave distributionTargets.set(filtered, NBTHelper .readCompoundList(compound.getList(filtered ? "FilteredTargets" : "Targets", NBT.TAG_COMPOUND), nbt -> { BlockPos pos = NBTUtil.readBlockPos(nbt.getCompound("Pos")); - Direction face = Direction.byIndex(nbt.getInt("Face")); + Direction face = Direction.from3DDataValue(nbt.getInt("Face")); return Pair.of(pos, face); })); } @@ -609,8 +609,8 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave return; if (wasConnectedLeft != connectedLeft || wasConnectedRight != connectedRight) { requestModelDataUpdate(); - if (hasWorld()) - world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 16); + if (hasLevel()) + level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), 16); } filtering.updateFilterPresence(); } @@ -630,10 +630,10 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave connectedLeft = nowConnectedLeft; connectivityChanged = true; BrassTunnelTileEntity adjacent = getAdjacent(true); - if (adjacent != null && !world.isRemote) { + if (adjacent != null && !level.isClientSide) { adjacent.updateTunnelConnections(); adjacent.selectionMode.setValue(selectionMode.getValue()); - AllTriggers.triggerForNearbyPlayers(AllTriggers.CONNECT_TUNNEL, world, pos, 4); + AllTriggers.triggerForNearbyPlayers(AllTriggers.CONNECT_TUNNEL, level, worldPosition, 4); } } @@ -641,7 +641,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave connectedRight = nowConnectedRight; connectivityChanged = true; BrassTunnelTileEntity adjacent = getAdjacent(false); - if (adjacent != null && !world.isRemote) { + if (adjacent != null && !level.isClientSide) { adjacent.updateTunnelConnections(); adjacent.selectionMode.setValue(selectionMode.getValue()); } @@ -662,24 +662,24 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave @Nullable protected BrassTunnelTileEntity getAdjacent(boolean leftSide) { - if (!hasWorld()) + if (!hasLevel()) return null; BlockState blockState = getBlockState(); if (!AllBlocks.BRASS_TUNNEL.has(blockState)) return null; - Axis axis = blockState.get(BrassTunnelBlock.HORIZONTAL_AXIS); - Direction baseDirection = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); - Direction direction = leftSide ? baseDirection.rotateYCCW() : baseDirection.rotateY(); - BlockPos adjacentPos = pos.offset(direction); - BlockState adjacentBlockState = world.getBlockState(adjacentPos); + Axis axis = blockState.getValue(BrassTunnelBlock.HORIZONTAL_AXIS); + Direction baseDirection = Direction.get(AxisDirection.POSITIVE, axis); + Direction direction = leftSide ? baseDirection.getCounterClockWise() : baseDirection.getClockWise(); + BlockPos adjacentPos = worldPosition.relative(direction); + BlockState adjacentBlockState = level.getBlockState(adjacentPos); if (!AllBlocks.BRASS_TUNNEL.has(adjacentBlockState)) return null; - if (adjacentBlockState.get(BrassTunnelBlock.HORIZONTAL_AXIS) != axis) + if (adjacentBlockState.getValue(BrassTunnelBlock.HORIZONTAL_AXIS) != axis) return null; - TileEntity adjacentTE = world.getTileEntity(adjacentPos); + TileEntity adjacentTE = level.getBlockEntity(adjacentPos); if (adjacentTE.isRemoved()) return null; if (!(adjacentTE instanceof BrassTunnelTileEntity)) @@ -688,9 +688,9 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave } @Override - public void remove() { + public void setRemoved() { tunnelCapability.invalidate(); - super.remove(); + super.setRemoved(); } @Override @@ -702,7 +702,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave public LazyOptional getBeltCapability() { if (!beltCapability.isPresent()) { - TileEntity tileEntity = world.getTileEntity(pos.down()); + TileEntity tileEntity = level.getBlockEntity(worldPosition.below()); if (tileEntity != null) beltCapability = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); } @@ -749,18 +749,18 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave if (allStacks.isEmpty()) return false; - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.brass_tunnel.contains")) - .formatted(TextFormatting.WHITE)); + .withStyle(TextFormatting.WHITE)); for (ItemStack item : allStacks) { - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.brass_tunnel.contains_entry", new TranslationTextComponent(item.getItem() - .getTranslationKey(item)).getString(), item.getCount())) - .formatted(TextFormatting.GRAY)); + .getDescriptionId(item)).getString(), item.getCount())) + .withStyle(TextFormatting.GRAY)); } - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.brass_tunnel.retrieve")) - .formatted(TextFormatting.DARK_GRAY)); + .withStyle(TextFormatting.DARK_GRAY)); return true; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/AbstractChuteBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/AbstractChuteBlock.java index 34e2a3976..72960cebf 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/AbstractChuteBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/AbstractChuteBlock.java @@ -32,6 +32,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class AbstractChuteBlock extends Block implements IWrenchable, ITE { public AbstractChuteBlock(Properties p_i48440_1_) { @@ -76,16 +78,16 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I public abstract TileEntity createTileEntity(BlockState state, IBlockReader world); @Override - public void onLanded(IBlockReader worldIn, Entity entityIn) { - super.onLanded(worldIn, entityIn); + public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + super.updateEntityAfterFallOn(worldIn, entityIn); if (!(entityIn instanceof ItemEntity)) return; - if (entityIn.world.isRemote) + if (entityIn.level.isClientSide) return; if (!entityIn.isAlive()) return; - DirectBeltInputBehaviour input = TileEntityBehaviour.get(entityIn.world, new BlockPos(entityIn.getPositionVec() - .add(0, 0.5f, 0)).down(), DirectBeltInputBehaviour.TYPE); + DirectBeltInputBehaviour input = TileEntityBehaviour.get(entityIn.level, new BlockPos(entityIn.position() + .add(0, 0.5f, 0)).below(), DirectBeltInputBehaviour.TYPE); if (input == null) return; if (!input.canInsertFromSide(Direction.UP)) @@ -102,7 +104,7 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) { + public void onPlace(BlockState state, World world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) { withTileEntityDo(world, pos, ChuteTileEntity::onAdded); if (p_220082_5_) return; @@ -114,24 +116,24 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I return; AbstractChuteBlock block = (AbstractChuteBlock) state.getBlock(); Direction facing = block.getFacing(state); - BlockPos toUpdate = pos.down(); + BlockPos toUpdate = pos.below(); if (facing.getAxis() .isHorizontal()) - toUpdate = toUpdate.offset(facing.getOpposite()); + toUpdate = toUpdate.relative(facing.getOpposite()); BlockState stateToUpdate = world.getBlockState(toUpdate); - BlockState updated = updateChuteState(stateToUpdate, world.getBlockState(toUpdate.up()), world, toUpdate); - if (stateToUpdate != updated && !world.isRemote) - world.setBlockState(toUpdate, updated); + BlockState updated = updateChuteState(stateToUpdate, world.getBlockState(toUpdate.above()), world, toUpdate); + if (stateToUpdate != updated && !world.isClientSide) + world.setBlockAndUpdate(toUpdate, updated); } @Override - public void onReplaced(BlockState state, World world, BlockPos pos, BlockState p_196243_4_, boolean p_196243_5_) { + public void onRemove(BlockState state, World world, BlockPos pos, BlockState p_196243_4_, boolean p_196243_5_) { boolean differentBlock = state.getBlock() != p_196243_4_.getBlock(); if (state.hasTileEntity() && (differentBlock || !p_196243_4_.hasTileEntity())) { TileEntityBehaviour.destroy(world, pos, FilteringBehaviour.TYPE); withTileEntityDo(world, pos, c -> c.onRemoved(state)); - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } if (p_196243_5_ || !differentBlock) return; @@ -139,20 +141,20 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I updateDiagonalNeighbour(state, world, pos); for (Direction direction : Iterate.horizontalDirections) { - BlockPos toUpdate = pos.up() - .offset(direction); + BlockPos toUpdate = pos.above() + .relative(direction); BlockState stateToUpdate = world.getBlockState(toUpdate); if (!isChute(stateToUpdate)) continue; BlockState updated = ((AbstractChuteBlock) stateToUpdate.getBlock()).updateChuteState(stateToUpdate, - world.getBlockState(toUpdate.up()), world, toUpdate); - if (stateToUpdate != updated && !world.isRemote) - world.setBlockState(toUpdate, updated); + world.getBlockState(toUpdate.above()), world, toUpdate); + if (stateToUpdate != updated && !world.isClientSide) + world.setBlockAndUpdate(toUpdate, updated); } } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState above, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState above, IWorld world, BlockPos pos, BlockPos p_196271_6_) { if (direction != Direction.UP) return state; @@ -162,10 +164,10 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I @Override public void neighborChanged(BlockState p_220069_1_, World world, BlockPos pos, Block p_220069_4_, BlockPos neighbourPos, boolean p_220069_6_) { - if (pos.down() + if (pos.below() .equals(neighbourPos)) withTileEntityDo(world, pos, ChuteTileEntity::blockBelowChanged); - else if (pos.up() + else if (pos.above() .equals(neighbourPos)) withTileEntityDo(world, pos, chute -> chute.capAbove = LazyOptional.empty()); } @@ -197,12 +199,12 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I } @Override - public ActionResultType onUse(BlockState p_225533_1_, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState p_225533_1_, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult p_225533_6_) { - if (!player.getHeldItem(hand) + if (!player.getItemInHand(hand) .isEmpty()) return ActionResultType.PASS; - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; return onTileEntityUse(world, pos, te -> { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteBlock.java index 9926f4ba4..bc3f6e87a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteBlock.java @@ -27,22 +27,24 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class ChuteBlock extends AbstractChuteBlock { public static final Property SHAPE = EnumProperty.create("shape", Shape.class); - public static final DirectionProperty FACING = BlockStateProperties.FACING_EXCEPT_UP; + public static final DirectionProperty FACING = BlockStateProperties.FACING_HOPPER; public ChuteBlock(Properties p_i48440_1_) { super(p_i48440_1_); - setDefaultState(getDefaultState().with(SHAPE, Shape.NORMAL) - .with(FACING, Direction.DOWN)); + registerDefaultState(defaultBlockState().setValue(SHAPE, Shape.NORMAL) + .setValue(FACING, Direction.DOWN)); } public enum Shape implements IStringSerializable { INTERSECTION, WINDOW, NORMAL; @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } } @@ -54,27 +56,27 @@ public class ChuteBlock extends AbstractChuteBlock { @Override public Direction getFacing(BlockState state) { - return state.get(FACING); + return state.getValue(FACING); } @Override public boolean isOpen(BlockState state) { - return state.get(FACING) == Direction.DOWN || state.get(SHAPE) == Shape.INTERSECTION; + return state.getValue(FACING) == Direction.DOWN || state.getValue(SHAPE) == Shape.INTERSECTION; } @Override public boolean isTransparent(BlockState state) { - return state.get(SHAPE) == Shape.WINDOW; + return state.getValue(SHAPE) == Shape.WINDOW; } @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - Shape shape = state.get(SHAPE); - boolean down = state.get(FACING) == Direction.DOWN; - if (!context.getWorld().isRemote && down && shape != Shape.INTERSECTION) { - context.getWorld() - .setBlockState(context.getPos(), - state.with(SHAPE, shape == Shape.WINDOW ? Shape.NORMAL : Shape.WINDOW)); + Shape shape = state.getValue(SHAPE); + boolean down = state.getValue(FACING) == Direction.DOWN; + if (!context.getLevel().isClientSide && down && shape != Shape.INTERSECTION) { + context.getLevel() + .setBlockAndUpdate(context.getClickedPos(), + state.setValue(SHAPE, shape == Shape.WINDOW ? Shape.NORMAL : Shape.WINDOW)); } return ActionResultType.SUCCESS; } @@ -82,24 +84,24 @@ public class ChuteBlock extends AbstractChuteBlock { @Override public BlockState getStateForPlacement(BlockItemUseContext ctx) { BlockState state = super.getStateForPlacement(ctx); - Direction face = ctx.getFace(); + Direction face = ctx.getClickedFace(); if (face.getAxis() - .isHorizontal() && !ctx.shouldCancelInteraction()) { - World world = ctx.getWorld(); - BlockPos pos = ctx.getPos(); - return updateChuteState(state.with(FACING, face), world.getBlockState(pos.up()), world, pos); + .isHorizontal() && !ctx.isSecondaryUseActive()) { + World world = ctx.getLevel(); + BlockPos pos = ctx.getClickedPos(); + return updateChuteState(state.setValue(FACING, face), world.getBlockState(pos.above()), world, pos); } return state; } @Override - protected void fillStateContainer(Builder p_206840_1_) { - super.fillStateContainer(p_206840_1_.add(SHAPE, FACING)); + protected void createBlockStateDefinition(Builder p_206840_1_) { + super.createBlockStateDefinition(p_206840_1_.add(SHAPE, FACING)); } @Override - public boolean isValidPosition(BlockState state, IWorldReader world, BlockPos pos) { - BlockState above = world.getBlockState(pos.up()); + public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { + BlockState above = world.getBlockState(pos.above()); return !isChute(above) || getChuteFacing(above) == Direction.DOWN; } @@ -110,22 +112,22 @@ public class ChuteBlock extends AbstractChuteBlock { Map connections = new HashMap<>(); int amtConnections = 0; - Direction facing = state.get(FACING); + Direction facing = state.getValue(FACING); boolean vertical = facing == Direction.DOWN; if (!vertical) { - BlockState target = world.getBlockState(pos.down() - .offset(facing.getOpposite())); + BlockState target = world.getBlockState(pos.below() + .relative(facing.getOpposite())); if (!isChute(target)) - return state.with(FACING, Direction.DOWN) - .with(SHAPE, Shape.NORMAL); + return state.setValue(FACING, Direction.DOWN) + .setValue(SHAPE, Shape.NORMAL); } for (Direction direction : Iterate.horizontalDirections) { - BlockState diagonalInputChute = world.getBlockState(pos.up() - .offset(direction)); + BlockState diagonalInputChute = world.getBlockState(pos.above() + .relative(direction)); boolean value = - diagonalInputChute.getBlock() instanceof ChuteBlock && diagonalInputChute.get(FACING) == direction; + diagonalInputChute.getBlock() instanceof ChuteBlock && diagonalInputChute.getValue(FACING) == direction; connections.put(direction, value); if (value) amtConnections++; @@ -133,22 +135,22 @@ public class ChuteBlock extends AbstractChuteBlock { boolean noConnections = amtConnections == 0; if (vertical) - return state.with(SHAPE, - noConnections ? state.get(SHAPE) == Shape.WINDOW ? Shape.WINDOW : Shape.NORMAL : Shape.INTERSECTION); + return state.setValue(SHAPE, + noConnections ? state.getValue(SHAPE) == Shape.WINDOW ? Shape.WINDOW : Shape.NORMAL : Shape.INTERSECTION); if (noConnections) - return state.with(SHAPE, Shape.INTERSECTION); + return state.setValue(SHAPE, Shape.INTERSECTION); if (connections.get(Direction.NORTH) && connections.get(Direction.SOUTH)) - return state.with(SHAPE, Shape.INTERSECTION); + return state.setValue(SHAPE, Shape.INTERSECTION); if (connections.get(Direction.EAST) && connections.get(Direction.WEST)) - return state.with(SHAPE, Shape.INTERSECTION); + return state.setValue(SHAPE, Shape.INTERSECTION); if (amtConnections == 1 && connections.get(facing) && !(getChuteFacing(above) == Direction.DOWN) && !(above.getBlock() instanceof FunnelBlock && FunnelBlock.getFunnelFacing(above) == Direction.DOWN)) - return state.with(SHAPE, Shape.NORMAL); - return state.with(SHAPE, Shape.INTERSECTION); + return state.setValue(SHAPE, Shape.NORMAL); + return state.setValue(SHAPE, Shape.INTERSECTION); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteGenerator.java index 5b07d8328..641bfde5e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteGenerator.java @@ -20,14 +20,14 @@ public class ChuteGenerator extends SpecialBlockStateGen { @Override protected int getYRotation(BlockState state) { - return horizontalAngle(state.get(ChuteBlock.FACING)); + return horizontalAngle(state.getValue(ChuteBlock.FACING)); } @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - boolean horizontal = state.get(ChuteBlock.FACING) != Direction.DOWN; - ChuteBlock.Shape shape = state.get(ChuteBlock.SHAPE); + boolean horizontal = state.getValue(ChuteBlock.FACING) != Direction.DOWN; + ChuteBlock.Shape shape = state.getValue(ChuteBlock.SHAPE); if (!horizontal) return shape == Shape.NORMAL ? AssetLookup.partialBaseModel(ctx, prov) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteItem.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteItem.java index 9cc13fc30..a9686aeea 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteItem.java @@ -9,6 +9,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.item.Item.Properties; + public class ChuteItem extends BlockItem { public ChuteItem(Block p_i48527_1_, Properties p_i48527_2_) { @@ -16,39 +18,39 @@ public class ChuteItem extends BlockItem { } @Override - public ActionResultType tryPlace(BlockItemUseContext context) { - Direction face = context.getFace(); - BlockPos placedOnPos = context.getPos() - .offset(face.getOpposite()); - World world = context.getWorld(); + public ActionResultType place(BlockItemUseContext context) { + Direction face = context.getClickedFace(); + BlockPos placedOnPos = context.getClickedPos() + .relative(face.getOpposite()); + World world = context.getLevel(); BlockState placedOnState = world.getBlockState(placedOnPos); - if (!AbstractChuteBlock.isChute(placedOnState) || context.shouldCancelInteraction()) - return super.tryPlace(context); + if (!AbstractChuteBlock.isChute(placedOnState) || context.isSecondaryUseActive()) + return super.place(context); if (face.getAxis() .isVertical()) - return super.tryPlace(context); + return super.place(context); - BlockPos correctPos = context.getPos() - .up(); + BlockPos correctPos = context.getClickedPos() + .above(); BlockState blockState = world.getBlockState(correctPos); if (blockState.getMaterial() .isReplaceable()) - context = BlockItemUseContext.func_221536_a(context, correctPos, face); + context = BlockItemUseContext.at(context, correctPos, face); else { - if (!(blockState.getBlock() instanceof ChuteBlock) || world.isRemote) + if (!(blockState.getBlock() instanceof ChuteBlock) || world.isClientSide) return ActionResultType.FAIL; AbstractChuteBlock block = (AbstractChuteBlock) blockState.getBlock(); if (block.getFacing(blockState) == Direction.DOWN) { - world.setBlockState(correctPos, block.updateChuteState(blockState.with(ChuteBlock.FACING, face), - world.getBlockState(correctPos.up()), world, correctPos)); + world.setBlockAndUpdate(correctPos, block.updateChuteState(blockState.setValue(ChuteBlock.FACING, face), + world.getBlockState(correctPos.above()), world, correctPos)); return ActionResultType.SUCCESS; } return ActionResultType.FAIL; } - return super.tryPlace(context); + return super.place(context); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteRenderer.java index 4d1540b68..0a17faf54 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteRenderer.java @@ -25,9 +25,9 @@ public class ChuteRenderer extends SafeTileEntityRenderer { if (te.item.isEmpty()) return; BlockState blockState = te.getBlockState(); - if (blockState.get(ChuteBlock.FACING) != Direction.DOWN) + if (blockState.getValue(ChuteBlock.FACING) != Direction.DOWN) return; - if (blockState.get(ChuteBlock.SHAPE) != Shape.WINDOW + if (blockState.getValue(ChuteBlock.SHAPE) != Shape.WINDOW && (te.bottomPullDistance == 0 || te.itemPosition.get(partialTicks) > .5f)) return; @@ -39,7 +39,7 @@ public class ChuteRenderer extends SafeTileEntityRenderer { ItemRenderer itemRenderer = Minecraft.getInstance() .getItemRenderer(); MatrixStacker msr = MatrixStacker.of(ms); - ms.push(); + ms.pushPose(); msr.centre(); float itemScale = .5f; float itemPosition = te.itemPosition.get(partialTicks); @@ -47,8 +47,8 @@ public class ChuteRenderer extends SafeTileEntityRenderer { ms.scale(itemScale, itemScale, itemScale); msr.rotateX(itemPosition * 180); msr.rotateY(itemPosition * 180); - itemRenderer.renderItem(te.item, TransformType.FIXED, light, overlay, ms, buffer); - ms.pop(); + itemRenderer.renderStatic(te.item, TransformType.FIXED, light, overlay, ms, buffer); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteShapes.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteShapes.java index 6e069aeae..e70ed6621 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteShapes.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteShapes.java @@ -19,24 +19,24 @@ public class ChuteShapes { static Map cache = new HashMap<>(); static Map collisionCache = new HashMap<>(); - public static final VoxelShape INTERSECTION_MASK = Block.makeCuboidShape(0, -16, 0, 16, 16, 16); - public static final VoxelShape COLLISION_MASK = Block.makeCuboidShape(0, 0, 0, 16, 24, 16); + public static final VoxelShape INTERSECTION_MASK = Block.box(0, -16, 0, 16, 16, 16); + public static final VoxelShape COLLISION_MASK = Block.box(0, 0, 0, 16, 24, 16); public static VoxelShape createShape(BlockState state) { if (AllBlocks.SMART_CHUTE.has(state)) return AllShapes.SMART_CHUTE; - Direction direction = state.get(ChuteBlock.FACING); - Shape shape = state.get(ChuteBlock.SHAPE); + Direction direction = state.getValue(ChuteBlock.FACING); + Shape shape = state.getValue(ChuteBlock.SHAPE); boolean intersection = shape == Shape.INTERSECTION; if (direction == Direction.DOWN) - return intersection ? VoxelShapes.fullCube() : AllShapes.CHUTE; + return intersection ? VoxelShapes.block() : AllShapes.CHUTE; - VoxelShape combineWith = intersection ? VoxelShapes.fullCube() : VoxelShapes.empty(); + VoxelShape combineWith = intersection ? VoxelShapes.block() : VoxelShapes.empty(); VoxelShape result = VoxelShapes.or(combineWith, AllShapes.CHUTE_SLOPE.get(direction)); if (intersection) - result = VoxelShapes.combine(INTERSECTION_MASK, result, IBooleanFunction.AND); + result = VoxelShapes.joinUnoptimized(INTERSECTION_MASK, result, IBooleanFunction.AND); return result; } @@ -51,18 +51,18 @@ public class ChuteShapes { public static VoxelShape getCollisionShape(BlockState state) { if (collisionCache.containsKey(state)) return collisionCache.get(state); - VoxelShape createdShape = VoxelShapes.combine(COLLISION_MASK, getShape(state), IBooleanFunction.AND); + VoxelShape createdShape = VoxelShapes.joinUnoptimized(COLLISION_MASK, getShape(state), IBooleanFunction.AND); collisionCache.put(state, createdShape); return createdShape; } - public static final VoxelShape PANEL = Block.makeCuboidShape(1, -15, 0, 15, 4, 1); + public static final VoxelShape PANEL = Block.box(1, -15, 0, 15, 4, 1); public static VoxelShape createSlope() { VoxelShape shape = VoxelShapes.empty(); for (int i = 0; i < 16; i++) { float offset = i / 16f; - shape = VoxelShapes.combineAndSimplify(shape, PANEL.withOffset(0, offset, offset), IBooleanFunction.OR); + shape = VoxelShapes.join(shape, PANEL.move(0, offset, offset), IBooleanFunction.OR); } return shape; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java index fbbffa98f..f18679690 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java @@ -110,7 +110,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor private boolean canDirectlyInsert() { BlockState blockState = getBlockState(); - BlockState blockStateAbove = world.getBlockState(pos.up()); + BlockState blockStateAbove = level.getBlockState(worldPosition.above()); if (!AbstractChuteBlock.isChute(blockState)) return false; if (AbstractChuteBlock.getChuteFacing(blockStateAbove) == Direction.DOWN) @@ -128,18 +128,18 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor @Override public AxisAlignedBB getRenderBoundingBox() { - return new AxisAlignedBB(pos).expand(0, -3, 0); + return new AxisAlignedBB(worldPosition).expandTowards(0, -3, 0); } @Override public void tick() { super.tick(); - if (!world.isRemote) + if (!level.isClientSide) canPickUpItems = canDirectlyInsert(); float itemMotion = getItemMotion(); - if (itemMotion != 0 && world != null && world.isRemote) + if (itemMotion != 0 && level != null && level.isClientSide) spawnParticles(itemMotion); tickAirStreams(itemMotion); @@ -158,7 +158,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (!handleDownwardOutput(true)) nextOffset = .5f; else if (nextOffset < 0) { - handleDownwardOutput(world.isRemote && !isVirtual()); + handleDownwardOutput(level.isClientSide && !isVirtual()); nextOffset = itemPosition.value; } } @@ -167,7 +167,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (!handleUpwardOutput(true)) nextOffset = .5f; else if (nextOffset > 1) { - handleUpwardOutput(world.isRemote && !isVirtual()); + handleUpwardOutput(level.isClientSide && !isVirtual()); nextOffset = itemPosition.value; } } @@ -179,7 +179,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor private void updateAirFlow(float itemSpeed) { updateAirFlow = false; // airCurrent.rebuild(); - if (itemSpeed > 0 && world != null && !world.isRemote) { + if (itemSpeed > 0 && level != null && !level.isClientSide) { float speed = pull - push; beltBelow = null; @@ -193,15 +193,15 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor else maxPullDistance = MathHelper.lerp(speed / 32, 0, 1); - if (AbstractChuteBlock.isChute(world.getBlockState(pos.down()))) + if (AbstractChuteBlock.isChute(level.getBlockState(worldPosition.below()))) maxPullDistance = 0; float flowLimit = maxPullDistance; if (flowLimit > 0) - flowLimit = AirCurrent.getFlowLimit(world, pos, maxPullDistance, Direction.DOWN); + flowLimit = AirCurrent.getFlowLimit(level, worldPosition, maxPullDistance, Direction.DOWN); for (int i = 1; i <= flowLimit + 1; i++) { TransportedItemStackHandlerBehaviour behaviour = - TileEntityBehaviour.get(world, pos.down(i), TransportedItemStackHandlerBehaviour.TYPE); + TileEntityBehaviour.get(level, worldPosition.below(i), TransportedItemStackHandlerBehaviour.TYPE); if (behaviour == null) continue; beltBelow = behaviour; @@ -216,29 +216,29 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor private void findEntities(float itemSpeed) { // if (getSpeed() != 0) // airCurrent.findEntities(); - if (bottomPullDistance <= 0 && !getItem().isEmpty() || itemSpeed <= 0 || world == null || world.isRemote) + if (bottomPullDistance <= 0 && !getItem().isEmpty() || itemSpeed <= 0 || level == null || level.isClientSide) return; if (!canCollectItemsFromBelow()) return; - Vector3d center = VecHelper.getCenterOf(pos); + Vector3d center = VecHelper.getCenterOf(worldPosition); AxisAlignedBB searchArea = - new AxisAlignedBB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).grow(.45f); - for (ItemEntity itemEntity : world.getEntitiesWithinAABB(ItemEntity.class, searchArea)) { + new AxisAlignedBB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f); + for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, searchArea)) { if (!itemEntity.isAlive()) continue; ItemStack entityItem = itemEntity.getItem(); if (!canAcceptItem(entityItem)) continue; setItem(entityItem.copy(), (float) (itemEntity.getBoundingBox() - .getCenter().y - pos.getY())); + .getCenter().y - worldPosition.getY())); itemEntity.remove(); - AllTriggers.triggerForNearbyPlayers(AllTriggers.UPWARD_CHUTE, world, pos, 5); + AllTriggers.triggerForNearbyPlayers(AllTriggers.UPWARD_CHUTE, level, worldPosition, 5); break; } } private void extractFromBelt(float itemSpeed) { - if (itemSpeed <= 0 || world == null || world.isRemote) + if (itemSpeed <= 0 || level == null || level.isClientSide) return; if (getItem().isEmpty() && beltBelow != null) { beltBelow.handleCenteredProcessingOnAllItems(.5f, ts -> { @@ -252,7 +252,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } private void tickAirStreams(float itemSpeed) { - if (!world.isRemote && airCurrentUpdateCooldown-- <= 0) { + if (!level.isClientSide && airCurrentUpdateCooldown-- <= 0) { airCurrentUpdateCooldown = AllConfigs.SERVER.kinetics.fanBlockCheckRate.get(); updateAirFlow = true; } @@ -278,7 +278,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor private void spawnParticles(float itemMotion) { // todo: reduce the amount of particles - if (world == null) + if (level == null) return; BlockState blockState = getBlockState(); boolean up = itemMotion > 0; @@ -288,7 +288,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (push == 0 && pull == 0) return; - if (up && AbstractChuteBlock.isOpenChute(blockState) && BlockHelper.noCollisionInSpace(world, pos.up())) + if (up && AbstractChuteBlock.isOpenChute(blockState) && BlockHelper.noCollisionInSpace(level, worldPosition.above())) spawnAirFlow(1, 2, absMotion, .5f); if (AbstractChuteBlock.getChuteFacing(blockState) != Direction.DOWN) @@ -297,7 +297,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (AbstractChuteBlock.isTransparentChute(blockState)) spawnAirFlow(up ? 0 : 1, up ? 1 : 0, absMotion, 1); - if (!up && BlockHelper.noCollisionInSpace(world, pos.down())) + if (!up && BlockHelper.noCollisionInSpace(level, worldPosition.below())) spawnAirFlow(0, -1, absMotion, .5f); if (up && canCollectItemsFromBelow() && bottomPullDistance > 0) { @@ -307,17 +307,17 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } private void spawnAirFlow(float verticalStart, float verticalEnd, float motion, float drag) { - if (world == null) + if (level == null) return; AirParticleData airParticleData = new AirParticleData(drag, motion); - Vector3d origin = Vector3d.of(pos); + Vector3d origin = Vector3d.atLowerCornerOf(worldPosition); float xOff = Create.RANDOM.nextFloat() * .5f + .25f; float zOff = Create.RANDOM.nextFloat() * .5f + .25f; Vector3d v = origin.add(xOff, verticalStart, zOff); Vector3d d = origin.add(xOff, verticalEnd, zOff) .subtract(v); if (Create.RANDOM.nextFloat() < 2 * motion) - world.addOptionalParticle(airParticleData, v.x, v.y, v.z, d.x, d.y, d.z); + level.addAlwaysVisibleParticle(airParticleData, v.x, v.y, v.z, d.x, d.y, d.z); } private void handleInputFromAbove() { @@ -350,12 +350,12 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor ChuteTileEntity targetChute = getTargetChute(blockState); Direction direction = AbstractChuteBlock.getChuteFacing(blockState); - if (world == null) + if (level == null) return false; if (!capBelow.isPresent()) capBelow = grabCapability(Direction.DOWN); if (capBelow.isPresent()) { - if (world.isRemote && !isVirtual()) + if (level.isClientSide && !isVirtual()) return false; ItemStack remainder = ItemHandlerHelper.insertItemStacked(capBelow.orElse(null), item, simulate); ItemStack held = getItem(); @@ -381,18 +381,18 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor .isHorizontal()) return false; - if (FunnelBlock.getFunnelFacing(world.getBlockState(pos.down())) == Direction.DOWN) + if (FunnelBlock.getFunnelFacing(level.getBlockState(worldPosition.below())) == Direction.DOWN) return false; - if (Block.hasSolidSideOnTop(world, pos.down())) + if (Block.canSupportRigidBlock(level, worldPosition.below())) return false; if (!simulate) { - Vector3d dropVec = VecHelper.getCenterOf(pos) + Vector3d dropVec = VecHelper.getCenterOf(worldPosition) .add(0, -12 / 16f, 0); - ItemEntity dropped = new ItemEntity(world, dropVec.x, dropVec.y, dropVec.z, item.copy()); - dropped.setDefaultPickupDelay(); - dropped.setMotion(0, -.25f, 0); - world.addEntity(dropped); + ItemEntity dropped = new ItemEntity(level, dropVec.x, dropVec.y, dropVec.z, item.copy()); + dropped.setDefaultPickUpDelay(); + dropped.setDeltaMovement(0, -.25f, 0); + level.addFreshEntity(dropped); setItem(ItemStack.EMPTY); } @@ -400,16 +400,16 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } private boolean handleUpwardOutput(boolean simulate) { - BlockState stateAbove = world.getBlockState(pos.up()); + BlockState stateAbove = level.getBlockState(worldPosition.above()); - if (world == null) + if (level == null) return false; if (AbstractChuteBlock.isOpenChute(getBlockState())) { if (!capAbove.isPresent()) capAbove = grabCapability(Direction.UP); if (capAbove.isPresent()) { - if (world.isRemote && !isVirtual() && !ChuteBlock.isChute(stateAbove)) + if (level.isClientSide && !isVirtual() && !ChuteBlock.isChute(stateAbove)) return false; int countBefore = item.getCount(); ItemStack remainder = ItemHandlerHelper.insertItemStacked(capAbove.orElse(null), item, simulate); @@ -440,20 +440,20 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return true; } - if (FunnelBlock.getFunnelFacing(world.getBlockState(pos.up())) == Direction.UP) + if (FunnelBlock.getFunnelFacing(level.getBlockState(worldPosition.above())) == Direction.UP) return false; - if (BlockHelper.hasBlockSolidSide(stateAbove, world, pos.up(), Direction.DOWN)) + if (BlockHelper.hasBlockSolidSide(stateAbove, level, worldPosition.above(), Direction.DOWN)) return false; if (!inputChutes.isEmpty()) return false; if (!simulate) { - Vector3d dropVec = VecHelper.getCenterOf(pos) + Vector3d dropVec = VecHelper.getCenterOf(worldPosition) .add(0, 8 / 16f, 0); - ItemEntity dropped = new ItemEntity(world, dropVec.x, dropVec.y, dropVec.z, item.copy()); - dropped.setDefaultPickupDelay(); - dropped.setMotion(0, getItemMotion() * 2, 0); - world.addEntity(dropped); + ItemEntity dropped = new ItemEntity(level, dropVec.x, dropVec.y, dropVec.z, item.copy()); + dropped.setDefaultPickUpDelay(); + dropped.setDeltaMovement(0, getItemMotion() * 2, 0); + level.addFreshEntity(dropped); setItem(ItemStack.EMPTY); } return true; @@ -476,10 +476,10 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } private LazyOptional grabCapability(Direction side) { - BlockPos pos = this.pos.offset(side); - if (world == null) + BlockPos pos = this.worldPosition.relative(side); + if (level == null) return LazyOptional.empty(); - TileEntity te = world.getTileEntity(pos); + TileEntity te = level.getBlockEntity(pos); if (te == null) return LazyOptional.empty(); if (te instanceof ChuteTileEntity) { @@ -496,13 +496,13 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor public void setItem(ItemStack stack, float insertionPos) { item = stack; itemPosition.lastValue = itemPosition.value = insertionPos; - markDirty(); + setChanged(); sendData(); } @Override - public void remove() { - super.remove(); + public void setRemoved() { + super.setRemoved(); if (lazyHandler != null) lazyHandler.invalidate(); } @@ -520,7 +520,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor @Override protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { ItemStack previousItem = item; - item = ItemStack.read(compound.getCompound("Item")); + item = ItemStack.of(compound.getCompound("Item")); itemPosition.lastValue = itemPosition.value = compound.getFloat("ItemPosition"); pull = compound.getFloat("Pull"); push = compound.getFloat("Push"); @@ -529,13 +529,13 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor // if (clientPacket) // airCurrent.rebuild(); - if (hasWorld() && world != null && world.isRemote && !previousItem.equals(item, false) && !item.isEmpty()) { - if (world.rand.nextInt(3) != 0) + if (hasLevel() && level != null && level.isClientSide && !previousItem.equals(item, false) && !item.isEmpty()) { + if (level.random.nextInt(3) != 0) return; - Vector3d p = VecHelper.getCenterOf(pos); - p = VecHelper.offsetRandomly(p, world.rand, .5f); + Vector3d p = VecHelper.getCenterOf(worldPosition); + p = VecHelper.offsetRandomly(p, level.random, .5f); Vector3d m = Vector3d.ZERO; - world.addParticle(new ItemParticleData(ParticleTypes.ITEM, item), p.x, p.y, p.z, m.x, m.y, m.z); + level.addParticle(new ItemParticleData(ParticleTypes.ITEM, item), p.x, p.y, p.z, m.x, m.y, m.z); } } @@ -552,9 +552,9 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor public void onRemoved(BlockState chuteState) { ChuteTileEntity targetChute = getTargetChute(chuteState); List inputChutes = getInputChutes(); - if (!item.isEmpty() && world != null) - InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), item); - remove(); + if (!item.isEmpty() && level != null) + InventoryHelper.dropItemStack(level, worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), item); + setRemoved(); if (targetChute != null) { targetChute.updatePull(); targetChute.propagatePush(); @@ -563,7 +563,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } public void onAdded() { - updateContainingBlockInfo(); + clearCache(); updatePull(); ChuteTileEntity targetChute = getTargetChute(getBlockState()); if (targetChute != null) @@ -600,10 +600,10 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } protected float calculatePull() { - BlockState blockStateAbove = world.getBlockState(pos.up()); + BlockState blockStateAbove = level.getBlockState(worldPosition.above()); if (AllBlocks.ENCASED_FAN.has(blockStateAbove) - && blockStateAbove.get(EncasedFanBlock.FACING) == Direction.DOWN) { - TileEntity te = world.getTileEntity(pos.up()); + && blockStateAbove.getValue(EncasedFanBlock.FACING) == Direction.DOWN) { + TileEntity te = level.getBlockEntity(worldPosition.above()); if (te instanceof EncasedFanTileEntity && !te.isRemoved()) { EncasedFanTileEntity fan = (EncasedFanTileEntity) te; return fan.getSpeed(); @@ -621,11 +621,11 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } protected float calculatePush(int branchCount) { - if (world == null) + if (level == null) return 0; - BlockState blockStateBelow = world.getBlockState(pos.down()); - if (AllBlocks.ENCASED_FAN.has(blockStateBelow) && blockStateBelow.get(EncasedFanBlock.FACING) == Direction.UP) { - TileEntity te = world.getTileEntity(pos.down()); + BlockState blockStateBelow = level.getBlockState(worldPosition.below()); + if (AllBlocks.ENCASED_FAN.has(blockStateBelow) && blockStateBelow.getValue(EncasedFanBlock.FACING) == Direction.UP) { + TileEntity te = level.getBlockEntity(worldPosition.below()); if (te instanceof EncasedFanTileEntity && !te.isRemoved()) { EncasedFanTileEntity fan = (EncasedFanTileEntity) te; return fan.getSpeed(); @@ -640,19 +640,19 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor @Nullable private ChuteTileEntity getTargetChute(BlockState state) { - if (world == null) + if (level == null) return null; Direction targetDirection = AbstractChuteBlock.getChuteFacing(state); if (targetDirection == null) return null; - BlockPos chutePos = pos.down(); + BlockPos chutePos = worldPosition.below(); if (targetDirection.getAxis() .isHorizontal()) - chutePos = chutePos.offset(targetDirection.getOpposite()); - BlockState chuteState = world.getBlockState(chutePos); + chutePos = chutePos.relative(targetDirection.getOpposite()); + BlockState chuteState = level.getBlockState(chutePos); if (!AbstractChuteBlock.isChute(chuteState)) return null; - TileEntity te = world.getTileEntity(chutePos); + TileEntity te = level.getBlockEntity(chutePos); if (te instanceof ChuteTileEntity) return (ChuteTileEntity) te; return null; @@ -671,18 +671,18 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor @Nullable private ChuteTileEntity getInputChute(Direction direction) { - if (world == null || direction == Direction.DOWN) + if (level == null || direction == Direction.DOWN) return null; direction = direction.getOpposite(); - BlockPos chutePos = pos.up(); + BlockPos chutePos = worldPosition.above(); if (direction.getAxis() .isHorizontal()) - chutePos = chutePos.offset(direction); - BlockState chuteState = world.getBlockState(chutePos); + chutePos = chutePos.relative(direction); + BlockState chuteState = level.getBlockState(chutePos); Direction chuteFacing = AbstractChuteBlock.getChuteFacing(chuteState); if (chuteFacing != direction) return null; - TileEntity te = world.getTileEntity(chutePos); + TileEntity te = level.getBlockEntity(chutePos); if (te instanceof ChuteTileEntity && !te.isRemoved()) return (ChuteTileEntity) te; return null; @@ -690,29 +690,29 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { boolean downward = getItemMotion() < 0; - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.chute.header"))); if (pull == 0 && push == 0) - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.chute.no_fans_attached")) - .formatted(TextFormatting.GRAY)); + .withStyle(TextFormatting.GRAY)); if (pull != 0) - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.chute.fans_" + (pull > 0 ? "pull_up" : "push_down")) - .formatted(TextFormatting.GRAY))); + .withStyle(TextFormatting.GRAY))); if (push != 0) - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.chute.fans_" + (push > 0 ? "push_up" : "pull_down")) - .formatted(TextFormatting.GRAY))); - tooltip.add(componentSpacing.copy() + .withStyle(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy() .append("-> ") .append(Lang.translate("tooltip.chute.items_move_" + (downward ? "down" : "up")) - .formatted(TextFormatting.YELLOW))); + .withStyle(TextFormatting.YELLOW))); if (!item.isEmpty()) { - tooltip.add(componentSpacing.copy() + tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.chute.contains", new TranslationTextComponent(item.getItem() - .getTranslationKey(item)).getString(), item.getCount())) - .formatted(TextFormatting.GREEN)); + .getDescriptionId(item)).getString(), item.getCount())) + .withStyle(TextFormatting.GREEN)); } return true; } 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 55b0b2d52..1ab93b740 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 @@ -17,11 +17,13 @@ import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class SmartChuteBlock extends AbstractChuteBlock { public SmartChuteBlock(Properties p_i48440_1_) { super(p_i48440_1_); - setDefaultState(getDefaultState().with(POWERED, true)); + registerDefaultState(defaultBlockState().setValue(POWERED, true)); } public static final BooleanProperty POWERED = BlockStateProperties.POWERED; @@ -30,29 +32,29 @@ public class SmartChuteBlock extends AbstractChuteBlock { public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving); - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - if (!worldIn.getPendingBlockTicks() - .isTickPending(pos, this)) - worldIn.getPendingBlockTicks() + if (!worldIn.getBlockTicks() + .willTickThisTick(pos, this)) + worldIn.getBlockTicks() .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); + public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + boolean previouslyPowered = state.getValue(POWERED); + if (previouslyPowered != worldIn.hasNeighborSignal(pos)) + worldIn.setBlock(pos, state.cycle(POWERED), 2); } @Override public BlockState getStateForPlacement(BlockItemUseContext p_196258_1_) { - return super.getStateForPlacement(p_196258_1_).with(POWERED, p_196258_1_.getWorld() - .isBlockPowered(p_196258_1_.getPos())); + return super.getStateForPlacement(p_196258_1_).setValue(POWERED, p_196258_1_.getLevel() + .hasNeighborSignal(p_196258_1_.getClickedPos())); } @Override - public boolean isValidPosition(BlockState state, IWorldReader world, BlockPos pos) { + public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { return true; } @@ -62,8 +64,8 @@ public class SmartChuteBlock extends AbstractChuteBlock { } @Override - protected void fillStateContainer(Builder p_206840_1_) { - super.fillStateContainer(p_206840_1_.add(POWERED)); + protected void createBlockStateDefinition(Builder p_206840_1_) { + super.createBlockStateDefinition(p_206840_1_.add(POWERED)); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteTileEntity.java index 585c7f10b..da88a5a24 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteTileEntity.java @@ -39,7 +39,7 @@ public class SmartChuteTileEntity extends ChuteTileEntity { @Override protected boolean canCollectItemsFromBelow() { BlockState blockState = getBlockState(); - return blockState.contains(SmartChuteBlock.POWERED) && !blockState.get(SmartChuteBlock.POWERED); + return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED); } @Override @@ -51,8 +51,8 @@ public class SmartChuteTileEntity extends ChuteTileEntity { private boolean isExtracting() { boolean up = getItemMotion() < 0; - BlockPos chutePos = pos.offset(up ? Direction.UP : Direction.DOWN); - BlockState blockState = world.getBlockState(chutePos); + BlockPos chutePos = worldPosition.relative(up ? Direction.UP : Direction.DOWN); + BlockState blockState = level.getBlockState(chutePos); return !AbstractChuteBlock.isChute(blockState) && !blockState.getMaterial() .isReplaceable(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBehaviour.java index ecac9759c..8c8d29659 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBehaviour.java @@ -76,20 +76,20 @@ public class DepotBehaviour extends TileEntityBehaviour { public void tick() { super.tick(); - World world = tileEntity.getWorld(); + World world = tileEntity.getLevel(); for (Iterator iterator = incoming.iterator(); iterator.hasNext();) { TransportedItemStack ts = iterator.next(); if (!tick(ts)) continue; - if (world.isRemote && !tileEntity.isVirtual()) + if (world.isClientSide && !tileEntity.isVirtual()) continue; if (heldItem == null) { heldItem = ts; } else { if (!ItemHelper.canItemStackAmountsStack(heldItem.stack, ts.stack)) { - Vector3d vec = VecHelper.getCenterOf(tileEntity.getPos()); - InventoryHelper.spawnItemStack(tileEntity.getWorld(), vec.x, vec.y + .5f, vec.z, ts.stack); + Vector3d vec = VecHelper.getCenterOf(tileEntity.getBlockPos()); + InventoryHelper.dropItemStack(tileEntity.getLevel(), vec.x, vec.y + .5f, vec.z, ts.stack); } else { heldItem.stack.grow(ts.stack.getCount()); } @@ -103,15 +103,15 @@ public class DepotBehaviour extends TileEntityBehaviour { if (!tick(heldItem)) return; - BlockPos pos = tileEntity.getPos(); + BlockPos pos = tileEntity.getBlockPos(); - if (world.isRemote) + if (world.isClientSide) return; if (handleBeltFunnelOutput()) return; BeltProcessingBehaviour processingBehaviour = - TileEntityBehaviour.get(world, pos.up(2), BeltProcessingBehaviour.TYPE); + TileEntityBehaviour.get(world, pos.above(2), BeltProcessingBehaviour.TYPE); if (processingBehaviour == null) return; if (!heldItem.locked && BeltProcessingBehaviour.isBlocked(world, pos)) @@ -145,7 +145,7 @@ public class DepotBehaviour extends TileEntityBehaviour { } private boolean handleBeltFunnelOutput() { - BlockState funnel = getWorld().getBlockState(getPos().up()); + BlockState funnel = getWorld().getBlockState(getPos().above()); Direction funnelFacing = AbstractFunnelBlock.getFunnelFacing(funnel); if (funnelFacing == null || !canFunnelsPullFrom.test(funnelFacing.getOpposite())) return false; @@ -356,8 +356,8 @@ public class DepotBehaviour extends TileEntityBehaviour { continue; } ItemStack remainder = ItemHandlerHelper.insertItemStacked(processingOutputBuffer, added.stack, false); - Vector3d vec = VecHelper.getCenterOf(tileEntity.getPos()); - InventoryHelper.spawnItemStack(tileEntity.getWorld(), vec.x, vec.y + .5f, vec.z, remainder); + Vector3d vec = VecHelper.getCenterOf(tileEntity.getBlockPos()); + InventoryHelper.dropItemStack(tileEntity.getLevel(), vec.x, vec.y + .5f, vec.z, remainder); } if (dirty) @@ -378,7 +378,7 @@ public class DepotBehaviour extends TileEntityBehaviour { private Vector3d getWorldPositionOf(TransportedItemStack transported) { Vector3d offsetVec = new Vector3d(.5f, 14 / 16f, .5f); - return offsetVec.add(Vector3d.of(tileEntity.getPos())); + return offsetVec.add(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBlock.java index b9852efb9..ca14a75fe 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBlock.java @@ -23,6 +23,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class DepotBlock extends Block implements ITE, IWrenchable { @@ -53,34 +55,34 @@ public class DepotBlock extends Block implements ITE, IWrenchab } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { return SharedDepotBlockMethods.onUse(state, world, pos, player, hand, ray); } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { SharedDepotBlockMethods.onReplaced(state, worldIn, pos, newState, isMoving); } @Override - public void onLanded(IBlockReader worldIn, Entity entityIn) { - super.onLanded(worldIn, entityIn); + public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + super.updateEntityAfterFallOn(worldIn, entityIn); SharedDepotBlockMethods.onLanded(worldIn, entityIn); } @Override - public boolean hasComparatorInputOverride(BlockState state) { + public boolean hasAnalogOutputSignal(BlockState state) { return true; } @Override - public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { return SharedDepotBlockMethods.getComparatorInputOverride(blockState, worldIn, pos); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotRenderer.java index 457359749..c60f2db6f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotRenderer.java @@ -39,9 +39,9 @@ public class DepotRenderer extends SafeTileEntityRenderer { TransportedItemStack transported = depotBehaviour.heldItem; MatrixStacker msr = MatrixStacker.of(ms); - Vector3d itemPosition = VecHelper.getCenterOf(te.getPos()); + Vector3d itemPosition = VecHelper.getCenterOf(te.getBlockPos()); - ms.push(); + ms.pushPose(); ms.translate(.5f, 15 / 16f, .5f); if (transported != null) @@ -49,17 +49,17 @@ public class DepotRenderer extends SafeTileEntityRenderer { // Render main items for (TransportedItemStack tis : depotBehaviour.incoming) { - ms.push(); + ms.pushPose(); msr.nudge(0); float offset = MathHelper.lerp(partialTicks, tis.prevBeltPosition, tis.beltPosition); float sideOffset = MathHelper.lerp(partialTicks, tis.prevSideOffset, tis.sideOffset); if (tis.insertedFrom.getAxis() .isHorizontal()) { - Vector3d offsetVec = Vector3d.of(tis.insertedFrom.getOpposite() - .getDirectionVec()).scale(.5f - offset); + Vector3d offsetVec = Vector3d.atLowerCornerOf(tis.insertedFrom.getOpposite() + .getNormal()).scale(.5f - offset); ms.translate(offsetVec.x, offsetVec.y, offsetVec.z); - boolean alongX = tis.insertedFrom.rotateY() + boolean alongX = tis.insertedFrom.getClockWise() .getAxis() == Axis.X; if (!alongX) sideOffset *= -1; @@ -70,7 +70,7 @@ public class DepotRenderer extends SafeTileEntityRenderer { int angle = tis.angle; Random r = new Random(0); renderItem(ms, buffer, light, overlay, itemStack, angle, r, itemPosition); - ms.pop(); + ms.popPose(); } if (transported != null) @@ -81,7 +81,7 @@ public class DepotRenderer extends SafeTileEntityRenderer { ItemStack stack = depotBehaviour.processingOutputBuffer.getStackInSlot(i); if (stack.isEmpty()) continue; - ms.push(); + ms.pushPose(); msr.nudge(i); boolean renderUpright = BeltHelper.isItemUpright(stack); @@ -92,10 +92,10 @@ public class DepotRenderer extends SafeTileEntityRenderer { Random r = new Random(i + 1); int angle = (int) (360 * r.nextFloat()); renderItem(ms, buffer, light, overlay, stack, renderUpright ? angle + 90 : angle, r, itemPosition); - ms.pop(); + ms.popPose(); } - ms.pop(); + ms.popPose(); } public static void renderItem(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, ItemStack itemStack, @@ -105,26 +105,26 @@ public class DepotRenderer extends SafeTileEntityRenderer { MatrixStacker msr = MatrixStacker.of(ms); int count = (int) (MathHelper.log2((int) (itemStack.getCount()))) / 2; boolean renderUpright = BeltHelper.isItemUpright(itemStack); - boolean blockItem = itemRenderer.getItemModelWithOverrides(itemStack, null, null) + boolean blockItem = itemRenderer.getModel(itemStack, null, null) .isGui3d(); - ms.push(); + ms.pushPose(); msr.rotateY(angle); if (renderUpright) { - Entity renderViewEntity = Minecraft.getInstance().renderViewEntity; + Entity renderViewEntity = Minecraft.getInstance().cameraEntity; if (renderViewEntity != null) { - Vector3d positionVec = renderViewEntity.getPositionVec(); + Vector3d positionVec = renderViewEntity.position(); Vector3d vectorForOffset = itemPosition; Vector3d diff = vectorForOffset.subtract(positionVec); float yRot = (float) -MathHelper.atan2(diff.z, diff.x); - ms.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float) (yRot - Math.PI / 2))); + ms.mulPose(Vector3f.YP.rotation((float) (yRot - Math.PI / 2))); } ms.translate(0, 3 / 32d, -1 / 16f); } for (int i = 0; i <= count; i++) { - ms.push(); + ms.pushPose(); if (blockItem) ms.translate(r.nextFloat() * .0625f * i, 0, r.nextFloat() * .0625f * i); ms.scale(.5f, .5f, .5f); @@ -132,8 +132,8 @@ public class DepotRenderer extends SafeTileEntityRenderer { ms.translate(0, -3 / 16f, 0); msr.rotateX(90); } - itemRenderer.renderItem(itemStack, TransformType.FIXED, light, overlay, ms, buffer); - ms.pop(); + itemRenderer.renderStatic(itemStack, TransformType.FIXED, light, overlay, ms, buffer); + ms.popPose(); if (!renderUpright) { if (!blockItem) @@ -143,7 +143,7 @@ public class DepotRenderer extends SafeTileEntityRenderer { ms.translate(0, 0, -1 / 16f); } - ms.pop(); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorBlock.java index fcdc894a7..551d843ad 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorBlock.java @@ -32,6 +32,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class EjectorBlock extends HorizontalKineticBlock implements ITE { public EjectorBlock(Properties properties) { @@ -58,24 +60,24 @@ public class EjectorBlock extends HorizontalKineticBlock implements ITE tileEntityOptional = getTileEntityOptional(p_180658_1_, p_180658_2_); - if (tileEntityOptional.isPresent() && !p_180658_3_.bypassesLandingEffects()) { - p_180658_3_.handleFallDamage(p_180658_4_, 0.0F); + if (tileEntityOptional.isPresent() && !p_180658_3_.isSuppressingBounce()) { + p_180658_3_.causeFallDamage(p_180658_4_, 0.0F); return; } - super.onFallenUpon(p_180658_1_, p_180658_2_, p_180658_3_, p_180658_4_); + super.fallOn(p_180658_1_, p_180658_2_, p_180658_3_, p_180658_4_); } @Override - public void onLanded(IBlockReader worldIn, Entity entityIn) { - super.onLanded(worldIn, entityIn); - BlockPos position = entityIn.getBlockPos(); + public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + super.updateEntityAfterFallOn(worldIn, entityIn); + BlockPos position = entityIn.blockPosition(); if (!AllBlocks.WEIGHTED_EJECTOR.has(worldIn.getBlockState(position))) return; if (!entityIn.isAlive()) return; - if (entityIn.bypassesLandingEffects()) + if (entityIn.isSuppressingBounce()) return; if (entityIn instanceof ItemEntity) { SharedDepotBlockMethods.onLanded(worldIn, entityIn); @@ -98,41 +100,41 @@ public class EjectorBlock extends HorizontalKineticBlock implements ITE 4 / 16f) { - entityIn.setPosition(vec.x, vec.y, vec.z); + entityIn.setPos(vec.x, vec.y, vec.z); return; } } ejectorTileEntity.activate(); ejectorTileEntity.notifyUpdate(); - if (entityIn.world.isRemote) - AllPackets.channel.sendToServer(new EjectorTriggerPacket(ejectorTileEntity.getPos())); + if (entityIn.level.isClientSide) + AllPackets.channel.sendToServer(new EjectorTriggerPacket(ejectorTileEntity.getBlockPos())); } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { - if (AllItems.WRENCH.isIn(player.getHeldItem(hand))) + if (AllItems.WRENCH.isIn(player.getItemInHand(hand))) return ActionResultType.PASS; return SharedDepotBlockMethods.onUse(state, world, pos, player, hand, ray); } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { withTileEntityDo(worldIn, pos, EjectorTileEntity::dropFlyingItems); SharedDepotBlockMethods.onReplaced(state, worldIn, pos, newState, isMoving); } @Override public Axis getRotationAxis(BlockState state) { - return state.get(HORIZONTAL_FACING) - .rotateY() + return state.getValue(HORIZONTAL_FACING) + .getClockWise() .getAxis(); } @@ -152,17 +154,17 @@ public class EjectorBlock extends HorizontalKineticBlock implements ITE () -> EjectorTargetHandler.flushSettings(pos)); - return super.onBlockPlaced(pos, world, p_195943_3_, p_195943_4_, p_195943_5_); + return super.updateCustomBlockEntityTag(pos, world, p_195943_3_, p_195943_4_, p_195943_5_); } @Override - public boolean canPlayerBreakBlockWhileHolding(BlockState state, World world, BlockPos pos, + public boolean canAttackBlock(BlockState state, World world, BlockPos pos, PlayerEntity p_195938_4_) { - return !p_195938_4_.isSneaking(); + return !p_195938_4_.isShiftKeyDown(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorPlacementPacket.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorPlacementPacket.java index 3cb0bfc71..54c8e6198 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorPlacementPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorPlacementPacket.java @@ -31,7 +31,7 @@ public class EjectorPlacementPacket extends SimplePacketBase { h = buffer.readInt(); v = buffer.readInt(); pos = buffer.readBlockPos(); - facing = Direction.byIndex(buffer.readVarInt()); + facing = Direction.from3DDataValue(buffer.readVarInt()); } @Override @@ -39,7 +39,7 @@ public class EjectorPlacementPacket extends SimplePacketBase { buffer.writeInt(h); buffer.writeInt(v); buffer.writeBlockPos(pos); - buffer.writeVarInt(facing.getIndex()); + buffer.writeVarInt(facing.get3DDataValue()); } @Override @@ -50,15 +50,15 @@ public class EjectorPlacementPacket extends SimplePacketBase { .getSender(); if (player == null) return; - World world = player.world; - if (world == null || !world.isBlockPresent(pos)) + World world = player.level; + if (world == null || !world.isLoaded(pos)) return; - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); BlockState state = world.getBlockState(pos); if (tileEntity instanceof EjectorTileEntity) ((EjectorTileEntity) tileEntity).setTarget(h, v); if (AllBlocks.WEIGHTED_EJECTOR.has(state)) - world.setBlockState(pos, state.with(EjectorBlock.HORIZONTAL_FACING, facing)); + world.setBlockAndUpdate(pos, state.setValue(EjectorBlock.HORIZONTAL_FACING, facing)); }); context.get() .setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java index 1ddf7bfa7..79f8e2333 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java @@ -31,7 +31,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer { } @Override - public boolean isGlobalRenderer(KineticTileEntity p_188185_1_) { + public boolean shouldRenderOffScreen(KineticTileEntity p_188185_1_) { return true; } @@ -41,11 +41,11 @@ public class EjectorRenderer extends KineticTileEntityRenderer { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); EjectorTileEntity ejector = (EjectorTileEntity) te; - IVertexBuilder vertexBuilder = buffer.getBuffer(RenderType.getSolid()); + IVertexBuilder vertexBuilder = buffer.getBuffer(RenderType.solid()); float lidProgress = ((EjectorTileEntity) te).getLidProgress(partialTicks); float angle = lidProgress * 70; - if (!Backend.getInstance().canUseInstancing(te.getWorld())) { + if (!Backend.getInstance().canUseInstancing(te.getLevel())) { SuperByteBuffer model = PartialBufferer.get(AllBlockPartials.EJECTOR_TOP, te.getBlockState()); applyLidAngle(te, angle, model.matrixStacker()); model.light(light) @@ -61,9 +61,9 @@ public class EjectorRenderer extends KineticTileEntityRenderer { if (time > maxTime) continue; - ms.push(); + ms.pushPose(); Vector3d launchedItemLocation = ejector.getLaunchedItemLocation(time); - msr.translate(launchedItemLocation.subtract(Vector3d.of(te.getPos()))); + msr.translate(launchedItemLocation.subtract(Vector3d.atLowerCornerOf(te.getBlockPos()))); Vector3d itemRotOffset = VecHelper.voxelSpace(0, 3, 0); msr.translate(itemRotOffset); msr.rotateY(AngleHelper.horizontalAngle(ejector.getFacing())); @@ -71,22 +71,22 @@ public class EjectorRenderer extends KineticTileEntityRenderer { msr.translateBack(itemRotOffset); Minecraft.getInstance() .getItemRenderer() - .renderItem(intAttached.getValue(), TransformType.GROUND, light, overlay, ms, buffer); - ms.pop(); + .renderStatic(intAttached.getValue(), TransformType.GROUND, light, overlay, ms, buffer); + ms.popPose(); } DepotBehaviour behaviour = te.getBehaviour(DepotBehaviour.TYPE); if (behaviour == null || behaviour.isEmpty()) return; - ms.push(); + ms.pushPose(); applyLidAngle(te, angle, msr); msr.centre() .rotateY(-180 - AngleHelper.horizontalAngle(te.getBlockState() - .get(EjectorBlock.HORIZONTAL_FACING))) + .getValue(EjectorBlock.HORIZONTAL_FACING))) .unCentre(); DepotRenderer.renderItemsOf(te, partialTicks, ms, buffer, light, overlay, behaviour); - ms.pop(); + ms.popPose(); } static void applyLidAngle(KineticTileEntity te, float angle, MatrixStacker matrixStacker) { @@ -96,7 +96,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer { static void applyLidAngle(KineticTileEntity te, Vector3d rotationOffset, float angle, MatrixStacker matrixStacker) { matrixStacker.centre() .rotateY(180 + AngleHelper.horizontalAngle(te.getBlockState() - .get(EjectorBlock.HORIZONTAL_FACING))) + .getValue(EjectorBlock.HORIZONTAL_FACING))) .unCentre() .translate(rotationOffset) .rotateX(-angle) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTargetHandler.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTargetHandler.java index 6fc1c45fc..3d254871b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTargetHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTargetHandler.java @@ -50,15 +50,15 @@ public class EjectorTargetHandler { return; BlockPos pos = event.getPos(); World world = event.getWorld(); - if (!world.isRemote) + if (!world.isClientSide) return; PlayerEntity player = event.getPlayer(); - if (player == null || player.isSpectator() || !player.isSneaking()) + if (player == null || player.isSpectator() || !player.isShiftKeyDown()) return; String key = "weighted_ejector.target_set"; TextFormatting colour = TextFormatting.GOLD; - player.sendStatusMessage(Lang.translate(key).formatted(colour), true); + player.displayClientMessage(Lang.translate(key).withStyle(colour), true); currentSelection = pos; launcher = null; event.setCanceled(true); @@ -69,10 +69,10 @@ public class EjectorTargetHandler { public static void leftClickingBlocksDeselectsThem(PlayerInteractEvent.LeftClickBlock event) { if (currentItem == null) return; - if (!event.getWorld().isRemote) + if (!event.getWorld().isClientSide) return; if (!event.getPlayer() - .isSneaking()) + .isShiftKeyDown()) return; BlockPos pos = event.getPos(); if (pos.equals(currentSelection)) { @@ -99,7 +99,7 @@ public class EjectorTargetHandler { Direction validTargetDirection = getValidTargetDirection(pos); if (validTargetDirection == null) { - player.sendStatusMessage(Lang.translate(key).formatted(colour), true); + player.displayClientMessage(Lang.translate(key).withStyle(colour), true); currentItem = null; currentSelection = null; return; @@ -108,9 +108,9 @@ public class EjectorTargetHandler { key = "weighted_ejector.targeting"; colour = TextFormatting.GREEN; - player.sendStatusMessage( + player.displayClientMessage( Lang.translate(key, currentSelection.getX(), currentSelection.getY(), currentSelection.getZ()) - .formatted(colour), + .withStyle(colour), true); BlockPos diff = pos.subtract(currentSelection); @@ -137,9 +137,9 @@ public class EjectorTargetHandler { return null; if (xDiff == 0) - return Direction.getFacingFromAxis(zDiff < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE, Axis.Z); + return Direction.get(zDiff < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE, Axis.Z); if (zDiff == 0) - return Direction.getFacingFromAxis(xDiff < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE, Axis.X); + return Direction.get(xDiff < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE, Axis.X); return null; } @@ -150,7 +150,7 @@ public class EjectorTargetHandler { if (player == null) return; - ItemStack heldItemMainhand = player.getHeldItemMainhand(); + ItemStack heldItemMainhand = player.getMainHandItem(); if (!AllBlocks.WEIGHTED_EJECTOR.isIn(heldItemMainhand)) { currentItem = null; } else { @@ -167,23 +167,23 @@ public class EjectorTargetHandler { protected static void drawArc() { Minecraft mc = Minecraft.getInstance(); - boolean wrench = AllItems.WRENCH.isIn(mc.player.getHeldItemMainhand()); + boolean wrench = AllItems.WRENCH.isIn(mc.player.getMainHandItem()); if (currentSelection == null) return; if (currentItem == null && !wrench) return; - RayTraceResult objectMouseOver = mc.objectMouseOver; + RayTraceResult objectMouseOver = mc.hitResult; if (!(objectMouseOver instanceof BlockRayTraceResult)) return; BlockRayTraceResult blockRayTraceResult = (BlockRayTraceResult) objectMouseOver; if (blockRayTraceResult.getType() == Type.MISS) return; - BlockPos pos = blockRayTraceResult.getPos(); + BlockPos pos = blockRayTraceResult.getBlockPos(); if (!wrench) - pos = pos.offset(blockRayTraceResult.getFace()); + pos = pos.relative(blockRayTraceResult.getDirection()); int xDiff = currentSelection.getX() - pos.getX(); int yDiff = currentSelection.getY() - pos.getY(); @@ -191,12 +191,12 @@ public class EjectorTargetHandler { int validX = Math.abs(zDiff) > Math.abs(xDiff) ? 0 : xDiff; int validZ = Math.abs(zDiff) < Math.abs(xDiff) ? 0 : zDiff; - BlockPos validPos = currentSelection.add(validX, yDiff, validZ); + BlockPos validPos = currentSelection.offset(validX, yDiff, validZ); Direction d = getValidTargetDirection(validPos); if (d == null) return; - if (launcher == null || lastHoveredBlockPos != pos.toLong()) { - lastHoveredBlockPos = pos.toLong(); + if (launcher == null || lastHoveredBlockPos != pos.asLong()) { + lastHoveredBlockPos = pos.asLong(); launcher = new EntityLauncher(Math.abs(validX + validZ), yDiff); } @@ -207,9 +207,9 @@ public class EjectorTargetHandler { int intColor = valid ? 0x9ede73 : 0xff7171; Vector3d color = ColorHelper.getRGB(intColor); RedstoneParticleData data = new RedstoneParticleData((float) color.x, (float) color.y, (float) color.z, 1); - ClientWorld world = mc.world; + ClientWorld world = mc.level; - AxisAlignedBB bb = new AxisAlignedBB(0, 0, 0, 1, 0, 1).offset(currentSelection.add(-validX, -yDiff, -validZ)); + AxisAlignedBB bb = new AxisAlignedBB(0, 0, 0, 1, 0, 1).move(currentSelection.offset(-validX, -yDiff, -validZ)); CreateClient.OUTLINER.chaseAABB("valid", bb) .colored(intColor) .lineWidth(1 / 16f); @@ -225,25 +225,25 @@ public class EjectorTargetHandler { private static void checkForWrench(ItemStack heldItem) { if (!AllItems.WRENCH.isIn(heldItem)) return; - RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver; + RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; if (!(objectMouseOver instanceof BlockRayTraceResult)) return; BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; - BlockPos pos = result.getPos(); + BlockPos pos = result.getBlockPos(); - TileEntity te = Minecraft.getInstance().world.getTileEntity(pos); + TileEntity te = Minecraft.getInstance().level.getBlockEntity(pos); if (!(te instanceof EjectorTileEntity)) { lastHoveredBlockPos = -1; currentSelection = null; return; } - if (lastHoveredBlockPos == -1 || lastHoveredBlockPos != pos.toLong()) { + if (lastHoveredBlockPos == -1 || lastHoveredBlockPos != pos.asLong()) { EjectorTileEntity ejector = (EjectorTileEntity) te; if (!ejector.getTargetPosition() - .equals(ejector.getPos())) + .equals(ejector.getBlockPos())) currentSelection = ejector.getTargetPosition(); - lastHoveredBlockPos = pos.toLong(); + lastHoveredBlockPos = pos.asLong(); launcher = null; } @@ -252,15 +252,15 @@ public class EjectorTargetHandler { } private static void drawOutline(BlockPos selection) { - World world = Minecraft.getInstance().world; + World world = Minecraft.getInstance().level; if (currentSelection == null) return; BlockPos pos = currentSelection; BlockState state = world.getBlockState(pos); VoxelShape shape = state.getShape(world, pos); - AxisAlignedBB boundingBox = shape.isEmpty() ? new AxisAlignedBB(BlockPos.ZERO) : shape.getBoundingBox(); - CreateClient.OUTLINER.showAABB("target", boundingBox.offset(pos)) + AxisAlignedBB boundingBox = shape.isEmpty() ? new AxisAlignedBB(BlockPos.ZERO) : shape.bounds(); + CreateClient.OUTLINER.showAABB("target", boundingBox.move(pos)) .colored(0xffcb74) .lineWidth(1 / 16f); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTileEntity.java index 0cf06c2f8..fc08ef89d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTileEntity.java @@ -126,7 +126,7 @@ public class EjectorTileEntity extends KineticTileEntity { } protected boolean cannotLaunch() { - return state != State.CHARGED && !(world.isRemote && state == State.LAUNCHING); + return state != State.CHARGED && !(level.isClientSide && state == State.LAUNCHING); } public void activateDeferred() { @@ -134,10 +134,10 @@ public class EjectorTileEntity extends KineticTileEntity { return; Direction facing = getFacing(); List entities = - world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos).grow(-1 / 16f, 0, -1 / 16f)); + level.getEntitiesOfClass(Entity.class, new AxisAlignedBB(worldPosition).inflate(-1 / 16f, 0, -1 / 16f)); // Launch Items - boolean doLogic = !world.isRemote || isVirtual(); + boolean doLogic = !level.isClientSide || isVirtual(); if (doLogic) launchItems(); @@ -151,33 +151,33 @@ public class EjectorTileEntity extends KineticTileEntity { entity.onGround = false; - if (isPlayerEntity != world.isRemote) + if (isPlayerEntity != level.isClientSide) continue; - entity.setPosition(pos.getX() + .5f, pos.getY() + 1, pos.getZ() + .5f); + entity.setPos(worldPosition.getX() + .5f, worldPosition.getY() + 1, worldPosition.getZ() + .5f); launcher.applyMotion(entity, facing); if (!isPlayerEntity) continue; PlayerEntity playerEntity = (PlayerEntity) entity; - if (!(playerEntity.getItemStackFromSlot(EquipmentSlotType.CHEST) + if (!(playerEntity.getItemBySlot(EquipmentSlotType.CHEST) .getItem() instanceof ElytraItem)) continue; - playerEntity.rotationYaw = facing.getHorizontalAngle(); - playerEntity.rotationPitch = -35; - playerEntity.setMotion(playerEntity.getMotion() + playerEntity.yRot = facing.toYRot(); + playerEntity.xRot = -35; + playerEntity.setDeltaMovement(playerEntity.getDeltaMovement() .scale(.75f)); deployElytra(playerEntity); - AllPackets.channel.sendToServer(new EjectorElytraPacket(pos)); + AllPackets.channel.sendToServer(new EjectorElytraPacket(worldPosition)); } if (doLogic) { lidProgress.chase(1, .8f, Chaser.EXP); state = State.LAUNCHING; - if (!world.isRemote) { - world.playSound(null, pos, SoundEvents.BLOCK_WOODEN_TRAPDOOR_CLOSE, SoundCategory.BLOCKS, .35f, 1f); - world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, .1f, 1.4f); + if (!level.isClientSide) { + level.playSound(null, worldPosition, SoundEvents.WOODEN_TRAPDOOR_CLOSE, SoundCategory.BLOCKS, .35f, 1f); + level.playSound(null, worldPosition, SoundEvents.CHEST_OPEN, SoundCategory.BLOCKS, .1f, 1.4f); } } } @@ -190,7 +190,7 @@ public class EjectorTileEntity extends KineticTileEntity { ItemStack heldItemStack = depotBehaviour.getHeldItemStack(); Direction funnelFacing = getFacing().getOpposite(); - if (AbstractFunnelBlock.getFunnelFacing(world.getBlockState(pos.up())) == funnelFacing) { + if (AbstractFunnelBlock.getFunnelFacing(level.getBlockState(worldPosition.above())) == funnelFacing) { DirectBeltInputBehaviour directOutput = getBehaviour(DirectBeltInputBehaviour.TYPE); if (depotBehaviour.heldItem != null) { @@ -199,7 +199,7 @@ public class EjectorTileEntity extends KineticTileEntity { ; else if (remainder.isEmpty()) depotBehaviour.removeHeldItem(); - else if (!remainder.isItemEqual(heldItemStack)) + else if (!remainder.sameItem(heldItemStack)) depotBehaviour.heldItem.stack = remainder; } @@ -211,7 +211,7 @@ public class EjectorTileEntity extends KineticTileEntity { ; else if (remainder.isEmpty()) iterator.remove(); - else if (!remainder.isItemEqual(stack)) + else if (!remainder.sameItem(stack)) transportedItemStack.stack = remainder; } @@ -225,14 +225,14 @@ public class EjectorTileEntity extends KineticTileEntity { return; } - if (!world.isRemote) + if (!level.isClientSide) for (Direction d : Iterate.directions) { - BlockState blockState = world.getBlockState(pos.offset(d)); + BlockState blockState = level.getBlockState(worldPosition.relative(d)); if (!(blockState.getBlock() instanceof ObserverBlock)) continue; - if (blockState.get(ObserverBlock.FACING) != d.getOpposite()) + if (blockState.getValue(ObserverBlock.FACING) != d.getOpposite()) continue; - blockState.updatePostPlacement(d.getOpposite(), blockState, world, pos.offset(d), pos); + blockState.updateShape(d.getOpposite(), blockState, level, worldPosition.relative(d), worldPosition); } if (depotBehaviour.heldItem != null) { @@ -253,7 +253,7 @@ public class EjectorTileEntity extends KineticTileEntity { } protected boolean addToLaunchedItems(ItemStack stack) { - if ((!world.isRemote || isVirtual()) && trackedItem == null && scanCooldown == 0) { + if ((!level.isClientSide || isVirtual()) && trackedItem == null && scanCooldown == 0) { scanCooldown = AllConfigs.SERVER.kinetics.ejectorScanInterval.get(); trackedItem = stack; } @@ -264,7 +264,7 @@ public class EjectorTileEntity extends KineticTileEntity { BlockState blockState = getBlockState(); if (!AllBlocks.WEIGHTED_EJECTOR.has(blockState)) return Direction.UP; - Direction facing = blockState.get(EjectorBlock.HORIZONTAL_FACING); + Direction facing = blockState.getValue(EjectorBlock.HORIZONTAL_FACING); return facing; } @@ -272,7 +272,7 @@ public class EjectorTileEntity extends KineticTileEntity { public void tick() { super.tick(); - boolean doLogic = !world.isRemote || isVirtual(); + boolean doLogic = !level.isClientSide || isVirtual(); State prevState = state; float totalTime = Math.max(3, (float) launcher.getTotalFlyingTicks()); @@ -331,8 +331,8 @@ public class EjectorTileEntity extends KineticTileEntity { int soundRate = (int) (1 / (getWindUpSpeed() * 5)) + 1; float volume = .125f; float pitch = 1.5f - lidProgress.getValue(); - if (((int) world.getGameTime()) % soundRate == 0 && doLogic) - world.playSound(null, pos, SoundEvents.BLOCK_WOODEN_BUTTON_CLICK_OFF, SoundCategory.BLOCKS, volume, + if (((int) level.getGameTime()) % soundRate == 0 && doLogic) + level.playSound(null, worldPosition, SoundEvents.WOODEN_BUTTON_CLICK_OFF, SoundCategory.BLOCKS, volume, pitch); } } @@ -349,7 +349,7 @@ public class EjectorTileEntity extends KineticTileEntity { Vector3d target = getLaunchedItemLocation(time + 1); BlockRayTraceResult rayTraceBlocks = - world.rayTraceBlocks(new RayTraceContext(source, target, BlockMode.COLLIDER, FluidMode.NONE, null)); + level.clip(new RayTraceContext(source, target, BlockMode.COLLIDER, FluidMode.NONE, null)); if (rayTraceBlocks.getType() == Type.MISS) { if (earlyTarget != null && earlyTargetTime < time + 1) { earlyTarget = null; @@ -358,19 +358,19 @@ public class EjectorTileEntity extends KineticTileEntity { return false; } - Vector3d vec = rayTraceBlocks.getHitVec(); - earlyTarget = Pair.of(vec.add(Vector3d.of(rayTraceBlocks.getFace() - .getDirectionVec()).scale(.25f)), rayTraceBlocks.getPos()); + Vector3d vec = rayTraceBlocks.getLocation(); + earlyTarget = Pair.of(vec.add(Vector3d.atLowerCornerOf(rayTraceBlocks.getDirection() + .getNormal()).scale(.25f)), rayTraceBlocks.getBlockPos()); earlyTargetTime = (float) (time + (source.distanceTo(vec) / source.distanceTo(target))); sendData(); return true; } protected void nudgeEntities() { - for (Entity entity : world.getEntitiesWithinAABB(Entity.class, - new AxisAlignedBB(pos).grow(-1 / 16f, 0, -1 / 16f))) + for (Entity entity : level.getEntitiesOfClass(Entity.class, + new AxisAlignedBB(worldPosition).inflate(-1 / 16f, 0, -1 / 16f))) if (!(entity instanceof PlayerEntity)) - entity.setPosition(entity.getX(), entity.getY() + .125f, entity.getZ()); + entity.setPos(entity.getX(), entity.getY() + .125f, entity.getZ()); } protected void ejectIfTriggered() { @@ -386,7 +386,7 @@ public class EjectorTileEntity extends KineticTileEntity { Direction funnelFacing = getFacing().getOpposite(); ItemStack held = depotBehaviour.getHeldItemStack(); - if (AbstractFunnelBlock.getFunnelFacing(world.getBlockState(pos.up())) == funnelFacing) { + if (AbstractFunnelBlock.getFunnelFacing(level.getBlockState(worldPosition.above())) == funnelFacing) { DirectBeltInputBehaviour directOutput = getBehaviour(DirectBeltInputBehaviour.TYPE); if (depotBehaviour.heldItem != null) { ItemStack tryFunnel = directOutput.tryExportingToBeltFunnel(held, funnelFacing, true); @@ -425,25 +425,25 @@ public class EjectorTileEntity extends KineticTileEntity { Vector3d ejectVec = earlyTarget != null ? earlyTarget.getFirst() : getLaunchedItemLocation(maxTime); Vector3d ejectMotionVec = getLaunchedItemMotion(maxTime); - ItemEntity item = new ItemEntity(world, ejectVec.x, ejectVec.y, ejectVec.z, intAttached.getValue()); - item.setMotion(ejectMotionVec); - item.setDefaultPickupDelay(); - world.addEntity(item); + ItemEntity item = new ItemEntity(level, ejectVec.x, ejectVec.y, ejectVec.z, intAttached.getValue()); + item.setDeltaMovement(ejectMotionVec); + item.setDefaultPickUpDelay(); + level.addFreshEntity(item); } public DirectBeltInputBehaviour getTargetOpenInv() { BlockPos targetPos = earlyTarget != null ? earlyTarget.getSecond() - : pos.up(launcher.getVerticalDistance()) - .offset(getFacing(), Math.max(1, launcher.getHorizontalDistance())); - return TileEntityBehaviour.get(world, targetPos, DirectBeltInputBehaviour.TYPE); + : worldPosition.above(launcher.getVerticalDistance()) + .relative(getFacing(), Math.max(1, launcher.getHorizontalDistance())); + return TileEntityBehaviour.get(level, targetPos, DirectBeltInputBehaviour.TYPE); } public Vector3d getLaunchedItemLocation(float time) { - return launcher.getGlobalPos(time, getFacing().getOpposite(), pos); + return launcher.getGlobalPos(time, getFacing().getOpposite(), worldPosition); } public Vector3d getLaunchedItemMotion(float time) { - return launcher.getGlobalVelocity(time, getFacing().getOpposite(), pos) + return launcher.getGlobalVelocity(time, getFacing().getOpposite(), worldPosition) .scale(.5f); } @@ -451,11 +451,11 @@ public class EjectorTileEntity extends KineticTileEntity { for (IntAttached intAttached : launchedItems) { Vector3d ejectVec = getLaunchedItemLocation(intAttached.getFirst()); Vector3d ejectMotionVec = getLaunchedItemMotion(intAttached.getFirst()); - ItemEntity item = new ItemEntity(world, 0, 0, 0, intAttached.getValue()); - item.setPos(ejectVec.x, ejectVec.y, ejectVec.z); - item.setMotion(ejectMotionVec); - item.setDefaultPickupDelay(); - world.addEntity(item); + ItemEntity item = new ItemEntity(level, 0, 0, 0, intAttached.getValue()); + item.setPosRaw(ejectVec.x, ejectVec.y, ejectVec.z); + item.setDeltaMovement(ejectMotionVec); + item.setDefaultPickUpDelay(); + level.addFreshEntity(item); } launchedItems.clear(); } @@ -514,7 +514,7 @@ public class EjectorTileEntity extends KineticTileEntity { state = NBTHelper.readEnum(compound, "State", State.class); lidProgress.readNBT(compound.getCompound("Lid"), false); launchedItems = NBTHelper.readCompoundList(compound.getList("LaunchedItems", NBT.TAG_COMPOUND), - nbt -> IntAttached.read(nbt, ItemStack::read)); + nbt -> IntAttached.read(nbt, ItemStack::of)); earlyTarget = null; earlyTargetTime = 0; @@ -529,7 +529,7 @@ public class EjectorTileEntity extends KineticTileEntity { } public void updateSignal() { - boolean shoudPower = world.isBlockPowered(pos); + boolean shoudPower = level.hasNeighborSignal(worldPosition); if (shoudPower == powered) return; powered = shoudPower; @@ -544,10 +544,10 @@ public class EjectorTileEntity extends KineticTileEntity { public BlockPos getTargetPosition() { BlockState blockState = getBlockState(); if (!AllBlocks.WEIGHTED_EJECTOR.has(blockState)) - return pos; - Direction facing = blockState.get(EjectorBlock.HORIZONTAL_FACING); - return pos.offset(facing, launcher.getHorizontalDistance()) - .up(launcher.getVerticalDistance()); + return worldPosition; + Direction facing = blockState.getValue(EjectorBlock.HORIZONTAL_FACING); + return worldPosition.relative(facing, launcher.getHorizontalDistance()) + .above(launcher.getVerticalDistance()); } @Override @@ -578,8 +578,8 @@ public class EjectorTileEntity extends KineticTileEntity { @Override @OnlyIn(Dist.CLIENT) - public double getMaxRenderDistanceSquared() { - return super.getMaxRenderDistanceSquared() * 16; + public double getViewDistance() { + return super.getViewDistance() * 16; } private static abstract class EntityHack extends Entity { @@ -589,8 +589,8 @@ public class EjectorTileEntity extends KineticTileEntity { } public static void setElytraFlying(Entity e) { - EntityDataManager data = e.getDataManager(); - data.set(FLAGS, (byte) (data.get(FLAGS) | 1 << 7)); + EntityDataManager data = e.getEntityData(); + data.set(DATA_SHARED_FLAGS_ID, (byte) (data.get(DATA_SHARED_FLAGS_ID) | 1 << 7)); } } @@ -611,7 +611,7 @@ public class EjectorTileEntity extends KineticTileEntity { protected float angle(BlockState state) { float horizontalAngle = AllBlocks.WEIGHTED_EJECTOR.has(state) - ? AngleHelper.horizontalAngle(state.get(EjectorBlock.HORIZONTAL_FACING)) + ? AngleHelper.horizontalAngle(state.getValue(EjectorBlock.HORIZONTAL_FACING)) : 0; return horizontalAngle; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EntityLauncher.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EntityLauncher.java index a2ae91d02..281d248ee 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EntityLauncher.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EntityLauncher.java @@ -24,7 +24,7 @@ public class EntityLauncher { public void clamp(int max) { set(Math.min(horizontalDistance, max), - MathHelper.signum(verticalDistance) * Math.min(Math.abs(verticalDistance), max)); + MathHelper.sign(verticalDistance) * Math.min(Math.abs(verticalDistance), max)); } public void set(int horizontalDistance, int verticalDistance) { @@ -36,7 +36,7 @@ public class EntityLauncher { public void applyMotion(Entity entity, Direction facing) { Vector3d motionVec = new Vector3d(0, yMotion, xMotion); motionVec = VecHelper.rotate(motionVec, AngleHelper.horizontalAngle(facing), Axis.Y); - entity.setMotion(motionVec.x * .91, motionVec.y * .98, motionVec.z * .91); + entity.setDeltaMovement(motionVec.x * .91, motionVec.y * .98, motionVec.z * .91); } public int getHorizontalDistance() { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/SharedDepotBlockMethods.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/SharedDepotBlockMethods.java index 55ba80aad..4d630916d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/SharedDepotBlockMethods.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/SharedDepotBlockMethods.java @@ -33,9 +33,9 @@ public class SharedDepotBlockMethods { public static ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { - if (ray.getFace() != Direction.UP) + if (ray.getDirection() != Direction.UP) return ActionResultType.PASS; - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; DepotBehaviour behaviour = get(world, pos); @@ -44,7 +44,7 @@ public class SharedDepotBlockMethods { if (!behaviour.canAcceptItems.get()) return ActionResultType.SUCCESS; - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); boolean wasEmptyHanded = heldItem.isEmpty(); boolean shouldntPlaceItem = AllBlocks.MECHANICAL_ARM.isIn(heldItem); @@ -52,7 +52,7 @@ public class SharedDepotBlockMethods { if (!mainItemStack.isEmpty()) { player.inventory.placeItemBackInInventory(world, mainItemStack); behaviour.removeHeldItem(); - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, .2f, + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .2f, 1f + Create.RANDOM.nextFloat()); } ItemStackHandler outputs = behaviour.processingOutputBuffer; @@ -61,11 +61,11 @@ public class SharedDepotBlockMethods { if (!wasEmptyHanded && !shouldntPlaceItem) { TransportedItemStack transported = new TransportedItemStack(heldItem); - transported.insertedFrom = player.getHorizontalFacing(); + transported.insertedFrom = player.getDirection(); transported.prevBeltPosition = .25f; transported.beltPosition = .25f; behaviour.setHeldItem(transported); - player.setHeldItem(hand, ItemStack.EMPTY); + player.setItemInHand(hand, ItemStack.EMPTY); AllSoundEvents.DEPOT_SLIDE.playOnServer(world, pos); } @@ -82,11 +82,11 @@ public class SharedDepotBlockMethods { return; ItemHelper.dropContents(worldIn, pos, behaviour.processingOutputBuffer); for (TransportedItemStack transportedItemStack : behaviour.incoming) - InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), transportedItemStack.stack); + InventoryHelper.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), transportedItemStack.stack); if (!behaviour.getHeldItemStack() .isEmpty()) - InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), behaviour.getHeldItemStack()); - worldIn.removeTileEntity(pos); + InventoryHelper.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), behaviour.getHeldItemStack()); + worldIn.removeBlockEntity(pos); } public static void onLanded(IBlockReader worldIn, Entity entityIn) { @@ -94,12 +94,12 @@ public class SharedDepotBlockMethods { return; if (!entityIn.isAlive()) return; - if (entityIn.world.isRemote) + if (entityIn.level.isClientSide) return; ItemEntity itemEntity = (ItemEntity) entityIn; DirectBeltInputBehaviour inputBehaviour = - TileEntityBehaviour.get(worldIn, entityIn.getBlockPos(), DirectBeltInputBehaviour.TYPE); + TileEntityBehaviour.get(worldIn, entityIn.blockPosition(), DirectBeltInputBehaviour.TYPE); if (inputBehaviour == null) return; ItemStack remainder = inputBehaviour.handleInsertion(itemEntity.getItem(), Direction.DOWN, false); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AbstractDiodeBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AbstractDiodeBlock.java index a79285187..82c434796 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AbstractDiodeBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AbstractDiodeBlock.java @@ -5,6 +5,8 @@ import com.simibubi.create.content.contraptions.wrench.IWrenchable; import net.minecraft.block.BlockState; import net.minecraft.block.RedstoneDiodeBlock; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class AbstractDiodeBlock extends RedstoneDiodeBlock implements IWrenchable { public AbstractDiodeBlock(Properties builder) { @@ -12,7 +14,7 @@ public abstract class AbstractDiodeBlock extends RedstoneDiodeBlock implements I } @Override - public boolean canProvidePower(BlockState state) { + public boolean isSignalSource(BlockState state) { return true; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AbstractDiodeGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AbstractDiodeGenerator.java index 7093f3d29..348b2e0e6 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AbstractDiodeGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AbstractDiodeGenerator.java @@ -42,7 +42,7 @@ public abstract class AbstractDiodeGenerator extends SpecialBlockStateGen { @Override protected final int getYRotation(BlockState state) { - return horizontalAngle(state.get(AbstractDiodeBlock.HORIZONTAL_FACING)); + return horizontalAngle(state.getValue(AbstractDiodeBlock.FACING)); } abstract Vector createModels(DataGenContext ctx, BlockModelProvider prov); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustablePulseRepeaterTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustablePulseRepeaterTileEntity.java index a3639fd05..4620d7393 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustablePulseRepeaterTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustablePulseRepeaterTileEntity.java @@ -17,12 +17,12 @@ public class AdjustablePulseRepeaterTileEntity extends AdjustableRepeaterTileEnt if (charging && atMax) { if (powering) { - world.setBlockState(pos, getBlockState().with(POWERING, false)); + level.setBlockAndUpdate(worldPosition, getBlockState().setValue(POWERING, false)); charging = false; return; } - if (!powering && !world.isRemote) - world.setBlockState(pos, getBlockState().with(POWERING, true)); + if (!powering && !level.isClientSide) + level.setBlockAndUpdate(worldPosition, getBlockState().setValue(POWERING, true)); return; } @@ -30,8 +30,8 @@ public class AdjustablePulseRepeaterTileEntity extends AdjustableRepeaterTileEnt return; if (!charging && !atMin) { - if (!world.isRemote) - world.setBlockState(pos, getBlockState().with(POWERING, false)); + if (!level.isClientSide) + level.setBlockAndUpdate(worldPosition, getBlockState().setValue(POWERING, false)); state = 0; return; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterBlock.java index 3ba865ded..9a49c184a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterBlock.java @@ -12,20 +12,22 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.block.AbstractBlock.Properties; + public class AdjustableRepeaterBlock extends AbstractDiodeBlock { public static BooleanProperty POWERING = BooleanProperty.create("powering"); public AdjustableRepeaterBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(POWERED, false) - .with(POWERING, false)); + registerDefaultState(defaultBlockState().setValue(POWERED, false) + .setValue(POWERING, false)); } @Override - protected void fillStateContainer(Builder builder) { - builder.add(POWERED, POWERING, HORIZONTAL_FACING); - super.fillStateContainer(builder); + protected void createBlockStateDefinition(Builder builder) { + builder.add(POWERED, POWERING, FACING); + super.createBlockStateDefinition(builder); } @Override @@ -40,13 +42,13 @@ public class AdjustableRepeaterBlock extends AbstractDiodeBlock { } @Override - protected int getActiveSignal(IBlockReader worldIn, BlockPos pos, BlockState state) { - return state.get(POWERING) ? 15 : 0; + protected int getOutputSignal(IBlockReader worldIn, BlockPos pos, BlockState state) { + return state.getValue(POWERING) ? 15 : 0; } @Override - public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { - return blockState.get(HORIZONTAL_FACING) == side ? this.getActiveSignal(blockAccess, pos, blockState) : 0; + public int getSignal(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + return blockState.getValue(FACING) == side ? this.getOutputSignal(blockAccess, pos, blockState) : 0; } @Override @@ -58,7 +60,7 @@ public class AdjustableRepeaterBlock extends AbstractDiodeBlock { public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { if (side == null) return false; - return side.getAxis() == state.get(HORIZONTAL_FACING) + return side.getAxis() == state.getValue(FACING) .getAxis(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterGenerator.java index 201675c68..ada44ac84 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterGenerator.java @@ -33,7 +33,7 @@ public class AdjustableRepeaterGenerator extends AbstractDiodeGenerator { @Override int getModelIndex(BlockState state) { - return (state.get(AdjustableRepeaterBlock.POWERING) ? 2 : 0) + (state.get(AdjustableRepeaterBlock.POWERED) ? 1 : 0); + return (state.getValue(AdjustableRepeaterBlock.POWERING) ? 2 : 0) + (state.getValue(AdjustableRepeaterBlock.POWERED) ? 1 : 0); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterScrollSlot.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterScrollSlot.java index 54d084788..328a7dfe2 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterScrollSlot.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterScrollSlot.java @@ -19,7 +19,7 @@ public class AdjustableRepeaterScrollSlot extends ValueBoxTransform { @Override protected void rotate(BlockState state, MatrixStack ms) { - float yRot = AngleHelper.horizontalAngle(state.get(BlockStateProperties.HORIZONTAL_FACING)) + 180; + float yRot = AngleHelper.horizontalAngle(state.getValue(BlockStateProperties.HORIZONTAL_FACING)) + 180; MatrixStacker.of(ms) .rotateY(yRot) .rotateX(90); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterTileEntity.java index c678c6085..e21121bdc 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterTileEntity.java @@ -90,8 +90,8 @@ public class AdjustableRepeaterTileEntity extends SmartTileEntity implements IIn @Override public void tick() { super.tick(); - boolean powered = getBlockState().get(POWERED); - boolean powering = getBlockState().get(POWERING); + boolean powered = getBlockState().getValue(POWERED); + boolean powering = getBlockState().getValue(POWERING); boolean atMax = state >= maxState.getValue(); boolean atMin = state <= 0; updateState(powered, powering, atMax, atMin); @@ -102,16 +102,16 @@ public class AdjustableRepeaterTileEntity extends SmartTileEntity implements IIn charging = true; if (charging && atMax) { - if (!powering && !world.isRemote) - world.setBlockState(pos, getBlockState().with(POWERING, true)); + if (!powering && !level.isClientSide) + level.setBlockAndUpdate(worldPosition, getBlockState().setValue(POWERING, true)); if (!powered) charging = false; return; } if (!charging && atMin) { - if (powering && !world.isRemote) - world.setBlockState(pos, getBlockState().with(POWERING, false)); + if (powering && !level.isClientSide) + level.setBlockAndUpdate(worldPosition, getBlockState().setValue(POWERING, false)); return; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/PoweredLatchBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/PoweredLatchBlock.java index 81f4670ae..667f9cbce 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/PoweredLatchBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/PoweredLatchBlock.java @@ -16,90 +16,92 @@ import net.minecraft.world.TickPriority; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class PoweredLatchBlock extends ToggleLatchBlock { public static BooleanProperty POWERED_SIDE = BooleanProperty.create("powered_side"); public PoweredLatchBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(POWERED_SIDE, false)); + registerDefaultState(defaultBlockState().setValue(POWERED_SIDE, false)); } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(POWERED_SIDE)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(POWERED_SIDE)); } @Override - protected void updateState(World worldIn, BlockPos pos, BlockState state) { - boolean back = state.get(POWERED); - boolean shouldBack = shouldBePowered(worldIn, pos, state); - boolean side = state.get(POWERED_SIDE); + protected void checkTickOnNeighbor(World worldIn, BlockPos pos, BlockState state) { + boolean back = state.getValue(POWERED); + boolean shouldBack = shouldTurnOn(worldIn, pos, state); + boolean side = state.getValue(POWERED_SIDE); boolean shouldSide = isPoweredOnSides(worldIn, pos, state); TickPriority tickpriority = TickPriority.HIGH; - if (this.isFacingTowardsRepeater(worldIn, pos, state)) + if (this.shouldPrioritize(worldIn, pos, state)) tickpriority = TickPriority.EXTREMELY_HIGH; else if (side || back) tickpriority = TickPriority.VERY_HIGH; - if (worldIn.getPendingBlockTicks().isTickPending(pos, this)) + if (worldIn.getBlockTicks().willTickThisTick(pos, this)) return; if (back != shouldBack || side != shouldSide) - worldIn.getPendingBlockTicks().scheduleTick(pos, this, this.getDelay(state), tickpriority); + worldIn.getBlockTicks().scheduleTick(pos, this, this.getDelay(state), tickpriority); } protected boolean isPoweredOnSides(World worldIn, BlockPos pos, BlockState state) { - Direction direction = state.get(HORIZONTAL_FACING); - Direction left = direction.rotateY(); - Direction right = direction.rotateYCCW(); + Direction direction = state.getValue(FACING); + Direction left = direction.getClockWise(); + Direction right = direction.getCounterClockWise(); for (Direction d : new Direction[] { left, right }) { - BlockPos blockpos = pos.offset(d); - int i = worldIn.getRedstonePower(blockpos, d); + BlockPos blockpos = pos.relative(d); + int i = worldIn.getSignal(blockpos, d); if (i > 0) return true; BlockState blockstate = worldIn.getBlockState(blockpos); - if (blockstate.getBlock() == Blocks.REDSTONE_WIRE && blockstate.get(RedstoneWireBlock.POWER) > 0) + if (blockstate.getBlock() == Blocks.REDSTONE_WIRE && blockstate.getValue(RedstoneWireBlock.POWER) > 0) return true; } return false; } @Override - public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { - boolean back = state.get(POWERED); - boolean shouldBack = this.shouldBePowered(worldIn, pos, state); - boolean side = state.get(POWERED_SIDE); + public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + boolean back = state.getValue(POWERED); + boolean shouldBack = this.shouldTurnOn(worldIn, pos, state); + boolean side = state.getValue(POWERED_SIDE); boolean shouldSide = isPoweredOnSides(worldIn, pos, state); BlockState stateIn = state; if (back != shouldBack) { - state = state.with(POWERED, shouldBack); + state = state.setValue(POWERED, shouldBack); if (shouldBack) - state = state.with(POWERING, true); + state = state.setValue(POWERING, true); else if (side) - state = state.with(POWERING, false); + state = state.setValue(POWERING, false); } if (side != shouldSide) { - state = state.with(POWERED_SIDE, shouldSide); + state = state.setValue(POWERED_SIDE, shouldSide); if (shouldSide) - state = state.with(POWERING, false); + state = state.setValue(POWERING, false); else if (back) - state = state.with(POWERING, true); + state = state.setValue(POWERING, true); } if (state != stateIn) - worldIn.setBlockState(pos, state, 2); + worldIn.setBlock(pos, state, 2); } @Override protected ActionResultType activated(World worldIn, BlockPos pos, BlockState state) { - if (state.get(POWERED) != state.get(POWERED_SIDE)) + if (state.getValue(POWERED) != state.getValue(POWERED_SIDE)) return ActionResultType.PASS; - if (!worldIn.isRemote) - worldIn.setBlockState(pos, state.cycle(POWERING), 2); + if (!worldIn.isClientSide) + worldIn.setBlock(pos, state.cycle(POWERING), 2); return ActionResultType.SUCCESS; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/PoweredLatchGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/PoweredLatchGenerator.java index 305c3e724..e09fabc11 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/PoweredLatchGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/PoweredLatchGenerator.java @@ -29,7 +29,7 @@ public class PoweredLatchGenerator extends AbstractDiodeGenerator { @Override int getModelIndex(BlockState state) { - return state.get(PoweredLatchBlock.POWERING)? 1 : 0; + return state.getValue(PoweredLatchBlock.POWERING)? 1 : 0; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/PulseRepeaterBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/PulseRepeaterBlock.java index d15a129ad..2e1253f4a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/PulseRepeaterBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/PulseRepeaterBlock.java @@ -12,13 +12,15 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.TickPriority; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class PulseRepeaterBlock extends AbstractDiodeBlock { public static BooleanProperty PULSING = BooleanProperty.create("pulsing"); public PulseRepeaterBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(PULSING, false).with(POWERED, false)); + registerDefaultState(defaultBlockState().setValue(PULSING, false).setValue(POWERED, false)); } @Override @@ -30,35 +32,35 @@ public class PulseRepeaterBlock extends AbstractDiodeBlock { public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { if (side == null) return false; - return side.getAxis() == state.get(HORIZONTAL_FACING).getAxis(); + return side.getAxis() == state.getValue(FACING).getAxis(); } @Override - public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { - boolean powered = state.get(POWERED); - boolean pulsing = state.get(PULSING); - boolean shouldPower = shouldBePowered(worldIn, pos, state); + public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + boolean powered = state.getValue(POWERED); + boolean pulsing = state.getValue(PULSING); + boolean shouldPower = shouldTurnOn(worldIn, pos, state); if (pulsing) { - worldIn.setBlockState(pos, state.with(POWERED, shouldPower).with(PULSING, false), 2); + worldIn.setBlock(pos, state.setValue(POWERED, shouldPower).setValue(PULSING, false), 2); } else if (powered && !shouldPower) { - worldIn.setBlockState(pos, state.with(POWERED, false).with(PULSING, false), 2); + worldIn.setBlock(pos, state.setValue(POWERED, false).setValue(PULSING, false), 2); } else if (!powered) { - worldIn.setBlockState(pos, state.with(POWERED, true).with(PULSING, true), 2); - worldIn.getPendingBlockTicks().scheduleTick(pos, this, this.getDelay(state), TickPriority.HIGH); + worldIn.setBlock(pos, state.setValue(POWERED, true).setValue(PULSING, true), 2); + worldIn.getBlockTicks().scheduleTick(pos, this, this.getDelay(state), TickPriority.HIGH); } } @Override - protected int getActiveSignal(IBlockReader worldIn, BlockPos pos, BlockState state) { - return state.get(PULSING) ? 15 : 0; + protected int getOutputSignal(IBlockReader worldIn, BlockPos pos, BlockState state) { + return state.getValue(PULSING) ? 15 : 0; } @Override - protected void fillStateContainer(Builder builder) { - builder.add(HORIZONTAL_FACING, POWERED, PULSING); - super.fillStateContainer(builder); + protected void createBlockStateDefinition(Builder builder) { + builder.add(FACING, POWERED, PULSING); + super.createBlockStateDefinition(builder); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/PulseRepeaterGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/PulseRepeaterGenerator.java index fd61ed1a8..c301ec552 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/PulseRepeaterGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/PulseRepeaterGenerator.java @@ -30,7 +30,7 @@ public class PulseRepeaterGenerator extends AbstractDiodeGenerator { @Override int getModelIndex(BlockState state) { - return state.get(PulseRepeaterBlock.PULSING) ? 2 : state.get(PulseRepeaterBlock.POWERED) ? 1 : 0; + return state.getValue(PulseRepeaterBlock.PULSING) ? 2 : state.getValue(PulseRepeaterBlock.POWERED) ? 1 : 0; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/ToggleLatchBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/ToggleLatchBlock.java index 4f378f8cb..553c704cd 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/ToggleLatchBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/ToggleLatchBlock.java @@ -18,24 +18,26 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class ToggleLatchBlock extends AbstractDiodeBlock { public static BooleanProperty POWERING = BooleanProperty.create("powering"); public ToggleLatchBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(POWERING, false) - .with(POWERED, false)); + registerDefaultState(defaultBlockState().setValue(POWERING, false) + .setValue(POWERED, false)); } @Override - protected void fillStateContainer(Builder builder) { - builder.add(POWERED, POWERING, HORIZONTAL_FACING); + protected void createBlockStateDefinition(Builder builder) { + builder.add(POWERED, POWERING, FACING); } @Override - public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { - return blockState.get(HORIZONTAL_FACING) == side ? this.getActiveSignal(blockAccess, pos, blockState) : 0; + public int getSignal(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + return blockState.getValue(FACING) == side ? this.getOutputSignal(blockAccess, pos, blockState) : 0; } @Override @@ -44,34 +46,34 @@ public class ToggleLatchBlock extends AbstractDiodeBlock { } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!player.isAllowEdit()) + if (!player.mayBuild()) return ActionResultType.PASS; - if (player.isSneaking()) + if (player.isShiftKeyDown()) return ActionResultType.PASS; - if (AllItems.WRENCH.isIn(player.getHeldItem(handIn))) + if (AllItems.WRENCH.isIn(player.getItemInHand(handIn))) return ActionResultType.PASS; return activated(worldIn, pos, state); } @Override - protected int getActiveSignal(IBlockReader worldIn, BlockPos pos, BlockState state) { - return state.get(POWERING) ? 15 : 0; + protected int getOutputSignal(IBlockReader worldIn, BlockPos pos, BlockState state) { + return state.getValue(POWERING) ? 15 : 0; } @Override - public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { - boolean poweredPreviously = state.get(POWERED); - super.scheduledTick(state, worldIn, pos, random); + public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + boolean poweredPreviously = state.getValue(POWERED); + super.tick(state, worldIn, pos, random); BlockState newState = worldIn.getBlockState(pos); - if (newState.get(POWERED) && !poweredPreviously) - worldIn.setBlockState(pos, newState.cycle(POWERING), 2); + if (newState.getValue(POWERED) && !poweredPreviously) + worldIn.setBlock(pos, newState.cycle(POWERING), 2); } protected ActionResultType activated(World worldIn, BlockPos pos, BlockState state) { - if (!worldIn.isRemote) - worldIn.setBlockState(pos, state.cycle(POWERING), 2); + if (!worldIn.isClientSide) + worldIn.setBlock(pos, state.cycle(POWERING), 2); return ActionResultType.SUCCESS; } @@ -79,7 +81,7 @@ public class ToggleLatchBlock extends AbstractDiodeBlock { public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { if (side == null) return false; - return side.getAxis() == state.get(HORIZONTAL_FACING) + return side.getAxis() == state.getValue(FACING) .getAxis(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/ToggleLatchGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/ToggleLatchGenerator.java index 3bcae9dcd..eda899142 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/ToggleLatchGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/ToggleLatchGenerator.java @@ -31,7 +31,7 @@ public class ToggleLatchGenerator extends AbstractDiodeGenerator { @Override int getModelIndex(BlockState state) { - return (state.get(ToggleLatchBlock.POWERING) ? 2 : 0) + (state.get(ToggleLatchBlock.POWERED) ? 1 : 0); + return (state.getValue(ToggleLatchBlock.POWERING) ? 2 : 0) + (state.getValue(ToggleLatchBlock.POWERED) ? 1 : 0); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractDirectionalFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractDirectionalFunnelBlock.java index 43dd71869..50bedef64 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractDirectionalFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractDirectionalFunnelBlock.java @@ -9,6 +9,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; +import net.minecraft.block.AbstractBlock.Properties; + public class AbstractDirectionalFunnelBlock extends AbstractFunnelBlock { public static final DirectionProperty FACING = BlockStateProperties.FACING; @@ -18,23 +20,23 @@ public class AbstractDirectionalFunnelBlock extends AbstractFunnelBlock { } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(FACING)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(FACING)); } @Override protected Direction getFacing(BlockState state) { - return state.get(FACING); + return state.getValue(FACING); } @Override public BlockState rotate(BlockState state, Rotation rot) { - return state.with(FACING, rot.rotate(state.get(FACING))); + return state.setValue(FACING, rot.rotate(state.getValue(FACING))); } @Override public BlockState mirror(BlockState state, Mirror mirrorIn) { - return state.rotate(mirrorIn.toRotation(state.get(FACING))); + return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); } } 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 b71846b3a..17beebbdb 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 @@ -31,29 +31,31 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class AbstractFunnelBlock extends Block implements ITE, IWrenchable { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; protected AbstractFunnelBlock(Properties p_i48377_1_) { super(p_i48377_1_); - setDefaultState(getDefaultState().with(POWERED, false)); + registerDefaultState(defaultBlockState().setValue(POWERED, false)); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return getDefaultState().with(POWERED, context.getWorld() - .isBlockPowered(context.getPos())); + return defaultBlockState().setValue(POWERED, context.getLevel() + .hasNeighborSignal(context.getClickedPos())); } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(POWERED)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(POWERED)); } @Override @@ -66,22 +68,22 @@ public abstract class AbstractFunnelBlock extends Block implements ITE builder) { - super.fillStateContainer(builder.add(HORIZONTAL_FACING)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(HORIZONTAL_FACING)); } @Override protected Direction getFacing(BlockState state) { - return state.get(HORIZONTAL_FACING); + return state.getValue(HORIZONTAL_FACING); } @Override public BlockState rotate(BlockState p_185499_1_, Rotation p_185499_2_) { - return p_185499_1_.with(HORIZONTAL_FACING, p_185499_2_.rotate(p_185499_1_.get(HORIZONTAL_FACING))); + return p_185499_1_.setValue(HORIZONTAL_FACING, p_185499_2_.rotate(p_185499_1_.getValue(HORIZONTAL_FACING))); } @Override public BlockState mirror(BlockState p_185471_1_, Mirror p_185471_2_) { - return p_185471_1_.rotate(p_185471_2_.toRotation(p_185471_1_.get(HORIZONTAL_FACING))); + return p_185471_1_.rotate(p_185471_2_.getRotation(p_185471_1_.getValue(HORIZONTAL_FACING))); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteFunnelBlock.java index 2dc92c421..2191748a3 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteFunnelBlock.java @@ -7,6 +7,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.block.AbstractBlock.Properties; + public class AndesiteFunnelBlock extends FunnelBlock { public AndesiteFunnelBlock(Properties p_i48415_1_) { @@ -17,8 +19,8 @@ public class AndesiteFunnelBlock extends FunnelBlock { public BlockState getEquivalentBeltFunnel(IBlockReader world, BlockPos pos, BlockState state) { Direction facing = getFunnelFacing(state); return AllBlocks.ANDESITE_BELT_FUNNEL.getDefaultState() - .with(BeltFunnelBlock.HORIZONTAL_FACING, facing) - .with(POWERED, state.get(POWERED)); + .setValue(BeltFunnelBlock.HORIZONTAL_FACING, facing) + .setValue(POWERED, state.getValue(POWERED)); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java index 56de5730e..e7e95f618 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java @@ -35,6 +35,8 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements ISpecialBlockItemRequirement { private BlockEntry parent; @@ -54,7 +56,7 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS } @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } } @@ -62,25 +64,25 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS public BeltFunnelBlock(BlockEntry parent, Properties p_i48377_1_) { super(p_i48377_1_); this.parent = parent; - setDefaultState(getDefaultState().with(SHAPE, Shape.RETRACTED)); + registerDefaultState(defaultBlockState().setValue(SHAPE, Shape.RETRACTED)); } @Override - protected void fillStateContainer(Builder p_206840_1_) { - super.fillStateContainer(p_206840_1_.add(SHAPE)); + protected void createBlockStateDefinition(Builder p_206840_1_) { + super.createBlockStateDefinition(p_206840_1_.add(SHAPE)); } @Override public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - return state.get(SHAPE).shaper.get(state.get(HORIZONTAL_FACING)); + return state.getValue(SHAPE).shaper.get(state.getValue(HORIZONTAL_FACING)); } @Override public VoxelShape getCollisionShape(BlockState p_220071_1_, IBlockReader p_220071_2_, BlockPos p_220071_3_, ISelectionContext p_220071_4_) { if (p_220071_4_.getEntity() instanceof ItemEntity - && (p_220071_1_.get(SHAPE) == Shape.PULLING || p_220071_1_.get(SHAPE) == Shape.PUSHING)) + && (p_220071_1_.getValue(SHAPE) == Shape.PULLING || p_220071_1_.getValue(SHAPE) == Shape.PUSHING)) return AllShapes.FUNNEL_COLLISION.get(getFacing(p_220071_1_)); return getShape(p_220071_1_, p_220071_2_, p_220071_3_, p_220071_4_); } @@ -88,25 +90,25 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS @Override public BlockState getStateForPlacement(BlockItemUseContext ctx) { BlockState stateForPlacement = super.getStateForPlacement(ctx); - BlockPos pos = ctx.getPos(); - World world = ctx.getWorld(); - Direction facing = ctx.getFace() + BlockPos pos = ctx.getClickedPos(); + World world = ctx.getLevel(); + Direction facing = ctx.getClickedFace() .getAxis() - .isHorizontal() ? ctx.getFace() : ctx.getPlacementHorizontalFacing(); + .isHorizontal() ? ctx.getClickedFace() : ctx.getHorizontalDirection(); - BlockState state = stateForPlacement.with(HORIZONTAL_FACING, facing); + BlockState state = stateForPlacement.setValue(HORIZONTAL_FACING, facing); boolean sneaking = ctx.getPlayer() != null && ctx.getPlayer() - .isSneaking(); - return state.with(SHAPE, getShapeForPosition(world, pos, facing, !sneaking)); + .isShiftKeyDown(); + return state.setValue(SHAPE, getShapeForPosition(world, pos, facing, !sneaking)); } public static Shape getShapeForPosition(IBlockReader world, BlockPos pos, Direction facing, boolean extracting) { - BlockPos posBelow = pos.down(); + BlockPos posBelow = pos.below(); BlockState stateBelow = world.getBlockState(posBelow); Shape perpendicularState = extracting ? Shape.PUSHING : Shape.PULLING; if (!AllBlocks.BELT.has(stateBelow)) return perpendicularState; - Direction movementFacing = stateBelow.get(BeltBlock.HORIZONTAL_FACING); + Direction movementFacing = stateBelow.getValue(BeltBlock.HORIZONTAL_FACING); return movementFacing.getAxis() != facing.getAxis() ? perpendicularState : Shape.RETRACTED; } @@ -117,19 +119,19 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbour, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbour, IWorld world, BlockPos pos, BlockPos p_196271_6_) { if (!isOnValidBelt(state, world, pos)) { BlockState parentState = parent.getDefaultState(); - if (state.method_28500(POWERED).orElse(false)) - parentState = parentState.with(POWERED, true); - if (state.get(SHAPE) == Shape.PUSHING) - parentState = parentState.with(FunnelBlock.EXTRACTING, true); - return parentState.with(FunnelBlock.FACING, state.get(HORIZONTAL_FACING)); + if (state.getOptionalValue(POWERED).orElse(false)) + parentState = parentState.setValue(POWERED, true); + if (state.getValue(SHAPE) == Shape.PUSHING) + parentState = parentState.setValue(FunnelBlock.EXTRACTING, true); + return parentState.setValue(FunnelBlock.FACING, state.getValue(HORIZONTAL_FACING)); } Shape updatedShape = - getShapeForPosition(world, pos, state.get(HORIZONTAL_FACING), state.get(SHAPE) == Shape.PUSHING); - Shape currentShape = state.get(SHAPE); + getShapeForPosition(world, pos, state.getValue(HORIZONTAL_FACING), state.getValue(SHAPE) == Shape.PUSHING); + Shape currentShape = state.getValue(SHAPE); if (updatedShape == currentShape) return state; @@ -139,15 +141,15 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS if (updatedShape == Shape.RETRACTED && currentShape == Shape.EXTENDED) return state; - return state.with(SHAPE, updatedShape); + return state.setValue(SHAPE, updatedShape); } public static boolean isOnValidBelt(BlockState state, IWorldReader world, BlockPos pos) { - BlockState stateBelow = world.getBlockState(pos.down()); + BlockState stateBelow = world.getBlockState(pos.below()); if ((stateBelow.getBlock() instanceof BeltBlock)) return BeltBlock.canTransportObjects(stateBelow); DirectBeltInputBehaviour directBeltInputBehaviour = - TileEntityBehaviour.get(world, pos.down(), DirectBeltInputBehaviour.TYPE); + TileEntityBehaviour.get(world, pos.below(), DirectBeltInputBehaviour.TYPE); if (directBeltInputBehaviour == null) return false; return directBeltInputBehaviour.canSupportBeltFunnels(); @@ -155,11 +157,11 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getWorld(); - if (world.isRemote) + World world = context.getLevel(); + if (world.isClientSide) return ActionResultType.SUCCESS; - Shape shape = state.get(SHAPE); + Shape shape = state.getValue(SHAPE); Shape newShape = shape; if (shape == Shape.PULLING) newShape = Shape.PUSHING; @@ -168,9 +170,9 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS else if (shape == Shape.EXTENDED) newShape = Shape.RETRACTED; else if (shape == Shape.RETRACTED) { - BlockState belt = world.getBlockState(context.getPos() - .down()); - if (belt.getBlock() instanceof BeltBlock && belt.get(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL) + BlockState belt = world.getBlockState(context.getClickedPos() + .below()); + if (belt.getBlock() instanceof BeltBlock && belt.getValue(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL) newShape = Shape.RETRACTED; else newShape = Shape.EXTENDED; @@ -179,14 +181,14 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS if (newShape == shape) return ActionResultType.SUCCESS; - world.setBlockState(context.getPos(), state.with(SHAPE, newShape)); + world.setBlockAndUpdate(context.getClickedPos(), state.setValue(SHAPE, newShape)); if (newShape == Shape.EXTENDED) { - Direction facing = state.get(HORIZONTAL_FACING); - BlockState opposite = world.getBlockState(context.getPos() - .offset(facing)); - if (opposite.getBlock() instanceof BeltFunnelBlock && opposite.get(SHAPE) == Shape.EXTENDED - && opposite.get(HORIZONTAL_FACING) == facing.getOpposite()) + Direction facing = state.getValue(HORIZONTAL_FACING); + BlockState opposite = world.getBlockState(context.getClickedPos() + .relative(facing)); + if (opposite.getBlock() instanceof BeltFunnelBlock && opposite.getValue(SHAPE) == Shape.EXTENDED + && opposite.getValue(HORIZONTAL_FACING) == facing.getOpposite()) AllTriggers.triggerFor(AllTriggers.BELT_FUNNEL_KISS, context.getPlayer()); } return ActionResultType.SUCCESS; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelGenerator.java index 792fbe5c4..2fe07b546 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelGenerator.java @@ -27,15 +27,15 @@ public class BeltFunnelGenerator extends SpecialBlockStateGen { @Override protected int getYRotation(BlockState state) { - return horizontalAngle(state.get(BeltFunnelBlock.HORIZONTAL_FACING)) + 180; + return horizontalAngle(state.getValue(BeltFunnelBlock.HORIZONTAL_FACING)) + 180; } @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - boolean powered = state.method_28500(BlockStateProperties.POWERED).orElse(false); - String shapeName = state.get(BeltFunnelBlock.SHAPE) - .getString(); + boolean powered = state.getOptionalValue(BlockStateProperties.POWERED).orElse(false); + String shapeName = state.getValue(BeltFunnelBlock.SHAPE) + .getSerializedName(); String poweredSuffix = powered ? "_powered" : ""; String name = ctx.getName() + "_" + poweredSuffix; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java index e44c2aa4d..d5a1f8426 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java @@ -7,6 +7,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.block.AbstractBlock.Properties; + public class BrassFunnelBlock extends FunnelBlock { public BrassFunnelBlock(Properties p_i48415_1_) { @@ -17,8 +19,8 @@ public class BrassFunnelBlock extends FunnelBlock { public BlockState getEquivalentBeltFunnel(IBlockReader world, BlockPos pos, BlockState state) { Direction facing = getFacing(state); return AllBlocks.BRASS_BELT_FUNNEL.getDefaultState() - .with(BeltFunnelBlock.HORIZONTAL_FACING, facing) - .with(POWERED, state.get(POWERED)); + .setValue(BeltFunnelBlock.HORIZONTAL_FACING, facing) + .setValue(POWERED, state.getValue(POWERED)); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java index 747414130..51a9b06bd 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java @@ -28,13 +28,15 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { public static final BooleanProperty EXTRACTING = BooleanProperty.create("extracting"); public FunnelBlock(Properties p_i48415_1_) { super(p_i48415_1_); - setDefaultState(getDefaultState().with(EXTRACTING, false)); + registerDefaultState(defaultBlockState().setValue(EXTRACTING, false)); } public abstract BlockState getEquivalentBeltFunnel(IBlockReader world, BlockPos pos, BlockState state); @@ -44,40 +46,40 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { BlockState state = super.getStateForPlacement(context); boolean sneak = context.getPlayer() != null && context.getPlayer() - .isSneaking(); - state = state.with(EXTRACTING, !sneak); + .isShiftKeyDown(); + state = state.setValue(EXTRACTING, !sneak); for (Direction direction : context.getNearestLookingDirections()) { - BlockState blockstate = state.with(FACING, direction.getOpposite()); - if (blockstate.isValidPosition(context.getWorld(), context.getPos())) - return blockstate.with(POWERED, state.get(POWERED)); + BlockState blockstate = state.setValue(FACING, direction.getOpposite()); + if (blockstate.canSurvive(context.getLevel(), context.getClickedPos())) + return blockstate.setValue(POWERED, state.getValue(POWERED)); } return state; } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(EXTRACTING)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(EXTRACTING)); } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - ItemStack heldItem = player.getHeldItem(handIn); + ItemStack heldItem = player.getItemInHand(handIn); boolean shouldntInsertItem = AllBlocks.MECHANICAL_ARM.isIn(heldItem) || !canInsertIntoFunnel(state); if (AllItems.WRENCH.isIn(heldItem)) return ActionResultType.PASS; - if (hit.getFace() == getFunnelFacing(state) && !shouldntInsertItem) { - if (!worldIn.isRemote) + if (hit.getDirection() == getFunnelFacing(state) && !shouldntInsertItem) { + if (!worldIn.isClientSide) withTileEntityDo(worldIn, pos, te -> { ItemStack toInsert = heldItem.copy(); ItemStack remainder = tryInsert(worldIn, pos, toInsert, false); - if (!ItemStack.areItemStacksEqual(remainder, toInsert)) - player.setHeldItem(handIn, remainder); + if (!ItemStack.matches(remainder, toInsert)) + player.setItemInHand(handIn, remainder); }); return ActionResultType.SUCCESS; } @@ -87,15 +89,15 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getWorld(); - if (!world.isRemote) - world.setBlockState(context.getPos(), state.cycle(EXTRACTING)); + World world = context.getLevel(); + if (!world.isClientSide) + world.setBlockAndUpdate(context.getClickedPos(), state.cycle(EXTRACTING)); return ActionResultType.SUCCESS; } @Override - public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { - if (worldIn.isRemote) + public void entityInside(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + if (worldIn.isClientSide) return; if (!(entityIn instanceof ItemEntity)) return; @@ -106,11 +108,11 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { ItemEntity itemEntity = (ItemEntity) entityIn; Direction direction = getFunnelFacing(state); - Vector3d diff = entityIn.getPositionVec() + Vector3d diff = entityIn.position() .subtract(VecHelper.getCenterOf(pos) - .add(Vector3d.of(direction.getDirectionVec()).scale(-.325f))); + .add(Vector3d.atLowerCornerOf(direction.getNormal()).scale(-.325f))); double projectedDiff = direction.getAxis() - .getCoordinate(diff.x, diff.y, diff.z); + .choose(diff.x, diff.y, diff.z); if (projectedDiff < 0 == (direction.getAxisDirection() == AxisDirection.POSITIVE)) return; @@ -124,12 +126,12 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { } protected boolean canInsertIntoFunnel(BlockState state) { - return !state.get(POWERED) && !state.get(EXTRACTING); + return !state.getValue(POWERED) && !state.getValue(EXTRACTING); } @Override public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) { - Direction facing = state.get(FACING); + Direction facing = state.getValue(FACING); return facing == Direction.DOWN ? AllShapes.FUNNEL_CEILING : facing == Direction.UP ? AllShapes.FUNNEL_FLOOR : AllShapes.FUNNEL_WALL.get(facing); } @@ -143,15 +145,15 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { } @Override - public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState p_196271_3_, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState p_196271_3_, IWorld world, BlockPos pos, BlockPos p_196271_6_) { if (getFacing(state).getAxis() .isVertical() || direction != Direction.DOWN) return state; BlockState equivalentFunnel = getEquivalentBeltFunnel(null, null, state); if (BeltFunnelBlock.isOnValidBelt(equivalentFunnel, world, pos)) - return equivalentFunnel.with(BeltFunnelBlock.SHAPE, - BeltFunnelBlock.getShapeForPosition(world, pos, getFacing(state), state.get(EXTRACTING))); + return equivalentFunnel.setValue(BeltFunnelBlock.SHAPE, + BeltFunnelBlock.getShapeForPosition(world, pos, getFacing(state), state.getValue(EXTRACTING))); return state; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelFilterSlotPositioning.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelFilterSlotPositioning.java index 927296f0a..39aa90062 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelFilterSlotPositioning.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelFilterSlotPositioning.java @@ -22,7 +22,7 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { float stateAngle = AngleHelper.horizontalAngle(funnelFacing); if (state.getBlock() instanceof BeltFunnelBlock) { - switch (state.get(BeltFunnelBlock.SHAPE)) { + switch (state.getValue(BeltFunnelBlock.SHAPE)) { case EXTENDED: return VecHelper.rotateCentered(VecHelper.voxelSpace(8, 15.5f, 13), stateAngle, Axis.Y); @@ -55,8 +55,8 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { } boolean isBeltFunnel = state.getBlock() instanceof BeltFunnelBlock; - if (isBeltFunnel && state.get(BeltFunnelBlock.SHAPE) != Shape.EXTENDED) { - Shape shape = state.get(BeltFunnelBlock.SHAPE); + if (isBeltFunnel && state.getValue(BeltFunnelBlock.SHAPE) != Shape.EXTENDED) { + Shape shape = state.getValue(BeltFunnelBlock.SHAPE); super.rotate(state, ms); if (shape == Shape.PULLING || shape == Shape.PUSHING) MatrixStacker.of(ms) @@ -88,7 +88,7 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { .isVertical()) return direction.getAxis() .isHorizontal(); - if (state.getBlock() instanceof BeltFunnelBlock && state.get(BeltFunnelBlock.SHAPE) == Shape.EXTENDED) + if (state.getBlock() instanceof BeltFunnelBlock && state.getValue(BeltFunnelBlock.SHAPE) == Shape.EXTENDED) return direction == Direction.UP; return direction == facing; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelGenerator.java index b41d3384f..3681ed623 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelGenerator.java @@ -29,21 +29,21 @@ public class FunnelGenerator extends SpecialBlockStateGen { @Override protected int getXRotation(BlockState state) { - return state.get(FunnelBlock.FACING) == Direction.DOWN ? 180 : 0; + return state.getValue(FunnelBlock.FACING) == Direction.DOWN ? 180 : 0; } @Override protected int getYRotation(BlockState state) { - return horizontalAngle(state.get(FunnelBlock.FACING)) + 180; + return horizontalAngle(state.getValue(FunnelBlock.FACING)) + 180; } @Override public ModelFile getModel(DataGenContext c, RegistrateBlockstateProvider p, BlockState s) { - String powered = s.get(FunnelBlock.POWERED) ? "_powered" : ""; - String closed = s.get(FunnelBlock.POWERED) ? "_closed" : "_open"; - String extracting = s.get(FunnelBlock.EXTRACTING) ? "_push" : "_pull"; - Direction facing = s.get(FunnelBlock.FACING); + String powered = s.getValue(FunnelBlock.POWERED) ? "_powered" : ""; + String closed = s.getValue(FunnelBlock.POWERED) ? "_closed" : "_open"; + String extracting = s.getValue(FunnelBlock.EXTRACTING) ? "_push" : "_pull"; + Direction facing = s.getValue(FunnelBlock.FACING); boolean horizontal = facing.getAxis() .isHorizontal(); String parent = horizontal ? "horizontal" : hasFilter ? "vertical" : "vertical_filterless"; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java index 26a975859..170d8e578 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java @@ -32,13 +32,13 @@ public class FunnelInstance extends TileEntityInstance impleme Instancer model = modelManager.getMaterial(AllMaterialSpecs.FLAPS) .getModel(flapPartial, blockState); - int blockLight = world.getLightLevel(LightType.BLOCK, pos); - int skyLight = world.getLightLevel(LightType.SKY, pos); + int blockLight = world.getBrightness(LightType.BLOCK, pos); + int skyLight = world.getBrightness(LightType.SKY, pos); Direction direction = FunnelBlock.getFunnelFacing(blockState); float flapness = tile.flap.get(AnimationTickHolder.getPartialTicks()); - float horizontalAngle = direction.getOpposite().getHorizontalAngle(); + float horizontalAngle = direction.getOpposite().toYRot(); for (int segment = 0; segment <= 3; segment++) { float intensity = segment == 3 ? 1.5f : segment + 1; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelItem.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelItem.java index f127a2b3c..df9cad383 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelItem.java @@ -14,6 +14,8 @@ import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.item.Item.Properties; + @EventBusSubscriber public class FunnelItem extends BlockItem { @@ -29,25 +31,25 @@ public class FunnelItem extends BlockItem { } @Override - protected BlockState getStateForPlacement(BlockItemUseContext ctx) { - World world = ctx.getWorld(); - BlockPos pos = ctx.getPos(); - BlockState state = super.getStateForPlacement(ctx); + protected BlockState getPlacementState(BlockItemUseContext ctx) { + World world = ctx.getLevel(); + BlockPos pos = ctx.getClickedPos(); + BlockState state = super.getPlacementState(ctx); if (state == null) return state; if (!(state.getBlock() instanceof FunnelBlock)) return state; - if (state.get(FunnelBlock.FACING) + if (state.getValue(FunnelBlock.FACING) .getAxis() .isVertical()) return state; - Direction direction = state.get(FunnelBlock.FACING); + Direction direction = state.getValue(FunnelBlock.FACING); FunnelBlock block = (FunnelBlock) getBlock(); Block beltFunnelBlock = block.getEquivalentBeltFunnel(world, pos, state) .getBlock(); BlockState equivalentBeltFunnel = beltFunnelBlock.getStateForPlacement(ctx) - .with(BeltFunnelBlock.HORIZONTAL_FACING, direction); + .setValue(BeltFunnelBlock.HORIZONTAL_FACING, direction); if (BeltFunnelBlock.isOnValidBelt(equivalentBeltFunnel, world, pos)) { AllTriggers.triggerFor(AllTriggers.BELT_FUNNEL, ctx.getPlayer()); return equivalentBeltFunnel; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelMovementBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelMovementBehaviour.java index 78d537c64..b5951638e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelMovementBehaviour.java @@ -38,9 +38,9 @@ public class FunnelMovementBehaviour extends MovementBehaviour { @Override public Vector3d getActiveAreaOffset(MovementContext context) { Direction facing = FunnelBlock.getFunnelFacing(context.state); - Vector3d vec = Vector3d.of(facing.getDirectionVec()); + Vector3d vec = Vector3d.atLowerCornerOf(facing.getNormal()); if (facing != Direction.UP) - return vec.scale(context.state.get(FunnelBlock.EXTRACTING) ? .15 : .65); + return vec.scale(context.state.getValue(FunnelBlock.EXTRACTING) ? .15 : .65); return vec.scale(.65); } @@ -49,7 +49,7 @@ public class FunnelMovementBehaviour extends MovementBehaviour { public void visitNewPosition(MovementContext context, BlockPos pos) { super.visitNewPosition(context, pos); - if (context.state.get(FunnelBlock.EXTRACTING)) + if (context.state.getValue(FunnelBlock.EXTRACTING)) extract(context, pos); else succ(context, pos); @@ -61,13 +61,13 @@ public class FunnelMovementBehaviour extends MovementBehaviour { World world = context.world; Vector3d entityPos = context.position; - if (context.state.get(FunnelBlock.FACING) != Direction.DOWN) + if (context.state.getValue(FunnelBlock.FACING) != Direction.DOWN) entityPos = entityPos.add(0, -.5f, 0); if (!world.getBlockState(pos).getCollisionShape(world, pos).isEmpty()) return;//only drop items if the target block is a empty space - if (!world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(new BlockPos(entityPos))).isEmpty()) + if (!world.getEntitiesOfClass(ItemEntity.class, new AxisAlignedBB(new BlockPos(entityPos))).isEmpty()) return;//don't drop items if there already are any in the target block space ItemStack filter = getFilter(context); @@ -85,21 +85,21 @@ public class FunnelMovementBehaviour extends MovementBehaviour { if (extract.isEmpty()) return; - if (world.isRemote) + if (world.isClientSide) return; ItemEntity entity = new ItemEntity(world, entityPos.x, entityPos.y, entityPos.z, extract); - entity.setMotion(Vector3d.ZERO); - entity.setPickupDelay(5); - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, 1/16f, .1f); - world.addEntity(entity); + entity.setDeltaMovement(Vector3d.ZERO); + entity.setPickUpDelay(5); + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.BLOCKS, 1/16f, .1f); + world.addFreshEntity(entity); } private void succ(MovementContext context, BlockPos pos) { World world = context.world; - List items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos)); + List items = world.getEntitiesOfClass(ItemEntity.class, new AxisAlignedBB(pos)); ItemStack filter = getFilter(context); for (ItemEntity item : items) { @@ -122,7 +122,7 @@ public class FunnelMovementBehaviour extends MovementBehaviour { } private ItemStack getFilter(MovementContext context) { - return hasFilter ? ItemStack.read(context.tileData.getCompound("Filter")) : ItemStack.EMPTY; + return hasFilter ? ItemStack.of(context.tileData.getCompound("Filter")) : ItemStack.EMPTY; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java index 7416c18ba..a5b1914c6 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java @@ -30,11 +30,11 @@ public class FunnelRenderer extends SmartTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (!te.hasFlap() || Backend.getInstance().canUseInstancing(te.getWorld())) + if (!te.hasFlap() || Backend.getInstance().canUseInstancing(te.getLevel())) return; BlockState blockState = te.getBlockState(); - IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); + IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP : AllBlockPartials.BELT_FUNNEL_FLAP); SuperByteBuffer flapBuffer = PartialBufferer.get(partialModel, blockState); @@ -45,14 +45,14 @@ public class FunnelRenderer extends SmartTileEntityRenderer { .getOpposite()); float f = te.flap.get(partialTicks); - ms.push(); + ms.pushPose(); msr.centre() .rotateY(horizontalAngle) .unCentre(); ms.translate(0, 0, -te.getFlapOffset()); for (int segment = 0; segment <= 3; segment++) { - ms.push(); + ms.pushPose(); float intensity = segment == 3 ? 1.5f : segment + 1; float abs = Math.abs(f); @@ -67,10 +67,10 @@ public class FunnelRenderer extends SmartTileEntityRenderer { flapBuffer.light(light) .renderInto(ms, vb); - ms.pop(); + ms.popPose(); ms.translate(-3 / 16f, 0, 0); } - ms.pop(); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java index 116d74468..d6e7773bd 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java @@ -62,24 +62,24 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn BlockState state = getBlockState(); if (!FunnelBlock.isFunnel(state)) return Mode.INVALID; - if (state.method_28500(BlockStateProperties.POWERED) + if (state.getOptionalValue(BlockStateProperties.POWERED) .orElse(false)) return Mode.PAUSED; if (state.getBlock() instanceof BeltFunnelBlock) { - Shape shape = state.get(BeltFunnelBlock.SHAPE); + Shape shape = state.getValue(BeltFunnelBlock.SHAPE); if (shape == Shape.PULLING) return Mode.TAKING_FROM_BELT; if (shape == Shape.PUSHING) return Mode.PUSHING_TO_BELT; - BeltTileEntity belt = BeltHelper.getSegmentTE(world, pos.down()); + BeltTileEntity belt = BeltHelper.getSegmentTE(level, worldPosition.below()); if (belt != null) - return belt.getMovementFacing() == state.get(BeltFunnelBlock.HORIZONTAL_FACING) ? Mode.PUSHING_TO_BELT + return belt.getMovementFacing() == state.getValue(BeltFunnelBlock.HORIZONTAL_FACING) ? Mode.PUSHING_TO_BELT : Mode.TAKING_FROM_BELT; return Mode.INVALID; } if (state.getBlock() instanceof FunnelBlock) - return state.get(FunnelBlock.EXTRACTING) ? Mode.EXTRACT : Mode.COLLECT; + return state.getValue(FunnelBlock.EXTRACTING) ? Mode.EXTRACT : Mode.COLLECT; return Mode.INVALID; } @@ -89,7 +89,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn super.tick(); flap.tick(); Mode mode = determineCurrentMode(); - if (world.isRemote) + if (level.isClientSide) return; // Redstone resets the extraction cooldown @@ -140,7 +140,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn .extract(amountToExtract); if (stack.isEmpty()) return; - for (ItemEntity itemEntity : world.getEntitiesWithinAABB(ItemEntity.class, area)) { + for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, area)) { lastObserved = new WeakReference<>(itemEntity); return; } @@ -153,12 +153,12 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn flap(false); onTransfer(stack); - Vector3d outputPos = VecHelper.getCenterOf(pos); + Vector3d outputPos = VecHelper.getCenterOf(worldPosition); boolean vertical = facing.getAxis() .isVertical(); boolean up = facing == Direction.UP; - outputPos = outputPos.add(Vector3d.of(facing.getDirectionVec()) + outputPos = outputPos.add(Vector3d.atLowerCornerOf(facing.getNormal()) .scale(vertical ? up ? .15f : .5f : .25f)); if (!vertical) outputPos = outputPos.subtract(0, .45f, 0); @@ -167,31 +167,31 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn if (up) motion = new Vector3d(0, 4 / 16f, 0); - ItemEntity item = new ItemEntity(world, outputPos.x, outputPos.y, outputPos.z, stack.copy()); - item.setDefaultPickupDelay(); - item.setMotion(motion); - world.addEntity(item); + ItemEntity item = new ItemEntity(level, outputPos.x, outputPos.y, outputPos.z, stack.copy()); + item.setDefaultPickUpDelay(); + item.setDeltaMovement(motion); + level.addFreshEntity(item); lastObserved = new WeakReference<>(item); startCooldown(); } static final AxisAlignedBB coreBB = - new AxisAlignedBB(VecHelper.CENTER_OF_ORIGIN, VecHelper.CENTER_OF_ORIGIN).grow(.75f); + new AxisAlignedBB(VecHelper.CENTER_OF_ORIGIN, VecHelper.CENTER_OF_ORIGIN).inflate(.75f); private AxisAlignedBB getEntityOverflowScanningArea() { Direction facing = AbstractFunnelBlock.getFunnelFacing(getBlockState()); - AxisAlignedBB bb = coreBB.offset(pos); + AxisAlignedBB bb = coreBB.move(worldPosition); if (facing == null || facing == Direction.UP) return bb; - return bb.expand(0, -1, 0); + return bb.expandTowards(0, -1, 0); } private void activateExtractingBeltFunnel() { BlockState blockState = getBlockState(); - Direction facing = blockState.get(BeltFunnelBlock.HORIZONTAL_FACING); + Direction facing = blockState.getValue(BeltFunnelBlock.HORIZONTAL_FACING); DirectBeltInputBehaviour inputBehaviour = - TileEntityBehaviour.get(world, pos.down(), DirectBeltInputBehaviour.TYPE); + TileEntityBehaviour.get(level, worldPosition.below(), DirectBeltInputBehaviour.TYPE); if (inputBehaviour == null) return; @@ -242,13 +242,13 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn BlockState blockState = getBlockState(); boolean beltFunnelsupportsAmount = false; if (blockState.getBlock() instanceof BeltFunnelBlock) { - Shape shape = blockState.get(BeltFunnelBlock.SHAPE); + Shape shape = blockState.getValue(BeltFunnelBlock.SHAPE); if (shape == Shape.PUSHING) beltFunnelsupportsAmount = true; else - beltFunnelsupportsAmount = BeltHelper.getSegmentTE(world, pos.down()) != null; + beltFunnelsupportsAmount = BeltHelper.getSegmentTE(level, worldPosition.below()) != null; } - boolean extractor = blockState.getBlock() instanceof FunnelBlock && blockState.get(FunnelBlock.EXTRACTING); + boolean extractor = blockState.getBlock() instanceof FunnelBlock && blockState.getValue(FunnelBlock.EXTRACTING); return beltFunnelsupportsAmount || extractor; } @@ -258,7 +258,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn return false; if (!(blockState.getBlock() instanceof FunnelBlock)) return false; - if (blockState.get(FunnelBlock.EXTRACTING)) + if (blockState.getValue(FunnelBlock.EXTRACTING)) return false; return FunnelBlock.getFunnelFacing(blockState) == Direction.UP; } @@ -282,11 +282,11 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn } public void flap(boolean inward) { - if (!world.isRemote) { + if (!level.isClientSide) { AllPackets.channel.send(packetTarget(), new FunnelFlapPacket(this, inward)); } else { flap.set(inward ? 1 : -1); - AllSoundEvents.FUNNEL_FLAP.playAt(world, pos, 1, 1, true); + AllSoundEvents.FUNNEL_FLAP.playAt(level, worldPosition, 1, 1, true); } } @@ -303,7 +303,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn BlockState blockState = getBlockState(); if (!(blockState.getBlock() instanceof BeltFunnelBlock)) return -1 / 16f; - switch (blockState.get(BeltFunnelBlock.SHAPE)) { + switch (blockState.getValue(BeltFunnelBlock.SHAPE)) { default: case RETRACTED: return 0; @@ -331,13 +331,13 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn } @Override - public double getMaxRenderDistanceSquared() { - return hasFlap() ? super.getMaxRenderDistanceSquared() : 64; + public double getViewDistance() { + return hasFlap() ? super.getViewDistance() : 64; } public void onTransfer(ItemStack stack) { AllBlocks.CONTENT_OBSERVER.get() - .onFunnelTransfer(world, pos, stack); + .onFunnelTransfer(level, worldPosition, stack); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateBlock.java index 54af02825..5402bebc7 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateBlock.java @@ -18,6 +18,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraft.block.AbstractBlock.Properties; + public class AdjustableCrateBlock extends CrateBlock { public AdjustableCrateBlock(Properties p_i48415_1_) { @@ -35,10 +37,10 @@ public class AdjustableCrateBlock extends CrateBlock { } @Override - public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { - if (oldState.getBlock() != state.getBlock() && state.hasTileEntity() && state.get(DOUBLE) - && state.get(FACING).getAxisDirection() == AxisDirection.POSITIVE) { - TileEntity tileEntity = worldIn.getTileEntity(pos); + public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + if (oldState.getBlock() != state.getBlock() && state.hasTileEntity() && state.getValue(DOUBLE) + && state.getValue(FACING).getAxisDirection() == AxisDirection.POSITIVE) { + TileEntity tileEntity = worldIn.getBlockEntity(pos); if (!(tileEntity instanceof AdjustableCrateTileEntity)) return; @@ -57,13 +59,13 @@ public class AdjustableCrateBlock extends CrateBlock { } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (worldIn.isRemote) { + if (worldIn.isClientSide) { return ActionResultType.SUCCESS; } else { - TileEntity te = worldIn.getTileEntity(pos); + TileEntity te = worldIn.getBlockEntity(pos); if (te instanceof AdjustableCrateTileEntity) { AdjustableCrateTileEntity fte = (AdjustableCrateTileEntity) te; fte = fte.getMainCrate(); @@ -77,39 +79,39 @@ public class AdjustableCrateBlock extends CrateBlock { BlockState state = world.getBlockState(pos); if (!AllBlocks.ADJUSTABLE_CRATE.has(state)) return; - if (!state.get(DOUBLE)) + if (!state.getValue(DOUBLE)) return; - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (!(te instanceof AdjustableCrateTileEntity)) return; AdjustableCrateTileEntity crateTe = (AdjustableCrateTileEntity) te; crateTe.onSplit(); - world.setBlockState(pos, state.with(DOUBLE, false)); - world.setBlockState(crateTe.getOtherCrate().getPos(), state.with(DOUBLE, false)); + world.setBlockAndUpdate(pos, state.setValue(DOUBLE, false)); + world.setBlockAndUpdate(crateTe.getOtherCrate().getBlockPos(), state.setValue(DOUBLE, false)); } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { - if (!(worldIn.getTileEntity(pos) instanceof AdjustableCrateTileEntity)) + public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + if (!(worldIn.getBlockEntity(pos) instanceof AdjustableCrateTileEntity)) return; if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { - AdjustableCrateTileEntity te = (AdjustableCrateTileEntity) worldIn.getTileEntity(pos); + AdjustableCrateTileEntity te = (AdjustableCrateTileEntity) worldIn.getBlockEntity(pos); if (!isMoving) te.onDestroyed(); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } } @Override - public boolean hasComparatorInputOverride(BlockState state) { + public boolean hasAnalogOutputSignal(BlockState state) { return true; } @Override - public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { - TileEntity te = worldIn.getTileEntity(pos); + public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { + TileEntity te = worldIn.getBlockEntity(pos); if (te instanceof AdjustableCrateTileEntity) { AdjustableCrateTileEntity flexcrateTileEntity = ((AdjustableCrateTileEntity) te).getMainCrate(); return ItemHelper.calcRedstoneFromInventory(flexcrateTileEntity.inventory); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateContainer.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateContainer.java index 20139c8d8..1df87b977 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateContainer.java @@ -22,12 +22,12 @@ public class AdjustableCrateContainer extends Container { public AdjustableCrateContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { super(type, id); - ClientWorld world = Minecraft.getInstance().world; - TileEntity tileEntity = world.getTileEntity(extraData.readBlockPos()); + ClientWorld world = Minecraft.getInstance().level; + TileEntity tileEntity = world.getBlockEntity(extraData.readBlockPos()); this.playerInventory = inv; if (tileEntity instanceof AdjustableCrateTileEntity) { this.te = (AdjustableCrateTileEntity) tileEntity; - this.te.handleUpdateTag(te.getBlockState(), extraData.readCompoundTag()); + this.te.handleUpdateTag(te.getBlockState(), extraData.readNbt()); init(); } } @@ -66,28 +66,28 @@ public class AdjustableCrateContainer extends Container { this.addSlot(new Slot(playerInventory, hotbarSlot, xOffset + hotbarSlot * 18, yOffset + 58)); } - detectAndSendChanges(); + broadcastChanges(); } @Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { Slot clickedSlot = getSlot(index); - if (!clickedSlot.getHasStack()) + if (!clickedSlot.hasItem()) return ItemStack.EMPTY; - ItemStack stack = clickedSlot.getStack(); + ItemStack stack = clickedSlot.getItem(); int crateSize = doubleCrate ? 32 : 16; if (index < crateSize) { - mergeItemStack(stack, crateSize, inventorySlots.size(), false); + moveItemStackTo(stack, crateSize, slots.size(), false); te.inventory.onContentsChanged(index); } else - mergeItemStack(stack, 0, crateSize - 1, false); + moveItemStackTo(stack, 0, crateSize - 1, false); return ItemStack.EMPTY; } @Override - public boolean canInteractWith(PlayerEntity player) { + public boolean stillValid(PlayerEntity player) { return te != null && te.canPlayerUse(player); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateScreen.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateScreen.java index f977b7b61..b77d93a1b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateScreen.java @@ -52,21 +52,21 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen slot * 64) continue; - int slotsPerRow = (container.doubleCrate ? 8 : 4); + int slotsPerRow = (menu.doubleCrate ? 8 : 4); int slotX = x + 22 + (slot % slotsPerRow) * 18; int slotY = y + 19 + (slot / slotsPerRow) * 18; AllGuiTextures.ADJUSTABLE_CRATE_LOCKED_SLOT.draw(ms, this, slotX, slotY); @@ -112,26 +112,26 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen= 0) lastModification++; if (lastModification >= 15) { lastModification = -1; - AllPackets.channel.sendToServer(new ConfigureFlexcratePacket(te.getPos(), allowedItems.getState())); + AllPackets.channel.sendToServer(new ConfigureFlexcratePacket(te.getBlockPos(), allowedItems.getState())); } - if (container.doubleCrate != te.isDoubleCrate()) - container.playerInventory.player.closeScreen(); + if (menu.doubleCrate != te.isDoubleCrate()) + menu.playerInventory.player.closeContainer(); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateTileEntity.java index 0840fe8a4..9ec1fbf31 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateTileEntity.java @@ -48,7 +48,7 @@ public class AdjustableCrateTileEntity extends CrateTileEntity implements INamed @Override protected void onContentsChanged(int slot) { super.onContentsChanged(slot); - markDirty(); + setChanged(); itemCount = 0; for (int i = 0; i < getSlots(); i++) { @@ -78,7 +78,7 @@ public class AdjustableCrateTileEntity extends CrateTileEntity implements INamed public AdjustableCrateTileEntity getOtherCrate() { if (!AllBlocks.ADJUSTABLE_CRATE.has(getBlockState())) return null; - TileEntity tileEntity = world.getTileEntity(pos.offset(getFacing())); + TileEntity tileEntity = level.getBlockEntity(worldPosition.relative(getFacing())); if (tileEntity instanceof AdjustableCrateTileEntity) return (AdjustableCrateTileEntity) tileEntity; return null; @@ -139,7 +139,7 @@ public class AdjustableCrateTileEntity extends CrateTileEntity implements INamed } private void drop(int slot) { - InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), inventory.getStackInSlot(slot)); + InventoryHelper.dropItemStack(level, worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), inventory.getStackInSlot(slot)); } @Override @@ -163,13 +163,13 @@ public class AdjustableCrateTileEntity extends CrateTileEntity implements INamed } public void sendToContainer(PacketBuffer buffer) { - buffer.writeBlockPos(getPos()); - buffer.writeCompoundTag(getUpdateTag()); + buffer.writeBlockPos(getBlockPos()); + buffer.writeNbt(getUpdateTag()); } @Override - public void remove() { - super.remove(); + public void setRemoved() { + super.setRemoved(); invHandler.invalidate(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/CrateBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/CrateBlock.java index 0cc52ac21..5b3e88f97 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/CrateBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/CrateBlock.java @@ -19,14 +19,16 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class CrateBlock extends ProperDirectionalBlock implements IWrenchable { public static final BooleanProperty DOUBLE = BooleanProperty.create("double"); public CrateBlock(Properties p_i48415_1_) { super(p_i48415_1_); - setDefaultState(getDefaultState().with(FACING, Direction.UP) - .with(DOUBLE, false)); + registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP) + .setValue(DOUBLE, false)); } @Override @@ -35,56 +37,56 @@ public class CrateBlock extends ProperDirectionalBlock implements IWrenchable { } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } @Override - public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { - boolean isDouble = stateIn.get(DOUBLE); - Direction blockFacing = stateIn.get(FACING); - boolean isFacingOther = facingState.getBlock() == this && facingState.get(DOUBLE) - && facingState.get(FACING) == facing.getOpposite(); + boolean isDouble = stateIn.getValue(DOUBLE); + Direction blockFacing = stateIn.getValue(FACING); + boolean isFacingOther = facingState.getBlock() == this && facingState.getValue(DOUBLE) + && facingState.getValue(FACING) == facing.getOpposite(); if (!isDouble) { if (!isFacingOther) return stateIn; - return stateIn.with(DOUBLE, true) - .with(FACING, facing); + return stateIn.setValue(DOUBLE, true) + .setValue(FACING, facing); } if (facing != blockFacing) return stateIn; if (!isFacingOther) - return stateIn.with(DOUBLE, false); + return stateIn.setValue(DOUBLE, false); return stateIn; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - BlockPos pos = context.getPos(); - World world = context.getWorld(); + BlockPos pos = context.getClickedPos(); + World world = context.getLevel(); if (context.getPlayer() == null || !context.getPlayer() - .isSneaking()) { + .isShiftKeyDown()) { for (Direction d : Iterate.directions) { - BlockState state = world.getBlockState(pos.offset(d)); - if (state.getBlock() == this && !state.get(DOUBLE)) - return getDefaultState().with(FACING, d) - .with(DOUBLE, true); + BlockState state = world.getBlockState(pos.relative(d)); + if (state.getBlock() == this && !state.getValue(DOUBLE)) + return defaultBlockState().setValue(FACING, d) + .setValue(DOUBLE, true); } } - Direction placedOnFace = context.getFace() + Direction placedOnFace = context.getClickedFace() .getOpposite(); - BlockState state = world.getBlockState(pos.offset(placedOnFace)); - if (state.getBlock() == this && !state.get(DOUBLE)) - return getDefaultState().with(FACING, placedOnFace) - .with(DOUBLE, true); - return getDefaultState(); + BlockState state = world.getBlockState(pos.relative(placedOnFace)); + if (state.getBlock() == this && !state.getValue(DOUBLE)) + return defaultBlockState().setValue(FACING, placedOnFace) + .setValue(DOUBLE, true); + return defaultBlockState(); } @Override @@ -93,8 +95,8 @@ public class CrateBlock extends ProperDirectionalBlock implements IWrenchable { } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(DOUBLE)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(DOUBLE)); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/CrateTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/CrateTileEntity.java index b4602f230..427afa31f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/CrateTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/CrateTileEntity.java @@ -19,11 +19,11 @@ public abstract class CrateTileEntity extends SmartTileEntity { public void addBehaviours(List behaviours) {} public boolean isDoubleCrate() { - return getBlockState().get(AdjustableCrateBlock.DOUBLE); + return getBlockState().getValue(AdjustableCrateBlock.DOUBLE); } public boolean isSecondaryCrate() { - if (!hasWorld()) + if (!hasLevel()) return false; if (!(getBlockState().getBlock() instanceof CrateBlock)) return false; @@ -31,7 +31,7 @@ public abstract class CrateTileEntity extends SmartTileEntity { } public Direction getFacing() { - return getBlockState().get(AdjustableCrateBlock.FACING); + return getBlockState().getValue(AdjustableCrateBlock.FACING); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/CreativeCrateBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/CreativeCrateBlock.java index f83ba35db..16f35efac 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/CreativeCrateBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/CreativeCrateBlock.java @@ -9,6 +9,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class CreativeCrateBlock extends CrateBlock implements ITE { public CreativeCrateBlock(Properties p_i48415_1_) { @@ -26,7 +28,7 @@ public class CreativeCrateBlock extends CrateBlock implements ITE, ICogWheel { public static final BooleanProperty CEILING = BooleanProperty.create("ceiling"); public ArmBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(CEILING, false)); + registerDefaultState(defaultBlockState().setValue(CEILING, false)); } @Override - protected void fillStateContainer(Builder p_206840_1_) { - super.fillStateContainer(p_206840_1_.add(CEILING)); + protected void createBlockStateDefinition(Builder p_206840_1_) { + super.createBlockStateDefinition(p_206840_1_.add(CEILING)); } @Override public BlockState getStateForPlacement(BlockItemUseContext ctx) { - return getDefaultState().with(CEILING, ctx.getFace() == Direction.DOWN); + return defaultBlockState().setValue(CEILING, ctx.getClickedFace() == Direction.DOWN); } @Override public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - return state.get(CEILING) ? AllShapes.MECHANICAL_ARM_CEILING : AllShapes.MECHANICAL_ARM; + return state.getValue(CEILING) ? AllShapes.MECHANICAL_ARM_CEILING : AllShapes.MECHANICAL_ARM; } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { - super.onBlockAdded(state, world, pos, oldState, isMoving); + public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + super.onPlace(state, world, pos, oldState, isMoving); withTileEntityDo(world, pos, ArmTileEntity::redstoneUpdate); } @@ -82,32 +84,32 @@ public class ArmBlock extends KineticBlock implements ITE, ICogWh } @Override - public void onReplaced(BlockState p_196243_1_, World world, BlockPos pos, BlockState p_196243_4_, + public void onRemove(BlockState p_196243_1_, World world, BlockPos pos, BlockState p_196243_4_, boolean p_196243_5_) { if (p_196243_1_.hasTileEntity() && (p_196243_1_.getBlock() != p_196243_4_.getBlock() || !p_196243_4_.hasTileEntity())) { withTileEntityDo(world, pos, te -> { if (!te.heldItem.isEmpty()) - InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), te.heldItem); + InventoryHelper.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), te.heldItem); }); - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } } @Override - public ActionResultType onUse(BlockState p_225533_1_, World world, BlockPos pos, PlayerEntity player, + public ActionResultType use(BlockState p_225533_1_, World world, BlockPos pos, PlayerEntity player, Hand p_225533_5_, BlockRayTraceResult p_225533_6_) { MutableBoolean success = new MutableBoolean(false); withTileEntityDo(world, pos, te -> { if (te.heldItem.isEmpty()) return; success.setTrue(); - if (world.isRemote) + if (world.isClientSide) return; player.inventory.placeItemBackInInventory(world, te.heldItem); te.heldItem = ItemStack.EMPTY; te.phase = Phase.SEARCH_INPUTS; - te.markDirty(); + te.setChanged(); te.sendData(); }); 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 3f0f4b12b..9bc1d69bd 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 @@ -62,7 +62,7 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta clawGrips = Lists.newArrayList(clawGrip1, clawGrip2); models = Lists.newArrayList(base, lowerBody, upperBody, head, claw, clawGrip1, clawGrip2); arm = tile; - ceiling = blockState.get(ArmBlock.CEILING); + ceiling = blockState.getValue(ArmBlock.CEILING); animateArm(false); } @@ -82,10 +82,10 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta float upperArmAngleNow = this.arm.upperArmAngle.get(pt); float headAngleNow = this.arm.headAngle.get(pt); - boolean settled = MathHelper.epsilonEquals(baseAngle, baseAngleNow) - && MathHelper.epsilonEquals(lowerArmAngle, lowerArmAngleNow) - && MathHelper.epsilonEquals(upperArmAngle, upperArmAngleNow) - && MathHelper.epsilonEquals(headAngle, headAngleNow); + boolean settled = MathHelper.equal(baseAngle, baseAngleNow) + && MathHelper.equal(lowerArmAngle, lowerArmAngleNow) + && MathHelper.equal(upperArmAngle, upperArmAngleNow) + && MathHelper.equal(headAngle, headAngleNow); this.baseAngle = baseAngleNow; this.lowerArmAngle = lowerArmAngleNow; @@ -107,7 +107,7 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta int color; if (rave) { - float renderTick = AnimationTickHolder.getRenderTime(this.arm.getWorld()) + (tile.hashCode() % 64); + float renderTick = AnimationTickHolder.getRenderTime(this.arm.getLevel()) + (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); @@ -151,15 +151,15 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta .getItemRenderer(); boolean hasItem = !item.isEmpty(); boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) - && itemRenderer.getItemModelWithOverrides(item, Minecraft.getInstance().world, null) + && itemRenderer.getModel(item, Minecraft.getInstance().level, null) .isGui3d(); for (int index : Iterate.zeroAndOne) { - msLocal.push(); + msLocal.pushPose(); int flip = index * 2 - 1; ArmRenderer.transformClawHalf(msr, hasItem, isBlockItem, flip); clawGrips.get(index).setTransform(msLocal); - msLocal.pop(); + msLocal.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java index f6b40d285..f295f8260 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java @@ -151,7 +151,7 @@ public abstract class ArmInteractionPoint { @Nullable protected IItemHandler getHandler(World world) { if (!cachedHandler.isPresent()) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (te == null) return null; cachedHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP); @@ -212,7 +212,7 @@ public abstract class ArmInteractionPoint { protected static ArmInteractionPoint deserialize(IBlockReader world, BlockPos anchor, CompoundNBT nbt) { BlockPos pos = NBTUtil.readBlockPos(nbt.getCompound("Pos")); - ArmInteractionPoint interactionPoint = createAt(world, pos.add(anchor)); + ArmInteractionPoint interactionPoint = createAt(world, pos.offset(anchor)); if (interactionPoint == null) return null; interactionPoint.mode = NBTHelper.readEnum(nbt, "Mode", Mode.class); @@ -229,7 +229,7 @@ public abstract class ArmInteractionPoint { @Override protected Vector3d getInteractionPositionVector() { - return Vector3d.of(pos).add(.5f, 1, .5f); + return Vector3d.atLowerCornerOf(pos).add(.5f, 1, .5f); } } @@ -238,7 +238,7 @@ public abstract class ArmInteractionPoint { @Override protected Vector3d getInteractionPositionVector() { - return Vector3d.of(pos).add(.5f, 14 / 16f, .5f); + return Vector3d.atLowerCornerOf(pos).add(.5f, 14 / 16f, .5f); } @Override @@ -252,8 +252,8 @@ public abstract class ArmInteractionPoint { @Override protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { - return AllBlocks.MECHANICAL_SAW.has(state) && state.get(SawBlock.FACING) == Direction.UP - && ((KineticTileEntity) reader.getTileEntity(pos)).getSpeed() != 0; + return AllBlocks.MECHANICAL_SAW.has(state) && state.getValue(SawBlock.FACING) == Direction.UP + && ((KineticTileEntity) reader.getBlockEntity(pos)).getSpeed() != 0; } } @@ -280,7 +280,7 @@ public abstract class ArmInteractionPoint { @Override protected Vector3d getInteractionPositionVector() { - return Vector3d.of(pos).add(.5f, 13 / 16f, .5f); + return Vector3d.atLowerCornerOf(pos).add(.5f, 13 / 16f, .5f); } @Override @@ -292,7 +292,7 @@ public abstract class ArmInteractionPoint { @Override protected IItemHandler getHandler(World world) { return new InvWrapper( - ((ComposterBlock) Blocks.COMPOSTER).createInventory(world.getBlockState(pos), world, pos)); + ((ComposterBlock) Blocks.COMPOSTER).getContainer(world.getBlockState(pos), world, pos)); } } @@ -305,14 +305,14 @@ public abstract class ArmInteractionPoint { @Override protected Direction getInteractionDirection() { - return state.get(DeployerBlock.FACING) + return state.getValue(DeployerBlock.FACING) .getOpposite(); } @Override protected Vector3d getInteractionPositionVector() { return super.getInteractionPositionVector() - .add(Vector3d.of(getInteractionDirection().getDirectionVec()).scale(.65f)); + .add(Vector3d.atLowerCornerOf(getInteractionDirection().getNormal()).scale(.65f)); } } @@ -333,12 +333,12 @@ public abstract class ArmInteractionPoint { protected ItemStack insert(World world, ItemStack stack, boolean simulate) { ItemStack input = stack.copy(); if (!BlazeBurnerBlock.tryInsert(state, world, pos, input, false, true) - .getResult() + .getObject() .isEmpty()) { return stack; } ActionResult res = BlazeBurnerBlock.tryInsert(state, world, pos, input, false, simulate); - return res.getType() == ActionResultType.SUCCESS + return res.getResult() == ActionResultType.SUCCESS ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1) : stack; } @@ -357,13 +357,13 @@ public abstract class ArmInteractionPoint { @Override protected Direction getInteractionDirection() { - return state.get(MechanicalCrafterBlock.HORIZONTAL_FACING) + return state.getValue(MechanicalCrafterBlock.HORIZONTAL_FACING) .getOpposite(); } @Override protected ItemStack extract(World world, int slot, int amount, boolean simulate) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (!(te instanceof MechanicalCrafterTileEntity)) return ItemStack.EMPTY; MechanicalCrafterTileEntity crafter = (MechanicalCrafterTileEntity) te; @@ -377,7 +377,7 @@ public abstract class ArmInteractionPoint { @Override protected Vector3d getInteractionPositionVector() { return super.getInteractionPositionVector() - .add(Vector3d.of(getInteractionDirection().getDirectionVec()).scale(.5f)); + .add(Vector3d.atLowerCornerOf(getInteractionDirection().getNormal()).scale(.5f)); } } @@ -405,7 +405,7 @@ public abstract class ArmInteractionPoint { @Override protected ItemStack insert(World world, ItemStack stack, boolean simulate) { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (!(tileEntity instanceof JukeboxTileEntity)) return stack; if (!(state.getBlock() instanceof JukeboxBlock)) @@ -419,9 +419,9 @@ public abstract class ArmInteractionPoint { return stack; ItemStack remainder = stack.copy(); ItemStack toInsert = remainder.split(1); - if (!simulate && !world.isRemote) { - jukeboxBlock.insertRecord(world, pos, state, toInsert); - world.playEvent(null, 1010, pos, Item.getIdFromItem(toInsert.getItem())); + if (!simulate && !world.isClientSide) { + jukeboxBlock.setRecord(world, pos, state, toInsert); + world.levelEvent(null, 1010, pos, Item.getId(toInsert.getItem())); AllTriggers.triggerForNearbyPlayers(AllTriggers.MUSICAL_ARM, world, pos, 10); } return remainder; @@ -429,7 +429,7 @@ public abstract class ArmInteractionPoint { @Override protected ItemStack extract(World world, int slot, int amount, boolean simulate) { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (!(tileEntity instanceof JukeboxTileEntity)) return ItemStack.EMPTY; if (!(state.getBlock() instanceof JukeboxBlock)) @@ -438,10 +438,10 @@ public abstract class ArmInteractionPoint { ItemStack itemstack = jukeboxTE.getRecord(); if (itemstack.isEmpty()) return ItemStack.EMPTY; - if (!simulate && !world.isRemote) { - world.playEvent(1010, pos, 0); - jukeboxTE.clear(); - world.setBlockState(pos, state.with(JukeboxBlock.HAS_RECORD, false), 2); + if (!simulate && !world.isClientSide) { + world.levelEvent(1010, pos, 0); + jukeboxTE.clearContent(); + world.setBlock(pos, state.setValue(JukeboxBlock.HAS_RECORD, false), 2); } return itemstack; } @@ -452,7 +452,7 @@ public abstract class ArmInteractionPoint { @Override protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { - return AllBlocks.BELT.has(state) && !(reader.getBlockState(pos.up()) + return AllBlocks.BELT.has(state) && !(reader.getBlockState(pos.above()) .getBlock() instanceof BeltTunnelBlock); } @@ -491,8 +491,8 @@ public abstract class ArmInteractionPoint { @Override protected Vector3d getInteractionPositionVector() { return VecHelper.getCenterOf(pos) - .add(Vector3d.of(FunnelBlock.getFunnelFacing(state) - .getDirectionVec()).scale(-.15f)); + .add(Vector3d.atLowerCornerOf(FunnelBlock.getFunnelFacing(state) + .getNormal()).scale(-.15f)); } @Override @@ -516,7 +516,7 @@ public abstract class ArmInteractionPoint { FilteringBehaviour filtering = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE); InvManipulationBehaviour inserter = TileEntityBehaviour.get(world, pos, InvManipulationBehaviour.TYPE); BlockState state = world.getBlockState(pos); - if (state.method_28500(BlockStateProperties.POWERED).orElse(false)) + if (state.getOptionalValue(BlockStateProperties.POWERED).orElse(false)) return stack; if (inserter == null) return stack; @@ -526,7 +526,7 @@ public abstract class ArmInteractionPoint { inserter.simulate(); ItemStack insert = inserter.insert(stack); if (!simulate && insert.getCount() != stack.getCount()) { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (tileEntity instanceof FunnelTileEntity) { FunnelTileEntity funnelTileEntity = (FunnelTileEntity) tileEntity; funnelTileEntity.onTransfer(stack); @@ -540,8 +540,8 @@ public abstract class ArmInteractionPoint { @Override protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { return state.getBlock() instanceof AbstractFunnelBlock - && !(state.contains(FunnelBlock.EXTRACTING) && state.get(FunnelBlock.EXTRACTING)) - && !(state.contains(BeltFunnelBlock.SHAPE) && state.get(BeltFunnelBlock.SHAPE) == Shape.PUSHING); + && !(state.hasProperty(FunnelBlock.EXTRACTING) && state.getValue(FunnelBlock.EXTRACTING)) + && !(state.hasProperty(BeltFunnelBlock.SHAPE) && state.getValue(BeltFunnelBlock.SHAPE) == Shape.PUSHING); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java index ff7cbdcc1..7e7142efc 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java @@ -45,7 +45,7 @@ public class ArmInteractionPointHandler { return; BlockPos pos = event.getPos(); World world = event.getWorld(); - if (!world.isRemote) + if (!world.isClientSide) return; PlayerEntity player = event.getPlayer(); if (player != null && player.isSpectator()) @@ -66,8 +66,8 @@ public class ArmInteractionPointHandler { String key = selected.mode == Mode.DEPOSIT ? "mechanical_arm.deposit_to" : "mechanical_arm.extract_from"; TextFormatting colour = selected.mode == Mode.DEPOSIT ? TextFormatting.GOLD : TextFormatting.AQUA; TranslationTextComponent translatedBlock = new TranslationTextComponent(selected.state.getBlock() - .getTranslationKey()); - player.sendStatusMessage((Lang.translate(key, translatedBlock.formatted(TextFormatting.WHITE, colour)).formatted(colour)), + .getDescriptionId()); + player.displayClientMessage((Lang.translate(key, translatedBlock.withStyle(TextFormatting.WHITE, colour)).withStyle(colour)), true); } @@ -79,7 +79,7 @@ public class ArmInteractionPointHandler { public static void leftClickingBlocksDeselectsThem(PlayerInteractEvent.LeftClickBlock event) { if (currentItem == null) return; - if (!event.getWorld().isRemote) + if (!event.getWorld().isClientSide) return; BlockPos pos = event.getPos(); if (remove(pos) != null) { @@ -95,7 +95,7 @@ public class ArmInteractionPointHandler { int removed = 0; for (Iterator iterator = currentSelection.iterator(); iterator.hasNext();) { ArmInteractionPoint point = iterator.next(); - if (point.pos.withinDistance(pos, ArmTileEntity.getRange())) + if (point.pos.closerThan(pos, ArmTileEntity.getRange())) continue; iterator.remove(); removed++; @@ -103,8 +103,8 @@ public class ArmInteractionPointHandler { ClientPlayerEntity player = Minecraft.getInstance().player; if (removed > 0) { - player.sendStatusMessage(Lang.createTranslationTextComponent("mechanical_arm.points_outside_range", removed) - .formatted(TextFormatting.RED), true); + player.displayClientMessage(Lang.createTranslationTextComponent("mechanical_arm.points_outside_range", removed) + .withStyle(TextFormatting.RED), true); } else { int inputs = 0; int outputs = 0; @@ -115,8 +115,8 @@ public class ArmInteractionPointHandler { inputs++; } if (inputs + outputs > 0) - player.sendStatusMessage(Lang.createTranslationTextComponent("mechanical_arm.summary", inputs, outputs) - .formatted(TextFormatting.WHITE), true); + player.displayClientMessage(Lang.createTranslationTextComponent("mechanical_arm.summary", inputs, outputs) + .withStyle(TextFormatting.WHITE), true); } AllPackets.channel.sendToServer(new ArmPlacementPacket(currentSelection, pos)); @@ -130,7 +130,7 @@ public class ArmInteractionPointHandler { if (player == null) return; - ItemStack heldItemMainhand = player.getHeldItemMainhand(); + ItemStack heldItemMainhand = player.getMainHandItem(); if (!AllBlocks.MECHANICAL_ARM.isIn(heldItemMainhand)) { currentItem = null; } else { @@ -150,27 +150,27 @@ public class ArmInteractionPointHandler { return; } - RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver; + RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; if (!(objectMouseOver instanceof BlockRayTraceResult)) { return; } BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; - BlockPos pos = result.getPos(); + BlockPos pos = result.getBlockPos(); - TileEntity te = Minecraft.getInstance().world.getTileEntity(pos); + TileEntity te = Minecraft.getInstance().level.getBlockEntity(pos); if (!(te instanceof ArmTileEntity)) { lastBlockPos = -1; currentSelection.clear(); return; } - if (lastBlockPos == -1 || lastBlockPos != pos.toLong()) { + if (lastBlockPos == -1 || lastBlockPos != pos.asLong()) { currentSelection.clear(); ArmTileEntity arm = (ArmTileEntity) te; arm.inputs.forEach(ArmInteractionPointHandler::put); arm.outputs.forEach(ArmInteractionPointHandler::put); - lastBlockPos = pos.toLong(); + lastBlockPos = pos.asLong(); } if (lastBlockPos != -1) { @@ -179,7 +179,7 @@ public class ArmInteractionPointHandler { } private static void drawOutlines(Collection selection) { - World world = Minecraft.getInstance().world; + World world = Minecraft.getInstance().level; for (Iterator iterator = selection.iterator(); iterator.hasNext();) { ArmInteractionPoint point = iterator.next(); BlockPos pos = point.pos; @@ -195,8 +195,8 @@ public class ArmInteractionPointHandler { continue; int color = point.mode == Mode.DEPOSIT ? 0xffcb74 : 0x4f8a8b; - CreateClient.OUTLINER.showAABB(point, shape.getBoundingBox() - .offset(pos)) + CreateClient.OUTLINER.showAABB(point, shape.bounds() + .move(pos)) .colored(color) .lineWidth(1 / 16f); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmItem.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmItem.java index c032ed3dc..ed0f82dc0 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmItem.java @@ -13,6 +13,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.item.Item.Properties; + @EventBusSubscriber public class ArmItem extends BlockItem { @@ -21,24 +23,24 @@ public class ArmItem extends BlockItem { } @Override - public ActionResultType onItemUse(ItemUseContext ctx) { - World world = ctx.getWorld(); - BlockPos pos = ctx.getPos(); + public ActionResultType useOn(ItemUseContext ctx) { + World world = ctx.getLevel(); + BlockPos pos = ctx.getClickedPos(); if (ArmInteractionPoint.isInteractable(world, pos, world.getBlockState(pos))) return ActionResultType.SUCCESS; - return super.onItemUse(ctx); + return super.useOn(ctx); } @Override - protected boolean onBlockPlaced(BlockPos pos, World world, PlayerEntity p_195943_3_, ItemStack p_195943_4_, + protected boolean updateCustomBlockEntityTag(BlockPos pos, World world, PlayerEntity p_195943_3_, ItemStack p_195943_4_, BlockState p_195943_5_) { - if (world.isRemote) + if (world.isClientSide) DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ArmInteractionPointHandler.flushSettings(pos)); - return super.onBlockPlaced(pos, world, p_195943_3_, p_195943_4_, p_195943_5_); + return super.updateCustomBlockEntityTag(pos, world, p_195943_3_, p_195943_4_, p_195943_5_); } @Override - public boolean canPlayerBreakBlockWhileHolding(BlockState state, World world, BlockPos pos, + public boolean canAttackBlock(BlockState state, World world, BlockPos pos, PlayerEntity p_195938_4_) { return !ArmInteractionPoint.isInteractable(world, pos, state); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmPlacementPacket.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmPlacementPacket.java index 5ef6187a7..df74cd272 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmPlacementPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmPlacementPacket.java @@ -27,7 +27,7 @@ public class ArmPlacementPacket extends SimplePacketBase { } public ArmPlacementPacket(PacketBuffer buffer) { - CompoundNBT nbt = buffer.readCompoundTag(); + CompoundNBT nbt = buffer.readNbt(); receivedTag = nbt.getList("Points", NBT.TAG_COMPOUND); pos = buffer.readBlockPos(); } @@ -40,7 +40,7 @@ public class ArmPlacementPacket extends SimplePacketBase { .map(aip -> aip.serialize(pos)) .forEach(pointsNBT::add); nbt.put("Points", pointsNBT); - buffer.writeCompoundTag(nbt); + buffer.writeNbt(nbt); buffer.writeBlockPos(pos); } @@ -52,10 +52,10 @@ public class ArmPlacementPacket extends SimplePacketBase { .getSender(); if (player == null) return; - World world = player.world; - if (world == null || !world.isBlockPresent(pos)) + World world = player.level; + if (world == null || !world.isLoaded(pos)) return; - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (!(tileEntity instanceof ArmTileEntity)) return; 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 3955b833c..0b3fc6077 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 @@ -32,7 +32,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { } @Override - public boolean isGlobalRenderer(KineticTileEntity te) { + public boolean shouldRenderOffScreen(KineticTileEntity te) { return true; } @@ -44,7 +44,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { ArmTileEntity arm = (ArmTileEntity) te; ItemStack item = arm.heldItem; boolean hasItem = !item.isEmpty(); - boolean usingFlywheel = Backend.getInstance().canUseInstancing(te.getWorld()); + boolean usingFlywheel = Backend.getInstance().canUseInstancing(te.getLevel()); if (usingFlywheel && !hasItem) return; @@ -52,10 +52,10 @@ public class ArmRenderer extends KineticTileEntityRenderer { .getItemRenderer(); boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) - && itemRenderer.getItemModelWithOverrides(item, Minecraft.getInstance().world, null) + && itemRenderer.getModel(item, Minecraft.getInstance().level, null) .isGui3d(); - IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid()); + IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); BlockState blockState = te.getBlockState(); MatrixStack msLocal = new MatrixStack(); @@ -69,7 +69,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { boolean rave = arm.phase == Phase.DANCING && te.getSpeed() != 0; if (rave) { - float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()) + (te.hashCode() % 64); + float renderTick = AnimationTickHolder.getRenderTime(te.getLevel()) + (te.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); @@ -85,7 +85,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { msr.centre(); - if (blockState.get(ArmBlock.CEILING)) + if (blockState.getValue(ArmBlock.CEILING)) msr.rotateX(180); if (usingFlywheel) @@ -94,17 +94,17 @@ public class ArmRenderer extends KineticTileEntityRenderer { renderArm(builder, ms, msLocal, msr, blockState, color, baseAngle, lowerArmAngle, upperArmAngle, headAngle, hasItem, isBlockItem, light); if (hasItem) { - ms.push(); + ms.pushPose(); float itemScale = isBlockItem ? .5f : .625f; msr.rotateX(90); msLocal.translate(0, -4 / 16f, 0); msLocal.scale(itemScale, itemScale, itemScale); - ms.peek().getModel().multiply(msLocal.peek().getModel()); + ms.last().pose().multiply(msLocal.last().pose()); itemRenderer - .renderItem(item, TransformType.FIXED, light, overlay, ms, buffer); - ms.pop(); + .renderStatic(item, TransformType.FIXED, light, overlay, ms, buffer); + ms.popPose(); } } @@ -140,10 +140,10 @@ public class ArmRenderer extends KineticTileEntityRenderer { .renderInto(ms, builder); for (int flip : Iterate.positiveAndNegative) { - msLocal.push(); + msLocal.pushPose(); transformClawHalf(msr, hasItem, isBlockItem, flip); clawGrip.light(light).transform(msLocal).renderInto(ms, builder); - msLocal.pop(); + msLocal.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java index 6a9fbde49..8c374085a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java @@ -118,11 +118,11 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE if (phase == Phase.MOVE_TO_INPUT) { ArmInteractionPoint point = getTargetedInteractionPoint(); if (point != null) - point.keepAlive(world); + point.keepAlive(level); } return; } - if (world.isRemote) + if (level.isClientSide) return; if (phase == Phase.MOVE_TO_INPUT) @@ -140,7 +140,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE public void lazyTick() { super.lazyTick(); - if (world.isRemote) + if (level.isClientSide) return; if (chasedPointProgress < .5f) return; @@ -154,7 +154,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE boolean hasMusic = checkForMusicAmong(inputs) || checkForMusicAmong(outputs); if (hasMusic != (phase == Phase.DANCING)) { phase = hasMusic ? Phase.DANCING : Phase.SEARCH_INPUTS; - markDirty(); + setChanged(); sendData(); } } @@ -162,15 +162,15 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE @Override @OnlyIn(Dist.CLIENT) public AxisAlignedBB makeRenderBoundingBox() { - return super.makeRenderBoundingBox().grow(3); + return super.makeRenderBoundingBox().inflate(3); } private boolean checkForMusicAmong(List list) { for (ArmInteractionPoint armInteractionPoint : list) { if (!(armInteractionPoint instanceof Jukebox)) continue; - BlockState state = world.getBlockState(armInteractionPoint.pos); - if (state.method_28500(JukeboxBlock.HAS_RECORD).orElse(false)) + BlockState state = level.getBlockState(armInteractionPoint.pos); + if (state.getOptionalValue(JukeboxBlock.HAS_RECORD).orElse(false)) return true; } return false; @@ -181,13 +181,13 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE chasedPointProgress += Math.min(256, Math.abs(getSpeed())) / 1024f; if (chasedPointProgress > 1) chasedPointProgress = 1; - if (!world.isRemote) + if (!level.isClientSide) return !targetReachedPreviously && chasedPointProgress >= 1; ArmInteractionPoint targetedInteractionPoint = getTargetedInteractionPoint(); ArmAngleTarget previousTarget = this.previousTarget; ArmAngleTarget target = targetedInteractionPoint == null ? ArmAngleTarget.NO_TARGET - : targetedInteractionPoint.getTargetAngles(pos, isOnCeiling()); + : targetedInteractionPoint.getTargetAngles(worldPosition, isOnCeiling()); baseAngle.set(AngleHelper.angleLerp(chasedPointProgress, previousBaseAngle, target == ArmAngleTarget.NO_TARGET ? previousBaseAngle : target.baseAngle)); @@ -208,7 +208,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE protected boolean isOnCeiling() { BlockState state = getBlockState(); - return hasWorld() && state.method_28500(ArmBlock.CEILING).orElse(false); + return hasLevel() && state.getOptionalValue(ArmBlock.CEILING).orElse(false); } @Nullable @@ -239,9 +239,9 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE InteractionPoints: for (int i = startIndex; i < scanRange; i++) { ArmInteractionPoint armInteractionPoint = inputs.get(i); - if (!armInteractionPoint.isStillValid(world)) + if (!armInteractionPoint.isStillValid(level)) continue; - for (int j = 0; j < armInteractionPoint.getSlotCount(world); j++) { + for (int j = 0; j < armInteractionPoint.getSlotCount(level); j++) { if (getDistributableAmount(armInteractionPoint, j) == 0) continue; @@ -277,10 +277,10 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE for (int i = startIndex; i < scanRange; i++) { ArmInteractionPoint armInteractionPoint = outputs.get(i); - if (!armInteractionPoint.isStillValid(world)) + if (!armInteractionPoint.isStillValid(level)) continue; - ItemStack remainder = armInteractionPoint.insert(world, held, true); + ItemStack remainder = armInteractionPoint.insert(level, held, true); if (remainder.equals(heldItem, false)) continue; @@ -310,11 +310,11 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE else lastOutputIndex = index; sendData(); - markDirty(); + setChanged(); } protected int getDistributableAmount(ArmInteractionPoint armInteractionPoint, int i) { - ItemStack stack = armInteractionPoint.extract(world, i, true); + ItemStack stack = armInteractionPoint.extract(level, i, true); ItemStack remainder = simulateInsertion(stack); return stack.getCount() - remainder.getCount(); } @@ -323,37 +323,37 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE ArmInteractionPoint armInteractionPoint = getTargetedInteractionPoint(); if (armInteractionPoint != null) { ItemStack toInsert = heldItem.copy(); - ItemStack remainder = armInteractionPoint.insert(world, toInsert, false); + ItemStack remainder = armInteractionPoint.insert(level, toInsert, false); heldItem = remainder; } phase = heldItem.isEmpty() ? Phase.SEARCH_INPUTS : Phase.SEARCH_OUTPUTS; chasedPointProgress = 0; chasedPointIndex = -1; sendData(); - markDirty(); + setChanged(); - if (!world.isRemote) - AllTriggers.triggerForNearbyPlayers(AllTriggers.MECHANICAL_ARM, world, pos, 10); + if (!level.isClientSide) + AllTriggers.triggerForNearbyPlayers(AllTriggers.MECHANICAL_ARM, level, worldPosition, 10); } protected void collectItem() { ArmInteractionPoint armInteractionPoint = getTargetedInteractionPoint(); if (armInteractionPoint != null) - for (int i = 0; i < armInteractionPoint.getSlotCount(world); i++) { + for (int i = 0; i < armInteractionPoint.getSlotCount(level); i++) { int amountExtracted = getDistributableAmount(armInteractionPoint, i); if (amountExtracted == 0) continue; ItemStack prevHeld = heldItem; - heldItem = armInteractionPoint.extract(world, i, amountExtracted, false); + heldItem = armInteractionPoint.extract(level, i, amountExtracted, false); phase = Phase.SEARCH_OUTPUTS; chasedPointProgress = 0; chasedPointIndex = -1; sendData(); - markDirty(); + setChanged(); - if (!prevHeld.isItemEqual(heldItem)) - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, .125f, + if (!prevHeld.sameItem(heldItem)) + level.playSound(null, worldPosition, SoundEvents.ITEM_PICKUP, SoundCategory.BLOCKS, .125f, .5f + Create.RANDOM.nextFloat() * .25f); return; } @@ -362,12 +362,12 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE chasedPointProgress = 0; chasedPointIndex = -1; sendData(); - markDirty(); + setChanged(); } private ItemStack simulateInsertion(ItemStack stack) { for (ArmInteractionPoint armInteractionPoint : outputs) { - stack = armInteractionPoint.insert(world, stack, true); + stack = armInteractionPoint.insert(level, stack, true); if (stack.isEmpty()) break; } @@ -375,9 +375,9 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE } public void redstoneUpdate() { - if (world.isRemote) + if (level.isClientSide) return; - boolean blockPowered = world.isBlockPowered(pos); + boolean blockPowered = level.hasNeighborSignal(worldPosition); if (blockPowered == redstoneLocked) return; redstoneLocked = blockPowered; @@ -396,20 +396,20 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE } sendData(); - markDirty(); + setChanged(); } protected void initInteractionPoints() { if (!updateInteractionPoints || interactionPointTag == null) return; - if (!world.isAreaLoaded(pos, getRange() + 1)) + if (!level.isAreaLoaded(worldPosition, getRange() + 1)) return; inputs.clear(); outputs.clear(); boolean hasBlazeBurner = false; for (INBT inbt : interactionPointTag) { - ArmInteractionPoint point = ArmInteractionPoint.deserialize(world, pos, (CompoundNBT) inbt); + ArmInteractionPoint point = ArmInteractionPoint.deserialize(level, worldPosition, (CompoundNBT) inbt); if (point == null) continue; if (point.mode == Mode.DEPOSIT) @@ -419,16 +419,16 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE hasBlazeBurner |= point instanceof ArmInteractionPoint.BlazeBurner; } - if (!world.isRemote) { + if (!level.isClientSide) { if (outputs.size() >= 10) - AllTriggers.triggerForNearbyPlayers(AllTriggers.ARM_MANY_TARGETS, world, pos, 5); + AllTriggers.triggerForNearbyPlayers(AllTriggers.ARM_MANY_TARGETS, level, worldPosition, 5); if (hasBlazeBurner) - AllTriggers.triggerForNearbyPlayers(AllTriggers.ARM_BLAZE_BURNER, world, pos, 5); + AllTriggers.triggerForNearbyPlayers(AllTriggers.ARM_BLAZE_BURNER, level, worldPosition, 5); } updateInteractionPoints = false; sendData(); - markDirty(); + setChanged(); } public void writeInteractionPoints(CompoundNBT compound) { @@ -437,10 +437,10 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE } else { ListNBT pointsNBT = new ListNBT(); inputs.stream() - .map(aip -> aip.serialize(pos)) + .map(aip -> aip.serialize(worldPosition)) .forEach(pointsNBT::add); outputs.stream() - .map(aip -> aip.serialize(pos)) + .map(aip -> aip.serialize(worldPosition)) .forEach(pointsNBT::add); compound.put("InteractionPoints", pointsNBT); } @@ -473,7 +473,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE ListNBT interactionPointTagBefore = interactionPointTag; super.fromTag(state, compound, clientPacket); - heldItem = ItemStack.read(compound.getCompound("HeldItem")); + heldItem = ItemStack.of(compound.getCompound("HeldItem")); phase = NBTHelper.readEnum(compound, "Phase", Phase.class); chasedPointIndex = compound.getInt("TargetPointIndex"); chasedPointProgress = compound.getFloat("MovementProgress"); @@ -493,9 +493,9 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE if (previousPhase == Phase.MOVE_TO_OUTPUT && previousIndex < outputs.size()) previousPoint = outputs.get(previousIndex); previousTarget = - previousPoint == null ? ArmAngleTarget.NO_TARGET : previousPoint.getTargetAngles(pos, ceiling); + previousPoint == null ? ArmAngleTarget.NO_TARGET : previousPoint.getTargetAngles(worldPosition, ceiling); if (previousPoint != null) - previousBaseAngle = previousPoint.getTargetAngles(pos, ceiling).baseAngle; + previousBaseAngle = previousPoint.getTargetAngles(worldPosition, ceiling).baseAngle; } } @@ -531,7 +531,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE @Override protected Vector3d getLocalOffset(BlockState state) { - int yPos = state.get(ArmBlock.CEILING) ? 16 - 3 : 3; + int yPos = state.getValue(ArmBlock.CEILING) ? 16 - 3 : 3; Vector3d location = VecHelper.voxelSpace(8, yPos, 15.95); location = VecHelper.rotateCentered(location, AngleHelper.horizontalAngle(getSide()), Direction.Axis.Y); return location; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverBlock.java index bda0d93db..1f2484371 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverBlock.java @@ -29,6 +29,8 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.block.AbstractBlock.Properties; + public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE { public AnalogLeverBlock(Properties p_i48402_1_) { @@ -46,36 +48,36 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE { - boolean sneak = player.isSneaking(); + boolean sneak = player.isShiftKeyDown(); te.changeState(sneak); float f = .25f + ((te.state + 5) / 15f) * .5f; - worldIn.playSound(null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.2F, f); + worldIn.playSound(null, pos, SoundEvents.LEVER_CLICK, SoundCategory.BLOCKS, 0.2F, f); return ActionResultType.SUCCESS; }); } @Override - public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + public int getSignal(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { return getTileEntityOptional(blockAccess, pos).map(al -> al.state) .orElse(0); } @Override - public boolean canProvidePower(BlockState state) { + public boolean isSignalSource(BlockState state) { return true; } @Override - public int getStrongPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { - return getFacing(blockState) == side ? getWeakPower(blockState, blockAccess, pos, side) : 0; + public int getDirectSignal(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + return getConnectedDirection(blockState) == side ? getSignal(blockState, blockAccess, pos, side) : 0; } @Override @@ -88,32 +90,32 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE { if (te.state != 0) updateNeighbors(state, worldIn, pos); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); }); } private static void addParticles(BlockState state, IWorld worldIn, BlockPos pos, float alpha) { - Direction direction = state.get(HORIZONTAL_FACING) + Direction direction = state.getValue(FACING) .getOpposite(); - Direction direction1 = getFacing(state).getOpposite(); - double d0 = (double) pos.getX() + 0.5D + 0.1D * (double) direction.getXOffset() - + 0.2D * (double) direction1.getXOffset(); - double d1 = (double) pos.getY() + 0.5D + 0.1D * (double) direction.getYOffset() - + 0.2D * (double) direction1.getYOffset(); - double d2 = (double) pos.getZ() + 0.5D + 0.1D * (double) direction.getZOffset() - + 0.2D * (double) direction1.getZOffset(); + Direction direction1 = getConnectedDirection(state).getOpposite(); + double d0 = (double) pos.getX() + 0.5D + 0.1D * (double) direction.getStepX() + + 0.2D * (double) direction1.getStepX(); + double d1 = (double) pos.getY() + 0.5D + 0.1D * (double) direction.getStepY() + + 0.2D * (double) direction1.getStepY(); + double d2 = (double) pos.getZ() + 0.5D + 0.1D * (double) direction.getStepZ() + + 0.2D * (double) direction1.getStepZ(); worldIn.addParticle(new RedstoneParticleData(1.0F, 0.0F, 0.0F, alpha), d0, d1, d2, 0.0D, 0.0D, 0.0D); } static void updateNeighbors(BlockState state, World world, BlockPos pos) { - world.notifyNeighborsOfStateChange(pos, state.getBlock()); - world.notifyNeighborsOfStateChange(pos.offset(getFacing(state).getOpposite()), state.getBlock()); + world.updateNeighborsAt(pos, state.getBlock()); + world.updateNeighborsAt(pos.relative(getConnectedDirection(state).getOpposite()), state.getBlock()); } @SuppressWarnings("deprecation") @@ -123,8 +125,8 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE builder) { - super.fillStateContainer(builder.add(HORIZONTAL_FACING, FACE)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(FACING, FACE)); } @Override @@ -133,7 +135,7 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE tooltip, boolean isPlayerSneaking) { - tooltip.add(componentSpacing.copy().append(Lang.translate("tooltip.analogStrength", this.state))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("tooltip.analogStrength", this.state))); return true; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContactMovementBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContactMovementBehaviour.java index 770dcf450..adbf2b22f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContactMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContactMovementBehaviour.java @@ -16,7 +16,7 @@ public class ContactMovementBehaviour extends MovementBehaviour { @Override public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.of(context.state.get(RedstoneContactBlock.FACING).getDirectionVec()).scale(.65f); + return Vector3d.atLowerCornerOf(context.state.getValue(RedstoneContactBlock.FACING).getNormal()).scale(.65f); } @Override @@ -24,7 +24,7 @@ public class ContactMovementBehaviour extends MovementBehaviour { BlockState block = context.state; World world = context.world; - if (world.isRemote) + if (world.isClientSide) return; if (context.firstMovement) return; @@ -34,13 +34,13 @@ public class ContactMovementBehaviour extends MovementBehaviour { if (!AllBlocks.REDSTONE_CONTACT.has(visitedState)) return; - Vector3d contact = Vector3d.of(block.get(RedstoneContactBlock.FACING).getDirectionVec()); + Vector3d contact = Vector3d.atLowerCornerOf(block.getValue(RedstoneContactBlock.FACING).getNormal()); contact = context.rotation.apply(contact); - Direction direction = Direction.getFacingFromVector(contact.x, contact.y, contact.z); + Direction direction = Direction.getNearest(contact.x, contact.y, contact.z); - if (!RedstoneContactBlock.hasValidContact(world, pos.offset(direction.getOpposite()), direction)) + if (!RedstoneContactBlock.hasValidContact(world, pos.relative(direction.getOpposite()), direction)) return; - world.setBlockState(pos, visitedState.with(RedstoneContactBlock.POWERED, true)); + world.setBlockAndUpdate(pos, visitedState.setValue(RedstoneContactBlock.POWERED, true)); context.data.put("lastContact", NBTUtil.writeBlockPos(pos)); return; } @@ -53,7 +53,7 @@ public class ContactMovementBehaviour extends MovementBehaviour { public void deactivateLastVisitedContact(MovementContext context) { if (context.data.contains("lastContact")) { BlockPos last = NBTUtil.readBlockPos(context.data.getCompound("lastContact")); - context.world.getPendingBlockTicks().scheduleTick(last, AllBlocks.REDSTONE_CONTACT.get(), 1, TickPriority.NORMAL); + context.world.getBlockTicks().scheduleTick(last, AllBlocks.REDSTONE_CONTACT.get(), 1, TickPriority.NORMAL); context.data.remove("lastContact"); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContentObserverBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContentObserverBlock.java index a5f568dbf..0eabc9284 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContentObserverBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContentObserverBlock.java @@ -32,19 +32,21 @@ import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraft.block.AbstractBlock.Properties; + public class ContentObserverBlock extends HorizontalBlock implements ITE, IWrenchable { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; public ContentObserverBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(POWERED, false)); + registerDefaultState(defaultBlockState().setValue(POWERED, false)); } @Override public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - return AllShapes.CONTENT_OBSERVER.get(state.get(HORIZONTAL_FACING)); + return AllShapes.CONTENT_OBSERVER.get(state.getValue(FACING)); } @Override @@ -58,22 +60,22 @@ public class ContentObserverBlock extends HorizontalBlock implements ITE builder) { - builder.add(POWERED, HORIZONTAL_FACING); - super.fillStateContainer(builder); + protected void createBlockStateDefinition(Builder builder) { + builder.add(POWERED, FACING); + super.createBlockStateDefinition(builder); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - BlockState state = getDefaultState(); + BlockState state = defaultBlockState(); Direction preferredFacing = null; for (Direction face : Iterate.horizontalDirections) { - BlockPos offsetPos = context.getPos() - .offset(face); - World world = context.getWorld(); + BlockPos offsetPos = context.getClickedPos() + .relative(face); + World world = context.getLevel(); boolean canDetect = false; - TileEntity tileEntity = world.getTileEntity(offsetPos); + TileEntity tileEntity = world.getBlockEntity(offsetPos); if (TileEntityBehaviour.get(tileEntity, TransportedItemStackHandlerBehaviour.TYPE) != null) canDetect = true; @@ -94,39 +96,39 @@ public class ContentObserverBlock extends HorizontalBlock implements ITE { FilteringBehaviour filteringBehaviour = TileEntityBehaviour.get(te, FilteringBehaviour.TYPE); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContentObserverTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContentObserverTileEntity.java index f8db685a2..878053ba1 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContentObserverTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/ContentObserverTileEntity.java @@ -45,18 +45,18 @@ public class ContentObserverTileEntity extends SmartTileEntity { if (turnOffTicks > 0) { turnOffTicks--; if (turnOffTicks == 0) - world.getPendingBlockTicks() - .scheduleTick(pos, state.getBlock(), 1); + level.getBlockTicks() + .scheduleTick(worldPosition, state.getBlock(), 1); } if (!isActive()) return; - Direction facing = state.get(ContentObserverBlock.HORIZONTAL_FACING); - BlockPos targetPos = pos.offset(facing); + Direction facing = state.getValue(ContentObserverBlock.FACING); + BlockPos targetPos = worldPosition.relative(facing); TransportedItemStackHandlerBehaviour behaviour = - TileEntityBehaviour.get(world, targetPos, TransportedItemStackHandlerBehaviour.TYPE); + TileEntityBehaviour.get(level, targetPos, TransportedItemStackHandlerBehaviour.TYPE); if (behaviour != null) { behaviour.handleCenteredProcessingOnAllItems(.45f, stack -> { if (!filtering.test(stack.stack) || turnOffTicks == 6) @@ -83,10 +83,10 @@ public class ContentObserverTileEntity extends SmartTileEntity { public void activate(int ticks) { BlockState state = getBlockState(); turnOffTicks = ticks; - if (state.get(ContentObserverBlock.POWERED)) + if (state.getValue(ContentObserverBlock.POWERED)) return; - world.setBlockState(pos, state.with(ContentObserverBlock.POWERED, true)); - world.notifyNeighborsOfStateChange(pos, state.getBlock()); + level.setBlockAndUpdate(worldPosition, state.setValue(ContentObserverBlock.POWERED, true)); + level.updateNeighborsAt(worldPosition, state.getBlock()); } private boolean isActive() { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/FilteredDetectorFilterSlot.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/FilteredDetectorFilterSlot.java index 85c340826..cf9782281 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/FilteredDetectorFilterSlot.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/FilteredDetectorFilterSlot.java @@ -20,7 +20,7 @@ public class FilteredDetectorFilterSlot extends ValueBoxTransform { @Override protected void rotate(BlockState state, MatrixStack ms) { - float yRot = AngleHelper.horizontalAngle(state.get(HorizontalBlock.HORIZONTAL_FACING)) + 180; + float yRot = AngleHelper.horizontalAngle(state.getValue(HorizontalBlock.FACING)) + 180; MatrixStacker.of(ms) .rotateY(yRot) .rotateX(90); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeBlock.java index c94efdab6..a85d24e45 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeBlock.java @@ -38,6 +38,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class NixieTubeBlock extends HorizontalBlock implements ITE, IWrenchable, ISpecialBlockItemRequirement { @@ -47,19 +49,19 @@ public class NixieTubeBlock extends HorizontalBlock public NixieTubeBlock(Properties properties, DyeColor color) { super(properties); this.color = color; - setDefaultState(getDefaultState().with(CEILING, false)); + registerDefaultState(defaultBlockState().setValue(CEILING, false)); } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); NixieTubeTileEntity nixie = getTileEntity(world, pos); if (nixie == null) return ActionResultType.PASS; - if (player.isSneaking()) + if (player.isShiftKeyDown()) return ActionResultType.PASS; if (heldItem.isEmpty()) { if (nixie.reactsToRedstone()) @@ -69,26 +71,26 @@ public class NixieTubeBlock extends HorizontalBlock return ActionResultType.SUCCESS; } - boolean display = heldItem.getItem() == Items.NAME_TAG && heldItem.hasDisplayName(); + boolean display = heldItem.getItem() == Items.NAME_TAG && heldItem.hasCustomHoverName(); DyeColor dye = null; for (DyeColor color : DyeColor.values()) if (heldItem.getItem() - .isIn(DyeHelper.getTagOfDye(color))) + .is(DyeHelper.getTagOfDye(color))) dye = color; if (!display && dye == null) return ActionResultType.PASS; - Direction left = state.get(HORIZONTAL_FACING) - .rotateY(); + Direction left = state.getValue(FACING) + .getClockWise(); Direction right = left.getOpposite(); - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; BlockPos currentPos = pos; while (true) { - BlockPos nextPos = currentPos.offset(left); + BlockPos nextPos = currentPos.relative(left); if (!areNixieBlocksEqual(world.getBlockState(nextPos), state)) break; currentPos = nextPos; @@ -102,9 +104,9 @@ public class NixieTubeBlock extends HorizontalBlock if (display) withTileEntityDo(world, currentPos, te -> te.displayCustomNameOf(heldItem, rowPosition)); if (dye != null) - world.setBlockState(currentPos, withColor(state, dye)); + world.setBlockAndUpdate(currentPos, withColor(state, dye)); - BlockPos nextPos = currentPos.offset(right); + BlockPos nextPos = currentPos.relative(right); if (!areNixieBlocksEqual(world.getBlockState(nextPos), state)) break; currentPos = nextPos; @@ -115,19 +117,19 @@ public class NixieTubeBlock extends HorizontalBlock } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(CEILING, HORIZONTAL_FACING)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(CEILING, FACING)); } @Override - public void onReplaced(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, + public void onRemove(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, boolean p_196243_5_) { if (!(p_196243_4_.getBlock() instanceof NixieTubeBlock)) - p_196243_2_.removeTileEntity(p_196243_3_); + p_196243_2_.removeBlockEntity(p_196243_3_); } @Override - public ItemStack getItem(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { + public ItemStack getCloneItemStack(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { return AllBlocks.ORANGE_NIXIE_TUBE.asStack(); } @@ -140,8 +142,8 @@ public class NixieTubeBlock extends HorizontalBlock @Override public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { - return (state.get(CEILING) ? AllShapes.NIXIE_TUBE_CEILING : AllShapes.NIXIE_TUBE) - .get(state.get(HORIZONTAL_FACING) + return (state.getValue(CEILING) ? AllShapes.NIXIE_TUBE_CEILING : AllShapes.NIXIE_TUBE) + .get(state.getValue(FACING) .getAxis()); } @@ -156,34 +158,34 @@ public class NixieTubeBlock extends HorizontalBlock @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - BlockPos pos = context.getPos(); - boolean ceiling = context.getFace() == Direction.DOWN; - Vector3d hitVec = context.getHitVec(); + BlockPos pos = context.getClickedPos(); + boolean ceiling = context.getClickedFace() == Direction.DOWN; + Vector3d hitVec = context.getClickLocation(); if (hitVec != null) ceiling = hitVec.y - pos.getY() > .5f; - return getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing() + return defaultBlockState().setValue(FACING, context.getHorizontalDirection() .getOpposite()) - .with(CEILING, ceiling); + .setValue(CEILING, ceiling); } @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; - if (!worldIn.getPendingBlockTicks() - .isTickPending(pos, this)) - worldIn.getPendingBlockTicks() + if (!worldIn.getBlockTicks() + .willTickThisTick(pos, this)) + worldIn.getBlockTicks() .scheduleTick(pos, this, 0); } @Override - public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { updateDisplayedRedstoneValue(state, worldIn, pos); } @Override - public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { if (state.getBlock() == oldState.getBlock() || isMoving) return; updateDisplayedRedstoneValue(state, worldIn, pos); @@ -200,7 +202,7 @@ public class NixieTubeBlock extends HorizontalBlock } private void updateDisplayedRedstoneValue(BlockState state, World worldIn, BlockPos pos) { - if (worldIn.isRemote) + if (worldIn.isClientSide) return; withTileEntityDo(worldIn, pos, te -> { if (te.reactsToRedstone()) @@ -209,7 +211,7 @@ public class NixieTubeBlock extends HorizontalBlock } static boolean isValidBlock(IBlockReader world, BlockPos pos, boolean above) { - BlockState state = world.getBlockState(pos.up(above ? 1 : -1)); + BlockState state = world.getBlockState(pos.above(above ? 1 : -1)); return !state.getShape(world, pos) .isEmpty(); } @@ -217,14 +219,14 @@ public class NixieTubeBlock extends HorizontalBlock private int getPower(World worldIn, BlockPos pos) { int power = 0; for (Direction direction : Iterate.directions) - power = Math.max(worldIn.getRedstonePower(pos.offset(direction), direction), power); + power = Math.max(worldIn.getSignal(pos.relative(direction), direction), power); for (Direction direction : Iterate.directions) - power = Math.max(worldIn.getRedstonePower(pos.offset(direction), Direction.UP), power); + power = Math.max(worldIn.getSignal(pos.relative(direction), Direction.UP), power); return power; } @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } @@ -249,8 +251,8 @@ public class NixieTubeBlock extends HorizontalBlock public static BlockState withColor(BlockState state, DyeColor color) { return (color == DyeColor.ORANGE ? AllBlocks.ORANGE_NIXIE_TUBE : AllBlocks.NIXIE_TUBES.get(color)) .getDefaultState() - .with(HORIZONTAL_FACING, state.get(HORIZONTAL_FACING)) - .with(CEILING, state.get(CEILING)); + .setValue(FACING, state.getValue(FACING)) + .setValue(CEILING, state.getValue(CEILING)); } public static DyeColor colorOf(BlockState blockState) { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeGenerator.java index 14df038a3..6324405aa 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeGenerator.java @@ -12,12 +12,12 @@ public class NixieTubeGenerator extends SpecialBlockStateGen { @Override protected int getXRotation(BlockState state) { - return state.get(NixieTubeBlock.CEILING) ? 180 : 0; + return state.getValue(NixieTubeBlock.CEILING) ? 180 : 0; } @Override protected int getYRotation(BlockState state) { - return horizontalAngle(state.get(NixieTubeBlock.HORIZONTAL_FACING)); + return horizontalAngle(state.getValue(NixieTubeBlock.FACING)); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeRenderer.java index fe2b2cc0f..c0b19ebe4 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeRenderer.java @@ -57,36 +57,36 @@ public class NixieTubeRenderer extends SafeTileEntityRenderer s = te.getDisplayedStrings(); DyeColor color = NixieTubeBlock.colorOf(te.getBlockState()); - ms.push(); + ms.pushPose(); ms.translate(-4 / 16f, 0, 0); ms.scale(scale, -scale, scale); drawTube(ms, buffer, s.getFirst(), height, color); - ms.pop(); + ms.popPose(); - ms.push(); + ms.pushPose(); ms.translate(4 / 16f, 0, 0); ms.scale(scale, -scale, scale); drawTube(ms, buffer, s.getSecond(), height, color); - ms.pop(); + ms.popPose(); - ms.pop(); + ms.popPose(); } private void drawTube(MatrixStack ms, IRenderTypeBuffer buffer, String c, float height, DyeColor color) { - FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; - float charWidth = fontRenderer.getStringWidth(c); + FontRenderer fontRenderer = Minecraft.getInstance().font; + float charWidth = fontRenderer.width(c); float shadowOffset = .5f; float flicker = r.nextFloat(); Couple couple = DYE_TABLE.get(color); @@ -94,34 +94,34 @@ public class NixieTubeRenderer extends SafeTileEntityRenderer currentStrings = displayedStrings; parsedCustomText = parseCustomText(); updateDisplayedStrings(); @@ -60,7 +60,7 @@ public class NixieTubeTileEntity extends SmartTileEntity { @Override public void initialize() { - if (world.isRemote) + if (level.isClientSide) updateDisplayedStrings(); } @@ -83,7 +83,7 @@ public class NixieTubeTileEntity extends SmartTileEntity { } public void displayCustomNameOf(ItemStack stack, int nixiePositionInRow) { - CompoundNBT compoundnbt = stack.getChildTag("display"); + CompoundNBT compoundnbt = stack.getTagElement("display"); if (compoundnbt != null && compoundnbt.contains("Name", NBT.TAG_STRING)) { hasCustomText = true; rawCustomText = getJsonFromString(compoundnbt.getString("Name")); @@ -182,9 +182,9 @@ public class NixieTubeTileEntity extends SmartTileEntity { } protected ITextComponent parseDynamicComponent(ITextComponent customText) { - if (world instanceof ServerWorld) { + if (level instanceof ServerWorld) { try { - return TextComponentUtils.parse(getCommandSource(null), customText, null, 0); + return TextComponentUtils.updateForEntity(getCommandSource(null), customText, null, 0); } catch (CommandSyntaxException e) { // } @@ -196,7 +196,7 @@ public class NixieTubeTileEntity extends SmartTileEntity { public CommandSource getCommandSource(@Nullable ServerPlayerEntity p_195539_1_) { String s = p_195539_1_ == null ? "Nixie Tube" : p_195539_1_.getName().getString(); ITextComponent itextcomponent = (ITextComponent)(p_195539_1_ == null ? new StringTextComponent("Nixie Tube") : p_195539_1_.getDisplayName()); - return new CommandSource(ICommandSource.field_213139_a_, Vector3d.ofCenter(this.pos), Vector2f.ZERO, (ServerWorld)this.world, 2, s, itextcomponent, this.world.getServer(), p_195539_1_); + return new CommandSource(ICommandSource.NULL, Vector3d.atCenterOf(this.worldPosition), Vector2f.ZERO, (ServerWorld)this.level, 2, s, itextcomponent, this.level.getServer(), p_195539_1_); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneContactBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneContactBlock.java index 8db988bfa..4b5859442 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneContactBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneContactBlock.java @@ -22,6 +22,8 @@ import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class RedstoneContactBlock extends ProperDirectionalBlock { @@ -30,81 +32,81 @@ public class RedstoneContactBlock extends ProperDirectionalBlock { public RedstoneContactBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(POWERED, false) - .with(FACING, Direction.UP)); + registerDefaultState(defaultBlockState().setValue(POWERED, false) + .setValue(FACING, Direction.UP)); } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(POWERED); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - BlockState state = getDefaultState().with(FACING, context.getNearestLookingDirection() + BlockState state = defaultBlockState().setValue(FACING, context.getNearestLookingDirection() .getOpposite()); - Direction placeDirection = context.getFace() + Direction placeDirection = context.getClickedFace() .getOpposite(); if ((context.getPlayer() != null && context.getPlayer() - .isSneaking()) || hasValidContact(context.getWorld(), context.getPos(), placeDirection)) - state = state.with(FACING, placeDirection); - if (hasValidContact(context.getWorld(), context.getPos(), state.get(FACING))) - state = state.with(POWERED, true); + .isShiftKeyDown()) || hasValidContact(context.getLevel(), context.getClickedPos(), placeDirection)) + state = state.setValue(FACING, placeDirection); + if (hasValidContact(context.getLevel(), context.getClickedPos(), state.getValue(FACING))) + state = state.setValue(POWERED, true); return state; } @Override - public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { - if (facing != stateIn.get(FACING)) + if (facing != stateIn.getValue(FACING)) return stateIn; boolean hasValidContact = hasValidContact(worldIn, currentPos, facing); - if (stateIn.get(POWERED) != hasValidContact) { - return stateIn.with(POWERED, hasValidContact); + if (stateIn.getValue(POWERED) != hasValidContact) { + return stateIn.setValue(POWERED, hasValidContact); } return stateIn; } @SuppressWarnings("deprecation") @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() == this && newState.getBlock() == this) { if (state == newState.cycle(POWERED)) - worldIn.notifyNeighborsOfStateChange(pos, this); + worldIn.updateNeighborsAt(pos, this); } - super.onReplaced(state, worldIn, pos, newState, isMoving); + super.onRemove(state, worldIn, pos, newState, isMoving); } @Override - public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { - boolean hasValidContact = hasValidContact(worldIn, pos, state.get(FACING)); - if (state.get(POWERED) != hasValidContact) - worldIn.setBlockState(pos, state.with(POWERED, hasValidContact)); + public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + boolean hasValidContact = hasValidContact(worldIn, pos, state.getValue(FACING)); + if (state.getValue(POWERED) != hasValidContact) + worldIn.setBlockAndUpdate(pos, state.setValue(POWERED, hasValidContact)); } public static boolean hasValidContact(IWorld world, BlockPos pos, Direction direction) { - BlockState blockState = world.getBlockState(pos.offset(direction)); - return AllBlocks.REDSTONE_CONTACT.has(blockState) && blockState.get(FACING) == direction.getOpposite(); + BlockState blockState = world.getBlockState(pos.relative(direction)); + return AllBlocks.REDSTONE_CONTACT.has(blockState) && blockState.getValue(FACING) == direction.getOpposite(); } @Override - public boolean canProvidePower(BlockState state) { - return state.get(POWERED); + public boolean isSignalSource(BlockState state) { + return state.getValue(POWERED); } @Override public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, @Nullable Direction side) { if (side == null) return true; - return state.get(FACING) != side.getOpposite(); + return state.getValue(FACING) != side.getOpposite(); } @Override - public int getWeakPower(BlockState state, IBlockReader blockAccess, BlockPos pos, Direction side) { - return state.get(POWERED) ? 15 : 0; + public int getSignal(BlockState state, IBlockReader blockAccess, BlockPos pos, Direction side) { + return state.getValue(POWERED) ? 15 : 0; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java index 0469c1161..c7505e3dc 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java @@ -30,6 +30,8 @@ import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; @@ -37,53 +39,53 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE 0) - worldIn.setBlockState(pos, state.cycle(POWERED), 2); + worldIn.setBlock(pos, state.cycle(POWERED), 2); int transmit = power; withTileEntityDo(worldIn, pos, te -> te.transmit(transmit)); @@ -92,36 +94,36 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(POWERED, RECEIVER); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override @@ -135,22 +137,22 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE { - Boolean wasReceiver = state.get(RECEIVER); - boolean blockPowered = worldIn.isBlockPowered(pos); - worldIn.setBlockState(pos, state.cycle(RECEIVER) - .with(POWERED, blockPowered), 3); + Boolean wasReceiver = state.getValue(RECEIVER); + boolean blockPowered = worldIn.hasNeighborSignal(pos); + worldIn.setBlock(pos, state.cycle(RECEIVER) + .setValue(POWERED, blockPowered), 3); te.transmit(wasReceiver ? 0 : getPower(worldIn, pos)); return ActionResultType.SUCCESS; }); @@ -158,7 +160,7 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - String variant = state.get(RedstoneLinkBlock.RECEIVER) ? "receiver" : "transmitter"; - if (state.get(RedstoneLinkBlock.FACING).getAxis().isHorizontal()) + String variant = state.getValue(RedstoneLinkBlock.RECEIVER) ? "receiver" : "transmitter"; + if (state.getValue(RedstoneLinkBlock.FACING).getAxis().isHorizontal()) variant += "_vertical"; - if (state.get(RedstoneLinkBlock.POWERED)) + if (state.getValue(RedstoneLinkBlock.POWERED)) variant += "_powered"; return prov.models().getExistingFile(prov.modLoc("block/redstone_link/" + variant)); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkTileEntity.java index 5a11ab2ee..cac4b3355 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkTileEntity.java @@ -79,7 +79,7 @@ public class RedstoneLinkTileEntity extends SmartTileEntity { receivedSignal = compound.getInt("Receive"); receivedSignalChanged = compound.getBoolean("ReceivedChanged"); - if (world == null || world.isRemote || !link.newPosition) + if (level == null || level.isClientSide || !link.newPosition) transmittedSignal = compound.getInt("Transmit"); } @@ -98,29 +98,29 @@ public class RedstoneLinkTileEntity extends SmartTileEntity { if (transmitter) return; - if (world.isRemote) + if (level.isClientSide) return; BlockState blockState = getBlockState(); if (!AllBlocks.REDSTONE_LINK.has(blockState)) return; - if ((getReceivedSignal() > 0) != blockState.get(POWERED)) { + if ((getReceivedSignal() > 0) != blockState.getValue(POWERED)) { receivedSignalChanged = true; - world.setBlockState(pos, blockState.cycle(POWERED)); + level.setBlockAndUpdate(worldPosition, blockState.cycle(POWERED)); } if (receivedSignalChanged) { - Direction attachedFace = blockState.get(RedstoneLinkBlock.FACING).getOpposite(); - BlockPos attachedPos = pos.offset(attachedFace); - world.updateNeighbors(pos, world.getBlockState(pos).getBlock()); - world.updateNeighbors(attachedPos, world.getBlockState(attachedPos).getBlock()); + Direction attachedFace = blockState.getValue(RedstoneLinkBlock.FACING).getOpposite(); + BlockPos attachedPos = worldPosition.relative(attachedFace); + level.blockUpdated(worldPosition, level.getBlockState(worldPosition).getBlock()); + level.blockUpdated(attachedPos, level.getBlockState(attachedPos).getBlock()); receivedSignalChanged = false; } } protected Boolean isTransmitterBlock() { - return !getBlockState().get(RedstoneLinkBlock.RECEIVER); + return !getBlockState().getValue(RedstoneLinkBlock.RECEIVER); } public int getReceivedSignal() { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java index 7dc6293fa..b2887a7a2 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java @@ -35,6 +35,8 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraft.block.AbstractBlock.Properties; + public class StockpileSwitchBlock extends HorizontalBlock implements ITE, IWrenchable { public static final IntegerProperty INDICATOR = IntegerProperty.create("indicator", 0, 6); @@ -44,13 +46,13 @@ public class StockpileSwitchBlock extends HorizontalBlock implements ITE 15) @@ -91,20 +93,20 @@ public class StockpileSwitchBlock extends HorizontalBlock implements ITE builder) { - builder.add(HORIZONTAL_FACING, INDICATOR); - super.fillStateContainer(builder); + protected void createBlockStateDefinition(Builder builder) { + builder.add(FACING, INDICATOR); + super.createBlockStateDefinition(builder); } @Override - public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (player != null && AllItems.WRENCH.isIn(player.getHeldItem(handIn))) + if (player != null && AllItems.WRENCH.isIn(player.getItemInHand(handIn))) return ActionResultType.PASS; DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> withTileEntityDo(worldIn, pos, te -> this.displayScreen(te, player))); @@ -119,13 +121,13 @@ public class StockpileSwitchBlock extends HorizontalBlock implements ITE { lastModification = 0; offBelow.titled(Lang.translate("gui.stockpile_switch.move_to_upper_at", state)); @@ -70,7 +70,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen { .setState((int) (te.offWhenBelow * 100)); onAbove = new ScrollInput(x + 36, y + 18, 102, 18).withRange(1, 101) - .titled(StringTextComponent.EMPTY.copy()) + .titled(StringTextComponent.EMPTY.plainCopy()) .calling(state -> { lastModification = 0; onAbove.titled(Lang.translate("gui.stockpile_switch.move_to_lower_at", state)); @@ -105,27 +105,27 @@ public class StockpileSwitchScreen extends AbstractSimiScreen { AllGuiTextures.STOCKSWITCH_POWERED_LANE.draw(ms, this, x + 36, y + (te.isInverted() ? 18 : 40)); AllGuiTextures.STOCKSWITCH_UNPOWERED_LANE.draw(ms, this, x + 36, y + (te.isInverted() ? 40 : 18)); - drawCenteredText(ms, textRenderer, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); + drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); AllGuiTextures sprite = AllGuiTextures.STOCKSWITCH_INTERVAL; float lowerBound = offBelow.getState(); float upperBound = onAbove.getState(); sprite.bind(); - drawTexture(ms, (int) (x + upperBound) + 37, y + 18, (int) (sprite.startX + upperBound), sprite.startY, + blit(ms, (int) (x + upperBound) + 37, y + 18, (int) (sprite.startX + upperBound), sprite.startY, (int) (sprite.width - upperBound), sprite.height); - drawTexture(ms, x + 37, y + 40, sprite.startX, sprite.startY, (int) (lowerBound), sprite.height); + blit(ms, x + 37, y + 40, sprite.startX, sprite.startY, (int) (lowerBound), sprite.height); AllGuiTextures.STOCKSWITCH_ARROW_UP.draw(ms, this, (int) (x + lowerBound + 36) - 2, y + 35); AllGuiTextures.STOCKSWITCH_ARROW_DOWN.draw(ms, this, (int) (x + upperBound + 36) - 3, y + 17); if (te.currentLevel != -1) { AllGuiTextures cursor = AllGuiTextures.STOCKSWITCH_CURSOR; - ms.push(); + ms.pushPose(); ms.translate(Math.min(99, this.cursor.getValue(partialTicks) * sprite.width), cursorLane.getValue(partialTicks) * 22, 0); cursor.draw(ms, this, x + 34, y + 19); - ms.pop(); + ms.popPose(); } GuiGameElement.of(renderedItem) @@ -158,7 +158,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen { } protected void send(boolean invert) { - AllPackets.channel.sendToServer(new ConfigureStockswitchPacket(te.getPos(), offBelow.getState() / 100f, + AllPackets.channel.sendToServer(new ConfigureStockswitchPacket(te.getBlockPos(), offBelow.getState() / 100f, onAbove.getState() / 100f, invert)); } @@ -167,7 +167,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen { if (flipSignals.isHovered()) send(!te.isInverted()); if (confirmButton.isHovered()) { - client.player.closeScreen(); + minecraft.player.closeContainer(); return true; } return super.mouseClicked(x, y, button); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchTileEntity.java index 3fbbe0c93..27cb20f2a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchTileEntity.java @@ -62,7 +62,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { super.write(compound, clientPacket); } - public float getLevel() { + public float getStockLevel() { return currentLevel; } @@ -72,10 +72,10 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { if (!observedInventory.hasInventory()) { if (currentLevel == -1) return; - world.setBlockState(pos, getBlockState().with(StockpileSwitchBlock.INDICATOR, 0), 3); + level.setBlock(worldPosition, getBlockState().setValue(StockpileSwitchBlock.INDICATOR, 0), 3); currentLevel = -1; state = false; - world.updateNeighbors(pos, getBlockState().getBlock()); + level.blockUpdated(worldPosition, getBlockState().getBlock()); sendData(); return; } @@ -98,10 +98,10 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { occupied += count * (1f / space); } - float level = (float) occupied / totalSpace; - if (currentLevel != level) + float stockLevel = occupied / totalSpace; + if (currentLevel != stockLevel) changed = true; - currentLevel = level; + currentLevel = stockLevel; currentLevel = MathHelper.clamp(currentLevel, 0, 1); boolean previouslyPowered = state; @@ -114,10 +114,10 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { int displayLevel = 0; if (currentLevel > 0) displayLevel = (int) (currentLevel * 6); - world.setBlockState(pos, getBlockState().with(StockpileSwitchBlock.INDICATOR, displayLevel), update ? 3 : 2); + level.setBlock(worldPosition, getBlockState().setValue(StockpileSwitchBlock.INDICATOR, displayLevel), update ? 3 : 2); - if (update && !world.getPendingBlockTicks().isTickPending(pos, getBlockState().getBlock())) - world.getPendingBlockTicks().scheduleTick(pos, getBlockState().getBlock(), 2, TickPriority.NORMAL); + if (update && !level.getBlockTicks().willTickThisTick(worldPosition, getBlockState().getBlock())) + level.getBlockTicks().scheduleTick(worldPosition, getBlockState().getBlock(), 2, TickPriority.NORMAL); if (changed || update) sendData(); @@ -126,7 +126,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { @Override public void lazyTick() { super.lazyTick(); - if (world.isRemote) + if (level.isClientSide) return; updateCurrentLevel(); } @@ -155,7 +155,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { public void updatePowerAfterDelay() { poweredAfterDelay = shouldBePowered(); - world.updateNeighbors(pos, getBlockState().getBlock()); + level.blockUpdated(worldPosition, getBlockState().getBlock()); } public boolean isPowered() { diff --git a/src/main/java/com/simibubi/create/content/logistics/item/CardboardBoxItem.java b/src/main/java/com/simibubi/create/content/logistics/item/CardboardBoxItem.java index 083722a79..4e6573fa6 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/CardboardBoxItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/CardboardBoxItem.java @@ -24,6 +24,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.Constants; +import net.minecraft.item.Item.Properties; + public class CardboardBoxItem extends Item { static final int SLOTS = 9; @@ -35,11 +37,11 @@ public class CardboardBoxItem extends Item { } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { - if (!playerIn.isSneaking()) - return super.onItemRightClick(worldIn, playerIn, handIn); + public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { + if (!playerIn.isShiftKeyDown()) + return super.use(worldIn, playerIn, handIn); - ItemStack box = playerIn.getHeldItem(handIn); + ItemStack box = playerIn.getItemInHand(handIn); for (ItemStack stack : getContents(box)) playerIn.inventory.placeItemBackInInventory(worldIn, stack); @@ -62,7 +64,7 @@ public class CardboardBoxItem extends Item { } @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { + public void fillItemCategory(ItemGroup group, NonNullList items) { } public static void addAddress(ItemStack box, String address) { @@ -95,13 +97,13 @@ public class CardboardBoxItem extends Item { @Override @OnlyIn(value = Dist.CLIENT) - public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { - super.addInformation(stack, worldIn, tooltip, flagIn); + public void appendHoverText(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + super.appendHoverText(stack, worldIn, tooltip, flagIn); CompoundNBT compoundnbt = stack.getOrCreateTag(); if (compoundnbt.contains("Address", Constants.NBT.TAG_STRING)) { tooltip.add(new StringTextComponent("-> " + compoundnbt.getString("Address")) - .formatted(TextFormatting.GOLD)); + .withStyle(TextFormatting.GOLD)); } if (!compoundnbt.contains("Items", Constants.NBT.TAG_LIST)) @@ -117,15 +119,15 @@ public class CardboardBoxItem extends Item { ++j; if (i <= 4) { ++i; - ITextComponent itextcomponent = itemstack.getDisplayName(); - tooltip.add(itextcomponent.copy().append(" x").append(String.valueOf(itemstack.getCount())) - .formatted(TextFormatting.GRAY)); + ITextComponent itextcomponent = itemstack.getHoverName(); + tooltip.add(itextcomponent.plainCopy().append(" x").append(String.valueOf(itemstack.getCount())) + .withStyle(TextFormatting.GRAY)); } } if (j - i > 0) { tooltip.add((new TranslationTextComponent("container.shulkerBox.more", j - i)) - .formatted(TextFormatting.ITALIC)); + .withStyle(TextFormatting.ITALIC)); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerBlock.java b/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerBlock.java index 339806dbb..eadb09685 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerBlock.java @@ -25,16 +25,18 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.block.AbstractBlock.Properties; + public class LecternControllerBlock extends LecternBlock implements ITE, ISpecialBlockItemRequirement { public LecternControllerBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(HAS_BOOK, true)); + registerDefaultState(defaultBlockState().setValue(HAS_BOOK, true)); } @Nullable @Override - public TileEntity createNewTileEntity(IBlockReader p_196283_1_) { + public TileEntity newBlockEntity(IBlockReader p_196283_1_) { return null; } @@ -50,15 +52,15 @@ public class LecternControllerBlock extends LecternBlock implements ITE te.tryStartUsing(player)); return ActionResultType.SUCCESS; } - if (player.isSneaking()) { - if (!world.isRemote) + if (player.isShiftKeyDown()) { + if (!world.isClientSide) replaceWithLectern(state, world, pos); return ActionResultType.SUCCESS; } @@ -67,32 +69,32 @@ public class LecternControllerBlock extends LecternBlock implements ITE te.dropController(state)); - super.onReplaced(state, world, pos, newState, isMoving); + super.onRemove(state, world, pos, newState, isMoving); } } @Override - public int getComparatorInputOverride(BlockState state, World world, BlockPos pos) { + public int getAnalogOutputSignal(BlockState state, World world, BlockPos pos) { return 15; } public void replaceLectern(BlockState lecternState, World world, BlockPos pos, ItemStack controller) { - world.setBlockState(pos, getDefaultState() - .with(FACING, lecternState.get(FACING)) - .with(POWERED, lecternState.get(POWERED))); + world.setBlockAndUpdate(pos, defaultBlockState() + .setValue(FACING, lecternState.getValue(FACING)) + .setValue(POWERED, lecternState.getValue(POWERED))); withTileEntityDo(world, pos, te -> te.setController(controller)); } public void replaceWithLectern(BlockState state, World world, BlockPos pos) { AllSoundEvents.CONTROLLER_TAKE.playOnServer(world, pos); - world.setBlockState(pos, Blocks.LECTERN.getDefaultState() - .with(FACING, state.get(FACING)) - .with(POWERED, state.get(POWERED))); + world.setBlockAndUpdate(pos, Blocks.LECTERN.defaultBlockState() + .setValue(FACING, state.getValue(FACING)) + .setValue(POWERED, state.getValue(POWERED))); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerRenderer.java b/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerRenderer.java index bbe2eaf63..14498a253 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerRenderer.java @@ -28,21 +28,21 @@ public class LecternControllerRenderer extends SafeTileEntityRenderer this::tryToggleActive); prevUser = user; } - if (!world.isRemote) { + if (!level.isClientSide) { deactivatedThisTick = false; - if (!(world instanceof ServerWorld)) + if (!(level instanceof ServerWorld)) return; if (user == null) return; - Entity entity = ((ServerWorld) world).getEntityByUuid(user); + Entity entity = ((ServerWorld) level).getEntity(user); if (!(entity instanceof PlayerEntity)) { stopUsing(null); return; } PlayerEntity player = (PlayerEntity) entity; - if (!playerInRange(player, world, pos) || !playerIsUsingLectern(player)) + if (!playerInRange(player, level, worldPosition) || !playerIsUsingLectern(player)) stopUsing(player); } } @OnlyIn(Dist.CLIENT) private void tryToggleActive() { - if (user == null && Minecraft.getInstance().player.getUniqueID().equals(prevUser)) { + if (user == null && Minecraft.getInstance().player.getUUID().equals(prevUser)) { LinkedControllerClientHandler.deactivateInLectern(); - } else if (prevUser == null && Minecraft.getInstance().player.getUniqueID().equals(user)) { - LinkedControllerClientHandler.activateInLectern(pos); + } else if (prevUser == null && Minecraft.getInstance().player.getUUID().equals(user)) { + LinkedControllerClientHandler.activateInLectern(worldPosition); } } public void setController(ItemStack newController) { controller = newController; if (newController != null) { - AllSoundEvents.CONTROLLER_PUT.playOnServer(world, pos); + AllSoundEvents.CONTROLLER_PUT.playOnServer(level, worldPosition); } } public void swapControllers(ItemStack stack, PlayerEntity player, Hand hand, BlockState state) { ItemStack newController = stack.copy(); stack.setCount(0); - if (player.getHeldItem(hand).isEmpty()) { - player.setHeldItem(hand, controller); + if (player.getItemInHand(hand).isEmpty()) { + player.setItemInHand(hand, controller); } else { dropController(state); } @@ -156,24 +156,24 @@ public class LecternControllerTileEntity extends SmartTileEntity { } public void dropController(BlockState state) { - Entity playerEntity = ((ServerWorld) world).getEntityByUuid(user); + Entity playerEntity = ((ServerWorld) level).getEntity(user); if (playerEntity instanceof PlayerEntity) stopUsing((PlayerEntity) playerEntity); - Direction dir = state.get(LecternControllerBlock.FACING); - double x = pos.getX() + 0.5 + 0.25*dir.getXOffset(); - double y = pos.getY() + 1; - double z = pos.getZ() + 0.5 + 0.25*dir.getZOffset(); - ItemEntity itementity = new ItemEntity(world, x, y, z, controller.copy()); - itementity.setDefaultPickupDelay(); - world.addEntity(itementity); + Direction dir = state.getValue(LecternControllerBlock.FACING); + double x = worldPosition.getX() + 0.5 + 0.25*dir.getStepX(); + double y = worldPosition.getY() + 1; + double z = worldPosition.getZ() + 0.5 + 0.25*dir.getStepZ(); + ItemEntity itementity = new ItemEntity(level, x, y, z, controller.copy()); + itementity.setDefaultPickUpDelay(); + level.addFreshEntity(itementity); controller = null; } public static boolean playerInRange(PlayerEntity player, World world, BlockPos pos) { //double modifier = world.isRemote ? 0 : 1.0; double reach = 0.4*player.getAttributeValue(ForgeMod.REACH_DISTANCE.get());// + modifier; - return player.getDistanceSq(Vector3d.ofCenter(pos)) < reach*reach; + return player.distanceToSqr(Vector3d.atCenterOf(pos)) < reach*reach; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerBindPacket.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerBindPacket.java index 3a0366d67..096f4f885 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerBindPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerBindPacket.java @@ -42,7 +42,7 @@ public class LinkedControllerBindPacket extends LinkedControllerPacketBase { return; ItemStackHandler frequencyItems = LinkedControllerItem.getFrequencyItems(heldItem); - LinkBehaviour linkBehaviour = TileEntityBehaviour.get(player.world, linkLocation, LinkBehaviour.TYPE); + LinkBehaviour linkBehaviour = TileEntityBehaviour.get(player.level, linkLocation, LinkBehaviour.TYPE); if (linkBehaviour == null) return; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java index 9dfaf30c1..c5dd09860 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java @@ -50,14 +50,14 @@ public class LinkedControllerClientHandler { public static Vector getControls() { if (controls == null) { - GameSettings gameSettings = Minecraft.getInstance().gameSettings; + GameSettings gameSettings = Minecraft.getInstance().options; controls = new Vector<>(6); - controls.add(gameSettings.keyBindForward); - controls.add(gameSettings.keyBindBack); - controls.add(gameSettings.keyBindLeft); - controls.add(gameSettings.keyBindRight); - controls.add(gameSettings.keyBindJump); - controls.add(gameSettings.keySneak); + controls.add(gameSettings.keyUp); + controls.add(gameSettings.keyDown); + controls.add(gameSettings.keyLeft); + controls.add(gameSettings.keyRight); + controls.add(gameSettings.keyJump); + controls.add(gameSettings.keyShift); } return controls; } @@ -101,7 +101,7 @@ public class LinkedControllerClientHandler { } protected static void onReset() { - getControls().forEach(kb -> kb.setPressed(isActuallyPressed(kb))); + getControls().forEach(kb -> kb.setDown(isActuallyPressed(kb))); packetCooldown = 0; selectedLocation = BlockPos.ZERO; @@ -117,9 +117,9 @@ public class LinkedControllerClientHandler { protected static boolean isActuallyPressed(KeyBinding kb) { return InputMappings.isKeyDown(Minecraft.getInstance() .getWindow() - .getHandle(), + .getWindow(), kb.getKey() - .getKeyCode()); + .getValue()); } public static void tick() { @@ -131,7 +131,7 @@ public class LinkedControllerClientHandler { Minecraft mc = Minecraft.getInstance(); ClientPlayerEntity player = mc.player; - ItemStack heldItem = player.getHeldItemMainhand(); + ItemStack heldItem = player.getMainHandItem(); if (player.isSpectator()) { MODE = Mode.IDLE; @@ -140,7 +140,7 @@ public class LinkedControllerClientHandler { } if (!inLectern() && !AllItems.LINKED_CONTROLLER.isIn(heldItem)) { - heldItem = player.getHeldItemOffhand(); + heldItem = player.getOffhandItem(); if (!AllItems.LINKED_CONTROLLER.isIn(heldItem)) { MODE = Mode.IDLE; onReset(); @@ -148,20 +148,20 @@ public class LinkedControllerClientHandler { } } - if (inLectern() && AllBlocks.LECTERN_CONTROLLER.get().getTileEntityOptional(mc.world, lecternPos) + if (inLectern() && AllBlocks.LECTERN_CONTROLLER.get().getTileEntityOptional(mc.level, lecternPos) .map(te -> !te.isUsedBy(mc.player)) .orElse(true)) { deactivateInLectern(); return; } - if (mc.currentScreen != null) { + if (mc.screen != null) { MODE = Mode.IDLE; onReset(); return; } - if (InputMappings.isKeyDown(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE)) { + if (InputMappings.isKeyDown(mc.getWindow().getWindow(), GLFW.GLFW_KEY_ESCAPE)) { MODE = Mode.IDLE; onReset(); return; @@ -183,14 +183,14 @@ public class LinkedControllerClientHandler { // Released Keys if (!releasedKeys.isEmpty()) { AllPackets.channel.sendToServer(new LinkedControllerInputPacket(releasedKeys, false, lecternPos)); - AllSoundEvents.CONTROLLER_CLICK.playAt(player.world, player.getBlockPos(), 1f, .5f, true); + AllSoundEvents.CONTROLLER_CLICK.playAt(player.level, player.blockPosition(), 1f, .5f, true); } // Newly Pressed Keys if (!newKeys.isEmpty()) { AllPackets.channel.sendToServer(new LinkedControllerInputPacket(newKeys, true, lecternPos)); packetCooldown = PACKET_RATE; - AllSoundEvents.CONTROLLER_CLICK.playAt(player.world, player.getBlockPos(), 1f, .75f, true); + AllSoundEvents.CONTROLLER_CLICK.playAt(player.level, player.blockPosition(), 1f, .75f, true); } // Keepalive Pressed Keys @@ -203,20 +203,20 @@ public class LinkedControllerClientHandler { } if (MODE == Mode.BIND) { - VoxelShape shape = mc.world.getBlockState(selectedLocation) - .getShape(mc.world, selectedLocation); + VoxelShape shape = mc.level.getBlockState(selectedLocation) + .getShape(mc.level, selectedLocation); if (!shape.isEmpty()) - CreateClient.OUTLINER.showAABB("controller", shape.getBoundingBox() - .offset(selectedLocation)) + CreateClient.OUTLINER.showAABB("controller", shape.bounds() + .move(selectedLocation)) .colored(0xB73C2D) .lineWidth(1 / 16f); for (Integer integer : newKeys) { - LinkBehaviour linkBehaviour = TileEntityBehaviour.get(mc.world, selectedLocation, LinkBehaviour.TYPE); + LinkBehaviour linkBehaviour = TileEntityBehaviour.get(mc.level, selectedLocation, LinkBehaviour.TYPE); if (linkBehaviour != null) { AllPackets.channel.sendToServer(new LinkedControllerBindPacket(integer, selectedLocation)); Lang.sendStatus(mc.player, "linked_controller.key_bound", controls.get(integer) - .getBoundKeyLocalizedText() + .getTranslatedKeyMessage() .getString()); } MODE = Mode.IDLE; @@ -225,7 +225,7 @@ public class LinkedControllerClientHandler { } currentlyPressed = pressedKeys; - controls.forEach(kb -> kb.setPressed(false)); + controls.forEach(kb -> kb.setDown(false)); } public static void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, @@ -234,38 +234,38 @@ public class LinkedControllerClientHandler { return; Minecraft mc = Minecraft.getInstance(); - ms.push(); + ms.pushPose(); Screen tooltipScreen = new TooltipScreen(null); tooltipScreen.init(mc, mc.getWindow() - .getScaledWidth(), + .getGuiScaledWidth(), mc.getWindow() - .getScaledHeight()); + .getGuiScaledHeight()); Object[] keys = new Object[6]; Vector controls = getControls(); for (int i = 0; i < controls.size(); i++) { KeyBinding keyBinding = controls.get(i); - keys[i] = keyBinding.getBoundKeyLocalizedText() + keys[i] = keyBinding.getTranslatedKeyMessage() .getString(); } List list = new ArrayList<>(); list.add(Lang.createTranslationTextComponent("linked_controller.bind_mode") - .formatted(TextFormatting.GOLD)); + .withStyle(TextFormatting.GOLD)); list.addAll( TooltipHelper.cutTextComponent(Lang.createTranslationTextComponent("linked_controller.press_keybind", keys), TextFormatting.GRAY, TextFormatting.GRAY)); int width = 0; - int height = list.size() * mc.fontRenderer.FONT_HEIGHT; + int height = list.size() * mc.font.lineHeight; for (ITextComponent iTextComponent : list) - width = Math.max(width, mc.fontRenderer.getWidth(iTextComponent)); + width = Math.max(width, mc.font.width(iTextComponent)); int x = (tooltipScreen.width / 3) - width / 2; int y = tooltipScreen.height - height; - tooltipScreen.renderTooltip(ms, list, x, y); + tooltipScreen.renderComponentTooltip(ms, list, x, y); - ms.pop(); + ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerContainer.java index d2770f269..3f546e399 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerContainer.java @@ -22,7 +22,7 @@ public class LinkedControllerContainer extends Container implements IClearableCo public ItemStackHandler filterInventory; public LinkedControllerContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { - this(type, id, inv, extraData.readItemStack()); + this(type, id, inv, extraData.readItem()); } public LinkedControllerContainer(ContainerType type, int id, PlayerInventory inv, ItemStack filterItem) { @@ -42,7 +42,7 @@ public class LinkedControllerContainer extends Container implements IClearableCo // readData(mainItem); addPlayerSlots(); addLinkSlots(); - detectAndSendChanges(); + broadcastChanges(); } protected void addPlayerSlots() { @@ -77,28 +77,28 @@ public class LinkedControllerContainer extends Container implements IClearableCo } @Override - public boolean canMergeSlot(ItemStack stack, Slot slotIn) { - return canDragIntoSlot(slotIn); + public boolean canTakeItemForPickAll(ItemStack stack, Slot slotIn) { + return canDragTo(slotIn); } @Override - public boolean canDragIntoSlot(Slot slotIn) { - return slotIn.inventory == playerInventory; + public boolean canDragTo(Slot slotIn) { + return slotIn.container == playerInventory; } @Override - public boolean canInteractWith(PlayerEntity playerIn) { - return playerInventory.getCurrentItem() == mainItem; + public boolean stillValid(PlayerEntity playerIn) { + return playerInventory.getSelected() == mainItem; } @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { - if (slotId == playerInventory.currentItem && clickTypeIn != ClickType.THROW) + public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { + if (slotId == playerInventory.selected && clickTypeIn != ClickType.THROW) return ItemStack.EMPTY; - ItemStack held = playerInventory.getItemStack(); + ItemStack held = playerInventory.getCarried(); if (slotId < 36) - return super.slotClick(slotId, dragType, clickTypeIn, player); + return super.clicked(slotId, dragType, clickTypeIn, player); if (clickTypeIn == ClickType.THROW) return ItemStack.EMPTY; @@ -108,7 +108,7 @@ public class LinkedControllerContainer extends Container implements IClearableCo ItemStack stackInSlot = filterInventory.getStackInSlot(slot) .copy(); stackInSlot.setCount(64); - playerInventory.setItemStack(stackInSlot); + playerInventory.setCarried(stackInSlot); return ItemStack.EMPTY; } return ItemStack.EMPTY; @@ -130,9 +130,9 @@ public class LinkedControllerContainer extends Container implements IClearableCo } @Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { if (index < 36) { - ItemStack stackToInsert = playerInventory.getStackInSlot(index); + ItemStack stackToInsert = playerInventory.getItem(index); for (int i = 0; i < filterInventory.getSlots(); i++) { ItemStack stack = filterInventory.getStackInSlot(i); if (stack.isEmpty()) { @@ -148,8 +148,8 @@ public class LinkedControllerContainer extends Container implements IClearableCo } @Override - public void onContainerClosed(PlayerEntity playerIn) { - super.onContainerClosed(playerIn); + public void removed(PlayerEntity playerIn) { + super.removed(playerIn); mainItem.getOrCreateTag() .put("Items", filterInventory.serializeNBT()); // saveData(filterItem); diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerInputPacket.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerInputPacket.java index 1b2414602..5a2105141 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerInputPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerInputPacket.java @@ -51,9 +51,9 @@ public class LinkedControllerInputPacket extends LinkedControllerPacketBase { @Override protected void handleItem(ServerPlayerEntity player, ItemStack heldItem) { - World world = player.getEntityWorld(); - UUID uniqueID = player.getUniqueID(); - BlockPos pos = player.getBlockPos(); + World world = player.getCommandSenderWorld(); + UUID uniqueID = player.getUUID(); + BlockPos pos = player.blockPosition(); if (player.isSpectator() && press) return; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItem.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItem.java index cfdf4be85..21cdf552a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItem.java @@ -31,6 +31,8 @@ import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.ItemStackHandler; +import net.minecraft.item.Item.Properties; + public class LinkedControllerItem extends Item implements INamedContainerProvider { public LinkedControllerItem(Properties properties) { @@ -42,29 +44,29 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide PlayerEntity player = ctx.getPlayer(); if (player == null) return ActionResultType.PASS; - World world = ctx.getWorld(); - BlockPos pos = ctx.getPos(); + World world = ctx.getLevel(); + BlockPos pos = ctx.getClickedPos(); BlockState hitState = world.getBlockState(pos); - if (player.isAllowEdit()) { - if (player.isSneaking()) { + if (player.mayBuild()) { + if (player.isShiftKeyDown()) { if (AllBlocks.LECTERN_CONTROLLER.has(hitState)) { - if (!world.isRemote) + if (!world.isClientSide) AllBlocks.LECTERN_CONTROLLER.get().withTileEntityDo(world, pos, te -> te.swapControllers(stack, player, ctx.getHand(), hitState)); return ActionResultType.SUCCESS; } } else { if (AllBlocks.REDSTONE_LINK.has(hitState)) { - if (world.isRemote) - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> this.toggleBindMode(ctx.getPos())); - player.getCooldownTracker() - .setCooldown(this, 2); + if (world.isClientSide) + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> this.toggleBindMode(ctx.getClickedPos())); + player.getCooldowns() + .addCooldown(this, 2); return ActionResultType.SUCCESS; } - if (hitState.isIn(Blocks.LECTERN) && !hitState.get(LecternBlock.HAS_BOOK)) { - if (!world.isRemote) { + if (hitState.is(Blocks.LECTERN) && !hitState.getValue(LecternBlock.HAS_BOOK)) { + if (!world.isClientSide) { ItemStack lecternStack = player.isCreative() ? stack.copy() : stack.split(1); AllBlocks.LECTERN_CONTROLLER.get().replaceLectern(hitState, world, pos, lecternStack); } @@ -76,26 +78,26 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide } } - return onItemRightClick(world, player, ctx.getHand()).getType(); + return use(world, player, ctx.getHand()).getResult(); } @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { - ItemStack heldItem = player.getHeldItem(hand); + public ActionResult use(World world, PlayerEntity player, Hand hand) { + ItemStack heldItem = player.getItemInHand(hand); - if (player.isSneaking() && hand == Hand.MAIN_HAND) { - if (!world.isRemote && player instanceof ServerPlayerEntity && player.isAllowEdit()) + if (player.isShiftKeyDown() && hand == Hand.MAIN_HAND) { + if (!world.isClientSide && player instanceof ServerPlayerEntity && player.mayBuild()) NetworkHooks.openGui((ServerPlayerEntity) player, this, buf -> { - buf.writeItemStack(heldItem); + buf.writeItem(heldItem); }); return ActionResult.success(heldItem); } - if (!player.isSneaking()) { - if (world.isRemote) + if (!player.isShiftKeyDown()) { + if (world.isClientSide) DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::toggleActive); - player.getCooldownTracker() - .setCooldown(this, 2); + player.getCooldowns() + .addCooldown(this, 2); } return ActionResult.pass(heldItem); @@ -115,7 +117,7 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide ItemStackHandler newInv = new ItemStackHandler(12); if (AllItems.LINKED_CONTROLLER.get() != stack.getItem()) throw new IllegalArgumentException("Cannot get frequency items from non-controller: " + stack); - CompoundNBT invNBT = stack.getOrCreateChildTag("Items"); + CompoundNBT invNBT = stack.getOrCreateTagElement("Items"); if (!invNBT.isEmpty()) newInv.deserializeNBT(invNBT); return newInv; @@ -129,13 +131,13 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide @Override public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { - ItemStack heldItem = player.getHeldItemMainhand(); + ItemStack heldItem = player.getMainHandItem(); return LinkedControllerContainer.create(id, inv, heldItem); } @Override public ITextComponent getDisplayName() { - return new TranslationTextComponent(getTranslationKey()); + return new TranslationTextComponent(getDescriptionId()); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java index 26bc5bad5..f99e22e72 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java @@ -65,10 +65,10 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere float pt = AnimationTickHolder.getPartialTicks(); MatrixStacker msr = MatrixStacker.of(ms); - ms.push(); + ms.pushPose(); Minecraft mc = Minecraft.getInstance(); - boolean rightHanded = mc.gameSettings.mainHand == HandSide.RIGHT; + boolean rightHanded = mc.options.mainHand == HandSide.RIGHT; TransformType mainHand = rightHanded ? TransformType.FIRST_PERSON_RIGHT_HAND : TransformType.FIRST_PERSON_LEFT_HAND; TransformType offHand = @@ -77,15 +77,15 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere if (active == null) { active = false; - boolean noControllerInMain = !AllItems.LINKED_CONTROLLER.isIn(mc.player.getHeldItemMainhand()); + boolean noControllerInMain = !AllItems.LINKED_CONTROLLER.isIn(mc.player.getMainHandItem()); if (transformType == mainHand || (transformType == offHand && noControllerInMain)) { active = true; } if (transformType == TransformType.GUI) { - if (stack == mc.player.getHeldItemMainhand()) + if (stack == mc.player.getMainHandItem()) active = true; - if (stack == mc.player.getHeldItemOffhand() && noControllerInMain) + if (stack == mc.player.getOffhandItem() && noControllerInMain) active = true; } @@ -104,7 +104,7 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere renderer.render(active ? model.getPartial("powered") : model.getOriginalModel(), light); if (!usedByMe) { - ms.pop(); + ms.popPose(); return; } @@ -118,7 +118,7 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere light = i << 20; } - ms.push(); + ms.pushPose(); msr.translate(2 * s, 0, 8 * s); button(renderer, ms, light, pt, button, b, index++); msr.translate(4 * s, 0, 0); @@ -127,23 +127,23 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere button(renderer, ms, light, pt, button, b, index++); msr.translate(0, 0, -4 * s); button(renderer, ms, light, pt, button, b, index++); - ms.pop(); + ms.popPose(); msr.translate(3 * s, 0, 3 * s); button(renderer, ms, light, pt, button, b, index++); msr.translate(2 * s, 0, 0); button(renderer, ms, light, pt, button, b, index++); - ms.pop(); + ms.popPose(); } protected static void button(PartialItemModelRenderer renderer, MatrixStack ms, int light, float pt, IBakedModel button, float b, int index) { - ms.push(); + ms.pushPose(); ms.translate(0, b * buttons.get(index) .getValue(pt), 0); renderer.renderSolid(button, light); - ms.pop(); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerPacketBase.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerPacketBase.java index 78a844af7..d6c391e69 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerPacketBase.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerPacketBase.java @@ -48,14 +48,14 @@ public abstract class LinkedControllerPacketBase extends SimplePacketBase { return; if (inLectern()) { - TileEntity te = player.world.getTileEntity(lecternPos); + TileEntity te = player.level.getBlockEntity(lecternPos); if (!(te instanceof LecternControllerTileEntity)) return; handleLectern(player, (LecternControllerTileEntity) te); } else { - ItemStack controller = player.getHeldItemMainhand(); + ItemStack controller = player.getMainHandItem(); if (!AllItems.LINKED_CONTROLLER.isIn(controller)) { - controller = player.getHeldItemOffhand(); + controller = player.getOffhandItem(); if (!AllItems.LINKED_CONTROLLER.isIn(controller)) return; } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerScreen.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerScreen.java index bfbfbbbde..8c95a94d1 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerScreen.java @@ -41,8 +41,8 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreenat(x + background.width - 4, y + background.height - 56, -200) .scale(5) .render(ms); @@ -76,9 +76,9 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen(), hoveredSlot.getSlotIndex()), x, y, textRenderer); + renderWrappedToolTip(ms, addToTooltip(new LinkedList<>(), hoveredSlot.getSlotIndex()), x, y, font); } @Override public List getTooltipFromItem(ItemStack stack) { List list = super.getTooltipFromItem(stack); - if (hoveredSlot.inventory == container.playerInventory) + if (hoveredSlot.container == menu.playerInventory) return list; return hoveredSlot != null ? addToTooltip(list, hoveredSlot.getSlotIndex()) : list; } @@ -126,9 +126,9 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen ex super.init(); widgets.clear(); - int x = guiLeft; - int y = guiTop; + int x = leftPos; + int y = topPos; resetButton = new IconButton(x + background.width - 62, y + background.height - 24, AllIcons.I_TRASH); confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM); @@ -62,16 +62,16 @@ public abstract class AbstractFilterScreen ex @Override protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { int invX = getLeftOfCentered(PLAYER_INVENTORY.width); - int invY = guiTop + background.height + 4; + int invY = topPos + background.height + 4; renderPlayerInventory(ms, invX, invY); - int x = guiLeft; - int y = guiTop; + int x = leftPos; + int y = topPos; background.draw(ms, this, x, y); - drawCenteredText(ms, textRenderer, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); + drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); - GuiGameElement.of(container.contentHolder) + GuiGameElement.of(menu.contentHolder) .at(x + background.width, y + background.height - 56, -200) .scale(5) .render(ms); @@ -83,9 +83,9 @@ public abstract class AbstractFilterScreen ex super.tick(); handleIndicators(); - if (!container.player.getHeldItemMainhand() - .equals(container.contentHolder, false)) - client.player.closeScreen(); + if (!menu.player.getMainHandItem() + .equals(menu.contentHolder, false)) + minecraft.player.closeContainer(); } public void handleIndicators() { @@ -142,13 +142,13 @@ public abstract class AbstractFilterScreen ex if (button == 0) { if (confirmButton.isHovered()) { - client.player.closeScreen(); + minecraft.player.closeContainer(); return true; } if (resetButton.isHovered()) { - container.clearContents(); + menu.clearContents(); contentsCleared(); - container.sendClearPacket(); + menu.sendClearPacket(); return true; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java index c6ddeec64..8d0691975 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java @@ -51,8 +51,8 @@ public class AttributeFilterContainer extends AbstractFilterContainer { protected void init(PlayerInventory inv, ItemStack contentHolder) { super.init(inv, contentHolder); ItemStack stack = new ItemStack(Items.NAME_TAG); - stack.setDisplayName( - new StringTextComponent("Selected Tags").formatted(TextFormatting.RESET, TextFormatting.BLUE)); + stack.setHoverName( + new StringTextComponent("Selected Tags").withStyle(TextFormatting.RESET, TextFormatting.BLUE)); ghostInventory.setStackInSlot(1, stack); } @@ -71,7 +71,7 @@ public class AttributeFilterContainer extends AbstractFilterContainer { this.addSlot(new SlotItemHandler(ghostInventory, 0, 16, 22)); this.addSlot(new SlotItemHandler(ghostInventory, 1, 22, 57) { @Override - public boolean canTakeStack(PlayerEntity playerIn) { + public boolean mayPickup(PlayerEntity playerIn) { return false; } }); @@ -88,28 +88,28 @@ public class AttributeFilterContainer extends AbstractFilterContainer { } @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { + public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { if (slotId == 37) return ItemStack.EMPTY; - return super.slotClick(slotId, dragType, clickTypeIn, player); + return super.clicked(slotId, dragType, clickTypeIn, player); } @Override - public boolean canDragIntoSlot(Slot slotIn) { - if (slotIn.slotNumber == 37) + public boolean canDragTo(Slot slotIn) { + if (slotIn.index == 37) return false; - return super.canDragIntoSlot(slotIn); + return super.canDragTo(slotIn); } @Override - public boolean canMergeSlot(ItemStack stack, Slot slotIn) { - if (slotIn.slotNumber == 37) + public boolean canTakeItemForPickAll(ItemStack stack, Slot slotIn) { + if (slotIn.index == 37) return false; - return super.canMergeSlot(stack, slotIn); + return super.canTakeItemForPickAll(stack, slotIn); } @Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { if (index == 37) return ItemStack.EMPTY; if (index == 36) { @@ -117,7 +117,7 @@ public class AttributeFilterContainer extends AbstractFilterContainer { return ItemStack.EMPTY; } if (index < 36) { - ItemStack stackToInsert = playerInventory.getStackInSlot(index); + ItemStack stackToInsert = playerInventory.getItem(index); ItemStack copy = stackToInsert.copy(); copy.setCount(1); ghostInventory.setStackInSlot(0, copy); diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java index ba7ccfa45..ee2339881 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java @@ -64,8 +64,8 @@ public class AttributeFilterScreen extends AbstractFilterScreen selectedAttributes.add(new StringTextComponent("- ") + selectedAttributes.add((menu.selectedAttributes.isEmpty() ? noSelectedT : selectedT).plainCopy() + .withStyle(TextFormatting.YELLOW)); + menu.selectedAttributes.forEach(at -> selectedAttributes.add(new StringTextComponent("- ") .append(at.getFirst() .format(at.getSecond())) - .formatted(TextFormatting.GRAY))); + .withStyle(TextFormatting.GRAY))); } private void referenceItemChanged(ItemStack stack) { @@ -113,8 +113,8 @@ public class AttributeFilterScreen extends AbstractFilterScreen { @@ -125,12 +125,12 @@ public class AttributeFilterScreen extends AbstractFilterScreen options = attributesOfItem.stream() .map(a -> a.format(false)) .collect(Collectors.toList()); @@ -141,7 +141,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen { attributeSelectorLabel.setTextAndTrim(options.get(i), true, 112); ItemAttribute selected = attributesOfItem.get(i); - for (Pair existing : container.selectedAttributes) { + for (Pair existing : menu.selectedAttributes) { CompoundNBT testTag = new CompoundNBT(); CompoundNBT testTag2 = new CompoundNBT(); existing.getFirst() @@ -161,16 +161,16 @@ public class AttributeFilterScreen extends AbstractFilterScreen getTooltipDescriptions() { - return Arrays.asList(denyDESC.copy(), allowConDESC.copy(), allowDisDESC.copy()); + return Arrays.asList(denyDESC.plainCopy(), allowConDESC.plainCopy(), allowDisDESC.plainCopy()); } @Override @@ -214,19 +214,19 @@ public class AttributeFilterScreen extends AbstractFilterScreen tooltip, ITooltipFlag flagIn) { + public void appendHoverText(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { if (!AllKeys.shiftDown()) { List makeSummary = makeSummary(stack); if (makeSummary.isEmpty()) @@ -90,18 +92,18 @@ public class FilterItem extends Item implements INamedContainerProvider { boolean blacklist = filter.getOrCreateTag() .getBoolean("Blacklist"); - list.add((blacklist ? Lang.translate("gui.filter.deny_list") : Lang.translate("gui.filter.allow_list")).formatted(TextFormatting.GOLD)); + list.add((blacklist ? Lang.translate("gui.filter.deny_list") : Lang.translate("gui.filter.allow_list")).withStyle(TextFormatting.GOLD)); int count = 0; for (int i = 0; i < filterItems.getSlots(); i++) { if (count > 3) { - list.add(new StringTextComponent("- ...").formatted(TextFormatting.DARK_GRAY)); + list.add(new StringTextComponent("- ...").withStyle(TextFormatting.DARK_GRAY)); break; } ItemStack filterStack = filterItems.getStackInSlot(i); if (filterStack.isEmpty()) continue; - list.add(new StringTextComponent("- ").append(filterStack.getDisplayName()).formatted(TextFormatting.GRAY)); + list.add(new StringTextComponent("- ").append(filterStack.getHoverName()).withStyle(TextFormatting.GRAY)); count++; } @@ -116,7 +118,7 @@ public class FilterItem extends Item implements INamedContainerProvider { ? Lang.translate("gui.attribute_filter.allow_list_conjunctive") : whitelistMode == WhitelistMode.WHITELIST_DISJ ? Lang.translate("gui.attribute_filter.allow_list_disjunctive") - : Lang.translate("gui.attribute_filter.deny_list")).formatted(TextFormatting.GOLD)); + : Lang.translate("gui.attribute_filter.deny_list")).withStyle(TextFormatting.GOLD)); int count = 0; ListNBT attributes = filter.getOrCreateTag() @@ -126,7 +128,7 @@ public class FilterItem extends Item implements INamedContainerProvider { ItemAttribute attribute = ItemAttribute.fromNBT(compound); boolean inverted = compound.getBoolean("Inverted"); if (count > 3) { - list.add(new StringTextComponent("- ...").formatted(TextFormatting.DARK_GRAY)); + list.add(new StringTextComponent("- ...").withStyle(TextFormatting.DARK_GRAY)); break; } list.add(new StringTextComponent("- ").append(attribute.format(inverted))); @@ -141,13 +143,13 @@ public class FilterItem extends Item implements INamedContainerProvider { } @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { - ItemStack heldItem = player.getHeldItem(hand); + public ActionResult use(World world, PlayerEntity player, Hand hand) { + ItemStack heldItem = player.getItemInHand(hand); - if (!player.isSneaking() && hand == Hand.MAIN_HAND) { - if (!world.isRemote && player instanceof ServerPlayerEntity) + if (!player.isShiftKeyDown() && hand == Hand.MAIN_HAND) { + if (!world.isClientSide && player instanceof ServerPlayerEntity) NetworkHooks.openGui((ServerPlayerEntity) player, this, buf -> { - buf.writeItemStack(heldItem); + buf.writeItem(heldItem); }); return ActionResult.success(heldItem); } @@ -156,7 +158,7 @@ public class FilterItem extends Item implements INamedContainerProvider { @Override public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { - ItemStack heldItem = player.getHeldItemMainhand(); + ItemStack heldItem = player.getMainHandItem(); if (type == FilterType.REGULAR) return FilterContainer.create(id, inv, heldItem); if (type == FilterType.ATTRIBUTE) @@ -166,14 +168,14 @@ public class FilterItem extends Item implements INamedContainerProvider { @Override public ITextComponent getDisplayName() { - return new TranslationTextComponent(getTranslationKey()); + return new TranslationTextComponent(getDescriptionId()); } public static ItemStackHandler getFilterItems(ItemStack stack) { ItemStackHandler newInv = new ItemStackHandler(18); if (AllItems.FILTER.get() != stack.getItem()) throw new IllegalArgumentException("Cannot get filter items from non-filter: " + stack); - CompoundNBT invNBT = stack.getOrCreateChildTag("Items"); + CompoundNBT invNBT = stack.getOrCreateTagElement("Items"); if (!invNBT.isEmpty()) newInv.deserializeNBT(invNBT); return newInv; @@ -193,7 +195,7 @@ public class FilterItem extends Item implements INamedContainerProvider { if (!(filter.getItem() instanceof FilterItem)) return (matchNBT ? ItemHandlerHelper.canItemStacksStack(filter, stack) - : ItemStack.areItemsEqual(filter, stack)); + : ItemStack.isSame(filter, stack)); if (AllItems.FILTER.get() == filter.getItem()) { ItemStackHandler filterItems = getFilterItems(filter); @@ -271,7 +273,7 @@ public class FilterItem extends Item implements INamedContainerProvider { return false; if (!matchNBT) return fluidInFilter.getFluid() - .isEquivalentTo(stack.getFluid()); + .isSame(stack.getFluid()); boolean fluidEqual = fluidInFilter.isFluidEqual(stack); return fluidEqual; } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreen.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreen.java index d4fcd2618..579c8d711 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreen.java @@ -43,8 +43,8 @@ public class FilterScreen extends AbstractFilterScreen { setWindowOffset(-11, 5); super.init(); - int x = guiLeft; - int y = guiTop; + int x = leftPos; + int y = topPos; blacklist = new IconButton(x + 18, y + 73, AllIcons.I_BLACKLIST); blacklist.setToolTip(denyN); @@ -73,25 +73,25 @@ public class FilterScreen extends AbstractFilterScreen { return mouseClicked; if (blacklist.isHovered()) { - container.blacklist = true; + menu.blacklist = true; sendOptionUpdate(Option.BLACKLIST); return true; } if (whitelist.isHovered()) { - container.blacklist = false; + menu.blacklist = false; sendOptionUpdate(Option.WHITELIST); return true; } if (respectNBT.isHovered()) { - container.respectNBT = true; + menu.respectNBT = true; sendOptionUpdate(Option.RESPECT_DATA); return true; } if (ignoreNBT.isHovered()) { - container.respectNBT = false; + menu.respectNBT = false; sendOptionUpdate(Option.IGNORE_DATA); return true; } @@ -106,32 +106,32 @@ public class FilterScreen extends AbstractFilterScreen { @Override protected List getTooltipDescriptions() { - return Arrays.asList(denyDESC.copy(), allowDESC.copy(), respectDataDESC.copy(), ignoreDataDESC.copy()); + return Arrays.asList(denyDESC.plainCopy(), allowDESC.plainCopy(), respectDataDESC.plainCopy(), ignoreDataDESC.plainCopy()); } @Override protected boolean isButtonEnabled(IconButton button) { if (button == blacklist) - return !container.blacklist; + return !menu.blacklist; if (button == whitelist) - return container.blacklist; + return menu.blacklist; if (button == respectNBT) - return !container.respectNBT; + return !menu.respectNBT; if (button == ignoreNBT) - return container.respectNBT; + return menu.respectNBT; return true; } @Override protected boolean isIndicatorOn(Indicator indicator) { if (indicator == blacklistIndicator) - return container.blacklist; + return menu.blacklist; if (indicator == whitelistIndicator) - return !container.blacklist; + return !menu.blacklist; if (indicator == respectNBTIndicator) - return container.respectNBT; + return menu.respectNBT; if (indicator == ignoreNBTIndicator) - return !container.respectNBT; + return !menu.respectNBT; return false; } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreenPacket.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreenPacket.java index 1b1f61398..a1e50375a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreenPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreenPacket.java @@ -30,13 +30,13 @@ public class FilterScreenPacket extends SimplePacketBase { public FilterScreenPacket(PacketBuffer buffer) { option = Option.values()[buffer.readInt()]; - data = buffer.readCompoundTag(); + data = buffer.readNbt(); } @Override public void write(PacketBuffer buffer) { buffer.writeInt(option.ordinal()); - buffer.writeCompoundTag(data); + buffer.writeNbt(data); } @Override @@ -46,8 +46,8 @@ public class FilterScreenPacket extends SimplePacketBase { if (player == null) return; - if (player.openContainer instanceof FilterContainer) { - FilterContainer c = (FilterContainer) player.openContainer; + if (player.containerMenu instanceof FilterContainer) { + FilterContainer c = (FilterContainer) player.containerMenu; if (option == Option.WHITELIST) c.blacklist = false; if (option == Option.BLACKLIST) @@ -59,11 +59,11 @@ public class FilterScreenPacket extends SimplePacketBase { if (option == Option.UPDATE_FILTER_ITEM) c.ghostInventory.setStackInSlot( data.getInt("Slot"), - net.minecraft.item.ItemStack.read(data.getCompound("Item"))); + net.minecraft.item.ItemStack.of(data.getCompound("Item"))); } - if (player.openContainer instanceof AttributeFilterContainer) { - AttributeFilterContainer c = (AttributeFilterContainer) player.openContainer; + if (player.containerMenu instanceof AttributeFilterContainer) { + AttributeFilterContainer c = (AttributeFilterContainer) player.containerMenu; if (option == Option.WHITELIST) c.whitelistMode = WhitelistMode.WHITELIST_DISJ; if (option == Option.WHITELIST2) diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/ItemAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/ItemAttribute.java index beb7a8946..b72d60db7 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/ItemAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/ItemAttribute.java @@ -54,7 +54,7 @@ public interface ItemAttribute { static ItemAttribute standard = register(StandardTraits.DUMMY); static ItemAttribute inTag = register(new InTag(new ResourceLocation("dummy"))); - static ItemAttribute inItemGroup = register(new InItemGroup(ItemGroup.MISC)); + static ItemAttribute inItemGroup = register(new InItemGroup(ItemGroup.TAB_MISC)); static ItemAttribute addedBy = register(new InItemGroup.AddedBy("dummy")); static ItemAttribute hasEnchant = register(EnchantAttribute.EMPTY); static ItemAttribute shulkerFillLevel = register(ShulkerFillLevelAttribute.EMPTY); @@ -128,12 +128,12 @@ public interface ItemAttribute { DUMMY(s -> false), PLACEABLE(s -> s.getItem() instanceof BlockItem), - CONSUMABLE(ItemStack::isFood), + CONSUMABLE(ItemStack::isEdible), FLUID_CONTAINER(s -> s.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).isPresent()), ENCHANTED(ItemStack::isEnchanted), - RENAMED(ItemStack::hasDisplayName), + RENAMED(ItemStack::hasCustomHoverName), DAMAGED(ItemStack::isDamaged), - BADLY_DAMAGED(s -> s.isDamaged() && s.getDamage() / s.getMaxDamage() > 3 / 4f), + BADLY_DAMAGED(s -> s.isDamaged() && s.getDamageValue() / s.getMaxDamage() > 3 / 4f), NOT_STACKABLE(((Predicate) ItemStack::isStackable).negate()), EQUIPABLE(s -> s.getEquipmentSlot() != null), MAX_ENCHANTED(StandardTraits::maxEnchanted), @@ -154,9 +154,9 @@ public interface ItemAttribute { } private static boolean testRecipe(ItemStack s, World w, IRecipeType> type) { - RECIPE_WRAPPER.setInventorySlotContents(0, s.copy()); + RECIPE_WRAPPER.setItem(0, s.copy()); return w.getRecipeManager() - .getRecipe(type, RECIPE_WRAPPER, w) + .getRecipeFor(type, RECIPE_WRAPPER, w) .isPresent(); } @@ -280,13 +280,13 @@ public interface ItemAttribute { @Override public boolean appliesTo(ItemStack stack) { Item item = stack.getItem(); - return item.getGroup() == group; + return item.getItemCategory() == group; } @Override public List listAttributesOf(ItemStack stack) { ItemGroup group = stack.getItem() - .getGroup(); + .getItemCategory(); return group == null ? Collections.emptyList() : Arrays.asList(new InItemGroup(group)); } @@ -299,19 +299,19 @@ public interface ItemAttribute { @OnlyIn(value = Dist.CLIENT) public TranslationTextComponent format(boolean inverted) { return Lang.translate("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""), - group.getTranslationKey()); + group.getDisplayName()); } @Override public void writeNBT(CompoundNBT nbt) { - nbt.putString("path", group.getPath()); + nbt.putString("path", group.getRecipeFolderName()); } @Override public ItemAttribute readNBT(CompoundNBT nbt) { String readPath = nbt.getString("path"); - for (ItemGroup group : ItemGroup.GROUPS) - if (group.getPath() + for (ItemGroup group : ItemGroup.TABS) + if (group.getRecipeFolderName() .equals(readPath)) return new InItemGroup(group); return null; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ColorAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ColorAttribute.java index f9e5e2380..354fe068c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ColorAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ColorAttribute.java @@ -56,7 +56,7 @@ public class ColorAttribute implements ItemAttribute { colors.addAll(getFireworkStarColors(nbt.getCompound("Explosion"))); } - Arrays.stream(DyeColor.values()).filter(c -> stack.getItem().getRegistryName().getPath().startsWith(c.getTranslationKey() + "_")).forEach(colors::add); + Arrays.stream(DyeColor.values()).filter(c -> stack.getItem().getRegistryName().getPath().startsWith(c.getName() + "_")).forEach(colors::add); return colors; } @@ -75,7 +75,7 @@ public class ColorAttribute implements ItemAttribute { @Override public Object[] getTranslationParameters() { - return new Object[]{new TranslationTextComponent(color.getTranslationKey()).getUnformattedComponentText()}; + return new Object[]{new TranslationTextComponent(color.getName()).getContents()}; } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/EnchantAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/EnchantAttribute.java index 611eb28a6..d23c806b9 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/EnchantAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/EnchantAttribute.java @@ -43,7 +43,7 @@ public class EnchantAttribute implements ItemAttribute { public Object[] getTranslationParameters() { String parameter = ""; if(enchantment != null) - parameter = new TranslationTextComponent(enchantment.getName()).getString(); + parameter = new TranslationTextComponent(enchantment.getDescriptionId()).getString(); return new Object[] { parameter }; } @@ -59,6 +59,6 @@ public class EnchantAttribute implements ItemAttribute { @Override public ItemAttribute readNBT(CompoundNBT nbt) { - return nbt.contains("id") ? new EnchantAttribute(ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryCreate(nbt.getString("id")))) : EMPTY; + return nbt.contains("id") ? new EnchantAttribute(ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryParse(nbt.getString("id")))) : EMPTY; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/FluidContentsAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/FluidContentsAttribute.java index 76638df30..dfe0ee944 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/FluidContentsAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/FluidContentsAttribute.java @@ -62,7 +62,7 @@ public class FluidContentsAttribute implements ItemAttribute { @Override public ItemAttribute readNBT(CompoundNBT nbt) { - return nbt.contains("id") ? new FluidContentsAttribute(ForgeRegistries.FLUIDS.getValue(ResourceLocation.tryCreate(nbt.getString("id")))) : EMPTY; + return nbt.contains("id") ? new FluidContentsAttribute(ForgeRegistries.FLUIDS.getValue(ResourceLocation.tryParse(nbt.getString("id")))) : EMPTY; } private List extractFluids(ItemStack stack) { diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ItemNameAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ItemNameAttribute.java index 0c9581cae..ebe7c6024 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ItemNameAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ItemNameAttribute.java @@ -54,7 +54,7 @@ public class ItemNameAttribute implements ItemAttribute { } private String extractCustomName(ItemStack stack) { - CompoundNBT compoundnbt = stack.getChildTag("display"); + CompoundNBT compoundnbt = stack.getTagElement("display"); if (compoundnbt != null && compoundnbt.contains("Name", 8)) { try { ITextComponent itextcomponent = ITextComponent.Serializer.fromJson(compoundnbt.getString("Name")); diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ShulkerFillLevelAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ShulkerFillLevelAttribute.java index 14cf79a44..8950409b6 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ShulkerFillLevelAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ShulkerFillLevelAttribute.java @@ -82,13 +82,13 @@ public class ShulkerFillLevelAttribute implements ItemAttribute { } private static boolean isShulker(ItemStack stack) { - return Block.getBlockFromItem(stack.getItem()) instanceof ShulkerBoxBlock; + return Block.byItem(stack.getItem()) instanceof ShulkerBoxBlock; } public boolean canApply(ItemStack testStack) { if (!isShulker(testStack)) return false; - CompoundNBT compoundnbt = testStack.getChildTag("BlockEntityTag"); + CompoundNBT compoundnbt = testStack.getTagElement("BlockEntityTag"); if (compoundnbt == null) return requiredSize.test(0); if (compoundnbt.contains("LootTable", 8)) diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryAmuletAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryAmuletAttribute.java index 85b40b8d2..dbc3c8e7a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryAmuletAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryAmuletAttribute.java @@ -54,9 +54,9 @@ public class AstralSorceryAmuletAttribute implements ItemAttribute { public Object[] getTranslationParameters() { String something = ""; - Enchantment enchant = ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryCreate(enchName)); + Enchantment enchant = ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryParse(enchName)); if(enchant != null) { - something = new TranslationTextComponent(enchant.getName()).getString(); + something = new TranslationTextComponent(enchant.getDescriptionId()).getString(); } if(enchType == 1) something = "existing " + something; diff --git a/src/main/java/com/simibubi/create/content/logistics/packet/FunnelFlapPacket.java b/src/main/java/com/simibubi/create/content/logistics/packet/FunnelFlapPacket.java index 4118817ff..526fbfe5f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/packet/FunnelFlapPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/packet/FunnelFlapPacket.java @@ -16,7 +16,7 @@ public class FunnelFlapPacket extends TileEntityDataPacket { } public FunnelFlapPacket(FunnelTileEntity tile, boolean inwards) { - super(tile.getPos()); + super(tile.getBlockPos()); this.inwards = inwards; } diff --git a/src/main/java/com/simibubi/create/content/logistics/packet/TunnelFlapPacket.java b/src/main/java/com/simibubi/create/content/logistics/packet/TunnelFlapPacket.java index 0fcf32b4d..2545b164e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/packet/TunnelFlapPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/packet/TunnelFlapPacket.java @@ -23,7 +23,7 @@ public class TunnelFlapPacket extends TileEntityDataPacket this.flaps = new ArrayList<>(size); for (int i = 0; i < size; i++) { - Direction direction = Direction.byIndex(buffer.readByte()); + Direction direction = Direction.from3DDataValue(buffer.readByte()); boolean inwards = buffer.readBoolean(); flaps.add(Pair.of(direction, inwards)); @@ -31,7 +31,7 @@ public class TunnelFlapPacket extends TileEntityDataPacket } public TunnelFlapPacket(BeltTunnelTileEntity tile, List> flaps) { - super(tile.getPos()); + super(tile.getBlockPos()); this.flaps = new ArrayList<>(flaps); } @@ -41,7 +41,7 @@ public class TunnelFlapPacket extends TileEntityDataPacket buffer.writeByte(flaps.size()); for (Pair flap : flaps) { - buffer.writeByte(flap.getLeft().getIndex()); + buffer.writeByte(flap.getLeft().get3DDataValue()); buffer.writeBoolean(flap.getRight()); } } diff --git a/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java b/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java index f51eb78a1..0e8bae19e 100644 --- a/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java +++ b/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java @@ -43,7 +43,7 @@ public class AllPaletteBlocks { public static final BlockEntry TILED_GLASS = REGISTRATE.block("tiled_glass", GlassBlock::new) .initialProperties(() -> Blocks.GLASS) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .recipe((c, p) -> p.stonecutting(DataIngredient.tag(Tags.Items.GLASS_COLORLESS), c::get)) .blockstate(palettesCubeAll()) .tag(Tags.Blocks.GLASS_COLORLESS, BlockTags.IMPERMEABLE) @@ -61,7 +61,7 @@ public class AllPaletteBlocks { public static final BlockEntry TILED_GLASS_PANE = WindowGen.standardGlassPane("tiled_glass", TILED_GLASS, Create.asResource("block/palettes/tiled_glass"), - new ResourceLocation("block/glass_pane_top"), () -> RenderType::getCutoutMipped); + new ResourceLocation("block/glass_pane_top"), () -> RenderType::cutoutMipped); public static final BlockEntry FRAMED_GLASS_PANE = framedGlassPane("framed_glass", FRAMED_GLASS, AllSpriteShifts.FRAMED_GLASS), @@ -72,26 +72,26 @@ public class AllPaletteBlocks { public static final BlockEntry OAK_WINDOW = woodenWindowBlock(WoodType.OAK, Blocks.OAK_PLANKS), SPRUCE_WINDOW = woodenWindowBlock(WoodType.SPRUCE, Blocks.SPRUCE_PLANKS), - BIRCH_WINDOW = woodenWindowBlock(WoodType.BIRCH, Blocks.BIRCH_PLANKS, () -> RenderType::getTranslucent), + BIRCH_WINDOW = woodenWindowBlock(WoodType.BIRCH, Blocks.BIRCH_PLANKS, () -> RenderType::translucent), JUNGLE_WINDOW = woodenWindowBlock(WoodType.JUNGLE, Blocks.JUNGLE_PLANKS), ACACIA_WINDOW = woodenWindowBlock(WoodType.ACACIA, Blocks.ACACIA_PLANKS), DARK_OAK_WINDOW = woodenWindowBlock(WoodType.DARK_OAK, Blocks.DARK_OAK_PLANKS), CRIMSON_WINDOW = woodenWindowBlock(WoodType.CRIMSON, Blocks.CRIMSON_PLANKS), WARPED_WINDOW = woodenWindowBlock(WoodType.WARPED, Blocks.WARPED_PLANKS), ORNATE_IRON_WINDOW = customWindowBlock("ornate_iron_window", AllItems.ANDESITE_ALLOY, - AllSpriteShifts.ORNATE_IRON_WINDOW, () -> RenderType::getCutoutMipped); + AllSpriteShifts.ORNATE_IRON_WINDOW, () -> RenderType::cutoutMipped); public static final BlockEntry OAK_WINDOW_PANE = woodenWindowPane(WoodType.OAK, OAK_WINDOW), SPRUCE_WINDOW_PANE = woodenWindowPane(WoodType.SPRUCE, SPRUCE_WINDOW), - BIRCH_WINDOW_PANE = woodenWindowPane(WoodType.BIRCH, BIRCH_WINDOW, () -> RenderType::getTranslucent), + BIRCH_WINDOW_PANE = woodenWindowPane(WoodType.BIRCH, BIRCH_WINDOW, () -> RenderType::translucent), JUNGLE_WINDOW_PANE = woodenWindowPane(WoodType.JUNGLE, JUNGLE_WINDOW), ACACIA_WINDOW_PANE = woodenWindowPane(WoodType.ACACIA, ACACIA_WINDOW), DARK_OAK_WINDOW_PANE = woodenWindowPane(WoodType.DARK_OAK, DARK_OAK_WINDOW), CRIMSON_WINDOW_PANE = woodenWindowPane(WoodType.CRIMSON, CRIMSON_WINDOW), WARPED_WINDOW_PANE = woodenWindowPane(WoodType.WARPED, WARPED_WINDOW), ORNATE_IRON_WINDOW_PANE = customWindowPane("ornate_iron_window", ORNATE_IRON_WINDOW, - AllSpriteShifts.ORNATE_IRON_WINDOW, () -> RenderType::getCutoutMipped); + AllSpriteShifts.ORNATE_IRON_WINDOW, () -> RenderType::cutoutMipped); // Vanilla stone variant patterns @@ -157,7 +157,7 @@ public class AllPaletteBlocks { .initialProperties(() -> Blocks.ANDESITE) .tag(BlockTags.BASE_STONE_OVERWORLD) .onRegister(CreateRegistrate.blockVertexColors(new ScoriaVertexColor())) - .loot((p, g) -> p.registerLootTable(g, RegistrateBlockLootTables.droppingWithSilkTouch(g, SCORIA.get()))) + .loot((p, g) -> p.add(g, RegistrateBlockLootTables.droppingWithSilkTouch(g, SCORIA.get()))) .blockstate(palettesCubeAll()) .simpleItem() .register(); @@ -174,7 +174,7 @@ public class AllPaletteBlocks { new PalettesVariantEntry(PaletteStoneVariants.DARK_SCORIA, PaletteBlockPattern.STANDARD_RANGE, DARK_SCORIA); private static NonNullBiConsumer cobblestoneLoot(PaletteStoneVariants variant) { - return (loot, block) -> loot.registerLootTable(block, RegistrateBlockLootTables.droppingWithSilkTouch(block, + return (loot, block) -> loot.add(block, RegistrateBlockLootTables.droppingWithSilkTouch(block, variant.getVariants().registeredBlocks.get(0).get())); } diff --git a/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassBlock.java b/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassBlock.java index 0a2f58468..14bb132ba 100644 --- a/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassBlock.java @@ -9,6 +9,8 @@ import net.minecraft.world.IBlockDisplayReader; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.block.AbstractBlock.Properties; + public class ConnectedGlassBlock extends GlassBlock { public ConnectedGlassBlock(Properties p_i48392_1_) { @@ -17,9 +19,9 @@ public class ConnectedGlassBlock extends GlassBlock { @Override @OnlyIn(Dist.CLIENT) - public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { + public boolean skipRendering(BlockState state, BlockState adjacentBlockState, Direction side) { return adjacentBlockState.getBlock() instanceof ConnectedGlassBlock ? true - : super.isSideInvisible(state, adjacentBlockState, side); + : super.skipRendering(state, adjacentBlockState, side); } @Override diff --git a/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassPaneBlock.java b/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassPaneBlock.java index b7d57bc0d..add90e71a 100644 --- a/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassPaneBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassPaneBlock.java @@ -5,6 +5,8 @@ import net.minecraft.util.Direction; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.block.AbstractBlock.Properties; + public class ConnectedGlassPaneBlock extends GlassPaneBlock { public ConnectedGlassPaneBlock(Properties builder) { @@ -13,11 +15,11 @@ public class ConnectedGlassPaneBlock extends GlassPaneBlock { @Override @OnlyIn(Dist.CLIENT) - public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { + public boolean skipRendering(BlockState state, BlockState adjacentBlockState, Direction side) { if (side.getAxis() .isVertical()) return adjacentBlockState == state; - return super.isSideInvisible(state, adjacentBlockState, side); + return super.skipRendering(state, adjacentBlockState, side); } } diff --git a/src/main/java/com/simibubi/create/content/palettes/GlassPaneBlock.java b/src/main/java/com/simibubi/create/content/palettes/GlassPaneBlock.java index afd74e0d8..85a875828 100644 --- a/src/main/java/com/simibubi/create/content/palettes/GlassPaneBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/GlassPaneBlock.java @@ -2,6 +2,8 @@ package com.simibubi.create.content.palettes; import net.minecraft.block.PaneBlock; +import net.minecraft.block.AbstractBlock.Properties; + public class GlassPaneBlock extends PaneBlock { public GlassPaneBlock(Properties builder) { diff --git a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java index 9c79046af..e21cc1e83 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java +++ b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java @@ -95,7 +95,7 @@ public abstract class PaletteBlockPartial { @Override protected StairsBlock createBlock(Supplier block) { return new StairsBlock(() -> block.get() - .getDefaultState(), Properties.from(block.get())); + .defaultBlockState(), Properties.copy(block.get())); } @Override @@ -135,7 +135,7 @@ public abstract class PaletteBlockPartial { @Override protected SlabBlock createBlock(Supplier block) { - return new SlabBlock(Properties.from(block.get())); + return new SlabBlock(Properties.copy(block.get())); } @Override @@ -186,7 +186,7 @@ public abstract class PaletteBlockPartial { protected BlockBuilder transformBlock( BlockBuilder builder, String variantName, PaletteBlockPattern pattern) { - builder.loot((lt, block) -> lt.registerLootTable(block, RegistrateBlockLootTables.droppingSlab(block))); + builder.loot((lt, block) -> lt.add(block, RegistrateBlockLootTables.droppingSlab(block))); return super.transformBlock(builder, variantName, pattern); } @@ -200,7 +200,7 @@ public abstract class PaletteBlockPartial { @Override protected WallBlock createBlock(Supplier block) { - return new WallBlock(Properties.from(block.get())); + return new WallBlock(Properties.copy(block.get())); } @Override diff --git a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java index 16cdd6dfe..91819c83d 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java +++ b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java @@ -43,20 +43,20 @@ public class PaletteBlockPattern { .addRecipes(v -> (c, p) -> { DataIngredient ingredient = DataIngredient.items(c.get()); Block result = v.getBaseBlock().get(); - CookingRecipeBuilder.smeltingRecipe(ingredient, result, 0.1f, 200) - .addCriterion("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) - .build(p, p.safeId(result)); + CookingRecipeBuilder.smelting(ingredient, result, 0.1f, 200) + .unlockedBy("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) + .save(p, p.safeId(result)); }), POLISHED = create("polished", PREFIX, FOR_POLISHED) .addRecipes(v -> (c, p) -> { DataIngredient ingredient = DataIngredient.items(v.getBaseBlock().get()); - ShapedRecipeBuilder.shapedRecipe(c.get(), 4) - .key('#', ingredient) - .patternLine("##") - .patternLine("##") - .addCriterion("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) - .build(p, p.safeId(c.get())); + ShapedRecipeBuilder.shaped(c.get(), 4) + .define('#', ingredient) + .pattern("##") + .pattern("##") + .unlockedBy("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) + .save(p, p.safeId(c.get())); }), BRICKS = create("bricks", SUFFIX, ALL_PARTIALS), FANCY_BRICKS = create("fancy_bricks", WRAP, ALL_PARTIALS), @@ -77,12 +77,12 @@ public class PaletteBlockPattern { .textures("pillar", "pillar_end") .addRecipes(v -> (c, p) -> { DataIngredient ingredient = DataIngredient.items(v.getBaseBlock().get()); - ShapedRecipeBuilder.shapedRecipe(c.get(), 2) - .key('#', ingredient) - .patternLine("#") - .patternLine("#") - .addCriterion("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) - .build(p, p.safeId(c.get())); + ShapedRecipeBuilder.shaped(c.get(), 2) + .define('#', ingredient) + .pattern("#") + .pattern("#") + .unlockedBy("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) + .save(p, p.safeId(c.get())); }), MOSSY = create("mossy", PREFIX).blockStateFactory(p -> p::cubeAllButMossy) diff --git a/src/main/java/com/simibubi/create/content/palettes/PalettesItemGroup.java b/src/main/java/com/simibubi/create/content/palettes/PalettesItemGroup.java index a96173a7b..aa9d5746b 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PalettesItemGroup.java +++ b/src/main/java/com/simibubi/create/content/palettes/PalettesItemGroup.java @@ -23,7 +23,7 @@ public class PalettesItemGroup extends CreateItemGroupBase { public void addItems(NonNullList items, boolean specialItems) {} @Override - public ItemStack createIcon() { + public ItemStack makeIcon() { return new ItemStack(AllPaletteBlocks.ORNATE_IRON_WINDOW.get()); } diff --git a/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java b/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java index 9543a7b37..cecd78294 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java +++ b/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java @@ -37,7 +37,7 @@ public class PalettesVariantEntry { .apply(name)::accept); if (pattern.isTranslucent()) - builder.addLayer(() -> RenderType::getTranslucent); + builder.addLayer(() -> RenderType::translucent); if (pattern == PaletteBlockPattern.COBBLESTONE) builder.item().tag(AllTags.AllItemTags.COBBLESTONE.tag); if (pattern.hasFoliage()) diff --git a/src/main/java/com/simibubi/create/content/palettes/PavedBlock.java b/src/main/java/com/simibubi/create/content/palettes/PavedBlock.java index f1376cb8a..5604a46ba 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PavedBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/PavedBlock.java @@ -9,32 +9,34 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class PavedBlock extends Block { public static final BooleanProperty COVERED = BooleanProperty.create("covered"); public PavedBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(COVERED, false)); + registerDefaultState(defaultBlockState().setValue(COVERED, false)); } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(COVERED)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(COVERED)); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return getDefaultState().with(COVERED, context.getWorld() - .getBlockState(context.getPos().up()) + return defaultBlockState().setValue(COVERED, context.getLevel() + .getBlockState(context.getClickedPos().above()) .getBlock() == this); } @Override - public BlockState updatePostPlacement(BlockState stateIn, Direction face, BlockState neighbour, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction face, BlockState neighbour, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { if (face == Direction.UP) - return stateIn.with(COVERED, worldIn.getBlockState(facingPos).getBlock() == this); + return stateIn.setValue(COVERED, worldIn.getBlockState(facingPos).getBlock() == this); return stateIn; } diff --git a/src/main/java/com/simibubi/create/content/palettes/StandardFoliageColorHandler.java b/src/main/java/com/simibubi/create/content/palettes/StandardFoliageColorHandler.java index 061ff32aa..d0aaea069 100644 --- a/src/main/java/com/simibubi/create/content/palettes/StandardFoliageColorHandler.java +++ b/src/main/java/com/simibubi/create/content/palettes/StandardFoliageColorHandler.java @@ -14,7 +14,7 @@ public class StandardFoliageColorHandler implements IBlockColor { @Override public int getColor(BlockState state, IBlockDisplayReader light, BlockPos pos, int layer) { - return pos != null && light != null ? BiomeColors.getGrassColor(light, pos) : GrassColors.get(0.5D, 1.0D); + return pos != null && light != null ? BiomeColors.getAverageGrassColor(light, pos) : GrassColors.get(0.5D, 1.0D); } } diff --git a/src/main/java/com/simibubi/create/content/palettes/WindowBlock.java b/src/main/java/com/simibubi/create/content/palettes/WindowBlock.java index 02e3db3f7..827c1f852 100644 --- a/src/main/java/com/simibubi/create/content/palettes/WindowBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/WindowBlock.java @@ -7,6 +7,8 @@ import net.minecraft.util.Direction; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.block.AbstractBlock.Properties; + public class WindowBlock extends ConnectedGlassBlock { public WindowBlock(Properties p_i48392_1_) { @@ -15,11 +17,11 @@ public class WindowBlock extends ConnectedGlassBlock { @Override @OnlyIn(Dist.CLIENT) - public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { + public boolean skipRendering(BlockState state, BlockState adjacentBlockState, Direction side) { return adjacentBlockState.getBlock() instanceof ConnectedGlassBlock - ? (!RenderTypeLookup.canRenderInLayer(state, RenderType.getTranslucent()) && side.getAxis() + ? (!RenderTypeLookup.canRenderInLayer(state, RenderType.translucent()) && side.getAxis() .isHorizontal() || state.getBlock() == adjacentBlockState.getBlock()) - : super.isSideInvisible(state, adjacentBlockState, side); + : super.skipRendering(state, adjacentBlockState, side); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java b/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java index 0416a9acd..51e85900f 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java +++ b/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java @@ -80,14 +80,14 @@ public class ClientSchematicLoader { } public static boolean validateSizeLimitation(long size) { - if (Minecraft.getInstance().isSingleplayer()) + if (Minecraft.getInstance().hasSingleplayerServer()) return true; Integer maxSize = AllConfigs.SERVER.schematics.maxTotalSchematicSize.get(); if (size > maxSize * 1000) { ClientPlayerEntity player = Minecraft.getInstance().player; if (player != null) { - player.sendMessage(Lang.translate("schematics.uploadTooLarge").append(" (" + size / 1000 + " KB)."), player.getUniqueID()); - player.sendMessage(Lang.translate("schematics.maxAllowedSize").append(" " + maxSize + " KB"), player.getUniqueID()); + player.sendMessage(Lang.translate("schematics.uploadTooLarge").append(" (" + size / 1000 + " KB)."), player.getUUID()); + player.sendMessage(Lang.translate("schematics.maxAllowedSize").append(" " + maxSize + " KB"), player.getUUID()); } return false; } @@ -104,7 +104,7 @@ public class ClientSchematicLoader { if (status != -1) { if (status < maxPacketSize) data = Arrays.copyOf(data, status); - if (Minecraft.getInstance().world != null) + if (Minecraft.getInstance().level != null) AllPackets.channel.sendToServer(SchematicUploadPacket.write(schematic, data)); else { activeUploads.remove(schematic); diff --git a/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java b/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java index e4fa3f827..aa52f4374 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java +++ b/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java @@ -92,17 +92,17 @@ public class ItemRequirement { if (block == Blocks.AIR) return NONE; - Item item = BlockItem.BLOCK_TO_ITEM.getOrDefault(state.getBlock(), Items.AIR); + Item item = BlockItem.BY_BLOCK.getOrDefault(state.getBlock(), Items.AIR); // double slab needs two items - if (state.contains(BlockStateProperties.SLAB_TYPE) && state.get(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE) + if (state.hasProperty(BlockStateProperties.SLAB_TYPE) && state.getValue(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE) return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, 2))); if (block instanceof TurtleEggBlock) - return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.get(TurtleEggBlock.EGGS).intValue()))); + return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.getValue(TurtleEggBlock.EGGS).intValue()))); if (block instanceof SeaPickleBlock) - return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.get(SeaPickleBlock.PICKLES).intValue()))); + return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.getValue(SeaPickleBlock.PICKLES).intValue()))); if (block instanceof SnowBlock) - return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.get(SnowBlock.LAYERS).intValue()))); + return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.getValue(SnowBlock.LAYERS).intValue()))); if (block instanceof GrassPathBlock) return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(Items.GRASS_BLOCK))); if (block instanceof FarmlandBlock) @@ -120,7 +120,7 @@ public class ItemRequirement { if (type == EntityType.ITEM_FRAME) { ItemFrameEntity ife = (ItemFrameEntity) entity; ItemStack frame = new ItemStack(Items.ITEM_FRAME); - ItemStack displayedItem = ife.getDisplayedItem(); + ItemStack displayedItem = ife.getItem(); if (displayedItem.isEmpty()) return new ItemRequirement(ItemUseType.CONSUME, Items.ITEM_FRAME); return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(frame, displayedItem)); @@ -132,7 +132,7 @@ public class ItemRequirement { if (type == EntityType.ARMOR_STAND) { List requirements = new ArrayList<>(); ArmorStandEntity armorStandEntity = (ArmorStandEntity) entity; - armorStandEntity.getEquipmentAndArmor().forEach(requirements::add); + armorStandEntity.getAllSlots().forEach(requirements::add); requirements.add(new ItemStack(Items.ARMOR_STAND)); return new ItemRequirement(ItemUseType.CONSUME, requirements); } @@ -144,7 +144,7 @@ public class ItemRequirement { if (entity instanceof BoatEntity) { BoatEntity boatEntity = (BoatEntity) entity; - return new ItemRequirement(ItemUseType.CONSUME, boatEntity.getItemBoat().getItem()); + return new ItemRequirement(ItemUseType.CONSUME, boatEntity.getDropItem().getItem()); } if (type == EntityType.END_CRYSTAL) diff --git a/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java b/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java index 1619173b4..bcfd97955 100644 --- a/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java +++ b/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java @@ -83,15 +83,15 @@ public class MaterialChecklist { textComponent = new StringTextComponent("\n" + TextFormatting.RED); textComponent = textComponent.append(Lang.createTranslationTextComponent("materialChecklist.blocksNotLoaded")); - pages.add(StringNBT.of(ITextComponent.Serializer.toJson(textComponent))); + pages.add(StringNBT.valueOf(ITextComponent.Serializer.toJson(textComponent))); } List keys = new ArrayList<>(Sets.union(required.keySet(), damageRequired.keySet())); Collections.sort(keys, (item1, item2) -> { Locale locale = Locale.ENGLISH; - String name1 = new TranslationTextComponent(item1.getTranslationKey()).getString() + String name1 = new TranslationTextComponent(item1.getDescriptionId()).getString() .toLowerCase(locale); - String name2 = new TranslationTextComponent(item2.getTranslationKey()).getString() + String name2 = new TranslationTextComponent(item2.getDescriptionId()).getString() .toLowerCase(locale); return name1.compareTo(name2); }); @@ -110,8 +110,8 @@ public class MaterialChecklist { if (itemsWritten == MAX_ENTRIES_PER_PAGE) { itemsWritten = 0; - textComponent.append(new StringTextComponent("\n >>>").formatted(TextFormatting.BLUE)); - pages.add(StringNBT.of(ITextComponent.Serializer.toJson(textComponent))); + textComponent.append(new StringTextComponent("\n >>>").withStyle(TextFormatting.BLUE)); + pages.add(StringNBT.valueOf(ITextComponent.Serializer.toJson(textComponent))); textComponent = new StringTextComponent(""); } @@ -122,8 +122,8 @@ public class MaterialChecklist { for (Item item : completed) { if (itemsWritten == MAX_ENTRIES_PER_PAGE) { itemsWritten = 0; - textComponent.append(new StringTextComponent("\n >>>").formatted(TextFormatting.DARK_GREEN)); - pages.add(StringNBT.of(ITextComponent.Serializer.toJson(textComponent))); + textComponent.append(new StringTextComponent("\n >>>").withStyle(TextFormatting.DARK_GREEN)); + pages.add(StringNBT.valueOf(ITextComponent.Serializer.toJson(textComponent))); textComponent = new StringTextComponent(""); } @@ -131,7 +131,7 @@ public class MaterialChecklist { textComponent.append(entry(new ItemStack(item), getRequiredAmount(item), false)); } - pages.add(StringNBT.of(ITextComponent.Serializer.toJson(textComponent))); + pages.add(StringNBT.valueOf(ITextComponent.Serializer.toJson(textComponent))); tag.put("pages", pages); tag.putString("author", "Schematicannon"); @@ -139,7 +139,7 @@ public class MaterialChecklist { textComponent = Lang.createTranslationTextComponent("materialChecklist") .setStyle(Style.EMPTY.withColor(TextFormatting.BLUE) .withItalic(Boolean.FALSE)); - book.getOrCreateChildTag("display") + book.getOrCreateTagElement("display") .putString("Name", ITextComponent.Serializer.toJson(textComponent)); book.setTag(tag); @@ -156,13 +156,13 @@ public class MaterialChecklist { private ITextComponent entry(ItemStack item, int amount, boolean unfinished) { int stacks = amount / 64; int remainder = amount % 64; - IFormattableTextComponent tc = new TranslationTextComponent(item.getTranslationKey()); + IFormattableTextComponent tc = new TranslationTextComponent(item.getDescriptionId()); if (!unfinished) tc.append(" \u2714"); - tc.formatted(unfinished ? TextFormatting.BLUE : TextFormatting.DARK_GREEN); - return tc.append(new StringTextComponent("\n" + " x" + amount).formatted(TextFormatting.BLACK)) + tc.withStyle(unfinished ? TextFormatting.BLUE : TextFormatting.DARK_GREEN); + return tc.append(new StringTextComponent("\n" + " x" + amount).withStyle(TextFormatting.BLACK)) .append( - new StringTextComponent(" | " + stacks + "\u25A4 +" + remainder + "\n").formatted(TextFormatting.GRAY)); + new StringTextComponent(" | " + stacks + "\u25A4 +" + remainder + "\n").withStyle(TextFormatting.GRAY)); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java b/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java index cc4634615..99dd33f7a 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java @@ -80,9 +80,9 @@ public class SchematicPrinter { schematicAnchor = NBTUtil.readBlockPos(blueprint.getTag().getCompound("Anchor")); blockReader = new SchematicWorld(schematicAnchor, originalWorld); - activeTemplate.place(blockReader, schematicAnchor, settings, blockReader.getRandom()); + activeTemplate.placeInWorldChunk(blockReader, schematicAnchor, settings, blockReader.getRandom()); - StructureTransform transform = new StructureTransform(settings.getCenterOffset(), Direction.Axis.Y, + StructureTransform transform = new StructureTransform(settings.getRotationPivot(), Direction.Axis.Y, settings.getRotation(), settings.getMirror()); for (TileEntity te : blockReader.tileEntities.values()) { transform.apply(te); @@ -92,7 +92,7 @@ public class SchematicPrinter { printStage = PrintStage.BLOCKS; deferredBlocks.clear(); MutableBoundingBox bounds = blockReader.getBounds(); - currentPos = new BlockPos(bounds.minX - 1, bounds.minY, bounds.minZ); + currentPos = new BlockPos(bounds.x0 - 1, bounds.y0, bounds.z0); schematicLoaded = true; } @@ -113,7 +113,7 @@ public class SchematicPrinter { public BlockPos getCurrentTarget() { if (!isLoaded()) return null; - return schematicAnchor.add(currentPos); + return schematicAnchor.offset(currentPos); } public PrintStage getPrintStage() { @@ -148,7 +148,7 @@ public class SchematicPrinter { entityHandler.handle(target, entity); } else { BlockState blockState = BlockHelper.setZeroAge(blockReader.getBlockState(target)); - TileEntity tileEntity = blockReader.getTileEntity(target); + TileEntity tileEntity = blockReader.getBlockEntity(target); blockHandler.handle(target, blockState, tileEntity); } } @@ -173,28 +173,28 @@ public class SchematicPrinter { public boolean shouldPlaceBlock(World world, PlacementPredicate predicate, BlockPos pos) { BlockState state = BlockHelper.setZeroAge(blockReader.getBlockState(pos)); - TileEntity tileEntity = blockReader.getTileEntity(pos); + TileEntity tileEntity = blockReader.getBlockEntity(pos); BlockState toReplace = world.getBlockState(pos); BlockState toReplaceOther = null; - if (state.contains(BlockStateProperties.BED_PART) && state.contains(BlockStateProperties.HORIZONTAL_FACING) - && state.get(BlockStateProperties.BED_PART) == BedPart.FOOT) - toReplaceOther = world.getBlockState(pos.offset(state.get(BlockStateProperties.HORIZONTAL_FACING))); - if (state.contains(BlockStateProperties.DOUBLE_BLOCK_HALF) - && state.get(BlockStateProperties.DOUBLE_BLOCK_HALF) == DoubleBlockHalf.LOWER) - toReplaceOther = world.getBlockState(pos.up()); + if (state.hasProperty(BlockStateProperties.BED_PART) && state.hasProperty(BlockStateProperties.HORIZONTAL_FACING) + && state.getValue(BlockStateProperties.BED_PART) == BedPart.FOOT) + toReplaceOther = world.getBlockState(pos.relative(state.getValue(BlockStateProperties.HORIZONTAL_FACING))); + if (state.hasProperty(BlockStateProperties.DOUBLE_BLOCK_HALF) + && state.getValue(BlockStateProperties.DOUBLE_BLOCK_HALF) == DoubleBlockHalf.LOWER) + toReplaceOther = world.getBlockState(pos.above()); - if (!world.isBlockPresent(pos)) + if (!world.isLoaded(pos)) return false; - if (!world.getWorldBorder().contains(pos)) + if (!world.getWorldBorder().isWithinBounds(pos)) return false; if (toReplace == state) return false; - if (toReplace.getBlockHardness(world, pos) == -1 - || (toReplaceOther != null && toReplaceOther.getBlockHardness(world, pos) == -1)) + if (toReplace.getDestroySpeed(world, pos) == -1 + || (toReplaceOther != null && toReplaceOther.getDestroySpeed(world, pos) == -1)) return false; - boolean isNormalCube = state.isNormalCube(blockReader, currentPos); + boolean isNormalCube = state.isRedstoneConductor(blockReader, currentPos); return predicate.shouldPlace(pos, state, tileEntity, toReplace, toReplaceOther, isNormalCube); } @@ -206,18 +206,18 @@ public class SchematicPrinter { BlockPos target = getCurrentTarget(); BlockState blockState = BlockHelper.setZeroAge(blockReader.getBlockState(target)); - TileEntity tileEntity = blockReader.getTileEntity(target); + TileEntity tileEntity = blockReader.getBlockEntity(target); return ItemRequirement.of(blockState, tileEntity); } public int markAllBlockRequirements(MaterialChecklist checklist, World world, PlacementPredicate predicate) { int blocksToPlace = 0; for (BlockPos pos : blockReader.getAllPositions()) { - BlockPos relPos = pos.add(schematicAnchor); + BlockPos relPos = pos.offset(schematicAnchor); BlockState required = blockReader.getBlockState(relPos); - TileEntity requiredTE = blockReader.getTileEntity(relPos); + TileEntity requiredTE = blockReader.getBlockEntity(relPos); - if (!world.isAreaLoaded(pos.add(schematicAnchor), 0)) { + if (!world.isAreaLoaded(pos.offset(schematicAnchor), 0)) { checklist.warnBlockNotLoaded(); continue; } @@ -267,30 +267,30 @@ public class SchematicPrinter { if (printStage == PrintStage.ENTITIES) { if (printingEntityIndex + 1 < entities.size()) { printingEntityIndex++; - currentPos = entities.get(printingEntityIndex).getBlockPos().subtract(schematicAnchor); + currentPos = entities.get(printingEntityIndex).blockPosition().subtract(schematicAnchor); } else { // Reached end of printing return false; } } - } while (!blockReader.getBounds().isVecInside(currentPos)); + } while (!blockReader.getBounds().isInside(currentPos)); // More things available to print return true; } public boolean tryAdvanceCurrentPos() { - currentPos = currentPos.offset(Direction.EAST); + currentPos = currentPos.relative(Direction.EAST); MutableBoundingBox bounds = blockReader.getBounds(); - BlockPos posInBounds = currentPos.add(-bounds.minX, -bounds.minY, -bounds.minZ); + BlockPos posInBounds = currentPos.offset(-bounds.x0, -bounds.y0, -bounds.z0); - if (posInBounds.getX() > bounds.getXSize()) - currentPos = new BlockPos(bounds.minX, currentPos.getY(), currentPos.getZ() + 1).west(); - if (posInBounds.getZ() > bounds.getZSize()) - currentPos = new BlockPos(currentPos.getX(), currentPos.getY() + 1, bounds.minZ).west(); + if (posInBounds.getX() > bounds.getXSpan()) + currentPos = new BlockPos(bounds.x0, currentPos.getY(), currentPos.getZ() + 1).west(); + if (posInBounds.getZ() > bounds.getZSpan()) + currentPos = new BlockPos(currentPos.getX(), currentPos.getY() + 1, bounds.z0).west(); // End of blocks reached - if (currentPos.getY() > bounds.getYSize()) { + if (currentPos.getY() > bounds.getYSpan()) { printStage = PrintStage.DEFERRED_BLOCKS; return false; } diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicProcessor.java b/src/main/java/com/simibubi/create/content/schematics/SchematicProcessor.java index 110444475..7539d6108 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicProcessor.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicProcessor.java @@ -51,10 +51,10 @@ public class SchematicProcessor extends StructureProcessor { @Override public Template.EntityInfo processEntity(IWorldReader world, BlockPos pos, Template.EntityInfo rawInfo, Template.EntityInfo info, PlacementSettings settings, Template template) { - return EntityType.readEntityType(info.nbt).flatMap(type -> { + return EntityType.by(info.nbt).flatMap(type -> { if (world instanceof World) { Entity e = type.create((World) world); - if (e != null && !e.ignoreItemEntityData()) { + if (e != null && !e.onlyOpCanSetNbt()) { return Optional.of(info); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java index 58df85ed1..c06e3e938 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java @@ -67,13 +67,13 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } @Override - public boolean addEntity(Entity entityIn) { + public boolean addFreshEntity(Entity entityIn) { if (entityIn instanceof ItemFrameEntity) - ((ItemFrameEntity) entityIn).getDisplayedItem() + ((ItemFrameEntity) entityIn).getItem() .setTag(null); if (entityIn instanceof ArmorStandEntity) { ArmorStandEntity armorStandEntity = (ArmorStandEntity) entityIn; - armorStandEntity.getEquipmentAndArmor() + armorStandEntity.getAllSlots() .forEach(stack -> stack.setTag(null)); } @@ -85,7 +85,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } @Override - public TileEntity getTileEntity(BlockPos pos) { + public TileEntity getBlockEntity(BlockPos pos) { if (isOutsideBuildHeight(pos)) return null; if (tileEntities.containsKey(pos)) @@ -111,18 +111,18 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } protected void onTEadded(TileEntity tileEntity, BlockPos pos) { - tileEntity.setLocation(this, pos); + tileEntity.setLevelAndPosition(this, pos); } @Override public BlockState getBlockState(BlockPos globalPos) { BlockPos pos = globalPos.subtract(anchor); - if (pos.getY() - bounds.minY == -1 && !renderMode) - return Blocks.GRASS_BLOCK.getDefaultState(); - if (getBounds().isVecInside(pos) && blocks.containsKey(pos)) + if (pos.getY() - bounds.y0 == -1 && !renderMode) + return Blocks.GRASS_BLOCK.defaultBlockState(); + if (getBounds().isInside(pos) && blocks.containsKey(pos)) return processBlockStateForPrinting(blocks.get(pos)); - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } public Map getBlockMap() { @@ -140,62 +140,62 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } @Override - public int getLightLevel(LightType p_226658_1_, BlockPos p_226658_2_) { + public int getBrightness(LightType p_226658_1_, BlockPos p_226658_2_) { return 10; } @Override - public List getEntitiesInAABBexcluding(Entity arg0, AxisAlignedBB arg1, Predicate arg2) { + public List getEntities(Entity arg0, AxisAlignedBB arg1, Predicate arg2) { return Collections.emptyList(); } @Override - public List getEntitiesWithinAABB(Class arg0, AxisAlignedBB arg1, + public List getEntitiesOfClass(Class arg0, AxisAlignedBB arg1, Predicate arg2) { return Collections.emptyList(); } @Override - public List getPlayers() { + public List players() { return Collections.emptyList(); } @Override - public int getSkylightSubtracted() { + public int getSkyDarken() { return 0; } @Override - public boolean hasBlockState(BlockPos pos, Predicate predicate) { + public boolean isStateAtPosition(BlockPos pos, Predicate predicate) { return predicate.test(getBlockState(pos)); } @Override public boolean destroyBlock(BlockPos arg0, boolean arg1) { - return setBlockState(arg0, Blocks.AIR.getDefaultState(), 3); + return setBlock(arg0, Blocks.AIR.defaultBlockState(), 3); } @Override public boolean removeBlock(BlockPos arg0, boolean arg1) { - return setBlockState(arg0, Blocks.AIR.getDefaultState(), 3); + return setBlock(arg0, Blocks.AIR.defaultBlockState(), 3); } @Override - public boolean setBlockState(BlockPos pos, BlockState arg1, int arg2) { - pos = pos.toImmutable() + public boolean setBlock(BlockPos pos, BlockState arg1, int arg2) { + pos = pos.immutable() .subtract(anchor); - bounds.expandTo(new MutableBoundingBox(pos, pos)); + bounds.expand(new MutableBoundingBox(pos, pos)); blocks.put(pos, arg1); if (tileEntities.containsKey(pos)) { TileEntity tileEntity = tileEntities.get(pos); if (!tileEntity.getType() - .isValidBlock(arg1.getBlock())) { + .isValid(arg1.getBlock())) { tileEntities.remove(pos); renderedTileEntities.remove(tileEntity); } } - TileEntity tileEntity = getTileEntity(pos); + TileEntity tileEntity = getBlockEntity(pos); if (tileEntity != null) tileEntities.put(pos, tileEntity); @@ -203,16 +203,16 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } @Override - public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { } + public void sendBlockUpdated(BlockPos pos, BlockState oldState, BlockState newState, int flags) { } @Override - public ITickList getPendingBlockTicks() { - return EmptyTickList.get(); + public ITickList getBlockTicks() { + return EmptyTickList.empty(); } @Override - public ITickList getPendingFluidTicks() { - return EmptyTickList.get(); + public ITickList getLiquidTicks() { + return EmptyTickList.empty(); } public MutableBoundingBox getBounds() { @@ -224,13 +224,13 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } protected BlockState processBlockStateForPrinting(BlockState state) { - if (state.getBlock() instanceof AbstractFurnaceBlock && state.contains(BlockStateProperties.LIT)) - state = state.with(BlockStateProperties.LIT, false); + if (state.getBlock() instanceof AbstractFurnaceBlock && state.hasProperty(BlockStateProperties.LIT)) + state = state.setValue(BlockStateProperties.LIT, false); return state; } @Override - public ServerWorld getWorld() { + public ServerWorld getLevel() { if (this.world instanceof ServerWorld) { return (ServerWorld) this.world; } diff --git a/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java b/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java index 151fdaf08..9c1b40ea1 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java +++ b/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java @@ -116,7 +116,7 @@ public class ServerSchematicLoader { try { // Validate Referenced Block - SchematicTableTileEntity table = getTable(player.getEntityWorld(), pos); + SchematicTableTileEntity table = getTable(player.getCommandSenderWorld(), pos); if (table == null) return; @@ -142,7 +142,7 @@ public class ServerSchematicLoader { // Open Stream OutputStream writer = Files.newOutputStream(uploadPath); - activeUploads.put(playerSchematicId, new SchematicUploadEntry(writer, size, player.getServerWorld(), pos)); + activeUploads.put(playerSchematicId, new SchematicUploadEntry(writer, size, player.getLevel(), pos)); // Notify Tile Entity table.startUpload(schematic); @@ -157,9 +157,9 @@ public class ServerSchematicLoader { Integer maxFileSize = getConfig().maxTotalSchematicSize.get(); if (size > maxFileSize * 1000) { player.sendMessage(new TranslationTextComponent("create.schematics.uploadTooLarge") - .append(new StringTextComponent(" (" + size / 1000 + " KB).")), player.getUniqueID()); + .append(new StringTextComponent(" (" + size / 1000 + " KB).")), player.getUUID()); player.sendMessage(new TranslationTextComponent("create.schematics.maxAllowedSize") - .append(new StringTextComponent(" " + maxFileSize + " KB")), player.getUniqueID()); + .append(new StringTextComponent(" " + maxFileSize + " KB")), player.getUUID()); return false; } return true; @@ -232,7 +232,7 @@ public class ServerSchematicLoader { } public SchematicTableTileEntity getTable(World world, BlockPos pos) { - TileEntity te = world.getTileEntity(pos); + TileEntity te = world.getBlockEntity(pos); if (!(te instanceof SchematicTableTileEntity)) return null; SchematicTableTileEntity table = (SchematicTableTileEntity) te; @@ -291,7 +291,7 @@ public class ServerSchematicLoader { } // Not holding S&Q - if (!AllItems.SCHEMATIC_AND_QUILL.isIn(player.getHeldItemMainhand())) + if (!AllItems.SCHEMATIC_AND_QUILL.isIn(player.getMainHandItem())) return; try { @@ -315,12 +315,12 @@ public class ServerSchematicLoader { } Template t = new Template(); - t.takeBlocksFromWorld(world, pos, bounds, true, Blocks.AIR); + t.fillFromWorld(world, pos, bounds, true, Blocks.AIR); try (OutputStream outputStream = Files.newOutputStream(path)) { - CompoundNBT nbttagcompound = t.writeToNBT(new CompoundNBT()); + CompoundNBT nbttagcompound = t.save(new CompoundNBT()); CompressedStreamTools.writeCompressed(nbttagcompound, outputStream); - player.setHeldItem(Hand.MAIN_HAND, SchematicItem.create(schematic, player.getGameProfile().getName())); + player.setItemInHand(Hand.MAIN_HAND, SchematicItem.create(schematic, player.getGameProfile().getName())); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java b/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java index 1e123ebfb..d542734bd 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java @@ -33,7 +33,7 @@ public abstract class LaunchedItem { } private static int ticksForDistance(BlockPos start, BlockPos target) { - return (int) (Math.max(10, MathHelper.sqrt(MathHelper.sqrt(target.distanceSq(start))) * 4f)); + return (int) (Math.max(10, MathHelper.sqrt(MathHelper.sqrt(target.distSqr(start))) * 4f)); } LaunchedItem() {} @@ -50,7 +50,7 @@ public abstract class LaunchedItem { ticksRemaining--; return false; } - if (world.isRemote) + if (world.isClientSide) return false; place(world); @@ -79,7 +79,7 @@ public abstract class LaunchedItem { target = NBTUtil.readBlockPos(c.getCompound("Target")); ticksRemaining = c.getInt("TicksLeft"); totalTicks = c.getInt("TotalTicks"); - stack = ItemStack.read(c.getCompound("Stack")); + stack = ItemStack.of(c.getCompound("Stack")); } public static class ForBlockState extends LaunchedItem { @@ -150,13 +150,13 @@ public abstract class LaunchedItem { @Override void place(World world) { // todo place belt - boolean isStart = state.get(BeltBlock.PART) == BeltPart.START; + boolean isStart = state.getValue(BeltBlock.PART) == BeltPart.START; BlockPos offset = BeltBlock.nextSegmentPosition(state, BlockPos.ZERO, isStart); int i = length - 1; - Axis axis = state.get(BeltBlock.HORIZONTAL_FACING).rotateY().getAxis(); - world.setBlockState(target, AllBlocks.SHAFT.getDefaultState().with(AbstractShaftBlock.AXIS, axis)); + Axis axis = state.getValue(BeltBlock.HORIZONTAL_FACING).getClockWise().getAxis(); + world.setBlockAndUpdate(target, AllBlocks.SHAFT.getDefaultState().setValue(AbstractShaftBlock.AXIS, axis)); BeltConnectorItem - .createBelts(world, target, target.add(offset.getX() * i, offset.getY() * i, offset.getZ() * i)); + .createBelts(world, target, target.offset(offset.getX() * i, offset.getY() * i, offset.getZ() * i)); } } @@ -176,7 +176,7 @@ public abstract class LaunchedItem { public boolean update(World world) { if (deferredTag != null && entity == null) { try { - Optional loadEntityUnchecked = EntityType.loadEntityUnchecked(deferredTag, world); + Optional loadEntityUnchecked = EntityType.create(deferredTag, world); if (!loadEntityUnchecked.isPresent()) return true; entity = loadEntityUnchecked.get(); @@ -205,7 +205,7 @@ public abstract class LaunchedItem { @Override void place(World world) { - world.addEntity(entity); + world.addFreshEntity(entity); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableBlock.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableBlock.java index 1640a46b0..3b20bce84 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableBlock.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableBlock.java @@ -25,6 +25,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraft.block.AbstractBlock.Properties; + public class SchematicTableBlock extends HorizontalBlock implements ITE { public SchematicTableBlock(Properties properties) { @@ -32,19 +34,19 @@ public class SchematicTableBlock extends HorizontalBlock implements ITE builder) { - builder.add(HORIZONTAL_FACING); - super.fillStateContainer(builder); + protected void createBlockStateDefinition(Builder builder) { + builder.add(FACING); + super.createBlockStateDefinition(builder); } @Override - public PushReaction getPushReaction(BlockState state) { + public PushReaction getPistonPushReaction(BlockState state) { return PushReaction.BLOCK; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); + return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); } @Override @@ -55,7 +57,7 @@ public class SchematicTableBlock extends HorizontalBlock implements ITE ItemHelper.dropContents(worldIn, pos, te.inventory)); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } @Override @@ -94,7 +96,7 @@ public class SchematicTableBlock extends HorizontalBlock implements ITE type, int id, PlayerInventory inv, PacketBuffer extraData) { super(type, id); player = inv.player; - ClientWorld world = Minecraft.getInstance().world; - TileEntity tileEntity = world.getTileEntity(extraData.readBlockPos()); + ClientWorld world = Minecraft.getInstance().level; + TileEntity tileEntity = world.getBlockEntity(extraData.readBlockPos()); if (tileEntity instanceof SchematicTableTileEntity) { this.te = (SchematicTableTileEntity) tileEntity; - this.te.handleUpdateTag(te.getBlockState(), extraData.readCompoundTag()); + this.te.handleUpdateTag(te.getBlockState(), extraData.readNbt()); init(); } } @@ -48,7 +48,7 @@ public class SchematicTableContainer extends Container { protected void init() { inputSlot = new SlotItemHandler(te.inventory, 0, 21, 57) { @Override - public boolean isItemValid(ItemStack stack) { + public boolean mayPlace(ItemStack stack) { return AllItems.EMPTY_SCHEMATIC.isIn(stack) || AllItems.SCHEMATIC_AND_QUILL.isIn(stack) || AllItems.SCHEMATIC.isIn(stack); } @@ -56,7 +56,7 @@ public class SchematicTableContainer extends Container { outputSlot = new SlotItemHandler(te.inventory, 1, 166, 57) { @Override - public boolean isItemValid(ItemStack stack) { + public boolean mayPlace(ItemStack stack) { return false; } }; @@ -75,29 +75,29 @@ public class SchematicTableContainer extends Container { this.addSlot(new Slot(player.inventory, hotbarSlot, 38 + hotbarSlot * 18, 163)); } - detectAndSendChanges(); + broadcastChanges(); } public boolean canWrite() { - return inputSlot.getHasStack() && !outputSlot.getHasStack(); + return inputSlot.hasItem() && !outputSlot.hasItem(); } @Override - public boolean canInteractWith(PlayerEntity player) { + public boolean stillValid(PlayerEntity player) { return te != null && te.canPlayerUse(player); } @Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { Slot clickedSlot = getSlot(index); - if (!clickedSlot.getHasStack()) + if (!clickedSlot.hasItem()) return ItemStack.EMPTY; - ItemStack stack = clickedSlot.getStack(); + ItemStack stack = clickedSlot.getItem(); if (index < 2) - mergeItemStack(stack, 2, inventorySlots.size(), false); + moveItemStackTo(stack, 2, slots.size(), false); else - mergeItemStack(stack, 0, 1, false); + moveItemStackTo(stack, 0, 1, false); return ItemStack.EMPTY; } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java index 658c99f78..deac70f34 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java @@ -70,15 +70,15 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = CreateClient.SCHEMATIC_SENDER.getAvailableSchematics(); - int x = guiLeft; - int y = guiTop; + int x = leftPos; + int y = topPos; schematicsLabel = new Label(x + 49, y + 26, StringTextComponent.EMPTY).withShadow(); schematicsLabel.text = StringTextComponent.EMPTY; if (!availableSchematics.isEmpty()) { schematicsArea = new SelectionScrollInput(x + 45, y + 21, 139, 18).forOptions(availableSchematics) - .titled(availableSchematicsTitle.copy()) + .titled(availableSchematicsTitle.plainCopy()) .writingTo(schematicsLabel); widgets.add(schematicsArea); widgets.add(schematicsLabel); @@ -97,33 +97,33 @@ public class SchematicTableScreen extends AbstractSimiContainerScreenat(x + background.width, y + background.height - 40, -200) @@ -135,29 +135,29 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = schematicSender.getAvailableSchematics(); ITextComponent schematic = availableSchematics.get(schematicsArea.getState()); - schematicSender.startNewUpload(schematic.getUnformattedComponentText()); + schematicSender.startNewUpload(schematic.getContents()); } if (folderButton.isHovered()) { - Util.getOSType() + Util.getPlatform() .openFile(Paths.get("schematics/") .toFile()); } @@ -202,9 +202,9 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen { public SchematicannonBlock(Properties properties) { @@ -38,7 +40,7 @@ public class SchematicannonBlock extends Block implements ITE NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer)); @@ -58,12 +60,12 @@ public class SchematicannonBlock extends Block implements ITE ItemHelper.dropContents(worldIn, pos, te.inventory)); - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } @Override diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonContainer.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonContainer.java index f3dee8ab1..d58a88a24 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonContainer.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonContainer.java @@ -22,11 +22,11 @@ public class SchematicannonContainer extends Container { public SchematicannonContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer buffer) { super(type, id); player = inv.player; - ClientWorld world = Minecraft.getInstance().world; - TileEntity tileEntity = world.getTileEntity(buffer.readBlockPos()); + ClientWorld world = Minecraft.getInstance().level; + TileEntity tileEntity = world.getBlockEntity(buffer.readBlockPos()); if (tileEntity instanceof SchematicannonTileEntity) { this.te = (SchematicannonTileEntity) tileEntity; - this.te.handleUpdateTag(te.getBlockState(), buffer.readCompoundTag()); + this.te.handleUpdateTag(te.getBlockState(), buffer.readNbt()); init(); } } @@ -62,17 +62,17 @@ public class SchematicannonContainer extends Container { for (int hotbarSlot = 0; hotbarSlot < 9; ++hotbarSlot) addSlot(new Slot(player.inventory, hotbarSlot, invX + hotbarSlot * 18, invY + 58)); - detectAndSendChanges(); + broadcastChanges(); } @Override - public boolean canInteractWith(PlayerEntity player) { + public boolean stillValid(PlayerEntity player) { return te != null && te.canPlayerUse(player); } @Override - public void onContainerClosed(PlayerEntity playerIn) { - super.onContainerClosed(playerIn); + public void removed(PlayerEntity playerIn) { + super.removed(playerIn); } public SchematicannonTileEntity getTileEntity() { @@ -80,17 +80,17 @@ public class SchematicannonContainer extends Container { } @Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { Slot clickedSlot = getSlot(index); - if (!clickedSlot.getHasStack()) + if (!clickedSlot.hasItem()) return ItemStack.EMPTY; - ItemStack stack = clickedSlot.getStack(); + ItemStack stack = clickedSlot.getItem(); if (index < 5) { - mergeItemStack(stack, 5, inventorySlots.size(), false); + moveItemStackTo(stack, 5, slots.size(), false); } else { - if (mergeItemStack(stack, 0, 1, false) || mergeItemStack(stack, 2, 3, false) - || mergeItemStack(stack, 4, 5, false)) + if (moveItemStackTo(stack, 0, 1, false) || moveItemStackTo(stack, 2, 3, false) + || moveItemStackTo(stack, 4, 5, false)) ; } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java index 98db7d37b..74903d25c 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java @@ -44,12 +44,12 @@ public class SchematicannonInstance extends TileEntityInstance(4); @@ -168,7 +168,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen tip = button.getToolTip(); - tip.add((enabled ? optionEnabled : optionDisabled).copy().formatted(BLUE)); + tip.add((enabled ? optionEnabled : optionDisabled).plainCopy().withStyle(BLUE)); tip.addAll(TooltipHelper.cutTextComponent(Lang.translate("gui.schematicannon.option." + tooltipKey + ".description"), GRAY, GRAY)); } @@ -248,16 +248,16 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen= fuelX && mouseY >= fuelY && mouseX <= fuelX + AllGuiTextures.SCHEMATICANNON_FUEL.width && mouseY <= fuelY + AllGuiTextures.SCHEMATICANNON_FUEL.height) { List tooltip = getFuelLevelTooltip(te); - renderTooltip(matrixStack, tooltip, mouseX, mouseY); + renderComponentTooltip(matrixStack, tooltip, mouseX, mouseY); } - if (hoveredSlot != null && !hoveredSlot.getHasStack()) { - if (hoveredSlot.slotNumber == 0) - renderTooltip(matrixStack, + if (hoveredSlot != null && !hoveredSlot.hasItem()) { + if (hoveredSlot.index == 0) + renderComponentTooltip(matrixStack, TooltipHelper.cutTextComponent(Lang.translate(_slotSchematic), GRAY, TextFormatting.BLUE), mouseX, mouseY); - if (hoveredSlot.slotNumber == 2) - renderTooltip(matrixStack, + if (hoveredSlot.index == 2) + renderComponentTooltip(matrixStack, TooltipHelper.cutTextComponent(Lang.translate(_slotListPrinter), GRAY, TextFormatting.BLUE), mouseX, mouseY); - if (hoveredSlot.slotNumber == 4) - renderTooltip(matrixStack, + if (hoveredSlot.index == 4) + renderComponentTooltip(matrixStack, TooltipHelper.cutTextComponent(Lang.translate(_slotGunpowder), GRAY, TextFormatting.BLUE), mouseX, mouseY); } @@ -371,15 +371,15 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen tileEntityTypeIn) { @@ -141,13 +142,13 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC attachedInventories.clear(); for (Direction facing : Iterate.directions) { - if (!world.isBlockPresent(pos.offset(facing))) + if (!level.isLoaded(worldPosition.relative(facing))) continue; - if (AllBlocks.CREATIVE_CRATE.has(world.getBlockState(pos.offset(facing)))) + if (AllBlocks.CREATIVE_CRATE.has(level.getBlockState(worldPosition.relative(facing)))) hasCreativeCrate = true; - TileEntity tileEntity = world.getTileEntity(pos.offset(facing)); + TileEntity tileEntity = level.getBlockEntity(worldPosition.relative(facing)); if (tileEntity != null) { LazyOptional capability = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); @@ -175,7 +176,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC missingItem = null; if (compound.contains("MissingItem")) - missingItem = ItemStack.read(compound.getCompound("MissingItem")); + missingItem = ItemStack.of(compound.getCompound("MissingItem")); // Settings CompoundNBT options = compound.getCompound("Options"); @@ -205,7 +206,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC BlockPos readBlockPos = launched.target; // Always write to Server tile - if (world == null || !world.isRemote) { + if (level == null || !level.isClientSide) { flyingBlocks.add(launched); continue; } @@ -281,7 +282,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC previousTarget = printer.getCurrentTarget(); tickFlyingBlocks(); - if (world.isRemote) + if (level.isClientSide) return; // Update Fuel and Paper @@ -302,7 +303,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC // Update Client Tile if (sendUpdate) { sendUpdate = false; - world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 6); + level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 6); } } @@ -369,7 +370,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } // Check block - if (!getWorld().isAreaLoaded(printer.getCurrentTarget(), 0)) { + if (!getLevel().isAreaLoaded(printer.getCurrentTarget(), 0)) { positionNotLoaded = true; statusMsg = "targetNotLoaded"; state = State.PAUSED; @@ -383,7 +384,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC // Get item requirement ItemRequirement requirement = printer.getCurrentRequirement(); - if (requirement.isInvalid() || !printer.shouldPlaceCurrent(world, this::shouldPlace)) { + if (requirement.isInvalid() || !printer.shouldPlaceCurrent(level, this::shouldPlace)) { statusMsg = "searching"; blockSkipped = true; return; @@ -455,7 +456,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } // Load blocks into reader - printer.loadSchematic(blueprint, world, true); + printer.loadSchematic(blueprint, level, true); if (printer.isWorldEmpty()) { state = State.STOPPED; @@ -466,7 +467,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC return; } - if (!printer.getAnchor().withinDistance(getPos(), MAX_ANCHOR_DISTANCE)) { + if (!printer.getAnchor().closerThan(getBlockPos(), MAX_ANCHOR_DISTANCE)) { state = State.STOPPED; statusMsg = "targetOutsideRange"; printer.resetSchematic(); @@ -481,7 +482,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } protected ItemStack getItemForBlock(BlockState blockState) { - Item item = BlockItem.BLOCK_TO_ITEM.getOrDefault(blockState.getBlock(), Items.AIR); + Item item = BlockItem.BY_BLOCK.getOrDefault(blockState.getBlock(), Items.AIR); return item == Items.AIR ? ItemStack.EMPTY : new ItemStack(item); } @@ -499,13 +500,13 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC ItemStack extractItem = iItemHandler.extractItem(slot, 1, true); if (!ItemRequirement.validate(required, extractItem)) continue; - if (!extractItem.isDamageable()) + if (!extractItem.isDamageableItem()) continue; if (!simulate) { ItemStack stack = iItemHandler.extractItem(slot, 1, false); - stack.setDamage(stack.getDamage() + 1); - if (stack.getDamage() <= stack.getMaxDamage()) { + stack.setDamageValue(stack.getDamageValue() + 1); + if (stack.getDamageValue() <= stack.getMaxDamage()) { if (iItemHandler.getStackInSlot(slot) .isEmpty()) iItemHandler.insertItem(slot, stack, false); @@ -562,7 +563,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC state = State.STOPPED; statusMsg = "finished"; resetPrinter(); - AllSoundEvents.SCHEMATICANNON_FINISH.playOnServer(world, pos); + AllSoundEvents.SCHEMATICANNON_FINISH.playOnServer(level, worldPosition); sendUpdate = true; } @@ -577,7 +578,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC protected boolean shouldPlace(BlockPos pos, BlockState state, TileEntity te, BlockState toReplace, BlockState toReplaceOther, boolean isNormalCube) { - if (pos.withinDistance(getPos(), 2f)) + if (pos.closerThan(getBlockPos(), 2f)) return false; if (!replaceTileEntities && (toReplace.hasTileEntity() || (toReplaceOther != null && toReplaceOther.hasTileEntity()))) @@ -586,19 +587,19 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC if (shouldIgnoreBlockState(state, te)) return false; - boolean placingAir = state.getBlock().isAir(state, world, pos); + boolean placingAir = state.getBlock().isAir(state, level, pos); if (replaceMode == 3) return true; if (replaceMode == 2 && !placingAir) return true; if (replaceMode == 1 - && (isNormalCube || (!toReplace.isNormalCube(world, pos) - && (toReplaceOther == null || !toReplaceOther.isNormalCube(world, pos)))) + && (isNormalCube || (!toReplace.isRedstoneConductor(level, pos) + && (toReplaceOther == null || !toReplaceOther.isRedstoneConductor(level, pos)))) && !placingAir) return true; - if (replaceMode == 0 && !toReplace.isNormalCube(world, pos) - && (toReplaceOther == null || !toReplaceOther.isNormalCube(world, pos)) && !placingAir) + if (replaceMode == 0 && !toReplace.isRedstoneConductor(level, pos) + && (toReplaceOther == null || !toReplaceOther.isRedstoneConductor(level, pos)) && !placingAir) return true; return false; @@ -616,10 +617,10 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC return false; // Block doesnt need to be placed twice (Doors, beds, double plants) - if (state.contains(BlockStateProperties.DOUBLE_BLOCK_HALF) - && state.get(BlockStateProperties.DOUBLE_BLOCK_HALF) == DoubleBlockHalf.UPPER) + if (state.hasProperty(BlockStateProperties.DOUBLE_BLOCK_HALF) + && state.getValue(BlockStateProperties.DOUBLE_BLOCK_HALF) == DoubleBlockHalf.UPPER) return true; - if (state.contains(BlockStateProperties.BED_PART) && state.get(BlockStateProperties.BED_PART) == BedPart.HEAD) + if (state.hasProperty(BlockStateProperties.BED_PART) && state.getValue(BlockStateProperties.BED_PART) == BedPart.HEAD) return true; if (state.getBlock() instanceof PistonHeadBlock) return true; @@ -630,7 +631,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC protected void tickFlyingBlocks() { List toRemove = new LinkedList<>(); for (LaunchedItem b : flyingBlocks) - if (b.update(world)) + if (b.update(level)) toRemove.add(b); flyingBlocks.removeAll(toRemove); } @@ -699,11 +700,11 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC public static BlockState stripBeltIfNotLast(BlockState blockState) { // is highest belt? boolean isLastSegment = false; - Direction facing = blockState.get(BeltBlock.HORIZONTAL_FACING); - BeltSlope slope = blockState.get(BeltBlock.SLOPE); + Direction facing = blockState.getValue(BeltBlock.HORIZONTAL_FACING); + BeltSlope slope = blockState.getValue(BeltBlock.SLOPE); boolean positive = facing.getAxisDirection() == AxisDirection.POSITIVE; - boolean start = blockState.get(BeltBlock.PART) == BeltPart.START; - boolean end = blockState.get(BeltBlock.PART) == BeltPart.END; + boolean start = blockState.getValue(BeltBlock.PART) == BeltPart.START; + boolean end = blockState.getValue(BeltBlock.PART) == BeltPart.END; switch (slope) { case DOWNWARD: @@ -718,9 +719,9 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC isLastSegment = positive && end || !positive && start; } if (!isLastSegment) - blockState = (blockState.get(BeltBlock.PART) == BeltPart.MIDDLE) ? Blocks.AIR.getDefaultState() + blockState = (blockState.getValue(BeltBlock.PART) == BeltPart.MIDDLE) ? Blocks.AIR.defaultBlockState() : AllBlocks.SHAFT.getDefaultState() - .with(AbstractShaftBlock.AXIS, facing.rotateY() + .setValue(AbstractShaftBlock.AXIS, facing.getClockWise() .getAxis()); return blockState; } @@ -736,7 +737,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC CompoundNBT data = null; if (tile != null) { if (AllBlockTags.SAFE_NBT.matches(blockState)) { - data = tile.write(new CompoundNBT()); + data = tile.save(new CompoundNBT()); data = NBTProcessors.process(tile, data, true); } else if (tile instanceof IPartialSafeNBT) { data = new CompoundNBT(); @@ -751,30 +752,30 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC protected void launchBelt(BlockPos target, BlockState state, int length) { blocksPlaced++; ItemStack connector = AllItems.BELT_CONNECTOR.asStack(); - flyingBlocks.add(new LaunchedItem.ForBelt(this.getPos(), target, connector, state, length)); + flyingBlocks.add(new LaunchedItem.ForBelt(this.getBlockPos(), target, connector, state, length)); playFiringSound(); } protected void launchBlock(BlockPos target, ItemStack stack, BlockState state, @Nullable CompoundNBT data) { - if (!state.getBlock().isAir(state, world, target)) + if (!state.getBlock().isAir(state, level, target)) blocksPlaced++; - flyingBlocks.add(new LaunchedItem.ForBlockState(this.getPos(), target, stack, state, data)); + flyingBlocks.add(new LaunchedItem.ForBlockState(this.getBlockPos(), target, stack, state, data)); playFiringSound(); } protected void launchEntity(BlockPos target, ItemStack stack, Entity entity) { blocksPlaced++; - flyingBlocks.add(new LaunchedItem.ForEntity(this.getPos(), target, stack, entity)); + flyingBlocks.add(new LaunchedItem.ForEntity(this.getBlockPos(), target, stack, entity)); playFiringSound(); } public void playFiringSound() { - AllSoundEvents.SCHEMATICANNON_LAUNCH_BLOCK.playOnServer(world, pos); + AllSoundEvents.SCHEMATICANNON_LAUNCH_BLOCK.playOnServer(level, worldPosition); } public void sendToContainer(PacketBuffer buffer) { - buffer.writeBlockPos(getPos()); - buffer.writeCompoundTag(getUpdateTag()); + buffer.writeBlockPos(getBlockPos()); + buffer.writeNbt(getUpdateTag()); } @Override @@ -794,7 +795,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC if (printer.isLoaded()) { blocksToPlace = blocksPlaced; - blocksToPlace += printer.markAllBlockRequirements(checklist, world, this::shouldPlace); + blocksToPlace += printer.markAllBlockRequirements(checklist, level, this::shouldPlace); printer.markAllEntityRequirements(checklist); } checklist.gathered.clear(); @@ -827,4 +828,6 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC public boolean shouldRenderNormally() { return true; } + + } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java index af0624b67..02243a42d 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java @@ -67,9 +67,9 @@ public class SchematicAndQuillHandler { return true; AxisAlignedBB bb = new AxisAlignedBB(firstPos, secondPos); - Vector3i vec = selectedFace.getDirectionVec(); - Vector3d projectedView = Minecraft.getInstance().gameRenderer.getActiveRenderInfo() - .getProjectedView(); + Vector3i vec = selectedFace.getNormal(); + Vector3d projectedView = Minecraft.getInstance().gameRenderer.getMainCamera() + .getPosition(); if (bb.contains(projectedView)) delta *= -1; @@ -79,17 +79,17 @@ public class SchematicAndQuillHandler { AxisDirection axisDirection = selectedFace.getAxisDirection(); if (axisDirection == AxisDirection.NEGATIVE) - bb = bb.offset(-x, -y, -z); + bb = bb.move(-x, -y, -z); - double maxX = Math.max(bb.maxX - x * axisDirection.getOffset(), bb.minX); - double maxY = Math.max(bb.maxY - y * axisDirection.getOffset(), bb.minY); - double maxZ = Math.max(bb.maxZ - z * axisDirection.getOffset(), bb.minZ); + double maxX = Math.max(bb.maxX - x * axisDirection.getStep(), bb.minX); + double maxY = Math.max(bb.maxY - y * axisDirection.getStep(), bb.minY); + double maxZ = Math.max(bb.maxZ - z * axisDirection.getStep(), bb.minZ); bb = new AxisAlignedBB(bb.minX, bb.minY, bb.minZ, maxX, maxY, maxZ); firstPos = new BlockPos(bb.minX, bb.minY, bb.minZ); secondPos = new BlockPos(bb.maxX, bb.maxY, bb.maxZ); - Lang.sendStatus(Minecraft.getInstance().player, "schematicAndQuill.dimensions", (int) bb.getXSize() + 1, - (int) bb.getYSize() + 1, (int) bb.getZSize() + 1); + Lang.sendStatus(Minecraft.getInstance().player, "schematicAndQuill.dimensions", (int) bb.getXsize() + 1, + (int) bb.getYsize() + 1, (int) bb.getZsize() + 1); return true; } @@ -102,7 +102,7 @@ public class SchematicAndQuillHandler { ClientPlayerEntity player = Minecraft.getInstance().player; - if (player.isSneaking()) { + if (player.isShiftKeyDown()) { discard(); return; } @@ -142,21 +142,21 @@ public class SchematicAndQuillHandler { if (AllKeys.ACTIVATE_TOOL.isPressed()) { float pt = AnimationTickHolder.getPartialTicks(); Vector3d targetVec = player.getEyePosition(pt) - .add(player.getLookVec() + .add(player.getLookAngle() .scale(range)); selectedPos = new BlockPos(targetVec); } else { - BlockRayTraceResult trace = RaycastHelper.rayTraceRange(player.world, player, 75); + BlockRayTraceResult trace = RaycastHelper.rayTraceRange(player.level, player, 75); if (trace != null && trace.getType() == Type.BLOCK) { - BlockPos hit = trace.getPos(); - boolean replaceable = player.world.getBlockState(hit) - .isReplaceable(new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, trace))); - if (trace.getFace() + BlockPos hit = trace.getBlockPos(); + boolean replaceable = player.level.getBlockState(hit) + .canBeReplaced(new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, trace))); + if (trace.getDirection() .getAxis() .isVertical() && !replaceable) - hit = hit.offset(trace.getFace()); + hit = hit.relative(trace.getDirection()); selectedPos = hit; } else selectedPos = null; @@ -164,10 +164,10 @@ public class SchematicAndQuillHandler { selectedFace = null; if (secondPos != null) { - AxisAlignedBB bb = new AxisAlignedBB(firstPos, secondPos).expand(1, 1, 1) - .grow(.45f); - Vector3d projectedView = Minecraft.getInstance().gameRenderer.getActiveRenderInfo() - .getProjectedView(); + AxisAlignedBB bb = new AxisAlignedBB(firstPos, secondPos).expandTowards(1, 1, 1) + .inflate(.45f); + Vector3d projectedView = Minecraft.getInstance().gameRenderer.getMainCamera() + .getPosition(); boolean inside = bb.contains(projectedView); PredicateTraceResult result = RaycastHelper.rayTraceUntil(player, 70, pos -> inside ^ bb.contains(VecHelper.getCenterOf(pos))); @@ -190,27 +190,27 @@ public class SchematicAndQuillHandler { if (firstPos == null) return selectedPos == null ? null : new AxisAlignedBB(selectedPos); return selectedPos == null ? new AxisAlignedBB(firstPos) - : new AxisAlignedBB(firstPos, selectedPos).expand(1, 1, 1); + : new AxisAlignedBB(firstPos, selectedPos).expandTowards(1, 1, 1); } - return new AxisAlignedBB(firstPos, secondPos).expand(1, 1, 1); + return new AxisAlignedBB(firstPos, secondPos).expandTowards(1, 1, 1); } private boolean isActive() { - return isPresent() && AllItems.SCHEMATIC_AND_QUILL.isIn(Minecraft.getInstance().player.getHeldItemMainhand()); + return isPresent() && AllItems.SCHEMATIC_AND_QUILL.isIn(Minecraft.getInstance().player.getMainHandItem()); } private boolean isPresent() { - return Minecraft.getInstance() != null && Minecraft.getInstance().world != null - && Minecraft.getInstance().currentScreen == null; + return Minecraft.getInstance() != null && Minecraft.getInstance().level != null + && Minecraft.getInstance().screen == null; } public void saveSchematic(String string, boolean convertImmediately) { Template t = new Template(); MutableBoundingBox bb = new MutableBoundingBox(firstPos, secondPos); - BlockPos origin = new BlockPos(bb.minX, bb.minY, bb.minZ); - BlockPos bounds = new BlockPos(bb.getXSize(), bb.getYSize(), bb.getZSize()); + BlockPos origin = new BlockPos(bb.x0, bb.y0, bb.z0); + BlockPos bounds = new BlockPos(bb.getXSpan(), bb.getYSpan(), bb.getZSpan()); - t.takeBlocksFromWorld(Minecraft.getInstance().world, origin, bounds, true, Blocks.AIR); + t.fillFromWorld(Minecraft.getInstance().level, origin, bounds, true, Blocks.AIR); if (string.isEmpty()) string = Lang.translate("schematicAndQuill.fallbackName").getString(); @@ -224,7 +224,7 @@ public class SchematicAndQuillHandler { OutputStream outputStream = null; try { outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE); - CompoundNBT nbttagcompound = t.writeToNBT(new CompoundNBT()); + CompoundNBT nbttagcompound = t.save(new CompoundNBT()); CompressedStreamTools.writeCompressed(nbttagcompound, outputStream); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java index 5f29331d4..4d2f11747 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java @@ -62,30 +62,30 @@ public class SchematicEditScreen extends AbstractSimiScreen { int x = guiLeft; int y = guiTop; - xInput = new TextFieldWidget(textRenderer, x + 50, y + 26, 34, 10, StringTextComponent.EMPTY); - yInput = new TextFieldWidget(textRenderer, x + 90, y + 26, 34, 10, StringTextComponent.EMPTY); - zInput = new TextFieldWidget(textRenderer, x + 130, y + 26, 34, 10, StringTextComponent.EMPTY); + xInput = new TextFieldWidget(font, x + 50, y + 26, 34, 10, StringTextComponent.EMPTY); + yInput = new TextFieldWidget(font, x + 90, y + 26, 34, 10, StringTextComponent.EMPTY); + zInput = new TextFieldWidget(font, x + 130, y + 26, 34, 10, StringTextComponent.EMPTY); BlockPos anchor = handler.getTransformation() .getAnchor(); if (handler.isDeployed()) { - xInput.setText("" + anchor.getX()); - yInput.setText("" + anchor.getY()); - zInput.setText("" + anchor.getZ()); + xInput.setValue("" + anchor.getX()); + yInput.setValue("" + anchor.getY()); + zInput.setValue("" + anchor.getZ()); } else { - BlockPos alt = client.player.getBlockPos(); - xInput.setText("" + alt.getX()); - yInput.setText("" + alt.getY()); - zInput.setText("" + alt.getZ()); + BlockPos alt = minecraft.player.blockPosition(); + xInput.setValue("" + alt.getX()); + yInput.setValue("" + alt.getY()); + zInput.setValue("" + alt.getZ()); } for (TextFieldWidget widget : new TextFieldWidget[] { xInput, yInput, zInput }) { - widget.setMaxStringLength(6); - widget.setEnableBackgroundDrawing(false); + widget.setMaxLength(6); + widget.setBordered(false); widget.setTextColor(0xFFFFFF); widget.changeFocus(false); widget.mouseClicked(0, 0, 0); - widget.setValidator(s -> { + widget.setFilter(s -> { if (s.isEmpty() || s.equals("-")) return true; try { @@ -101,14 +101,14 @@ public class SchematicEditScreen extends AbstractSimiScreen { .toSettings(); Label labelR = new Label(x + 50, y + 48, StringTextComponent.EMPTY).withShadow(); rotationArea = new SelectionScrollInput(x + 45, y + 43, 118, 18).forOptions(rotationOptions) - .titled(rotationLabel.copy()) + .titled(rotationLabel.plainCopy()) .setState(settings.getRotation() .ordinal()) .writingTo(labelR); Label labelM = new Label(x + 50, y + 70, StringTextComponent.EMPTY).withShadow(); mirrorArea = new SelectionScrollInput(x + 45, y + 65, 118, 18).forOptions(mirrorOptions) - .titled(mirrorLabel.copy()) + .titled(mirrorLabel.plainCopy()) .setState(settings.getMirror() .ordinal()) .writingTo(labelM); @@ -124,7 +124,7 @@ public class SchematicEditScreen extends AbstractSimiScreen { @Override public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) { if (isPaste(code)) { - String coords = client.keyboardListener.getClipboardString(); + String coords = minecraft.keyboardHandler.getClipboard(); if (coords != null && !coords.isEmpty()) { coords.replaceAll(" ", ""); String[] split = coords.split(","); @@ -138,9 +138,9 @@ public class SchematicEditScreen extends AbstractSimiScreen { } } if (valid) { - xInput.setText(split[0]); - yInput.setText(split[1]); - zInput.setText(split[2]); + xInput.setValue(split[0]); + yInput.setValue(split[1]); + zInput.setValue(split[2]); return true; } } @@ -157,7 +157,7 @@ public class SchematicEditScreen extends AbstractSimiScreen { background.draw(ms, this, x, y); String title = handler.getCurrentSchematicName(); - drawCenteredString(ms, textRenderer, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); + drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); GuiGameElement.of(AllItems.SCHEMATIC.asStack()) .at(x + background.width + 6, y + background.height - 40, -200) @@ -170,8 +170,8 @@ public class SchematicEditScreen extends AbstractSimiScreen { boolean validCoords = true; BlockPos newLocation = null; try { - newLocation = new BlockPos(Integer.parseInt(xInput.getText()), Integer.parseInt(yInput.getText()), - Integer.parseInt(zInput.getText())); + newLocation = new BlockPos(Integer.parseInt(xInput.getValue()), Integer.parseInt(yInput.getValue()), + Integer.parseInt(zInput.getValue())); } catch (NumberFormatException e) { validCoords = false; } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java index 9bea80f55..305a11982 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java @@ -126,17 +126,17 @@ public class SchematicHandler { if (size.equals(BlockPos.ZERO)) return; - World clientWorld = Minecraft.getInstance().world; + World clientWorld = Minecraft.getInstance().level; SchematicWorld w = new SchematicWorld(clientWorld); SchematicWorld wMirroredFB = new SchematicWorld(clientWorld); SchematicWorld wMirroredLR = new SchematicWorld(clientWorld); PlacementSettings placementSettings = new PlacementSettings(); - schematic.place(w, BlockPos.ZERO, placementSettings, w.getRandom()); + schematic.placeInWorldChunk(w, BlockPos.ZERO, placementSettings, w.getRandom()); placementSettings.setMirror(Mirror.FRONT_BACK); - schematic.place(wMirroredFB, BlockPos.ZERO.east(size.getX() - 1), placementSettings, wMirroredFB.getRandom()); + schematic.placeInWorldChunk(wMirroredFB, BlockPos.ZERO.east(size.getX() - 1), placementSettings, wMirroredFB.getRandom()); placementSettings.setMirror(Mirror.LEFT_RIGHT); - schematic.place(wMirroredLR, BlockPos.ZERO.south(size.getZ() - 1), placementSettings, wMirroredFB.getRandom()); + schematic.placeInWorldChunk(wMirroredLR, BlockPos.ZERO.south(size.getZ() - 1), placementSettings, wMirroredFB.getRandom()); renderers.get(0) .display(w); @@ -152,13 +152,13 @@ public class SchematicHandler { return; if (active) { - ms.push(); + ms.pushPose(); currentTool.getTool() .renderTool(ms, buffer); - ms.pop(); + ms.popPose(); } - ms.push(); + ms.pushPose(); transformation.applyGLTransformations(ms); if (!renderers.isEmpty()) { @@ -182,7 +182,7 @@ public class SchematicHandler { currentTool.getTool() .renderOnSchematic(ms, buffer); - ms.pop(); + ms.popPose(); } @@ -202,11 +202,11 @@ public class SchematicHandler { if (!pressed || button != 1) return; Minecraft mc = Minecraft.getInstance(); - if (mc.player.isSneaking()) + if (mc.player.isShiftKeyDown()) return; - if (mc.objectMouseOver instanceof BlockRayTraceResult) { - BlockRayTraceResult blockRayTraceResult = (BlockRayTraceResult) mc.objectMouseOver; - BlockState clickedBlock = mc.world.getBlockState(blockRayTraceResult.getPos()); + if (mc.hitResult instanceof BlockRayTraceResult) { + BlockRayTraceResult blockRayTraceResult = (BlockRayTraceResult) mc.hitResult; + BlockState clickedBlock = mc.level.getBlockState(blockRayTraceResult.getBlockPos()); if (AllBlocks.SCHEMATICANNON.has(clickedBlock)) return; if (AllBlocks.DEPLOYER.has(clickedBlock)) @@ -245,23 +245,23 @@ public class SchematicHandler { } private ItemStack findBlueprintInHand(PlayerEntity player) { - ItemStack stack = player.getHeldItemMainhand(); + ItemStack stack = player.getMainHandItem(); if (!AllItems.SCHEMATIC.isIn(stack)) return null; if (!stack.hasTag()) return null; activeSchematicItem = stack; - activeHotbarSlot = player.inventory.currentItem; + activeHotbarSlot = player.inventory.selected; return stack; } private boolean itemLost(PlayerEntity player) { - for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) { - if (!player.inventory.getStackInSlot(i) - .isItemEqual(activeSchematicItem)) + for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + if (!player.inventory.getItem(i) + .sameItem(activeSchematicItem)) continue; - if (!ItemStack.areItemStackTagsEqual(player.inventory.getStackInSlot(i), activeSchematicItem)) + if (!ItemStack.tagMatches(player.inventory.getItem(i), activeSchematicItem)) continue; return false; } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHotbarSlotOverlay.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHotbarSlotOverlay.java index 33f531cbe..a5fe5eff7 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHotbarSlotOverlay.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHotbarSlotOverlay.java @@ -12,12 +12,12 @@ public class SchematicHotbarSlotOverlay extends AbstractGui { public void renderOn(MatrixStack matrixStack, int slot) { MainWindow mainWindow = Minecraft.getInstance().getWindow(); - int x = mainWindow.getScaledWidth() / 2 - 88; - int y = mainWindow.getScaledHeight() - 19; + int x = mainWindow.getGuiScaledWidth() / 2 - 88; + int y = mainWindow.getGuiScaledHeight() - 19; RenderSystem.enableDepthTest(); - matrixStack.push(); + matrixStack.pushPose(); AllGuiTextures.SCHEMATIC_SLOT.draw(matrixStack, this, x + 20 * slot, y); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicPromptScreen.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicPromptScreen.java index c635d4bb9..c13cc1dc0 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicPromptScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicPromptScreen.java @@ -43,11 +43,11 @@ public class SchematicPromptScreen extends AbstractSimiScreen { int x = guiLeft; int y = guiTop; - nameField = new TextFieldWidget(textRenderer, x + 49, y + 26, 131, 10, StringTextComponent.EMPTY); + nameField = new TextFieldWidget(font, x + 49, y + 26, 131, 10, StringTextComponent.EMPTY); nameField.setTextColor(-1); - nameField.setDisabledTextColour(-1); - nameField.setEnableBackgroundDrawing(false); - nameField.setMaxStringLength(35); + nameField.setTextColorUneditable(-1); + nameField.setBordered(false); + nameField.setMaxLength(35); nameField.changeFocus(true); abort = new IconButton(x + 7, y + 53, AllIcons.I_TRASH); @@ -74,7 +74,7 @@ public class SchematicPromptScreen extends AbstractSimiScreen { int y = guiTop; background.draw(ms, this, x, y); - drawCenteredText(ms, textRenderer, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); + drawCenteredString(ms, font, title, x + (background.width - 8) / 2, y + 3, 0xFFFFFF); GuiGameElement.of(AllItems.SCHEMATIC.asStack()) .at(x + 22, y + 23, 0) .render(ms); @@ -106,7 +106,7 @@ public class SchematicPromptScreen extends AbstractSimiScreen { } if (abort.isHovered()) { CreateClient.SCHEMATIC_AND_QUILL_HANDLER.discard(); - client.player.closeScreen(); + minecraft.player.closeContainer(); return true; } if (convert.isHovered()) { @@ -117,8 +117,8 @@ public class SchematicPromptScreen extends AbstractSimiScreen { } private void confirm(boolean convertImmediately) { - CreateClient.SCHEMATIC_AND_QUILL_HANDLER.saveSchematic(nameField.getText(), convertImmediately); - client.player.closeScreen(); + CreateClient.SCHEMATIC_AND_QUILL_HANDLER.saveSchematic(nameField.getValue(), convertImmediately); + minecraft.player.closeContainer(); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java index 75f55c7ba..2cc709335 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java @@ -61,7 +61,7 @@ public class SchematicRenderer { if (!active) return; Minecraft mc = Minecraft.getInstance(); - if (mc.world == null || mc.player == null || !changed) + if (mc.level == null || mc.player == null || !changed) return; redraw(mc); @@ -71,8 +71,8 @@ public class SchematicRenderer { public void render(MatrixStack ms, SuperRenderTypeBuffer buffer) { if (!active) return; - buffer.getBuffer(RenderType.getSolid()); - for (RenderType layer : RenderType.getBlockLayers()) { + buffer.getBuffer(RenderType.solid()); + for (RenderType layer : RenderType.chunkBufferLayers()) { if (!usedBlockRenderLayers.contains(layer)) continue; SuperByteBuffer superByteBuffer = bufferCache.get(layer); @@ -86,21 +86,21 @@ public class SchematicRenderer { startedBufferBuilders.clear(); final SchematicWorld blockAccess = schematic; - final BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRendererDispatcher(); + final BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRenderer(); List blockstates = new LinkedList<>(); Map buffers = new HashMap<>(); MatrixStack ms = new MatrixStack(); - BlockPos.stream(blockAccess.getBounds()) + BlockPos.betweenClosedStream(blockAccess.getBounds()) .forEach(localPos -> { - ms.push(); + ms.pushPose(); MatrixStacker.of(ms) .translate(localPos); - BlockPos pos = localPos.add(anchor); + BlockPos pos = localPos.offset(anchor); BlockState state = blockAccess.getBlockState(pos); - for (RenderType blockRenderLayer : RenderType.getBlockLayers()) { + for (RenderType blockRenderLayer : RenderType.chunkBufferLayers()) { if (!RenderTypeLookup.canRenderInLayer(state, blockRenderLayer)) continue; ForgeHooksClient.setRenderLayer(blockRenderLayer); @@ -111,10 +111,10 @@ public class SchematicRenderer { if (startedBufferBuilders.add(blockRenderLayer)) bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - TileEntity tileEntity = blockAccess.getTileEntity(localPos); + TileEntity tileEntity = blockAccess.getBlockEntity(localPos); if (blockRendererDispatcher.renderModel(state, pos, blockAccess, ms, bufferBuilder, true, - minecraft.world.rand, + minecraft.level.random, tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE)) { usedBlockRenderLayers.add(blockRenderLayer); } @@ -122,21 +122,21 @@ public class SchematicRenderer { } ForgeHooksClient.setRenderLayer(null); - ms.pop(); + ms.popPose(); }); // finishDrawing - for (RenderType layer : RenderType.getBlockLayers()) { + for (RenderType layer : RenderType.chunkBufferLayers()) { if (!startedBufferBuilders.contains(layer)) continue; BufferBuilder buf = buffers.get(layer); - buf.finishDrawing(); + buf.end(); bufferCache.put(layer, new SuperByteBuffer(buf)); } } private static int getLayerCount() { - return RenderType.getBlockLayers() + return RenderType.chunkBufferLayers() .size(); } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java index 7c3c6c6a2..97f496ecd 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java @@ -38,8 +38,8 @@ public class SchematicTransformation { int frontBack = settings.getMirror() == Mirror.FRONT_BACK ? -1 : 1; getScaleFB().start(frontBack); getScaleLR().start(leftRight); - xOrigin = bounds.getXSize() / 2f; - zOrigin = bounds.getZSize() / 2f; + xOrigin = bounds.getXsize() / 2f; + zOrigin = bounds.getZsize() / 2f; int r = -(settings.getRotation() .ordinal() * 90); @@ -99,7 +99,7 @@ public class SchematicTransformation { vec = vec.subtract(xOrigin + rotationOffset.x, 0, zOrigin + rotationOffset.z); vec = VecHelper.rotate(vec, -rotation.get(pt), Axis.Y); vec = vec.add(rotationOffset.x, 0, rotationOffset.z); - vec = vec.mul(getScaleFB().get(pt), 1, getScaleLR().get(pt)); + vec = vec.multiply(getScaleFB().get(pt), 1, getScaleLR().get(pt)); vec = vec.add(xOrigin, 0, zOrigin); return vec; @@ -148,7 +148,7 @@ public class SchematicTransformation { Vector3d rotationOffset = getRotationOffset(false); vec = vec.subtract(xOrigin, 0, zOrigin); vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z); - vec = vec.mul(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); + vec = vec.multiply(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); vec = VecHelper.rotate(vec, rotation.getTarget(), Axis.Y); vec = vec.add(xOrigin, 0, zOrigin); @@ -161,11 +161,11 @@ public class SchematicTransformation { Vector3d rotationOffset = getRotationOffset(false); vec = vec.subtract(xOrigin, 0, zOrigin); vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z); - vec = vec.mul(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); + vec = vec.multiply(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); vec = VecHelper.rotate(vec, rotation.getTarget(), Axis.Y); vec = vec.add(xOrigin, 0, zOrigin); - return Vector3d.of(pos.subtract(new BlockPos(vec.x, vec.y, vec.z))); + return Vector3d.atLowerCornerOf(pos.subtract(new BlockPos(vec.x, vec.y, vec.z))); } public int getRotationTarget() { diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java index b873d5f78..ab108da12 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java @@ -42,7 +42,7 @@ public class DeployTool extends PlacementToolBase { if (selectedPos == null) return; - ms.push(); + ms.pushPose(); float pt = AnimationTickHolder.getPartialTicks(); double x = MathHelper.lerp(pt, lastChasingSelectedPos.x, chasingSelectedPos.x); double y = MathHelper.lerp(pt, lastChasingSelectedPos.y, chasingSelectedPos.y); @@ -54,8 +54,8 @@ public class DeployTool extends PlacementToolBase { Vector3d rotationOffset = transformation.getRotationOffset(true); int centerX = (int) center.x; int centerZ = (int) center.z; - double xOrigin = bounds.getXSize() / 2f; - double zOrigin = bounds.getZSize() / 2f; + double xOrigin = bounds.getXsize() / 2f; + double zOrigin = bounds.getZsize() / 2f; Vector3d origin = new Vector3d(xOrigin, 0, zOrigin); ms.translate(x - centerX, y, z - centerZ); @@ -70,7 +70,7 @@ public class DeployTool extends PlacementToolBase { outline.render(ms, buffer, pt); outline.getParams() .clearTextures(); - ms.pop(); + ms.popPose(); } @Override @@ -88,7 +88,7 @@ public class DeployTool extends PlacementToolBase { return super.handleRightClick(); Vector3d center = schematicHandler.getBounds() .getCenter(); - BlockPos target = selectedPos.add(-((int) center.x), 0, -((int) center.z)); + BlockPos target = selectedPos.offset(-((int) center.x), 0, -((int) center.z)); ItemStack item = schematicHandler.getActiveSchematicItem(); if (item != null) { diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java index dc8733e61..82b6b0f2f 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java @@ -56,17 +56,17 @@ public class FlipTool extends PlacementToolBase { return; } - Direction facing = selectedFace.rotateY(); + Direction facing = selectedFace.getClockWise(); AxisAlignedBB bounds = schematicHandler.getBounds(); - Vector3d directionVec = Vector3d.of(Direction.getFacingFromAxis(AxisDirection.POSITIVE, facing.getAxis()) - .getDirectionVec()); - Vector3d boundsSize = new Vector3d(bounds.getXSize(), bounds.getYSize(), bounds.getZSize()); - Vector3d vec = boundsSize.mul(directionVec); + Vector3d directionVec = Vector3d.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, facing.getAxis()) + .getNormal()); + Vector3d boundsSize = new Vector3d(bounds.getXsize(), bounds.getYsize(), bounds.getZsize()); + Vector3d vec = boundsSize.multiply(directionVec); bounds = bounds.contract(vec.x, vec.y, vec.z) - .grow(1 - directionVec.x, 1 - directionVec.y, 1 - directionVec.z); - bounds = bounds.offset(directionVec.scale(.5f) - .mul(boundsSize)); + .inflate(1 - directionVec.x, 1 - directionVec.y, 1 - directionVec.z); + bounds = bounds.move(directionVec.scale(.5f) + .multiply(boundsSize)); outline.setBounds(bounds); AllSpecialTextures tex = AllSpecialTextures.CHECKERED; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/MoveTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/MoveTool.java index 4fcaf8659..f01e87d7c 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/MoveTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/MoveTool.java @@ -25,8 +25,8 @@ public class MoveTool extends PlacementToolBase { return true; SchematicTransformation transformation = schematicHandler.getTransformation(); - Vector3d vec = Vector3d.of(selectedFace.getDirectionVec()).scale(-Math.signum(delta)); - vec = vec.mul(transformation.getMirrorModifier(Axis.X), 1, transformation.getMirrorModifier(Axis.Z)); + Vector3d vec = Vector3d.atLowerCornerOf(selectedFace.getNormal()).scale(-Math.signum(delta)); + vec = vec.multiply(transformation.getMirrorModifier(Axis.X), 1, transformation.getMirrorModifier(Axis.Z)); vec = VecHelper.rotate(vec, transformation.getRotationTarget(), Axis.Y); transformation.move((float) vec.x, 0, (float) vec.z); schematicHandler.markDirty(); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java index 2e57dd830..bc793d1ec 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java @@ -23,7 +23,7 @@ public class RotateTool extends PlacementToolBase { @Override public void renderOnSchematic(MatrixStack ms, SuperRenderTypeBuffer buffer) { AxisAlignedBB bounds = schematicHandler.getBounds(); - double height = bounds.getYSize() + Math.max(20, bounds.getYSize()); + double height = bounds.getYsize() + Math.max(20, bounds.getYsize()); Vector3d center = bounds.getCenter() .add(schematicHandler.getTransformation() .getRotationOffset(false)); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java index bbfa5163c..9340d82a6 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java @@ -60,7 +60,7 @@ public abstract class SchematicToolBase implements ISchematicTool { if (selectedPos == null) return; lastChasingSelectedPos = chasingSelectedPos; - Vector3d target = Vector3d.of(selectedPos); + Vector3d target = Vector3d.atLowerCornerOf(selectedPos); if (target.distanceTo(chasingSelectedPos) < 1 / 512f) { chasingSelectedPos = target; return; @@ -94,30 +94,30 @@ public abstract class SchematicToolBase implements ISchematicTool { if (selectIgnoreBlocks) { float pt = AnimationTickHolder.getPartialTicks(); selectedPos = new BlockPos(player.getEyePosition(pt) - .add(player.getLookVec() + .add(player.getLookAngle() .scale(selectionRange))); if (snap) - lastChasingSelectedPos = chasingSelectedPos = Vector3d.of(selectedPos); + lastChasingSelectedPos = chasingSelectedPos = Vector3d.atLowerCornerOf(selectedPos); return; } // Select targeted Block selectedPos = null; - BlockRayTraceResult trace = RaycastHelper.rayTraceRange(player.world, player, 75); + BlockRayTraceResult trace = RaycastHelper.rayTraceRange(player.level, player, 75); if (trace == null || trace.getType() != Type.BLOCK) return; - BlockPos hit = new BlockPos(trace.getHitVec()); - boolean replaceable = player.world.getBlockState(hit) + BlockPos hit = new BlockPos(trace.getLocation()); + boolean replaceable = player.level.getBlockState(hit) .getMaterial() .isReplaceable(); - if (trace.getFace() + if (trace.getDirection() .getAxis() .isVertical() && !replaceable) - hit = hit.offset(trace.getFace()); + hit = hit.relative(trace.getDirection()); selectedPos = hit; if (snap) - lastChasingSelectedPos = chasingSelectedPos = Vector3d.of(selectedPos); + lastChasingSelectedPos = chasingSelectedPos = Vector3d.atLowerCornerOf(selectedPos); } @Override @@ -131,7 +131,7 @@ public abstract class SchematicToolBase implements ISchematicTool { if (!schematicHandler.isDeployed()) return; - ms.push(); + ms.pushPose(); AABBOutline outline = schematicHandler.getOutline(); if (renderSelectedFace) { outline.getParams() @@ -146,7 +146,7 @@ public abstract class SchematicToolBase implements ISchematicTool { outline.render(ms, buffer, AnimationTickHolder.getPartialTicks()); outline.getParams() .clearTextures(); - ms.pop(); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/filtering/SchematicInstances.java b/src/main/java/com/simibubi/create/content/schematics/filtering/SchematicInstances.java index 8bd1c542b..3942a7eb9 100644 --- a/src/main/java/com/simibubi/create/content/schematics/filtering/SchematicInstances.java +++ b/src/main/java/com/simibubi/create/content/schematics/filtering/SchematicInstances.java @@ -61,7 +61,7 @@ public class SchematicInstances { .getCompound("Anchor")); SchematicWorld world = new SchematicWorld(anchor, wrapped); PlacementSettings settings = SchematicItem.getSettings(schematic); - activeTemplate.place(world, anchor, settings, wrapped.getRandom()); + activeTemplate.placeInWorldChunk(world, anchor, settings, wrapped.getRandom()); return world; } diff --git a/src/main/java/com/simibubi/create/content/schematics/item/SchematicAndQuillItem.java b/src/main/java/com/simibubi/create/content/schematics/item/SchematicAndQuillItem.java index 30e330076..63b5e67ee 100644 --- a/src/main/java/com/simibubi/create/content/schematics/item/SchematicAndQuillItem.java +++ b/src/main/java/com/simibubi/create/content/schematics/item/SchematicAndQuillItem.java @@ -2,6 +2,8 @@ package com.simibubi.create.content.schematics.item; import net.minecraft.item.Item; +import net.minecraft.item.Item.Properties; + public class SchematicAndQuillItem extends Item { public SchematicAndQuillItem(Properties properties) { diff --git a/src/main/java/com/simibubi/create/content/schematics/item/SchematicItem.java b/src/main/java/com/simibubi/create/content/schematics/item/SchematicItem.java index eca91e789..ffdede407 100644 --- a/src/main/java/com/simibubi/create/content/schematics/item/SchematicItem.java +++ b/src/main/java/com/simibubi/create/content/schematics/item/SchematicItem.java @@ -50,12 +50,14 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.thread.SidedThreadGroups; +import net.minecraft.item.Item.Properties; + public class SchematicItem extends Item { private static final Logger LOGGER = LogManager.getLogger(); public SchematicItem(Properties properties) { - super(properties.maxStackSize(1)); + super(properties.stacksTo(1)); } public static ItemStack create(String schematic, String owner) { @@ -75,20 +77,20 @@ public class SchematicItem extends Item { } @Override - public void fillItemGroup(ItemGroup group, NonNullList items) {} + public void fillItemCategory(ItemGroup group, NonNullList items) {} @Override @OnlyIn(value = Dist.CLIENT) - public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + public void appendHoverText(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { if (stack.hasTag()) { if (stack.getTag() .contains("File")) tooltip.add(new StringTextComponent(TextFormatting.GOLD + stack.getTag() .getString("File"))); } else { - tooltip.add(Lang.translate("schematic.invalid").formatted(TextFormatting.RED)); + tooltip.add(Lang.translate("schematic.invalid").withStyle(TextFormatting.RED)); } - super.addInformation(stack, worldIn, tooltip, flagIn); + super.appendHoverText(stack, worldIn, tooltip, flagIn); } public static void writeSize(ItemStack blueprint) { @@ -141,7 +143,7 @@ public class SchematicItem extends Item { try (DataInputStream stream = new DataInputStream(new BufferedInputStream( new GZIPInputStream(Files.newInputStream(path, StandardOpenOption.READ))))) { CompoundNBT nbt = CompressedStreamTools.read(stream, new NBTSizeTracker(0x20000000L)); - t.read(nbt); + t.load(nbt); } catch (IOException e) { LOGGER.warn("Failed to read schematic", e); } @@ -151,23 +153,23 @@ public class SchematicItem extends Item { @Nonnull @Override - public ActionResultType onItemUse(ItemUseContext context) { + public ActionResultType useOn(ItemUseContext context) { if (context.getPlayer() != null && !onItemUse(context.getPlayer(), context.getHand())) - return super.onItemUse(context); + return super.useOn(context); return ActionResultType.SUCCESS; } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { if (!onItemUse(playerIn, handIn)) - return super.onItemRightClick(worldIn, playerIn, handIn); - return new ActionResult<>(ActionResultType.SUCCESS, playerIn.getHeldItem(handIn)); + return super.use(worldIn, playerIn, handIn); + return new ActionResult<>(ActionResultType.SUCCESS, playerIn.getItemInHand(handIn)); } private boolean onItemUse(PlayerEntity player, Hand hand) { - if (!player.isSneaking() || hand != Hand.MAIN_HAND) + if (!player.isShiftKeyDown() || hand != Hand.MAIN_HAND) return false; - if (!player.getHeldItem(hand) + if (!player.getItemInHand(hand) .hasTag()) return false; DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::displayBlueprintScreen); diff --git a/src/main/java/com/simibubi/create/content/schematics/packet/ConfigureSchematicannonPacket.java b/src/main/java/com/simibubi/create/content/schematics/packet/ConfigureSchematicannonPacket.java index 2e66fc255..e53a876db 100644 --- a/src/main/java/com/simibubi/create/content/schematics/packet/ConfigureSchematicannonPacket.java +++ b/src/main/java/com/simibubi/create/content/schematics/packet/ConfigureSchematicannonPacket.java @@ -26,21 +26,21 @@ public class ConfigureSchematicannonPacket extends SimplePacketBase { } public ConfigureSchematicannonPacket(PacketBuffer buffer) { - this(buffer.readEnumValue(Option.class), buffer.readBoolean()); + this(buffer.readEnum(Option.class), buffer.readBoolean()); } public void write(PacketBuffer buffer) { - buffer.writeEnumValue(option); + buffer.writeEnum(option); buffer.writeBoolean(set); } public void handle(Supplier context) { context.get().enqueueWork(() -> { ServerPlayerEntity player = context.get().getSender(); - if (player == null || !(player.openContainer instanceof SchematicannonContainer)) + if (player == null || !(player.containerMenu instanceof SchematicannonContainer)) return; - SchematicannonTileEntity te = ((SchematicannonContainer) player.openContainer).getTileEntity(); + SchematicannonTileEntity te = ((SchematicannonContainer) player.containerMenu).getTileEntity(); switch (option) { case DONT_REPLACE: case REPLACE_ANY: diff --git a/src/main/java/com/simibubi/create/content/schematics/packet/InstantSchematicPacket.java b/src/main/java/com/simibubi/create/content/schematics/packet/InstantSchematicPacket.java index 00255c435..433875cb2 100644 --- a/src/main/java/com/simibubi/create/content/schematics/packet/InstantSchematicPacket.java +++ b/src/main/java/com/simibubi/create/content/schematics/packet/InstantSchematicPacket.java @@ -23,14 +23,14 @@ public class InstantSchematicPacket extends SimplePacketBase { } public InstantSchematicPacket(PacketBuffer buffer) { - name = buffer.readString(32767); + name = buffer.readUtf(32767); origin = buffer.readBlockPos(); bounds = buffer.readBlockPos(); } @Override public void write(PacketBuffer buffer) { - buffer.writeString(name); + buffer.writeUtf(name); buffer.writeBlockPos(origin); buffer.writeBlockPos(bounds); } @@ -43,7 +43,7 @@ public class InstantSchematicPacket extends SimplePacketBase { .getSender(); if (player == null) return; - Create.SCHEMATIC_RECEIVER.handleInstantSchematic(player, name, player.world, origin, bounds); + Create.SCHEMATIC_RECEIVER.handleInstantSchematic(player, name, player.level, origin, bounds); }); context.get() .setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java index 01cc59d07..3f6eccd0f 100644 --- a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java +++ b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java @@ -22,11 +22,11 @@ public class SchematicPlacePacket extends SimplePacketBase { } public SchematicPlacePacket(PacketBuffer buffer) { - stack = buffer.readItemStack(); + stack = buffer.readItem(); } public void write(PacketBuffer buffer) { - buffer.writeItemStack(stack); + buffer.writeItem(stack); } public void handle(Supplier context) { @@ -35,19 +35,19 @@ public class SchematicPlacePacket extends SimplePacketBase { if (player == null) return; - World world = player.getServerWorld(); + World world = player.getLevel(); SchematicPrinter printer = new SchematicPrinter(); - printer.loadSchematic(stack, world, !player.canUseCommandBlock()); + printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks()); while (printer.advanceCurrentPos()) { if (!printer.shouldPlaceCurrent(world)) continue; printer.handleCurrentTarget((pos, state, tile) -> { - CompoundNBT tileData = tile != null ? tile.write(new CompoundNBT()) : null; + CompoundNBT tileData = tile != null ? tile.save(new CompoundNBT()) : null; BlockHelper.placeSchematicBlock(world, state, pos, null, tileData); }, (pos, entity) -> { - world.addEntity(entity); + world.addFreshEntity(entity); }); } }); diff --git a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicSyncPacket.java b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicSyncPacket.java index 030f66a93..f35991b80 100644 --- a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicSyncPacket.java +++ b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicSyncPacket.java @@ -38,8 +38,8 @@ public class SchematicSyncPacket extends SimplePacketBase { slot = buffer.readVarInt(); deployed = buffer.readBoolean(); anchor = buffer.readBlockPos(); - rotation = buffer.readEnumValue(Rotation.class); - mirror = buffer.readEnumValue(Mirror.class); + rotation = buffer.readEnum(Rotation.class); + mirror = buffer.readEnum(Mirror.class); } @Override @@ -47,8 +47,8 @@ public class SchematicSyncPacket extends SimplePacketBase { buffer.writeVarInt(slot); buffer.writeBoolean(deployed); buffer.writeBlockPos(anchor); - buffer.writeEnumValue(rotation); - buffer.writeEnumValue(mirror); + buffer.writeEnum(rotation); + buffer.writeEnum(mirror); } @Override @@ -59,9 +59,9 @@ public class SchematicSyncPacket extends SimplePacketBase { return; ItemStack stack = ItemStack.EMPTY; if (slot == -1) { - stack = player.getHeldItemMainhand(); + stack = player.getMainHandItem(); } else { - stack = player.inventory.getStackInSlot(slot); + stack = player.inventory.getItem(slot); } if (!AllItems.SCHEMATIC.isIn(stack)) { return; diff --git a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicUploadPacket.java b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicUploadPacket.java index bde22038b..3828588c9 100644 --- a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicUploadPacket.java +++ b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicUploadPacket.java @@ -45,7 +45,7 @@ public class SchematicUploadPacket extends SimplePacketBase { public SchematicUploadPacket(PacketBuffer buffer) { code = buffer.readInt(); - schematic = buffer.readString(256); + schematic = buffer.readUtf(256); if (code == BEGIN) size = buffer.readLong(); @@ -55,7 +55,7 @@ public class SchematicUploadPacket extends SimplePacketBase { public void write(PacketBuffer buffer) { buffer.writeInt(code); - buffer.writeString(schematic); + buffer.writeUtf(schematic); if (code == BEGIN) buffer.writeLong(size); @@ -71,8 +71,8 @@ public class SchematicUploadPacket extends SimplePacketBase { if (player == null) return; if (code == BEGIN) { - BlockPos pos = ((SchematicTableContainer) player.openContainer).getTileEntity() - .getPos(); + BlockPos pos = ((SchematicTableContainer) player.containerMenu).getTileEntity() + .getBlockPos(); Create.SCHEMATIC_RECEIVER.handleNewUpload(player, schematic, size, pos); } if (code == WRITE) diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index cf8c2a81c..7021f2dfd 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -96,7 +96,7 @@ public class ClientEvents { @SubscribeEvent public static void onTick(ClientTickEvent event) { - World world = Minecraft.getInstance().world; + World world = Minecraft.getInstance().level; if (!isGameActive()) return; @@ -153,7 +153,7 @@ public class ClientEvents { @SubscribeEvent public static void onLoadWorld(WorldEvent.Load event) { IWorld world = event.getWorld(); - if (world.isRemote() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) { + if (world.isClientSide() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) { CreateClient.invalidateRenderers(); AnimationTickHolder.reset(); } @@ -169,7 +169,7 @@ public class ClientEvents { @SubscribeEvent public static void onUnloadWorld(WorldEvent.Unload event) { if (event.getWorld() - .isRemote()) { + .isClientSide()) { CreateClient.invalidateRenderers(); CreateClient.SOUL_PULSE_EFFECT_HANDLER.refresh(); AnimationTickHolder.reset(); @@ -178,13 +178,13 @@ public class ClientEvents { @SubscribeEvent public static void onRenderWorld(RenderWorldLastEvent event) { - Vector3d cameraPos = Minecraft.getInstance().gameRenderer.getActiveRenderInfo() - .getProjectedView(); + Vector3d cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera() + .getPosition(); float pt = AnimationTickHolder.getPartialTicks(); MatrixStack ms = event.getMatrixStack(); - ms.push(); - ms.translate(-cameraPos.getX(), -cameraPos.getY(), -cameraPos.getZ()); + ms.pushPose(); + ms.translate(-cameraPos.x(), -cameraPos.y(), -cameraPos.z()); SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance(); CouplingRenderer.renderAll(ms, buffer); @@ -196,17 +196,17 @@ public class ClientEvents { buffer.draw(); RenderSystem.enableCull(); - ms.pop(); + ms.popPose(); } @SubscribeEvent public static void onRenderOverlay(RenderGameOverlayEvent.Post event) { MatrixStack ms = event.getMatrixStack(); Impl buffers = Minecraft.getInstance() - .getBufferBuilders() - .getEntityVertexConsumers(); + .renderBuffers() + .bufferSource(); int light = 0xF000F0; - int overlay = OverlayTexture.DEFAULT_UV; + int overlay = OverlayTexture.NO_OVERLAY; float pt = event.getPartialTicks(); if (event.getType() == ElementType.AIR) @@ -239,7 +239,7 @@ public class ClientEvents { ItemStack stack = event.getItemStack(); String translationKey = stack.getItem() - .getTranslationKey(stack); + .getDescriptionId(stack); if (translationKey.startsWith(itemPrefix) || translationKey.startsWith(blockPrefix)) if (TooltipHelper.hasTooltip(stack, event.getPlayer())) { @@ -276,31 +276,31 @@ public class ClientEvents { } protected static boolean isGameActive() { - return !(Minecraft.getInstance().world == null || Minecraft.getInstance().player == null); + return !(Minecraft.getInstance().level == null || Minecraft.getInstance().player == null); } @SubscribeEvent public static void getFogDensity(EntityViewRenderEvent.FogDensity event) { ActiveRenderInfo info = event.getInfo(); - FluidState fluidState = info.getFluidState(); + FluidState fluidState = info.getFluidInCamera(); if (fluidState.isEmpty()) return; - Fluid fluid = fluidState.getFluid(); + Fluid fluid = fluidState.getType(); - if (fluid.isEquivalentTo(AllFluids.CHOCOLATE.get())) { + if (fluid.isSame(AllFluids.CHOCOLATE.get())) { event.setDensity(5f); event.setCanceled(true); return; } - if (fluid.isEquivalentTo(AllFluids.HONEY.get())) { + if (fluid.isSame(AllFluids.HONEY.get())) { event.setDensity(1.5f); event.setCanceled(true); return; } if (FluidHelper.isWater(fluid) && AllItems.DIVING_HELMET.get() - .isWornBy(Minecraft.getInstance().renderViewEntity)) { + .isWornBy(Minecraft.getInstance().cameraEntity)) { event.setDensity(0.010f); event.setCanceled(true); return; @@ -310,18 +310,18 @@ public class ClientEvents { @SubscribeEvent public static void getFogColor(EntityViewRenderEvent.FogColors event) { ActiveRenderInfo info = event.getInfo(); - FluidState fluidState = info.getFluidState(); + FluidState fluidState = info.getFluidInCamera(); if (fluidState.isEmpty()) return; - Fluid fluid = fluidState.getFluid(); + Fluid fluid = fluidState.getType(); - if (fluid.isEquivalentTo(AllFluids.CHOCOLATE.get())) { + if (fluid.isSame(AllFluids.CHOCOLATE.get())) { event.setRed(98 / 256f); event.setGreen(32 / 256f); event.setBlue(32 / 256f); } - if (fluid.isEquivalentTo(AllFluids.HONEY.get())) { + if (fluid.isSame(AllFluids.HONEY.get())) { event.setRed(234 / 256f); event.setGreen(174 / 256f); event.setBlue(47 / 256f); diff --git a/src/main/java/com/simibubi/create/events/CommonEvents.java b/src/main/java/com/simibubi/create/events/CommonEvents.java index 6664931dd..3631e9b0b 100644 --- a/src/main/java/com/simibubi/create/events/CommonEvents.java +++ b/src/main/java/com/simibubi/create/events/CommonEvents.java @@ -71,12 +71,12 @@ public class CommonEvents { BlockPos pos = event.getPos(); IWorld world = event.getWorld(); - if (fluidState.isSource() && FluidHelper.isLava(fluidState.getFluid())) + if (fluidState.isSource() && FluidHelper.isLava(fluidState.getType())) return; for (Direction direction : Iterate.directions) { - FluidState metFluidState = fluidState.isSource() ? fluidState : world.getFluidState(pos.offset(direction)); - if (!metFluidState.isTagged(FluidTags.WATER)) + FluidState metFluidState = fluidState.isSource() ? fluidState : world.getFluidState(pos.relative(direction)); + if (!metFluidState.is(FluidTags.WATER)) continue; BlockState lavaInteraction = AllFluids.getLavaInteraction(metFluidState); if (lavaInteraction == null) @@ -100,7 +100,7 @@ public class CommonEvents { @SubscribeEvent public static void onUpdateLivingEntity(LivingUpdateEvent event) { LivingEntity entityLiving = event.getEntityLiving(); - World world = entityLiving.world; + World world = entityLiving.level; if (world == null) return; ContraptionHandler.entitiesWhoJustDismountedGetSentToTheRightLocation(entityLiving, world); @@ -161,7 +161,7 @@ public class CommonEvents { } public static void leftClickEmpty(ServerPlayerEntity player) { - ItemStack stack = player.getHeldItemMainhand(); + ItemStack stack = player.getMainHandItem(); if (stack.getItem() instanceof ZapperItem) { ZapperInteractionHandler.trySelect(stack, player); } diff --git a/src/main/java/com/simibubi/create/events/InputEvents.java b/src/main/java/com/simibubi/create/events/InputEvents.java index b40da1974..2b97cb343 100644 --- a/src/main/java/com/simibubi/create/events/InputEvents.java +++ b/src/main/java/com/simibubi/create/events/InputEvents.java @@ -22,7 +22,7 @@ public class InputEvents { int key = event.getKey(); boolean pressed = !(event.getAction() == 0); - if (Minecraft.getInstance().currentScreen != null) + if (Minecraft.getInstance().screen != null) return; CreateClient.SCHEMATIC_HANDLER.onKeyInput(key, pressed); @@ -30,7 +30,7 @@ public class InputEvents { @SubscribeEvent public static void onMouseScrolled(MouseScrollEvent event) { - if (Minecraft.getInstance().currentScreen != null) + if (Minecraft.getInstance().screen != null) return; double delta = event.getScrollDelta(); @@ -43,7 +43,7 @@ public class InputEvents { @SubscribeEvent public static void onMouseInput(MouseInputEvent event) { - if (Minecraft.getInstance().currentScreen != null) + if (Minecraft.getInstance().screen != null) return; int button = event.getButton(); @@ -55,7 +55,7 @@ public class InputEvents { @SubscribeEvent public static void onClickInput(ClickInputEvent event) { - if (Minecraft.getInstance().currentScreen != null) + if (Minecraft.getInstance().screen != null) return; if (event.isUseItem()) diff --git a/src/main/java/com/simibubi/create/foundation/BreakProgressHook.java b/src/main/java/com/simibubi/create/foundation/BreakProgressHook.java index 34c16f20e..c77691c83 100644 --- a/src/main/java/com/simibubi/create/foundation/BreakProgressHook.java +++ b/src/main/java/com/simibubi/create/foundation/BreakProgressHook.java @@ -12,10 +12,10 @@ public class BreakProgressHook { public static void whenBreaking(ClientWorld world, WorldRenderer renderer, int playerEntityId, BlockPos pos, int progress) { if (AllBlocks.BELT.has(world.getBlockState(pos))) { - BeltTileEntity belt = (BeltTileEntity) world.getTileEntity(pos); + BeltTileEntity belt = (BeltTileEntity) world.getBlockEntity(pos); for (BlockPos beltPos : BeltBlock.getBeltChain(world, belt.getController())) { - renderer.sendBlockBreakProgress(beltPos.hashCode(), beltPos, progress); + renderer.destroyBlockProgress(beltPos.hashCode(), beltPos, progress); } } } diff --git a/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java b/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java index 42b1a6a5c..f5e4d5b02 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java @@ -45,135 +45,135 @@ public class AllAdvancements implements IDataProvider { public void register(Consumer t) { String id = Create.ID; - Advancement root = Advancement.Builder.builder() - .withDisplay(AllItems.BRASS_HAND.asStack(), new TranslationTextComponent(LANG + "root"), + Advancement root = Advancement.Builder.advancement() + .display(AllItems.BRASS_HAND.asStack(), new TranslationTextComponent(LANG + "root"), new TranslationTextComponent(LANG + "root.desc"), new ResourceLocation(Create.ID, "textures/block/palettes/gabbro/bricks.png"), FrameType.TASK, false, false, false) - .withCriterion("0", InventoryChangeTrigger.Instance.forItems(new IItemProvider[] {})) - .register(t, id + ":root"); + .addCriterion("0", InventoryChangeTrigger.Instance.hasItems(new IItemProvider[] {})) + .save(t, id + ":root"); Advancement andesite_alloy = - advancement("andesite_alloy", AllItems.ANDESITE_ALLOY.get(), TaskType.NORMAL).withParent(root) - .withCriterion("0", itemGathered(AllItems.ANDESITE_ALLOY.get())) - .register(t, id + ":andesite_alloy"); + advancement("andesite_alloy", AllItems.ANDESITE_ALLOY.get(), TaskType.NORMAL).parent(root) + .addCriterion("0", itemGathered(AllItems.ANDESITE_ALLOY.get())) + .save(t, id + ":andesite_alloy"); kineticsBranch(t, andesite_alloy); Advancement aesthetics = advancement("aesthetics", AllBlocks.WOODEN_BRACKET.get(), TaskType.NORMAL) - .withParent(andesite_alloy) - .withCriterion("0", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.SHAFT.get())) - .withCriterion("1", + .parent(andesite_alloy) + .addCriterion("0", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.SHAFT.get())) + .addCriterion("1", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.COGWHEEL.get(), AllBlocks.LARGE_COGWHEEL.get())) - .withCriterion("2", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.FLUID_PIPE.get())) - .register(t, id + ":aesthetics"); + .addCriterion("2", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.FLUID_PIPE.get())) + .save(t, id + ":aesthetics"); Advancement reinforced = - advancement("reinforced", AllBlocks.ANDESITE_ENCASED_SHAFT.get(), TaskType.NORMAL).withParent(aesthetics) - .withCriterion("0", AllTriggers.CASING_SHAFT.instance()) - .withCriterion("1", AllTriggers.CASING_BELT.instance()) - .withCriterion("2", AllTriggers.CASING_PIPE.instance()) - .register(t, id + ":reinforced"); + advancement("reinforced", AllBlocks.ANDESITE_ENCASED_SHAFT.get(), TaskType.NORMAL).parent(aesthetics) + .addCriterion("0", AllTriggers.CASING_SHAFT.instance()) + .addCriterion("1", AllTriggers.CASING_BELT.instance()) + .addCriterion("2", AllTriggers.CASING_PIPE.instance()) + .save(t, id + ":reinforced"); Advancement water_wheel = - advancement("water_wheel", AllBlocks.WATER_WHEEL.get(), TaskType.NORMAL).withParent(andesite_alloy) - .withCriterion("0", placeBlock(AllBlocks.WATER_WHEEL.get())) - .withCriterion("1", AllTriggers.WATER_WHEEL.instance()) - .register(t, id + ":water_wheel"); + advancement("water_wheel", AllBlocks.WATER_WHEEL.get(), TaskType.NORMAL).parent(andesite_alloy) + .addCriterion("0", placeBlock(AllBlocks.WATER_WHEEL.get())) + .addCriterion("1", AllTriggers.WATER_WHEEL.instance()) + .save(t, id + ":water_wheel"); - Advancement lava_wheel = advancement("lava_wheel", Items.LAVA_BUCKET, TaskType.SECRET).withParent(water_wheel) - .withCriterion("0", AllTriggers.LAVA_WHEEL.instance()) - .register(t, id + ":lava_wheel"); + Advancement lava_wheel = advancement("lava_wheel", Items.LAVA_BUCKET, TaskType.SECRET).parent(water_wheel) + .addCriterion("0", AllTriggers.LAVA_WHEEL.instance()) + .save(t, id + ":lava_wheel"); Advancement chocolate_wheel = advancement("chocolate_wheel", AllFluids.CHOCOLATE.get() - .getFilledBucket(), TaskType.SECRET).withParent(water_wheel) - .withCriterion("0", AllTriggers.CHOCOLATE_WHEEL.instance()) - .register(t, id + ":chocolate_wheel"); + .getBucket(), TaskType.SECRET).parent(water_wheel) + .addCriterion("0", AllTriggers.CHOCOLATE_WHEEL.instance()) + .save(t, id + ":chocolate_wheel"); Advancement millstone = - kinecticAdvancement("millstone", AllBlocks.MILLSTONE.get(), TaskType.NORMAL).withParent(andesite_alloy) - .register(t, id + ":millstone"); + kinecticAdvancement("millstone", AllBlocks.MILLSTONE.get(), TaskType.NORMAL).parent(andesite_alloy) + .save(t, id + ":millstone"); Advancement cuckoo = - advancement("cuckoo", AllBlocks.CUCKOO_CLOCK.get(), TaskType.NORMAL).withParent(andesite_alloy) - .withCriterion("0", AllTriggers.CUCKOO.instance()) - .register(t, id + ":cuckoo"); + advancement("cuckoo", AllBlocks.CUCKOO_CLOCK.get(), TaskType.NORMAL).parent(andesite_alloy) + .addCriterion("0", AllTriggers.CUCKOO.instance()) + .save(t, id + ":cuckoo"); Advancement windmill = - advancement("windmill", AllBlocks.WINDMILL_BEARING.get(), TaskType.NORMAL).withParent(andesite_alloy) - .withCriterion("0", AllTriggers.WINDMILL.instance()) - .register(t, id + ":windmill"); + advancement("windmill", AllBlocks.WINDMILL_BEARING.get(), TaskType.NORMAL).parent(andesite_alloy) + .addCriterion("0", AllTriggers.WINDMILL.instance()) + .save(t, id + ":windmill"); Advancement maxed_windmill = - advancement("maxed_windmill", AllBlocks.WINDMILL_BEARING.get(), TaskType.GOAL).withParent(windmill) - .withCriterion("0", AllTriggers.MAXED_WINDMILL.instance()) - .register(t, id + ":maxed_windmill"); + advancement("maxed_windmill", AllBlocks.WINDMILL_BEARING.get(), TaskType.GOAL).parent(windmill) + .addCriterion("0", AllTriggers.MAXED_WINDMILL.instance()) + .save(t, id + ":maxed_windmill"); Advancement andesite_casing = - advancement("andesite_casing", AllBlocks.ANDESITE_CASING.get(), TaskType.GOAL).withParent(andesite_alloy) - .withCriterion("0", itemGathered(AllBlocks.ANDESITE_CASING.get())) - .register(t, id + ":andesite_casing"); + advancement("andesite_casing", AllBlocks.ANDESITE_CASING.get(), TaskType.GOAL).parent(andesite_alloy) + .addCriterion("0", itemGathered(AllBlocks.ANDESITE_CASING.get())) + .save(t, id + ":andesite_casing"); Advancement drill = kinecticAdvancement("mechanical_drill", AllBlocks.MECHANICAL_DRILL.get(), TaskType.NORMAL) - .withParent(andesite_casing) - .register(t, id + ":mechanical_drill"); + .parent(andesite_casing) + .save(t, id + ":mechanical_drill"); Advancement press = - advancement("press", AllBlocks.MECHANICAL_PRESS.get(), TaskType.MILESTONE).withParent(andesite_casing) - .withCriterion("0", AllTriggers.BONK.instance()) - .register(t, id + ":press"); + advancement("press", AllBlocks.MECHANICAL_PRESS.get(), TaskType.MILESTONE).parent(andesite_casing) + .addCriterion("0", AllTriggers.BONK.instance()) + .save(t, id + ":press"); - Advancement fan = advancement("fan", AllBlocks.ENCASED_FAN.get(), TaskType.NORMAL).withParent(press) - .withCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.NONE)) - .register(t, id + ":fan"); + Advancement fan = advancement("fan", AllBlocks.ENCASED_FAN.get(), TaskType.NORMAL).parent(press) + .addCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.NONE)) + .save(t, id + ":fan"); - Advancement fan_lava = advancement("fan_lava", Items.LAVA_BUCKET, TaskType.NORMAL).withParent(fan) - .withCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.BLASTING)) - .register(t, id + ":fan_lava"); + Advancement fan_lava = advancement("fan_lava", Items.LAVA_BUCKET, TaskType.NORMAL).parent(fan) + .addCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.BLASTING)) + .save(t, id + ":fan_lava"); - Advancement fan_smoke = advancement("fan_smoke", Items.CAMPFIRE, TaskType.NORMAL).withParent(fan) - .withCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.SMOKING)) - .register(t, id + ":fan_smoke"); + Advancement fan_smoke = advancement("fan_smoke", Items.CAMPFIRE, TaskType.NORMAL).parent(fan) + .addCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.SMOKING)) + .save(t, id + ":fan_smoke"); - Advancement fan_water = advancement("fan_water", Items.WATER_BUCKET, TaskType.NORMAL).withParent(fan) - .withCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.SPLASHING)) - .register(t, id + ":fan_water"); + Advancement fan_water = advancement("fan_water", Items.WATER_BUCKET, TaskType.NORMAL).parent(fan) + .addCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.SPLASHING)) + .save(t, id + ":fan_water"); Advancement rose_quartz = itemAdvancement("polished_rose_quartz", AllItems.POLISHED_ROSE_QUARTZ, TaskType.NORMAL) - .withParent(andesite_casing) - .register(t, id + ":polished_rose_quartz"); + .parent(andesite_casing) + .save(t, id + ":polished_rose_quartz"); Advancement electron_tube = - itemAdvancement("electron_tube", AllItems.ELECTRON_TUBE, TaskType.NORMAL).withParent(rose_quartz) - .register(t, id + ":electron_tube"); + itemAdvancement("electron_tube", AllItems.ELECTRON_TUBE, TaskType.NORMAL).parent(rose_quartz) + .save(t, id + ":electron_tube"); Advancement saw = - kinecticAdvancement("mechanical_saw", AllBlocks.MECHANICAL_SAW.get(), TaskType.NORMAL).withParent(press) - .register(t, id + ":mechanical_saw"); + kinecticAdvancement("mechanical_saw", AllBlocks.MECHANICAL_SAW.get(), TaskType.NORMAL).parent(press) + .save(t, id + ":mechanical_saw"); - Advancement basin = advancement("basin", AllBlocks.BASIN.get(), TaskType.NORMAL).withParent(press) - .withCriterion("0", placeBlock(AllBlocks.BASIN.get())) - .withCriterion("1", AllTriggers.BASIN_THROW.instance()) - .register(t, id + ":basin"); + Advancement basin = advancement("basin", AllBlocks.BASIN.get(), TaskType.NORMAL).parent(press) + .addCriterion("0", placeBlock(AllBlocks.BASIN.get())) + .addCriterion("1", AllTriggers.BASIN_THROW.instance()) + .save(t, id + ":basin"); Advancement mixer = advancement("mixer", AllBlocks.MECHANICAL_MIXER.get(), TaskType.MILESTONE) - .withCriterion("0", placeBlock(AllBlocks.MECHANICAL_MIXER.get())) - .withCriterion("1", AllTriggers.MIXER_MIX.instance()) - .withParent(basin) - .register(t, id + ":mixer"); + .addCriterion("0", placeBlock(AllBlocks.MECHANICAL_MIXER.get())) + .addCriterion("1", AllTriggers.MIXER_MIX.instance()) + .parent(basin) + .save(t, id + ":mixer"); Advancement compact = advancement("compact", Blocks.IRON_BLOCK, TaskType.NORMAL) - .withCriterion("0", AllTriggers.PRESS_COMPACT.instance()) - .withParent(basin) - .register(t, id + ":compact"); + .addCriterion("0", AllTriggers.PRESS_COMPACT.instance()) + .parent(basin) + .save(t, id + ":compact"); Advancement blaze_burner = - itemAdvancement("blaze_burner", AllBlocks.BLAZE_BURNER, TaskType.NORMAL).withParent(mixer) - .register(t, id + ":blaze_burner"); + itemAdvancement("blaze_burner", AllBlocks.BLAZE_BURNER, TaskType.NORMAL).parent(mixer) + .save(t, id + ":blaze_burner"); - Advancement brass = itemAdvancement("brass", AllItems.BRASS_INGOT, TaskType.NORMAL).withParent(blaze_burner) - .register(t, id + ":brass"); + Advancement brass = itemAdvancement("brass", AllItems.BRASS_INGOT, TaskType.NORMAL).parent(blaze_burner) + .save(t, id + ":brass"); brassAge(t, brass); copperAge(t, press); @@ -182,64 +182,64 @@ public class AllAdvancements implements IDataProvider { void kineticsBranch(Consumer t, Advancement root) { String id = Create.ID; - Advancement its_alive = advancement("its_alive", AllBlocks.COGWHEEL.get(), TaskType.NORMAL).withParent(root) - .withCriterion("0", AllTriggers.ROTATION.instance()) - .register(t, id + ":its_alive"); + Advancement its_alive = advancement("its_alive", AllBlocks.COGWHEEL.get(), TaskType.NORMAL).parent(root) + .addCriterion("0", AllTriggers.ROTATION.instance()) + .save(t, id + ":its_alive"); - Advancement belt = advancement("belt", AllItems.BELT_CONNECTOR.get(), TaskType.NORMAL).withParent(its_alive) - .withCriterion("0", AllTriggers.CONNECT_BELT.instance()) - .register(t, id + ":belt"); + Advancement belt = advancement("belt", AllItems.BELT_CONNECTOR.get(), TaskType.NORMAL).parent(its_alive) + .addCriterion("0", AllTriggers.CONNECT_BELT.instance()) + .save(t, id + ":belt"); - Advancement tunnel = advancement("tunnel", AllBlocks.ANDESITE_TUNNEL.get(), TaskType.NORMAL).withParent(belt) - .withCriterion("0", AllTriggers.PLACE_TUNNEL.instance()) - .register(t, id + ":tunnel"); + Advancement tunnel = advancement("tunnel", AllBlocks.ANDESITE_TUNNEL.get(), TaskType.NORMAL).parent(belt) + .addCriterion("0", AllTriggers.PLACE_TUNNEL.instance()) + .save(t, id + ":tunnel"); Advancement splitter_tunnel = - advancement("splitter_tunnel", AllBlocks.BRASS_TUNNEL.get(), TaskType.MILESTONE).withParent(tunnel) - .withCriterion("0", AllTriggers.CONNECT_TUNNEL.instance()) - .register(t, id + ":splitter_tunnel"); + advancement("splitter_tunnel", AllBlocks.BRASS_TUNNEL.get(), TaskType.MILESTONE).parent(tunnel) + .addCriterion("0", AllTriggers.CONNECT_TUNNEL.instance()) + .save(t, id + ":splitter_tunnel"); - Advancement chute = advancement("chute", AllBlocks.CHUTE.get(), TaskType.NORMAL).withParent(belt) - .withCriterion("0", placeBlock(AllBlocks.CHUTE.get())) - .register(t, id + ":chute"); + Advancement chute = advancement("chute", AllBlocks.CHUTE.get(), TaskType.NORMAL).parent(belt) + .addCriterion("0", placeBlock(AllBlocks.CHUTE.get())) + .save(t, id + ":chute"); Advancement upward_chute = - advancement("upward_chute", AllBlocks.ENCASED_FAN.get(), TaskType.NORMAL).withParent(chute) - .withCriterion("0", AllTriggers.UPWARD_CHUTE.instance()) - .register(t, id + ":upward_chute"); + advancement("upward_chute", AllBlocks.ENCASED_FAN.get(), TaskType.NORMAL).parent(chute) + .addCriterion("0", AllTriggers.UPWARD_CHUTE.instance()) + .save(t, id + ":upward_chute"); Advancement belt_funnel = - advancement("belt_funnel", AllBlocks.ANDESITE_FUNNEL.get(), TaskType.NORMAL).withParent(belt) - .withCriterion("0", AllTriggers.BELT_FUNNEL.instance()) - .register(t, id + ":belt_funnel"); + advancement("belt_funnel", AllBlocks.ANDESITE_FUNNEL.get(), TaskType.NORMAL).parent(belt) + .addCriterion("0", AllTriggers.BELT_FUNNEL.instance()) + .save(t, id + ":belt_funnel"); Advancement belt_funnel_kiss = - advancement("belt_funnel_kiss", AllBlocks.BRASS_FUNNEL.get(), TaskType.SECRET).withParent(belt_funnel) - .withCriterion("0", AllTriggers.BELT_FUNNEL_KISS.instance()) - .register(t, id + ":belt_funnel_kiss"); + advancement("belt_funnel_kiss", AllBlocks.BRASS_FUNNEL.get(), TaskType.SECRET).parent(belt_funnel) + .addCriterion("0", AllTriggers.BELT_FUNNEL_KISS.instance()) + .save(t, id + ":belt_funnel_kiss"); - Advancement wrench = itemAdvancement("wrench", AllItems.WRENCH, TaskType.NORMAL).withParent(its_alive) - .register(t, id + ":wrench"); + Advancement wrench = itemAdvancement("wrench", AllItems.WRENCH, TaskType.NORMAL).parent(its_alive) + .save(t, id + ":wrench"); - Advancement goggles = itemAdvancement("goggles", AllItems.GOGGLES, TaskType.NORMAL).withParent(its_alive) - .register(t, id + ":goggles"); + Advancement goggles = itemAdvancement("goggles", AllItems.GOGGLES, TaskType.NORMAL).parent(its_alive) + .save(t, id + ":goggles"); Advancement speed_gauge = - kinecticAdvancement("speedometer", AllBlocks.SPEEDOMETER.get(), TaskType.NORMAL).withParent(goggles) - .register(t, id + ":speedometer"); + kinecticAdvancement("speedometer", AllBlocks.SPEEDOMETER.get(), TaskType.NORMAL).parent(goggles) + .save(t, id + ":speedometer"); Advancement stress_gauge = - kinecticAdvancement("stressometer", AllBlocks.STRESSOMETER.get(), TaskType.NORMAL).withParent(goggles) - .register(t, id + ":stressometer"); + kinecticAdvancement("stressometer", AllBlocks.STRESSOMETER.get(), TaskType.NORMAL).parent(goggles) + .save(t, id + ":stressometer"); Advancement shifting_gears = - advancement("shifting_gears", AllBlocks.LARGE_COGWHEEL.get(), TaskType.NORMAL).withParent(its_alive) - .withCriterion("0", AllTriggers.SHIFTING_GEARS.instance()) - .register(t, id + ":shifting_gears"); + advancement("shifting_gears", AllBlocks.LARGE_COGWHEEL.get(), TaskType.NORMAL).parent(its_alive) + .addCriterion("0", AllTriggers.SHIFTING_GEARS.instance()) + .save(t, id + ":shifting_gears"); - Advancement overstressed = advancement("overstressed", Items.BARRIER, TaskType.SECRET).withParent(its_alive) - .withCriterion("0", AllTriggers.OVERSTRESSED.instance()) - .register(t, id + ":overstressed"); + Advancement overstressed = advancement("overstressed", Items.BARRIER, TaskType.SECRET).parent(its_alive) + .addCriterion("0", AllTriggers.OVERSTRESSED.instance()) + .save(t, id + ":overstressed"); } @@ -247,190 +247,190 @@ public class AllAdvancements implements IDataProvider { String id = Create.ID; Advancement copper_casing = - advancement("copper_casing", AllBlocks.COPPER_CASING.get(), TaskType.GOAL).withParent(root) - .withCriterion("0", itemGathered(AllBlocks.COPPER_CASING.get())) - .register(t, id + ":copper_casing"); + advancement("copper_casing", AllBlocks.COPPER_CASING.get(), TaskType.GOAL).parent(root) + .addCriterion("0", itemGathered(AllBlocks.COPPER_CASING.get())) + .save(t, id + ":copper_casing"); Advancement item_drain = - advancement("item_drain", AllBlocks.ITEM_DRAIN.get(), TaskType.NORMAL).withParent(copper_casing) - .withCriterion("0", AllTriggers.ITEM_DRAIN.instance()) - .register(t, id + ":item_drain"); + advancement("item_drain", AllBlocks.ITEM_DRAIN.get(), TaskType.NORMAL).parent(copper_casing) + .addCriterion("0", AllTriggers.ITEM_DRAIN.instance()) + .save(t, id + ":item_drain"); Advancement chained_item_drain = - advancement("chained_item_drain", AllBlocks.ITEM_DRAIN.get(), TaskType.SECRET).withParent(item_drain) - .withCriterion("0", AllTriggers.CHAINED_ITEM_DRAIN.instance()) - .register(t, id + ":chained_item_drain"); + advancement("chained_item_drain", AllBlocks.ITEM_DRAIN.get(), TaskType.SECRET).parent(item_drain) + .addCriterion("0", AllTriggers.CHAINED_ITEM_DRAIN.instance()) + .save(t, id + ":chained_item_drain"); - Advancement spout = advancement("spout", AllBlocks.SPOUT.get(), TaskType.NORMAL).withParent(copper_casing) - .withCriterion("0", AllTriggers.SPOUT.instance()) - .register(t, id + ":spout"); + Advancement spout = advancement("spout", AllBlocks.SPOUT.get(), TaskType.NORMAL).parent(copper_casing) + .addCriterion("0", AllTriggers.SPOUT.instance()) + .save(t, id + ":spout"); - Advancement spout_potion = advancement("spout_potion", Items.POTION, TaskType.GOAL).withParent(spout) - .withCriterion("0", AllTriggers.SPOUT_POTION.instance()) - .register(t, id + ":spout_potion"); + Advancement spout_potion = advancement("spout_potion", Items.POTION, TaskType.GOAL).parent(spout) + .addCriterion("0", AllTriggers.SPOUT_POTION.instance()) + .save(t, id + ":spout_potion"); Advancement chocolate = itemAdvancement("chocolate", () -> AllFluids.CHOCOLATE.get() - .getFilledBucket(), TaskType.GOAL).withParent(spout) - .register(t, id + ":chocolate"); + .getBucket(), TaskType.GOAL).parent(spout) + .save(t, id + ":chocolate"); Advancement glass_pipe = - advancement("glass_pipe", AllBlocks.FLUID_PIPE.get(), TaskType.NORMAL).withParent(copper_casing) - .withCriterion("0", AllTriggers.GLASS_PIPE.instance()) - .register(t, id + ":glass_pipe"); + advancement("glass_pipe", AllBlocks.FLUID_PIPE.get(), TaskType.NORMAL).parent(copper_casing) + .addCriterion("0", AllTriggers.GLASS_PIPE.instance()) + .save(t, id + ":glass_pipe"); Advancement pipe_collision = - advancement("pipe_collision", AllBlocks.FLUID_VALVE.get(), TaskType.NORMAL).withParent(glass_pipe) - .withCriterion("0", AllTriggers.PIPE_COLLISION.instance()) - .register(t, id + ":pipe_collision"); + advancement("pipe_collision", AllBlocks.FLUID_VALVE.get(), TaskType.NORMAL).parent(glass_pipe) + .addCriterion("0", AllTriggers.PIPE_COLLISION.instance()) + .save(t, id + ":pipe_collision"); - Advancement pipe_spill = advancement("pipe_spill", Items.BUCKET, TaskType.NORMAL).withParent(glass_pipe) - .withCriterion("0", AllTriggers.PIPE_SPILL.instance()) - .register(t, id + ":pipe_spill"); + Advancement pipe_spill = advancement("pipe_spill", Items.BUCKET, TaskType.NORMAL).parent(glass_pipe) + .addCriterion("0", AllTriggers.PIPE_SPILL.instance()) + .save(t, id + ":pipe_spill"); Advancement hose_pulley = - advancement("hose_pulley", AllBlocks.HOSE_PULLEY.get(), TaskType.NORMAL).withParent(pipe_spill) - .withCriterion("0", AllTriggers.HOSE_PULLEY.instance()) - .register(t, id + ":hose_pulley"); + advancement("hose_pulley", AllBlocks.HOSE_PULLEY.get(), TaskType.NORMAL).parent(pipe_spill) + .addCriterion("0", AllTriggers.HOSE_PULLEY.instance()) + .save(t, id + ":hose_pulley"); Advancement infinite_water = - advancement("infinite_water", Items.WATER_BUCKET, TaskType.NORMAL).withParent(hose_pulley) - .withCriterion("0", isInfinite(Fluids.WATER)) - .register(t, id + ":infinite_water"); + advancement("infinite_water", Items.WATER_BUCKET, TaskType.NORMAL).parent(hose_pulley) + .addCriterion("0", isInfinite(Fluids.WATER)) + .save(t, id + ":infinite_water"); Advancement infinite_lava = - advancement("infinite_lava", Items.LAVA_BUCKET, TaskType.GOAL).withParent(hose_pulley) - .withCriterion("0", isInfinite(Fluids.LAVA)) - .register(t, id + ":infinite_lava"); + advancement("infinite_lava", Items.LAVA_BUCKET, TaskType.GOAL).parent(hose_pulley) + .addCriterion("0", isInfinite(Fluids.LAVA)) + .save(t, id + ":infinite_lava"); Advancement infinite_chocolate = advancement("infinite_chocolate", AllFluids.CHOCOLATE.get() - .getFilledBucket(), TaskType.CHALLENGE).withParent(hose_pulley) - .withCriterion("0", isInfinite(AllFluids.CHOCOLATE.get())) - .register(t, id + ":infinite_chocolate"); + .getBucket(), TaskType.CHALLENGE).parent(hose_pulley) + .addCriterion("0", isInfinite(AllFluids.CHOCOLATE.get())) + .save(t, id + ":infinite_chocolate"); } void brassAge(Consumer t, Advancement root) { String id = Create.ID; Advancement brass_casing = - advancement("brass_casing", AllBlocks.BRASS_CASING.get(), TaskType.GOAL).withParent(root) - .withCriterion("0", itemGathered(AllBlocks.BRASS_CASING.get())) - .register(t, id + ":brass_casing"); + advancement("brass_casing", AllBlocks.BRASS_CASING.get(), TaskType.GOAL).parent(root) + .addCriterion("0", itemGathered(AllBlocks.BRASS_CASING.get())) + .save(t, id + ":brass_casing"); Advancement nixie_tube = - advancement("nixie_tube", AllBlocks.ORANGE_NIXIE_TUBE.get(), TaskType.NORMAL).withParent(brass_casing) - .withCriterion("0", placeBlock(AllBlocks.ORANGE_NIXIE_TUBE.get())) - .register(t, id + ":nixie_tube"); + advancement("nixie_tube", AllBlocks.ORANGE_NIXIE_TUBE.get(), TaskType.NORMAL).parent(brass_casing) + .addCriterion("0", placeBlock(AllBlocks.ORANGE_NIXIE_TUBE.get())) + .save(t, id + ":nixie_tube"); Advancement crafter = kinecticAdvancement("crafter", AllBlocks.MECHANICAL_CRAFTER.get(), TaskType.MILESTONE) - .withParent(brass_casing) - .register(t, id + ":crafter"); + .parent(brass_casing) + .save(t, id + ":crafter"); - Advancement flywheel = advancement("flywheel", AllBlocks.FLYWHEEL.get(), TaskType.NORMAL).withParent(crafter) - .withCriterion("0", AllTriggers.FLYWHEEL.instance()) - .register(t, id + ":flywheel"); + Advancement flywheel = advancement("flywheel", AllBlocks.FLYWHEEL.get(), TaskType.NORMAL).parent(crafter) + .addCriterion("0", AllTriggers.FLYWHEEL.instance()) + .save(t, id + ":flywheel"); Advancement overstress_flywheel = - advancement("overstress_flywheel", AllBlocks.FURNACE_ENGINE.get(), TaskType.CHALLENGE).withParent(flywheel) - .withCriterion("0", AllTriggers.OVERSTRESS_FLYWHEEL.instance()) - .register(t, id + ":overstress_flywheel"); + advancement("overstress_flywheel", AllBlocks.FURNACE_ENGINE.get(), TaskType.CHALLENGE).parent(flywheel) + .addCriterion("0", AllTriggers.OVERSTRESS_FLYWHEEL.instance()) + .save(t, id + ":overstress_flywheel"); Advancement clockwork_bearing = advancement("clockwork_bearing", AllBlocks.CLOCKWORK_BEARING.get(), TaskType.NORMAL) - .withParent(brass_casing) - .withCriterion("0", AllTriggers.CLOCKWORK_BEARING.instance()) - .register(t, id + ":clockwork_bearing"); + .parent(brass_casing) + .addCriterion("0", AllTriggers.CLOCKWORK_BEARING.instance()) + .save(t, id + ":clockwork_bearing"); Advancement mechanical_arm = advancement("mechanical_arm", AllBlocks.MECHANICAL_ARM.get(), TaskType.MILESTONE) - .withCriterion("0", AllTriggers.MECHANICAL_ARM.instance()) - .withParent(brass_casing) - .register(t, id + ":mechanical_arm"); + .addCriterion("0", AllTriggers.MECHANICAL_ARM.instance()) + .parent(brass_casing) + .save(t, id + ":mechanical_arm"); Advancement musical_arm = advancement("musical_arm", Items.MUSIC_DISC_13, TaskType.MILESTONE) - .withCriterion("0", AllTriggers.MUSICAL_ARM.instance()) - .withParent(mechanical_arm) - .register(t, id + ":musical_arm"); + .addCriterion("0", AllTriggers.MUSICAL_ARM.instance()) + .parent(mechanical_arm) + .save(t, id + ":musical_arm"); Advancement arm_many_targets = advancement("arm_many_targets", AllBlocks.BRASS_FUNNEL.get(), TaskType.MILESTONE) - .withCriterion("0", AllTriggers.ARM_MANY_TARGETS.instance()) - .withParent(mechanical_arm) - .register(t, id + ":arm_many_targets"); + .addCriterion("0", AllTriggers.ARM_MANY_TARGETS.instance()) + .parent(mechanical_arm) + .save(t, id + ":arm_many_targets"); Advancement arm_blaze_burner = advancement("arm_blaze_burner", AllBlocks.BLAZE_BURNER.get(), TaskType.NORMAL) - .withCriterion("0", AllTriggers.ARM_BLAZE_BURNER.instance()) - .withParent(mechanical_arm) - .register(t, id + ":arm_blaze_burner"); + .addCriterion("0", AllTriggers.ARM_BLAZE_BURNER.instance()) + .parent(mechanical_arm) + .save(t, id + ":arm_blaze_burner"); Advancement deployer = - kinecticAdvancement("deployer", AllBlocks.DEPLOYER.get(), TaskType.MILESTONE).withParent(brass_casing) - .register(t, id + ":deployer"); + kinecticAdvancement("deployer", AllBlocks.DEPLOYER.get(), TaskType.MILESTONE).parent(brass_casing) + .save(t, id + ":deployer"); Advancement clockwork_component = - itemAdvancement("precision_mechanism", AllItems.PRECISION_MECHANISM, TaskType.NORMAL).withParent(deployer) - .register(t, id + ":precision_mechanism"); + itemAdvancement("precision_mechanism", AllItems.PRECISION_MECHANISM, TaskType.NORMAL).parent(deployer) + .save(t, id + ":precision_mechanism"); - Advancement clockwork_component_eob = deadEnd().withParent(clockwork_component) - .withCriterion("0", itemGathered(AllItems.PRECISION_MECHANISM.get())) - .register(t, id + ":clockwork_component_eob"); + Advancement clockwork_component_eob = deadEnd().parent(clockwork_component) + .addCriterion("0", itemGathered(AllItems.PRECISION_MECHANISM.get())) + .save(t, id + ":clockwork_component_eob"); Advancement extendo_grip = - advancement("extendo_grip", AllItems.EXTENDO_GRIP.get(), TaskType.NORMAL).withParent(clockwork_component) - .withCriterion("0", AllTriggers.EXTENDO.instance()) - .register(t, id + ":extendo_grip"); + advancement("extendo_grip", AllItems.EXTENDO_GRIP.get(), TaskType.NORMAL).parent(clockwork_component) + .addCriterion("0", AllTriggers.EXTENDO.instance()) + .save(t, id + ":extendo_grip"); Advancement potato_cannon = - advancement("potato_cannon", AllItems.POTATO_CANNON.get(), TaskType.GOAL).withParent(clockwork_component) - .withCriterion("0", AllTriggers.POTATO_KILL.instance()) - .register(t, id + ":potato_cannon"); + advancement("potato_cannon", AllItems.POTATO_CANNON.get(), TaskType.GOAL).parent(clockwork_component) + .addCriterion("0", AllTriggers.POTATO_KILL.instance()) + .save(t, id + ":potato_cannon"); Advancement dual_extendo_grip = - advancement("dual_extendo_grip", AllItems.EXTENDO_GRIP.get(), TaskType.SECRET).withParent(extendo_grip) - .withCriterion("0", AllTriggers.GIGA_EXTENDO.instance()) - .register(t, id + ":dual_extendo_grip"); + advancement("dual_extendo_grip", AllItems.EXTENDO_GRIP.get(), TaskType.SECRET).parent(extendo_grip) + .addCriterion("0", AllTriggers.GIGA_EXTENDO.instance()) + .save(t, id + ":dual_extendo_grip"); Advancement speed_controller = kinecticAdvancement("speed_controller", AllBlocks.ROTATION_SPEED_CONTROLLER.get(), TaskType.NORMAL) - .withParent(clockwork_component) - .register(t, id + ":speed_controller"); + .parent(clockwork_component) + .save(t, id + ":speed_controller"); - Advancement fist_bump = advancement("fist_bump", AllBlocks.DEPLOYER.get(), TaskType.SECRET).withParent(deployer) - .withCriterion("0", AllTriggers.DEPLOYER_BOOP.instance()) - .register(t, id + ":fist_bump"); + Advancement fist_bump = advancement("fist_bump", AllBlocks.DEPLOYER.get(), TaskType.SECRET).parent(deployer) + .addCriterion("0", AllTriggers.DEPLOYER_BOOP.instance()) + .save(t, id + ":fist_bump"); Advancement crushing_wheel = - advancement("crushing_wheel", AllBlocks.CRUSHING_WHEEL.get(), TaskType.MILESTONE).withParent(crafter) - .withCriterion("0", itemGathered(AllBlocks.CRUSHING_WHEEL.get())) - .register(t, id + ":crushing_wheel"); + advancement("crushing_wheel", AllBlocks.CRUSHING_WHEEL.get(), TaskType.MILESTONE).parent(crafter) + .addCriterion("0", itemGathered(AllBlocks.CRUSHING_WHEEL.get())) + .save(t, id + ":crushing_wheel"); Advancement blaze_cake = - itemAdvancement("blaze_cake", AllItems.BLAZE_CAKE, TaskType.NORMAL).withParent(crushing_wheel) - .register(t, id + ":blaze_cake"); + itemAdvancement("blaze_cake", AllItems.BLAZE_CAKE, TaskType.NORMAL).parent(crushing_wheel) + .save(t, id + ":blaze_cake"); Advancement chromatic_compound = - itemAdvancement("chromatic_compound", AllItems.CHROMATIC_COMPOUND, TaskType.NORMAL).withParent(blaze_cake) - .register(t, id + ":chromatic_compound"); + itemAdvancement("chromatic_compound", AllItems.CHROMATIC_COMPOUND, TaskType.NORMAL).parent(blaze_cake) + .save(t, id + ":chromatic_compound"); Advancement shadow_steel = - itemAdvancement("shadow_steel", AllItems.SHADOW_STEEL, TaskType.GOAL).withParent(chromatic_compound) - .register(t, id + ":shadow_steel"); + itemAdvancement("shadow_steel", AllItems.SHADOW_STEEL, TaskType.GOAL).parent(chromatic_compound) + .save(t, id + ":shadow_steel"); Advancement refined_radiance = - itemAdvancement("refined_radiance", AllItems.REFINED_RADIANCE, TaskType.GOAL).withParent(chromatic_compound) - .register(t, id + ":refined_radiance"); + itemAdvancement("refined_radiance", AllItems.REFINED_RADIANCE, TaskType.GOAL).parent(chromatic_compound) + .save(t, id + ":refined_radiance"); Advancement chromatic_age = advancement("chromatic_age", AllBlocks.REFINED_RADIANCE_CASING.get(), TaskType.GOAL) - .withParent(chromatic_compound) - .withCriterion("0", itemGathered(AllBlocks.SHADOW_STEEL_CASING.get())) - .withCriterion("1", itemGathered(AllBlocks.REFINED_RADIANCE_CASING.get())) - .register(t, id + "chromatic_age"); + .parent(chromatic_compound) + .addCriterion("0", itemGathered(AllBlocks.SHADOW_STEEL_CASING.get())) + .addCriterion("1", itemGathered(AllBlocks.REFINED_RADIANCE_CASING.get())) + .save(t, id + "chromatic_age"); - Advancement chromatic_eob = deadEnd().withParent(chromatic_age) - .withCriterion("0", itemGathered(AllBlocks.SHADOW_STEEL_CASING.get())) - .withCriterion("1", itemGathered(AllBlocks.REFINED_RADIANCE_CASING.get())) - .register(t, id + ":chromatic_eob"); + Advancement chromatic_eob = deadEnd().parent(chromatic_age) + .addCriterion("0", itemGathered(AllBlocks.SHADOW_STEEL_CASING.get())) + .addCriterion("1", itemGathered(AllBlocks.REFINED_RADIANCE_CASING.get())) + .save(t, id + ":chromatic_eob"); Advancement symmetry_wand = - itemAdvancement("wand_of_symmetry", AllItems.WAND_OF_SYMMETRY, TaskType.NORMAL).withParent(refined_radiance) - .register(t, id + ":wand_of_symmetry"); + itemAdvancement("wand_of_symmetry", AllItems.WAND_OF_SYMMETRY, TaskType.NORMAL).parent(refined_radiance) + .save(t, id + ":wand_of_symmetry"); } @@ -446,7 +446,7 @@ public class AllAdvancements implements IDataProvider { } @Override - public void act(DirectoryCache cache) throws IOException { + public void run(DirectoryCache cache) throws IOException { Path path = this.generator.getOutputFolder(); Set set = Sets.newHashSet(); Consumer consumer = (p_204017_3_) -> { @@ -456,8 +456,8 @@ public class AllAdvancements implements IDataProvider { Path path1 = getPath(path, p_204017_3_); try { - IDataProvider.save(GSON, cache, p_204017_3_.copy() - .serialize(), path1); + IDataProvider.save(GSON, cache, p_204017_3_.deconstruct() + .serializeToJson(), path1); } catch (IOException ioexception) { LOGGER.error("Couldn't save advancement {}", path1, ioexception); } @@ -484,11 +484,11 @@ public class AllAdvancements implements IDataProvider { } public RegistryTrigger.Instance isInfinite(FlowingFluid fluid) { - return AllTriggers.INFINITE_FLUID.forEntries(fluid.getStillFluid()); + return AllTriggers.INFINITE_FLUID.forEntries(fluid.getSource()); } public InventoryChangeTrigger.Instance itemGathered(IItemProvider itemprovider) { - return InventoryChangeTrigger.Instance.forItems(itemprovider); + return InventoryChangeTrigger.Instance.hasItems(itemprovider); } static enum TaskType { @@ -516,7 +516,7 @@ public class AllAdvancements implements IDataProvider { } public Builder kinecticAdvancement(String name, Block block, TaskType type) { - return advancement(name, block, type).withCriterion("0", placeBlock(block)); + return advancement(name, block, type).addCriterion("0", placeBlock(block)); // .withCriterion("1", isPowered(block)); Duplicate toast } @@ -529,14 +529,14 @@ public class AllAdvancements implements IDataProvider { } public Builder advancement(String name, ItemStack icon, TaskType type) { - return Advancement.Builder.builder() - .withDisplay(icon, new TranslationTextComponent(LANG + name), + return Advancement.Builder.advancement() + .display(icon, new TranslationTextComponent(LANG + name), new TranslationTextComponent(LANG + name + ".desc"), null, type.frame, type.toast, type.announce, type.hide); } public Builder itemAdvancement(String name, Supplier item, TaskType type) { - return advancement(name, item.get(), type).withCriterion("0", itemGathered(item.get())); + return advancement(name, item.get(), type).addCriterion("0", itemGathered(item.get())); } } diff --git a/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java b/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java index 12ecd41c9..d3af35134 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java @@ -72,7 +72,7 @@ public class AllTriggers { Predicate playerFilter) { if (world == null) return; - if (world.isRemote()) + if (world.isClientSide()) return; List players = getPlayersInRange(world, pos, range); players.stream() @@ -81,6 +81,6 @@ public class AllTriggers { } public static List getPlayersInRange(IWorld world, BlockPos pos, int range) { - return world.getEntitiesWithinAABB(ServerPlayerEntity.class, new AxisAlignedBB(pos).grow(range)); + return world.getEntitiesOfClass(ServerPlayerEntity.class, new AxisAlignedBB(pos).inflate(range)); } } diff --git a/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java b/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java index c1acd07f4..7ebc2a596 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java @@ -21,6 +21,8 @@ import net.minecraft.advancements.criterion.EntityPredicate; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.util.ResourceLocation; +import net.minecraft.advancements.ICriterionTrigger.Listener; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public abstract class CriterionTriggerBase implements ICriterionTrigger { @@ -33,14 +35,14 @@ public abstract class CriterionTriggerBase>> listeners = Maps.newHashMap(); @Override - public void addListener(PlayerAdvancements playerAdvancementsIn, Listener listener) { + public void addPlayerListener(PlayerAdvancements playerAdvancementsIn, Listener listener) { Set> playerListeners = this.listeners.computeIfAbsent(playerAdvancementsIn, k -> new HashSet<>()); playerListeners.add(listener); } @Override - public void removeListener(PlayerAdvancements playerAdvancementsIn, Listener listener) { + public void removePlayerListener(PlayerAdvancements playerAdvancementsIn, Listener listener) { Set> playerListeners = this.listeners.get(playerAdvancementsIn); if (playerListeners != null) { playerListeners.remove(listener); @@ -51,7 +53,7 @@ public abstract class CriterionTriggerBase> list = new LinkedList<>(); for (Listener listener : playerListeners) { - if (listener.getCriterionInstance() + if (listener.getTriggerInstance() .test(suppliers)) { list.add(listener); } } - list.forEach(listener -> listener.grantCriterion(playerAdvancements)); + list.forEach(listener -> listener.run(playerAdvancements)); } } diff --git a/src/main/java/com/simibubi/create/foundation/advancement/SimpleTrigger.java b/src/main/java/com/simibubi/create/foundation/advancement/SimpleTrigger.java index 7713bf39d..49ec625e1 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/SimpleTrigger.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/SimpleTrigger.java @@ -23,7 +23,7 @@ public class SimpleTrigger extends CriterionTriggerBase } @Override - public Instance conditionsFromJson(JsonObject json, ConditionArrayParser context) { + public Instance createInstance(JsonObject json, ConditionArrayParser context) { return new Instance(getId()); } @@ -38,7 +38,7 @@ public class SimpleTrigger extends CriterionTriggerBase public static class Instance extends CriterionTriggerBase.Instance { public Instance(ResourceLocation idIn) { - super(idIn, EntityPredicate.AndPredicate.EMPTY); // FIXME: Is this right? + super(idIn, EntityPredicate.AndPredicate.ANY); // FIXME: Is this right? } @Override diff --git a/src/main/java/com/simibubi/create/foundation/advancement/StringSerializableTrigger.java b/src/main/java/com/simibubi/create/foundation/advancement/StringSerializableTrigger.java index 125e4772d..0c2c3b8fe 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/StringSerializableTrigger.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/StringSerializableTrigger.java @@ -48,7 +48,7 @@ public abstract class StringSerializableTrigger extends CriterionTriggerBase< } @Override - public Instance conditionsFromJson(JsonObject json, ConditionArrayParser context) { + public Instance createInstance(JsonObject json, ConditionArrayParser context) { if (json.has(getJsonKey())) { JsonArray elements = json.getAsJsonArray(getJsonKey()); return new Instance<>(this, StreamSupport.stream(elements.spliterator(), false) @@ -77,7 +77,7 @@ public abstract class StringSerializableTrigger extends CriterionTriggerBase< private final StringSerializableTrigger trigger; public Instance(StringSerializableTrigger trigger, @Nullable Set entries) { - super(trigger.getId(), EntityPredicate.AndPredicate.EMPTY); + super(trigger.getId(), EntityPredicate.AndPredicate.ANY); this.trigger = trigger; this.entries = entries; } @@ -91,8 +91,8 @@ public abstract class StringSerializableTrigger extends CriterionTriggerBase< } @Override - public JsonObject toJson(ConditionArraySerializer p_230240_1_) { - JsonObject jsonobject = super.toJson(p_230240_1_); + public JsonObject serializeToJson(ConditionArraySerializer p_230240_1_) { + JsonObject jsonobject = super.serializeToJson(p_230240_1_); JsonArray elements = new JsonArray(); if (entries == null) { diff --git a/src/main/java/com/simibubi/create/foundation/block/ITE.java b/src/main/java/com/simibubi/create/foundation/block/ITE.java index 16eae3ba0..f84a378ae 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ITE.java +++ b/src/main/java/com/simibubi/create/foundation/block/ITE.java @@ -31,7 +31,7 @@ public interface ITE { @Nullable @SuppressWarnings("unchecked") default T getTileEntity(IBlockReader worldIn, BlockPos pos) { - TileEntity tileEntity = worldIn.getTileEntity(pos); + TileEntity tileEntity = worldIn.getBlockEntity(pos); Class expectedClass = getTileEntityClass(); if (tileEntity == null) diff --git a/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java b/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java index 9d3dbf59b..5dfee53d8 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java +++ b/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java @@ -39,9 +39,9 @@ public class ItemUseOverrides { BlockRayTraceResult blockTrace = new BlockRayTraceResult(VecHelper.getCenterOf(event.getPos()), event.getFace(), event.getPos(), true); - ActionResultType result = state.onUse(event.getWorld(), event.getPlayer(), event.getHand(), blockTrace); + ActionResultType result = state.use(event.getWorld(), event.getPlayer(), event.getHand(), blockTrace); - if (!result.isAccepted()) + if (!result.consumesAction()) return; event.setCanceled(true); diff --git a/src/main/java/com/simibubi/create/foundation/block/ProperDirectionalBlock.java b/src/main/java/com/simibubi/create/foundation/block/ProperDirectionalBlock.java index c7e30cb34..17416492a 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ProperDirectionalBlock.java +++ b/src/main/java/com/simibubi/create/foundation/block/ProperDirectionalBlock.java @@ -12,6 +12,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; +import net.minecraft.block.AbstractBlock.Properties; + public class ProperDirectionalBlock extends DirectionalBlock implements IWrenchable { public ProperDirectionalBlock(Properties p_i48415_1_) { @@ -19,36 +21,36 @@ public class ProperDirectionalBlock extends DirectionalBlock implements IWrencha } @Override - protected void fillStateContainer(Builder builder) { + protected void createBlockStateDefinition(Builder builder) { builder.add(FACING); - super.fillStateContainer(builder); + super.createBlockStateDefinition(builder); } @Override public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) { - Direction facing = originalState.get(FACING); + Direction facing = originalState.getValue(FACING); if (facing.getAxis() == targetedFace.getAxis()) return originalState; Direction newFacing = DirectionHelper.rotateAround(facing, targetedFace.getAxis()); - return originalState.with(FACING, newFacing); + return originalState.setValue(FACING, newFacing); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - return getDefaultState().with(FACING, context.getNearestLookingDirection()); + return defaultBlockState().setValue(FACING, context.getNearestLookingDirection()); } @Override public BlockState rotate(BlockState state, Rotation rot) { - return state.with(FACING, rot.rotate(state.get(FACING))); + return state.setValue(FACING, rot.rotate(state.getValue(FACING))); } @Override public BlockState mirror(BlockState state, Mirror mirrorIn) { - return state.rotate(mirrorIn.toRotation(state.get(FACING))); + return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); } } diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java b/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java index 3ed787c7e..51971939d 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java @@ -36,11 +36,11 @@ public class CTModel extends BakedModelWrapperWithData { } void put(Direction face, int texture) { - indices[face.getIndex()] = texture; + indices[face.get3DDataValue()] = texture; } int get(Direction face) { - return indices[face.getIndex()]; + return indices[face.get3DDataValue()]; } } @@ -57,7 +57,7 @@ public class CTModel extends BakedModelWrapperWithData { protected CTData createCTData(IBlockDisplayReader world, BlockPos pos, BlockState state) { CTData data = new CTData(); for (Direction face : Iterate.directions) { - if (!Block.shouldSideBeRendered(state, world, pos, face) && !behaviour.buildContextForOccludedDirections()) + if (!Block.shouldRenderFace(state, world, pos, face) && !behaviour.buildContextForOccludedDirections()) continue; CTSpriteShiftEntry spriteShift = behaviour.get(state, face); if (spriteShift == null) @@ -81,17 +81,17 @@ public class CTModel extends BakedModelWrapperWithData { for (int i = 0; i < quads.size(); i++) { BakedQuad quad = quads.get(i); - CTSpriteShiftEntry spriteShift = behaviour.get(state, quad.getFace()); + CTSpriteShiftEntry spriteShift = behaviour.get(state, quad.getDirection()); if (spriteShift == null) continue; if (quad.getSprite() != spriteShift.getOriginal()) continue; - int index = data.get(quad.getFace()); + int index = data.get(quad.getDirection()); if (index == -1) continue; BakedQuad newQuad = QuadHelper.clone(quad); - int[] vertexData = newQuad.getVertexData(); + int[] vertexData = newQuad.getVertices(); for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) { int uvOffset = 16 / 4; diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShiftEntry.java b/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShiftEntry.java index fa99114c3..40d6bf434 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShiftEntry.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShiftEntry.java @@ -15,13 +15,13 @@ public abstract class CTSpriteShiftEntry extends SpriteShiftEntry { public float getTargetU(float localU, int index) { float uOffset = (index % textureSheetSize); - return getTarget().getInterpolatedU( + return getTarget().getU( (SuperByteBuffer.getUnInterpolatedU(getOriginal(), localU) + (uOffset * 16)) / ((float) textureSheetSize)); } public float getTargetV(float localV, int index) { float vOffset = (index / textureSheetSize); - return getTarget().getInterpolatedV( + return getTarget().getV( (SuperByteBuffer.getUnInterpolatedV(getOriginal(), localV) + (vOffset * 16)) / ((float) textureSheetSize)); } 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 4a373e8c2..e2a8f06ed 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 @@ -41,10 +41,10 @@ public abstract class ConnectedTextureBehaviour { protected boolean isBeingBlocked(BlockState state, IBlockDisplayReader reader, BlockPos pos, BlockPos otherPos, Direction face) { - BlockPos blockingPos = otherPos.offset(face); + BlockPos blockingPos = otherPos.relative(face); return face.getAxis() - .getCoordinate(pos.getX(), pos.getY(), pos.getZ()) == face.getAxis() - .getCoordinate(otherPos.getX(), otherPos.getY(), otherPos.getZ()) + .choose(pos.getX(), pos.getY(), pos.getZ()) == face.getAxis() + .choose(otherPos.getX(), otherPos.getY(), otherPos.getZ()) && connectsTo(state, reader.getBlockState(blockingPos), reader, pos, blockingPos, face); } @@ -106,8 +106,8 @@ public abstract class ConnectedTextureBehaviour { private boolean testConnection(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face, final Direction horizontal, final Direction vertical, int sh, int sv) { - BlockPos p = pos.offset(horizontal, sh) - .offset(vertical, sv); + BlockPos p = pos.relative(horizontal, sh) + .relative(vertical, sv); boolean test = connectsTo(state, reader.getBlockState(p), reader, pos, p, face); return test; } diff --git a/src/main/java/com/simibubi/create/foundation/block/render/ColoredVertexModel.java b/src/main/java/com/simibubi/create/foundation/block/render/ColoredVertexModel.java index e4be4b2ba..305e4364d 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/ColoredVertexModel.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/ColoredVertexModel.java @@ -57,7 +57,7 @@ public class ColoredVertexModel extends BakedModelWrapper { BakedQuad quad = quads.get(i); BakedQuad newQuad = QuadHelper.clone(quad); - int[] vertexData = newQuad.getVertexData(); + int[] vertexData = newQuad.getVertices(); for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) { float x = Float.intBitsToFloat(vertexData[vertex]); diff --git a/src/main/java/com/simibubi/create/foundation/block/render/QuadHelper.java b/src/main/java/com/simibubi/create/foundation/block/render/QuadHelper.java index 81ece13f1..68dc08dac 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/QuadHelper.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/QuadHelper.java @@ -9,8 +9,8 @@ public final class QuadHelper { private QuadHelper() {} public static BakedQuad clone(BakedQuad quad) { - return new BakedQuad(Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length), - quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.hasShade()); + return new BakedQuad(Arrays.copyOf(quad.getVertices(), quad.getVertices().length), + quad.getTintIndex(), quad.getDirection(), quad.getSprite(), quad.isShade()); } } diff --git a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java index c5c96b82e..dd5593034 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java @@ -20,7 +20,7 @@ public class SpriteShiftEntry { protected void loadTextures() { Function textureMap = Minecraft.getInstance() - .getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE); + .getTextureAtlas(PlayerContainer.BLOCK_ATLAS); original = textureMap.apply(originalTextureLocation); target = textureMap.apply(targetTextureLocation); } diff --git a/src/main/java/com/simibubi/create/foundation/collision/ContinuousOBBCollider.java b/src/main/java/com/simibubi/create/foundation/collision/ContinuousOBBCollider.java index ae561cf1c..8b56c8ba6 100644 --- a/src/main/java/com/simibubi/create/foundation/collision/ContinuousOBBCollider.java +++ b/src/main/java/com/simibubi/create/foundation/collision/ContinuousOBBCollider.java @@ -5,6 +5,8 @@ import static java.lang.Math.signum; import net.minecraft.util.math.vector.Vector3d; +import com.simibubi.create.foundation.collision.OBBCollider.SeparationManifold; + public class ContinuousOBBCollider extends OBBCollider { public static ContinuousSeparationManifold separateBBs(Vector3d cA, Vector3d cB, Vector3d eA, Vector3d eB, @@ -89,19 +91,19 @@ public class ContinuousOBBCollider extends OBBCollider { mf.normalSeparation = seperation; } - double dot = mf.stepSeparationAxis.dotProduct(axis); + double dot = mf.stepSeparationAxis.dot(axis); if (dot != 0 && discreteCollision) { - Vector3d cross = axis.crossProduct(mf.stepSeparationAxis); + Vector3d cross = axis.cross(mf.stepSeparationAxis); double dotSeparation = signum(dot) * TL - (rA + rB); double stepSeparation = -dotSeparation; Vector3d stepSeparationVec = axis; if (!cross.equals(Vector3d.ZERO)) { Vector3d sepVec = normalizedAxis.scale(dotSeparation); - Vector3d axisPlane = axis.crossProduct(cross); - Vector3d stepPlane = mf.stepSeparationAxis.crossProduct(cross); + Vector3d axisPlane = axis.cross(cross); + Vector3d stepPlane = mf.stepSeparationAxis.cross(cross); stepSeparationVec = - sepVec.subtract(axisPlane.scale(sepVec.dotProduct(stepPlane) / axisPlane.dotProduct(stepPlane))); + sepVec.subtract(axisPlane.scale(sepVec.dot(stepPlane) / axisPlane.dot(stepPlane))); stepSeparation = stepSeparationVec.length(); if (abs(mf.stepSeparation) > abs(stepSeparation) && stepSeparation != 0) mf.stepSeparation = stepSeparation; diff --git a/src/main/java/com/simibubi/create/foundation/collision/OrientedBB.java b/src/main/java/com/simibubi/create/foundation/collision/OrientedBB.java index 09a2d4579..2fa4c582d 100644 --- a/src/main/java/com/simibubi/create/foundation/collision/OrientedBB.java +++ b/src/main/java/com/simibubi/create/foundation/collision/OrientedBB.java @@ -41,7 +41,7 @@ public class OrientedBB { } private static Vector3d extentsFromBB(AxisAlignedBB bb) { - return new Vector3d(bb.getXSize() / 2, bb.getYSize() / 2, bb.getZSize() / 2); + return new Vector3d(bb.getXsize() / 2, bb.getYsize() / 2, bb.getZsize() / 2); } public Matrix3d getRotation() { @@ -65,8 +65,8 @@ public class OrientedBB { } public AxisAlignedBB getAsAxisAlignedBB() { - return new AxisAlignedBB(0, 0, 0, 0, 0, 0).offset(center) - .grow(extents.x, extents.y, extents.z); + return new AxisAlignedBB(0, 0, 0, 0, 0, 0).move(center) + .inflate(extents.x, extents.y, extents.z); } /* diff --git a/src/main/java/com/simibubi/create/foundation/command/AllCommands.java b/src/main/java/com/simibubi/create/foundation/command/AllCommands.java index 9f393940b..e8534da84 100644 --- a/src/main/java/com/simibubi/create/foundation/command/AllCommands.java +++ b/src/main/java/com/simibubi/create/foundation/command/AllCommands.java @@ -21,7 +21,7 @@ public class AllCommands { LiteralCommandNode util = buildUtilityCommands(); LiteralCommandNode createRoot = dispatcher.register(Commands.literal("create") - .requires(cs -> cs.hasPermissionLevel(0)) + .requires(cs -> cs.hasPermission(0)) // general purpose .then(new ToggleDebugCommand().register()) .then(FabulousWarningCommand.register()) diff --git a/src/main/java/com/simibubi/create/foundation/command/ChunkUtil.java b/src/main/java/com/simibubi/create/foundation/command/ChunkUtil.java index df7abeb39..af82ccc0a 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ChunkUtil.java +++ b/src/main/java/com/simibubi/create/foundation/command/ChunkUtil.java @@ -34,11 +34,11 @@ public class ChunkUtil { new ChunkStatus("full", ChunkStatus.HEIGHTMAPS, 0, POST_FEATURES, ChunkStatus.Type.LEVELCHUNK, (_0, _1, _2, _3, _4, future, _6, chunk) -> future.apply(chunk), (_0, _1, _2, _3, future, chunk) -> { if (markedChunks.contains(chunk.getPos() - .asLong())) { + .toLong())) { LOGGER.debug("trying to load unforced chunk " + chunk.getPos() .toString() + ", returning chunk loading error"); // this.reloadChunk(world.getChunkProvider(), chunk.getPos()); - return ChunkHolder.MISSING_CHUNK_FUTURE; + return ChunkHolder.UNLOADED_CHUNK_FUTURE; } else { // LOGGER.debug("regular, chunkStatus: " + chunk.getStatus().toString()); return future.apply(chunk); @@ -48,11 +48,11 @@ public class ChunkUtil { } public boolean reloadChunk(ServerChunkProvider provider, ChunkPos pos) { - ChunkHolder holder = provider.chunkManager.loadedChunks.remove(pos.asLong()); - provider.chunkManager.immutableLoadedChunksDirty = true; + ChunkHolder holder = provider.chunkMap.updatingChunkMap.remove(pos.toLong()); + provider.chunkMap.modified = true; if (holder != null) { - provider.chunkManager.chunksToUnload.put(pos.asLong(), holder); - provider.chunkManager.scheduleSave(pos.asLong(), holder); + provider.chunkMap.pendingUnloads.put(pos.toLong(), holder); + provider.chunkMap.scheduleUnload(pos.toLong(), holder); return true; } else { return false; @@ -60,8 +60,8 @@ public class ChunkUtil { } public boolean unloadChunk(ServerChunkProvider provider, ChunkPos pos) { - this.interestingChunks.add(pos.asLong()); - this.markedChunks.add(pos.asLong()); + this.interestingChunks.add(pos.toLong()); + this.markedChunks.add(pos.toLong()); return this.reloadChunk(provider, pos); } @@ -78,8 +78,8 @@ public class ChunkUtil { } public void reForce(ServerChunkProvider provider, ChunkPos pos) { - provider.forceChunk(pos, true); - provider.forceChunk(pos, false); + provider.updateChunkForced(pos, true); + provider.updateChunkForced(pos, false); } @SubscribeEvent @@ -87,7 +87,7 @@ public class ChunkUtil { // LOGGER.debug("Chunk Unload: " + event.getChunk().getPos().toString()); if (interestingChunks.contains(event.getChunk() .getPos() - .asLong())) { + .toLong())) { LOGGER.info("Interesting Chunk Unload: " + event.getChunk() .getPos() .toString()); @@ -100,10 +100,10 @@ public class ChunkUtil { ChunkPos pos = event.getChunk() .getPos(); - if (interestingChunks.contains(pos.asLong())) { + if (interestingChunks.contains(pos.toLong())) { LOGGER.info("Interesting Chunk Load: " + pos.toString()); - if (!markedChunks.contains(pos.asLong())) - interestingChunks.remove(pos.asLong()); + if (!markedChunks.contains(pos.toLong())) + interestingChunks.remove(pos.toLong()); } } diff --git a/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java b/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java index e999333ca..8179fbbfc 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java @@ -15,27 +15,27 @@ public class ChunkUtilCommand { public static ArgumentBuilder register() { return Commands.literal("chunk") - .requires(cs -> cs.hasPermissionLevel(2)) + .requires(cs -> cs.hasPermission(2)) .then(Commands.literal("reload") .then(Commands.argument("pos", ColumnPosArgument.columnPos()) .executes(ctx -> { // chunk reload - ColumnPos columnPos = ColumnPosArgument.fromBlockPos(ctx, "pos"); + ColumnPos columnPos = ColumnPosArgument.getColumnPos(ctx, "pos"); ChunkPos chunkPos = new ChunkPos(columnPos.x >> 4, columnPos.z >> 4); ServerChunkProvider chunkProvider = ctx.getSource() - .getWorld() - .getChunkProvider(); + .getLevel() + .getChunkSource(); boolean success = Create.CHUNK_UTIL.reloadChunk(chunkProvider, chunkPos); if (success) { ctx.getSource() - .sendFeedback(new StringTextComponent("scheduled unload for chunk " + .sendSuccess(new StringTextComponent("scheduled unload for chunk " + chunkPos.toString() + ", might need to repeat command"), true); return 1; } else { ctx.getSource() - .sendFeedback( + .sendSuccess( new StringTextComponent( "unable to schedule unload, is chunk " + chunkPos.toString() + " loaded?"), true); @@ -46,26 +46,26 @@ public class ChunkUtilCommand { .then(Commands.argument("pos", ColumnPosArgument.columnPos()) .executes(ctx -> { // chunk unload - ColumnPos columnPos = ColumnPosArgument.fromBlockPos(ctx, "pos"); + ColumnPos columnPos = ColumnPosArgument.getColumnPos(ctx, "pos"); ChunkPos chunkPos = new ChunkPos(columnPos.x >> 4, columnPos.z >> 4); ServerChunkProvider chunkProvider = ctx.getSource() - .getWorld() - .getChunkProvider(); + .getLevel() + .getChunkSource(); boolean success = Create.CHUNK_UTIL.unloadChunk(chunkProvider, chunkPos); ctx.getSource() - .sendFeedback( + .sendSuccess( new StringTextComponent("added chunk " + chunkPos.toString() + " to unload list"), true); if (success) { ctx.getSource() - .sendFeedback(new StringTextComponent("scheduled unload for chunk " + .sendSuccess(new StringTextComponent("scheduled unload for chunk " + chunkPos.toString() + ", might need to repeat command"), true); return 1; } else { ctx.getSource() - .sendFeedback( + .sendSuccess( new StringTextComponent( "unable to schedule unload, is chunk " + chunkPos.toString() + " loaded?"), true); @@ -76,10 +76,10 @@ public class ChunkUtilCommand { .executes(ctx -> { // chunk clear int count = Create.CHUNK_UTIL.clear(ctx.getSource() - .getWorld() - .getChunkProvider()); + .getLevel() + .getChunkSource()); ctx.getSource() - .sendFeedback(new StringTextComponent("removed " + count + " entries from unload list"), false); + .sendSuccess(new StringTextComponent("removed " + count + " entries from unload list"), false); return 1; })); diff --git a/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java b/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java index 3cc35646e..6161a973d 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java @@ -14,11 +14,11 @@ public class ClearBufferCacheCommand { static ArgumentBuilder register() { return Commands.literal("clearRenderBuffers") - .requires(cs -> cs.hasPermissionLevel(0)) + .requires(cs -> cs.hasPermission(0)) .executes(ctx -> { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> ClearBufferCacheCommand::execute); ctx.getSource() - .sendFeedback(new StringTextComponent("Cleared rendering buffers."), true); + .sendSuccess(new StringTextComponent("Cleared rendering buffers."), true); return 1; }); } diff --git a/src/main/java/com/simibubi/create/foundation/command/CloneCommand.java b/src/main/java/com/simibubi/create/foundation/command/CloneCommand.java index 5147a4bae..40f3a16ed 100644 --- a/src/main/java/com/simibubi/create/foundation/command/CloneCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/CloneCommand.java @@ -35,7 +35,7 @@ public class CloneCommand { public static ArgumentBuilder register() { return Commands.literal("clone") - .requires(cs -> cs.hasPermissionLevel(2)) + .requires(cs -> cs.hasPermission(2)) .then(Commands.argument("begin", BlockPosArgument.blockPos()) .then(Commands.argument("end", BlockPosArgument.blockPos()) .then(Commands.argument("destination", BlockPosArgument.blockPos()) @@ -48,7 +48,7 @@ public class CloneCommand { BlockPosArgument.getLoadedBlockPos(ctx, "destination"), true))))) .executes(ctx -> { ctx.getSource() - .sendFeedback(new StringTextComponent( + .sendSuccess(new StringTextComponent( "Clones all blocks as well as super glue from the specified area to the target destination"), true); @@ -60,28 +60,28 @@ public class CloneCommand { private static int doClone(CommandSource source, BlockPos begin, BlockPos end, BlockPos destination, boolean cloneBlocks) throws CommandSyntaxException { MutableBoundingBox sourceArea = new MutableBoundingBox(begin, end); - BlockPos destinationEnd = destination.add(sourceArea.getLength()); + BlockPos destinationEnd = destination.offset(sourceArea.getLength()); MutableBoundingBox destinationArea = new MutableBoundingBox(destination, destinationEnd); - int i = sourceArea.getXSize() * sourceArea.getYSize() * sourceArea.getZSize(); + int i = sourceArea.getXSpan() * sourceArea.getYSpan() * sourceArea.getZSpan(); if (i > 32768) throw CLONE_TOO_BIG_EXCEPTION.create(32768, i); - ServerWorld world = source.getWorld(); + ServerWorld world = source.getLevel(); - if (!world.isAreaLoaded(begin, end) || !world.isAreaLoaded(destination, destinationEnd)) - throw BlockPosArgument.POS_UNLOADED.create(); + if (!world.hasChunksAt(begin, end) || !world.hasChunksAt(destination, destinationEnd)) + throw BlockPosArgument.ERROR_NOT_LOADED.create(); - BlockPos diffToTarget = new BlockPos(destinationArea.minX - sourceArea.minX, - destinationArea.minY - sourceArea.minY, destinationArea.minZ - sourceArea.minZ); + BlockPos diffToTarget = new BlockPos(destinationArea.x0 - sourceArea.x0, + destinationArea.y0 - sourceArea.y0, destinationArea.z0 - sourceArea.z0); int blockPastes = cloneBlocks ? cloneBlocks(sourceArea, world, diffToTarget) : 0; int gluePastes = cloneGlue(sourceArea, world, diffToTarget); if (cloneBlocks) - source.sendFeedback(new StringTextComponent("Successfully cloned " + blockPastes + " Blocks"), true); + source.sendSuccess(new StringTextComponent("Successfully cloned " + blockPastes + " Blocks"), true); - source.sendFeedback(new StringTextComponent("Successfully applied glue " + gluePastes + " times"), true); + source.sendSuccess(new StringTextComponent("Successfully applied glue " + gluePastes + " times"), true); return blockPastes + gluePastes; } @@ -90,19 +90,19 @@ public class CloneCommand { int gluePastes = 0; List glue = - world.getEntitiesWithinAABB(SuperGlueEntity.class, AxisAlignedBB.func_216363_a(sourceArea)); + world.getEntitiesOfClass(SuperGlueEntity.class, AxisAlignedBB.of(sourceArea)); List> newGlue = Lists.newArrayList(); for (SuperGlueEntity g : glue) { BlockPos pos = g.getHangingPosition(); Direction direction = g.getFacingDirection(); - newGlue.add(Pair.of(pos.add(diffToTarget), direction)); + newGlue.add(Pair.of(pos.offset(diffToTarget), direction)); } for (Pair p : newGlue) { SuperGlueEntity g = new SuperGlueEntity(world, p.getFirst(), p.getSecond()); if (g.onValidSurface()) { - world.addEntity(g); + world.addFreshEntity(g); gluePastes++; } } @@ -115,16 +115,16 @@ public class CloneCommand { List blocks = Lists.newArrayList(); List tileBlocks = Lists.newArrayList(); - for (int z = sourceArea.minZ; z <= sourceArea.maxZ; ++z) { - for (int y = sourceArea.minY; y <= sourceArea.maxY; ++y) { - for (int x = sourceArea.minX; x <= sourceArea.maxX; ++x) { + for (int z = sourceArea.z0; z <= sourceArea.z1; ++z) { + for (int y = sourceArea.y0; y <= sourceArea.y1; ++y) { + for (int x = sourceArea.x0; x <= sourceArea.x1; ++x) { BlockPos currentPos = new BlockPos(x, y, z); - BlockPos newPos = currentPos.add(diffToTarget); + BlockPos newPos = currentPos.offset(diffToTarget); CachedBlockInfo cached = new CachedBlockInfo(world, currentPos, false); - BlockState state = cached.getBlockState(); - TileEntity te = world.getTileEntity(currentPos); + BlockState state = cached.getState(); + TileEntity te = world.getBlockEntity(currentPos); if (te != null) { - CompoundNBT nbt = te.write(new CompoundNBT()); + CompoundNBT nbt = te.save(new CompoundNBT()); tileBlocks.add(new Template.BlockInfo(newPos, state, nbt)); } else { blocks.add(new Template.BlockInfo(newPos, state, null)); @@ -140,36 +140,36 @@ public class CloneCommand { List reverse = Lists.reverse(allBlocks); for (Template.BlockInfo info : reverse) { - TileEntity te = world.getTileEntity(info.pos); - IClearable.clearObj(te); - world.setBlockState(info.pos, Blocks.BARRIER.getDefaultState(), 2); + TileEntity te = world.getBlockEntity(info.pos); + IClearable.tryClear(te); + world.setBlock(info.pos, Blocks.BARRIER.defaultBlockState(), 2); } for (Template.BlockInfo info : allBlocks) { - if (world.setBlockState(info.pos, info.state, 2)) + if (world.setBlock(info.pos, info.state, 2)) blockPastes++; } for (Template.BlockInfo info : tileBlocks) { - TileEntity te = world.getTileEntity(info.pos); + TileEntity te = world.getBlockEntity(info.pos); if (te != null && info.nbt != null) { info.nbt.putInt("x", info.pos.getX()); info.nbt.putInt("y", info.pos.getY()); info.nbt.putInt("z", info.pos.getZ()); - te.fromTag(info.state, info.nbt); - te.markDirty(); + te.load(info.state, info.nbt); + te.setChanged(); } // idk why the state is set twice for a te, but its done like this in the original clone command - world.setBlockState(info.pos, info.state, 2); + world.setBlock(info.pos, info.state, 2); } for (Template.BlockInfo info : reverse) { - world.updateNeighbors(info.pos, info.state.getBlock()); + world.blockUpdated(info.pos, info.state.getBlock()); } - world.getPendingBlockTicks() - .copyTicks(sourceArea, diffToTarget); + world.getBlockTicks() + .copy(sourceArea, diffToTarget); return blockPastes; } diff --git a/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java b/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java index 5115d9d6f..2ea2e7971 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java @@ -25,7 +25,7 @@ public class ConfigCommand { public static ArgumentBuilder register() { return Commands.literal("config") .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource().asPlayer(); + ServerPlayerEntity player = ctx.getSource().getPlayerOrException(); AllPackets.channel.send( PacketDistributor.PLAYER.with(() -> player), new SConfigureConfigPacket(SConfigureConfigPacket.Actions.configScreen.name(), "") @@ -35,7 +35,7 @@ public class ConfigCommand { }) .then(Commands.argument("path", StringArgumentType.string()) .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource().asPlayer(); + ServerPlayerEntity player = ctx.getSource().getPlayerOrException(); AllPackets.channel.send( PacketDistributor.PLAYER.with(() -> player), new SConfigureConfigPacket(SConfigureConfigPacket.Actions.configScreen.name(), StringArgumentType.getString(ctx, "path")) @@ -44,7 +44,7 @@ public class ConfigCommand { return Command.SINGLE_SUCCESS; }) .then(Commands.literal("set") - .requires(cs -> cs.hasPermissionLevel(2)) + .requires(cs -> cs.hasPermission(2)) .then(Commands.argument("value", StringArgumentType.string()) .executes(ctx -> { String path = StringArgumentType.getString(ctx, "path"); @@ -55,12 +55,12 @@ public class ConfigCommand { try { configPath = ConfigHelper.ConfigPath.parse(path); } catch (IllegalArgumentException e) { - ctx.getSource().sendErrorMessage(new StringTextComponent(e.getMessage())); + ctx.getSource().sendFailure(new StringTextComponent(e.getMessage())); return 0; } if (configPath.getType() == ModConfig.Type.CLIENT) { - ServerPlayerEntity player = ctx.getSource().asPlayer(); + ServerPlayerEntity player = ctx.getSource().getPlayerOrException(); AllPackets.channel.send( PacketDistributor.PLAYER.with(() -> player), new SConfigureConfigPacket("SET" + path, value) @@ -71,13 +71,13 @@ public class ConfigCommand { try { ConfigHelper.setConfigValue(configPath, value); - ctx.getSource().sendFeedback(new StringTextComponent("Great Success!"), false); + ctx.getSource().sendSuccess(new StringTextComponent("Great Success!"), false); return Command.SINGLE_SUCCESS; } catch (ConfigHelper.InvalidValueException e) { - ctx.getSource().sendErrorMessage(new StringTextComponent("Config could not be set the the specified value!")); + ctx.getSource().sendFailure(new StringTextComponent("Config could not be set the the specified value!")); return 0; } catch (Exception e) { - ctx.getSource().sendErrorMessage(new StringTextComponent("Something went wrong while trying to set config value. Check the server logs for more information")); + ctx.getSource().sendFailure(new StringTextComponent("Something went wrong while trying to set config value. Check the server logs for more information")); Create.LOGGER.warn("Exception during server-side config value set:", e); return 0; } diff --git a/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigCommand.java b/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigCommand.java index bcb8206d6..31837720d 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigCommand.java @@ -17,11 +17,11 @@ public abstract class ConfigureConfigCommand { ArgumentBuilder register() { return Commands.literal(this.commandLiteral) - .requires(cs -> cs.hasPermissionLevel(0)) + .requires(cs -> cs.hasPermission(0)) .then(Commands.literal("on") .executes(ctx -> { ServerPlayerEntity player = ctx.getSource() - .asPlayer(); + .getPlayerOrException(); sendPacket(player, String.valueOf(true)); return Command.SINGLE_SUCCESS; @@ -29,14 +29,14 @@ public abstract class ConfigureConfigCommand { .then(Commands.literal("off") .executes(ctx -> { ServerPlayerEntity player = ctx.getSource() - .asPlayer(); + .getPlayerOrException(); sendPacket(player, String.valueOf(false)); return Command.SINGLE_SUCCESS; })) .executes(ctx -> { ServerPlayerEntity player = ctx.getSource() - .asPlayer(); + .getPlayerOrException(); sendPacket(player, "info"); return Command.SINGLE_SUCCESS; diff --git a/src/main/java/com/simibubi/create/foundation/command/CouplingCommand.java b/src/main/java/com/simibubi/create/foundation/command/CouplingCommand.java index 4cec64866..38ebe6177 100644 --- a/src/main/java/com/simibubi/create/foundation/command/CouplingCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/CouplingCommand.java @@ -36,7 +36,7 @@ public class CouplingCommand { public static ArgumentBuilder register() { return Commands.literal("coupling") - .requires(cs -> cs.hasPermissionLevel(2)) + .requires(cs -> cs.hasPermission(2)) .then(Commands.literal("add") .then(Commands.argument("cart1", EntityArgument.entity()) .then(Commands.argument("cart2", EntityArgument.entity()) @@ -49,16 +49,16 @@ public class CouplingCommand { if (!(cart2 instanceof AbstractMinecartEntity)) throw ONLY_MINECARTS_ALLOWED.create(); - if (!cart1.getEntityWorld() - .equals(cart2.getEntityWorld())) + if (!cart1.getCommandSenderWorld() + .equals(cart2.getCommandSenderWorld())) throw SAME_DIMENSION.create(); Entity source = ctx.getSource() .getEntity(); CouplingHandler.tryToCoupleCarts( - source instanceof PlayerEntity ? (PlayerEntity) source : null, cart1.getEntityWorld(), - cart1.getEntityId(), cart2.getEntityId()); + source instanceof PlayerEntity ? (PlayerEntity) source : null, cart1.getCommandSenderWorld(), + cart1.getId(), cart2.getId()); return Command.SINGLE_SUCCESS; }))) @@ -77,15 +77,15 @@ public class CouplingCommand { if (!(cart2 instanceof AbstractMinecartEntity)) throw ONLY_MINECARTS_ALLOWED.create(); - if (!cart1.getEntityWorld() - .equals(cart2.getEntityWorld())) + if (!cart1.getCommandSenderWorld() + .equals(cart2.getCommandSenderWorld())) throw SAME_DIMENSION.create(); Entity source = ctx.getSource() .getEntity(); CouplingHandler.tryToCoupleCarts(source instanceof PlayerEntity ? (PlayerEntity) source : null, - cart1.getEntityWorld(), cart1.getEntityId(), cart2.getEntityId()); + cart1.getCommandSenderWorld(), cart1.getId(), cart2.getId()); return Command.SINGLE_SUCCESS; }))) @@ -105,7 +105,7 @@ public class CouplingCommand { cart1.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY); if (!cart1Capability.isPresent()) { ctx.getSource() - .sendFeedback(new StringTextComponent("Minecart has no Couplings Attached"), true); + .sendSuccess(new StringTextComponent("Minecart has no Couplings Attached"), true); return 0; } @@ -115,7 +115,7 @@ public class CouplingCommand { + (cart1Controller.isLeadingCoupling() ? 1 : 0); if (cart1Couplings == 0) { ctx.getSource() - .sendFeedback(new StringTextComponent("Minecart has no Couplings Attached"), true); + .sendSuccess(new StringTextComponent("Minecart has no Couplings Attached"), true); return 0; } @@ -124,11 +124,11 @@ public class CouplingCommand { if (coupledCart == null) continue; - if (coupledCart != cart2.getUniqueID()) + if (coupledCart != cart2.getUUID()) continue; MinecartController cart2Controller = - CapabilityMinecartController.getIfPresent(cart1.getEntityWorld(), coupledCart); + CapabilityMinecartController.getIfPresent(cart1.getCommandSenderWorld(), coupledCart); if (cart2Controller == null) return 0; @@ -138,7 +138,7 @@ public class CouplingCommand { } ctx.getSource() - .sendFeedback(new StringTextComponent("The specified Carts are not coupled"), true); + .sendSuccess(new StringTextComponent("The specified Carts are not coupled"), true); return 0; })))) @@ -153,7 +153,7 @@ public class CouplingCommand { cart.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY); if (!capability.isPresent()) { ctx.getSource() - .sendFeedback(new StringTextComponent("Minecart has no Couplings Attached"), true); + .sendSuccess(new StringTextComponent("Minecart has no Couplings Attached"), true); return 0; } @@ -163,14 +163,14 @@ public class CouplingCommand { (controller.isConnectedToCoupling() ? 1 : 0) + (controller.isLeadingCoupling() ? 1 : 0); if (couplings == 0) { ctx.getSource() - .sendFeedback(new StringTextComponent("Minecart has no Couplings Attached"), true); + .sendSuccess(new StringTextComponent("Minecart has no Couplings Attached"), true); return 0; } controller.decouple(); ctx.getSource() - .sendFeedback( + .sendSuccess( new StringTextComponent("Removed " + couplings + " couplings from the Minecart"), true); return couplings; diff --git a/src/main/java/com/simibubi/create/foundation/command/FabulousWarningCommand.java b/src/main/java/com/simibubi/create/foundation/command/FabulousWarningCommand.java index 2c03d40b0..c85496e46 100644 --- a/src/main/java/com/simibubi/create/foundation/command/FabulousWarningCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/FabulousWarningCommand.java @@ -16,7 +16,7 @@ public class FabulousWarningCommand { .requires(AllCommands.sourceIsPlayer) .executes(ctx -> { ServerPlayerEntity player = ctx.getSource() - .asPlayer(); + .getPlayerOrException(); AllPackets.channel.send( PacketDistributor.PLAYER.with(() -> player), diff --git a/src/main/java/com/simibubi/create/foundation/command/FixLightingCommand.java b/src/main/java/com/simibubi/create/foundation/command/FixLightingCommand.java index 4557c07ad..5e11d833d 100644 --- a/src/main/java/com/simibubi/create/foundation/command/FixLightingCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/FixLightingCommand.java @@ -13,14 +13,14 @@ public class FixLightingCommand { static ArgumentBuilder register() { return Commands.literal("fixLighting") - .requires(cs -> cs.hasPermissionLevel(0)) + .requires(cs -> cs.hasPermission(0)) .executes(ctx -> { AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource() .getEntity()), new SConfigureConfigPacket(SConfigureConfigPacket.Actions.fixLighting.name(), String.valueOf(true))); ctx.getSource() - .sendFeedback( + .sendSuccess( new StringTextComponent("Forge's experimental block rendering pipeline is now enabled."), true); return 1; diff --git a/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java b/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java index 2a8a1c189..a005f379f 100644 --- a/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java @@ -17,18 +17,18 @@ public class FlySpeedCommand { public static ArgumentBuilder register() { return Commands.literal("flySpeed") - .requires(cs -> cs.hasPermissionLevel(2)) + .requires(cs -> cs.hasPermission(2)) .then(Commands.argument("speed", FloatArgumentType.floatArg(0)) .then(Commands.argument("target", EntityArgument.player()) .executes(ctx -> sendFlySpeedUpdate(ctx, EntityArgument.getPlayer(ctx, "target"), FloatArgumentType.getFloat(ctx, "speed")))) .executes(ctx -> sendFlySpeedUpdate(ctx, ctx.getSource() - .asPlayer(), FloatArgumentType.getFloat(ctx, "speed")))) + .getPlayerOrException(), FloatArgumentType.getFloat(ctx, "speed")))) .then(Commands.literal("reset") .then(Commands.argument("target", EntityArgument.player()) .executes(ctx -> sendFlySpeedUpdate(ctx, EntityArgument.getPlayer(ctx, "target"), 0.05f))) .executes(ctx -> sendFlySpeedUpdate(ctx, ctx.getSource() - .asPlayer(), 0.05f)) + .getPlayerOrException(), 0.05f)) ); } @@ -36,11 +36,11 @@ public class FlySpeedCommand { private static int sendFlySpeedUpdate(CommandContext ctx, ServerPlayerEntity player, float speed) { SPlayerAbilitiesPacket packet = new SPlayerAbilitiesPacket(player.abilities); // packet.setFlySpeed(speed); - ObfuscationReflectionHelper.setPrivateValue(SPlayerAbilitiesPacket.class, packet, speed, "field_149116_e"); - player.connection.sendPacket(packet); + ObfuscationReflectionHelper.setPrivateValue(SPlayerAbilitiesPacket.class, packet, speed, "flyingSpeed"); // flyingSpeed + player.connection.send(packet); ctx.getSource() - .sendFeedback(new StringTextComponent("Temporarily set " + player.getName() + .sendSuccess(new StringTextComponent("Temporarily set " + player.getName() .getString() + "'s Flying Speed to: " + speed), true); return Command.SINGLE_SUCCESS; diff --git a/src/main/java/com/simibubi/create/foundation/command/GlueCommand.java b/src/main/java/com/simibubi/create/foundation/command/GlueCommand.java index 269d52023..c3535e5a4 100644 --- a/src/main/java/com/simibubi/create/foundation/command/GlueCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/GlueCommand.java @@ -13,17 +13,17 @@ import net.minecraft.world.server.ServerWorld; public class GlueCommand { public static ArgumentBuilder register() { return Commands.literal("glue") - .requires(cs -> cs.hasPermissionLevel(0)) + .requires(cs -> cs.hasPermission(0)) .then(Commands.argument("pos", BlockPosArgument.blockPos()) //.then(Commands.argument("direction", EnumArgument.enumArgument(Direction.class)) .executes(ctx -> { - BlockPos pos = BlockPosArgument.getBlockPos(ctx, "pos"); + BlockPos pos = BlockPosArgument.getOrLoadBlockPos(ctx, "pos"); - ServerWorld world = ctx.getSource().getWorld(); + ServerWorld world = ctx.getSource().getLevel(); SuperGlueEntity entity = new SuperGlueEntity(world, pos, Direction.UP); entity.playPlaceSound(); - world.addEntity(entity); + world.addFreshEntity(entity); return 1; })); diff --git a/src/main/java/com/simibubi/create/foundation/command/HighlightCommand.java b/src/main/java/com/simibubi/create/foundation/command/HighlightCommand.java index 2d242ee4f..44dc55900 100644 --- a/src/main/java/com/simibubi/create/foundation/command/HighlightCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/HighlightCommand.java @@ -28,12 +28,12 @@ public class HighlightCommand { public static ArgumentBuilder register() { return Commands.literal("highlight") - .requires(cs -> cs.hasPermissionLevel(0)) + .requires(cs -> cs.hasPermission(0)) .then(Commands.argument("pos", BlockPosArgument.blockPos()) .then(Commands.argument("players", EntityArgument.players()) .executes(ctx -> { Collection players = EntityArgument.getPlayers(ctx, "players"); - BlockPos pos = BlockPosArgument.getBlockPos(ctx, "pos"); + BlockPos pos = BlockPosArgument.getOrLoadBlockPos(ctx, "pos"); for (ServerPlayerEntity p : players) { AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> p), new HighlightPacket(pos)); @@ -53,14 +53,14 @@ public class HighlightCommand { // .requires(AllCommands.sourceIsPlayer) .executes(ctx -> { ServerPlayerEntity player = ctx.getSource() - .asPlayer(); + .getPlayerOrException(); return highlightAssemblyExceptionFor(player, ctx.getSource()); }); } private static void sendMissMessage(CommandSource source) { - source.sendFeedback( + source.sendSuccess( new StringTextComponent("Try looking at a Block that has failed to assemble a Contraption and try again."), true); } @@ -69,19 +69,19 @@ public class HighlightCommand { double distance = player.getAttribute(ForgeMod.REACH_DISTANCE.get()) .getValue(); Vector3d start = player.getEyePosition(1); - Vector3d look = player.getLook(1); + Vector3d look = player.getViewVector(1); Vector3d end = start.add(look.x * distance, look.y * distance, look.z * distance); - World world = player.world; + World world = player.level; - BlockRayTraceResult ray = world.rayTraceBlocks( + BlockRayTraceResult ray = world.clip( new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player)); if (ray.getType() == RayTraceResult.Type.MISS) { sendMissMessage(source); return 0; } - BlockPos pos = ray.getPos(); - TileEntity te = world.getTileEntity(pos); + BlockPos pos = ray.getBlockPos(); + TileEntity te = world.getBlockEntity(pos); if (!(te instanceof IDisplayAssemblyExceptions)) { sendMissMessage(source); return 0; @@ -95,13 +95,13 @@ public class HighlightCommand { } if (!exception.hasPosition()) { - source.sendFeedback(new StringTextComponent("Can't highlight a specific position for this issue"), true); + source.sendSuccess(new StringTextComponent("Can't highlight a specific position for this issue"), true); return Command.SINGLE_SUCCESS; } BlockPos p = exception.getPosition(); String command = "/create highlight " + p.getX() + " " + p.getY() + " " + p.getZ(); - return player.server.getCommandManager() - .handleCommand(source, command); + return player.server.getCommands() + .performCommand(source, command); } } diff --git a/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java b/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java index 900e250fe..61422c598 100644 --- a/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java +++ b/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java @@ -24,12 +24,12 @@ public class HighlightPacket extends SimplePacketBase { } public HighlightPacket(PacketBuffer buffer) { - this.pos = BlockPos.fromLong(buffer.readLong()); + this.pos = BlockPos.of(buffer.readLong()); } @Override public void write(PacketBuffer buffer) { - buffer.writeLong(pos.toLong()); + buffer.writeLong(pos.asLong()); } @Override @@ -45,12 +45,12 @@ public class HighlightPacket extends SimplePacketBase { @OnlyIn(Dist.CLIENT) public static void performHighlight(BlockPos pos) { - if (Minecraft.getInstance().world == null || !Minecraft.getInstance().world.isBlockPresent(pos)) + if (Minecraft.getInstance().level == null || !Minecraft.getInstance().level.isLoaded(pos)) return; - CreateClient.OUTLINER.showAABB("highlightCommand", VoxelShapes.fullCube() - .getBoundingBox() - .offset(pos), 200) + CreateClient.OUTLINER.showAABB("highlightCommand", VoxelShapes.block() + .bounds() + .move(pos), 200) .lineWidth(1 / 32f) .colored(0xEeEeEe) // .colored(0x243B50) diff --git a/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java b/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java index 46e18f681..366e83196 100644 --- a/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java @@ -12,19 +12,19 @@ public class KillTPSCommand { public static ArgumentBuilder register() { return Commands.literal("killtps") - .requires(cs -> cs.hasPermissionLevel(2)) + .requires(cs -> cs.hasPermission(2)) .executes(ctx -> { // killtps no arguments ctx.getSource() - .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.0", + .sendSuccess(Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.0", Create.LAGGER.isLagging() ? Create.LAGGER.getTickTime() : 0), true); if (Create.LAGGER.isLagging()) ctx.getSource() - .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), + .sendSuccess(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), true); else ctx.getSource() - .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.1"), + .sendSuccess(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.1"), true); return 1; @@ -36,35 +36,35 @@ public class KillTPSCommand { if (tickTime > 0) { Create.LAGGER.setLagging(true); ctx.getSource() - .sendFeedback((Lang + .sendSuccess((Lang .createTranslationTextComponent("command.killTPSCommand.status.slowed_by.1", tickTime)), true); ctx.getSource() - .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), + .sendSuccess(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), true); } else { ctx.getSource() - .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.1"), + .sendSuccess(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.1"), true); } return 1; }) .then(Commands.argument(Lang.translate("command.killTPSCommand.argument.tickTime") - .getUnformattedComponentText(), IntegerArgumentType.integer(1)) + .getContents(), IntegerArgumentType.integer(1)) .executes(ctx -> { // killtps start tickTime int tickTime = IntegerArgumentType.getInteger(ctx, Lang.translate("command.killTPSCommand.argument.tickTime") - .getUnformattedComponentText()); + .getContents()); Create.LAGGER.setTickTime(tickTime); Create.LAGGER.setLagging(true); ctx.getSource() - .sendFeedback((Lang + .sendSuccess((Lang .createTranslationTextComponent("command.killTPSCommand.status.slowed_by.1", tickTime)), true); ctx.getSource() - .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), + .sendSuccess(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), true); return 1; @@ -74,7 +74,7 @@ public class KillTPSCommand { // killtps stop Create.LAGGER.setLagging(false); ctx.getSource() - .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.2"), + .sendSuccess(Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.2"), false); return 1; diff --git a/src/main/java/com/simibubi/create/foundation/command/OverlayConfigCommand.java b/src/main/java/com/simibubi/create/foundation/command/OverlayConfigCommand.java index 034746d58..e7479a2a6 100644 --- a/src/main/java/com/simibubi/create/foundation/command/OverlayConfigCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/OverlayConfigCommand.java @@ -15,7 +15,7 @@ public class OverlayConfigCommand { public static ArgumentBuilder register() { return Commands.literal("overlay") - .requires(cs -> cs.hasPermissionLevel(0)) + .requires(cs -> cs.hasPermission(0)) .then(Commands.literal("reset") .executes(ctx -> { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> SConfigureConfigPacket.Actions.overlayReset.performAction("")); @@ -26,7 +26,7 @@ public class OverlayConfigCommand { new SConfigureConfigPacket(SConfigureConfigPacket.Actions.overlayReset.name(), ""))); ctx.getSource() - .sendFeedback(new StringTextComponent("reset overlay offset"), true); + .sendSuccess(new StringTextComponent("reset overlay offset"), true); return 1; }) @@ -40,7 +40,7 @@ public class OverlayConfigCommand { new SConfigureConfigPacket(SConfigureConfigPacket.Actions.overlayScreen.name(), ""))); ctx.getSource() - .sendFeedback(new StringTextComponent("window opened"), true); + .sendSuccess(new StringTextComponent("window opened"), true); return 1; }); 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 70d353a64..ea174394b 100644 --- a/src/main/java/com/simibubi/create/foundation/command/PonderCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/PonderCommand.java @@ -21,18 +21,18 @@ import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.network.PacketDistributor; public class PonderCommand { - public static final SuggestionProvider ITEM_PONDERS = SuggestionProviders.register(new ResourceLocation("all_ponders"), (iSuggestionProviderCommandContext, builder) -> ISuggestionProvider.func_212476_a(PonderRegistry.all.keySet().stream(), builder)); + public static final SuggestionProvider ITEM_PONDERS = SuggestionProviders.register(new ResourceLocation("all_ponders"), (iSuggestionProviderCommandContext, builder) -> ISuggestionProvider.suggestResource(PonderRegistry.all.keySet().stream(), builder)); static ArgumentBuilder register() { return Commands.literal("ponder") - .requires(cs -> cs.hasPermissionLevel(0)) - .executes(ctx -> openScene("index", ctx.getSource().asPlayer())) - .then(Commands.argument("scene", ResourceLocationArgument.resourceLocation()) + .requires(cs -> cs.hasPermission(0)) + .executes(ctx -> openScene("index", ctx.getSource().getPlayerOrException())) + .then(Commands.argument("scene", ResourceLocationArgument.id()) .suggests(ITEM_PONDERS) - .executes(ctx -> openScene(ResourceLocationArgument.getResourceLocation(ctx, "scene").toString(), ctx.getSource().asPlayer())) + .executes(ctx -> openScene(ResourceLocationArgument.getId(ctx, "scene").toString(), ctx.getSource().getPlayerOrException())) .then(Commands.argument("targets", EntityArgument.players()) - .requires(cs -> cs.hasPermissionLevel(2)) - .executes(ctx -> openScene(ResourceLocationArgument.getResourceLocation(ctx, "scene").toString(), EntityArgument.getPlayers(ctx, "targets"))) + .requires(cs -> cs.hasPermission(2)) + .executes(ctx -> openScene(ResourceLocationArgument.getId(ctx, "scene").toString(), EntityArgument.getPlayers(ctx, "targets"))) ) ); diff --git a/src/main/java/com/simibubi/create/foundation/command/ReplaceInCommandBlocksCommand.java b/src/main/java/com/simibubi/create/foundation/command/ReplaceInCommandBlocksCommand.java index 7a7e136e6..02f62bcc5 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ReplaceInCommandBlocksCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ReplaceInCommandBlocksCommand.java @@ -21,7 +21,7 @@ public class ReplaceInCommandBlocksCommand { public static ArgumentBuilder register() { return Commands.literal("replaceInCommandBlocks") - .requires(cs -> cs.hasPermissionLevel(0)) + .requires(cs -> cs.hasPermission(0)) .then(Commands.argument("begin", BlockPosArgument.blockPos()) .then(Commands.argument("end", BlockPosArgument.blockPos()) .then(Commands.argument("toReplace", StringArgumentType.string()) @@ -38,31 +38,31 @@ public class ReplaceInCommandBlocksCommand { private static void doReplace(CommandSource source, BlockPos from, BlockPos to, String toReplace, String replaceWith) { - ServerWorld world = source.getWorld(); + ServerWorld world = source.getLevel(); MutableInt blocks = new MutableInt(0); - BlockPos.getAllInBox(from, to) + BlockPos.betweenClosedStream(from, to) .forEach(pos -> { BlockState blockState = world.getBlockState(pos); if (!(blockState.getBlock() instanceof CommandBlockBlock)) return; - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (!(tileEntity instanceof CommandBlockTileEntity)) return; CommandBlockTileEntity cb = (CommandBlockTileEntity) tileEntity; - CommandBlockLogic commandBlockLogic = cb.getCommandBlockLogic(); + CommandBlockLogic commandBlockLogic = cb.getCommandBlock(); String command = commandBlockLogic.getCommand(); if (command.indexOf(toReplace) != -1) blocks.increment(); commandBlockLogic.setCommand(command.replaceAll(toReplace, replaceWith)); - cb.markDirty(); - world.notifyBlockUpdate(pos, blockState, blockState, 2); + cb.setChanged(); + world.sendBlockUpdated(pos, blockState, blockState, 2); }); int intValue = blocks.intValue(); if (intValue == 0) { - source.sendFeedback(new StringTextComponent("Couldn't find \"" + toReplace + "\" anywhere."), true); + source.sendSuccess(new StringTextComponent("Couldn't find \"" + toReplace + "\" anywhere."), true); return; } - source.sendFeedback(new StringTextComponent("Replaced occurrences in " + intValue + " blocks."), true); + source.sendSuccess(new StringTextComponent("Replaced occurrences in " + intValue + " blocks."), true); } } diff --git a/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java b/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java index 73ffd6168..192321c33 100644 --- a/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java @@ -44,14 +44,14 @@ public class SConfigureConfigPacket extends SimplePacketBase { } public SConfigureConfigPacket(PacketBuffer buffer) { - this.option = buffer.readString(32767); - this.value = buffer.readString(32767); + this.option = buffer.readUtf(32767); + this.value = buffer.readUtf(32767); } @Override public void write(PacketBuffer buffer) { - buffer.writeString(option); - buffer.writeString(value); + buffer.writeUtf(option); + buffer.writeUtf(value); } @Override @@ -85,7 +85,7 @@ public class SConfigureConfigPacket extends SimplePacketBase { try { configPath = ConfigHelper.ConfigPath.parse(option); } catch (IllegalArgumentException e) { - player.sendStatusMessage(new StringTextComponent(e.getMessage()), false); + player.displayClientMessage(new StringTextComponent(e.getMessage()), false); return; } @@ -96,11 +96,11 @@ public class SConfigureConfigPacket extends SimplePacketBase { try { ConfigHelper.setConfigValue(configPath, value); - player.sendStatusMessage(new StringTextComponent("Great Success!"), false); + player.displayClientMessage(new StringTextComponent("Great Success!"), false); } catch (ConfigHelper.InvalidValueException e) { - player.sendStatusMessage(new StringTextComponent("Config could not be set the the specified value!"), false); + player.displayClientMessage(new StringTextComponent("Config could not be set the the specified value!"), false); } catch (Exception e) { - player.sendStatusMessage(new StringTextComponent("Something went wrong while trying to set config value. Check the client logs for more information"), false); + player.displayClientMessage(new StringTextComponent("Something went wrong while trying to set config value. Check the client logs for more information"), false); Create.LOGGER.warn("Exception during client-side config value set:", e); } @@ -140,14 +140,14 @@ public class SConfigureConfigPacket extends SimplePacketBase { try { configPath = ConfigHelper.ConfigPath.parse(value); } catch (IllegalArgumentException e) { - player.sendStatusMessage(new StringTextComponent(e.getMessage()), false); + player.displayClientMessage(new StringTextComponent(e.getMessage()), false); return; } try { ScreenOpener.open(SubMenuConfigScreen.find(configPath)); } catch (Exception e) { - player.sendStatusMessage(new StringTextComponent("Unable to find the specified config"), false); + player.displayClientMessage(new StringTextComponent("Unable to find the specified config"), false); } } @@ -160,14 +160,14 @@ public class SConfigureConfigPacket extends SimplePacketBase { if (value.equals("info")) { ITextComponent text = new StringTextComponent("Rainbow Debug Utility is currently: ") .append(boolToText(AllConfigs.CLIENT.rainbowDebug.get())); - player.sendStatusMessage(text, false); + player.displayClientMessage(text, false); return; } AllConfigs.CLIENT.rainbowDebug.set(Boolean.parseBoolean(value)); ITextComponent text = boolToText(AllConfigs.CLIENT.rainbowDebug.get()) - .append(new StringTextComponent(" Rainbow Debug Utility").formatted(TextFormatting.WHITE)); - player.sendStatusMessage(text, false); + .append(new StringTextComponent(" Rainbow Debug Utility").withStyle(TextFormatting.WHITE)); + player.displayClientMessage(text, false); } @OnlyIn(Dist.CLIENT) @@ -184,7 +184,7 @@ public class SConfigureConfigPacket extends SimplePacketBase { @OnlyIn(Dist.CLIENT) private static void experimentalLighting(String value) { ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled.set(true); - Minecraft.getInstance().worldRenderer.loadRenderers(); + Minecraft.getInstance().levelRenderer.allChanged(); } @OnlyIn(Dist.CLIENT) @@ -207,14 +207,14 @@ public class SConfigureConfigPacket extends SimplePacketBase { @OnlyIn(Dist.CLIENT) private static void fabulousWarning(String value) { AllConfigs.CLIENT.ignoreFabulousWarning.set(true); - Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.CHAT, + Minecraft.getInstance().gui.handleChat(ChatType.CHAT, new StringTextComponent("Disabled Fabulous graphics warning"), - Minecraft.getInstance().player.getUniqueID()); + Minecraft.getInstance().player.getUUID()); } private static IFormattableTextComponent boolToText(boolean b) { - return b ? new StringTextComponent("enabled").formatted(TextFormatting.DARK_GREEN) - : new StringTextComponent("disabled").formatted(TextFormatting.RED); + return b ? new StringTextComponent("enabled").withStyle(TextFormatting.DARK_GREEN) + : new StringTextComponent("disabled").withStyle(TextFormatting.RED); } } } diff --git a/src/main/java/com/simibubi/create/foundation/config/CClient.java b/src/main/java/com/simibubi/create/foundation/config/CClient.java index bea229d1e..c54d8ad82 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CClient.java +++ b/src/main/java/com/simibubi/create/foundation/config/CClient.java @@ -1,4 +1,10 @@ package com.simibubi.create.foundation.config; +import com.simibubi.create.foundation.config.ConfigBase.ConfigBool; +import com.simibubi.create.foundation.config.ConfigBase.ConfigEnum; +import com.simibubi.create.foundation.config.ConfigBase.ConfigFloat; +import com.simibubi.create.foundation.config.ConfigBase.ConfigGroup; +import com.simibubi.create.foundation.config.ConfigBase.ConfigInt; + public class CClient extends ConfigBase { diff --git a/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java b/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java index 2ba15eaea..e1e5840c5 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java +++ b/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java @@ -1,4 +1,6 @@ package com.simibubi.create.foundation.config; +import com.simibubi.create.foundation.config.ConfigBase.ConfigInt; + public class CCuriosities extends ConfigBase { diff --git a/src/main/java/com/simibubi/create/foundation/config/CFluids.java b/src/main/java/com/simibubi/create/foundation/config/CFluids.java index ad8684da1..1c546399e 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CFluids.java +++ b/src/main/java/com/simibubi/create/foundation/config/CFluids.java @@ -1,4 +1,6 @@ package com.simibubi.create.foundation.config; +import com.simibubi.create.foundation.config.ConfigBase.ConfigInt; + public class CFluids extends ConfigBase { diff --git a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java index b5fe5002d..d4cf51867 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java @@ -1,4 +1,10 @@ package com.simibubi.create.foundation.config; +import com.simibubi.create.foundation.config.ConfigBase.ConfigBool; +import com.simibubi.create.foundation.config.ConfigBase.ConfigEnum; +import com.simibubi.create.foundation.config.ConfigBase.ConfigFloat; +import com.simibubi.create.foundation.config.ConfigBase.ConfigGroup; +import com.simibubi.create.foundation.config.ConfigBase.ConfigInt; + public class CKinetics extends ConfigBase { diff --git a/src/main/java/com/simibubi/create/foundation/config/CLogistics.java b/src/main/java/com/simibubi/create/foundation/config/CLogistics.java index 33e4333cb..76fbeced0 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CLogistics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CLogistics.java @@ -1,4 +1,6 @@ package com.simibubi.create.foundation.config; +import com.simibubi.create.foundation.config.ConfigBase.ConfigInt; + public class CLogistics extends ConfigBase { diff --git a/src/main/java/com/simibubi/create/foundation/config/CRecipes.java b/src/main/java/com/simibubi/create/foundation/config/CRecipes.java index 86531dcb6..fabba448b 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CRecipes.java +++ b/src/main/java/com/simibubi/create/foundation/config/CRecipes.java @@ -1,4 +1,7 @@ package com.simibubi.create.foundation.config; +import com.simibubi.create.foundation.config.ConfigBase.ConfigBool; +import com.simibubi.create.foundation.config.ConfigBase.ConfigInt; + public class CRecipes extends ConfigBase { diff --git a/src/main/java/com/simibubi/create/foundation/config/CSchematics.java b/src/main/java/com/simibubi/create/foundation/config/CSchematics.java index 21a38ef34..445ca9a2d 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CSchematics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CSchematics.java @@ -1,4 +1,8 @@ package com.simibubi.create.foundation.config; +import com.simibubi.create.foundation.config.ConfigBase.ConfigFloat; +import com.simibubi.create.foundation.config.ConfigBase.ConfigGroup; +import com.simibubi.create.foundation.config.ConfigBase.ConfigInt; + public class CSchematics extends ConfigBase { diff --git a/src/main/java/com/simibubi/create/foundation/config/CServer.java b/src/main/java/com/simibubi/create/foundation/config/CServer.java index e5cf81cfd..ddac01277 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CServer.java +++ b/src/main/java/com/simibubi/create/foundation/config/CServer.java @@ -1,4 +1,7 @@ package com.simibubi.create.foundation.config; +import com.simibubi.create.foundation.config.ConfigBase.ConfigGroup; +import com.simibubi.create.foundation.config.ConfigBase.ConfigInt; + public class CServer extends ConfigBase { diff --git a/src/main/java/com/simibubi/create/foundation/config/CWorldGen.java b/src/main/java/com/simibubi/create/foundation/config/CWorldGen.java index f90afb0a0..f1aa768c3 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CWorldGen.java +++ b/src/main/java/com/simibubi/create/foundation/config/CWorldGen.java @@ -4,6 +4,8 @@ import com.simibubi.create.foundation.worldgen.AllWorldFeatures; import net.minecraftforge.common.ForgeConfigSpec.Builder; +import com.simibubi.create.foundation.config.ConfigBase.ConfigBool; + public class CWorldGen extends ConfigBase { public ConfigBool disable = b(false, "disableWorldGen", Comments.disable); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java index cb2e3401b..eb551320e 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java @@ -117,7 +117,7 @@ public class BaseConfigScreen extends ConfigScreen { super.init(); returnOnClose = true; - TextStencilElement clientText = new TextStencilElement(client.fontRenderer, new StringTextComponent(clientTile)).centered(true, true); + TextStencilElement clientText = new TextStencilElement(minecraft.font, new StringTextComponent(clientTile)).centered(true, true); widgets.add(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16).showingElement(clientText)); if (clientSpec != null) { @@ -129,7 +129,7 @@ public class BaseConfigScreen extends ConfigScreen { clientText.withElementRenderer(DISABLED_RENDERER); } - TextStencilElement commonText = new TextStencilElement(client.fontRenderer, new StringTextComponent(commonTile)).centered(true, true); + TextStencilElement commonText = new TextStencilElement(minecraft.font, new StringTextComponent(commonTile)).centered(true, true); widgets.add(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 16).showingElement(commonText)); if (commonSpec != null) { @@ -141,14 +141,14 @@ public class BaseConfigScreen extends ConfigScreen { commonText.withElementRenderer(DISABLED_RENDERER); } - TextStencilElement serverText = new TextStencilElement(client.fontRenderer, new StringTextComponent(serverTile)).centered(true, true); + TextStencilElement serverText = new TextStencilElement(minecraft.font, new StringTextComponent(serverTile)).centered(true, true); widgets.add(serverConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 + 30, 200, 16).showingElement(serverText)); if (serverSpec == null) { serverConfigWidget.active = false; serverConfigWidget.updateColorsFromState(); serverText.withElementRenderer(DISABLED_RENDERER); - } else if (Minecraft.getInstance().world == null) { + } else if (Minecraft.getInstance().level == null) { serverText.withElementRenderer(DISABLED_RENDERER); serverConfigWidget.getToolTip() .add(new StringTextComponent("Stored individually per World")); @@ -162,7 +162,7 @@ public class BaseConfigScreen extends ConfigScreen { serverText.withElementRenderer(BoxWidget.gradientFactory.apply(serverConfigWidget)); } - TextStencilElement titleText = new TextStencilElement(client.fontRenderer, modID.toUpperCase(Locale.ROOT)) + TextStencilElement titleText = new TextStencilElement(minecraft.font, modID.toUpperCase(Locale.ROOT)) .centered(true, true) .withElementRenderer((ms, w, h, alpha) -> { UIRenderHelper.angledGradient(ms, 0, 0, h / 2, h, w / 2, Theme.p(Theme.Key.CONFIG_TITLE_A)); @@ -195,7 +195,7 @@ public class BaseConfigScreen extends ConfigScreen { @Override protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - drawCenteredString(ms, client.fontRenderer, "Access Configs for Mod:", width / 2, height / 2 - 105, Theme.i(Theme.Key.TEXT_ACCENT_STRONG)); + drawCenteredString(ms, minecraft.font, "Access Configs for Mod:", width / 2, height / 2 - 105, Theme.i(Theme.Key.TEXT_ACCENT_STRONG)); } private void linkTo(Screen screen) { diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java b/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java index b472b0a70..3def1c55e 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java @@ -25,16 +25,16 @@ public class CConfigureConfigPacket extends SimplePacketBase { } public CConfigureConfigPacket(PacketBuffer buffer) { - this.modID = buffer.readString(32767); - this.path = buffer.readString(32767); - this.value = buffer.readString(32767); + this.modID = buffer.readUtf(32767); + this.path = buffer.readUtf(32767); + this.value = buffer.readUtf(32767); } @Override public void write(PacketBuffer buffer) { - buffer.writeString(modID); - buffer.writeString(path); - buffer.writeString(value); + buffer.writeUtf(modID); + buffer.writeUtf(path); + buffer.writeUtf(value); } @Override @@ -42,7 +42,7 @@ public class CConfigureConfigPacket extends SimplePacketBase { context.get().enqueueWork(() -> { try { ServerPlayerEntity sender = context.get().getSender(); - if (sender == null || !sender.hasPermissionLevel(2)) + if (sender == null || !sender.hasPermissions(2)) return; ForgeConfigSpec spec = ConfigHelper.findConfigSpecFor(ModConfig.Type.SERVER, modID); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java index 475ac2db8..797c4758f 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java @@ -53,7 +53,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { public static final Map> backgrounds = new HashMap<>(); public static final PhysicalFloat cogSpin = PhysicalFloat.create().withLimit(10f).withDrag(0.3).addForce(new Force.Static(.2f)); - public static final BlockState cogwheelState = AllBlocks.LARGE_COGWHEEL.getDefaultState().with(CogWheelBlock.AXIS, Direction.Axis.Y); + public static final BlockState cogwheelState = AllBlocks.LARGE_COGWHEEL.getDefaultState().setValue(CogWheelBlock.AXIS, Direction.Axis.Y); public static final Map changes = new HashMap<>(); public static String modID = null; protected final Screen parent; @@ -75,7 +75,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { @Override protected void renderWindowBackground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - if (this.client != null && this.client.world != null) { + if (this.minecraft != null && this.minecraft.level != null) { //in game fill(ms, 0, 0, this.width, this.height, 0xb0_282c34); } else { @@ -102,14 +102,14 @@ public abstract class ConfigScreen extends AbstractSimiScreen { @Override protected void prepareFrame() { Framebuffer thisBuffer = UIRenderHelper.framebuffer; - Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); + Framebuffer mainBuffer = Minecraft.getInstance().getMainRenderTarget(); GlCompat functions = Backend.getInstance().compat; - functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.framebufferObject); - functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, thisBuffer.framebufferObject); - functions.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); + functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.frameBufferId); + functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, thisBuffer.frameBufferId); + functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); - functions.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, thisBuffer.framebufferObject); + functions.fbo.bindFramebuffer(FramebufferConstants.GL_FRAMEBUFFER, thisBuffer.frameBufferId); GL11.glClear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT); } @@ -118,14 +118,14 @@ public abstract class ConfigScreen extends AbstractSimiScreen { protected void endFrame() { Framebuffer thisBuffer = UIRenderHelper.framebuffer; - Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); + Framebuffer mainBuffer = Minecraft.getInstance().getMainRenderTarget(); GlCompat functions = Backend.getInstance().compat; - functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.framebufferObject); - functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject); - functions.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); + functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.frameBufferId); + functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.frameBufferId); + functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); - functions.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject); + functions.fbo.bindFramebuffer(FramebufferConstants.GL_FRAMEBUFFER, mainBuffer.frameBufferId); } @Override @@ -164,19 +164,19 @@ public abstract class ConfigScreen extends AbstractSimiScreen { return; } - float elapsedPartials = client.getTickLength(); + float elapsedPartials = minecraft.getDeltaFrameTime(); CreateMainMenuScreen.panorama.render(elapsedPartials, 1); - client.getTextureManager().bindTexture(CreateMainMenuScreen.PANORAMA_OVERLAY_TEXTURES); + minecraft.getTextureManager().bind(CreateMainMenuScreen.PANORAMA_OVERLAY_TEXTURES); RenderSystem.enableBlend(); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - drawTexture(ms, 0, 0, this.width, this.height, 0.0F, 0.0F, 16, 128, 16, 128); + blit(ms, 0, 0, this.width, this.height, 0.0F, 0.0F, 16, 128, 16, 128); fill(ms, 0, 0, this.width, this.height, 0x90_282c34); } protected void renderCog(MatrixStack ms, float partialTicks) { - ms.push(); + ms.pushPose(); ms.translate(-100, 100, -100); ms.scale(200, 200, 1); @@ -184,6 +184,6 @@ public abstract class ConfigScreen extends AbstractSimiScreen { .rotateBlock(22.5, cogSpin.getValue(partialTicks), 22.5) .render(ms); - ms.pop(); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java index 2b01b9647..1a7f4e105 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java @@ -31,8 +31,8 @@ public class ConfigScreenList extends ExtendedList { public ConfigScreenList(Minecraft client, int width, int height, int top, int bottom, int elementHeight) { super(client, width, height, top, bottom, elementHeight); - func_244605_b(false); - func_244606_c(false); + setRenderBackground(false); + setRenderTopAndBottom(false); setRenderSelection(false); currentText = null; headerHeight = 3; @@ -40,10 +40,10 @@ public class ConfigScreenList extends ExtendedList { @Override public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - UIRenderHelper.angledGradient(ms, 90, left + width / 2, top, width, 5, 0x60_000000, 0x0); - UIRenderHelper.angledGradient(ms, -90, left + width / 2, bottom, width, 5, 0x60_000000, 0x0); - UIRenderHelper.angledGradient(ms, 0, left, top + height / 2, height, 5, 0x60_000000, 0x0); - UIRenderHelper.angledGradient(ms, 180, right, top + height / 2, height, 5, 0x60_000000, 0x0); + UIRenderHelper.angledGradient(ms, 90, x0 + width / 2, y0, width, 5, 0x60_000000, 0x0); + UIRenderHelper.angledGradient(ms, -90, x0 + width / 2, y1, width, 5, 0x60_000000, 0x0); + UIRenderHelper.angledGradient(ms, 0, x0, y0 + height / 2, height, 5, 0x60_000000, 0x0); + UIRenderHelper.angledGradient(ms, 180, x1, y0 + height / 2, height, 5, 0x60_000000, 0x0); super.render(ms, mouseX, mouseY, partialTicks); } @@ -51,8 +51,8 @@ public class ConfigScreenList extends ExtendedList { @Override protected void renderList(MatrixStack p_238478_1_, int p_238478_2_, int p_238478_3_, int p_238478_4_, int p_238478_5_, float p_238478_6_) { MainWindow window = Minecraft.getInstance().getWindow(); - double d0 = window.getGuiScaleFactor(); - RenderSystem.enableScissor((int) (this.left * d0), (int) (window.getFramebufferHeight() - (this.bottom * d0)), (int) (this.width * d0), (int) (this.height * d0)); + double d0 = window.getGuiScale(); + RenderSystem.enableScissor((int) (this.x0 * d0), (int) (window.getHeight() - (this.y1 * d0)), (int) (this.width * d0), (int) (this.height * d0)); super.renderList(p_238478_1_, p_238478_2_, p_238478_3_, p_238478_4_, p_238478_5_, p_238478_6_); RenderSystem.disableScissor(); } @@ -70,15 +70,15 @@ public class ConfigScreenList extends ExtendedList { } @Override - protected int getScrollbarPositionX() { - return left + this.width - 6; + protected int getScrollbarPosition() { + return x0 + this.width - 6; } public void tick() { for(int i = 0; i < getItemCount(); ++i) { int top = this.getRowTop(i); int bot = top + itemHeight; - if (bot >= this.top && top <= this.bottom) + if (bot >= this.y0 && top <= this.y1) this.getEntry(i).tick(); } @@ -128,7 +128,7 @@ public class ConfigScreenList extends ExtendedList { protected String unit = null; public LabeledEntry(String label) { - this.label = new TextStencilElement(Minecraft.getInstance().fontRenderer, label); + this.label = new TextStencilElement(Minecraft.getInstance().font, label); this.label.withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, height, width, Theme.p(Theme.Key.TEXT_ACCENT_STRONG))); labelTooltip = new ArrayList<>(); } @@ -138,12 +138,12 @@ public class ConfigScreenList extends ExtendedList { UIRenderHelper.streak(ms, 0, x - 10, y + height / 2, height - 6, width / 8 * 7, 0xdd_000000); UIRenderHelper.streak(ms, 180, x + (int) (width * 1.35f) + 10, y + height / 2, height - 6, width / 8 * 7, 0xdd_000000); IFormattableTextComponent component = label.getComponent(); - FontRenderer font = Minecraft.getInstance().fontRenderer; - if (font.getWidth(component) > getLabelWidth(width) - 10) { - label.withText(font.trimToWidth(component, getLabelWidth(width) - 15).getString() + "..."); + FontRenderer font = Minecraft.getInstance().font; + if (font.width(component) > getLabelWidth(width) - 10) { + label.withText(font.substrByWidth(component, getLabelWidth(width) - 15).getString() + "..."); } if (unit != null) { - int unitWidth = font.getStringWidth(unit); + int unitWidth = font.width(unit); font.draw(ms, unit, x + getLabelWidth(width) - unitWidth - 5, y + height / 2 + 2, Theme.i(Theme.Key.TEXT_DARKER)); label.at(x + 10, y + height / 2 - 10, 0).render(ms); } else { @@ -157,11 +157,11 @@ public class ConfigScreenList extends ExtendedList { return; GL11.glDisable(GL11.GL_SCISSOR_TEST); - Screen screen = Minecraft.getInstance().currentScreen; - ms.push(); + Screen screen = Minecraft.getInstance().screen; + ms.pushPose(); ms.translate(0, 0, 400); GuiUtils.drawHoveringText(ms, tooltip, mouseX, mouseY, screen.width, screen.height, 300, font); - ms.pop(); + ms.popPose(); GL11.glEnable(GL11.GL_SCISSOR_TEST); } } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigTextField.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigTextField.java index efa5d886d..e00b8638a 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigTextField.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigTextField.java @@ -16,8 +16,8 @@ public class ConfigTextField extends TextFieldWidget { } @Override - public void setFocused2(boolean focus) { - super.setFocused2(focus); + public void setFocus(boolean focus) { + super.setFocus(focus); if (!focus) { if (ConfigScreenList.currentText == this) @@ -27,7 +27,7 @@ public class ConfigTextField extends TextFieldWidget { } if (ConfigScreenList.currentText != null && ConfigScreenList.currentText != this) - ConfigScreenList.currentText.setFocused2(false); + ConfigScreenList.currentText.setFocus(false); ConfigScreenList.currentText = this; } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/OpenCreateMenuButton.java b/src/main/java/com/simibubi/create/foundation/config/ui/OpenCreateMenuButton.java index 6d12dc3f8..a1f5ed7b2 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/OpenCreateMenuButton.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/OpenCreateMenuButton.java @@ -34,18 +34,18 @@ public class OpenCreateMenuButton extends Button { @Override public void render(MatrixStack mstack, int mouseX, int mouseY, float pticks) { super.render(mstack, mouseX, mouseY, pticks); - Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(icon, x + 2, y + 2); + Minecraft.getInstance().getItemRenderer().renderGuiItem(icon, x + 2, y + 2); } public static void click(Button b) { - ScreenOpener.open(new CreateMainMenuScreen(Minecraft.getInstance().currentScreen)); + ScreenOpener.open(new CreateMainMenuScreen(Minecraft.getInstance().screen)); } public static class SingleMenuRow { public final String left, right; public SingleMenuRow(String left, String right) { - this.left = I18n.format(left); - this.right = I18n.format(right); + this.left = I18n.get(left); + this.right = I18n.get(right); } public SingleMenuRow(String center) { this(center, center); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java index 1dd1156b5..639de55c8 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java @@ -166,7 +166,7 @@ public class SubMenuConfigScreen extends ConfigScreen { .withCallback((x, y) -> new ConfirmationScreen() .centered() - .withText(ITextProperties.plain("Resetting all settings of the " + type.toString() + " config. Are you sure?")) + .withText(ITextProperties.of("Resetting all settings of the " + type.toString() + " config. Are you sure?")) .withAction(success -> { if (success) resetConfig(spec.getValues()); @@ -186,7 +186,7 @@ public class SubMenuConfigScreen extends ConfigScreen { new ConfirmationScreen() .centered() - .withText(ITextProperties.plain("Saving " + changes.size() + " changed value" + (changes.size() != 1 ? "s" : "") + "")) + .withText(ITextProperties.of("Saving " + changes.size() + " changed value" + (changes.size() != 1 ? "s" : "") + "")) .withAction(success -> { if (success) saveChanges(); @@ -205,7 +205,7 @@ public class SubMenuConfigScreen extends ConfigScreen { new ConfirmationScreen() .centered() - .withText(ITextProperties.plain("Discarding " + changes.size() + " unsaved change" + (changes.size() != 1 ? "s" : "") + "")) + .withText(ITextProperties.of("Discarding " + changes.size() + " unsaved change" + (changes.size() != 1 ? "s" : "") + "")) .withAction(success -> { if (success) clearChanges(); @@ -227,7 +227,7 @@ public class SubMenuConfigScreen extends ConfigScreen { widgets.add(discardChanges); widgets.add(goBack); - list = new ConfigScreenList(client, listWidth, height - 60, 45, height - 15, 40); + list = new ConfigScreenList(minecraft, listWidth, height - 60, 45, height - 15, 40); list.setLeftPos(this.width / 2 - list.getWidth() / 2); children.add(list); @@ -284,11 +284,11 @@ public class SubMenuConfigScreen extends ConfigScreen { //extras for server configs if (type != ModConfig.Type.SERVER) return; - if (client.isSingleplayer()) + if (minecraft.hasSingleplayerServer()) return; list.isForServer = true; - boolean canEdit = client != null && client.player != null && client.player.hasPermissionLevel(2); + boolean canEdit = minecraft != null && minecraft.player != null && minecraft.player.hasPermissions(2); Couple red = Theme.p(Theme.Key.BUTTON_FAIL); Couple green = Theme.p(Theme.Key.BUTTON_SUCCESS); @@ -306,13 +306,13 @@ public class SubMenuConfigScreen extends ConfigScreen { stencil.withStencilRenderer((ms, w, h, alpha) -> AllIcons.I_CONFIG_LOCKED.draw(ms, 0, 0)); stencil.withElementRenderer((ms, w, h, alpha) -> UIRenderHelper.angledGradient(ms, 90, 8, 0, 16, 16, red)); serverLocked.withBorderColors(red); - serverLocked.getToolTip().add(new StringTextComponent("Locked").formatted(TextFormatting.BOLD)); + serverLocked.getToolTip().add(new StringTextComponent("Locked").withStyle(TextFormatting.BOLD)); serverLocked.getToolTip().addAll(TooltipHelper.cutStringTextComponent("You do not have enough permissions to edit the server config. You can still look at the current values here though.", TextFormatting.GRAY, TextFormatting.GRAY)); } else { stencil.withStencilRenderer((ms, w, h, alpha) -> AllIcons.I_CONFIG_UNLOCKED.draw(ms, 0, 0)); stencil.withElementRenderer((ms, w, h, alpha) -> UIRenderHelper.angledGradient(ms, 90, 8, 0, 16, 16, green)); serverLocked.withBorderColors(green); - serverLocked.getToolTip().add(new StringTextComponent("Unlocked").formatted(TextFormatting.BOLD)); + serverLocked.getToolTip().add(new StringTextComponent("Unlocked").withStyle(TextFormatting.BOLD)); serverLocked.getToolTip().addAll(TooltipHelper.cutStringTextComponent("You have enough permissions to edit the server config. Changes you make here will be synced with the server when you save them.", TextFormatting.GRAY, TextFormatting.GRAY)); } @@ -324,7 +324,7 @@ public class SubMenuConfigScreen extends ConfigScreen { super.renderWindow(ms, mouseX, mouseY, partialTicks); int x = width / 2; - drawCenteredString(ms, client.fontRenderer, ConfigScreen.modID + " > " + type.toString().toLowerCase(Locale.ROOT) + " > " + title, x, 15, Theme.i(Theme.Key.TEXT)); + drawCenteredString(ms, minecraft.font, ConfigScreen.modID + " > " + type.toString().toLowerCase(Locale.ROOT) + " > " + title, x, 15, Theme.i(Theme.Key.TEXT)); list.render(ms, mouseX, mouseY, partialTicks); } @@ -402,7 +402,7 @@ public class SubMenuConfigScreen extends ConfigScreen { public void showLeavingPrompt(Consumer action) { new ConfirmationScreen().centered() - .addText(ITextProperties.plain("Leaving with " + changes.size() + " unsaved change" + .addText(ITextProperties.of("Leaving with " + changes.size() + " unsaved change" + (changes.size() != 1 ? "s" : "") + " for this config")) .withThreeActions(action) .open(this); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java index da4f56137..2c82b98bf 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java @@ -25,7 +25,7 @@ public class EnumEntry extends ValueEntry> { public EnumEntry(String label, ForgeConfigSpec.ConfigValue> value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); - valueText = new TextStencilElement(Minecraft.getInstance().fontRenderer, "YEP").centered(true, true); + valueText = new TextStencilElement(Minecraft.getInstance().font, "YEP").centered(true, true); valueText.withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, height, width, Theme.p(Theme.Key.TEXT))); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java index 315d147df..79b5c7a75 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java @@ -38,8 +38,8 @@ public abstract class NumberEntry extends ValueEntry { public NumberEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); - textField = new ConfigTextField(Minecraft.getInstance().fontRenderer, 0, 0, 200, 20, unit); - textField.setText(String.valueOf(getValue())); + textField = new ConfigTextField(Minecraft.getInstance().font, 0, 0, 200, 20, unit); + textField.setValue(String.valueOf(getValue())); textField.setTextColor(Theme.i(Theme.Key.TEXT)); Object range = spec.getRange(); @@ -51,18 +51,18 @@ public abstract class NumberEntry extends ValueEntry { T min = (T) minField.get(range); T max = (T) maxField.get(range); - FontRenderer font = Minecraft.getInstance().fontRenderer; + FontRenderer font = Minecraft.getInstance().font; if (min.doubleValue() > getTypeMin().doubleValue()) { StringTextComponent t = new StringTextComponent(formatBound(min) + " < "); minText = new TextStencilElement(font, t).centered(true, false); minText.withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0 ,0, height/2, height, width, Theme.p(Theme.Key.TEXT_DARKER))); - minOffset = font.getWidth(t); + minOffset = font.width(t); } if (max.doubleValue() < getTypeMax().doubleValue()) { StringTextComponent t = new StringTextComponent(" < " + formatBound(max)); maxText = new TextStencilElement(font, t).centered(true, false); maxText.withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0 ,0, height/2, height, width, Theme.p(Theme.Key.TEXT_DARKER))); - maxOffset = font.getWidth(t); + maxOffset = font.width(t); } } catch (NoSuchFieldException | IllegalAccessException | ClassCastException | NullPointerException ignored) { @@ -101,17 +101,17 @@ public abstract class NumberEntry extends ValueEntry { @Override protected void setEditable(boolean b) { super.setEditable(b); - textField.setEnabled(b); + textField.setEditable(b); } @Override public void onValueChange(T newValue) { super.onValueChange(newValue); String newText = String.valueOf(newValue); - if (textField.getText().equals(newText)) + if (textField.getValue().equals(newText)) return; - textField.setText(newText); + textField.setValue(newText); } @Override @@ -133,13 +133,13 @@ public abstract class NumberEntry extends ValueEntry { if (minText != null) minText .at(textField.x - minOffset, textField.y, 0) - .withBounds(minOffset, textField.unusedGetHeight()) + .withBounds(minOffset, textField.getHeight()) .render(ms); if (maxText != null) maxText .at(textField.x + textField.getWidth(), textField.y, 0) - .withBounds(maxOffset, textField.unusedGetHeight()) + .withBounds(maxOffset, textField.getHeight()) .render(ms); } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java index 52a0d3fa1..1a0d05cdf 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java @@ -27,7 +27,7 @@ import net.minecraftforge.common.ForgeConfigSpec; public class ValueEntry extends ConfigScreenList.LabeledEntry { - protected static final IFormattableTextComponent modComponent = new StringTextComponent("* ").formatted(TextFormatting.BOLD, TextFormatting.DARK_BLUE).append(StringTextComponent.EMPTY.copy().formatted(TextFormatting.RESET)); + protected static final IFormattableTextComponent modComponent = new StringTextComponent("* ").withStyle(TextFormatting.BOLD, TextFormatting.DARK_BLUE).append(StringTextComponent.EMPTY.plainCopy().withStyle(TextFormatting.RESET)); protected static final int resetWidth = 28;//including 6px offset on either side public static final Pattern unitPattern = Pattern.compile("\\[(in .*)]"); @@ -54,7 +54,7 @@ public class ValueEntry extends ConfigScreenList.LabeledEntry { listeners.add(resetButton); List path = value.getPath(); - labelTooltip.add(new StringTextComponent(label).formatted(TextFormatting.WHITE)); + labelTooltip.add(new StringTextComponent(label).withStyle(TextFormatting.WHITE)); String comment = spec.getComment(); if (comment == null || comment.isEmpty()) return; @@ -85,7 +85,7 @@ public class ValueEntry extends ConfigScreenList.LabeledEntry { .flatMap(stc -> TooltipHelper.cutTextComponent(stc, TextFormatting.GRAY, TextFormatting.GRAY) .stream()) .collect(Collectors.toList())); - labelTooltip.add(new StringTextComponent(ConfigScreen.modID + ":" + path.get(path.size() - 1)).formatted(TextFormatting.DARK_GRAY)); + labelTooltip.add(new StringTextComponent(ConfigScreen.modID + ":" + path.get(path.size() - 1)).withStyle(TextFormatting.DARK_GRAY)); } @Override @@ -105,7 +105,7 @@ public class ValueEntry extends ConfigScreenList.LabeledEntry { public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { if (isCurrentValueChanged()) { IFormattableTextComponent original = label.getComponent(); - IFormattableTextComponent changed = modComponent.copy().append(original); + IFormattableTextComponent changed = modComponent.plainCopy().append(original); label.withText(changed); super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); label.withText(original); diff --git a/src/main/java/com/simibubi/create/foundation/data/AssetLookup.java b/src/main/java/com/simibubi/create/foundation/data/AssetLookup.java index 78f8b11df..18977afe5 100644 --- a/src/main/java/com/simibubi/create/foundation/data/AssetLookup.java +++ b/src/main/java/com/simibubi/create/foundation/data/AssetLookup.java @@ -79,7 +79,7 @@ public class AssetLookup { public static Function forPowered(DataGenContext ctx, RegistrateBlockstateProvider prov) { - return state -> state.get(BlockStateProperties.POWERED) ? partialBaseModel(ctx, prov, "powered") + return state -> state.getValue(BlockStateProperties.POWERED) ? partialBaseModel(ctx, prov, "powered") : partialBaseModel(ctx, prov); } @@ -87,7 +87,7 @@ public class AssetLookup { RegistrateBlockstateProvider prov, String path) { return state -> prov.models() .getExistingFile( - prov.modLoc("block/" + path + (state.get(BlockStateProperties.POWERED) ? "_powered" : ""))); + prov.modLoc("block/" + path + (state.getValue(BlockStateProperties.POWERED) ? "_powered" : ""))); } public static Function withIndicator(DataGenContext ctx, @@ -95,7 +95,7 @@ public class AssetLookup { return state -> { ResourceLocation baseModel = baseModelFunc.apply(state) .getLocation(); - Integer integer = state.get(property); + Integer integer = state.getValue(property); return prov.models() .withExistingParent(ctx.getName() + "_" + integer, baseModel) .texture("indicator", "block/indicator/" + integer); diff --git a/src/main/java/com/simibubi/create/foundation/data/BlockStateGen.java b/src/main/java/com/simibubi/create/foundation/data/BlockStateGen.java index 5661543b3..b3bb67a33 100644 --- a/src/main/java/com/simibubi/create/foundation/data/BlockStateGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/BlockStateGen.java @@ -87,7 +87,7 @@ public class BlockStateGen { public static

NonNullUnaryOperator> oxidizedBlockstate() { return b -> b.blockstate((ctx, prov) -> prov.getVariantBuilder(ctx.getEntry()) .forAllStates(state -> { - String name = AssetLookup.getOxidizedModel(ctx.getName(), state.get(OxidizingBlock.OXIDIZATION)); + String name = AssetLookup.getOxidizedModel(ctx.getName(), state.getValue(OxidizingBlock.OXIDIZATION)); return ConfiguredModel.builder() .modelFile(prov.models() .cubeAll(name, prov.modLoc(name))) @@ -108,14 +108,14 @@ public class BlockStateGen { RegistrateBlockstateProvider prov, Function modelFunc) { prov.getVariantBuilder(ctx.getEntry()) .forAllStatesExcept(state -> { - Direction dir = state.get(BlockStateProperties.FACING); + Direction dir = state.getValue(BlockStateProperties.FACING); return ConfiguredModel.builder() .modelFile(modelFunc.apply(state)) .rotationX(dir == Direction.DOWN ? 180 : dir.getAxis() .isHorizontal() ? 90 : 0) .rotationY(dir.getAxis() - .isVertical() ? 0 : (((int) dir.getHorizontalAngle()) + 180) % 360) + .isVertical() ? 0 : (((int) dir.toYRot()) + 180) % 360) .build(); }, BlockStateProperties.WATERLOGGED); } @@ -129,7 +129,7 @@ public class BlockStateGen { Function modelFunc, boolean uvLock) { prov.getVariantBuilder(ctx.getEntry()) .forAllStatesExcept(state -> { - Axis axis = state.get(BlockStateProperties.AXIS); + Axis axis = state.getValue(BlockStateProperties.AXIS); return ConfiguredModel.builder() .modelFile(modelFunc.apply(state)) .uvLock(uvLock) @@ -153,7 +153,7 @@ public class BlockStateGen { RegistrateBlockstateProvider prov, Function modelFunc) { prov.getVariantBuilder(ctx.getEntry()) .forAllStates(state -> { - Axis axis = state.get(BlockStateProperties.HORIZONTAL_AXIS); + Axis axis = state.getValue(BlockStateProperties.HORIZONTAL_AXIS); return ConfiguredModel.builder() .modelFile(modelFunc.apply(state)) .rotationY(axis == Axis.X ? 90 : 0) @@ -166,13 +166,13 @@ public class BlockStateGen { prov.getVariantBuilder(ctx.getEntry()) .forAllStates(state -> { - boolean alongFirst = state.get(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE); - Direction direction = state.get(DirectionalAxisKineticBlock.FACING); + boolean alongFirst = state.getValue(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE); + Direction direction = state.getValue(DirectionalAxisKineticBlock.FACING); boolean vertical = direction.getAxis() .isHorizontal() && (direction.getAxis() == Axis.X) == alongFirst; int xRot = direction == Direction.DOWN ? 270 : direction == Direction.UP ? 90 : 0; int yRot = direction.getAxis() - .isVertical() ? alongFirst ? 0 : 90 : (int) direction.getHorizontalAngle(); + .isVertical() ? alongFirst ? 0 : 90 : (int) direction.toYRot(); return ConfiguredModel.builder() .modelFile(modelFunc.apply(state, vertical)) @@ -188,8 +188,8 @@ public class BlockStateGen { .forAllStates(state -> ConfiguredModel.builder() .modelFile(modelFunc.apply(state)) .rotationX(90) - .rotationY(((int) state.get(BlockStateProperties.HORIZONTAL_FACING) - .getHorizontalAngle() + 180) % 360) + .rotationY(((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING) + .toYRot() + 180) % 360) .build()); } @@ -209,17 +209,17 @@ public class BlockStateGen { ModelFile top, ModelFile covered) { prov.getVariantBuilder(ctx.getEntry()) .forAllStates(state -> ConfiguredModel.builder() - .modelFile(state.get(PavedBlock.COVERED) ? covered : top) + .modelFile(state.getValue(PavedBlock.COVERED) ? covered : top) .build()); } public static NonNullBiConsumer, RegistrateBlockstateProvider> cartAssembler() { return (c, p) -> p.getVariantBuilder(c.get()) .forAllStates(state -> { - CartAssembleRailType type = state.get(CartAssemblerBlock.RAIL_TYPE); - Boolean powered = state.get(CartAssemblerBlock.POWERED); - Boolean backwards = state.get(CartAssemblerBlock.BACKWARDS); - RailShape shape = state.get(CartAssemblerBlock.RAIL_SHAPE); + CartAssembleRailType type = state.getValue(CartAssemblerBlock.RAIL_TYPE); + Boolean powered = state.getValue(CartAssemblerBlock.POWERED); + Boolean backwards = state.getValue(CartAssemblerBlock.BACKWARDS); + RailShape shape = state.getValue(CartAssemblerBlock.RAIL_SHAPE); int yRotation = shape == RailShape.EAST_WEST ? 270 : 0; if (backwards) @@ -228,7 +228,7 @@ public class BlockStateGen { return ConfiguredModel.builder() .modelFile(p.models() .getExistingFile(p.modLoc( - "block/" + c.getName() + "/block_" + type.getString() + (powered ? "_powered" : "")))) + "block/" + c.getName() + "/block_" + type.getSerializedName() + (powered ? "_powered" : "")))) .rotationY(yRotation % 360) .build(); }); @@ -247,9 +247,9 @@ public class BlockStateGen { return ConfiguredModel.builder() .modelFile(p.models() .getExistingFile(p.modLoc( - "block/" + c.getName() + "/block" + (state.get(ReinforcedRailBlock.CONNECTS_S) ? "_s" : "") - + (state.get(ReinforcedRailBlock.CONNECTS_N) ? "_n" : "")))) - .rotationY(state.get(ReinforcedRailBlock.RAIL_SHAPE) == RailShape.EAST_WEST ? 90 : 0) + "block/" + c.getName() + "/block" + (state.getValue(ReinforcedRailBlock.CONNECTS_S) ? "_s" : "") + + (state.getValue(ReinforcedRailBlock.CONNECTS_N) ? "_n" : "")))) + .rotationY(state.getValue(ReinforcedRailBlock.RAIL_SHAPE) == RailShape.EAST_WEST ? 90 : 0) .build(); }); } @@ -272,8 +272,8 @@ public class BlockStateGen { .texture("top", isTopSticky ? top_sticky : top)); BiFunction modelFunc = (t, b) -> models.get((t ? 0 : 2) + (b ? 0 : 1)); - axisBlock(c, p, state -> modelFunc.apply(state.get(LinearChassisBlock.STICKY_TOP), - state.get(LinearChassisBlock.STICKY_BOTTOM))); + axisBlock(c, p, state -> modelFunc.apply(state.getValue(LinearChassisBlock.STICKY_TOP), + state.getValue(LinearChassisBlock.STICKY_BOTTOM))); }; } @@ -290,14 +290,14 @@ public class BlockStateGen { Vector stickyFaces = new Vector<>(3); for (Axis axis : Iterate.axes) { - String suffix = "side_" + axis.getString(); + String suffix = "side_" + axis.getSerializedName(); faces.add(p.models() .withExistingParent("block/" + c.getName() + "_" + suffix, p.modLoc(templateModelPath + "/" + suffix)) .texture("side", side)); } for (Axis axis : Iterate.axes) { - String suffix = "side_" + axis.getString(); + String suffix = "side_" + axis.getSerializedName(); stickyFaces.add(p.models() .withExistingParent("block/" + c.getName() + "_" + suffix + "_sticky", p.modLoc(templateModelPath + "/" + suffix)) @@ -306,8 +306,8 @@ public class BlockStateGen { MultiPartBlockStateBuilder builder = p.getMultipartBuilder(c.get()); BlockState propertyGetter = c.get() - .getDefaultState() - .with(RadialChassisBlock.AXIS, Axis.Y); + .defaultBlockState() + .setValue(RadialChassisBlock.AXIS, Axis.Y); for (Axis axis : Iterate.axes) builder.part() @@ -321,7 +321,7 @@ public class BlockStateGen { for (Direction face : Iterate.horizontalDirections) { for (boolean sticky : Iterate.trueAndFalse) { for (Axis axis : Iterate.axes) { - int horizontalAngle = (int) (face.getHorizontalAngle()); + int horizontalAngle = (int) (face.toYRot()); int index = axis.ordinal(); int xRot = 0; int yRot = 0; @@ -367,7 +367,7 @@ public class BlockStateGen { builder.part() .modelFile(flatPass ? flat : open) .rotationX(verticalAngle) - .rotationY((int) (d.getHorizontalAngle() + (d.getAxis() + .rotationY((int) (d.toYRot() + (d.getAxis() .isVertical() ? 90 : 0)) % 360) .addModel() .condition(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), !flatPass) @@ -403,22 +403,22 @@ public class BlockStateGen { Map, ModelFile> coreModels = new HashMap<>(); for (Axis axis : Iterate.axes) - coreTemplates.put(axis, p.modLoc(path + "/core_" + axis.getString())); + coreTemplates.put(axis, p.modLoc(path + "/core_" + axis.getSerializedName())); ModelFile end = AssetLookup.partialBaseModel(c, p, "end"); for (Axis axis : Iterate.axes) { ResourceLocation parent = coreTemplates.get(axis); for (String s : orientations) { Pair key = Pair.of(s, axis); - String modelName = path + "/" + s + "_" + axis.getString(); + String modelName = path + "/" + s + "_" + axis.getSerializedName(); coreModels.put(key, p.models() .withExistingParent(modelName, parent) .element() .from(4, 4, 4) .to(12, 12, 12) - .face(Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis)) + .face(Direction.get(AxisDirection.POSITIVE, axis)) .end() - .face(Direction.getFacingFromAxis(AxisDirection.NEGATIVE, axis)) + .face(Direction.get(AxisDirection.NEGATIVE, axis)) .end() .faces((d, builder) -> { Pair pair = uvs.get(s); @@ -441,9 +441,9 @@ public class BlockStateGen { builder.part() .modelFile(end) .rotationX(d == Direction.UP ? 0 : d == Direction.DOWN ? 180 : 90) - .rotationY((int) (d.getHorizontalAngle() + 180) % 360) + .rotationY((int) (d.toYRot() + 180) % 360) .addModel() - .condition(FluidPipeBlock.FACING_TO_PROPERTY_MAP.get(d), true) + .condition(FluidPipeBlock.PROPERTY_BY_DIRECTION.get(d), true) .end(); for (Axis axis : Iterate.axes) { @@ -464,8 +464,8 @@ public class BlockStateGen { private static void putPart(Map, ModelFile> coreModels, MultiPartBlockStateBuilder builder, Axis axis, String s, boolean up, boolean down, boolean left, boolean right) { - Direction positiveAxis = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); - Map propertyMap = FluidPipeBlock.FACING_TO_PROPERTY_MAP; + Direction positiveAxis = Direction.get(AxisDirection.POSITIVE, axis); + Map propertyMap = FluidPipeBlock.PROPERTY_BY_DIRECTION; builder.part() .modelFile(coreModels.get(Pair.of(s, axis))) .addModel() 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 799a837af..f4830ec00 100644 --- a/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java +++ b/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java @@ -41,13 +41,15 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; +import net.minecraft.block.AbstractBlock; + public class BuilderTransformers { public static NonNullUnaryOperator> cuckooClock() { return b -> b.initialProperties(SharedProperties::wooden) .blockstate((c, p) -> p.horizontalBlock(c.get(), p.models() .getExistingFile(p.modLoc("block/cuckoo_clock/block")))) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .transform(StressConfigDefaults.setImpact(1.0)) .item() .transform(ModelGen.customItemModel("cuckoo_clock", "item")); @@ -56,14 +58,14 @@ public class BuilderTransformers { public static NonNullUnaryOperator> encasedShaft(String casing, CTSpriteShiftEntry casingShift) { return builder -> builder.initialProperties(SharedProperties::stone) - .properties(Block.Properties::nonOpaque) + .properties(AbstractBlock.Properties::noOcclusion) .onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(casingShift))) .onRegister(CreateRegistrate.casingConnectivity( - (block, cc) -> cc.make(block, casingShift, (s, f) -> f.getAxis() != s.get(EncasedShaftBlock.AXIS)))) + (block, cc) -> cc.make(block, casingShift, (s, f) -> f.getAxis() != s.getValue(EncasedShaftBlock.AXIS)))) .blockstate((c, p) -> axisBlock(c, p, blockState -> p.models() .getExistingFile(p.modLoc("block/encased_shaft/block_" + casing)), true)) .transform(StressConfigDefaults.setNoImpact()) - .loot((p, b) -> p.registerDropping(b, AllBlocks.SHAFT.get())) + .loot((p, b) -> p.dropOther(b, AllBlocks.SHAFT.get())) .item() .model(AssetLookup.customBlockItemModel("encased_shaft", "item_" + casing)) .build(); @@ -73,7 +75,7 @@ public class BuilderTransformers { @Nullable DyeColor color) { return b -> b.initialProperties(SharedProperties::softMetal) .blockstate((c, p) -> { - String variant = color == null ? "copper" : color.getString(); + String variant = color == null ? "copper" : color.getSerializedName(); p.directionalBlock(c.get(), p.models() .withExistingParent(variant + "_valve_handle", p.modLoc("block/valve_handle")) .texture("3", p.modLoc("block/valve_handle/valve_handle_" + variant))); @@ -97,15 +99,15 @@ public class BuilderTransformers { public static NonNullUnaryOperator> beltTunnel( String type, ResourceLocation particleTexture) { return b -> b.initialProperties(SharedProperties::stone) - .addLayer(() -> RenderType::getCutoutMipped) - .properties(Block.Properties::nonOpaque) + .addLayer(() -> RenderType::cutoutMipped) + .properties(AbstractBlock.Properties::noOcclusion) .blockstate((c, p) -> p.getVariantBuilder(c.get()) .forAllStates(state -> { String id = "block/" + type + "_tunnel"; - Shape shape = state.get(BeltTunnelBlock.SHAPE); + Shape shape = state.getValue(BeltTunnelBlock.SHAPE); if (shape == BeltTunnelBlock.Shape.CLOSED) shape = BeltTunnelBlock.Shape.STRAIGHT; - String shapeName = shape.getString(); + String shapeName = shape.getSerializedName(); return ConfiguredModel.builder() .modelFile(p.models() .withExistingParent(id + "/" + shapeName, p.modLoc("block/belt_tunnel/" + shapeName)) @@ -113,7 +115,7 @@ public class BuilderTransformers { .texture("2", p.modLoc(id)) .texture("3", p.modLoc(id + "_top_window")) .texture("particle", particleTexture)) - .rotationY(state.get(BeltTunnelBlock.HORIZONTAL_AXIS) == Axis.X ? 0 : 90) + .rotationY(state.getValue(BeltTunnelBlock.HORIZONTAL_AXIS) == Axis.X ? 0 : 90) .build(); })) .item(BeltTunnelItem::new) @@ -129,12 +131,12 @@ public class BuilderTransformers { public static NonNullUnaryOperator> mechanicalPiston(PistonType type) { return b -> b.initialProperties(SharedProperties::stone) - .properties(p -> p.nonOpaque()) + .properties(p -> p.noOcclusion()) .blockstate(new MechanicalPistonGenerator(type)::generate) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .transform(StressConfigDefaults.setImpact(4.0)) .item() - .transform(ModelGen.customItemModel("mechanical_piston", type.getString(), "item")); + .transform(ModelGen.customItemModel("mechanical_piston", type.getSerializedName(), "item")); } public static NonNullUnaryOperator> bearing(String prefix, @@ -147,7 +149,7 @@ public class BuilderTransformers { ResourceLocation sideTextureLocation = Create.asResource("block/" + prefix + "_bearing_side"); ResourceLocation backTextureLocation = Create.asResource("block/" + backTexture); return b -> b.initialProperties(SharedProperties::stone) - .properties(p -> p.nonOpaque()) + .properties(p -> p.noOcclusion()) .blockstate((c, p) -> p.directionalBlock(c.get(), p.models() .withExistingParent(c.getName(), baseBlockModelLocation) .texture("side", sideTextureLocation) @@ -183,8 +185,8 @@ public class BuilderTransformers { String variant = "single"; int yRot = 0; - if (state.get(CrateBlock.DOUBLE)) { - Direction direction = state.get(CrateBlock.FACING); + if (state.getValue(CrateBlock.DOUBLE)) { + Direction direction = state.getValue(CrateBlock.FACING); if (direction.getAxis() == Axis.X) yRot = 90; @@ -220,13 +222,13 @@ public class BuilderTransformers { public static NonNullUnaryOperator> bell() { return b -> b.initialProperties(SharedProperties::softMetal) - .properties(p -> p.nonOpaque() + .properties(p -> p.noOcclusion() .sound(SoundType.ANVIL)) - .addLayer(() -> RenderType::getCutoutMipped) + .addLayer(() -> RenderType::cutoutMipped) .tag(AllBlockTags.BRITTLE.tag) .blockstate((c, p) -> p.horizontalBlock(c.getEntry(), state -> { - String variant = state.get(BlockStateProperties.BELL_ATTACHMENT) - .getString(); + String variant = state.getValue(BlockStateProperties.BELL_ATTACHMENT) + .getSerializedName(); return p.models() .withExistingParent(c.getName() + "_" + variant, p.modLoc("block/bell_base/block_" + variant)); })) diff --git a/src/main/java/com/simibubi/create/foundation/data/DirectionalAxisBlockStateGen.java b/src/main/java/com/simibubi/create/foundation/data/DirectionalAxisBlockStateGen.java index 64512db71..ec321bd6e 100644 --- a/src/main/java/com/simibubi/create/foundation/data/DirectionalAxisBlockStateGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/DirectionalAxisBlockStateGen.java @@ -14,8 +14,8 @@ public abstract class DirectionalAxisBlockStateGen extends SpecialBlockStateGen @Override protected int getXRotation(BlockState state) { - Direction direction = state.get(GaugeBlock.FACING); - boolean alongFirst = state.get(GaugeBlock.AXIS_ALONG_FIRST_COORDINATE); + Direction direction = state.getValue(GaugeBlock.FACING); + boolean alongFirst = state.getValue(GaugeBlock.AXIS_ALONG_FIRST_COORDINATE); if (direction == Direction.DOWN) return 180; @@ -29,8 +29,8 @@ public abstract class DirectionalAxisBlockStateGen extends SpecialBlockStateGen @Override protected int getYRotation(BlockState state) { - Direction direction = state.get(GaugeBlock.FACING); - boolean alongFirst = state.get(GaugeBlock.AXIS_ALONG_FIRST_COORDINATE); + Direction direction = state.getValue(GaugeBlock.FACING); + boolean alongFirst = state.getValue(GaugeBlock.AXIS_ALONG_FIRST_COORDINATE); if (direction.getAxis() .isVertical()) @@ -45,7 +45,7 @@ public abstract class DirectionalAxisBlockStateGen extends SpecialBlockStateGen @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - boolean vertical = state.get(GaugeBlock.FACING) + boolean vertical = state.getValue(GaugeBlock.FACING) .getAxis() .isVertical(); String partial = vertical ? "" : "_wall"; diff --git a/src/main/java/com/simibubi/create/foundation/data/LangMerger.java b/src/main/java/com/simibubi/create/foundation/data/LangMerger.java index 1f92db23c..0b71d5383 100644 --- a/src/main/java/com/simibubi/create/foundation/data/LangMerger.java +++ b/src/main/java/com/simibubi/create/foundation/data/LangMerger.java @@ -76,7 +76,7 @@ public class LangMerger implements IDataProvider { } @Override - public void act(DirectoryCache cache) throws IOException { + public void run(DirectoryCache cache) throws IOException { Path path = this.gen.getOutputFolder() .resolve("assets/" + Create.ID + "/lang/" + "en_us.json"); @@ -232,9 +232,9 @@ public class LangMerger implements IDataProvider { String data = createString(dataIn, missingKeys); // data = JavaUnicodeEscaper.outsideOf(0, 0x7f) // .translate(data); - String hash = IDataProvider.HASH_FUNCTION.hashUnencodedChars(data) + String hash = IDataProvider.SHA1.hashUnencodedChars(data) .toString(); - if (!Objects.equals(cache.getPreviousHash(target), hash) || !Files.exists(target)) { + if (!Objects.equals(cache.getHash(target), hash) || !Files.exists(target)) { Files.createDirectories(target.getParent()); try (BufferedWriter bufferedwriter = Files.newBufferedWriter(target)) { @@ -244,7 +244,7 @@ public class LangMerger implements IDataProvider { } } - cache.recordHash(target, hash); + cache.putNew(target, hash); } protected String createString(List data, int missingKeys) { diff --git a/src/main/java/com/simibubi/create/foundation/data/NamedTag.java b/src/main/java/com/simibubi/create/foundation/data/NamedTag.java index 066552663..000ff1b05 100644 --- a/src/main/java/com/simibubi/create/foundation/data/NamedTag.java +++ b/src/main/java/com/simibubi/create/foundation/data/NamedTag.java @@ -22,7 +22,7 @@ public class NamedTag implements ITag.INamedTag { } @Override - public ResourceLocation getId() { + public ResourceLocation getName() { return id; } @@ -34,9 +34,9 @@ public class NamedTag implements ITag.INamedTag { } @Override - public List values() { + public List getValues() { if (tag == null) return Collections.emptyList(); - return tag.values(); + return tag.getValues(); } } diff --git a/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java b/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java index f685c4368..c65837850 100644 --- a/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java +++ b/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java @@ -10,7 +10,7 @@ import net.minecraft.block.material.PushReaction; @MethodsReturnNonnullByDefault public class SharedProperties { public static Material beltMaterial = - new Material(MaterialColor.GRAY, false, true, true, true, false, false, PushReaction.NORMAL); + new Material(MaterialColor.COLOR_GRAY, false, true, true, true, false, false, PushReaction.NORMAL); public static Block stone() { return Blocks.ANDESITE; diff --git a/src/main/java/com/simibubi/create/foundation/data/SpecialBlockStateGen.java b/src/main/java/com/simibubi/create/foundation/data/SpecialBlockStateGen.java index 98aea3c9c..1529eac07 100644 --- a/src/main/java/com/simibubi/create/foundation/data/SpecialBlockStateGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/SpecialBlockStateGen.java @@ -31,7 +31,7 @@ public abstract class SpecialBlockStateGen { if (direction.getAxis() .isVertical()) return 0; - return (int) direction.getHorizontalAngle(); + return (int) direction.toYRot(); } protected abstract int getXRotation(BlockState state); diff --git a/src/main/java/com/simibubi/create/foundation/data/WindowGen.java b/src/main/java/com/simibubi/create/foundation/data/WindowGen.java index 3aabbe3d3..8139a6f9b 100644 --- a/src/main/java/com/simibubi/create/foundation/data/WindowGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/WindowGen.java @@ -44,10 +44,10 @@ public class WindowGen { private static final CreateRegistrate REGISTRATE = Create.registrate(); private static Properties glassProperties(Properties p) { - return p.allowsSpawning(WindowGen::never) - .solidBlock(WindowGen::never) - .suffocates(WindowGen::never) - .blockVision(WindowGen::never); + return p.isValidSpawn(WindowGen::never) + .isRedstoneConductor(WindowGen::never) + .isSuffocating(WindowGen::never) + .isViewBlocking(WindowGen::never); } private static boolean never(BlockState p_235436_0_, IBlockReader p_235436_1_, BlockPos p_235436_2_) { @@ -60,7 +60,7 @@ public class WindowGen { } public static BlockEntry woodenWindowBlock(WoodType woodType, Block planksBlock) { - return woodenWindowBlock(woodType, planksBlock, () -> RenderType::getCutoutMipped); + return woodenWindowBlock(woodType, planksBlock, () -> RenderType::cutoutMipped); } public static BlockEntry customWindowBlock(String name, Supplier ingredient, @@ -72,7 +72,7 @@ public class WindowGen { public static BlockEntry woodenWindowBlock(WoodType woodType, Block planksBlock, Supplier> renderType) { - String woodName = woodType.getName(); + String woodName = woodType.name(); String name = woodName + "_window"; NonNullFunction end_texture = $ -> new ResourceLocation("block/" + woodName + "_planks"); @@ -87,16 +87,16 @@ public class WindowGen { return REGISTRATE.block(name, WindowBlock::new) .onRegister(connectedTextures(new HorizontalCTBehaviour(ct))) .addLayer(renderType) - .recipe((c, p) -> ShapedRecipeBuilder.shapedRecipe(c.get(), 2) - .patternLine(" # ") - .patternLine("#X#") - .key('#', ingredient.get()) - .key('X', DataIngredient.tag(Tags.Items.GLASS_COLORLESS)) - .addCriterion("has_ingredient", p.hasItem(ingredient.get())) - .build(p::accept)) + .recipe((c, p) -> ShapedRecipeBuilder.shaped(c.get(), 2) + .pattern(" # ") + .pattern("#X#") + .define('#', ingredient.get()) + .define('X', DataIngredient.tag(Tags.Items.GLASS_COLORLESS)) + .unlockedBy("has_ingredient", p.hasItem(ingredient.get())) + .save(p::accept)) .initialProperties(() -> Blocks.GLASS) .properties(WindowGen::glassProperties) - .loot((t, g) -> t.registerSilkTouch(g)) + .loot((t, g) -> t.dropWhenSilkTouch(g)) .blockstate((c, p) -> p.simpleBlock(c.get(), p.models() .cubeColumn(c.getName(), sideTexture.apply(c.getName()), endTexture.apply(c.getName())))) .tag(BlockTags.IMPERMEABLE) @@ -107,10 +107,10 @@ public class WindowGen { public static BlockEntry framedGlass(String name, ConnectedTextureBehaviour behaviour) { return REGISTRATE.block(name, ConnectedGlassBlock::new) .onRegister(connectedTextures(behaviour)) - .addLayer(() -> RenderType::getTranslucent) + .addLayer(() -> RenderType::translucent) .initialProperties(() -> Blocks.GLASS) .properties(WindowGen::glassProperties) - .loot((t, g) -> t.registerSilkTouch(g)) + .loot((t, g) -> t.dropWhenSilkTouch(g)) .recipe((c, p) -> p.stonecutting(DataIngredient.tag(Tags.Items.GLASS_COLORLESS), c::get)) .blockstate((c, p) -> BlockStateGen.cubeAll(c, p, "palettes/", "framed_glass")) .tag(Tags.Blocks.GLASS_COLORLESS, BlockTags.IMPERMEABLE) @@ -127,7 +127,7 @@ public class WindowGen { ResourceLocation sideTexture = Create.asResource(palettesDir() + "framed_glass"); ResourceLocation itemSideTexture = Create.asResource(palettesDir() + name); ResourceLocation topTexture = Create.asResource(palettesDir() + "framed_glass_pane_top"); - Supplier> renderType = () -> RenderType::getTranslucent; + Supplier> renderType = () -> RenderType::translucent; return connectedGlassPane(name, parent, ctshift, sideTexture, itemSideTexture, topTexture, renderType); } @@ -140,12 +140,12 @@ public class WindowGen { public static BlockEntry woodenWindowPane(WoodType woodType, Supplier parent) { - return woodenWindowPane(woodType, parent, () -> RenderType::getCutoutMipped); + return woodenWindowPane(woodType, parent, () -> RenderType::cutoutMipped); } public static BlockEntry woodenWindowPane(WoodType woodType, Supplier parent, Supplier> renderType) { - String woodName = woodType.getName(); + String woodName = woodType.name(); String name = woodName + "_window"; ResourceLocation topTexture = new ResourceLocation("block/" + woodName + "_planks"); ResourceLocation sideTexture = Create.asResource(palettesDir() + name); @@ -203,14 +203,14 @@ public class WindowGen { .addLayer(renderType) .initialProperties(() -> Blocks.GLASS_PANE) .blockstate(stateProvider) - .recipe((c, p) -> ShapedRecipeBuilder.shapedRecipe(c.get(), 16) - .patternLine("###") - .patternLine("###") - .key('#', parent.get()) - .addCriterion("has_ingredient", p.hasItem(parent.get())) - .build(p::accept)) + .recipe((c, p) -> ShapedRecipeBuilder.shaped(c.get(), 16) + .pattern("###") + .pattern("###") + .define('#', parent.get()) + .unlockedBy("has_ingredient", p.hasItem(parent.get())) + .save(p::accept)) .tag(Tags.Blocks.GLASS_PANES) - .loot((t, g) -> t.registerSilkTouch(g)) + .loot((t, g) -> t.dropWhenSilkTouch(g)) .item() .tag(Tags.Items.GLASS_PANES) .model((c, p) -> p.withExistingParent(c.getName(), new ResourceLocation(Create.ID, "item/pane")) diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/CompactingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/CompactingRecipeGen.java index ccf3125c5..2ae48e5c3 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/CompactingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/CompactingRecipeGen.java @@ -12,6 +12,8 @@ import net.minecraft.fluid.Fluids; import net.minecraft.item.Items; import net.minecraftforge.common.Tags; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; + public class CompactingRecipeGen extends ProcessingRecipeGen { GeneratedRecipe diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java b/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java index eb4f95506..baae5baa3 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java @@ -27,7 +27,7 @@ public abstract class CreateRecipeProvider extends RecipeProvider { } @Override - protected void registerRecipes(Consumer p_200404_1_) { + protected void buildShapelessRecipes(Consumer p_200404_1_) { all.forEach(c -> c.register(p_200404_1_)); Create.LOGGER.info(getName() + " registered " + all.size() + " recipe" + (all.size() == 1 ? "" : "s")); } diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/CrushingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/CrushingRecipeGen.java index 4262c8bcc..288ef4b12 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/CrushingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/CrushingRecipeGen.java @@ -14,6 +14,9 @@ import net.minecraft.tags.ItemTags; import net.minecraftforge.common.crafting.conditions.NotCondition; import net.minecraftforge.common.crafting.conditions.TagEmptyCondition; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.I; + public class CrushingRecipeGen extends ProcessingRecipeGen { GeneratedRecipe diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/CuttingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/CuttingRecipeGen.java index eac7c4424..9251f0b74 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/CuttingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/CuttingRecipeGen.java @@ -7,6 +7,9 @@ import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.data.DataGenerator; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.I; + public class CuttingRecipeGen extends ProcessingRecipeGen { GeneratedRecipe diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/EmptyingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/EmptyingRecipeGen.java index 9df7864d4..42d9b9bb3 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/EmptyingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/EmptyingRecipeGen.java @@ -7,6 +7,8 @@ import com.simibubi.create.AllRecipeTypes; import net.minecraft.data.DataGenerator; import net.minecraft.item.Items; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; + public class EmptyingRecipeGen extends ProcessingRecipeGen { /* diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/FillingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/FillingRecipeGen.java index 62ed6d8b2..6799d7cdd 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/FillingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/FillingRecipeGen.java @@ -12,6 +12,8 @@ import net.minecraft.item.Items; import net.minecraft.potion.Potions; import net.minecraftforge.common.Tags; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; + public class FillingRecipeGen extends ProcessingRecipeGen { GeneratedRecipe diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeBuilder.java b/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeBuilder.java index 1bc1314c7..8bff65111 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeBuilder.java @@ -54,14 +54,14 @@ public class MechanicalCraftingRecipeBuilder { * Adds a key to the recipe pattern. */ public MechanicalCraftingRecipeBuilder key(Character p_200469_1_, Tag p_200469_2_) { - return this.key(p_200469_1_, Ingredient.fromTag(p_200469_2_)); + return this.key(p_200469_1_, Ingredient.of(p_200469_2_)); } /** * Adds a key to the recipe pattern. */ public MechanicalCraftingRecipeBuilder key(Character p_200462_1_, IItemProvider p_200462_2_) { - return this.key(p_200462_1_, Ingredient.fromItems(p_200462_2_)); + return this.key(p_200462_1_, Ingredient.of(p_200462_2_)); } /** @@ -161,7 +161,7 @@ public class MechanicalCraftingRecipeBuilder { this.key = p_i48271_7_; } - public void serialize(JsonObject p_218610_1_) { + public void serializeRecipeData(JsonObject p_218610_1_) { JsonArray jsonarray = new JsonArray(); for (String s : this.pattern) jsonarray.add(s); @@ -170,7 +170,7 @@ public class MechanicalCraftingRecipeBuilder { JsonObject jsonobject = new JsonObject(); for (Entry entry : this.key.entrySet()) jsonobject.add(String.valueOf(entry.getKey()), entry.getValue() - .serialize()); + .toJson()); p_218610_1_.add("key", jsonobject); JsonObject jsonobject1 = new JsonObject(); @@ -182,21 +182,21 @@ public class MechanicalCraftingRecipeBuilder { p_218610_1_.add("result", jsonobject1); } - public IRecipeSerializer getSerializer() { + public IRecipeSerializer getType() { return AllRecipeTypes.MECHANICAL_CRAFTING.serializer; } - public ResourceLocation getID() { + public ResourceLocation getId() { return this.id; } @Nullable - public JsonObject getAdvancementJson() { + public JsonObject serializeAdvancement() { return null; } @Nullable - public ResourceLocation getAdvancementID() { + public ResourceLocation getAdvancementId() { return null; } } diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeGen.java index ba98441ee..2d8585af5 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/MechanicalCraftingRecipeGen.java @@ -15,13 +15,16 @@ import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.Tags; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.I; + public class MechanicalCraftingRecipeGen extends CreateRecipeProvider { GeneratedRecipe CRUSHING_WHEEL = create(AllBlocks.CRUSHING_WHEEL::get).returns(2) - .recipe(b -> b.key('P', Ingredient.fromTag(ItemTags.PLANKS)) - .key('S', Ingredient.fromTag(I.stone())) + .recipe(b -> b.key('P', Ingredient.of(ItemTags.PLANKS)) + .key('S', Ingredient.of(I.stone())) .key('A', I.andesite()) .patternLine(" AAA ") .patternLine("AAPAA") @@ -30,10 +33,10 @@ public class MechanicalCraftingRecipeGen extends CreateRecipeProvider { .patternLine(" AAA ")), EXTENDO_GRIP = create(AllItems.EXTENDO_GRIP::get).returns(1) - .recipe(b -> b.key('L', Ingredient.fromTag(I.brass())) + .recipe(b -> b.key('L', Ingredient.of(I.brass())) .key('R', I.precisionMechanism()) .key('H', AllItems.BRASS_HAND.get()) - .key('S', Ingredient.fromTag(Tags.Items.RODS_WOODEN)) + .key('S', Ingredient.of(Tags.Items.RODS_WOODEN)) .patternLine(" L ") .patternLine(" R ") .patternLine("SSS") @@ -44,21 +47,21 @@ public class MechanicalCraftingRecipeGen extends CreateRecipeProvider { .recipe(b -> b.key('L', I.andesite()) .key('R', I.precisionMechanism()) .key('S', AllBlocks.FLUID_PIPE.get()) - .key('C', Ingredient.fromTag(I.copper())) + .key('C', Ingredient.of(I.copper())) .patternLine("LRSSS") .patternLine("CC ")), FURNACE_ENGINE = create(AllBlocks.FURNACE_ENGINE::get).returns(1) - .recipe(b -> b.key('P', Ingredient.fromTag(I.brassSheet())) - .key('B', Ingredient.fromTag(I.brass())) - .key('I', Ingredient.fromItems(Blocks.PISTON, Blocks.STICKY_PISTON)) + .recipe(b -> b.key('P', Ingredient.of(I.brassSheet())) + .key('B', Ingredient.of(I.brass())) + .key('I', Ingredient.of(Blocks.PISTON, Blocks.STICKY_PISTON)) .key('C', I.brassCasing()) .patternLine("PPB") .patternLine("PCI") .patternLine("PPB")), FLYWHEEL = create(AllBlocks.FLYWHEEL::get).returns(1) - .recipe(b -> b.key('B', Ingredient.fromTag(I.brass())) + .recipe(b -> b.key('B', Ingredient.of(I.brass())) .key('C', I.brassCasing()) .patternLine(" BBB") .patternLine("CB B") diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/MillingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/MillingRecipeGen.java index 92480a848..c6e339586 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/MillingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/MillingRecipeGen.java @@ -14,6 +14,8 @@ import net.minecraft.tags.ItemTags; import net.minecraftforge.common.crafting.conditions.NotCondition; import net.minecraftforge.common.crafting.conditions.TagEmptyCondition; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; + public class MillingRecipeGen extends ProcessingRecipeGen { GeneratedRecipe diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/MixingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/MixingRecipeGen.java index 6e26a2e26..e3c346298 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/MixingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/MixingRecipeGen.java @@ -13,6 +13,9 @@ import net.minecraft.item.Items; import net.minecraft.tags.ItemTags; import net.minecraftforge.common.Tags; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.I; + public class MixingRecipeGen extends ProcessingRecipeGen { GeneratedRecipe diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/PolishingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/PolishingRecipeGen.java index 8f1ea96aa..67526b1d0 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/PolishingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/PolishingRecipeGen.java @@ -5,6 +5,8 @@ import com.simibubi.create.AllRecipeTypes; import net.minecraft.data.DataGenerator; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; + public class PolishingRecipeGen extends ProcessingRecipeGen { GeneratedRecipe diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/PressingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/PressingRecipeGen.java index e2f38a40c..34fa2f987 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/PressingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/PressingRecipeGen.java @@ -7,13 +7,16 @@ import net.minecraft.data.DataGenerator; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.I; + public class PressingRecipeGen extends ProcessingRecipeGen { GeneratedRecipe SUGAR_CANE = create(() -> Items.SUGAR_CANE, b -> b.output(Items.PAPER)), - PATH = create("path", b -> b.require(Ingredient.fromItems(Items.GRASS_BLOCK, Items.DIRT)) + PATH = create("path", b -> b.require(Ingredient.of(Items.GRASS_BLOCK, Items.DIRT)) .output(Items.GRASS_PATH)), IRON = create("iron_ingot", b -> b.require(I.iron()) diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/ProcessingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/ProcessingRecipeGen.java index 58d35e2ab..90ae53c38 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/ProcessingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/ProcessingRecipeGen.java @@ -20,6 +20,8 @@ import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidAttributes; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; + public abstract class ProcessingRecipeGen extends CreateRecipeProvider { protected static List generators = new ArrayList<>(); @@ -47,10 +49,10 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider { } @Override - public void act(DirectoryCache dc) throws IOException { + public void run(DirectoryCache dc) throws IOException { generators.forEach(g -> { try { - g.act(dc); + g.run(dc); } catch (IOException e) { e.printStackTrace(); } @@ -75,7 +77,7 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider { transform .apply(new ProcessingRecipeBuilder<>(serializer.getFactory(), new ResourceLocation(namespace, iItemProvider.asItem() .getRegistryName() - .getPath())).withItemIngredients(Ingredient.fromItems(iItemProvider))) + .getPath())).withItemIngredients(Ingredient.of(iItemProvider))) .build(c); }; all.add(generatedRecipe); diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/SequencedAssemblyRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/SequencedAssemblyRecipeGen.java index 42b653da0..6e8497008 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/SequencedAssemblyRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/SequencedAssemblyRecipeGen.java @@ -15,6 +15,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.tags.ItemTags; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.I; + public class SequencedAssemblyRecipeGen extends CreateRecipeProvider { GeneratedRecipe diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java index 3d6a0d568..440a573bd 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java @@ -51,6 +51,10 @@ import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.crafting.conditions.ModLoadedCondition; import net.minecraftforge.common.crafting.conditions.NotCondition; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.I; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.Marker; + @SuppressWarnings("unused") public class StandardRecipeGen extends CreateRecipeProvider { @@ -77,699 +81,699 @@ public class StandardRecipeGen extends CreateRecipeProvider { ImmutableList.of(I::zincNugget, I::zinc, I::zincBlock)), ANDESITE_ALLOY = create(AllItems.ANDESITE_ALLOY).unlockedByTag(I::iron) - .viaShaped(b -> b.key('A', Blocks.ANDESITE) - .key('B', Tags.Items.NUGGETS_IRON) - .patternLine("BA") - .patternLine("AB")), + .viaShaped(b -> b.define('A', Blocks.ANDESITE) + .define('B', Tags.Items.NUGGETS_IRON) + .pattern("BA") + .pattern("AB")), ANDESITE_ALLOY_FROM_ZINC = create(AllItems.ANDESITE_ALLOY).withSuffix("_from_zinc") .unlockedByTag(I::zinc) - .viaShaped(b -> b.key('A', Blocks.ANDESITE) - .key('B', I.zincNugget()) - .patternLine("BA") - .patternLine("AB")), + .viaShaped(b -> b.define('A', Blocks.ANDESITE) + .define('B', I.zincNugget()) + .pattern("BA") + .pattern("AB")), ANDESITE_CASING = create(AllBlocks.ANDESITE_CASING).returns(4) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('A', ItemTags.PLANKS) - .key('C', I.andesite()) - .key('S', ItemTags.LOGS) - .patternLine("AAA") - .patternLine("CSC") - .patternLine("AAA")), + .viaShaped(b -> b.define('A', ItemTags.PLANKS) + .define('C', I.andesite()) + .define('S', ItemTags.LOGS) + .pattern("AAA") + .pattern("CSC") + .pattern("AAA")), BRASS_CASING = create(AllBlocks.BRASS_CASING).returns(4) .unlockedByTag(I::brass) - .viaShaped(b -> b.key('A', ItemTags.PLANKS) - .key('C', I.brassSheet()) - .key('S', ItemTags.LOGS) - .patternLine("AAA") - .patternLine("CSC") - .patternLine("AAA")), + .viaShaped(b -> b.define('A', ItemTags.PLANKS) + .define('C', I.brassSheet()) + .define('S', ItemTags.LOGS) + .pattern("AAA") + .pattern("CSC") + .pattern("AAA")), COPPER_CASING = create(AllBlocks.COPPER_CASING).returns(4) .unlockedByTag(I::copper) - .viaShaped(b -> b.key('A', ItemTags.PLANKS) - .key('C', I.copperSheet()) - .key('S', ItemTags.LOGS) - .patternLine("AAA") - .patternLine("CSC") - .patternLine("AAA")), + .viaShaped(b -> b.define('A', ItemTags.PLANKS) + .define('C', I.copperSheet()) + .define('S', ItemTags.LOGS) + .pattern("AAA") + .pattern("CSC") + .pattern("AAA")), RADIANT_CASING = create(AllBlocks.REFINED_RADIANCE_CASING).returns(4) .unlockedBy(I::refinedRadiance) - .viaShaped(b -> b.key('A', ItemTags.PLANKS) - .key('C', I.refinedRadiance()) - .key('S', Tags.Items.GLASS_COLORLESS) - .patternLine("AAA") - .patternLine("CSC") - .patternLine("AAA")), + .viaShaped(b -> b.define('A', ItemTags.PLANKS) + .define('C', I.refinedRadiance()) + .define('S', Tags.Items.GLASS_COLORLESS) + .pattern("AAA") + .pattern("CSC") + .pattern("AAA")), SHADOW_CASING = create(AllBlocks.SHADOW_STEEL_CASING).returns(4) .unlockedBy(I::shadowSteel) - .viaShaped(b -> b.key('A', ItemTags.PLANKS) - .key('C', I.shadowSteel()) - .key('S', Tags.Items.OBSIDIAN) - .patternLine("AAA") - .patternLine("CSC") - .patternLine("AAA")), + .viaShaped(b -> b.define('A', ItemTags.PLANKS) + .define('C', I.shadowSteel()) + .define('S', Tags.Items.OBSIDIAN) + .pattern("AAA") + .pattern("CSC") + .pattern("AAA")), ELECTRON_TUBE = create(AllItems.ELECTRON_TUBE).unlockedBy(AllItems.ROSE_QUARTZ::get) - .viaShaped(b -> b.key('L', AllItems.POLISHED_ROSE_QUARTZ.get()) - .key('R', Items.REDSTONE_TORCH) - .key('N', Tags.Items.NUGGETS_IRON) - .patternLine("L") - .patternLine("R") - .patternLine("N")), + .viaShaped(b -> b.define('L', AllItems.POLISHED_ROSE_QUARTZ.get()) + .define('R', Items.REDSTONE_TORCH) + .define('N', Tags.Items.NUGGETS_IRON) + .pattern("L") + .pattern("R") + .pattern("N")), ROSE_QUARTZ = create(AllItems.ROSE_QUARTZ).unlockedBy(() -> Items.REDSTONE) - .viaShapeless(b -> b.addIngredient(Tags.Items.GEMS_QUARTZ) - .addIngredient(Ingredient.fromTag(I.redstone()), 8)), + .viaShapeless(b -> b.requires(Tags.Items.GEMS_QUARTZ) + .requires(Ingredient.of(I.redstone()), 8)), SAND_PAPER = create(AllItems.SAND_PAPER).unlockedBy(() -> Items.PAPER) - .viaShapeless(b -> b.addIngredient(Items.PAPER) - .addIngredient(Tags.Items.SAND_COLORLESS)), + .viaShapeless(b -> b.requires(Items.PAPER) + .requires(Tags.Items.SAND_COLORLESS)), RED_SAND_PAPER = create(AllItems.RED_SAND_PAPER).unlockedBy(() -> Items.PAPER) - .viaShapeless(b -> b.addIngredient(Items.PAPER) - .addIngredient(Tags.Items.SAND_RED)) + .viaShapeless(b -> b.requires(Items.PAPER) + .requires(Tags.Items.SAND_RED)) ; private Marker CURIOSITIES = enterSection(AllSections.CURIOSITIES); GeneratedRecipe WAND_OF_SYMMETRY = create(AllItems.WAND_OF_SYMMETRY).unlockedBy(I::refinedRadiance) - .viaShaped(b -> b.key('E', I.refinedRadiance()) - .key('G', Tags.Items.GLASS_PANES_WHITE) - .key('O', Tags.Items.OBSIDIAN) - .key('L', I.brass()) - .patternLine(" GE") - .patternLine("LEG") - .patternLine("OL ")), + .viaShaped(b -> b.define('E', I.refinedRadiance()) + .define('G', Tags.Items.GLASS_PANES_WHITE) + .define('O', Tags.Items.OBSIDIAN) + .define('L', I.brass()) + .pattern(" GE") + .pattern("LEG") + .pattern("OL ")), MINECART_COUPLING = create(AllItems.MINECART_COUPLING).unlockedBy(I::andesite) - .viaShaped(b -> b.key('E', I.andesite()) - .key('O', I.ironSheet()) - .patternLine(" E") - .patternLine(" O ") - .patternLine("E ")), + .viaShaped(b -> b.define('E', I.andesite()) + .define('O', I.ironSheet()) + .pattern(" E") + .pattern(" O ") + .pattern("E ")), PECULIAR_BELL = create(AllBlocks.PECULIAR_BELL).unlockedByTag(I::brass) - .viaShaped(b -> b.key('I', I.brassBlock()) - .key('P', I.brassSheet()) - .patternLine("I") - .patternLine("P")) + .viaShaped(b -> b.define('I', I.brassBlock()) + .define('P', I.brassSheet()) + .pattern("I") + .pattern("P")) ; private Marker KINETICS = enterSection(AllSections.KINETICS); GeneratedRecipe BASIN = create(AllBlocks.BASIN).unlockedBy(I::andesite) - .viaShaped(b -> b.key('A', I.andesite()) - .patternLine("A A") - .patternLine("AAA")), + .viaShaped(b -> b.define('A', I.andesite()) + .pattern("A A") + .pattern("AAA")), GOGGLES = create(AllItems.GOGGLES).unlockedBy(I::andesite) - .viaShaped(b -> b.key('G', Tags.Items.GLASS) - .key('P', I.goldSheet()) - .key('S', Tags.Items.STRING) - .patternLine(" S ") - .patternLine("GPG")), + .viaShaped(b -> b.define('G', Tags.Items.GLASS) + .define('P', I.goldSheet()) + .define('S', Tags.Items.STRING) + .pattern(" S ") + .pattern("GPG")), WRENCH = create(AllItems.WRENCH).unlockedBy(I::andesite) - .viaShaped(b -> b.key('G', I.goldSheet()) - .key('P', I.cog()) - .key('S', Tags.Items.RODS_WOODEN) - .patternLine("GG") - .patternLine("GP") - .patternLine(" S")), + .viaShaped(b -> b.define('G', I.goldSheet()) + .define('P', I.cog()) + .define('S', Tags.Items.RODS_WOODEN) + .pattern("GG") + .pattern("GP") + .pattern(" S")), FILTER = create(AllItems.FILTER).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', ItemTags.WOOL) - .key('A', Tags.Items.NUGGETS_IRON) - .patternLine("ASA")), + .viaShaped(b -> b.define('S', ItemTags.WOOL) + .define('A', Tags.Items.NUGGETS_IRON) + .pattern("ASA")), ATTRIBUTE_FILTER = create(AllItems.ATTRIBUTE_FILTER).unlockedByTag(I::brass) - .viaShaped(b -> b.key('S', ItemTags.WOOL) - .key('A', I.brassNugget()) - .patternLine("ASA")), + .viaShaped(b -> b.define('S', ItemTags.WOOL) + .define('A', I.brassNugget()) + .pattern("ASA")), BRASS_HAND = create(AllItems.BRASS_HAND).unlockedByTag(I::brass) - .viaShaped(b -> b.key('A', I.andesite()) - .key('B', I.brassSheet()) - .patternLine(" A ") - .patternLine("BBB") - .patternLine(" B ")), + .viaShaped(b -> b.define('A', I.andesite()) + .define('B', I.brassSheet()) + .pattern(" A ") + .pattern("BBB") + .pattern(" B ")), SUPER_GLUE = create(AllItems.SUPER_GLUE).unlockedByTag(I::ironSheet) - .viaShaped(b -> b.key('A', Tags.Items.SLIMEBALLS) - .key('S', I.ironSheet()) - .key('N', Tags.Items.NUGGETS_IRON) - .patternLine("AS") - .patternLine("NA")), + .viaShaped(b -> b.define('A', Tags.Items.SLIMEBALLS) + .define('S', I.ironSheet()) + .define('N', Tags.Items.NUGGETS_IRON) + .pattern("AS") + .pattern("NA")), CRAFTER_SLOT_COVER = create(AllItems.CRAFTER_SLOT_COVER).unlockedBy(AllBlocks.MECHANICAL_CRAFTER::get) - .viaShaped(b -> b.key('A', I.brassNugget()) - .patternLine("AAA")), + .viaShaped(b -> b.define('A', I.brassNugget()) + .pattern("AAA")), COGWHEEL = create(AllBlocks.COGWHEEL).returns(8) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', ItemTags.WOODEN_BUTTONS) - .key('C', I.andesite()) - .patternLine("SSS") - .patternLine("SCS") - .patternLine("SSS")), + .viaShaped(b -> b.define('S', ItemTags.WOODEN_BUTTONS) + .define('C', I.andesite()) + .pattern("SSS") + .pattern("SCS") + .pattern("SSS")), LARGE_COGWHEEL = create(AllBlocks.LARGE_COGWHEEL).returns(2) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', ItemTags.WOODEN_BUTTONS) - .key('C', I.andesite()) - .key('D', ItemTags.PLANKS) - .patternLine("SDS") - .patternLine("DCD") - .patternLine("SDS")), + .viaShaped(b -> b.define('S', ItemTags.WOODEN_BUTTONS) + .define('C', I.andesite()) + .define('D', ItemTags.PLANKS) + .pattern("SDS") + .pattern("DCD") + .pattern("SDS")), WATER_WHEEL = create(AllBlocks.WATER_WHEEL).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', ItemTags.WOODEN_SLABS) - .key('C', AllBlocks.LARGE_COGWHEEL.get()) - .patternLine("SSS") - .patternLine("SCS") - .patternLine("SSS")), + .viaShaped(b -> b.define('S', ItemTags.WOODEN_SLABS) + .define('C', AllBlocks.LARGE_COGWHEEL.get()) + .pattern("SSS") + .pattern("SCS") + .pattern("SSS")), SHAFT = create(AllBlocks.SHAFT).returns(8) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('A', I.andesite()) - .patternLine("A") - .patternLine("A")), + .viaShaped(b -> b.define('A', I.andesite()) + .pattern("A") + .pattern("A")), MECHANICAL_PRESS = create(AllBlocks.MECHANICAL_PRESS).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('B', I.andesite()) - .key('S', I.cog()) - .key('C', I.andesiteCasing()) - .key('I', AllTags.forgeItemTag("storage_blocks/iron")) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" I ")), + .viaShaped(b -> b.define('B', I.andesite()) + .define('S', I.cog()) + .define('C', I.andesiteCasing()) + .define('I', AllTags.forgeItemTag("storage_blocks/iron")) + .pattern(" B ") + .pattern("SCS") + .pattern(" I ")), MILLSTONE = create(AllBlocks.MILLSTONE).unlockedBy(I::andesite) - .viaShaped(b -> b.key('B', ItemTags.PLANKS) - .key('S', I.andesite()) - .key('C', I.cog()) - .key('I', I.stone()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" I ")), + .viaShaped(b -> b.define('B', ItemTags.PLANKS) + .define('S', I.andesite()) + .define('C', I.cog()) + .define('I', I.stone()) + .pattern(" B ") + .pattern("SCS") + .pattern(" I ")), MECHANICAL_PISTON = create(AllBlocks.MECHANICAL_PISTON).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('B', ItemTags.PLANKS) - .key('S', I.cog()) - .key('C', I.andesiteCasing()) - .key('I', AllBlocks.PISTON_EXTENSION_POLE.get()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" I ")), + .viaShaped(b -> b.define('B', ItemTags.PLANKS) + .define('S', I.cog()) + .define('C', I.andesiteCasing()) + .define('I', AllBlocks.PISTON_EXTENSION_POLE.get()) + .pattern(" B ") + .pattern("SCS") + .pattern(" I ")), STICKY_MECHANICAL_PISTON = create(AllBlocks.STICKY_MECHANICAL_PISTON).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', Tags.Items.SLIMEBALLS) - .key('P', AllBlocks.MECHANICAL_PISTON.get()) - .patternLine("S") - .patternLine("P")), + .viaShaped(b -> b.define('S', Tags.Items.SLIMEBALLS) + .define('P', AllBlocks.MECHANICAL_PISTON.get()) + .pattern("S") + .pattern("P")), TURNTABLE = create(AllBlocks.TURNTABLE).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', I.shaft()) - .key('P', ItemTags.WOODEN_SLABS) - .patternLine("P") - .patternLine("S")), + .viaShaped(b -> b.define('S', I.shaft()) + .define('P', ItemTags.WOODEN_SLABS) + .pattern("P") + .pattern("S")), PISTON_EXTENSION_POLE = create(AllBlocks.PISTON_EXTENSION_POLE).returns(8) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('A', I.andesite()) - .key('P', ItemTags.PLANKS) - .patternLine("P") - .patternLine("A") - .patternLine("P")), + .viaShaped(b -> b.define('A', I.andesite()) + .define('P', ItemTags.PLANKS) + .pattern("P") + .pattern("A") + .pattern("P")), GANTRY_PINION = create(AllBlocks.GANTRY_CARRIAGE).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('B', ItemTags.PLANKS) - .key('S', I.cog()) - .key('C', I.andesiteCasing()) - .key('I', I.shaft()) - .patternLine(" B ") - .patternLine("ICI") - .patternLine(" S ")), + .viaShaped(b -> b.define('B', ItemTags.PLANKS) + .define('S', I.cog()) + .define('C', I.andesiteCasing()) + .define('I', I.shaft()) + .pattern(" B ") + .pattern("ICI") + .pattern(" S ")), GANTRY_SHAFT = create(AllBlocks.GANTRY_SHAFT).returns(8) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('A', I.andesite()) - .key('R', I.redstone()) - .patternLine("A") - .patternLine("R") - .patternLine("A")), + .viaShaped(b -> b.define('A', I.andesite()) + .define('R', I.redstone()) + .pattern("A") + .pattern("R") + .pattern("A")), ANALOG_LEVER = create(AllBlocks.ANALOG_LEVER).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', I.andesiteCasing()) - .key('P', Tags.Items.RODS_WOODEN) - .patternLine("P") - .patternLine("S")), + .viaShaped(b -> b.define('S', I.andesiteCasing()) + .define('P', Tags.Items.RODS_WOODEN) + .pattern("P") + .pattern("S")), BELT_CONNECTOR = create(AllItems.BELT_CONNECTOR).unlockedBy(I::andesite) - .viaShaped(b -> b.key('D', Items.DRIED_KELP) - .patternLine("DDD") - .patternLine("DDD")), + .viaShaped(b -> b.define('D', Items.DRIED_KELP) + .pattern("DDD") + .pattern("DDD")), ADJUSTABLE_PULLEY = create(AllBlocks.ADJUSTABLE_CHAIN_GEARSHIFT).unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('A', I.electronTube()) - .key('B', AllBlocks.ENCASED_CHAIN_DRIVE.get()) - .key('C', AllBlocks.LARGE_COGWHEEL.get()) - .patternLine("A") - .patternLine("B") - .patternLine("C")), + .viaShaped(b -> b.define('A', I.electronTube()) + .define('B', AllBlocks.ENCASED_CHAIN_DRIVE.get()) + .define('C', AllBlocks.LARGE_COGWHEEL.get()) + .pattern("A") + .pattern("B") + .pattern("C")), CART_ASSEMBLER = create(AllBlocks.CART_ASSEMBLER).unlockedBy(I::andesite) - .viaShaped(b -> b.key('L', ItemTags.LOGS) - .key('R', I.redstone()) - .key('C', I.andesite()) - .patternLine(" L ") - .patternLine("CRC") - .patternLine("L L")), + .viaShaped(b -> b.define('L', ItemTags.LOGS) + .define('R', I.redstone()) + .define('C', I.andesite()) + .pattern(" L ") + .pattern("CRC") + .pattern("L L")), CONTROLLER_RAIL = create(AllBlocks.CONTROLLER_RAIL).returns(6) .unlockedBy(() -> Items.POWERED_RAIL) - .viaShaped(b -> b.key('A', I.gold()) - .key('E', I.electronTube()) - .key('S', Tags.Items.RODS_WOODEN) - .patternLine("A A") - .patternLine("ASA") - .patternLine("AEA")), + .viaShaped(b -> b.define('A', I.gold()) + .define('E', I.electronTube()) + .define('S', Tags.Items.RODS_WOODEN) + .pattern("A A") + .pattern("ASA") + .pattern("AEA")), HAND_CRANK = create(AllBlocks.HAND_CRANK).unlockedBy(I::andesite) - .viaShaped(b -> b.key('A', I.andesite()) - .key('C', ItemTags.PLANKS) - .key('S', I.shaft()) - .patternLine(" S ") - .patternLine("CCC") - .patternLine(" A")), + .viaShaped(b -> b.define('A', I.andesite()) + .define('C', ItemTags.PLANKS) + .define('S', I.shaft()) + .pattern(" S ") + .pattern("CCC") + .pattern(" A")), COPPER_VALVE_HANDLE = create(AllBlocks.COPPER_VALVE_HANDLE).unlockedByTag(I::copper) - .viaShaped(b -> b.key('S', I.andesite()) - .key('C', I.copperSheet()) - .patternLine("CCC") - .patternLine(" S ")), + .viaShaped(b -> b.define('S', I.andesite()) + .define('C', I.copperSheet()) + .pattern("CCC") + .pattern(" S ")), COPPER_VALVE_HANDLE_FROM_OTHER_HANDLES = create(AllBlocks.COPPER_VALVE_HANDLE).withSuffix("_from_others") .unlockedByTag(I::copper) - .viaShapeless(b -> b.addIngredient(AllItemTags.VALVE_HANDLES.tag)), + .viaShapeless(b -> b.requires(AllItemTags.VALVE_HANDLES.tag)), NOZZLE = create(AllBlocks.NOZZLE).unlockedBy(AllBlocks.ENCASED_FAN::get) - .viaShaped(b -> b.key('S', I.andesite()) - .key('C', ItemTags.WOOL) - .patternLine(" S ") - .patternLine(" C ") - .patternLine("SSS")), + .viaShaped(b -> b.define('S', I.andesite()) + .define('C', ItemTags.WOOL) + .pattern(" S ") + .pattern(" C ") + .pattern("SSS")), PROPELLER = create(AllItems.PROPELLER).unlockedByTag(I::ironSheet) - .viaShaped(b -> b.key('S', I.ironSheet()) - .key('C', I.andesite()) - .patternLine(" S ") - .patternLine("SCS") - .patternLine(" S ")), + .viaShaped(b -> b.define('S', I.ironSheet()) + .define('C', I.andesite()) + .pattern(" S ") + .pattern("SCS") + .pattern(" S ")), WHISK = create(AllItems.WHISK).unlockedByTag(I::ironSheet) - .viaShaped(b -> b.key('S', I.ironSheet()) - .key('C', I.andesite()) - .patternLine(" C ") - .patternLine("SCS") - .patternLine("SSS")), + .viaShaped(b -> b.define('S', I.ironSheet()) + .define('C', I.andesite()) + .pattern(" C ") + .pattern("SCS") + .pattern("SSS")), ENCASED_FAN = create(AllBlocks.ENCASED_FAN).unlockedByTag(I::ironSheet) - .viaShaped(b -> b.key('S', I.shaft()) - .key('A', I.andesiteCasing()) - .key('R', I.cog()) - .key('P', AllItems.PROPELLER.get()) - .patternLine(" S ") - .patternLine("RAR") - .patternLine(" P ")), + .viaShaped(b -> b.define('S', I.shaft()) + .define('A', I.andesiteCasing()) + .define('R', I.cog()) + .define('P', AllItems.PROPELLER.get()) + .pattern(" S ") + .pattern("RAR") + .pattern(" P ")), CUCKOO_CLOCK = create(AllBlocks.CUCKOO_CLOCK).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', ItemTags.PLANKS) - .key('A', Items.CLOCK) - .key('B', ItemTags.LOGS) - .key('P', I.cog()) - .patternLine(" S ") - .patternLine("SAS") - .patternLine("BPB")), + .viaShaped(b -> b.define('S', ItemTags.PLANKS) + .define('A', Items.CLOCK) + .define('B', ItemTags.LOGS) + .define('P', I.cog()) + .pattern(" S ") + .pattern("SAS") + .pattern("BPB")), MECHANICAL_CRAFTER = create(AllBlocks.MECHANICAL_CRAFTER).returns(3) .unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('B', I.electronTube()) - .key('R', Blocks.CRAFTING_TABLE) - .key('C', I.brassCasing()) - .key('S', I.cog()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" R ")), + .viaShaped(b -> b.define('B', I.electronTube()) + .define('R', Blocks.CRAFTING_TABLE) + .define('C', I.brassCasing()) + .define('S', I.cog()) + .pattern(" B ") + .pattern("SCS") + .pattern(" R ")), WINDMILL_BEARING = create(AllBlocks.WINDMILL_BEARING).unlockedBy(I::andesite) - .viaShaped(b -> b.key('I', I.shaft()) - .key('B', AllBlocks.TURNTABLE.get()) - .key('C', I.stone()) - .patternLine(" B ") - .patternLine(" C ") - .patternLine(" I ")), + .viaShaped(b -> b.define('I', I.shaft()) + .define('B', AllBlocks.TURNTABLE.get()) + .define('C', I.stone()) + .pattern(" B ") + .pattern(" C ") + .pattern(" I ")), MECHANICAL_BEARING = create(AllBlocks.MECHANICAL_BEARING).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('I', I.shaft()) - .key('S', I.andesite()) - .key('B', AllBlocks.TURNTABLE.get()) - .key('C', I.andesiteCasing()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" I ")), + .viaShaped(b -> b.define('I', I.shaft()) + .define('S', I.andesite()) + .define('B', AllBlocks.TURNTABLE.get()) + .define('C', I.andesiteCasing()) + .pattern(" B ") + .pattern("SCS") + .pattern(" I ")), CLOCKWORK_BEARING = create(AllBlocks.CLOCKWORK_BEARING).unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('I', I.shaft()) - .key('S', I.electronTube()) - .key('B', AllBlocks.TURNTABLE.get()) - .key('C', I.brassCasing()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" I ")), + .viaShaped(b -> b.define('I', I.shaft()) + .define('S', I.electronTube()) + .define('B', AllBlocks.TURNTABLE.get()) + .define('C', I.brassCasing()) + .pattern(" B ") + .pattern("SCS") + .pattern(" I ")), WOODEN_BRACKET = create(AllBlocks.WOODEN_BRACKET).returns(4) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', Tags.Items.RODS_WOODEN) - .key('P', I.planks()) - .key('C', I.andesite()) - .patternLine("SSS") - .patternLine("PCP")), + .viaShaped(b -> b.define('S', Tags.Items.RODS_WOODEN) + .define('P', I.planks()) + .define('C', I.andesite()) + .pattern("SSS") + .pattern("PCP")), METAL_BRACKET = create(AllBlocks.METAL_BRACKET).returns(4) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', Tags.Items.NUGGETS_IRON) - .key('P', I.iron()) - .key('C', I.andesite()) - .patternLine("SSS") - .patternLine("PCP")), + .viaShaped(b -> b.define('S', Tags.Items.NUGGETS_IRON) + .define('P', I.iron()) + .define('C', I.andesite()) + .pattern("SSS") + .pattern("PCP")), FLUID_PIPE = create(AllBlocks.FLUID_PIPE).returns(8) .unlockedByTag(I::copper) - .viaShaped(b -> b.key('S', I.copperSheet()) - .key('C', I.copper()) - .patternLine("SCS")), + .viaShaped(b -> b.define('S', I.copperSheet()) + .define('C', I.copper()) + .pattern("SCS")), MECHANICAL_PUMP = create(AllBlocks.MECHANICAL_PUMP).unlockedByTag(I::copper) - .viaShaped(b -> b.key('P', I.cog()) - .key('S', AllBlocks.FLUID_PIPE.get()) - .patternLine("P") - .patternLine("S")), + .viaShaped(b -> b.define('P', I.cog()) + .define('S', AllBlocks.FLUID_PIPE.get()) + .pattern("P") + .pattern("S")), SMART_FLUID_PIPE = create(AllBlocks.SMART_FLUID_PIPE).unlockedByTag(I::copper) - .viaShaped(b -> b.key('P', I.electronTube()) - .key('S', AllBlocks.FLUID_PIPE.get()) - .key('I', I.brassSheet()) - .patternLine("I") - .patternLine("S") - .patternLine("P")), + .viaShaped(b -> b.define('P', I.electronTube()) + .define('S', AllBlocks.FLUID_PIPE.get()) + .define('I', I.brassSheet()) + .pattern("I") + .pattern("S") + .pattern("P")), FLUID_VALVE = create(AllBlocks.FLUID_VALVE).unlockedByTag(I::copper) - .viaShaped(b -> b.key('P', I.shaft()) - .key('S', AllBlocks.FLUID_PIPE.get()) - .key('I', I.ironSheet()) - .patternLine("I") - .patternLine("S") - .patternLine("P")), + .viaShaped(b -> b.define('P', I.shaft()) + .define('S', AllBlocks.FLUID_PIPE.get()) + .define('I', I.ironSheet()) + .pattern("I") + .pattern("S") + .pattern("P")), SPOUT = create(AllBlocks.SPOUT).unlockedBy(I::copperCasing) - .viaShaped(b -> b.key('T', AllBlocks.FLUID_TANK.get()) - .key('P', Items.DRIED_KELP) - .key('S', I.copperNugget()) - .patternLine("T") - .patternLine("P") - .patternLine("S")), + .viaShaped(b -> b.define('T', AllBlocks.FLUID_TANK.get()) + .define('P', Items.DRIED_KELP) + .define('S', I.copperNugget()) + .pattern("T") + .pattern("P") + .pattern("S")), ITEM_DRAIN = create(AllBlocks.ITEM_DRAIN).unlockedBy(I::copperCasing) - .viaShaped(b -> b.key('P', Blocks.IRON_BARS) - .key('S', I.copperCasing()) - .patternLine("P") - .patternLine("S")), + .viaShaped(b -> b.define('P', Blocks.IRON_BARS) + .define('S', I.copperCasing()) + .pattern("P") + .pattern("S")), FLUID_TANK = create(AllBlocks.FLUID_TANK).returns(2) .unlockedBy(I::copperCasing) - .viaShaped(b -> b.key('B', I.copperCasing()) - .key('S', I.copperNugget()) - .key('C', Tags.Items.GLASS) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" B ")), + .viaShaped(b -> b.define('B', I.copperCasing()) + .define('S', I.copperNugget()) + .define('C', Tags.Items.GLASS) + .pattern(" B ") + .pattern("SCS") + .pattern(" B ")), DEPLOYER = create(AllBlocks.DEPLOYER).unlockedBy(I::electronTube) - .viaShaped(b -> b.key('I', AllItems.BRASS_HAND.get()) - .key('B', I.electronTube()) - .key('S', I.cog()) - .key('C', I.andesiteCasing()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" I ")), + .viaShaped(b -> b.define('I', AllItems.BRASS_HAND.get()) + .define('B', I.electronTube()) + .define('S', I.cog()) + .define('C', I.andesiteCasing()) + .pattern(" B ") + .pattern("SCS") + .pattern(" I ")), PORTABLE_STORAGE_INTERFACE = create(AllBlocks.PORTABLE_STORAGE_INTERFACE).unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('I', I.brassCasing()) - .key('B', AllBlocks.ANDESITE_FUNNEL.get()) - .patternLine(" B ") - .patternLine(" I ")), + .viaShaped(b -> b.define('I', I.brassCasing()) + .define('B', AllBlocks.ANDESITE_FUNNEL.get()) + .pattern(" B ") + .pattern(" I ")), PORTABLE_FLUID_INTERFACE = create(AllBlocks.PORTABLE_FLUID_INTERFACE).unlockedBy(I::copperCasing) - .viaShaped(b -> b.key('I', I.copperCasing()) - .key('B', AllBlocks.ANDESITE_FUNNEL.get()) - .patternLine(" B ") - .patternLine(" I ")), + .viaShaped(b -> b.define('I', I.copperCasing()) + .define('B', AllBlocks.ANDESITE_FUNNEL.get()) + .pattern(" B ") + .pattern(" I ")), ROPE_PULLEY = create(AllBlocks.ROPE_PULLEY).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', I.shaft()) - .key('B', I.andesiteCasing()) - .key('C', ItemTags.WOOL) - .key('I', I.ironSheet()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" I ")), + .viaShaped(b -> b.define('S', I.shaft()) + .define('B', I.andesiteCasing()) + .define('C', ItemTags.WOOL) + .define('I', I.ironSheet()) + .pattern(" B ") + .pattern("SCS") + .pattern(" I ")), HOSE_PULLEY = create(AllBlocks.HOSE_PULLEY).unlockedByTag(I::copper) - .viaShaped(b -> b.key('S', I.shaft()) - .key('P', AllBlocks.FLUID_PIPE.get()) - .key('B', I.copperCasing()) - .key('C', Items.DRIED_KELP) - .key('I', I.copperSheet()) - .patternLine(" B ") - .patternLine("SCP") - .patternLine(" I ")), + .viaShaped(b -> b.define('S', I.shaft()) + .define('P', AllBlocks.FLUID_PIPE.get()) + .define('B', I.copperCasing()) + .define('C', Items.DRIED_KELP) + .define('I', I.copperSheet()) + .pattern(" B ") + .pattern("SCP") + .pattern(" I ")), EMPTY_BLAZE_BURNER = create(AllItems.EMPTY_BLAZE_BURNER).unlockedByTag(I::iron) - .viaShaped(b -> b.key('A', Blocks.IRON_BARS) - .key('I', I.ironSheet()) - .patternLine("II") - .patternLine("AA")), + .viaShaped(b -> b.define('A', Blocks.IRON_BARS) + .define('I', I.ironSheet()) + .pattern("II") + .pattern("AA")), CHUTE = create(AllBlocks.CHUTE).unlockedBy(I::andesite) .returns(4) - .viaShaped(b -> b.key('A', I.ironSheet()) - .key('I', I.andesite()) - .patternLine("II") - .patternLine("AA")), + .viaShaped(b -> b.define('A', I.ironSheet()) + .define('I', I.andesite()) + .pattern("II") + .pattern("AA")), SMART_CHUTE = create(AllBlocks.SMART_CHUTE).unlockedBy(AllBlocks.CHUTE::get) - .viaShaped(b -> b.key('P', I.electronTube()) - .key('S', AllBlocks.CHUTE.get()) - .key('I', I.brassSheet()) - .patternLine("I") - .patternLine("S") - .patternLine("P")), + .viaShaped(b -> b.define('P', I.electronTube()) + .define('S', AllBlocks.CHUTE.get()) + .define('I', I.brassSheet()) + .pattern("I") + .pattern("S") + .pattern("P")), DEPOT = create(AllBlocks.DEPOT).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('A', I.andesite()) - .key('I', I.andesiteCasing()) - .patternLine("A") - .patternLine("I")), + .viaShaped(b -> b.define('A', I.andesite()) + .define('I', I.andesiteCasing()) + .pattern("A") + .pattern("I")), WEIGHTED_EJECTOR = create(AllBlocks.WEIGHTED_EJECTOR).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('A', I.goldSheet()) - .key('D', AllBlocks.DEPOT.get()) - .key('I', I.cog()) - .patternLine("A") - .patternLine("D") - .patternLine("I")), + .viaShaped(b -> b.define('A', I.goldSheet()) + .define('D', AllBlocks.DEPOT.get()) + .define('I', I.cog()) + .pattern("A") + .pattern("D") + .pattern("I")), MECHANICAL_ARM = create(AllBlocks.MECHANICAL_ARM::get).unlockedBy(I::brassCasing) .returns(1) - .viaShaped(b -> b.key('L', I.brassSheet()) - .key('I', I.precisionMechanism()) - .key('A', I.andesite()) - .key('C', I.brassCasing()) - .patternLine("LLA") - .patternLine("L ") - .patternLine("IC ")), + .viaShaped(b -> b.define('L', I.brassSheet()) + .define('I', I.precisionMechanism()) + .define('A', I.andesite()) + .define('C', I.brassCasing()) + .pattern("LLA") + .pattern("L ") + .pattern("IC ")), MECHANICAL_MIXER = create(AllBlocks.MECHANICAL_MIXER).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', I.cog()) - .key('B', I.andesite()) - .key('C', I.andesiteCasing()) - .key('I', AllItems.WHISK.get()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" I ")), + .viaShaped(b -> b.define('S', I.cog()) + .define('B', I.andesite()) + .define('C', I.andesiteCasing()) + .define('I', AllItems.WHISK.get()) + .pattern(" B ") + .pattern("SCS") + .pattern(" I ")), CLUTCH = create(AllBlocks.CLUTCH).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', I.shaft()) - .key('B', I.redstone()) - .key('C', I.andesiteCasing()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" B ")), + .viaShaped(b -> b.define('S', I.shaft()) + .define('B', I.redstone()) + .define('C', I.andesiteCasing()) + .pattern(" B ") + .pattern("SCS") + .pattern(" B ")), GEARSHIFT = create(AllBlocks.GEARSHIFT).unlockedBy(I::andesite) - .viaShaped(b -> b.key('S', I.cog()) - .key('B', I.redstone()) - .key('C', I.andesiteCasing()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" B ")), + .viaShaped(b -> b.define('S', I.cog()) + .define('B', I.redstone()) + .define('C', I.andesiteCasing()) + .pattern(" B ") + .pattern("SCS") + .pattern(" B ")), SAIL_FRAME = create(AllBlocks.SAIL_FRAME).returns(8) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('A', I.andesite()) - .key('S', Tags.Items.RODS_WOODEN) - .patternLine("SSS") - .patternLine("SAS") - .patternLine("SSS")), + .viaShaped(b -> b.define('A', I.andesite()) + .define('S', Tags.Items.RODS_WOODEN) + .pattern("SSS") + .pattern("SAS") + .pattern("SSS")), SAIL = create(AllBlocks.SAIL).returns(8) .unlockedBy(AllBlocks.SAIL_FRAME::get) - .viaShaped(b -> b.key('F', AllBlocks.SAIL_FRAME.get()) - .key('W', ItemTags.WOOL) - .patternLine("FFF") - .patternLine("FWF") - .patternLine("FFF")), + .viaShaped(b -> b.define('F', AllBlocks.SAIL_FRAME.get()) + .define('W', ItemTags.WOOL) + .pattern("FFF") + .pattern("FWF") + .pattern("FFF")), RADIAL_CHASIS = create(AllBlocks.RADIAL_CHASSIS).returns(3) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('P', I.andesite()) - .key('L', ItemTags.LOGS) - .patternLine(" L ") - .patternLine("PLP") - .patternLine(" L ")), + .viaShaped(b -> b.define('P', I.andesite()) + .define('L', ItemTags.LOGS) + .pattern(" L ") + .pattern("PLP") + .pattern(" L ")), LINEAR_CHASIS = create(AllBlocks.LINEAR_CHASSIS).returns(3) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('P', I.andesite()) - .key('L', ItemTags.LOGS) - .patternLine(" P ") - .patternLine("LLL") - .patternLine(" P ")), + .viaShaped(b -> b.define('P', I.andesite()) + .define('L', ItemTags.LOGS) + .pattern(" P ") + .pattern("LLL") + .pattern(" P ")), LINEAR_CHASSIS_CYCLE = conversionCycle(ImmutableList.of(AllBlocks.LINEAR_CHASSIS, AllBlocks.SECONDARY_LINEAR_CHASSIS)), STICKER = create(AllBlocks.STICKER).returns(1) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('I', I.andesite()) - .key('C', Tags.Items.COBBLESTONE) - .key('R', I.redstone()) - .key('S', Tags.Items.SLIMEBALLS) - .patternLine("ISI") - .patternLine("CRC")), + .viaShaped(b -> b.define('I', I.andesite()) + .define('C', Tags.Items.COBBLESTONE) + .define('R', I.redstone()) + .define('S', Tags.Items.SLIMEBALLS) + .pattern("ISI") + .pattern("CRC")), MINECART = create(() -> Items.MINECART).withSuffix("_from_contraption_cart") .unlockedBy(AllBlocks.CART_ASSEMBLER::get) - .viaShapeless(b -> b.addIngredient(AllItems.MINECART_CONTRAPTION.get())), + .viaShapeless(b -> b.requires(AllItems.MINECART_CONTRAPTION.get())), FURNACE_MINECART = create(() -> Items.FURNACE_MINECART).withSuffix("_from_contraption_cart") .unlockedBy(AllBlocks.CART_ASSEMBLER::get) - .viaShapeless(b -> b.addIngredient(AllItems.FURNACE_MINECART_CONTRAPTION.get())), + .viaShapeless(b -> b.requires(AllItems.FURNACE_MINECART_CONTRAPTION.get())), GEARBOX = create(AllBlocks.GEARBOX).unlockedBy(I::cog) - .viaShaped(b -> b.key('C', I.cog()) - .key('B', I.andesiteCasing()) - .patternLine(" C ") - .patternLine("CBC") - .patternLine(" C ")), + .viaShaped(b -> b.define('C', I.cog()) + .define('B', I.andesiteCasing()) + .pattern(" C ") + .pattern("CBC") + .pattern(" C ")), GEARBOX_CYCLE = conversionCycle(ImmutableList.of(AllBlocks.GEARBOX, AllItems.VERTICAL_GEARBOX)), MYSTERIOUS_CUCKOO_CLOCK = create(AllBlocks.MYSTERIOUS_CUCKOO_CLOCK).unlockedBy(AllBlocks.CUCKOO_CLOCK::get) - .viaShaped(b -> b.key('C', Tags.Items.GUNPOWDER) - .key('B', AllBlocks.CUCKOO_CLOCK.get()) - .patternLine(" C ") - .patternLine("CBC") - .patternLine(" C ")), + .viaShaped(b -> b.define('C', Tags.Items.GUNPOWDER) + .define('B', AllBlocks.CUCKOO_CLOCK.get()) + .pattern(" C ") + .pattern("CBC") + .pattern(" C ")), ENCASED_CHAIN_DRIVE = create(AllBlocks.ENCASED_CHAIN_DRIVE).returns(2) .unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('S', I.shaft()) - .key('B', Tags.Items.NUGGETS_IRON) - .key('C', I.andesiteCasing()) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" B ")), + .viaShaped(b -> b.define('S', I.shaft()) + .define('B', Tags.Items.NUGGETS_IRON) + .define('C', I.andesiteCasing()) + .pattern(" B ") + .pattern("SCS") + .pattern(" B ")), SPEEDOMETER = create(AllBlocks.SPEEDOMETER).unlockedBy(I::andesite) - .viaShaped(b -> b.key('C', Items.COMPASS) - .key('A', I.andesiteCasing()) - .key('S', I.shaft()) - .patternLine(" C ") - .patternLine("SAS")), + .viaShaped(b -> b.define('C', Items.COMPASS) + .define('A', I.andesiteCasing()) + .define('S', I.shaft()) + .pattern(" C ") + .pattern("SAS")), GAUGE_CYCLE = conversionCycle(ImmutableList.of(AllBlocks.SPEEDOMETER, AllBlocks.STRESSOMETER)), ROTATION_SPEED_CONTROLLER = create(AllBlocks.ROTATION_SPEED_CONTROLLER).unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('B', I.precisionMechanism()) - .key('C', I.brassCasing()) - .key('S', I.shaft()) - .patternLine(" B ") - .patternLine("SCS")), + .viaShaped(b -> b.define('B', I.precisionMechanism()) + .define('C', I.brassCasing()) + .define('S', I.shaft()) + .pattern(" B ") + .pattern("SCS")), NIXIE_TUBE = create(AllBlocks.ORANGE_NIXIE_TUBE).unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('E', I.electronTube()) - .key('B', I.brassCasing()) - .patternLine("EBE")), + .viaShaped(b -> b.define('E', I.electronTube()) + .define('B', I.brassCasing()) + .pattern("EBE")), MECHANICAL_SAW = create(AllBlocks.MECHANICAL_SAW).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('C', I.andesiteCasing()) - .key('A', I.ironSheet()) - .key('I', I.iron()) - .patternLine(" A ") - .patternLine("AIA") - .patternLine(" C ")), + .viaShaped(b -> b.define('C', I.andesiteCasing()) + .define('A', I.ironSheet()) + .define('I', I.iron()) + .pattern(" A ") + .pattern("AIA") + .pattern(" C ")), MECHANICAL_HARVESTER = create(AllBlocks.MECHANICAL_HARVESTER).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('C', I.andesiteCasing()) - .key('A', I.andesite()) - .key('I', I.ironSheet()) - .patternLine("AIA") - .patternLine("AIA") - .patternLine(" C ")), + .viaShaped(b -> b.define('C', I.andesiteCasing()) + .define('A', I.andesite()) + .define('I', I.ironSheet()) + .pattern("AIA") + .pattern("AIA") + .pattern(" C ")), MECHANICAL_PLOUGH = create(AllBlocks.MECHANICAL_PLOUGH).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('C', I.andesiteCasing()) - .key('A', I.andesite()) - .key('I', I.ironSheet()) - .patternLine("III") - .patternLine("AAA") - .patternLine(" C ")), + .viaShaped(b -> b.define('C', I.andesiteCasing()) + .define('A', I.andesite()) + .define('I', I.ironSheet()) + .pattern("III") + .pattern("AAA") + .pattern(" C ")), MECHANICAL_DRILL = create(AllBlocks.MECHANICAL_DRILL).unlockedBy(I::andesiteCasing) - .viaShaped(b -> b.key('C', I.andesiteCasing()) - .key('A', I.andesite()) - .key('I', I.iron()) - .patternLine(" A ") - .patternLine("AIA") - .patternLine(" C ")), + .viaShaped(b -> b.define('C', I.andesiteCasing()) + .define('A', I.andesite()) + .define('I', I.iron()) + .pattern(" A ") + .pattern("AIA") + .pattern(" C ")), SEQUENCED_GEARSHIFT = create(AllBlocks.SEQUENCED_GEARSHIFT).unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('B', I.electronTube()) - .key('S', I.cog()) - .key('C', I.brassCasing()) - .key('I', Items.CLOCK) - .patternLine(" B ") - .patternLine("SCS") - .patternLine(" I ")) + .viaShaped(b -> b.define('B', I.electronTube()) + .define('S', I.cog()) + .define('C', I.brassCasing()) + .define('I', Items.CLOCK) + .pattern(" B ") + .pattern("SCS") + .pattern(" I ")) ; @@ -779,111 +783,111 @@ public class StandardRecipeGen extends CreateRecipeProvider { REDSTONE_CONTACT = create(AllBlocks.REDSTONE_CONTACT).returns(2) .unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('W', I.redstone()) - .key('C', Blocks.COBBLESTONE) - .key('S', I.ironSheet()) - .patternLine(" S ") - .patternLine("CWC") - .patternLine("CCC")), + .viaShaped(b -> b.define('W', I.redstone()) + .define('C', Blocks.COBBLESTONE) + .define('S', I.ironSheet()) + .pattern(" S ") + .pattern("CWC") + .pattern("CCC")), ANDESITE_FUNNEL = create(AllBlocks.ANDESITE_FUNNEL).returns(2) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('A', I.andesite()) - .key('K', Items.DRIED_KELP) - .patternLine("AKA") - .patternLine(" K ")), + .viaShaped(b -> b.define('A', I.andesite()) + .define('K', Items.DRIED_KELP) + .pattern("AKA") + .pattern(" K ")), BRASS_FUNNEL = create(AllBlocks.BRASS_FUNNEL).returns(2) .unlockedByTag(I::brass) - .viaShaped(b -> b.key('A', I.brass()) - .key('K', Items.DRIED_KELP) - .key('E', I.electronTube()) - .patternLine("AEA") - .patternLine(" K ")), + .viaShaped(b -> b.define('A', I.brass()) + .define('K', Items.DRIED_KELP) + .define('E', I.electronTube()) + .pattern("AEA") + .pattern(" K ")), ANDESITE_TUNNEL = create(AllBlocks.ANDESITE_TUNNEL).returns(2) .unlockedBy(I::andesite) - .viaShaped(b -> b.key('A', I.andesite()) - .key('K', Items.DRIED_KELP) - .patternLine("AA") - .patternLine("KK")), + .viaShaped(b -> b.define('A', I.andesite()) + .define('K', Items.DRIED_KELP) + .pattern("AA") + .pattern("KK")), BRASS_TUNNEL = create(AllBlocks.BRASS_TUNNEL).returns(2) .unlockedByTag(I::brass) - .viaShaped(b -> b.key('A', I.brass()) - .key('K', Items.DRIED_KELP) - .key('E', I.electronTube()) - .patternLine("E ") - .patternLine("AA") - .patternLine("KK")), + .viaShaped(b -> b.define('A', I.brass()) + .define('K', Items.DRIED_KELP) + .define('E', I.electronTube()) + .pattern("E ") + .pattern("AA") + .pattern("KK")), ADJUSTABLE_CRATE = create(AllBlocks.ADJUSTABLE_CRATE).returns(4) .unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('B', I.brassCasing()) - .patternLine("BBB") - .patternLine("B B") - .patternLine("BBB")), + .viaShaped(b -> b.define('B', I.brassCasing()) + .pattern("BBB") + .pattern("B B") + .pattern("BBB")), BELT_OBSERVER = create(AllBlocks.CONTENT_OBSERVER).unlockedBy(AllItems.BELT_CONNECTOR::get) - .viaShaped(b -> b.key('B', I.brassCasing()) - .key('R', I.redstone()) - .key('I', I.iron()) - .key('C', Blocks.OBSERVER) - .patternLine("RCI") - .patternLine(" B ")), + .viaShaped(b -> b.define('B', I.brassCasing()) + .define('R', I.redstone()) + .define('I', I.iron()) + .define('C', Blocks.OBSERVER) + .pattern("RCI") + .pattern(" B ")), STOCKPILE_SWITCH = create(AllBlocks.STOCKPILE_SWITCH).unlockedBy(I::brassCasing) - .viaShaped(b -> b.key('B', I.brassCasing()) - .key('R', I.redstone()) - .key('I', I.iron()) - .key('C', Blocks.COMPARATOR) - .patternLine("RCI") - .patternLine(" B ")), + .viaShaped(b -> b.define('B', I.brassCasing()) + .define('R', I.redstone()) + .define('I', I.iron()) + .define('C', Blocks.COMPARATOR) + .pattern("RCI") + .pattern(" B ")), ADJUSTABLE_REPEATER = create(AllBlocks.ADJUSTABLE_REPEATER).unlockedByTag(I::redstone) - .viaShaped(b -> b.key('T', Blocks.REDSTONE_TORCH) - .key('C', Items.CLOCK) - .key('R', I.redstone()) - .key('S', I.stone()) - .patternLine("RCT") - .patternLine("SSS")), + .viaShaped(b -> b.define('T', Blocks.REDSTONE_TORCH) + .define('C', Items.CLOCK) + .define('R', I.redstone()) + .define('S', I.stone()) + .pattern("RCT") + .pattern("SSS")), ADJUSTABLE_PULSE_REPEATER = create(AllBlocks.ADJUSTABLE_PULSE_REPEATER).unlockedByTag(I::redstone) - .viaShaped(b -> b.key('S', AllBlocks.PULSE_REPEATER.get()) - .key('P', AllBlocks.ADJUSTABLE_REPEATER.get()) - .patternLine("SP")), + .viaShaped(b -> b.define('S', AllBlocks.PULSE_REPEATER.get()) + .define('P', AllBlocks.ADJUSTABLE_REPEATER.get()) + .pattern("SP")), PULSE_REPEATER = create(AllBlocks.PULSE_REPEATER).unlockedByTag(I::redstone) - .viaShaped(b -> b.key('T', Blocks.REDSTONE_TORCH) - .key('R', I.redstone()) - .key('S', I.stone()) - .patternLine("RRT") - .patternLine("SSS")), + .viaShaped(b -> b.define('T', Blocks.REDSTONE_TORCH) + .define('R', I.redstone()) + .define('S', I.stone()) + .pattern("RRT") + .pattern("SSS")), POWERED_TOGGLE_LATCH = create(AllBlocks.POWERED_TOGGLE_LATCH).unlockedByTag(I::redstone) - .viaShaped(b -> b.key('T', Blocks.REDSTONE_TORCH) - .key('C', Blocks.LEVER) - .key('S', I.stone()) - .patternLine(" T ") - .patternLine(" C ") - .patternLine("SSS")), + .viaShaped(b -> b.define('T', Blocks.REDSTONE_TORCH) + .define('C', Blocks.LEVER) + .define('S', I.stone()) + .pattern(" T ") + .pattern(" C ") + .pattern("SSS")), POWERED_LATCH = create(AllBlocks.POWERED_LATCH).unlockedByTag(I::redstone) - .viaShaped(b -> b.key('T', Blocks.REDSTONE_TORCH) - .key('C', Blocks.LEVER) - .key('R', I.redstone()) - .key('S', I.stone()) - .patternLine(" T ") - .patternLine("RCR") - .patternLine("SSS")), + .viaShaped(b -> b.define('T', Blocks.REDSTONE_TORCH) + .define('C', Blocks.LEVER) + .define('R', I.redstone()) + .define('S', I.stone()) + .pattern(" T ") + .pattern("RCR") + .pattern("SSS")), REDSTONE_LINK = create(AllBlocks.REDSTONE_LINK).returns(2) .unlockedByTag(I::brass) - .viaShaped(b -> b.key('C', Blocks.REDSTONE_TORCH) - .key('S', I.brassSheet()) - .key('I', ItemTags.PLANKS) - .patternLine(" C") - .patternLine("SIS")) + .viaShaped(b -> b.define('C', Blocks.REDSTONE_TORCH) + .define('S', I.brassSheet()) + .define('I', ItemTags.PLANKS) + .pattern(" C") + .pattern("SIS")) ; @@ -892,29 +896,29 @@ public class StandardRecipeGen extends CreateRecipeProvider { GeneratedRecipe SCHEMATIC_TABLE = create(AllBlocks.SCHEMATIC_TABLE).unlockedBy(AllItems.EMPTY_SCHEMATIC::get) - .viaShaped(b -> b.key('W', ItemTags.WOODEN_SLABS) - .key('S', Blocks.SMOOTH_STONE) - .patternLine("WWW") - .patternLine(" S ") - .patternLine(" S ")), + .viaShaped(b -> b.define('W', ItemTags.WOODEN_SLABS) + .define('S', Blocks.SMOOTH_STONE) + .pattern("WWW") + .pattern(" S ") + .pattern(" S ")), SCHEMATICANNON = create(AllBlocks.SCHEMATICANNON).unlockedBy(AllItems.EMPTY_SCHEMATIC::get) - .viaShaped(b -> b.key('L', ItemTags.LOGS) - .key('D', Blocks.DISPENSER) - .key('C', Blocks.CAULDRON) - .key('S', Blocks.SMOOTH_STONE) - .key('I', Blocks.IRON_BLOCK) - .patternLine(" C ") - .patternLine("LDL") - .patternLine("SIS")), + .viaShaped(b -> b.define('L', ItemTags.LOGS) + .define('D', Blocks.DISPENSER) + .define('C', Blocks.CAULDRON) + .define('S', Blocks.SMOOTH_STONE) + .define('I', Blocks.IRON_BLOCK) + .pattern(" C ") + .pattern("LDL") + .pattern("SIS")), EMPTY_SCHEMATIC = create(AllItems.EMPTY_SCHEMATIC).unlockedBy(() -> Items.PAPER) - .viaShapeless(b -> b.addIngredient(Items.PAPER) - .addIngredient(Tags.Items.DYES_LIGHT_BLUE)), + .viaShapeless(b -> b.requires(Items.PAPER) + .requires(Tags.Items.DYES_LIGHT_BLUE)), SCHEMATIC_AND_QUILL = create(AllItems.SCHEMATIC_AND_QUILL).unlockedBy(() -> Items.PAPER) - .viaShapeless(b -> b.addIngredient(AllItems.EMPTY_SCHEMATIC.get()) - .addIngredient(Tags.Items.FEATHERS)) + .viaShapeless(b -> b.requires(AllItems.EMPTY_SCHEMATIC.get()) + .requires(Tags.Items.FEATHERS)) ; @@ -924,24 +928,24 @@ public class StandardRecipeGen extends CreateRecipeProvider { DARK_SCORIA = create(AllPaletteBlocks.DARK_SCORIA).returns(8) .unlockedBy(() -> AllPaletteBlocks.SCORIA.get()) - .viaShaped(b -> b.key('#', AllPaletteBlocks.SCORIA.get()) - .key('D', Tags.Items.DYES_BLACK) - .patternLine("###") - .patternLine("#D#") - .patternLine("###")), + .viaShaped(b -> b.define('#', AllPaletteBlocks.SCORIA.get()) + .define('D', Tags.Items.DYES_BLACK) + .pattern("###") + .pattern("#D#") + .pattern("###")), COPPER_SHINGLES = create(AllBlocks.COPPER_SHINGLES).returns(16) .unlockedByTag(I::copperSheet) - .viaShaped(b -> b.key('#', I.copperSheet()) - .patternLine("##") - .patternLine("##")), + .viaShaped(b -> b.define('#', I.copperSheet()) + .pattern("##") + .pattern("##")), COPPER_SHINGLES_FROM_TILES = create(AllBlocks.COPPER_SHINGLES).withSuffix("_from_tiles") .unlockedByTag(I::copperSheet) - .viaShapeless(b -> b.addIngredient(AllBlocks.COPPER_TILES.get())), + .viaShapeless(b -> b.requires(AllBlocks.COPPER_TILES.get())), COPPER_TILES = create(AllBlocks.COPPER_TILES).unlockedByTag(I::copperSheet) - .viaShapeless(b -> b.addIngredient(AllBlocks.COPPER_SHINGLES.get())) + .viaShapeless(b -> b.requires(AllBlocks.COPPER_SHINGLES.get())) ; @@ -950,52 +954,52 @@ public class StandardRecipeGen extends CreateRecipeProvider { GeneratedRecipe DOUGH = create(AllItems.DOUGH).unlockedBy(AllItems.WHEAT_FLOUR::get) - .viaShapeless(b -> b.addIngredient(AllItems.WHEAT_FLOUR.get()) - .addIngredient(Items.WATER_BUCKET)), + .viaShapeless(b -> b.requires(AllItems.WHEAT_FLOUR.get()) + .requires(Items.WATER_BUCKET)), DIVING_HELMET = create(AllItems.DIVING_HELMET).unlockedByTag(I::copper) - .viaShaped(b -> b.key('G', Tags.Items.GLASS) - .key('P', I.copper()) - .patternLine("PPP") - .patternLine("PGP")), + .viaShaped(b -> b.define('G', Tags.Items.GLASS) + .define('P', I.copper()) + .pattern("PPP") + .pattern("PGP")), COPPER_BACKTANK = create(AllItems.COPPER_BACKTANK).unlockedByTag(I::copper) - .viaShaped(b -> b.key('G', I.shaft()) - .key('A', I.andesite()) - .key('B', I.copperBlock()) - .key('P', I.copper()) - .patternLine("AGA") - .patternLine("PBP") - .patternLine(" P ")), + .viaShaped(b -> b.define('G', I.shaft()) + .define('A', I.andesite()) + .define('B', I.copperBlock()) + .define('P', I.copper()) + .pattern("AGA") + .pattern("PBP") + .pattern(" P ")), DIVING_BOOTS = create(AllItems.DIVING_BOOTS).unlockedByTag(I::copper) - .viaShaped(b -> b.key('G', I.andesite()) - .key('P', I.copper()) - .patternLine("P P") - .patternLine("P P") - .patternLine("G G")), + .viaShaped(b -> b.define('G', I.andesite()) + .define('P', I.copper()) + .pattern("P P") + .pattern("P P") + .pattern("G G")), LINKED_CONTROLLER = create(AllItems.LINKED_CONTROLLER).unlockedBy(AllBlocks.REDSTONE_LINK::get) - .viaShaped(b -> b.key('S', ItemTags.WOODEN_BUTTONS) - .key('P', AllBlocks.REDSTONE_LINK.get()) - .patternLine("SSS") - .patternLine(" P ") - .patternLine("SSS")), + .viaShaped(b -> b.define('S', ItemTags.WOODEN_BUTTONS) + .define('P', AllBlocks.REDSTONE_LINK.get()) + .pattern("SSS") + .pattern(" P ") + .pattern("SSS")), CRAFTING_BLUEPRINT = create(AllItems.CRAFTING_BLUEPRINT).unlockedBy(() -> Items.CRAFTING_TABLE) - .viaShapeless(b -> b.addIngredient(Items.PAINTING) - .addIngredient(Items.CRAFTING_TABLE)), + .viaShapeless(b -> b.requires(Items.PAINTING) + .requires(Items.CRAFTING_TABLE)), SLIME_BALL = create(() -> Items.SLIME_BALL).unlockedBy(AllItems.DOUGH::get) - .viaShapeless(b -> b.addIngredient(AllItems.DOUGH.get()) - .addIngredient(Tags.Items.DYES_LIME)), + .viaShapeless(b -> b.requires(AllItems.DOUGH.get()) + .requires(Tags.Items.DYES_LIME)), TREE_FERTILIZER = create(AllItems.TREE_FERTILIZER).returns(2) .unlockedBy(() -> Items.BONE_MEAL) - .viaShapeless(b -> b.addIngredient(Ingredient.fromTag(ItemTags.SMALL_FLOWERS), 2) - .addIngredient(Ingredient.fromItems(Items.HORN_CORAL, Items.BRAIN_CORAL, Items.TUBE_CORAL, + .viaShapeless(b -> b.requires(Ingredient.of(ItemTags.SMALL_FLOWERS), 2) + .requires(Ingredient.of(Items.HORN_CORAL, Items.BRAIN_CORAL, Items.TUBE_CORAL, Items.BUBBLE_CORAL, Items.FIRE_CORAL)) - .addIngredient(Items.BONE_MEAL)) + .requires(Items.BONE_MEAL)) ; @@ -1130,15 +1134,15 @@ public class StandardRecipeGen extends CreateRecipeProvider { result = create(nextEntry).withSuffix("_from_compacting") .unlockedBy(currentEntry::get) - .viaShaped(b -> b.patternLine("###") - .patternLine("###") - .patternLine("###") - .key('#', currentIngredient.get())); + .viaShaped(b -> b.pattern("###") + .pattern("###") + .pattern("###") + .define('#', currentIngredient.get())); result = create(currentEntry).returns(9) .withSuffix("_from_decompacting") .unlockedBy(nextEntry::get) - .viaShapeless(b -> b.addIngredient(nextIngredient.get())); + .viaShapeless(b -> b.requires(nextIngredient.get())); } return result; } @@ -1150,7 +1154,7 @@ public class StandardRecipeGen extends CreateRecipeProvider { ItemProviderEntry nextEntry = cycle.get((i + 1) % cycle.size()); result = create(nextEntry).withSuffix("from_conversion") .unlockedBy(currentEntry::get) - .viaShapeless(b -> b.addIngredient(currentEntry.get())); + .viaShapeless(b -> b.requires(currentEntry.get())); } return result; } @@ -1189,15 +1193,15 @@ public class StandardRecipeGen extends CreateRecipeProvider { } GeneratedRecipeBuilder unlockedBy(Supplier item) { - this.unlockedBy = () -> ItemPredicate.Builder.create() - .item(item.get()) + this.unlockedBy = () -> ItemPredicate.Builder.item() + .of(item.get()) .build(); return this; } GeneratedRecipeBuilder unlockedByTag(Supplier> tag) { - this.unlockedBy = () -> ItemPredicate.Builder.create() - .tag(tag.get()) + this.unlockedBy = () -> ItemPredicate.Builder.item() + .of(tag.get()) .build(); return this; } @@ -1222,19 +1226,19 @@ public class StandardRecipeGen extends CreateRecipeProvider { GeneratedRecipe viaShaped(UnaryOperator builder) { return register(consumer -> { - ShapedRecipeBuilder b = builder.apply(ShapedRecipeBuilder.shapedRecipe(result.get(), amount)); + ShapedRecipeBuilder b = builder.apply(ShapedRecipeBuilder.shaped(result.get(), amount)); if (unlockedBy != null) - b.addCriterion("has_item", hasItem(unlockedBy.get())); - b.build(consumer, createLocation("crafting")); + b.unlockedBy("has_item", inventoryTrigger(unlockedBy.get())); + b.save(consumer, createLocation("crafting")); }); } GeneratedRecipe viaShapeless(UnaryOperator builder) { return register(consumer -> { - ShapelessRecipeBuilder b = builder.apply(ShapelessRecipeBuilder.shapelessRecipe(result.get(), amount)); + ShapelessRecipeBuilder b = builder.apply(ShapelessRecipeBuilder.shapeless(result.get(), amount)); if (unlockedBy != null) - b.addCriterion("has_item", hasItem(unlockedBy.get())); - b.build(consumer, createLocation("crafting")); + b.unlockedBy("has_item", inventoryTrigger(unlockedBy.get())); + b.save(consumer, createLocation("crafting")); }); } @@ -1253,11 +1257,11 @@ public class StandardRecipeGen extends CreateRecipeProvider { } GeneratedCookingRecipeBuilder viaCooking(Supplier item) { - return unlockedBy(item).viaCookingIngredient(() -> Ingredient.fromItems(item.get())); + return unlockedBy(item).viaCookingIngredient(() -> Ingredient.of(item.get())); } GeneratedCookingRecipeBuilder viaCookingTag(Supplier> tag) { - return unlockedByTag(tag).viaCookingIngredient(() -> Ingredient.fromTag(tag.get())); + return unlockedByTag(tag).viaCookingIngredient(() -> Ingredient.of(tag.get())); } GeneratedCookingRecipeBuilder viaCookingIngredient(Supplier ingredient) { @@ -1270,9 +1274,9 @@ public class StandardRecipeGen extends CreateRecipeProvider { private float exp; private int cookingTime; - private final CookingRecipeSerializer FURNACE = IRecipeSerializer.SMELTING, - SMOKER = IRecipeSerializer.SMOKING, BLAST = IRecipeSerializer.BLASTING, - CAMPFIRE = IRecipeSerializer.CAMPFIRE_COOKING; + private final CookingRecipeSerializer FURNACE = IRecipeSerializer.SMELTING_RECIPE, + SMOKER = IRecipeSerializer.SMOKING_RECIPE, BLAST = IRecipeSerializer.BLASTING_RECIPE, + CAMPFIRE = IRecipeSerializer.CAMPFIRE_COOKING_RECIPE; GeneratedCookingRecipeBuilder(Supplier ingredient) { this.ingredient = ingredient; @@ -1323,11 +1327,11 @@ public class StandardRecipeGen extends CreateRecipeProvider { boolean isOtherMod = compatDatagenOutput != null; CookingRecipeBuilder b = builder.apply( - CookingRecipeBuilder.cookingRecipe(ingredient.get(), isOtherMod ? Items.DIRT : result.get(), + CookingRecipeBuilder.cooking(ingredient.get(), isOtherMod ? Items.DIRT : result.get(), exp, (int) (cookingTime * cookingTimeModifier), serializer)); if (unlockedBy != null) - b.addCriterion("has_item", hasItem(unlockedBy.get())); - b.build(result -> { + b.unlockedBy("has_item", inventoryTrigger(unlockedBy.get())); + b.save(result -> { consumer.accept( isOtherMod ? new ModdedCookingRecipeResult(result, compatDatagenOutput, recipeConditions) : result); @@ -1361,28 +1365,28 @@ public class StandardRecipeGen extends CreateRecipeProvider { } @Override - public ResourceLocation getID() { - return wrapped.getID(); + public ResourceLocation getId() { + return wrapped.getId(); } @Override - public IRecipeSerializer getSerializer() { - return wrapped.getSerializer(); + public IRecipeSerializer getType() { + return wrapped.getType(); } @Override - public JsonObject getAdvancementJson() { - return wrapped.getAdvancementJson(); + public JsonObject serializeAdvancement() { + return wrapped.serializeAdvancement(); } @Override - public ResourceLocation getAdvancementID() { - return wrapped.getAdvancementID(); + public ResourceLocation getAdvancementId() { + return wrapped.getAdvancementId(); } @Override - public void serialize(JsonObject object) { - wrapped.serialize(object); + public void serializeRecipeData(JsonObject object) { + wrapped.serializeRecipeData(object); object.addProperty("result", outputOverride.toString()); JsonArray conds = new JsonArray(); diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java index 8f8bb2a0b..1ae416478 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java @@ -26,6 +26,8 @@ import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.Tags; +import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe; + public class WashingRecipeGen extends ProcessingRecipeGen { GeneratedRecipe @@ -100,7 +102,7 @@ public class WashingRecipeGen extends ProcessingRecipeGen { ResourceLocation nugget = mod.nuggetOf(metalName); create(mod.getId() + "/" + crushed.getId() .getPath(), - b -> b.withItemIngredients(Ingredient.fromItems(crushed::get)) + b -> b.withItemIngredients(Ingredient.of(crushed::get)) .output(1, nugget, 10) .output(.5f, nugget, 5) .whenModLoaded(mod.getId())); diff --git a/src/main/java/com/simibubi/create/foundation/fluid/CombinedTankWrapper.java b/src/main/java/com/simibubi/create/foundation/fluid/CombinedTankWrapper.java index 8a25aa0fe..6639e9722 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/CombinedTankWrapper.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/CombinedTankWrapper.java @@ -6,6 +6,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.wrapper.EmptyHandler; +import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; + /** * Combines multiple IFluidHandlers into one interface (See CombinedInvWrapper * for items) diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java index b6494e1d9..2ec01040d 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java @@ -48,9 +48,9 @@ public class FluidHelper { } public static boolean hasBlockState(Fluid fluid) { - BlockState blockState = fluid.getDefaultState() - .getBlockState(); - return blockState != null && blockState != Blocks.AIR.getDefaultState(); + BlockState blockState = fluid.defaultFluidState() + .createLegacyBlock(); + return blockState != null && blockState != Blocks.AIR.defaultBlockState(); } public static FluidStack copyStackWithAmount(FluidStack fs, int amount) { @@ -67,7 +67,7 @@ public class FluidHelper { if (fluid == Fluids.LAVA) return Fluids.FLOWING_LAVA; if (fluid instanceof ForgeFlowingFluid) - return ((ForgeFlowingFluid) fluid).getFlowingFluid(); + return ((ForgeFlowingFluid) fluid).getFlowing(); return fluid; } @@ -77,7 +77,7 @@ public class FluidHelper { if (fluid == Fluids.FLOWING_LAVA) return Fluids.LAVA; if (fluid instanceof ForgeFlowingFluid) - return ((ForgeFlowingFluid) fluid).getStillFluid(); + return ((ForgeFlowingFluid) fluid).getSource(); return fluid; } @@ -94,11 +94,11 @@ public class FluidHelper { } public static FluidStack deserializeFluidStack(JsonObject json) { - ResourceLocation id = new ResourceLocation(JSONUtils.getString(json, "fluid")); + ResourceLocation id = new ResourceLocation(JSONUtils.getAsString(json, "fluid")); Fluid fluid = ForgeRegistries.FLUIDS.getValue(id); if (fluid == null) throw new JsonSyntaxException("Unknown fluid '" + id + "'"); - int amount = JSONUtils.getInt(json, "amount"); + int amount = JSONUtils.getAsInt(json, "amount"); FluidStack stack = new FluidStack(fluid, amount); if (!json.has("nbt")) @@ -106,8 +106,8 @@ public class FluidHelper { try { JsonElement element = json.get("nbt"); - stack.setTag(JsonToNBT.getTagFromJson( - element.isJsonObject() ? Create.GSON.toJson(element) : JSONUtils.getString(element, "nbt"))); + stack.setTag(JsonToNBT.parseTag( + element.isJsonObject() ? Create.GSON.toJson(element) : JSONUtils.convertToString(element, "nbt"))); } catch (CommandSyntaxException e) { e.printStackTrace(); @@ -128,7 +128,7 @@ public class FluidHelper { if (tank == null || fluidStack.getAmount() != tank.fill(fluidStack, FluidAction.SIMULATE)) return false; - if (worldIn.isRemote) + if (worldIn.isClientSide) return true; ItemStack copyOfHeld = heldItem.copy(); @@ -137,9 +137,9 @@ public class FluidHelper { if (!player.isCreative() && !(te instanceof CreativeFluidTankTileEntity)) { if (copyOfHeld.isEmpty()) - player.setHeldItem(handIn, emptyingResult.getSecond()); + player.setItemInHand(handIn, emptyingResult.getSecond()); else { - player.setHeldItem(handIn, copyOfHeld); + player.setItemInHand(handIn, copyOfHeld); player.inventory.placeItemBackInInventory(worldIn, emptyingResult.getSecond()); } } @@ -167,7 +167,7 @@ public class FluidHelper { if (requiredAmountForItem > fluid.getAmount()) continue; - if (world.isRemote) + if (world.isClientSide) return true; if (player.isCreative() || te instanceof CreativeFluidTankTileEntity) diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java index 1082cb755..65e9d416a 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java @@ -131,7 +131,7 @@ public abstract class FluidIngredient implements Predicate { if (!json.has("amount")) throw new JsonSyntaxException("Fluid ingredient has to define an amount"); - ingredient.amountRequired = JSONUtils.getInt(json, "amount"); + ingredient.amountRequired = JSONUtils.getAsInt(json, "amount"); return ingredient; } @@ -146,13 +146,13 @@ public abstract class FluidIngredient implements Predicate { void fixFlowing() { if (fluid instanceof FlowingFluid) - fluid = ((FlowingFluid) fluid).getStillFluid(); + fluid = ((FlowingFluid) fluid).getSource(); } @Override protected boolean testInternal(FluidStack t) { if (!t.getFluid() - .isEquivalentTo(fluid)) + .isSame(fluid)) return false; if (tagToMatch.isEmpty()) return true; @@ -165,13 +165,13 @@ public abstract class FluidIngredient implements Predicate { @Override protected void readInternal(PacketBuffer buffer) { fluid = buffer.readRegistryId(); - tagToMatch = buffer.readCompoundTag(); + tagToMatch = buffer.readNbt(); } @Override protected void writeInternal(PacketBuffer buffer) { buffer.writeRegistryId(fluid); - buffer.writeCompoundTag(tagToMatch); + buffer.writeNbt(tagToMatch); } @Override @@ -205,10 +205,10 @@ public abstract class FluidIngredient implements Predicate { if (tag == null) for (FluidStack accepted : getMatchingFluidStacks()) if (accepted.getFluid() - .isEquivalentTo(t.getFluid())) + .isSame(t.getFluid())) return true; return t.getFluid() - .isIn(tag); + .is(tag); } @Override @@ -230,10 +230,10 @@ public abstract class FluidIngredient implements Predicate { @Override protected void readInternal(JsonObject json) { - ResourceLocation id = new ResourceLocation(JSONUtils.getString(json, "fluidTag")); - Optional> optionalINamedTag = FluidTags.getRequiredTags() + ResourceLocation id = new ResourceLocation(JSONUtils.getAsString(json, "fluidTag")); + Optional> optionalINamedTag = FluidTags.getWrappers() .stream() - .filter(fluidINamedTag -> fluidINamedTag.getId() + .filter(fluidINamedTag -> fluidINamedTag.getName() .equals(id)) .findFirst(); // fixme if (!optionalINamedTag.isPresent()) @@ -243,17 +243,17 @@ public abstract class FluidIngredient implements Predicate { @Override protected void writeInternal(JsonObject json) { - json.addProperty("fluidTag", tag.getId() + json.addProperty("fluidTag", tag.getName() .toString()); } @Override protected List determineMatchingFluidStacks() { - return tag.values() + return tag.getValues() .stream() .map(f -> { if (f instanceof FlowingFluid) - return ((FlowingFluid) f).getStillFluid(); + return ((FlowingFluid) f).getSource(); return f; }) .distinct() diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java index a87676674..3415ddf52 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java @@ -46,7 +46,7 @@ public class FluidRenderer { Fluid fluid = fluidStack.getFluid(); FluidAttributes fluidAttributes = fluid.getAttributes(); Function spriteAtlas = Minecraft.getInstance() - .getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE); + .getTextureAtlas(PlayerContainer.BLOCK_ATLAS); TextureAtlasSprite flowTexture = spriteAtlas.apply(fluidAttributes.getFlowingTexture(fluidStack)); TextureAtlasSprite stillTexture = spriteAtlas.apply(fluidAttributes.getStillTexture(fluidStack)); @@ -59,7 +59,7 @@ public class FluidRenderer { direction = direction.getOpposite(); MatrixStacker msr = MatrixStacker.of(ms); - ms.push(); + ms.pushPose(); msr.centre() .rotateY(AngleHelper.horizontalAngle(direction)) .rotateX(direction == Direction.UP ? 0 : direction == Direction.DOWN ? 180 : 90) @@ -74,10 +74,10 @@ public class FluidRenderer { float yMax = y + MathHelper.clamp(progress * .5f - 1e-6f, 0, 1); for (int i = 0; i < 4; i++) { - ms.push(); + ms.pushPose(); renderTiledHorizontalFace(h, Direction.SOUTH, hMin, yMin, hMax, yMax, builder, ms, light, color, flowTexture); - ms.pop(); + ms.popPose(); msr.rotateY(90); } @@ -85,7 +85,7 @@ public class FluidRenderer { renderTiledVerticalFace(yMax, Direction.UP, hMin, hMin, hMax, hMax, builder, ms, light, color, stillTexture); - ms.pop(); + ms.popPose(); } public static void renderTiledFluidBB(FluidStack fluidStack, float xMin, float yMin, float zMin, float xMax, @@ -98,7 +98,7 @@ public class FluidRenderer { Fluid fluid = fluidStack.getFluid(); FluidAttributes fluidAttributes = fluid.getAttributes(); TextureAtlasSprite fluidTexture = Minecraft.getInstance() - .getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE) + .getTextureAtlas(PlayerContainer.BLOCK_ATLAS) .apply(fluidAttributes.getStillTexture(fluidStack)); int color = fluidAttributes.getColor(fluidStack); @@ -108,7 +108,7 @@ public class FluidRenderer { Vector3d center = new Vector3d(xMin + (xMax - xMin) / 2, yMin + (yMax - yMin) / 2, zMin + (zMax - zMin) / 2); MatrixStacker msr = MatrixStacker.of(ms); - ms.push(); + ms.pushPose(); if (fluidStack.getFluid() .getAttributes() .isLighterThanAir()) @@ -123,7 +123,7 @@ public class FluidRenderer { if (side.getAxis() .isHorizontal()) { - ms.push(); + ms.pushPose(); if (side.getAxisDirection() == AxisDirection.NEGATIVE) msr.translate(center) @@ -135,7 +135,7 @@ public class FluidRenderer { renderTiledHorizontalFace(X ? xMax : zMax, side, X ? zMin : xMin, yMin, X ? zMax : xMax, yMax, builder, ms, light, darkColor, fluidTexture); - ms.pop(); + ms.popPose(); continue; } @@ -143,7 +143,7 @@ public class FluidRenderer { light, color, fluidTexture); } - ms.pop(); + ms.popPose(); } @@ -156,10 +156,10 @@ public class FluidRenderer { for (float z1 = zMin; z1 < zMax; z1 = z2) { z2 = Math.min((int) (z1 + 1), zMax); - float u1 = texture.getInterpolatedU(local(x1) * 16); - float v1 = texture.getInterpolatedV(local(z1) * 16); - float u2 = texture.getInterpolatedU(x2 == xMax ? local(x2) * 16 : 16); - float v2 = texture.getInterpolatedV(z2 == zMax ? local(z2) * 16 : 16); + float u1 = texture.getU(local(x1) * 16); + float v1 = texture.getV(local(z1) * 16); + float u2 = texture.getU(x2 == xMax ? local(x2) * 16 : 16); + float v2 = texture.getV(z2 == zMax ? local(z2) * 16 : 16); putVertex(builder, ms, x1, y, z2, color, u1, v2, face, light); putVertex(builder, ms, x2, y, z2, color, u2, v2, face, light); @@ -182,10 +182,10 @@ public class FluidRenderer { y2 = Math.min((int) (y1 + 1), yMax); int multiplier = texture.getWidth() == 32 ? 8 : 16; - float u1 = texture.getInterpolatedU(local(h1) * multiplier); - float v1 = texture.getInterpolatedV(local(y1) * multiplier); - float u2 = texture.getInterpolatedU(h2 == hMax ? local(h2) * multiplier : multiplier); - float v2 = texture.getInterpolatedV(y2 == yMax ? local(y2) * multiplier : multiplier); + float u1 = texture.getU(local(h1) * multiplier); + float v1 = texture.getV(local(y1) * multiplier); + float u2 = texture.getU(h2 == hMax ? local(h2) * multiplier : multiplier); + float v2 = texture.getV(y2 == yMax ? local(y2) * multiplier : multiplier); float x1 = X ? h : h1; float x2 = X ? h : h2; @@ -209,19 +209,19 @@ public class FluidRenderer { private static void putVertex(IVertexBuilder builder, MatrixStack ms, float x, float y, float z, int color, float u, float v, Direction face, int light) { - Vector3i n = face.getDirectionVec(); - Entry peek = ms.peek(); + Vector3i n = face.getNormal(); + Entry peek = ms.last(); int ff = 0xff; int a = color >> 24 & ff; int r = color >> 16 & ff; int g = color >> 8 & ff; int b = color & ff; - builder.vertex(peek.getModel(), x, y, z) + builder.vertex(peek.pose(), x, y, z) .color(r, g, b, a) - .texture(u, v) - .overlay(OverlayTexture.DEFAULT_UV) - .light(light) + .uv(u, v) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(light) .normal(n.getX(), n.getY(), n.getZ()) .endVertex(); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiContainerScreen.java b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiContainerScreen.java index fe7b26623..acc765909 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiContainerScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiContainerScreen.java @@ -44,8 +44,8 @@ public abstract class AbstractSimiContainerScreen extends C } protected void setWindowSize(int width, int height) { - this.xSize = width; - this.ySize = height; + this.imageWidth = width; + this.imageHeight = height; } protected void setWindowOffset(int xOffset, int yOffset) { @@ -56,12 +56,12 @@ public abstract class AbstractSimiContainerScreen extends C @Override protected void init() { super.init(); - guiLeft += windowXOffset; - guiTop += windowYOffset; + leftPos += windowXOffset; + topPos += windowYOffset; } @Override - protected void drawForeground(MatrixStack p_230451_1_, int p_230451_2_, int p_230451_3_) { + protected void renderLabels(MatrixStack p_230451_1_, int p_230451_2_, int p_230451_3_) { // no-op to prevent screen- and inventory-title from being rendered at incorrect location // could also set this.titleX/Y and this.playerInventoryTitleX/Y to the proper values instead } @@ -69,7 +69,7 @@ public abstract class AbstractSimiContainerScreen extends C @Override public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { partialTicks = Minecraft.getInstance() - .getRenderPartialTicks(); + .getFrameTime(); renderBackground(matrixStack); renderWindow(matrixStack, mouseX, mouseY, partialTicks); @@ -81,7 +81,7 @@ public abstract class AbstractSimiContainerScreen extends C RenderSystem.enableAlphaTest(); RenderSystem.enableBlend(); RenderSystem.disableRescaleNormal(); - RenderHelper.disableStandardItemLighting(); + RenderHelper.turnOff(); RenderSystem.disableLighting(); RenderSystem.disableDepthTest(); renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks); @@ -107,8 +107,8 @@ public abstract class AbstractSimiContainerScreen extends C if (super.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_)) return true; - InputMappings.Input mouseKey = InputMappings.getInputByCode(code, p_keyPressed_2_); - if (this.client.gameSettings.keyBindInventory.isActiveAndMatches(mouseKey)) { + InputMappings.Input mouseKey = InputMappings.getKey(code, p_keyPressed_2_); + if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { this.onClose(); return true; } @@ -146,18 +146,18 @@ public abstract class AbstractSimiContainerScreen extends C protected abstract void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks); @Override - protected void drawBackground(MatrixStack p_230450_1_, float p_230450_2_, int p_230450_3_, int p_230450_4_) { + protected void renderBg(MatrixStack p_230450_1_, float p_230450_2_, int p_230450_3_, int p_230450_4_) { } protected void renderWindowForeground(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - drawMouseoverTooltip(matrixStack, mouseX, mouseY); + renderTooltip(matrixStack, mouseX, mouseY); for (Widget widget : widgets) { if (!widget.isHovered()) continue; if (widget instanceof AbstractSimiWidget) { if (!((AbstractSimiWidget) widget).getToolTip().isEmpty()) - renderTooltip(matrixStack, ((AbstractSimiWidget) widget).getToolTip(), mouseX, mouseY); + renderComponentTooltip(matrixStack, ((AbstractSimiWidget) widget).getToolTip(), mouseX, mouseY); } else { widget.renderToolTip(matrixStack, mouseX, mouseY); @@ -166,8 +166,8 @@ public abstract class AbstractSimiContainerScreen extends C } public double getItemCountTextScale() { - int guiScaleFactor = (int) client.getWindow() - .getGuiScaleFactor(); + int guiScaleFactor = (int) minecraft.getWindow() + .getGuiScale(); double scale = 1; switch (guiScaleFactor) { case 1: @@ -194,7 +194,7 @@ public abstract class AbstractSimiContainerScreen extends C public void renderPlayerInventory(MatrixStack ms, int x, int y) { AllGuiTextures.PLAYER_INVENTORY.draw(ms, this, x, y); - textRenderer.draw(ms, playerInventory.getDisplayName(), x + 8, y + 6, 0x404040); + font.draw(ms, inventory.getDisplayName(), x + 8, y + 6, 0x404040); } /** @@ -221,7 +221,7 @@ public abstract class AbstractSimiContainerScreen extends C RenderSystem.disableAlphaTest(); RenderSystem.disableBlend(); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); + BufferBuilder bufferbuilder = tessellator.getBuilder(); double health = stack.getItem() .getDurabilityForDisplay(stack); int i = Math.round(13.0F - (float) health * 13.0F); @@ -242,19 +242,19 @@ public abstract class AbstractSimiContainerScreen extends C RenderSystem.disableLighting(); RenderSystem.disableDepthTest(); RenderSystem.disableBlend(); - matrixStack.push(); + matrixStack.pushPose(); - int guiScaleFactor = (int) client.getWindow() - .getGuiScaleFactor(); + int guiScaleFactor = (int) minecraft.getWindow() + .getGuiScale(); matrixStack.translate(xPosition + 16.5f, yPosition + 16.5f, 0); double scale = getItemCountTextScale(); matrixStack.scale((float) scale, (float) scale, 0); - matrixStack.translate(-fr.getStringWidth(s) - (guiScaleFactor > 1 ? 0 : -.5f), - -textRenderer.FONT_HEIGHT + (guiScaleFactor > 1 ? 1 : 1.75f), 0); - fr.drawWithShadow(matrixStack, s, 0, 0, textColor); + matrixStack.translate(-fr.width(s) - (guiScaleFactor > 1 ? 0 : -.5f), + -font.lineHeight + (guiScaleFactor > 1 ? 1 : 1.75f), 0); + fr.drawShadow(matrixStack, s, 0, 0, textColor); - matrixStack.pop(); + matrixStack.popPose(); RenderSystem.enableBlend(); RenderSystem.enableLighting(); RenderSystem.enableDepthTest(); @@ -280,12 +280,12 @@ public abstract class AbstractSimiContainerScreen extends C .color(red, green, blue, alpha) .endVertex(); Tessellator.getInstance() - .draw(); + .end(); } @Deprecated protected void debugWindowArea(MatrixStack matrixStack) { - fill(matrixStack, guiLeft + xSize, guiTop + ySize, guiLeft, guiTop, 0xD3D3D3D3); + fill(matrixStack, leftPos + imageWidth, topPos + imageHeight, leftPos, topPos, 0xD3D3D3D3); } @Deprecated diff --git a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java index a9d07e4ec..1329ee837 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java @@ -62,9 +62,9 @@ public abstract class AbstractSimiScreen extends Screen { public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { partialTicks = partialTicks == 10 ? 0 : Minecraft.getInstance() - .getRenderPartialTicks(); + .getFrameTime(); - ms.push(); + ms.pushPose(); prepareFrame(); @@ -76,7 +76,7 @@ public abstract class AbstractSimiScreen extends Screen { endFrame(); - ms.pop(); + ms.popPose(); } protected void prepareFrame() { @@ -111,8 +111,8 @@ public abstract class AbstractSimiScreen extends Screen { if (super.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_)) return true; - InputMappings.Input mouseKey = InputMappings.getInputByCode(code, p_keyPressed_2_); - if (this.client.gameSettings.keyBindInventory.isActiveAndMatches(mouseKey)) { + InputMappings.Input mouseKey = InputMappings.getKey(code, p_keyPressed_2_); + if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { this.onClose(); return true; } @@ -166,7 +166,7 @@ public abstract class AbstractSimiScreen extends Screen { if (widget instanceof AbstractSimiWidget) { if (!((AbstractSimiWidget) widget).getToolTip().isEmpty()) - renderTooltip(ms, ((AbstractSimiWidget) widget).getToolTip(), mouseX, mouseY); + renderComponentTooltip(ms, ((AbstractSimiWidget) widget).getToolTip(), mouseX, mouseY); } else { widget.renderToolTip(ms, mouseX, mouseY); diff --git a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java index a063943d3..54e04197d 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java @@ -132,14 +132,14 @@ public enum AllGuiTextures implements IScreenRenderable { public void bind() { Minecraft.getInstance() .getTextureManager() - .bindTexture(location); + .bind(location); } @Override @OnlyIn(Dist.CLIENT) public void draw(MatrixStack ms, AbstractGui screen, int x, int y) { bind(); - screen.drawTexture(ms, x, y, startX, startY, width, height); + screen.blit(ms, x, y, startX, startY, width, height); } public void draw(MatrixStack ms, int x, int y, Color c) { 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 3351867e7..23d28abe8 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java @@ -163,24 +163,24 @@ public class AllIcons implements IScreenRenderable { public void bind() { Minecraft.getInstance() .getTextureManager() - .bindTexture(ICON_ATLAS); + .bind(ICON_ATLAS); } @Override @OnlyIn(Dist.CLIENT) public void draw(MatrixStack matrixStack, AbstractGui screen, int x, int y) { bind(); - screen.drawTexture(matrixStack, x, y, iconX, iconY, 16, 16); + screen.blit(matrixStack, x, y, iconX, iconY, 16, 16); } @OnlyIn(Dist.CLIENT) public void draw(MatrixStack ms, IRenderTypeBuffer buffer, int color) { - IVertexBuilder builder = buffer.getBuffer(RenderType.getTextSeeThrough(ICON_ATLAS)); + IVertexBuilder builder = buffer.getBuffer(RenderType.textSeeThrough(ICON_ATLAS)); float sheetSize = 256; int i = 15 << 20 | 15 << 4; int j = i >> 16 & '\uffff'; int k = i & '\uffff'; - Entry peek = ms.peek(); + Entry peek = ms.last(); Vector3d rgb = ColorHelper.getRGB(color); Vector3d vec4 = new Vector3d(1, 1, 0); @@ -206,10 +206,10 @@ public class AllIcons implements IScreenRenderable { @OnlyIn(Dist.CLIENT) private void vertex(Entry peek, IVertexBuilder builder, int j, int k, Vector3d rgb, Vector3d vec, float u, float v) { - builder.vertex(peek.getModel(), (float) vec.x, (float) vec.y, (float) vec.z) + builder.vertex(peek.pose(), (float) vec.x, (float) vec.y, (float) vec.z) .color((float) rgb.x, (float) rgb.y, (float) rgb.z, 1) - .texture(u, v) - .light(j, k) + .uv(u, v) + .uv2(j, k) .endVertex(); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/BoxElement.java b/src/main/java/com/simibubi/create/foundation/gui/BoxElement.java index 673b057b6..405413920 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/BoxElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/BoxElement.java @@ -100,8 +100,8 @@ public class BoxElement extends RenderElement { Color c2 = ColorHelper.applyAlpha(borderTop, alpha); Color c3 = ColorHelper.applyAlpha(borderBot, alpha); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder b = tessellator.getBuffer(); - Matrix4f model = ms.peek().getModel(); + BufferBuilder b = tessellator.getBuilder(); + Matrix4f model = ms.last().pose(); b.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); //outer top b.vertex(model, x - f - 1 , y - f - 2 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex(); @@ -128,7 +128,7 @@ public class BoxElement extends RenderElement { b.vertex(model, x - f - 1 , y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex(); b.vertex(model, x + f + 1 + width, y + f + 1 + height, z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex(); b.vertex(model, x + f + 1 + width, y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex(); - tessellator.draw(); + tessellator.end(); b.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); //inner top - includes corners b.vertex(model, x - f - 1 , y - f - 1 , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex(); @@ -151,7 +151,7 @@ public class BoxElement extends RenderElement { b.vertex(model, x + f + 1 + width, y + f + height, z).color(c3.getRed(), c3.getGreen(), c3.getBlue(), c3.getAlpha()).endVertex(); b.vertex(model, x + f + 1 + width, y - f , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex(); - tessellator.draw(); + tessellator.end(); RenderSystem.shadeModel(GL11.GL_FLAT); RenderSystem.disableBlend(); diff --git a/src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java b/src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java index 4714c273c..24b961302 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java @@ -25,9 +25,9 @@ public class ClearContainerPacket extends SimplePacketBase { .getSender(); if (player == null) return; - if (!(player.openContainer instanceof IClearableContainer)) + if (!(player.containerMenu instanceof IClearableContainer)) return; - ((IClearableContainer) player.openContainer).clearContents(); + ((IClearableContainer) player.containerMenu).clearContents(); }); context.get() .setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/foundation/gui/CombinedStencilElement.java b/src/main/java/com/simibubi/create/foundation/gui/CombinedStencilElement.java index 374479c69..6382dce01 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/CombinedStencilElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/CombinedStencilElement.java @@ -44,16 +44,16 @@ public class CombinedStencilElement extends StencilElement { @Override protected void renderStencil(MatrixStack ms) { - ms.push(); + ms.pushPose(); element1.transform(ms); element1.withBounds(width, height); element1.renderStencil(ms); - ms.pop(); - ms.push(); + ms.popPose(); + ms.pushPose(); element2.transform(ms); element2.withBounds(width, height); element2.renderStencil(ms); - ms.pop(); + ms.popPose(); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java b/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java index 7dcfd715b..849c1ff51 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java @@ -95,8 +95,8 @@ public class ConfirmationScreen extends AbstractSimiScreen { public void open(@Nonnull Screen source) { this.source = source; Minecraft client = source.getMinecraft(); - this.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight()); - this.client.currentScreen = this; + this.init(client, client.getWindow().getGuiScaledWidth(), client.getWindow().getGuiScaledHeight()); + this.minecraft.screen = this; } @Override @@ -112,9 +112,9 @@ public class ConfirmationScreen extends AbstractSimiScreen { ArrayList copy = new ArrayList<>(text); text.clear(); - copy.forEach(t -> text.addAll(client.fontRenderer.getTextHandler().wrapLines(t, 300, Style.EMPTY))); + copy.forEach(t -> text.addAll(minecraft.font.getSplitter().splitLines(t, 300, Style.EMPTY))); - textHeight = text.size() * (client.fontRenderer.FONT_HEIGHT + 1) + 4; + textHeight = text.size() * (minecraft.font.lineHeight + 1) + 4; textWidth = 300; if (centered) { @@ -136,7 +136,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { int buttonX = x + textWidth / 2 - 6 - (int) (70 * (tristate ? 1.5f : 1)); TextStencilElement confirmText = - new TextStencilElement(client.fontRenderer, tristate ? "Save" : "Confirm").centered(true, true); + new TextStencilElement(minecraft.font, tristate ? "Save" : "Confirm").centered(true, true); confirm = new BoxWidget(buttonX, y + textHeight + 6, 70, 16).withCallback(() -> accept(Response.Confirm)); confirm.showingElement(confirmText.withElementRenderer(BoxWidget.gradientFactory.apply(confirm))); widgets.add(confirm); @@ -145,7 +145,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { if (tristate) { TextStencilElement confirmDontSaveText = - new TextStencilElement(client.fontRenderer, "Don't Save").centered(true, true); + new TextStencilElement(minecraft.font, "Don't Save").centered(true, true); confirmDontSave = new BoxWidget(buttonX, y + textHeight + 6, 70, 16).withCallback(() -> accept(Response.ConfirmDontSave)); confirmDontSave.showingElement( @@ -154,7 +154,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { buttonX += 12 + 70; } - TextStencilElement cancelText = new TextStencilElement(client.fontRenderer, "Cancel").centered(true, true); + TextStencilElement cancelText = new TextStencilElement(minecraft.font, "Cancel").centered(true, true); cancel = new BoxWidget(buttonX, y + textHeight + 6, 70, 16) .withCallback(() -> accept(Response.Cancel)); cancel.showingElement(cancelText.withElementRenderer(BoxWidget.gradientFactory.apply(cancel))); @@ -173,7 +173,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { } private void accept(Response success) { - client.currentScreen = source; + minecraft.screen = source; action.accept(success); } @@ -181,10 +181,10 @@ public class ConfirmationScreen extends AbstractSimiScreen { protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { textBackground.render(ms); - int offset = client.fontRenderer.FONT_HEIGHT + 1; + int offset = minecraft.font.lineHeight + 1; int lineY = y - offset; - ms.push(); + ms.pushPose(); ms.translate(0, 0, 200); for (ITextProperties line : text) { @@ -193,11 +193,11 @@ public class ConfirmationScreen extends AbstractSimiScreen { continue; int textX = x; if (text.size() == 1) - x = (width - client.fontRenderer.getWidth(line)) / 2; - client.fontRenderer.draw(ms, line.getString(), textX, lineY, 0xeaeaea); + x = (width - minecraft.font.width(line)) / 2; + minecraft.font.draw(ms, line.getString(), textX, lineY, 0xeaeaea); } - ms.pop(); + ms.popPose(); } @@ -215,14 +215,14 @@ public class ConfirmationScreen extends AbstractSimiScreen { @Override protected void prepareFrame() { Framebuffer thisBuffer = UIRenderHelper.framebuffer; - Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); + Framebuffer mainBuffer = Minecraft.getInstance().getMainRenderTarget(); GlCompat functions = Backend.getInstance().compat; - functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.framebufferObject); - functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, thisBuffer.framebufferObject); - functions.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); + functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.frameBufferId); + functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, thisBuffer.frameBufferId); + functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); - functions.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, thisBuffer.framebufferObject); + functions.fbo.bindFramebuffer(FramebufferConstants.GL_FRAMEBUFFER, thisBuffer.frameBufferId); GL11.glClear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT); } @@ -231,14 +231,14 @@ public class ConfirmationScreen extends AbstractSimiScreen { protected void endFrame() { Framebuffer thisBuffer = UIRenderHelper.framebuffer; - Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); + Framebuffer mainBuffer = Minecraft.getInstance().getMainRenderTarget(); GlCompat functions = Backend.getInstance().compat; - functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.framebufferObject); - functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject); - functions.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); + functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.frameBufferId); + functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.frameBufferId); + functions.blit.blitFramebuffer(0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, 0, 0, mainBuffer.viewWidth, mainBuffer.viewHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); - functions.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject); + functions.fbo.bindFramebuffer(FramebufferConstants.GL_FRAMEBUFFER, mainBuffer.frameBufferId); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java b/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java index a66e908b0..392dc76fa 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java +++ b/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java @@ -21,20 +21,20 @@ public class CustomLightingSettings implements ILightingSettings { } protected void init(float yRot1, float xRot1, float yRot2, float xRot2, boolean doubleLight) { - light1 = Vector3f.POSITIVE_Z.copy(); - light1.func_214905_a(Vector3f.POSITIVE_Y.getDegreesQuaternion(yRot1)); - light1.func_214905_a(Vector3f.POSITIVE_X.getDegreesQuaternion(xRot1)); + light1 = Vector3f.ZP.copy(); + light1.transform(Vector3f.YP.rotationDegrees(yRot1)); + light1.transform(Vector3f.XP.rotationDegrees(xRot1)); if (doubleLight) { - light2 = Vector3f.POSITIVE_Z.copy(); - light2.func_214905_a(Vector3f.POSITIVE_Y.getDegreesQuaternion(yRot2)); - light2.func_214905_a(Vector3f.POSITIVE_X.getDegreesQuaternion(xRot2)); + light2 = Vector3f.ZP.copy(); + light2.transform(Vector3f.YP.rotationDegrees(yRot2)); + light2.transform(Vector3f.XP.rotationDegrees(xRot2)); } else { light2 = VecHelper.ZERO_3F; } lightMatrix = new Matrix4f(); - lightMatrix.loadIdentity(); + lightMatrix.setIdentity(); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/gui/GhostItemContainer.java b/src/main/java/com/simibubi/create/foundation/gui/GhostItemContainer.java index 5c553ebce..d2b00bea3 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GhostItemContainer.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GhostItemContainer.java @@ -50,7 +50,7 @@ public abstract class GhostItemContainer extends Container implements ICleara ghostInventory = createGhostInventory(); readData(contentHolder); addSlots(); - detectAndSendChanges(); + broadcastChanges(); } @Override @@ -68,22 +68,22 @@ public abstract class GhostItemContainer extends Container implements ICleara } @Override - public boolean canMergeSlot(ItemStack stack, Slot slotIn) { - return slotIn.inventory == playerInventory; + public boolean canTakeItemForPickAll(ItemStack stack, Slot slotIn) { + return slotIn.container == playerInventory; } @Override - public boolean canDragIntoSlot(Slot slotIn) { + public boolean canDragTo(Slot slotIn) { if (allowRepeats()) return true; - return slotIn.inventory == playerInventory; + return slotIn.container == playerInventory; } @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { - ItemStack held = playerInventory.getItemStack(); + public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { + ItemStack held = playerInventory.getCarried(); if (slotId < 36) - return super.slotClick(slotId, dragType, clickTypeIn, player); + return super.clicked(slotId, dragType, clickTypeIn, player); if (clickTypeIn == ClickType.THROW) return ItemStack.EMPTY; @@ -93,7 +93,7 @@ public abstract class GhostItemContainer extends Container implements ICleara ItemStack stackInSlot = ghostInventory.getStackInSlot(slot) .copy(); stackInSlot.setCount(stackInSlot.getMaxStackSize()); - playerInventory.setItemStack(stackInSlot); + playerInventory.setCarried(stackInSlot); return ItemStack.EMPTY; } return ItemStack.EMPTY; @@ -101,21 +101,21 @@ public abstract class GhostItemContainer extends Container implements ICleara if (held.isEmpty()) { ghostInventory.setStackInSlot(slot, ItemStack.EMPTY); - getSlot(slotId).onSlotChanged(); + getSlot(slotId).setChanged(); return ItemStack.EMPTY; } ItemStack insert = held.copy(); insert.setCount(1); ghostInventory.setStackInSlot(slot, insert); - getSlot(slotId).onSlotChanged(); + getSlot(slotId).setChanged(); return held; } @Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { if (index < 36) { - ItemStack stackToInsert = playerInventory.getStackInSlot(index); + ItemStack stackToInsert = playerInventory.getItem(index); for (int i = 0; i < ghostInventory.getSlots(); i++) { ItemStack stack = ghostInventory.getStackInSlot(i); if (!allowRepeats() && ItemHandlerHelper.canItemStacksStack(stack, stackToInsert)) @@ -124,20 +124,20 @@ public abstract class GhostItemContainer extends Container implements ICleara ItemStack copy = stackToInsert.copy(); copy.setCount(1); ghostInventory.insertItem(i, copy, false); - getSlot(i + 36).onSlotChanged(); + getSlot(i + 36).setChanged(); break; } } } else { ghostInventory.extractItem(index - 36, 1, false); - getSlot(index).onSlotChanged(); + getSlot(index).setChanged(); } return ItemStack.EMPTY; } @Override - public void onContainerClosed(PlayerEntity playerIn) { - super.onContainerClosed(playerIn); + public void removed(PlayerEntity playerIn) { + super.removed(playerIn); saveData(contentHolder); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/GhostItemSubmitPacket.java b/src/main/java/com/simibubi/create/foundation/gui/GhostItemSubmitPacket.java index 54df945ac..3245586b6 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GhostItemSubmitPacket.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GhostItemSubmitPacket.java @@ -20,13 +20,13 @@ public class GhostItemSubmitPacket extends SimplePacketBase { } public GhostItemSubmitPacket(PacketBuffer buffer) { - item = buffer.readItemStack(); + item = buffer.readItem(); slot = buffer.readInt(); } @Override public void write(PacketBuffer buffer) { - buffer.writeItemStack(item); + buffer.writeItem(item); buffer.writeInt(slot); } @@ -39,10 +39,10 @@ public class GhostItemSubmitPacket extends SimplePacketBase { if (player == null) return; - if (player.openContainer instanceof GhostItemContainer) { - GhostItemContainer c = (GhostItemContainer) player.openContainer; + if (player.containerMenu instanceof GhostItemContainer) { + GhostItemContainer c = (GhostItemContainer) player.containerMenu; c.ghostInventory.setStackInSlot(slot, item); - c.getSlot(36 + slot).onSlotChanged(); + c.getSlot(36 + slot).setChanged(); } }); diff --git a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java index b2f1bd5f4..9a7c2df7f 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java @@ -58,9 +58,9 @@ public class GuiGameElement { } public static GuiRenderBuilder of(Fluid fluid) { - return new GuiBlockStateRenderBuilder(fluid.getDefaultState() - .getBlockState() - .with(FlowingFluidBlock.LEVEL, 0)); + return new GuiBlockStateRenderBuilder(fluid.defaultFluidState() + .createLegacyBlock() + .setValue(FlowingFluidBlock.LEVEL, 0)); } public static abstract class GuiRenderBuilder extends RenderElement { @@ -111,7 +111,7 @@ public class GuiGameElement { } protected void prepareMatrix(MatrixStack matrixStack) { - matrixStack.push(); + matrixStack.pushPose(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.alphaFunc(516, 0.1F); RenderSystem.enableAlphaTest(); @@ -128,14 +128,14 @@ public class GuiGameElement { matrixStack.translate(xLocal, yLocal, zLocal); matrixStack.scale(1, -1, 1); matrixStack.translate(rotationOffset.x, rotationOffset.y, rotationOffset.z); - matrixStack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion((float) zRot)); - matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion((float) xRot)); - matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion((float) yRot)); + matrixStack.mulPose(Vector3f.ZP.rotationDegrees((float) zRot)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees((float) xRot)); + matrixStack.mulPose(Vector3f.YP.rotationDegrees((float) yRot)); matrixStack.translate(-rotationOffset.x, -rotationOffset.y, -rotationOffset.z); } protected void cleanUpMatrix(MatrixStack matrixStack) { - matrixStack.pop(); + matrixStack.popPose(); RenderSystem.disableRescaleNormal(); RenderSystem.disableAlphaTest(); cleanUpLighting(matrixStack); @@ -145,13 +145,13 @@ public class GuiGameElement { if (customLighting != null) { customLighting.applyLighting(); } else { - RenderHelper.enableGuiDepthLighting(); + RenderHelper.setupFor3DItems(); } } protected void cleanUpLighting(MatrixStack matrixStack) { if (customLighting != null) { - RenderHelper.enableGuiDepthLighting(); + RenderHelper.setupFor3DItems(); } } } @@ -162,7 +162,7 @@ public class GuiGameElement { protected BlockState blockState; public GuiBlockModelRenderBuilder(IBakedModel blockmodel, @Nullable BlockState blockState) { - this.blockState = blockState == null ? Blocks.AIR.getDefaultState() : blockState; + this.blockState = blockState == null ? Blocks.AIR.defaultBlockState() : blockState; this.blockModel = blockmodel; } @@ -171,17 +171,17 @@ public class GuiGameElement { prepareMatrix(matrixStack); Minecraft mc = Minecraft.getInstance(); - BlockRendererDispatcher blockRenderer = mc.getBlockRendererDispatcher(); - IRenderTypeBuffer.Impl buffer = mc.getBufferBuilders() - .getEntityVertexConsumers(); - RenderType renderType = blockState.getBlock() == Blocks.AIR ? Atlases.getEntityTranslucentCull() - : RenderTypeLookup.getEntityBlockLayer(blockState, true); + BlockRendererDispatcher blockRenderer = mc.getBlockRenderer(); + IRenderTypeBuffer.Impl buffer = mc.renderBuffers() + .bufferSource(); + RenderType renderType = blockState.getBlock() == Blocks.AIR ? Atlases.translucentCullBlockSheet() + : RenderTypeLookup.getRenderType(blockState, true); IVertexBuilder vb = buffer.getBuffer(renderType); transformMatrix(matrixStack); mc.getTextureManager() - .bindTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE); + .bind(PlayerContainer.BLOCK_ATLAS); renderModel(blockRenderer, buffer, renderType, vb, matrixStack); cleanUpMatrix(matrixStack); @@ -193,10 +193,10 @@ public class GuiGameElement { .getBlockColors() .getColor(blockState, null, null, 0); Vector3d rgb = ColorHelper.getRGB(color == -1 ? this.color : color); - blockRenderer.getBlockModelRenderer() - .renderModel(ms.peek(), vb, blockState, blockModel, (float) rgb.x, (float) rgb.y, (float) rgb.z, - 0xF000F0, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); - buffer.draw(); + blockRenderer.getModelRenderer() + .renderModel(ms.last(), vb, blockState, blockModel, (float) rgb.x, (float) rgb.y, (float) rgb.z, + 0xF000F0, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); + buffer.endBatch(); } } @@ -205,19 +205,19 @@ public class GuiGameElement { public GuiBlockStateRenderBuilder(BlockState blockstate) { super(Minecraft.getInstance() - .getBlockRendererDispatcher() - .getModelForState(blockstate), blockstate); + .getBlockRenderer() + .getBlockModel(blockstate), blockstate); } @Override protected void renderModel(BlockRendererDispatcher blockRenderer, IRenderTypeBuffer.Impl buffer, RenderType renderType, IVertexBuilder vb, MatrixStack ms) { if (blockState.getBlock() instanceof FireBlock) { - RenderHelper.disableGuiDepthLighting(); - blockRenderer.renderBlock(blockState, ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, + RenderHelper.setupForFlatItems(); + blockRenderer.renderBlock(blockState, ms, buffer, 0xF000F0, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); - buffer.draw(); - RenderHelper.enableGuiDepthLighting(); + buffer.endBatch(); + RenderHelper.setupFor3DItems(); return; } @@ -228,8 +228,8 @@ public class GuiGameElement { return; FluidRenderer.renderTiledFluidBB(new FluidStack(blockState.getFluidState() - .getFluid(), 1000), 0, 0, 0, 1.0001f, 1.0001f, 1.0001f, buffer, ms, 0xF000F0, false); - buffer.draw(); + .getType(), 1000), 0, 0, 0, 1.0001f, 1.0001f, 1.0001f, buffer, ms, 0xF000F0, false); + buffer.endBatch(); } } @@ -263,11 +263,11 @@ public class GuiGameElement { public static void renderItemIntoGUI(MatrixStack matrixStack, ItemStack stack, boolean useDefaultLighting) { ItemRenderer renderer = Minecraft.getInstance().getItemRenderer(); - IBakedModel bakedModel = renderer.getItemModelWithOverrides(stack, null, null); + IBakedModel bakedModel = renderer.getModel(stack, null, null); - matrixStack.push(); - renderer.textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); - renderer.textureManager.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).setBlurMipmapDirect(false, false); + matrixStack.pushPose(); + renderer.textureManager.bind(AtlasTexture.LOCATION_BLOCKS); + renderer.textureManager.getTexture(AtlasTexture.LOCATION_BLOCKS).setFilter(false, false); RenderSystem.enableRescaleNormal(); RenderSystem.enableAlphaTest(); RenderSystem.enableCull(); @@ -275,30 +275,30 @@ public class GuiGameElement { RenderSystem.enableBlend(); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - matrixStack.translate(0, 0, 100.0F + renderer.zLevel); + matrixStack.translate(0, 0, 100.0F + renderer.blitOffset); matrixStack.translate(8.0F, -8.0F, 0.0F); matrixStack.scale(16.0F, 16.0F, 16.0F); - IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers(); - boolean flatLighting = !bakedModel.isSideLit(); + IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().renderBuffers().bufferSource(); + boolean flatLighting = !bakedModel.usesBlockLight(); if (useDefaultLighting) { if (flatLighting) { - RenderHelper.disableGuiDepthLighting(); + RenderHelper.setupForFlatItems(); } } - renderer.renderItem(stack, ItemCameraTransforms.TransformType.GUI, false, matrixStack, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, bakedModel); - buffer.draw(); + renderer.render(stack, ItemCameraTransforms.TransformType.GUI, false, matrixStack, buffer, 0xF000F0, OverlayTexture.NO_OVERLAY, bakedModel); + buffer.endBatch(); RenderSystem.enableDepthTest(); if (useDefaultLighting) { if (flatLighting) { - RenderHelper.enableGuiDepthLighting(); + RenderHelper.setupFor3DItems(); } } RenderSystem.disableAlphaTest(); RenderSystem.disableRescaleNormal(); RenderSystem.enableCull(); - matrixStack.pop(); + matrixStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/ILightingSettings.java b/src/main/java/com/simibubi/create/foundation/gui/ILightingSettings.java index bd585d587..4248e4de2 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ILightingSettings.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ILightingSettings.java @@ -6,7 +6,7 @@ public interface ILightingSettings { void applyLighting(); - static final ILightingSettings DEFAULT_3D = () -> RenderHelper.enableGuiDepthLighting(); - static final ILightingSettings DEFAULT_FLAT = () -> RenderHelper.disableGuiDepthLighting(); + static final ILightingSettings DEFAULT_3D = () -> RenderHelper.setupFor3DItems(); + static final ILightingSettings DEFAULT_FLAT = () -> RenderHelper.setupForFlatItems(); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/ScreenOpener.java b/src/main/java/com/simibubi/create/foundation/gui/ScreenOpener.java index cfe1aa1d1..d28fa2eb4 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ScreenOpener.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ScreenOpener.java @@ -20,7 +20,7 @@ public class ScreenOpener { private static Screen backSteppedFrom = null; public static void open(Screen screen) { - open(Minecraft.getInstance().currentScreen, screen); + open(Minecraft.getInstance().screen, screen); } public static void open(@Nullable Screen current, Screen toOpen) { @@ -70,7 +70,7 @@ public class ScreenOpener { if (!screen.isEquivalentTo((NavigatableSimiScreen) previouslyRenderedScreen)) return false; - openPreviousScreen(Minecraft.getInstance().currentScreen, Optional.of(screen)); + openPreviousScreen(Minecraft.getInstance().screen, Optional.of(screen)); return true; } @@ -89,9 +89,9 @@ public class ScreenOpener { private static void openScreen(Screen screen) { Minecraft.getInstance() - .enqueue(() -> { + .tell(() -> { Minecraft.getInstance() - .displayGuiScreen(screen); + .setScreen(screen); Screen previouslyRenderedScreen = getPreviouslyRenderedScreen(); if (previouslyRenderedScreen != null && screen instanceof NavigatableSimiScreen) previouslyRenderedScreen.init(Minecraft.getInstance(), screen.width, screen.height); diff --git a/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java b/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java index 22c70b75f..6bbdeae75 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java @@ -11,14 +11,14 @@ public abstract class StencilElement extends RenderElement { @Override public void render(MatrixStack ms) { - ms.push(); + ms.pushPose(); transform(ms); prepareStencil(ms); renderStencil(ms); prepareElement(ms); renderElement(ms); cleanUp(ms); - ms.pop(); + ms.popPose(); } protected abstract void renderStencil(MatrixStack ms); @@ -32,7 +32,7 @@ public abstract class StencilElement extends RenderElement { protected void prepareStencil(MatrixStack ms) { GL11.glDisable(GL11.GL_STENCIL_TEST); RenderSystem.stencilMask(~0); - RenderSystem.clear(GL11.GL_STENCIL_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC); + RenderSystem.clear(GL11.GL_STENCIL_BUFFER_BIT, Minecraft.ON_OSX); GL11.glEnable(GL11.GL_STENCIL_TEST); RenderSystem.stencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP); RenderSystem.stencilMask(0xFF); diff --git a/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java b/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java index cdea4f887..9ede69764 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java @@ -50,10 +50,10 @@ public class TextStencilElement extends DelegatedStencilElement { float x = 0, y = 0; if (centerHorizontally) - x = width / 2f - font.getWidth(component) / 2f; + x = width / 2f - font.width(component) / 2f; if (centerVertically) - y = height / 2f - (font.FONT_HEIGHT - 1) / 2f; + y = height / 2f - (font.lineHeight - 1) / 2f; font.draw(ms, component, x, y, 0xff_000000); } @@ -62,15 +62,15 @@ public class TextStencilElement extends DelegatedStencilElement { protected void renderElement(MatrixStack ms) { float x = 0, y = 0; if (centerHorizontally) - x = width / 2f - font.getWidth(component) / 2f; + x = width / 2f - font.width(component) / 2f; if (centerVertically) - y = height / 2f - (font.FONT_HEIGHT - 1) / 2f; + y = height / 2f - (font.lineHeight - 1) / 2f; - ms.push(); + ms.pushPose(); ms.translate(x, y, 0); - element.render(ms, font.getWidth(component), font.FONT_HEIGHT + 2, alpha); - ms.pop(); + element.render(ms, font.width(component), font.lineHeight + 2, alpha); + ms.popPose(); } public IFormattableTextComponent getComponent() { diff --git a/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java b/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java index cb77c8b7d..4748a8742 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java @@ -33,7 +33,7 @@ public class ToolSelectionScreen extends Screen { public ToolSelectionScreen(List tools, Consumer callback) { super(new StringTextComponent("Tool Selection")); - this.client = Minecraft.getInstance(); + this.minecraft = Minecraft.getInstance(); this.tools = tools; this.callback = callback; focused = false; @@ -62,12 +62,12 @@ public class ToolSelectionScreen extends Screen { Minecraft mc = Minecraft.getInstance(); MainWindow mainWindow = mc.getWindow(); if (!initialized) - init(mc, mainWindow.getScaledWidth(), mainWindow.getScaledHeight()); + init(mc, mainWindow.getGuiScaledWidth(), mainWindow.getGuiScaledHeight()); - int x = (mainWindow.getScaledWidth() - w) / 2 + 15; - int y = mainWindow.getScaledHeight() - h - 75; + int x = (mainWindow.getGuiScaledWidth() - w) / 2 + 15; + int y = mainWindow.getGuiScaledHeight() - h - 75; - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(0, -yOffset, focused ? 100 : 0); AllGuiTextures gray = AllGuiTextures.HUD_BACKGROUND; @@ -76,8 +76,8 @@ public class ToolSelectionScreen extends Screen { Minecraft.getInstance() .getTextureManager() - .bindTexture(gray.location); - drawTexture(matrixStack, x - 15, y, gray.startX, gray.startY, w, h, gray.width, gray.height); + .bind(gray.location); + blit(matrixStack, x - 15, y, gray.startX, gray.startY, w, h, gray.width, gray.height); float toolTipAlpha = yOffset / 10; List toolTip = tools.get(selection) @@ -86,40 +86,40 @@ public class ToolSelectionScreen extends Screen { if (toolTipAlpha > 0.25f) { RenderSystem.color4f(.7f, .7f, .8f, toolTipAlpha); - drawTexture(matrixStack, x - 15, y + 33, gray.startX, gray.startY, w, h + 22, gray.width, gray.height); + blit(matrixStack, x - 15, y + 33, gray.startX, gray.startY, w, h + 22, gray.width, gray.height); RenderSystem.color4f(1, 1, 1, 1); if (toolTip.size() > 0) - textRenderer.draw(matrixStack, toolTip.get(0), x - 10, y + 38, 0xEEEEEE + stringAlphaComponent); + font.draw(matrixStack, toolTip.get(0), x - 10, y + 38, 0xEEEEEE + stringAlphaComponent); if (toolTip.size() > 1) - textRenderer.draw(matrixStack, toolTip.get(1), x - 10, y + 50, 0xCCDDFF + stringAlphaComponent); + font.draw(matrixStack, toolTip.get(1), x - 10, y + 50, 0xCCDDFF + stringAlphaComponent); if (toolTip.size() > 2) - textRenderer.draw(matrixStack, toolTip.get(2), x - 10, y + 60, 0xCCDDFF + stringAlphaComponent); + font.draw(matrixStack, toolTip.get(2), x - 10, y + 60, 0xCCDDFF + stringAlphaComponent); if (toolTip.size() > 3) - textRenderer.draw(matrixStack, toolTip.get(3), x - 10, y + 72, 0xCCCCDD + stringAlphaComponent); + font.draw(matrixStack, toolTip.get(3), x - 10, y + 72, 0xCCCCDD + stringAlphaComponent); } RenderSystem.color4f(1, 1, 1, 1); if (tools.size() > 1) { String keyName = AllKeys.TOOL_MENU.getBoundKey(); - int width = client.getWindow() - .getScaledWidth(); + int width = minecraft.getWindow() + .getGuiScaledWidth(); if (!focused) - drawCenteredText(matrixStack, client.fontRenderer, Lang.translate(holdToFocus, keyName), width / 2, + drawCenteredString(matrixStack, minecraft.font, Lang.translate(holdToFocus, keyName), width / 2, y - 10, 0xCCDDFF); else - drawCenteredString(matrixStack, client.fontRenderer, scrollToCycle, width / 2, y - 10, 0xCCDDFF); + drawCenteredString(matrixStack, minecraft.font, scrollToCycle, width / 2, y - 10, 0xCCDDFF); } else { x += 65; } for (int i = 0; i < tools.size(); i++) { - matrixStack.push(); + matrixStack.pushPose(); float alpha = focused ? 1 : .2f; if (i == selection) { matrixStack.translate(0, -10, 0); - drawCenteredString(matrixStack, client.fontRenderer, tools.get(i) + drawCenteredString(matrixStack, minecraft.font, tools.get(i) .getDisplayName() .getString(), x + i * 50 + 24, y + 28, 0xCCDDFF); alpha = 1; @@ -133,11 +133,11 @@ public class ToolSelectionScreen extends Screen { .getIcon() .draw(matrixStack, this, x + i * 50 + 16, y + 11); - matrixStack.pop(); + matrixStack.popPose(); } RenderSystem.enableBlend(); - matrixStack.pop(); + matrixStack.popPose(); } public void update() { diff --git a/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java b/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java index 562751419..70def0c92 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java @@ -32,7 +32,7 @@ public class UIRenderHelper { public static void updateWindowSize(MainWindow mainWindow) { if (framebuffer != null) - framebuffer.func_216491_a(mainWindow.getFramebufferWidth(), mainWindow.getFramebufferHeight(), Minecraft.IS_RUNNING_ON_MAC); + framebuffer.resize(mainWindow.getWidth(), mainWindow.getHeight(), Minecraft.ON_OSX); } public static void init() { @@ -44,9 +44,9 @@ public class UIRenderHelper { } private static Framebuffer createFramebuffer(MainWindow mainWindow) { - Framebuffer framebuffer = new Framebuffer(mainWindow.getFramebufferWidth(), mainWindow.getFramebufferHeight(), true, - Minecraft.IS_RUNNING_ON_MAC); - framebuffer.setFramebufferColor(0, 0, 0, 0); + Framebuffer framebuffer = new Framebuffer(mainWindow.getWidth(), mainWindow.getHeight(), true, + Minecraft.ON_OSX); + framebuffer.setClearColor(0, 0, 0, 0); framebuffer.enableStencil(); return framebuffer; } @@ -55,27 +55,27 @@ public class UIRenderHelper { MainWindow window = Minecraft.getInstance() .getWindow(); - float vx = (float) window.getScaledWidth(); - float vy = (float) window.getScaledHeight(); - float tx = (float) framebuffer.framebufferWidth / (float) framebuffer.framebufferTextureWidth; - float ty = (float) framebuffer.framebufferHeight / (float) framebuffer.framebufferTextureHeight; + float vx = (float) window.getGuiScaledWidth(); + float vy = (float) window.getGuiScaledHeight(); + float tx = (float) framebuffer.viewWidth / (float) framebuffer.width; + float ty = (float) framebuffer.viewHeight / (float) framebuffer.height; RenderSystem.enableTexture(); RenderSystem.enableDepthTest(); - framebuffer.bindFramebufferTexture(); + framebuffer.bindRead(); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); - bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEXTURE); + BufferBuilder bufferbuilder = tessellator.getBuilder(); + bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX); - bufferbuilder.vertex(0, vy, 0).color(1, 1, 1, alpha).texture(0, 0).endVertex(); - bufferbuilder.vertex(vx, vy, 0).color(1, 1, 1, alpha).texture(tx, 0).endVertex(); - bufferbuilder.vertex(vx, 0, 0).color(1, 1, 1, alpha).texture(tx, ty).endVertex(); - bufferbuilder.vertex(0, 0, 0).color(1, 1, 1, alpha).texture(0, ty).endVertex(); + bufferbuilder.vertex(0, vy, 0).color(1, 1, 1, alpha).uv(0, 0).endVertex(); + bufferbuilder.vertex(vx, vy, 0).color(1, 1, 1, alpha).uv(tx, 0).endVertex(); + bufferbuilder.vertex(vx, 0, 0).color(1, 1, 1, alpha).uv(tx, ty).endVertex(); + bufferbuilder.vertex(0, 0, 0).color(1, 1, 1, alpha).uv(0, ty).endVertex(); - tessellator.draw(); - framebuffer.unbindFramebufferTexture(); + tessellator.end(); + framebuffer.unbindRead(); } public static void streak(MatrixStack ms, float angle, int x, int y, int breadth, int length) {streak(ms, angle, x, y, breadth, length, Theme.i(Theme.Key.STREAK));} @@ -95,19 +95,19 @@ public class UIRenderHelper { int c3 = a3 | color; int c4 = a4 | color; - ms.push(); + ms.pushPose(); ms.translate(x, y, 0); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(angle - 90)); + ms.mulPose(Vector3f.ZP.rotationDegrees(angle - 90)); streak(ms, breadth / 2, length, c1, c2, c3, c4); - ms.pop(); + ms.popPose(); } private static void streak(MatrixStack ms, int width, int height, int c1, int c2, int c3, int c4) { double split1 = .5; double split2 = .75; - Matrix4f model = ms.peek().getModel(); + Matrix4f model = ms.last().pose(); RenderSystem.disableAlphaTest(); GuiUtils.drawGradientRect(model, 0, -width, 0, width, (int) (split1 * height), c1, c2); GuiUtils.drawGradientRect(model, 0, -width, (int) (split1 * height), width, (int) (split2 * height), c2, c3); @@ -145,27 +145,27 @@ public class UIRenderHelper { * @param breadth the total width of the gradient */ public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int z, int breadth, int length, int color1, int color2) { - ms.push(); + ms.pushPose(); ms.translate(x, y, z); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(angle - 90)); + ms.mulPose(Vector3f.ZP.rotationDegrees(angle - 90)); - Matrix4f model = ms.peek().getModel(); + Matrix4f model = ms.last().pose(); int w = breadth / 2; GuiUtils.drawGradientRect(model, 0, -w, 0, w, length, color1, color2); - ms.pop(); + ms.popPose(); } public static void breadcrumbArrow(MatrixStack matrixStack, int x, int y, int z, int width, int height, int indent, Couple colors) {breadcrumbArrow(matrixStack, x, y, z, width, height, indent, colors.getFirst().getRGB(), colors.getSecond().getRGB());} // draws a wide chevron-style breadcrumb arrow pointing left public static void breadcrumbArrow(MatrixStack matrixStack, int x, int y, int z, int width, int height, int indent, int startColor, int endColor) { - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(x - indent, y, z); breadcrumbArrow(matrixStack, width, height, indent, startColor, endColor); - matrixStack.pop(); + matrixStack.popPose(); } private static void breadcrumbArrow(MatrixStack ms, int width, int height, int indent, int c1, int c2) { @@ -206,8 +206,8 @@ public class UIRenderHelper { RenderSystem.shadeModel(GL11.GL_SMOOTH); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); - Matrix4f model = ms.peek().getModel(); + BufferBuilder bufferbuilder = tessellator.getBuilder(); + Matrix4f model = ms.last().pose(); bufferbuilder.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); bufferbuilder.vertex(model, x0, y0, 0).color(fc1 >> 16 & 0xFF, fc1 >> 8 & 0xFF, fc1 & 0xFF, fc1 >> 24 & 0xFF).endVertex(); @@ -234,7 +234,7 @@ public class UIRenderHelper { bufferbuilder.vertex(model, x5, y5, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex(); bufferbuilder.vertex(model, x8, y8, 0).color(fc4 >> 16 & 0xFF, fc4 >> 8 & 0xFF, fc4 & 0xFF, fc4 >> 24 & 0xFF).endVertex(); - tessellator.draw(); + tessellator.end(); RenderSystem.shadeModel(GL11.GL_FLAT); RenderSystem.disableBlend(); RenderSystem.enableCull(); @@ -252,20 +252,20 @@ public class UIRenderHelper { } private static void drawColoredTexture(MatrixStack ms, Color c, int left, int right, int top, int bot, int z, int tex_width, int tex_height, float tex_left, float tex_top, int sheet_width, int sheet_height) { - drawTexturedQuad(ms.peek().getModel(), c, left, right, top, bot, z, (tex_left + 0.0F) / (float) sheet_width, (tex_left + (float) tex_width) / (float) sheet_width, (tex_top + 0.0F) / (float) sheet_height, (tex_top + (float) tex_height) / (float) sheet_height); + drawTexturedQuad(ms.last().pose(), c, left, right, top, bot, z, (tex_left + 0.0F) / (float) sheet_width, (tex_left + (float) tex_width) / (float) sheet_width, (tex_top + 0.0F) / (float) sheet_height, (tex_top + (float) tex_height) / (float) sheet_height); } private static void drawTexturedQuad(Matrix4f m, Color c, int left, int right, int top, int bot, int z, float u1, float u2, float v1, float v2) { RenderSystem.enableBlend(); - BufferBuilder bufferbuilder = Tessellator.getInstance().getBuffer(); - bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEXTURE); - bufferbuilder.vertex(m, (float) left , (float) bot, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u1, v2).endVertex(); - bufferbuilder.vertex(m, (float) right, (float) bot, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u2, v2).endVertex(); - bufferbuilder.vertex(m, (float) right, (float) top, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u2, v1).endVertex(); - bufferbuilder.vertex(m, (float) left , (float) top, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).texture(u1, v1).endVertex(); - bufferbuilder.finishDrawing(); + BufferBuilder bufferbuilder = Tessellator.getInstance().getBuilder(); + bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX); + bufferbuilder.vertex(m, (float) left , (float) bot, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u1, v2).endVertex(); + bufferbuilder.vertex(m, (float) right, (float) bot, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u2, v2).endVertex(); + bufferbuilder.vertex(m, (float) right, (float) top, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u2, v1).endVertex(); + bufferbuilder.vertex(m, (float) left , (float) top, (float) z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u1, v1).endVertex(); + bufferbuilder.end(); RenderSystem.enableAlphaTest(); - WorldVertexBufferUploader.draw(bufferbuilder); + WorldVertexBufferUploader.end(bufferbuilder); } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/mainMenu/CreateMainMenuScreen.java b/src/main/java/com/simibubi/create/foundation/gui/mainMenu/CreateMainMenuScreen.java index 36e1ab619..912409cd9 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/mainMenu/CreateMainMenuScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/mainMenu/CreateMainMenuScreen.java @@ -41,7 +41,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { new RenderSkyboxCube(Create.asResource("textures/gui/title/background/panorama")); public static final ResourceLocation PANORAMA_OVERLAY_TEXTURES = new ResourceLocation("textures/gui/title/background/panorama_overlay.png"); - private RenderSkybox vanillaPanorama = new RenderSkybox(MainMenuScreen.PANORAMA_RESOURCES); + private RenderSkybox vanillaPanorama = new RenderSkybox(MainMenuScreen.CUBE_MAP); public static RenderSkybox panorama = new RenderSkybox(PANORAMA_RESOURCES); private long firstRenderTime; private Button gettingStarted; @@ -51,74 +51,74 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { returnOnClose = true; if (parent instanceof MainMenuScreen) vanillaPanorama = ObfuscationReflectionHelper.getPrivateValue(MainMenuScreen.class, (MainMenuScreen) parent, - "field_209101_K"); + "panorama"); } @Override public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { if (firstRenderTime == 0L) - this.firstRenderTime = Util.milliTime(); + this.firstRenderTime = Util.getMillis(); super.render(ms, mouseX, mouseY, partialTicks); } @Override protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - float f = (float) (Util.milliTime() - this.firstRenderTime) / 1000.0F; + float f = (float) (Util.getMillis() - this.firstRenderTime) / 1000.0F; float alpha = MathHelper.clamp(f, 0.0F, 1.0F); - float elapsedPartials = client.getTickLength(); + float elapsedPartials = minecraft.getDeltaFrameTime(); if (parent instanceof MainMenuScreen) { if (alpha < 1) vanillaPanorama.render(elapsedPartials, 1); panorama.render(elapsedPartials, alpha); - client.getTextureManager() - .bindTexture(PANORAMA_OVERLAY_TEXTURES); + minecraft.getTextureManager() + .bind(PANORAMA_OVERLAY_TEXTURES); RenderSystem.enableBlend(); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - drawTexture(ms, 0, 0, this.width, this.height, 0.0F, 0.0F, 16, 128, 16, 128); + blit(ms, 0, 0, this.width, this.height, 0.0F, 0.0F, 16, 128, 16, 128); } RenderSystem.enableDepthTest(); for (int side : Iterate.positiveAndNegative) { - ms.push(); + ms.pushPose(); ms.translate(width / 2, 60, 200); ms.scale(24 * side, 24 * side, 32); ms.translate(-1.75 * ((alpha * alpha) / 2f + .5f), .25f, 0); MatrixStacker.of(ms) .rotateX(45); GuiGameElement.of(AllBlocks.LARGE_COGWHEEL.getDefaultState()) - .rotateBlock(0, Util.milliTime() / 32f * side, 0) + .rotateBlock(0, Util.getMillis() / 32f * side, 0) .render(ms); ms.translate(-1, 0, -1); GuiGameElement.of(AllBlocks.COGWHEEL.getDefaultState()) - .rotateBlock(0, Util.milliTime() / -16f * side + 22.5f, 0) + .rotateBlock(0, Util.getMillis() / -16f * side + 22.5f, 0) .render(ms); - ms.pop(); + ms.popPose(); } - ms.push(); + ms.pushPose(); ms.translate(width / 2 - 32, 32, -10); - ms.push(); + ms.pushPose(); ms.scale(0.25f, 0.25f, 0.25f); AllGuiTextures.LOGO.draw(ms, 0, 0); - ms.pop(); + ms.popPose(); new BoxElement().withBackground(0x88_000000) .flatBorder(new Color(0x01_000000, true)) .at(-32, 56, 100) .withBounds(128, 11) .render(ms); - ms.pop(); + ms.popPose(); - ms.push(); + ms.pushPose(); ms.translate(0, 0, 200); - drawCenteredText(ms, textRenderer, new StringTextComponent(Create.NAME).formatted(TextFormatting.BOLD) + drawCenteredString(ms, font, new StringTextComponent(Create.NAME).withStyle(TextFormatting.BOLD) .append( - new StringTextComponent(" v" + Create.VERSION).formatted(TextFormatting.BOLD, TextFormatting.WHITE)), + new StringTextComponent(" v" + Create.VERSION).withStyle(TextFormatting.BOLD, TextFormatting.WHITE)), width / 2, 89, 0xff_E4BB67); - ms.pop(); + ms.popPose(); RenderSystem.disableDepthTest(); } @@ -170,7 +170,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { return; if (mouseY < gettingStarted.y || mouseY > gettingStarted.y + 20) return; - renderTooltip(ms, TooltipHelper.cutTextComponent(Lang.translate("menu.only_ingame"), TextFormatting.GRAY, + renderComponentTooltip(ms, TooltipHelper.cutTextComponent(Lang.translate("menu.only_ingame"), TextFormatting.GRAY, TextFormatting.GRAY), mouseX, mouseY); } } @@ -188,9 +188,9 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { returnOnClose = false; ScreenOpener.open(new ConfirmOpenLinkScreen((p_213069_2_) -> { if (p_213069_2_) - Util.getOSType() - .openURI(url); - this.client.displayGuiScreen(this); + Util.getPlatform() + .openUri(url); + this.minecraft.setScreen(this); }, url, true)); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/AbstractSimiWidget.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/AbstractSimiWidget.java index f8539a3d3..48e73d983 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/AbstractSimiWidget.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/AbstractSimiWidget.java @@ -56,7 +56,7 @@ public abstract class AbstractSimiWidget extends Widget { @Override public void render(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { if (visible) { - hovered = isMouseOver(mouseX, mouseY); + isHovered = isMouseOver(mouseX, mouseY); beforeRender(ms, mouseX, mouseY, partialTicks); renderButton(ms, mouseX, mouseY, partialTicks); afterRender(ms, mouseX, mouseY, partialTicks); @@ -73,11 +73,11 @@ public abstract class AbstractSimiWidget extends Widget { } protected void beforeRender(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - ms.push(); + ms.pushPose(); } protected void afterRender(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - ms.pop(); + ms.popPose(); } public void runCallback(double mouseX, double mouseY) { diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/BoxWidget.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/BoxWidget.java index 2e5cac63e..c74606d81 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/BoxWidget.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/BoxWidget.java @@ -103,11 +103,11 @@ public class BoxWidget extends ElementWidget { protected void beforeRender(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { super.beforeRender(ms, mouseX, mouseY, partialTicks); - if (hovered != wasHovered) { + if (isHovered != wasHovered) { startGradientAnimation( getColorForState(true), getColorForState(false), - hovered + isHovered ); } @@ -137,7 +137,7 @@ public class BoxWidget extends ElementWidget { super.renderButton(ms, mouseX, mouseY, partialTicks); - wasHovered = hovered; + wasHovered = isHovered; } @Override @@ -192,7 +192,7 @@ public class BoxWidget extends ElementWidget { if (!active) return Theme.p(getDisabledTheme()).get(first); - if (hovered) { + if (isHovered) { if (first) return customBorderTop != null ? customBorderTop.darker() : Theme.c(getHoverTheme(), true); else diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/ElementWidget.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/ElementWidget.java index bc782e26f..6bb91486d 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/ElementWidget.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/ElementWidget.java @@ -130,7 +130,7 @@ public class ElementWidget extends AbstractSimiWidget { @Override public void renderButton(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - ms.push(); + ms.pushPose(); ms.translate(x + paddingX, y + paddingY, z); float innerWidth = width - 2 * paddingX; float innerHeight = height - 2 * paddingY; @@ -144,7 +144,7 @@ public class ElementWidget extends AbstractSimiWidget { innerHeight /= yScale; } element.withBounds((int) innerWidth, (int) innerHeight).render(ms); - ms.pop(); + ms.popPose(); if (rescaleElement) { element.at(eX, eY); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/IconButton.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/IconButton.java index fbb6ee950..8209c907a 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/IconButton.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/IconButton.java @@ -22,15 +22,15 @@ public class IconButton extends AbstractSimiWidget { @Override public void renderButton(@Nonnull MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { if (this.visible) { - this.hovered = + this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; AllGuiTextures button = (pressed || !active) ? button = AllGuiTextures.BUTTON_DOWN - : (hovered) ? AllGuiTextures.BUTTON_HOVER : AllGuiTextures.BUTTON; + : (isHovered) ? AllGuiTextures.BUTTON_HOVER : AllGuiTextures.BUTTON; RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); AllGuiTextures.BUTTON.bind(); - drawTexture(matrixStack, x, y, button.startX, button.startY, button.width, button.height); + blit(matrixStack, x, y, button.startX, button.startY, button.width, button.height); icon.draw(matrixStack, this, x + 1, y + 1); } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/Label.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/Label.java index 3c7d904ca..1fc0a881d 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/Label.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/Label.java @@ -20,8 +20,8 @@ public class Label extends AbstractSimiWidget { protected FontRenderer font; public Label(int x, int y, ITextComponent text) { - super(x, y, Minecraft.getInstance().fontRenderer.getWidth(text), 10); - font = Minecraft.getInstance().fontRenderer; + super(x, y, Minecraft.getInstance().font.width(text), 10); + font = Minecraft.getInstance().font; this.text = new StringTextComponent("Label"); color = 0xFFFFFF; hasShadow = false; @@ -44,15 +44,15 @@ public class Label extends AbstractSimiWidget { } public void setTextAndTrim(ITextComponent newText, boolean trimFront, int maxWidthPx) { - FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; + FontRenderer fontRenderer = Minecraft.getInstance().font; - if (fontRenderer.getWidth(newText) <= maxWidthPx) { + if (fontRenderer.width(newText) <= maxWidthPx) { text = newText; return; } String trim = "..."; - int trimWidth = fontRenderer.getStringWidth(trim); + int trimWidth = fontRenderer.width(trim); String raw = newText.getString(); StringBuilder builder = new StringBuilder(raw); @@ -62,7 +62,7 @@ public class Label extends AbstractSimiWidget { for (int i = startIndex; i != endIndex; i += step) { String sub = builder.substring(trimFront ? i : startIndex, trimFront ? endIndex + 1 : i + 1); - if (fontRenderer.getWidth(new StringTextComponent(sub).setStyle(newText.getStyle())) + trimWidth <= maxWidthPx) { + if (fontRenderer.width(new StringTextComponent(sub).setStyle(newText.getStyle())) + trimWidth <= maxWidthPx) { text = new StringTextComponent(trimFront ? trim + sub : sub + trim).setStyle(newText.getStyle()); return; } @@ -78,12 +78,12 @@ public class Label extends AbstractSimiWidget { return; RenderSystem.color4f(1, 1, 1, 1); - IFormattableTextComponent copy = text.copy(); + IFormattableTextComponent copy = text.plainCopy(); if (suffix != null && !suffix.isEmpty()) copy.append(suffix); if (hasShadow) - font.drawWithShadow(matrixStack, copy, x, y, color); + font.drawShadow(matrixStack, copy, x, y, color); else font.draw(matrixStack, copy, x, y, color); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/ScrollInput.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/ScrollInput.java index 146874bbf..8329c530c 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/ScrollInput.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/ScrollInput.java @@ -91,7 +91,7 @@ public class ScrollInput extends AbstractSimiWidget { @Override public boolean mouseScrolled(double mouseX, double mouseY, double delta) { - if (!hovered) + if (!isHovered) return false; StepContext context = new StepContext(); @@ -137,9 +137,9 @@ public class ScrollInput extends AbstractSimiWidget { protected void updateTooltip() { toolTip.clear(); - toolTip.add(title.copy().formatted(TextFormatting.BLUE)); - toolTip.add(scrollToModify.copy().formatted(TextFormatting.ITALIC, TextFormatting.DARK_GRAY)); - toolTip.add(shiftScrollsFaster.copy().formatted(TextFormatting.ITALIC, TextFormatting.DARK_GRAY)); + toolTip.add(title.plainCopy().withStyle(TextFormatting.BLUE)); + toolTip.add(scrollToModify.plainCopy().withStyle(TextFormatting.ITALIC, TextFormatting.DARK_GRAY)); + toolTip.add(shiftScrollsFaster.plainCopy().withStyle(TextFormatting.ITALIC, TextFormatting.DARK_GRAY)); } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/SelectionScrollInput.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/SelectionScrollInput.java index c056984fe..4fb8329b7 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/SelectionScrollInput.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/SelectionScrollInput.java @@ -40,7 +40,7 @@ public class SelectionScrollInput extends ScrollInput { @Override protected void updateTooltip() { toolTip.clear(); - toolTip.add(title.copy().formatted(TextFormatting.BLUE)); + toolTip.add(title.plainCopy().withStyle(TextFormatting.BLUE)); int min = Math.min(this.max - 16, state - 7); int max = Math.max(this.min + 16, state + 8); min = Math.max(min, this.min); @@ -48,19 +48,19 @@ public class SelectionScrollInput extends ScrollInput { if (this.min + 1 == min) min--; if (min > this.min) - toolTip.add(new StringTextComponent("> ...").formatted(TextFormatting.GRAY)); + toolTip.add(new StringTextComponent("> ...").withStyle(TextFormatting.GRAY)); if (this.max - 1 == max) max++; for (int i = min; i < max; i++) { if (i == state) - toolTip.add(StringTextComponent.EMPTY.copy().append("-> ").append(options.get(i)).formatted(TextFormatting.WHITE)); + toolTip.add(StringTextComponent.EMPTY.plainCopy().append("-> ").append(options.get(i)).withStyle(TextFormatting.WHITE)); else - toolTip.add(StringTextComponent.EMPTY.copy().append("> ").append(options.get(i)).formatted(TextFormatting.GRAY)); + toolTip.add(StringTextComponent.EMPTY.plainCopy().append("> ").append(options.get(i)).withStyle(TextFormatting.GRAY)); } if (max < this.max) - toolTip.add(new StringTextComponent("> ...").formatted(TextFormatting.GRAY)); + toolTip.add(new StringTextComponent("> ...").withStyle(TextFormatting.GRAY)); - toolTip.add(scrollToSelect.copy().formatted(TextFormatting.DARK_GRAY, TextFormatting.ITALIC)); + toolTip.add(scrollToSelect.plainCopy().withStyle(TextFormatting.DARK_GRAY, TextFormatting.ITALIC)); } } diff --git a/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java b/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java index cc234227a..1b354c712 100644 --- a/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java +++ b/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java @@ -30,7 +30,7 @@ public abstract class CreateItemGroupBase extends ItemGroup { @Override @OnlyIn(Dist.CLIENT) - public void fill(NonNullList items) { + public void fillItemList(NonNullList items) { addItems(items, true); addBlocks(items); addItems(items, false); @@ -42,7 +42,7 @@ public abstract class CreateItemGroupBase extends ItemGroup { Block def = entry.get(); Item item = def.asItem(); if (item != Items.AIR) - def.fillItemGroup(this, items); + def.fillItemCategory(this, items); } } @@ -50,17 +50,17 @@ public abstract class CreateItemGroupBase extends ItemGroup { public void addItems(NonNullList items, boolean specialItems) { Minecraft mc = Minecraft.getInstance(); ItemRenderer itemRenderer = mc.getItemRenderer(); - ClientWorld world = mc.world; + ClientWorld world = mc.level; for (RegistryEntry entry : getItems()) { Item item = entry.get(); if (item instanceof BlockItem) continue; ItemStack stack = new ItemStack(item); - IBakedModel model = itemRenderer.getItemModelWithOverrides(stack, world, null); + IBakedModel model = itemRenderer.getModel(stack, world, null); if (model.isGui3d() != specialItems) continue; - item.fillItemGroup(this, items); + item.fillItemCategory(this, items); } } diff --git a/src/main/java/com/simibubi/create/foundation/item/HiddenIngredientItem.java b/src/main/java/com/simibubi/create/foundation/item/HiddenIngredientItem.java index c565d81e9..3671935ad 100644 --- a/src/main/java/com/simibubi/create/foundation/item/HiddenIngredientItem.java +++ b/src/main/java/com/simibubi/create/foundation/item/HiddenIngredientItem.java @@ -5,6 +5,8 @@ import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraft.item.Item.Properties; + public class HiddenIngredientItem extends Item { public HiddenIngredientItem(Properties p_i48487_1_) { @@ -12,10 +14,10 @@ public class HiddenIngredientItem extends Item { } @Override - public void fillItemGroup(ItemGroup p_150895_1_, NonNullList p_150895_2_) { - if (p_150895_1_ != ItemGroup.SEARCH) + public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + if (p_150895_1_ != ItemGroup.TAB_SEARCH) return; - super.fillItemGroup(p_150895_1_, p_150895_2_); + super.fillItemCategory(p_150895_1_, p_150895_2_); } } diff --git a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java index b9579d81d..f564d0456 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java @@ -51,7 +51,7 @@ public class ItemDescription { public static final ItemDescription MISSING = new ItemDescription(null); public static ITextComponent trim = - new StringTextComponent(" ").formatted(WHITE, STRIKETHROUGH); + new StringTextComponent(" ").withStyle(WHITE, STRIKETHROUGH); public enum Palette { @@ -106,7 +106,7 @@ public class ItemDescription { .get() > 0 && StressImpact.isEnabled(); boolean hasStressCapacity = (isHandle || capacities.containsKey(id)) && StressImpact.isEnabled(); boolean hasGlasses = - AllItems.GOGGLES.get() == Minecraft.getInstance().player.getItemStackFromSlot(EquipmentSlotType.HEAD) + AllItems.GOGGLES.get() == Minecraft.getInstance().player.getItemBySlot(EquipmentSlotType.HEAD) .getItem(); ITextComponent rpmUnit = Lang.translate("generic.unit.rpm"); @@ -115,7 +115,7 @@ public class ItemDescription { Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high"); int index = minimumRequiredSpeedLevel.ordinal(); IFormattableTextComponent level = - new StringTextComponent(makeProgressBar(3, index)).formatted(minimumRequiredSpeedLevel.getTextColor()); + new StringTextComponent(makeProgressBar(3, index)).withStyle(minimumRequiredSpeedLevel.getTextColor()); if (hasGlasses) level.append(String.valueOf(minimumRequiredSpeedLevel.getSpeedValue())) @@ -125,7 +125,7 @@ public class ItemDescription { level.append(speedLevels.get(index)); list.add(Lang.translate("tooltip.speedRequirement") - .formatted(GRAY)); + .withStyle(GRAY)); list.add(level); } @@ -137,7 +137,7 @@ public class ItemDescription { : (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW); int index = impactId.ordinal(); IFormattableTextComponent level = - new StringTextComponent(makeProgressBar(3, index)).formatted(impactId.getAbsoluteColor()); + new StringTextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor()); if (hasGlasses) level.append(impacts.get(id) @@ -147,7 +147,7 @@ public class ItemDescription { level.append(stressLevels.get(index)); list.add(Lang.translate("tooltip.stressImpact") - .formatted(GRAY)); + .withStyle(GRAY)); list.add(level); } @@ -160,7 +160,7 @@ public class ItemDescription { : (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH); int index = StressImpact.values().length - 2 - impactId.ordinal(); IFormattableTextComponent level = - new StringTextComponent(makeProgressBar(3, index)).formatted(impactId.getAbsoluteColor()); + new StringTextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor()); if (hasGlasses) level.append(capacity + "x ") @@ -173,14 +173,14 @@ public class ItemDescription { // " " + DARK_GRAY + TextFormatting.ITALIC + Lang.translate("tooltip.capacityProvided.asGenerator"); list.add(Lang.translate("tooltip.capacityProvided") - .formatted(GRAY)); + .withStyle(GRAY)); list.add(level); IFormattableTextComponent genSpeed = generatorSpeed(block, rpmUnit); if (!genSpeed.getString() .isEmpty()) list.add(new StringTextComponent(" ").append(genSpeed) - .formatted(DARK_GRAY)); + .withStyle(DARK_GRAY)); } // if (hasSpeedRequirement || hasStressImpact || hasStressCapacity) @@ -199,13 +199,13 @@ public class ItemDescription { } public ItemDescription withBehaviour(String condition, String behaviour) { - add(linesOnShift, new StringTextComponent(condition).formatted(GRAY)); + add(linesOnShift, new StringTextComponent(condition).withStyle(GRAY)); addStrings(linesOnShift, cutStringTextComponent(behaviour, palette.color, palette.hColor, 1)); return this; } public ItemDescription withControl(String condition, String action) { - add(linesOnCtrl, new StringTextComponent(condition).formatted(GRAY)); + add(linesOnCtrl, new StringTextComponent(condition).withStyle(GRAY)); addStrings(linesOnCtrl, cutStringTextComponent(action, palette.color, palette.hColor, 1)); return this; } @@ -230,19 +230,19 @@ public class ItemDescription { if (hasControls) { IFormattableTextComponent tabBuilder = new StringTextComponent(""); - tabBuilder.append(new StringTextComponent(holdCtrl[0]).formatted(DARK_GRAY)); - tabBuilder.append(keyCtrl.copy() - .formatted(ctrl ? WHITE : GRAY)); - tabBuilder.append(new StringTextComponent(holdCtrl[1]).formatted(DARK_GRAY)); + tabBuilder.append(new StringTextComponent(holdCtrl[0]).withStyle(DARK_GRAY)); + tabBuilder.append(keyCtrl.plainCopy() + .withStyle(ctrl ? WHITE : GRAY)); + tabBuilder.append(new StringTextComponent(holdCtrl[1]).withStyle(DARK_GRAY)); list.add(0, tabBuilder); } if (hasDescription) { IFormattableTextComponent tabBuilder = new StringTextComponent(""); - tabBuilder.append(new StringTextComponent(holdDesc[0]).formatted(DARK_GRAY)); - tabBuilder.append(keyShift.copy() - .formatted(shift ? WHITE : GRAY)); - tabBuilder.append(new StringTextComponent(holdDesc[1]).formatted(DARK_GRAY)); + tabBuilder.append(new StringTextComponent(holdDesc[0]).withStyle(DARK_GRAY)); + tabBuilder.append(keyShift.plainCopy() + .withStyle(shift ? WHITE : GRAY)); + tabBuilder.append(new StringTextComponent(holdDesc[1]).withStyle(DARK_GRAY)); list.add(0, tabBuilder); } @@ -325,7 +325,7 @@ public class ItemDescription { } return !value.equals("") ? Lang.translate("tooltip.generationSpeed", value, unitRPM) - : StringTextComponent.EMPTY.copy(); + : StringTextComponent.EMPTY.plainCopy(); } } diff --git a/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java b/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java index 155f4758c..fdcdbb801 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java @@ -26,7 +26,7 @@ public class ItemHelper { public static void dropContents(World world, BlockPos pos, IItemHandler inv) { for (int slot = 0; slot < inv.getSlots(); slot++) - InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), inv.getStackInSlot(slot)); + InventoryHelper.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), inv.getStackInSlot(slot)); } public static List multipliedOutput(ItemStack in, ItemStack out) { @@ -98,8 +98,8 @@ public class ItemHelper { Ingredients: for (Ingredient igd : recipeIngredients) { for (Pair pair : actualIngredients) { ItemStack[] stacks1 = pair.getFirst() - .getMatchingStacks(); - ItemStack[] stacks2 = igd.getMatchingStacks(); + .getItems(); + ItemStack[] stacks2 = igd.getItems(); if (stacks1.length != stacks2.length) continue; for (int i = 0; i <= stacks1.length; i++) { @@ -108,7 +108,7 @@ public class ItemHelper { .increment(); continue Ingredients; } - if (!ItemStack.areItemStacksEqual(stacks1[i], stacks2[i])) + if (!ItemStack.matches(stacks1[i], stacks2[i])) break; } } @@ -118,11 +118,11 @@ public class ItemHelper { } public static boolean matchIngredients(Ingredient i1, Ingredient i2) { - ItemStack[] stacks1 = i1.getMatchingStacks(); - ItemStack[] stacks2 = i2.getMatchingStacks(); + ItemStack[] stacks1 = i1.getItems(); + ItemStack[] stacks2 = i2.getItems(); if (stacks1.length == stacks2.length) { for (int i = 0; i < stacks1.length; i++) - if (!ItemStack.areItemsEqual(stacks1[i], stacks2[i])) + if (!ItemStack.isSame(stacks1[i], stacks2[i])) return false; return true; } diff --git a/src/main/java/com/simibubi/create/foundation/item/SmartInventory.java b/src/main/java/com/simibubi/create/foundation/item/SmartInventory.java index 7be383918..f8ab9b2f7 100644 --- a/src/main/java/com/simibubi/create/foundation/item/SmartInventory.java +++ b/src/main/java/com/simibubi/create/foundation/item/SmartInventory.java @@ -105,8 +105,8 @@ public class SmartInventory extends RecipeWrapper } @Override - public ItemStack getStackInSlot(int slot) { - return super.getStackInSlot(slot); + public ItemStack getItem(int slot) { + return super.getItem(slot); } public int getStackLimit(int slot, @Nonnull ItemStack stack) { @@ -162,7 +162,7 @@ public class SmartInventory extends RecipeWrapper @Override public ItemStack getStackInSlotIntermediate(int slot) { - return getStackInSlot(slot); + return getItem(slot); } } diff --git a/src/main/java/com/simibubi/create/foundation/item/TagDependentIngredientItem.java b/src/main/java/com/simibubi/create/foundation/item/TagDependentIngredientItem.java index 55e6f5d8f..777e174c9 100644 --- a/src/main/java/com/simibubi/create/foundation/item/TagDependentIngredientItem.java +++ b/src/main/java/com/simibubi/create/foundation/item/TagDependentIngredientItem.java @@ -8,6 +8,8 @@ import net.minecraft.tags.ItemTags; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; +import net.minecraft.item.Item.Properties; + public class TagDependentIngredientItem extends Item { private ResourceLocation tag; @@ -18,15 +20,15 @@ public class TagDependentIngredientItem extends Item { } @Override - public void fillItemGroup(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { if (!shouldHide()) - super.fillItemGroup(p_150895_1_, p_150895_2_); + super.fillItemCategory(p_150895_1_, p_150895_2_); } public boolean shouldHide() { - ITag tag = ItemTags.getCollection() - .get(this.tag); - return tag == null || tag.values() + ITag tag = ItemTags.getAllTags() + .getTag(this.tag); + return tag == null || tag.getValues() .isEmpty(); } 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 29f2c2abf..5b1704b5d 100644 --- a/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java @@ -45,26 +45,26 @@ public class TooltipHelper { public static IFormattableTextComponent holdShift(Palette color, boolean highlighted) { return Lang.translate("tooltip.holdForDescription", Lang.translate("tooltip.keyShift") - .formatted(TextFormatting.GRAY)) - .formatted(TextFormatting.DARK_GRAY); + .withStyle(TextFormatting.GRAY)) + .withStyle(TextFormatting.DARK_GRAY); } public static void addHint(List tooltip, String hintKey, Object... messageParams) { ITextComponent spacing = IHaveGoggleInformation.componentSpacing; - tooltip.add(spacing.copy() + tooltip.add(spacing.plainCopy() .append(Lang.translate(hintKey + ".title")) - .formatted(GOLD)); + .withStyle(GOLD)); ITextComponent hint = Lang.translate(hintKey); List cutComponent = TooltipHelper.cutTextComponent(hint, GRAY, TextFormatting.WHITE); for (ITextComponent component : cutComponent) - tooltip.add(spacing.copy() + tooltip.add(spacing.plainCopy() .append(component)); } public static void referTo(IItemProvider item, Supplier itemWithTooltip) { tooltipReferrals.put(item.asItem(), () -> itemWithTooltip.get() .asItem() - .getTranslationKey()); + .getDescriptionId()); } public static void referTo(IItemProvider item, String string) { @@ -73,7 +73,7 @@ public class TooltipHelper { @Deprecated public static List cutString(ITextComponent s, TextFormatting defaultColor, TextFormatting highlightColor) { - return cutString(s.getUnformattedComponentText(), defaultColor, highlightColor, 0); + return cutString(s.getContents(), defaultColor, highlightColor, 0); } @Deprecated @@ -92,7 +92,7 @@ public class TooltipHelper { words.add(word); } - FontRenderer font = Minecraft.getInstance().fontRenderer; + FontRenderer font = Minecraft.getInstance().font; List lines = FontHelper.cutString(font, markedUp, maxWidthPerLine); // Format @@ -140,12 +140,12 @@ public class TooltipHelper { } // Apply hard wrap - FontRenderer font = Minecraft.getInstance().fontRenderer; + FontRenderer font = Minecraft.getInstance().font; List lines = new LinkedList<>(); StringBuilder currentLine = new StringBuilder(); int width = 0; for (String word : words) { - int newWidth = font.getStringWidth(word.replaceAll("_", "")); + int newWidth = font.width(word.replaceAll("_", "")); if (width + newWidth > maxWidthPerLine) { if (width > 0) { String line = currentLine.toString(); @@ -166,16 +166,16 @@ public class TooltipHelper { // Format IFormattableTextComponent lineStart = new StringTextComponent(Strings.repeat(" ", indent)); - lineStart.formatted(defaultColor); + lineStart.withStyle(defaultColor); List formattedLines = new ArrayList<>(lines.size()); Couple f = Couple.create(highlightColor, defaultColor); boolean currentlyHighlighted = false; for (String string : lines) { - IFormattableTextComponent currentComponent = lineStart.copy(); + IFormattableTextComponent currentComponent = lineStart.plainCopy(); String[] split = string.split("_"); for (String part : split) { - currentComponent.append(new StringTextComponent(part).formatted(f.get(currentlyHighlighted))); + currentComponent.append(new StringTextComponent(part).withStyle(f.get(currentlyHighlighted))); currentlyHighlighted = !currentlyHighlighted; } @@ -228,7 +228,7 @@ public class TooltipHelper { private static void checkLocale() { Language currentLanguage = Minecraft.getInstance() .getLanguageManager() - .getCurrentLanguage(); + .getSelected(); if (cachedLanguage != currentLanguage) { cachedTooltips.clear(); cachedLanguage = currentLanguage; @@ -238,7 +238,7 @@ public class TooltipHelper { public static boolean hasTooltip(ItemStack stack, PlayerEntity player) { checkLocale(); - boolean hasGlasses = AllItems.GOGGLES.isIn(player.getItemStackFromSlot(EquipmentSlotType.HEAD)); + boolean hasGlasses = AllItems.GOGGLES.isIn(player.getItemBySlot(EquipmentSlotType.HEAD)); if (hasGlasses != gogglesMode) { gogglesMode = hasGlasses; @@ -264,7 +264,7 @@ public class TooltipHelper { private static boolean findTooltip(ItemStack stack) { String key = getTooltipTranslationKey(stack); - if (I18n.hasKey(key)) { + if (I18n.exists(key)) { cachedTooltips.put(key, buildToolTip(key, stack)); return true; } @@ -278,8 +278,8 @@ public class TooltipHelper { String summaryKey = translationKey + ".summary"; // Summary - if (I18n.hasKey(summaryKey)) - tooltip = tooltip.withSummary(new StringTextComponent(I18n.format(summaryKey))); + if (I18n.exists(summaryKey)) + tooltip = tooltip.withSummary(new StringTextComponent(I18n.get(summaryKey))); // Requirements // if (stack.getItem() instanceof BlockItem) { @@ -293,21 +293,21 @@ public class TooltipHelper { for (int i = 1; i < 100; i++) { String conditionKey = translationKey + ".condition" + i; String behaviourKey = translationKey + ".behaviour" + i; - if (!I18n.hasKey(conditionKey)) + if (!I18n.exists(conditionKey)) break; if (i == 1) tooltip.getLinesOnShift() .add(new StringTextComponent("")); - tooltip.withBehaviour(I18n.format(conditionKey), I18n.format(behaviourKey)); + tooltip.withBehaviour(I18n.get(conditionKey), I18n.get(behaviourKey)); } // Controls for (int i = 1; i < 100; i++) { String controlKey = translationKey + ".control" + i; String actionKey = translationKey + ".action" + i; - if (!I18n.hasKey(controlKey)) + if (!I18n.exists(controlKey)) break; - tooltip.withControl(I18n.format(controlKey), I18n.format(actionKey)); + tooltip.withControl(I18n.get(controlKey), I18n.get(actionKey)); } return tooltip.createTabs(); @@ -318,7 +318,7 @@ public class TooltipHelper { if (tooltipReferrals.containsKey(item)) return tooltipReferrals.get(item) .get() + ".tooltip"; - return item.getTranslationKey(stack) + ".tooltip"; + return item.getDescriptionId(stack) + ".tooltip"; } // private static int getComponentLength(ITextComponent component) { diff --git a/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java b/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java index 6ef18e8cd..23fa7f229 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java @@ -29,7 +29,7 @@ public abstract class CustomRenderedItemModel extends BakedModelWrapper getIntersectingContraptions() { - Set contraptions = ContraptionHandler.loadedContraptions.get(self.world) + Set contraptions = ContraptionHandler.loadedContraptions.get(self.level) .values() .stream() .map(Reference::get) .filter(cEntity -> cEntity != null && cEntity.collidingEntities.containsKey(self)) .collect(Collectors.toSet()); - contraptions.addAll(self.world.getEntitiesWithinAABB(AbstractContraptionEntity.class, self.getBoundingBox() - .grow(1f))); + contraptions.addAll(self.level.getEntitiesOfClass(AbstractContraptionEntity.class, self.getBoundingBox() + .inflate(1f))); return contraptions; } @@ -87,9 +87,9 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid } @Inject(at = @At(value = "JUMP", opcode = 154, // IFNE line 587 injecting before `!blockstate.isAir(this.world, blockpos)` - ordinal = 4), method = "move") + ordinal = 4), method = "move") // nextStep()F private void movementMixin(MoverType mover, Vector3d movement, CallbackInfo ci) { - Vector3d worldPos = self.getPositionVec() + Vector3d worldPos = self.position() .add(0, -0.2, 0); AtomicBoolean stepped = new AtomicBoolean(false); @@ -104,25 +104,25 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid this.nextStepDistance = this.determineNextStepDistance(); } - @Inject(method = { "spawnSprintingParticles" }, at = @At(value = "TAIL")) + @Inject(method = { "spawnSprintingParticles" }, at = @At(value = "TAIL")) // spawnSprintParticle()V private void createRunningParticlesMixin(CallbackInfo ci) { - Vector3d worldPos = self.getPositionVec() + Vector3d worldPos = self.position() .add(0, -0.2, 0); BlockPos pos = new BlockPos(worldPos); // pos where particles are spawned forCollision(worldPos, (contraption, blockstate, blockpos) -> { - if (!blockstate.addRunningEffects(self.world, blockpos, self) - && blockstate.getRenderType() != BlockRenderType.INVISIBLE) { - Vector3d vec3d = self.getMotion(); - self.world.addParticle(new BlockParticleData(ParticleTypes.BLOCK, blockstate).setPos(pos), - self.getX() + ((double) rand.nextFloat() - 0.5D) * (double) self.getWidth(), self.getY() + 0.1D, - self.getZ() + ((double) rand.nextFloat() - 0.5D) * (double) self.getWidth(), vec3d.x * -4.0D, 1.5D, + if (!blockstate.addRunningEffects(self.level, blockpos, self) + && blockstate.getRenderShape() != BlockRenderType.INVISIBLE) { + Vector3d vec3d = self.getDeltaMovement(); + self.level.addParticle(new BlockParticleData(ParticleTypes.BLOCK, blockstate).setPos(pos), + self.getX() + ((double) rand.nextFloat() - 0.5D) * (double) self.getBbWidth(), self.getY() + 0.1D, + self.getZ() + ((double) rand.nextFloat() - 0.5D) * (double) self.getBbWidth(), vec3d.x * -4.0D, 1.5D, vec3d.z * -4.0D); } }); } - @Inject(method = "playSound", at = @At("HEAD"), cancellable = true) + @Inject(method = "playSound", at = @At("HEAD"), cancellable = true) // playSound(Lnet/minecraft/util/SoundEvent;FF)V private void playSoundShifted(SoundEvent event, float pitch, float volume, CallbackInfo ci) { if (this.contraption != null && (!self.isSilent() || self instanceof PlayerEntity)) { double x = self.getX(); @@ -132,7 +132,7 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid worldPos = worldPos.add(x, y, z); - self.world.playSound(null, worldPos.x + x, worldPos.y + y, worldPos.z + z, event, self.getSoundCategory(), + self.level.playSound(null, worldPos.x + x, worldPos.y + y, worldPos.z + z, event, self.getSoundSource(), pitch, volume); ci.cancel(); diff --git a/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java index 46b35d6e3..12bb65618 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java @@ -18,6 +18,7 @@ public class FixNormalScalingMixin { * same as in the beginning. */ @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/vector/Matrix3f;multiply(F)V", shift = Shift.AFTER), method = "scale(FFF)V", cancellable = true) + // At mul(F)V, method: scale(FFF)V private void returnAfterNegate(float x, float y, float z, CallbackInfo ci) { ci.cancel(); } @@ -30,6 +31,7 @@ public class FixNormalScalingMixin { * does not work for negative numbers. */ @ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;fastInverseCbrt(F)F"), method = "scale(FFF)V") + // at fastInvCubeRoot(F)F, method: fastInvCubeRoot(F)F private float absInvCbrtInput(float input) { return Math.abs(input); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java index 3ab84bb01..985b74d01 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java @@ -22,7 +22,7 @@ public abstract class HeavyBootsOnPlayerMixin extends AbstractClientPlayerEntity super(p_i50991_1_, p_i50991_2_); } - @Inject(at = @At("HEAD"), method = "canSwim", cancellable = true) + @Inject(at = @At("HEAD"), method = "canSwim", cancellable = true) // isUnderWater()Z public void noSwimmingWithHeavyBootsOn(CallbackInfoReturnable cir) { CompoundNBT persistentData = getPersistentData(); if (persistentData.contains("HeavyBoots")) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java index cf9babd4d..a7857c1b0 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java @@ -27,8 +27,8 @@ public class ModelDataRefreshMixin { @Inject(at = @At("HEAD"), method = "requestModelDataRefresh", cancellable = true, remap = false) private static void requestModelDataRefresh(TileEntity te, CallbackInfo ci) { if (te != null) { - World world = te.getWorld(); - if (world != Minecraft.getInstance().world && world instanceof SchematicWorld) + World world = te.getLevel(); + if (world != Minecraft.getInstance().level && world instanceof SchematicWorld) ci.cancel(); } } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java index 21ed291ff..5d0a60b8c 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java @@ -20,7 +20,7 @@ public class WindowResizeMixin { @Shadow @Final private MainWindow mainWindow; - @Inject(at = @At("TAIL"), method = "updateWindowSize") + @Inject(at = @At("TAIL"), method = "updateWindowSize") // resizeDisplay()V private void updateWindowSize(CallbackInfo ci) { UIRenderHelper.updateWindowSize(mainWindow); } 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 4138e6fc1..079bc0cbd 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java +++ b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java @@ -143,7 +143,7 @@ public enum AllPackets { public static void sendToNear(World world, BlockPos pos, int range, Object message) { channel.send(PacketDistributor.NEAR - .with(TargetPoint.p(pos.getX(), pos.getY(), pos.getZ(), range, world.getRegistryKey())), message); + .with(TargetPoint.p(pos.getX(), pos.getY(), pos.getZ(), range, world.dimension())), message); } private static class LoadedPacket { diff --git a/src/main/java/com/simibubi/create/foundation/networking/ISyncPersistentData.java b/src/main/java/com/simibubi/create/foundation/networking/ISyncPersistentData.java index f8d30dd44..77d3ccfde 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/ISyncPersistentData.java +++ b/src/main/java/com/simibubi/create/foundation/networking/ISyncPersistentData.java @@ -26,29 +26,29 @@ public interface ISyncPersistentData { public Packet(Entity entity) { this.entity = entity; - this.entityId = entity.getEntityId(); + this.entityId = entity.getId(); } public Packet(PacketBuffer buffer) { entityId = buffer.readInt(); - readData = buffer.readCompoundTag(); + readData = buffer.readNbt(); } @Override public void write(PacketBuffer buffer) { buffer.writeInt(entityId); - buffer.writeCompoundTag(entity.getPersistentData()); + buffer.writeNbt(entity.getPersistentData()); } @Override public void handle(Supplier context) { context.get() .enqueueWork(() -> { - Entity entityByID = Minecraft.getInstance().world.getEntityByID(entityId); + Entity entityByID = Minecraft.getInstance().level.getEntity(entityId); if (!(entityByID instanceof ISyncPersistentData)) return; CompoundNBT data = entityByID.getPersistentData(); - for (Iterator iterator = data.keySet() + for (Iterator iterator = data.getAllKeys() .iterator(); iterator.hasNext(); ) { data.remove(iterator.next()); } diff --git a/src/main/java/com/simibubi/create/foundation/networking/NbtPacket.java b/src/main/java/com/simibubi/create/foundation/networking/NbtPacket.java index b42262760..92d01609e 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/NbtPacket.java +++ b/src/main/java/com/simibubi/create/foundation/networking/NbtPacket.java @@ -30,13 +30,13 @@ public class NbtPacket extends SimplePacketBase { } public NbtPacket(PacketBuffer buffer) { - stack = buffer.readItemStack(); + stack = buffer.readItem(); slot = buffer.readInt(); hand = Hand.values()[buffer.readInt()]; } public void write(PacketBuffer buffer) { - buffer.writeItemStack(stack); + buffer.writeItem(stack); buffer.writeInt(slot); buffer.writeInt(hand.ordinal()); } @@ -51,16 +51,16 @@ public class NbtPacket extends SimplePacketBase { if (!(stack.getItem() instanceof SymmetryWandItem || stack.getItem() instanceof ZapperItem)) { return; } - stack.removeChildTag("AttributeModifiers"); + stack.removeTagKey("AttributeModifiers"); if (slot == -1) { - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); if (heldItem.getItem() == stack.getItem()) { heldItem.setTag(stack.getTag()); } return; } - ItemStack heldInSlot = player.inventory.getStackInSlot(slot); + ItemStack heldInSlot = player.inventory.getItem(slot); if (heldInSlot.getItem() == stack.getItem()) { heldInSlot.setTag(stack.getTag()); } diff --git a/src/main/java/com/simibubi/create/foundation/networking/TileEntityConfigurationPacket.java b/src/main/java/com/simibubi/create/foundation/networking/TileEntityConfigurationPacket.java index 4bb198dcc..9f0ca903d 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/TileEntityConfigurationPacket.java +++ b/src/main/java/com/simibubi/create/foundation/networking/TileEntityConfigurationPacket.java @@ -39,15 +39,15 @@ public abstract class TileEntityConfigurationPacket .getSender(); if (player == null) return; - World world = player.world; + World world = player.level; - if (world == null || !world.isBlockPresent(pos)) + if (world == null || !world.isLoaded(pos)) return; - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (tileEntity instanceof SyncedTileEntity) { applySettings((TE) tileEntity); ((SyncedTileEntity) tileEntity).sendData(); - tileEntity.markDirty(); + tileEntity.setChanged(); } }); context.get() diff --git a/src/main/java/com/simibubi/create/foundation/networking/TileEntityDataPacket.java b/src/main/java/com/simibubi/create/foundation/networking/TileEntityDataPacket.java index 0be7edd6d..4e8acd5f7 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/TileEntityDataPacket.java +++ b/src/main/java/com/simibubi/create/foundation/networking/TileEntityDataPacket.java @@ -38,12 +38,12 @@ public abstract class TileEntityDataPacket extends public void handle(Supplier context) { NetworkEvent.Context ctx = context.get(); ctx.enqueueWork(() -> { - ClientWorld world = Minecraft.getInstance().world; + ClientWorld world = Minecraft.getInstance().level; if (world == null) return; - TileEntity tile = world.getTileEntity(tilePos); + TileEntity tile = world.getBlockEntity(tilePos); if (tile instanceof SyncedTileEntity) { handlePacket((TE) tile); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java b/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java index 3ff97cfbb..83291738a 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java @@ -45,8 +45,8 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { public NavigatableSimiScreen() { MainWindow window = Minecraft.getInstance() .getWindow(); - depthPointX = window.getScaledWidth() / 2; - depthPointY = window.getScaledHeight() / 2; + depthPointX = window.getGuiScaledWidth() / 2; + depthPointY = window.getGuiScaledHeight() / 2; } @Override @@ -100,18 +100,18 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { if (backTrack == null) return; - ms.push(); + ms.pushPose(); ms.translate(0, 0, 500); if (backTrack.isHovered()) { TranslationTextComponent translate = Lang.translate(backTrackingLangKey()); - textRenderer.draw(ms, translate, 41 - textRenderer.getWidth(translate) / 2, height - 16, + font.draw(ms, translate, 41 - font.width(translate) / 2, height - 16, Theme.i(Theme.Key.TEXT_DARKER)); - if (MathHelper.epsilonEquals(arrowAnimation.getValue(), arrowAnimation.getChaseTarget())) { + if (MathHelper.equal(arrowAnimation.getValue(), arrowAnimation.getChaseTarget())) { arrowAnimation.setValue(1); arrowAnimation.setValue(1);// called twice to also set the previous value to 1 } } - ms.pop(); + ms.popPose(); } protected String backTrackingLangKey() { @@ -145,24 +145,24 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { // draw last screen into buffer if (lastScreen != null && lastScreen != this && !transition.settled()) { - ms.push(); - UIRenderHelper.framebuffer.framebufferClear(Minecraft.IS_RUNNING_ON_MAC); + ms.pushPose(); + UIRenderHelper.framebuffer.clear(Minecraft.ON_OSX); ms.translate(0, 0, -1000); - UIRenderHelper.framebuffer.bindFramebuffer(true); + UIRenderHelper.framebuffer.bindWrite(true); lastScreen.render(ms, mouseX, mouseY, partialTicks); - ms.pop(); - ms.push(); + ms.popPose(); + ms.pushPose(); // use the buffer texture Minecraft.getInstance() - .getFramebuffer() - .bindFramebuffer(true); + .getMainRenderTarget() + .bindWrite(true); MainWindow window = Minecraft.getInstance() .getWindow(); - int dpx = window.getScaledWidth() / 2; - int dpy = window.getScaledHeight() / 2; + int dpx = window.getGuiScaledWidth() / 2; + int dpy = window.getGuiScaledHeight() / 2; if (lastScreen instanceof AbstractSimiScreen) { dpx = ((NavigatableSimiScreen) lastScreen).depthPointX; dpy = ((NavigatableSimiScreen) lastScreen).depthPointY; @@ -177,7 +177,7 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { UIRenderHelper.drawFramebuffer(1f - Math.abs(transitionValue)); RenderSystem.disableBlend(); RenderSystem.enableAlphaTest(); - ms.pop(); + ms.popPose(); } // modify current screen as well @@ -202,9 +202,9 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { } public void centerScalingOnMouse() { - MainWindow w = client.getWindow(); - double mouseX = client.mouseHelper.getMouseX() * w.getScaledWidth() / w.getWidth(); - double mouseY = client.mouseHelper.getMouseY() * w.getScaledHeight() / w.getHeight(); + MainWindow w = minecraft.getWindow(); + double mouseX = minecraft.mouseHandler.xpos() * w.getGuiScaledWidth() / w.getScreenWidth(); + double mouseY = minecraft.mouseHandler.ypos() * w.getGuiScaledHeight() / w.getScreenHeight(); centerScalingOn((int) mouseX, (int) mouseY); } @@ -219,7 +219,7 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { if (history.isEmpty()) return; - history.add(0, Minecraft.getInstance().currentScreen); + history.add(0, Minecraft.getInstance().screen); int spacing = 20; List names = history.stream() @@ -227,7 +227,7 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { .collect(Collectors.toList()); int bWidth = names.stream() - .mapToInt(s -> textRenderer.getStringWidth(s) + spacing) + .mapToInt(s -> font.width(s) + spacing) .sum(); MutableInt x = new MutableInt(width - bWidth); @@ -237,18 +237,18 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { if (x.getValue() < 25) x.setValue(25); - ms.push(); + ms.pushPose(); ms.translate(0, 0, 600); names.forEach(s -> { - int sWidth = textRenderer.getStringWidth(s); + int sWidth = font.width(s); UIRenderHelper.breadcrumbArrow(ms, x.getValue(), y.getValue(), 0, sWidth + spacing, 14, spacing / 2, 0xdd101010, 0x44101010); - textRenderer.draw(ms, s, x.getValue() + 5, y.getValue() + 3, first.getValue() ? 0xffeeffee : 0xffddeeff); + font.draw(ms, s, x.getValue() + 5, y.getValue() + 3, first.getValue() ? 0xffeeffee : 0xffddeeff); first.setFalse(); x.add(sWidth + spacing); }); - ms.pop(); + ms.popPose(); } private static String screenTitle(Screen screen) { 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 bcaf05352..b85cbb1db 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java @@ -90,7 +90,7 @@ public class PonderProgressBar extends AbstractSimiWidget { @Override public void renderButton(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - hovered = clicked(mouseX, mouseY); + isHovered = clicked(mouseX, mouseY); new BoxElement() .withBackground(Theme.c(Theme.Key.PONDER_BACKGROUND_FLAT)) @@ -99,20 +99,20 @@ public class PonderProgressBar extends AbstractSimiWidget { .withBounds(width, height) .render(ms); - ms.push(); + ms.pushPose(); ms.translate(x - 2, y - 2, 200); - ms.push(); + ms.pushPose(); ms.scale((width + 4) * progress.getValue(partialTicks), 1, 1); int c1 = Theme.i(Theme.Key.PONDER_PROGRESSBAR, true); int c2 = Theme.i(Theme.Key.PONDER_PROGRESSBAR, false); - GuiUtils.drawGradientRect(ms.peek().getModel(), 110, 0, 3, 1, 4, c1, c1); - GuiUtils.drawGradientRect(ms.peek().getModel(), 110, 0, 4, 1, 5, c2, c2); - ms.pop(); + GuiUtils.drawGradientRect(ms.last().pose(), 110, 0, 3, 1, 4, c1, c1); + GuiUtils.drawGradientRect(ms.last().pose(), 110, 0, 4, 1, 5, c2, c2); + ms.popPose(); renderKeyframes(ms, mouseX, partialTicks); - ms.pop(); + ms.popPose(); } private void renderKeyframes(MatrixStack ms, int mouseX, float partialTicks) { @@ -124,7 +124,7 @@ public class PonderProgressBar extends AbstractSimiWidget { int idleEndColor = Theme.i(Theme.Key.PONDER_IDLE, false) | 0x40_000000; int hoverIndex; - if (hovered) { + if (isHovered) { hoverIndex = getHoveredKeyframeIndex(activeScene, mouseX); } else { hoverIndex = -2; @@ -152,26 +152,26 @@ public class PonderProgressBar extends AbstractSimiWidget { private void drawKeyframe(MatrixStack ms, PonderScene activeScene, boolean selected, int keyframeTime, int keyframePos, int startColor, int endColor, int height) { if (selected) { - FontRenderer font = Minecraft.getInstance().fontRenderer; - GuiUtils.drawGradientRect(ms.peek() - .getModel(), 100, keyframePos, 10, keyframePos + 1, 10 + height, endColor, startColor); - ms.push(); + FontRenderer font = Minecraft.getInstance().font; + GuiUtils.drawGradientRect(ms.last() + .pose(), 100, keyframePos, 10, keyframePos + 1, 10 + height, endColor, startColor); + ms.pushPose(); ms.translate(0, 0, 100); String text; int offset; if (activeScene.currentTime < keyframeTime) { text = ">"; - offset = -1 - font.getStringWidth(text); + offset = -1 - font.width(text); } else { text = "<"; offset = 3; } font.draw(ms, text, keyframePos + offset, 10, endColor); - ms.pop(); + ms.popPose(); } - GuiUtils.drawGradientRect(ms.peek() - .getModel(), 500, keyframePos, -1, keyframePos + 1, 2 + height, startColor, endColor); + GuiUtils.drawGradientRect(ms.last() + .pose(), 500, keyframePos, -1, keyframePos + 1, 2 + height, startColor, endColor); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java index 06348383c..dac81b346 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java @@ -88,8 +88,8 @@ public class PonderRegistry { for (int i = 0; i < entries.size(); i++) { PonderStoryBoardEntry sb = entries.get(i); Template activeTemplate = loadSchematic(sb.getSchematicName()); - PonderWorld world = new PonderWorld(BlockPos.ZERO, Minecraft.getInstance().world); - activeTemplate.placeAndNotifyListeners(world, BlockPos.ZERO, new PlacementSettings(), world.rand); + PonderWorld world = new PonderWorld(BlockPos.ZERO, Minecraft.getInstance().level); + activeTemplate.placeInWorld(world, BlockPos.ZERO, new PlacementSettings(), world.random); world.createBackup(); PonderScene scene = compileScene(i, sb, world); scene.begin(); @@ -119,7 +119,7 @@ public class PonderRegistry { try (DataInputStream stream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(resourceAsStream)))) { CompoundNBT nbt = CompressedStreamTools.read(stream, new NBTSizeTracker(0x20000000L)); - t.read(nbt); + t.load(nbt); } catch (IOException e) { Create.LOGGER.warn("Failed to read ponder schematic", e); } 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 a970431bd..f1942fba6 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java @@ -107,7 +107,7 @@ public class PonderScene { schedule = new ArrayList<>(); activeSchedule = new ArrayList<>(); transform = new SceneTransform(); - basePlateSize = getBounds().getXSize(); + basePlateSize = getBounds().getXSpan(); info = new SceneRenderInfo(); baseWorldSection = new WorldSectionElement(); renderViewEntity = new ArmorStandEntity(world, 0, 0, 0); @@ -150,10 +150,10 @@ public class PonderScene { BlockPos origin = new BlockPos(basePlateOffsetX, 0, basePlateOffsetZ); if (!world.getBounds() - .isVecInside(selectedPos)) + .isInside(selectedPos)) return Pair.of(ItemStack.EMPTY, null); - if (new MutableBoundingBox(origin, origin.add(new Vector3i(basePlateSize - 1, 0, basePlateSize - 1))) - .isVecInside(selectedPos)) { + if (new MutableBoundingBox(origin, origin.offset(new Vector3i(basePlateSize - 1, 0, basePlateSize - 1))) + .isInside(selectedPos)) { if (PonderIndex.EDITOR_MODE) nearestHit.getValue() .getFirst() @@ -223,15 +223,15 @@ public class PonderScene { } public void renderScene(SuperRenderTypeBuffer buffer, MatrixStack ms, float pt) { - ms.push(); + ms.pushPose(); Minecraft mc = Minecraft.getInstance(); - Entity prevRVE = mc.renderViewEntity; + Entity prevRVE = mc.cameraEntity; - mc.renderViewEntity = this.renderViewEntity; + mc.cameraEntity = this.renderViewEntity; forEachVisible(PonderSceneElement.class, e -> e.renderFirst(world, buffer, ms, pt)); - mc.renderViewEntity = prevRVE; + mc.cameraEntity = prevRVE; - for (RenderType type : RenderType.getBlockLayers()) + for (RenderType type : RenderType.chunkBufferLayers()) forEachVisible(PonderSceneElement.class, e -> e.renderLayer(world, buffer, type, ms, pt)); forEachVisible(PonderSceneElement.class, e -> e.renderLast(world, buffer, ms, pt)); @@ -240,13 +240,13 @@ public class PonderScene { world.renderParticles(ms, buffer, info, pt); outliner.renderOutlines(ms, buffer, pt); - ms.pop(); + ms.popPose(); } public void renderOverlay(PonderUI screen, MatrixStack ms, float partialTicks) { - ms.push(); + ms.pushPose(); forEachVisible(PonderOverlayElement.class, e -> e.render(this, screen, ms, partialTicks)); - ms.pop(); + ms.popPose(); } public void setPointOfInterest(Vector3d poi) { @@ -464,7 +464,7 @@ public class PonderScene { public void updateSceneRVE(float pt) { Vector3d v = screenToScene(width / 2, height / 2, 500, pt); - renderViewEntity.setPosition(v.x, v.y, v.z); + renderViewEntity.setPos(v.x, v.y, v.z); } public Vector3d screenToScene(double x, double y, int depth, float pt) { @@ -482,7 +482,7 @@ public class PonderScene { float f = 1f / (30 * scaleFactor); - vec = vec.mul(f, -f, f); + vec = vec.multiply(f, -f, f); vec = vec.subtract((basePlateSize + basePlateOffsetX) / -2f, -1f + yOffset, (basePlateSize + basePlateOffsetZ) / -2f); @@ -493,14 +493,14 @@ public class PonderScene { refreshMatrix(pt); Vector4f vec4 = new Vector4f((float) vec.x, (float) vec.y, (float) vec.z, 1); vec4.transform(cachedMat); - return new Vector2f(vec4.getX(), vec4.getY()); + return new Vector2f(vec4.x(), vec4.y()); } protected void refreshMatrix(float pt) { if (cachedMat != null) return; - cachedMat = apply(new MatrixStack(), pt, false).peek() - .getModel(); + cachedMat = apply(new MatrixStack(), pt, false).last() + .pose(); } } @@ -508,7 +508,7 @@ public class PonderScene { public class SceneRenderInfo extends ActiveRenderInfo { public void set(float xRotation, float yRotation) { - setDirection(yRotation, xRotation); + setRotation(yRotation, xRotation); } } 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 0cb380252..a47304a31 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java @@ -45,12 +45,12 @@ public class PonderTooltipHandler { } Minecraft instance = Minecraft.getInstance(); - Screen currentScreen = instance.currentScreen; + Screen currentScreen = instance.screen; float value = holdWProgress.getValue(); int keyCode = ponderKeybind().getKey() - .getKeyCode(); + .getValue(); long window = instance.getWindow() - .getHandle(); + .getWindow(); if (!subject && InputMappings.isKeyDown(window, keyCode)) { if (value >= 1) { @@ -77,9 +77,9 @@ public class PonderTooltipHandler { return; float renderPartialTicks = Minecraft.getInstance() - .getRenderPartialTicks(); + .getFrameTime(); ITextComponent component = subject ? Lang.createTranslationTextComponent(SUBJECT) - .formatted(TextFormatting.GREEN) + .withStyle(TextFormatting.GREEN) : makeProgressBar(Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f)); if (toolTip.size() < 2) toolTip.add(component); @@ -89,14 +89,14 @@ public class PonderTooltipHandler { protected static void updateHovered(ItemStack stack) { Minecraft instance = Minecraft.getInstance(); - Screen currentScreen = instance.currentScreen; + Screen currentScreen = instance.screen; ItemStack prevStack = trackingStack; hoveredStack = ItemStack.EMPTY; subject = false; if (currentScreen instanceof PonderUI) { PonderUI ponderUI = (PonderUI) currentScreen; - if (stack.isItemEqual(ponderUI.getSubject())) + if (stack.sameItem(ponderUI.getSubject())) subject = true; } @@ -106,7 +106,7 @@ public class PonderTooltipHandler { .getRegistryName())) return; - if (prevStack.isEmpty() || !prevStack.isItemEqual(stack)) + if (prevStack.isEmpty() || !prevStack.sameItem(stack)) holdWProgress.startWithValue(0); hoveredStack = stack; @@ -119,7 +119,7 @@ public class PonderTooltipHandler { if (holdWProgress.getValue() == 0) return; float renderPartialTicks = Minecraft.getInstance() - .getRenderPartialTicks(); + .getFrameTime(); int start = event.getOriginalBorderStart(); int end = event.getOriginalBorderEnd(); float progress = Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f); @@ -140,12 +140,12 @@ public class PonderTooltipHandler { private static ITextComponent makeProgressBar(float progress) { IFormattableTextComponent holdW = Lang .translate(HOLD_TO_PONDER, - ((IFormattableTextComponent) ponderKeybind().getBoundKeyLocalizedText()).formatted(TextFormatting.GRAY)) - .formatted(TextFormatting.DARK_GRAY); + ((IFormattableTextComponent) ponderKeybind().getTranslatedKeyMessage()).withStyle(TextFormatting.GRAY)) + .withStyle(TextFormatting.DARK_GRAY); - FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; - float charWidth = fontRenderer.getStringWidth("|"); - float tipWidth = fontRenderer.getWidth(holdW); + FontRenderer fontRenderer = Minecraft.getInstance().font; + float charWidth = fontRenderer.width("|"); + float tipWidth = fontRenderer.width(holdW); int total = (int) (tipWidth / charWidth); int current = (int) (progress * total); @@ -162,7 +162,7 @@ public class PonderTooltipHandler { } protected static KeyBinding ponderKeybind() { - return Minecraft.getInstance().gameSettings.keyBindForward; + return Minecraft.getInstance().options.keyUp; } } 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 20a99833a..ddf6de0f7 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java @@ -190,7 +190,7 @@ public class PonderUI extends NavigatableSimiScreen { }).showing(chapter)); }*/ - GameSettings bindings = client.gameSettings; + GameSettings bindings = minecraft.options; int spacing = 8; int bX = (width - 20) / 2 - (70 + 2 * spacing); int bY = height - 20 - 31; @@ -203,7 +203,7 @@ public class PonderUI extends NavigatableSimiScreen { } widgets.add(scan = new PonderButton(bX, bY) - .withShortcut(bindings.keyBindDrop) + .withShortcut(bindings.keyDrop) .showing(AllIcons.I_MTD_SCAN) .enableFade(0, 5) .withCallback(() -> { @@ -212,7 +212,7 @@ public class PonderUI extends NavigatableSimiScreen { scenes.get(index) .deselect(); else - ponderPartialTicksPaused = client.getRenderPartialTicks(); + ponderPartialTicksPaused = minecraft.getFrameTime(); })); widgets.add(slowMode = new PonderButton(width - 20 - 31, bY) @@ -229,28 +229,28 @@ public class PonderUI extends NavigatableSimiScreen { bX += 50 + spacing; widgets.add(left = new PonderButton(bX, bY) - .withShortcut(bindings.keyBindLeft) + .withShortcut(bindings.keyLeft) .showing(AllIcons.I_MTD_LEFT) .enableFade(0, 5) .withCallback(() -> this.scroll(false))); bX += 20 + spacing; widgets.add(close = new PonderButton(bX, bY) - .withShortcut(bindings.keyBindInventory) + .withShortcut(bindings.keyInventory) .showing(AllIcons.I_MTD_CLOSE) .enableFade(0, 5) .withCallback(this::onClose)); bX += 20 + spacing; widgets.add(right = new PonderButton(bX, bY) - .withShortcut(bindings.keyBindRight) + .withShortcut(bindings.keyRight) .showing(AllIcons.I_MTD_RIGHT) .enableFade(0, 5) .withCallback(() -> this.scroll(true))); bX += 50 + spacing; widgets.add(replay = new PonderButton(bX, bY) - .withShortcut(bindings.keyBindBack) + .withShortcut(bindings.keyDown) .showing(AllIcons.I_MTD_REPLAY) .enableFade(0, 5) .withCallback(this::replay)); @@ -342,9 +342,9 @@ public class PonderUI extends NavigatableSimiScreen { if (!identifyMode) return; - MainWindow w = client.getWindow(); - double mouseX = client.mouseHelper.getMouseX() * w.getScaledWidth() / w.getWidth(); - double mouseY = client.mouseHelper.getMouseY() * w.getScaledHeight() / w.getHeight(); + MainWindow w = minecraft.getWindow(); + double mouseX = minecraft.mouseHandler.xpos() * w.getGuiScaledWidth() / w.getScreenWidth(); + double mouseY = minecraft.mouseHandler.ypos() * w.getGuiScaledHeight() / w.getScreenHeight(); SceneTransform t = activeScene.getTransform(); Vector3d vec1 = t.screenToScene(mouseX, mouseY, 1000, 0); Vector3d vec2 = t.screenToScene(mouseX, mouseY, -100, 0); @@ -368,8 +368,8 @@ public class PonderUI extends NavigatableSimiScreen { List list = PonderRegistry.all.get(scene.component); PonderStoryBoardEntry sb = list.get(index); Template activeTemplate = PonderRegistry.loadSchematic(sb.getSchematicName()); - PonderWorld world = new PonderWorld(BlockPos.ZERO, Minecraft.getInstance().world); - activeTemplate.placeAndNotifyListeners(world, BlockPos.ZERO, new PlacementSettings(), new Random()); + PonderWorld world = new PonderWorld(BlockPos.ZERO, Minecraft.getInstance().level); + activeTemplate.placeInWorld(world, BlockPos.ZERO, new PlacementSettings(), new Random()); world.createBackup(); scene = PonderRegistry.compileScene(index, sb, world); scene.begin(); @@ -420,7 +420,7 @@ public class PonderUI extends NavigatableSimiScreen { protected void renderScene(MatrixStack ms, int mouseX, int mouseY, int i, float partialTicks) { SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance(); PonderScene story = scenes.get(i); - double value = lazyIndex.getValue(client.getRenderPartialTicks()); + double value = lazyIndex.getValue(minecraft.getFrameTime()); double diff = i - value; double slide = MathHelper.lerp(diff * diff, 200, 600) * diff; @@ -433,7 +433,7 @@ public class PonderUI extends NavigatableSimiScreen { // has to be outside of MS transforms, important for vertex sorting RenderSystem.translated(0, 0, 800); - ms.push(); + ms.pushPose(); ms.translate(0, 0, -800); story.transform.updateScreenParams(width, height, slide); story.transform.apply(ms, partialTicks, false); @@ -442,13 +442,13 @@ public class PonderUI extends NavigatableSimiScreen { buffer.draw(); MutableBoundingBox bounds = story.getBounds(); - ms.push(); + ms.pushPose(); // kool shadow fx { RenderSystem.enableCull(); RenderSystem.enableDepthTest(); - ms.push(); + ms.pushPose(); ms.translate(story.basePlateOffsetX, 0, story.basePlateOffsetZ); ms.scale(1, -1, 1); @@ -461,23 +461,23 @@ public class PonderUI extends NavigatableSimiScreen { for (int f = 0; f < 4; f++) { ms.translate(story.basePlateSize, 0, 0); - ms.push(); + ms.pushPose(); ms.translate(0, 0, -1 / 1024f); if (flash > 0) { - ms.push(); + ms.pushPose(); ms.scale(1, .5f + flash * .75f, 1); - GuiUtils.drawGradientRect(ms.peek() - .getModel(), 0, 0, -1, -story.basePlateSize, 0, 0x00_c6ffc9, + GuiUtils.drawGradientRect(ms.last() + .pose(), 0, 0, -1, -story.basePlateSize, 0, 0x00_c6ffc9, ColorHelper.applyAlpha(0xaa_c6ffc9, alpha)); - ms.pop(); + ms.popPose(); } ms.translate(0, 0, 2 / 1024f); - GuiUtils.drawGradientRect(ms.peek() - .getModel(), 0, 0, 0, -story.basePlateSize, 4, 0x66_000000, 0x00_000000); - ms.pop(); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90)); + GuiUtils.drawGradientRect(ms.last() + .pose(), 0, 0, 0, -story.basePlateSize, 4, 0x66_000000, 0x00_000000); + ms.popPose(); + ms.mulPose(Vector3f.YP.rotationDegrees(-90)); } - ms.pop(); + ms.popPose(); RenderSystem.disableCull(); RenderSystem.disableDepthTest(); } @@ -490,48 +490,48 @@ public class PonderUI extends NavigatableSimiScreen { ms.translate(1, -8, -1 / 64f); // X AXIS - ms.push(); + ms.pushPose(); ms.translate(4, -3, 0); ms.translate(0, 0, -2 / 1024f); - for (int x = 0; x <= bounds.getXSize(); x++) { + for (int x = 0; x <= bounds.getXSpan(); x++) { ms.translate(-16, 0, 0); - textRenderer.draw(ms, x == bounds.getXSize() ? "x" : "" + x, 0, 0, 0xFFFFFFFF); + font.draw(ms, x == bounds.getXSpan() ? "x" : "" + x, 0, 0, 0xFFFFFFFF); } - ms.pop(); + ms.popPose(); // Z AXIS - ms.push(); + ms.pushPose(); ms.scale(-1, 1, 1); ms.translate(0, -3, -4); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90)); + ms.mulPose(Vector3f.YP.rotationDegrees(-90)); ms.translate(-8, -2, 2 / 64f); - for (int z = 0; z <= bounds.getZSize(); z++) { + for (int z = 0; z <= bounds.getZSpan(); z++) { ms.translate(16, 0, 0); - textRenderer.draw(ms, z == bounds.getZSize() ? "z" : "" + z, 0, 0, 0xFFFFFFFF); + font.draw(ms, z == bounds.getZSpan() ? "z" : "" + z, 0, 0, 0xFFFFFFFF); } - ms.pop(); + ms.popPose(); // DIRECTIONS - ms.push(); - ms.translate(bounds.getXSize() * -8, 0, bounds.getZSize() * 8); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90)); + ms.pushPose(); + ms.translate(bounds.getXSpan() * -8, 0, bounds.getZSpan() * 8); + ms.mulPose(Vector3f.YP.rotationDegrees(-90)); for (Direction d : Iterate.horizontalDirections) { - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90)); - ms.push(); - ms.translate(0, 0, bounds.getZSize() * 16); - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90)); - textRenderer.draw(ms, d.name() + ms.mulPose(Vector3f.YP.rotationDegrees(90)); + ms.pushPose(); + ms.translate(0, 0, bounds.getZSpan() * 16); + ms.mulPose(Vector3f.XP.rotationDegrees(-90)); + font.draw(ms, d.name() .substring(0, 1), 0, 0, 0x66FFFFFF); - textRenderer.draw(ms, "|", 2, 10, 0x44FFFFFF); - textRenderer.draw(ms, ".", 2, 14, 0x22FFFFFF); - ms.pop(); + font.draw(ms, "|", 2, 10, 0x44FFFFFF); + font.draw(ms, ".", 2, 14, 0x22FFFFFF); + ms.popPose(); } - ms.pop(); + ms.popPose(); buffer.draw(); } - ms.pop(); - ms.pop(); + ms.popPose(); + ms.popPose(); RenderSystem.popMatrix(); } @@ -550,13 +550,13 @@ public class PonderUI extends NavigatableSimiScreen { int tooltipColor = Theme.i(Theme.Key.TEXT_DARKER); { // Chapter title - ms.push(); + ms.pushPose(); ms.translate(0, 0, 400); int x = 31 + 20 + 8; int y = 31; String title = activeScene.getTitle(); - int wordWrappedHeight = textRenderer.getWordWrappedHeight(title, left.x - 51); + int wordWrappedHeight = font.wordWrapHeight(title, left.x - 51); int streakHeight = 35 - 9 + wordWrappedHeight; UIRenderHelper.streak(ms, 0, x - 4, y - 12 + streakHeight / 2, streakHeight, (int) (150 * fade)); @@ -574,27 +574,27 @@ public class PonderUI extends NavigatableSimiScreen { .at(x - 39, y - 11) .render(ms); - textRenderer.draw(ms, Lang.translate(PONDERING), x, y - 6, tooltipColor); + font.draw(ms, Lang.translate(PONDERING), x, y - 6, tooltipColor); y += 8; x += 0; ms.translate(x, y, 0); - ms.multiply(Vector3f.NEGATIVE_X.getDegreesQuaternion(indexDiff * -75)); + ms.mulPose(Vector3f.XN.rotationDegrees(indexDiff * -75)); ms.translate(0, 0, 5); - FontHelper.drawSplitString(ms, textRenderer, title, 0, 0, left.x - 51, + FontHelper.drawSplitString(ms, font, title, 0, 0, left.x - 51, ColorHelper.applyAlpha(Theme.i(Theme.Key.TEXT), 1 - indexDiff)); - ms.pop(); + ms.popPose(); if (chapter != null) { - ms.push(); + ms.pushPose(); ms.translate(chap.x - 4 - 4, chap.y, 0); UIRenderHelper.streak(ms, 180, 4, 10, 26, (int) (150 * fade)); - drawRightAlignedString(textRenderer, ms, Lang.translate(IN_CHAPTER).getString(), 0, 0, tooltipColor); - drawRightAlignedString(textRenderer, ms, + drawRightAlignedString(font, ms, Lang.translate(IN_CHAPTER).getString(), 0, 0, tooltipColor); + drawRightAlignedString(font, ms, Lang.translate(LANG_PREFIX + "chapter." + chapter.getId()).getString(), 0, 12, Theme.i(Theme.Key.TEXT)); - ms.pop(); + ms.popPose(); } UIRenderHelper.breadcrumbArrow(ms, width / 2 - 20, height - 51, 0, 20, 20, 5, 0x40aa9999, 0x20aa9999); @@ -605,16 +605,16 @@ public class PonderUI extends NavigatableSimiScreen { if (identifyMode) { if (noWidgetsHovered && mouseY < height - 80) { - ms.push(); + ms.pushPose(); ms.translate(mouseX, mouseY, 100); if (hoveredTooltipItem.isEmpty()) { IFormattableTextComponent text = Lang.translate( IDENTIFY_MODE, - ((IFormattableTextComponent) client.gameSettings.keyBindDrop.getBoundKeyLocalizedText()).formatted(TextFormatting.WHITE) - ).formatted(TextFormatting.GRAY); + ((IFormattableTextComponent) minecraft.options.keyDrop.getTranslatedKeyMessage()).withStyle(TextFormatting.WHITE) + ).withStyle(TextFormatting.GRAY); //renderOrderedTooltip(ms, textRenderer.wrapLines(text, width / 3), 0, 0); - renderWrappedToolTip(ms, textRenderer.getTextHandler().wrapLines(text, width / 3, Style.EMPTY), 0, 0, textRenderer); + renderWrappedToolTip(ms, font.getSplitter().splitLines(text, width / 3, Style.EMPTY), 0, 0, font); /*String tooltip = Lang .createTranslationTextComponent(IDENTIFY_MODE, client.gameSettings.keyBindDrop.getBoundKeyLocalizedText().applyTextStyle(TextFormatting.WHITE)) .applyTextStyle(TextFormatting.GRAY) @@ -626,10 +626,10 @@ public class PonderUI extends NavigatableSimiScreen { ms.translate(0, -15, 0); boolean copied = copiedBlockPos != null && hoveredBlockPos.equals(copiedBlockPos); IFormattableTextComponent coords = new StringTextComponent(hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ()) - .formatted(copied ? TextFormatting.GREEN : TextFormatting.GOLD); + .withStyle(copied ? TextFormatting.GREEN : TextFormatting.GOLD); renderTooltip(ms, coords, 0, 0); } - ms.pop(); + ms.popPose(); } scan.flash(); } else { @@ -651,12 +651,12 @@ public class PonderUI extends NavigatableSimiScreen { { // Scene overlay float scenePT = skipCooling > 0 ? 0 : partialTicks; - ms.push(); + ms.pushPose(); ms.translate(0, 0, 100); renderOverlay(ms, index, scenePT); if (indexDiff > 1 / 512f) renderOverlay(ms, lazyIndexValue < index ? index - 1 : index + 1, scenePT); - ms.pop(); + ms.popPose(); } // Widgets @@ -682,10 +682,10 @@ public class PonderUI extends NavigatableSimiScreen { boolean highlightAll = sceneTags.contains(PonderTag.Highlight.ALL); double s = Minecraft.getInstance() .getWindow() - .getGuiScaleFactor(); + .getGuiScale(); IntStream.range(0, tagButtons.size()) .forEach(i -> { - ms.push(); + ms.pushPose(); LerpedFloat chase = tagFades.get(i); PonderButton button = tagButtons.get(i); if (button.isMouseOver(mouseX, mouseY)) { @@ -712,31 +712,31 @@ public class PonderUI extends NavigatableSimiScreen { String tagName = this.tags.get(i) .getTitle(); - textRenderer.draw(ms, tagName, 3, 8, Theme.i(Theme.Key.TEXT_ACCENT_SLIGHT)); + font.draw(ms, tagName, 3, 8, Theme.i(Theme.Key.TEXT_ACCENT_SLIGHT)); GL11.glDisable(GL11.GL_SCISSOR_TEST); - ms.pop(); + ms.popPose(); }); - ms.push(); + ms.pushPose(); ms.translate(0, 0, 500); int tooltipY = height - 16; if (scan.isHovered()) - drawCenteredText(ms, textRenderer, Lang.translate(IDENTIFY), scan.x + 10, tooltipY, tooltipColor); + drawCenteredString(ms, font, Lang.translate(IDENTIFY), scan.x + 10, tooltipY, tooltipColor); if (index != 0 && left.isHovered()) - drawCenteredText(ms, textRenderer, Lang.translate(PREVIOUS), left.x + 10, tooltipY, tooltipColor); + drawCenteredString(ms, font, Lang.translate(PREVIOUS), left.x + 10, tooltipY, tooltipColor); if (close.isHovered()) - drawCenteredText(ms, textRenderer, Lang.translate(CLOSE), close.x + 10, tooltipY, tooltipColor); + drawCenteredString(ms, font, Lang.translate(CLOSE), close.x + 10, tooltipY, tooltipColor); if (index != scenes.size() - 1 && right.isHovered()) - drawCenteredText(ms, textRenderer, Lang.translate(NEXT), right.x + 10, tooltipY, tooltipColor); + drawCenteredString(ms, font, Lang.translate(NEXT), right.x + 10, tooltipY, tooltipColor); if (replay.isHovered()) - drawCenteredText(ms, textRenderer, Lang.translate(REPLAY), replay.x + 10, tooltipY, tooltipColor); + drawCenteredString(ms, font, Lang.translate(REPLAY), replay.x + 10, tooltipY, tooltipColor); if (slowMode.isHovered()) - drawCenteredText(ms, textRenderer, Lang.translate(SLOW_TEXT), slowMode.x + 5, tooltipY, tooltipColor); + drawCenteredString(ms, font, Lang.translate(SLOW_TEXT), slowMode.x + 5, tooltipY, tooltipColor); if (PonderIndex.EDITOR_MODE && userMode.isHovered()) - drawCenteredString(ms, textRenderer, "Editor View", userMode.x + 10, tooltipY, tooltipColor); - ms.pop(); + drawCenteredString(ms, font, "Editor View", userMode.x + 10, tooltipY, tooltipColor); + ms.popPose(); RenderSystem.enableDepthTest(); } @@ -744,19 +744,19 @@ public class PonderUI extends NavigatableSimiScreen { private void renderOverlay(MatrixStack ms, int i, float partialTicks) { if (identifyMode) return; - ms.push(); + ms.pushPose(); PonderScene story = scenes.get(i); story.renderOverlay(this, ms, skipCooling > 0 ? 0 : identifyMode ? ponderPartialTicksPaused : partialTicks); - ms.pop(); + ms.popPose(); } @Override public boolean mouseClicked(double x, double y, int button) { if (identifyMode && hoveredBlockPos != null && PonderIndex.EDITOR_MODE) { - long handle = client.getWindow() - .getHandle(); + long handle = minecraft.getWindow() + .getWindow(); if (copiedBlockPos != null && button == 1) { - clipboardHelper.setClipboardString(handle, + clipboardHelper.setClipboard(handle, "util.select.fromTo(" + copiedBlockPos.getX() + ", " + copiedBlockPos.getY() + ", " + copiedBlockPos.getZ() + ", " + hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ() + ")"); @@ -765,10 +765,10 @@ public class PonderUI extends NavigatableSimiScreen { } if (hasShiftDown()) - clipboardHelper.setClipboardString(handle, "util.select.position(" + hoveredBlockPos.getX() + ", " + clipboardHelper.setClipboard(handle, "util.select.position(" + hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ() + ")"); else - clipboardHelper.setClipboardString(handle, "util.grid.at(" + hoveredBlockPos.getX() + ", " + clipboardHelper.setClipboard(handle, "util.grid.at(" + hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ() + ")"); copiedBlockPos = hoveredBlockPos; return true; @@ -779,15 +779,15 @@ public class PonderUI extends NavigatableSimiScreen { @Override public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) { - GameSettings settings = Minecraft.getInstance().gameSettings; - int sCode = settings.keyBindBack.getKey() - .getKeyCode(); - int aCode = settings.keyBindLeft.getKey() - .getKeyCode(); - int dCode = settings.keyBindRight.getKey() - .getKeyCode(); - int qCode = settings.keyBindDrop.getKey() - .getKeyCode(); + GameSettings settings = Minecraft.getInstance().options; + int sCode = settings.keyDown.getKey() + .getValue(); + int aCode = settings.keyLeft.getKey() + .getValue(); + int dCode = settings.keyRight.getKey() + .getValue(); + int qCode = settings.keyDrop.getKey() + .getValue(); if (code == sCode) { replay(); @@ -822,12 +822,12 @@ public class PonderUI extends NavigatableSimiScreen { .getString(); return stack.getItem() - .getName() + .getDescription() .getString(); } public FontRenderer getFontRenderer() { - return textRenderer; + return font; } protected boolean isMouseOver(double mouseX, double mouseY, int x, int y, int w, int h) { @@ -839,7 +839,7 @@ public class PonderUI extends NavigatableSimiScreen { public static void renderSpeechBox(MatrixStack ms, int x, int y, int w, int h, boolean highlighted, Pointing pointing, boolean returnWithLocalTransform) { if (!returnWithLocalTransform) - ms.push(); + ms.pushPose(); int boxX = x; int boxY = y; @@ -895,20 +895,20 @@ public class PonderUI extends NavigatableSimiScreen { .withBounds(w, h) .render(ms); - ms.push(); + ms.pushPose(); ms.translate(divotX + divotRadius, divotY + divotRadius, 10); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(divotRotation)); + ms.mulPose(Vector3f.ZP.rotationDegrees(divotRotation)); ms.translate(-divotRadius, -divotRadius, 0); AllGuiTextures.SPEECH_TOOLTIP_BACKGROUND.draw(ms, 0, 0); AllGuiTextures.SPEECH_TOOLTIP_COLOR.draw(ms, 0, 0, c); - ms.pop(); + ms.popPose(); if (returnWithLocalTransform) { ms.translate(boxX, boxY, 0); return; } - ms.pop(); + ms.popPose(); } @@ -923,7 +923,7 @@ public class PonderUI extends NavigatableSimiScreen { @Override public boolean isEquivalentTo(NavigatableSimiScreen other) { if (other instanceof PonderUI) - return stack.isItemEqual(((PonderUI) other).stack); + return stack.sameItem(((PonderUI) other).stack); return super.isEquivalentTo(other); } @@ -937,10 +937,10 @@ public class PonderUI extends NavigatableSimiScreen { public static float getPartialTicks() { float renderPartialTicks = Minecraft.getInstance() - .getRenderPartialTicks(); + .getFrameTime(); - if (Minecraft.getInstance().currentScreen instanceof PonderUI) { - PonderUI ui = (PonderUI) Minecraft.getInstance().currentScreen; + if (Minecraft.getInstance().screen instanceof PonderUI) { + PonderUI ui = (PonderUI) Minecraft.getInstance().screen; if (ui.identifyMode) return ponderPartialTicksPaused; @@ -967,7 +967,7 @@ public class PonderUI extends NavigatableSimiScreen { public void drawRightAlignedString(FontRenderer fontRenderer, MatrixStack ms, String string, int x, int y, int color) { - fontRenderer.draw(ms, string, (float) (x - fontRenderer.getStringWidth(string)), (float) y, color); + fontRenderer.draw(ms, string, (float) (x - fontRenderer.width(string)), (float) y, color); } public boolean isComfyReadingEnabled() { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java index 83a8d7f46..aa659dc95 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java @@ -76,7 +76,7 @@ public class PonderWorld extends SchematicWorld { // ParticleManager.factories - ATs don't seem to like this one particleFactories = ObfuscationReflectionHelper.getPrivateValue(ParticleManager.class, - Minecraft.getInstance().particles, "field_178932_g"); + Minecraft.getInstance().particleEngine, "providers"); } public void createBackup() { @@ -84,8 +84,8 @@ public class PonderWorld extends SchematicWorld { originalTileEntities.clear(); blocks.forEach((k, v) -> originalBlocks.put(k, v)); tileEntities.forEach( - (k, v) -> originalTileEntities.put(k, TileEntity.createFromTag(blocks.get(k), v.write(new CompoundNBT())))); - entities.forEach(e -> EntityType.loadEntityUnchecked(e.serializeNBT(), this) + (k, v) -> originalTileEntities.put(k, TileEntity.loadStatic(blocks.get(k), v.save(new CompoundNBT())))); + entities.forEach(e -> EntityType.create(e.serializeNBT(), this) .ifPresent(originalEntities::add)); } @@ -97,12 +97,12 @@ public class PonderWorld extends SchematicWorld { renderedTileEntities.clear(); originalBlocks.forEach((k, v) -> blocks.put(k, v)); originalTileEntities.forEach((k, v) -> { - TileEntity te = TileEntity.createFromTag(originalBlocks.get(k), v.write(new CompoundNBT())); - onTEadded(te, te.getPos()); + TileEntity te = TileEntity.loadStatic(originalBlocks.get(k), v.save(new CompoundNBT())); + onTEadded(te, te.getBlockPos()); tileEntities.put(k, te); renderedTileEntities.add(te); }); - originalEntities.forEach(e -> EntityType.loadEntityUnchecked(e.serializeNBT(), this) + originalEntities.forEach(e -> EntityType.create(e.serializeNBT(), this) .ifPresent(entities::add)); particles.clearEffects(); fixControllerTileEntities(); @@ -113,9 +113,9 @@ public class PonderWorld extends SchematicWorld { if (originalBlocks.containsKey(p)) blocks.put(p, originalBlocks.get(p)); if (originalTileEntities.containsKey(p)) { - TileEntity te = TileEntity.createFromTag(originalBlocks.get(p), originalTileEntities.get(p) - .write(new CompoundNBT())); - onTEadded(te, te.getPos()); + TileEntity te = TileEntity.loadStatic(originalBlocks.get(p), originalTileEntities.get(p) + .save(new CompoundNBT())); + onTEadded(te, te.getBlockPos()); tileEntities.put(p, te); } }); @@ -136,7 +136,7 @@ public class PonderWorld extends SchematicWorld { } @Override - public int getLightLevel(LightType p_226658_1_, BlockPos p_226658_2_) { + public int getBrightness(LightType p_226658_1_, BlockPos p_226658_2_) { return overrideLight == -1 ? 15 : overrideLight; } @@ -151,46 +151,46 @@ public class PonderWorld extends SchematicWorld { @Override public BlockState getBlockState(BlockPos globalPos) { if (mask != null && !mask.test(globalPos.subtract(anchor))) - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); return super.getBlockState(globalPos); } @Override // For particle collision - public IBlockReader getExistingChunk(int p_225522_1_, int p_225522_2_) { + public IBlockReader getChunkForCollisions(int p_225522_1_, int p_225522_2_) { return this; } public void renderEntities(MatrixStack ms, SuperRenderTypeBuffer buffer, ActiveRenderInfo ari, float pt) { - Vector3d Vector3d = ari.getProjectedView(); - double d0 = Vector3d.getX(); - double d1 = Vector3d.getY(); - double d2 = Vector3d.getZ(); + Vector3d Vector3d = ari.getPosition(); + double d0 = Vector3d.x(); + double d1 = Vector3d.y(); + double d2 = Vector3d.z(); for (Entity entity : entities) { - if (entity.ticksExisted == 0) { - entity.lastTickPosX = entity.getX(); - entity.lastTickPosY = entity.getY(); - entity.lastTickPosZ = entity.getZ(); + if (entity.tickCount == 0) { + entity.xOld = entity.getX(); + entity.yOld = entity.getY(); + entity.zOld = entity.getZ(); } renderEntity(entity, d0, d1, d2, pt, ms, buffer); } - buffer.draw(RenderType.getEntitySolid(PlayerContainer.BLOCK_ATLAS_TEXTURE)); - buffer.draw(RenderType.getEntityCutout(PlayerContainer.BLOCK_ATLAS_TEXTURE)); - buffer.draw(RenderType.getEntityCutoutNoCull(PlayerContainer.BLOCK_ATLAS_TEXTURE)); - buffer.draw(RenderType.getEntitySmoothCutout(PlayerContainer.BLOCK_ATLAS_TEXTURE)); + buffer.draw(RenderType.entitySolid(PlayerContainer.BLOCK_ATLAS)); + buffer.draw(RenderType.entityCutout(PlayerContainer.BLOCK_ATLAS)); + buffer.draw(RenderType.entityCutoutNoCull(PlayerContainer.BLOCK_ATLAS)); + buffer.draw(RenderType.entitySmoothCutout(PlayerContainer.BLOCK_ATLAS)); } private void renderEntity(Entity entity, double x, double y, double z, float pt, MatrixStack ms, IRenderTypeBuffer buffer) { - double d0 = MathHelper.lerp((double) pt, entity.lastTickPosX, entity.getX()); - double d1 = MathHelper.lerp((double) pt, entity.lastTickPosY, entity.getY()); - double d2 = MathHelper.lerp((double) pt, entity.lastTickPosZ, entity.getZ()); - float f = MathHelper.lerp(pt, entity.prevRotationYaw, entity.rotationYaw); + double d0 = MathHelper.lerp((double) pt, entity.xOld, entity.getX()); + double d1 = MathHelper.lerp((double) pt, entity.yOld, entity.getY()); + double d2 = MathHelper.lerp((double) pt, entity.zOld, entity.getZ()); + float f = MathHelper.lerp(pt, entity.yRotO, entity.yRot); EntityRendererManager renderManager = Minecraft.getInstance() - .getRenderManager(); + .getEntityRenderDispatcher(); int light = renderManager.getRenderer(entity) - .getLight(entity, pt); + .getPackedLightCoords(entity, pt); renderManager.render(entity, d0 - x, d1 - y, d2 - z, f, pt, ms, buffer, light); } @@ -204,10 +204,10 @@ public class PonderWorld extends SchematicWorld { for (Iterator iterator = entities.iterator(); iterator.hasNext();) { Entity entity = iterator.next(); - entity.ticksExisted++; - entity.lastTickPosX = entity.getX(); - entity.lastTickPosY = entity.getY(); - entity.lastTickPosZ = entity.getZ(); + entity.tickCount++; + entity.xOld = entity.getX(); + entity.yOld = entity.getY(); + entity.zOld = entity.getZ(); entity.tick(); if (entity.getY() <= -.5f) @@ -224,7 +224,7 @@ public class PonderWorld extends SchematicWorld { } @Override - public void addOptionalParticle(IParticleData data, double x, double y, double z, double mx, double my, double mz) { + public void addAlwaysVisibleParticle(IParticleData data, double x, double y, double z, double mx, double my, double mz) { addParticle(data, x, y, z, mx, my, mz); } @@ -235,12 +235,12 @@ public class PonderWorld extends SchematicWorld { ResourceLocation key = ForgeRegistries.PARTICLE_TYPES.getKey(data.getType()); IParticleFactory iparticlefactory = (IParticleFactory) particleFactories.get(key); return iparticlefactory == null ? null - : iparticlefactory.makeParticle(data, asClientWorld.getValue(), x, y, z, mx, my, mz); + : iparticlefactory.createParticle(data, asClientWorld.get(), x, y, z, mx, my, mz); } @Override - public boolean setBlockState(BlockPos pos, BlockState arg1, int arg2) { - return super.setBlockState(pos, arg1, arg2); + public boolean setBlock(BlockPos pos, BlockState arg1, int arg2) { + return super.setBlock(pos, arg1, arg2); } public void addParticle(Particle p) { @@ -263,9 +263,9 @@ public class PonderWorld extends SchematicWorld { BeltTileEntity beltTileEntity = (BeltTileEntity) tileEntity; if (!beltTileEntity.isController()) continue; - BlockPos controllerPos = tileEntity.getPos(); + BlockPos controllerPos = tileEntity.getBlockPos(); for (BlockPos blockPos : BeltBlock.getBeltChain(this, controllerPos)) { - TileEntity tileEntity2 = getTileEntity(blockPos); + TileEntity tileEntity2 = getBlockEntity(blockPos); if (!(tileEntity2 instanceof BeltTileEntity)) continue; BeltTileEntity belt2 = (BeltTileEntity) tileEntity2; @@ -275,14 +275,14 @@ public class PonderWorld extends SchematicWorld { if (tileEntity instanceof FluidTankTileEntity) { FluidTankTileEntity fluidTankTileEntity = (FluidTankTileEntity) tileEntity; BlockPos lastKnown = fluidTankTileEntity.getLastKnownPos(); - BlockPos current = fluidTankTileEntity.getPos(); + BlockPos current = fluidTankTileEntity.getBlockPos(); if (lastKnown == null || current == null) continue; if (fluidTankTileEntity.isController()) continue; if (!lastKnown.equals(current)) { BlockPos newControllerPos = fluidTankTileEntity.getController() - .add(current.subtract(lastKnown)); + .offset(current.subtract(lastKnown)); fluidTankTileEntity.setController(newControllerPos); } } @@ -305,7 +305,7 @@ public class PonderWorld extends SchematicWorld { if (voxelshape.isEmpty()) return; - AxisAlignedBB bb = voxelshape.getBoundingBox(); + AxisAlignedBB bb = voxelshape.bounds(); double d1 = Math.min(1.0D, bb.maxX - bb.minX); double d2 = Math.min(1.0D, bb.maxY - bb.minY); double d3 = Math.min(1.0D, bb.maxZ - bb.minZ); @@ -335,22 +335,22 @@ public class PonderWorld extends SchematicWorld { } @Override - public boolean isBlockLoaded(BlockPos pos) { + public boolean hasChunkAt(BlockPos pos) { return true; // fix particle lighting } @Override - public boolean chunkExists(int x, int y) { + public boolean hasChunk(int x, int y) { return true; // fix particle lighting } @Override - public boolean isBlockPresent(BlockPos pos) { + public boolean isLoaded(BlockPos pos) { return true; // fix particle lighting } @Override - public boolean isPlayerWithin(double p_217358_1_, double p_217358_3_, double p_217358_5_, double p_217358_7_) { + public boolean hasNearbyAlivePlayer(double p_217358_1_, double p_217358_3_, double p_217358_5_, double p_217358_7_) { return true; // always enable spawner animations } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderWorldParticles.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderWorldParticles.java index 6fad6cdb3..79ce37930 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderWorldParticles.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderWorldParticles.java @@ -61,9 +61,9 @@ public class PonderWorldParticles { public void renderParticles(MatrixStack ms, IRenderTypeBuffer buffer, ActiveRenderInfo renderInfo, float pt) { Minecraft mc = Minecraft.getInstance(); - LightTexture lightTexture = mc.gameRenderer.getLightmapTextureManager(); + LightTexture lightTexture = mc.gameRenderer.lightTexture(); - lightTexture.enableLightmap(); + lightTexture.turnOnLightLayer(); Runnable enable = () -> { RenderSystem.enableAlphaTest(); RenderSystem.defaultAlphaFunc(); @@ -71,8 +71,8 @@ public class PonderWorldParticles { RenderSystem.enableFog(); }; RenderSystem.pushMatrix(); - RenderSystem.multMatrix(ms.peek() - .getModel()); + RenderSystem.multMatrix(ms.last() + .pose()); for (IParticleRenderType iparticlerendertype : this.byType.keySet()) { if (iparticlerendertype == IParticleRenderType.NO_RENDER) @@ -82,13 +82,13 @@ public class PonderWorldParticles { if (iterable != null) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); - iparticlerendertype.beginRender(bufferbuilder, mc.textureManager); + BufferBuilder bufferbuilder = tessellator.getBuilder(); + iparticlerendertype.begin(bufferbuilder, mc.textureManager); for (Particle particle : iterable) - particle.buildGeometry(bufferbuilder, renderInfo, pt); + particle.render(bufferbuilder, renderInfo, pt); - iparticlerendertype.finishRender(tessellator); + iparticlerendertype.end(tessellator); } } @@ -97,7 +97,7 @@ public class PonderWorldParticles { RenderSystem.depthFunc(515); RenderSystem.disableBlend(); RenderSystem.defaultAlphaFunc(); - lightTexture.disableLightmap(); + lightTexture.turnOffLightLayer(); RenderSystem.disableFog(); } 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 ed7868ae3..dbecedced 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java @@ -82,6 +82,8 @@ import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3i; import net.minecraft.world.World; +import com.simibubi.create.foundation.ponder.elements.TextWindowElement.Builder; + /** * Enqueue instructions to the schedule via this object's methods. */ @@ -264,7 +266,7 @@ public class SceneBuilder { private void rotationIndicator(BlockPos pos, boolean direction) { addInstruction(scene -> { BlockState blockState = scene.world.getBlockState(pos); - TileEntity tileEntity = scene.world.getTileEntity(pos); + TileEntity tileEntity = scene.world.getBlockEntity(pos); if (!(blockState.getBlock() instanceof KineticBlock)) return; @@ -564,7 +566,7 @@ public class SceneBuilder { } public void destroyBlock(BlockPos pos) { - setBlock(pos, Blocks.AIR.getDefaultState(), true); + setBlock(pos, Blocks.AIR.defaultBlockState(), true); } public void setBlock(BlockPos pos, BlockState state, boolean spawnParticles) { @@ -581,7 +583,7 @@ public class SceneBuilder { public void cycleBlockProperty(BlockPos pos, Property property) { modifyBlocks(scene.getSceneBuildingUtil().select.position(pos), - s -> s.contains(property) ? s.cycle(property) : s, false); + s -> s.hasProperty(property) ? s.cycle(property) : s, false); } public void modifyBlocks(Selection selection, UnaryOperator stateFunc, boolean spawnParticles) { @@ -590,11 +592,11 @@ public class SceneBuilder { public void toggleRedstonePower(Selection selection) { modifyBlocks(selection, s -> { - if (s.contains(BlockStateProperties.POWER_0_15)) - s = s.with(BlockStateProperties.POWER_0_15, s.get(BlockStateProperties.POWER_0_15) == 0 ? 15 : 0); - if (s.contains(BlockStateProperties.POWERED)) + if (s.hasProperty(BlockStateProperties.POWER)) + s = s.setValue(BlockStateProperties.POWER, s.getValue(BlockStateProperties.POWER) == 0 ? 15 : 0); + if (s.hasProperty(BlockStateProperties.POWERED)) s = s.cycle(BlockStateProperties.POWERED); - if (s.contains(RedstoneTorchBlock.LIT)) + if (s.hasProperty(RedstoneTorchBlock.LIT)) s = s.cycle(RedstoneTorchBlock.LIT); return s; }, false); @@ -607,7 +609,7 @@ public class SceneBuilder { public void modifyEntitiesInside(Class entityClass, Selection area, Consumer entityCallBack) { addInstruction(scene -> scene.forEachWorldEntity(entityClass, e -> { - if (area.test(e.getBlockPos())) + if (area.test(e.blockPosition())) entityCallBack.accept(e); })); } @@ -628,7 +630,7 @@ public class SceneBuilder { EntityElement handle = new EntityElement(entity); scene.addElement(handle); scene.linkElement(handle, link); - world.addEntity(entity); + world.addFreshEntity(entity); }); return link; } @@ -636,7 +638,7 @@ public class SceneBuilder { public ElementLink createItemEntity(Vector3d location, Vector3d motion, ItemStack stack) { return createEntity(world -> { ItemEntity itemEntity = new ItemEntity(world, location.x, location.y, location.z, stack); - itemEntity.setMotion(motion); + itemEntity.setDeltaMovement(motion); return itemEntity; }); } @@ -649,7 +651,7 @@ public class SceneBuilder { public void createItemOnBeltLike(BlockPos location, Direction insertionSide, ItemStack stack) { addInstruction(scene -> { PonderWorld world = scene.getWorld(); - TileEntity tileEntity = world.getTileEntity(location); + TileEntity tileEntity = world.getBlockEntity(location); if (!(tileEntity instanceof SmartTileEntity)) return; SmartTileEntity beltTileEntity = (SmartTileEntity) tileEntity; @@ -658,7 +660,7 @@ public class SceneBuilder { return; behaviour.handleInsertion(stack, insertionSide.getOpposite(), false); }); - flapFunnel(location.up(), true); + flapFunnel(location.above(), true); } public ElementLink createItemOnBelt(BlockPos beltLocation, Direction insertionSide, @@ -666,7 +668,7 @@ public class SceneBuilder { ElementLink link = new ElementLink<>(BeltItemElement.class); addInstruction(scene -> { PonderWorld world = scene.getWorld(); - TileEntity tileEntity = world.getTileEntity(beltLocation); + TileEntity tileEntity = world.getBlockEntity(beltLocation); if (!(tileEntity instanceof BeltTileEntity)) return; @@ -687,14 +689,14 @@ public class SceneBuilder { return TransportedResult.doNothing(); }); }); - flapFunnel(beltLocation.up(), true); + flapFunnel(beltLocation.above(), true); return link; } public void removeItemsFromBelt(BlockPos beltLocation) { addInstruction(scene -> { PonderWorld world = scene.getWorld(); - TileEntity tileEntity = world.getTileEntity(beltLocation); + TileEntity tileEntity = world.getBlockEntity(beltLocation); if (!(tileEntity instanceof SmartTileEntity)) return; SmartTileEntity beltTileEntity = (SmartTileEntity) tileEntity; @@ -757,7 +759,7 @@ public class SceneBuilder { public void modifyTileEntity(BlockPos position, Class teType, Consumer consumer) { addInstruction(scene -> { - TileEntity tileEntity = scene.world.getTileEntity(position); + TileEntity tileEntity = scene.world.getBlockEntity(position); if (teType.isInstance(tileEntity)) consumer.accept(teType.cast(tileEntity)); }); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuildingUtil.java b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuildingUtil.java index a7eed2600..3af92af68 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuildingUtil.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuildingUtil.java @@ -61,7 +61,7 @@ public class SceneBuildingUtil { } public Vector3d blockSurface(BlockPos pos, Direction face, float margin) { - return centerOf(pos).add(Vector3d.of(face.getDirectionVec()) + return centerOf(pos).add(Vector3d.atLowerCornerOf(face.getNormal()) .scale(.5f + margin)); } @@ -94,7 +94,7 @@ public class SceneBuildingUtil { } public Selection column(int x, int z) { - return cuboid(new BlockPos(x, 1, z), new Vector3i(0, sceneBounds.getYSize(), 0)); + return cuboid(new BlockPos(x, 1, z), new Vector3i(0, sceneBounds.getYSpan(), 0)); } public Selection layer(int y) { @@ -102,16 +102,16 @@ public class SceneBuildingUtil { } public Selection layersFrom(int y) { - return layers(y, sceneBounds.getYSize() - y); + return layers(y, sceneBounds.getYSpan() - y); } public Selection layers(int y, int height) { - return cuboid(new BlockPos(0, y, 0), new Vector3i(sceneBounds.getXSize() - 1, - Math.min(sceneBounds.getYSize() - y, height) - 1, sceneBounds.getZSize() - 1)); + return cuboid(new BlockPos(0, y, 0), new Vector3i(sceneBounds.getXSpan() - 1, + Math.min(sceneBounds.getYSpan() - y, height) - 1, sceneBounds.getZSpan() - 1)); } public Selection cuboid(BlockPos origin, Vector3i size) { - return Selection.of(new MutableBoundingBox(origin, origin.add(size))); + return Selection.of(new MutableBoundingBox(origin, origin.offset(size))); } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/Selection.java b/src/main/java/com/simibubi/create/foundation/ponder/Selection.java index 4541f1cbe..f0885bce1 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/Selection.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/Selection.java @@ -56,14 +56,14 @@ public abstract class Selection implements Predicate { @Override public Selection add(Selection other) { - other.forEach(p -> posSet.add(p.toImmutable())); + other.forEach(p -> posSet.add(p.immutable())); center = null; return this; } @Override public Selection substract(Selection other) { - other.forEach(p -> posSet.remove(p.toImmutable())); + other.forEach(p -> posSet.remove(p.immutable())); center = null; return this; } @@ -88,7 +88,7 @@ public abstract class Selection implements Predicate { if (posSet.isEmpty()) return center; for (BlockPos blockPos : posSet) - center = center.add(Vector3d.of(blockPos)); + center = center.add(Vector3d.atLowerCornerOf(blockPos)); center = center.scale(1f / posSet.size()); return center.add(new Vector3d(.5, .5, .5)); } @@ -112,7 +112,7 @@ public abstract class Selection implements Predicate { @Override public boolean test(BlockPos t) { - return bb.isVecInside(t); + return bb.isInside(t); } @Override @@ -127,7 +127,7 @@ public abstract class Selection implements Predicate { @Override public void forEach(Consumer callback) { - BlockPos.stream(bb) + BlockPos.betweenClosedStream(bb) .forEach(callback); } @@ -142,7 +142,7 @@ public abstract class Selection implements Predicate { } private AxisAlignedBB getAABB() { - return new AxisAlignedBB(bb.minX, bb.minY, bb.minZ, bb.maxX + 1, bb.maxY + 1, bb.maxZ + 1); + return new AxisAlignedBB(bb.x0, bb.y0, bb.z0, bb.x1 + 1, bb.y1 + 1, bb.z1 + 1); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/ArmScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/ArmScenes.java index af26370f7..4ba0e1116 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/ArmScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/ArmScenes.java @@ -56,8 +56,8 @@ public class ArmScenes { scene.overlay.showControls(new InputWindowElement(depotSurface, Pointing.RIGHT).rightClick() .withItem(armItem), 50); scene.idle(7); - AxisAlignedBB depotBounds = AllShapes.DEPOT.getBoundingBox(); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.offset(4, 2, 1), 400); + AxisAlignedBB depotBounds = AllShapes.DEPOT.bounds(); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.move(4, 2, 1), 400); scene.overlay.showText(70) .attachKeyFrame() @@ -74,11 +74,11 @@ public class ArmScenes { scene.overlay.showControls(input, 20); scene.idle(7); Object second = new Object(); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, second, depotBounds.offset(0, 2, 1), 100); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, second, depotBounds.move(0, 2, 1), 100); scene.idle(25); scene.overlay.showControls(input, 30); scene.idle(7); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, second, depotBounds.offset(0, 2, 1), 280); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, second, depotBounds.move(0, 2, 1), 280); scene.overlay.showText(70) .colored(PonderPalette.OUTPUT) .text("Right-Click again to toggle between Input (Blue) and Output (Orange)") @@ -88,7 +88,7 @@ public class ArmScenes { scene.idle(80); scene.world.showSection(util.select.position(1, 1, 0), Direction.DOWN); scene.idle(15); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.offset(1, 1, 0), 43); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.move(1, 1, 0), 43); scene.overlay.showText(50) .colored(PonderPalette.WHITE) @@ -138,15 +138,15 @@ public class ArmScenes { scene.world.showSection(util.select.position(4, 1, 2), Direction.DOWN); scene.idle(5); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, new Object(), depotBounds.offset(0, 2, 1), 60); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, new Object(), depotBounds.move(0, 2, 1), 60); scene.idle(5); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.offset(4, 2, 1), 60); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.move(4, 2, 1), 60); scene.idle(5); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, new Object(), depotBounds.offset(1, 1, 0), 60); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, new Object(), depotBounds.move(1, 1, 0), 60); scene.idle(5); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.offset(1, 3, 4), 60); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.move(1, 3, 4), 60); scene.idle(5); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.offset(4, 1, 2), 60); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.move(4, 1, 2), 60); scene.idle(5); scene.overlay.showText(80) @@ -191,8 +191,8 @@ public class ArmScenes { AxisAlignedBB chestBounds = new AxisAlignedBB(1 / 16f, 0, 1 / 16f, 15 / 16f, 14 / 16f, 15 / 16f); AxisAlignedBB funnelBounds = new AxisAlignedBB(0, 0, 8 / 16f, 16 / 16f, 16 / 16f, 16 / 16f); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, in, chestBounds.offset(4, 2, 3), 120); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, out, chestBounds.offset(0, 2, 3), 120); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, in, chestBounds.move(4, 2, 3), 120); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, out, chestBounds.move(0, 2, 3), 120); scene.overlay.showText(80) .attachKeyFrame() .text("However, not every type of Inventory can be interacted with directly") @@ -206,9 +206,9 @@ public class ArmScenes { scene.world.showSection(util.select.position(0, 2, 2), Direction.SOUTH); scene.idle(10); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, depotBounds.offset(4, 1, 2), 80); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, depotBounds.move(4, 1, 2), 80); scene.idle(5); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, funnelBounds.offset(0, 2, 2), 80); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, funnelBounds.move(0, 2, 2), 80); scene.idle(5); scene.overlay.showText(60) @@ -381,7 +381,7 @@ public class ArmScenes { public static void modes(SceneBuilder scene, SceneBuildingUtil util) { scene.title("mechanical_arm_modes", "Distribution modes of the Mechanical Arm"); scene.configureBasePlate(0, 1, 5); - scene.world.setBlock(util.grid.at(3, 1, 0), Blocks.BARRIER.getDefaultState(), false); + scene.world.setBlock(util.grid.at(3, 1, 0), Blocks.BARRIER.defaultBlockState(), false); scene.world.showSection(util.select.layer(0), Direction.UP); scene.idle(5); @@ -392,20 +392,20 @@ public class ArmScenes { scene.world.showSection(util.select.fromTo(1, 1, 1, 5, 1, 2), Direction.SOUTH); scene.idle(10); - AxisAlignedBB depotBox = AllShapes.DEPOT.getBoundingBox(); + AxisAlignedBB depotBox = AllShapes.DEPOT.bounds(); AxisAlignedBB beltBox = depotBox.contract(0, -3 / 16f, 0) - .grow(1, 0, 0); + .inflate(1, 0, 0); BlockPos depotPos = util.grid.at(1, 1, 4); BlockPos armPos = util.grid.at(3, 1, 4); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, depotBox, depotBox.offset(1, 1, 4), 60); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, depotBox, depotBox.move(1, 1, 4), 60); scene.overlay.showText(30) .text("Input") .pointAt(util.vector.blockSurface(depotPos, Direction.WEST)) .placeNearTarget() .colored(PonderPalette.INPUT); scene.idle(40); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, depotBox, beltBox.offset(2, 1, 2), 40); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, depotBox, beltBox.move(2, 1, 2), 40); scene.overlay.showText(40) .text("Outputs") .pointAt(util.vector.blockSurface(util.grid.at(1, 1, 2), Direction.WEST)) @@ -468,13 +468,13 @@ public class ArmScenes { if (i == 12) { scene.world.moveSection(blockage, util.vector.of(-1, 0, 0), 10); - scene.world.setBlock(util.grid.at(3, 1, 0), Blocks.BARRIER.getDefaultState(), false); + scene.world.setBlock(util.grid.at(3, 1, 0), Blocks.BARRIER.defaultBlockState(), false); } int index = i % 3; if (i == 13) { - scene.world.setBlock(util.grid.at(2, 1, 0), Blocks.BARRIER.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 1, 0), Blocks.BARRIER.defaultBlockState(), false); ElementLink blockage2 = scene.world.showIndependentSection(util.select.position(4, 1, 0), Direction.UP); scene.world.moveSection(blockage2, util.vector.of(-2, 0, 0), 0); @@ -510,7 +510,7 @@ public class ArmScenes { .colored(PonderPalette.RED); scene.idle(40); scene.world.moveSection(blockage, util.vector.of(1, 0, 0), 10); - scene.world.setBlock(util.grid.at(3, 1, 0), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(3, 1, 0), Blocks.AIR.defaultBlockState(), false); scene.idle(50); scene.world.multiplyKineticSpeed(util.select.fromTo(1, 1, 1, 5, 0, 3), 2); } @@ -557,7 +557,7 @@ public class ArmScenes { scene.overlay.showText(60) .colored(PonderPalette.RED) .attachKeyFrame() - .pointAt(util.vector.topOf(armPos.up())) + .pointAt(util.vector.topOf(armPos.above())) .placeNearTarget() .text("When powered by Redstone, Mechanical Arms will not activate"); scene.idle(70); @@ -582,7 +582,7 @@ public class ArmScenes { scene.world.toggleRedstonePower(redstone); scene.effects.indicateRedstone(leverPos); scene.overlay.showText(60) - .pointAt(util.vector.topOf(armPos.up())) + .pointAt(util.vector.topOf(armPos.above())) .placeNearTarget() .text("Before stopping, it will finish any started cycles"); } @@ -593,7 +593,7 @@ public class ArmScenes { scene.overlay.showText(100) .colored(PonderPalette.GREEN) .attachKeyFrame() - .pointAt(util.vector.topOf(armPos.up())) + .pointAt(util.vector.topOf(armPos.above())) .placeNearTarget() .text("Thus, a negative pulse can be used to trigger exactly one activation cycle"); } 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 34d878e95..394241ae8 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 @@ -31,7 +31,7 @@ public class BearingScenes { 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); + .setValue(SailBlock.FACING, Direction.NORTH), false); scene.idle(5); Selection kinetics = util.select.fromTo(3, 1, 1, 4, 1, 4); Selection largeCog = util.select.position(3, 2, 2); @@ -56,35 +56,35 @@ public class BearingScenes { scene.idle(10); for (Direction d : Iterate.directions) if (d.getAxis() != Axis.Z) - scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.offset(d, 1), anchorPos.offset(d, 2)), + scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.relative(d, 1), anchorPos.relative(d, 2)), d.getOpposite(), structure); scene.idle(10); - scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.up() + scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.above() .east(), - anchorPos.up(3) + anchorPos.above(3) .east()), Direction.WEST, structure); - scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.down() + scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.below() .west(), - anchorPos.down(3) + anchorPos.below(3) .west()), Direction.EAST, structure); scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.east() - .down(), + .below(), anchorPos.east(3) - .down()), + .below()), Direction.UP, structure); scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.west() - .up(), + .above(), anchorPos.west(3) - .up()), + .above()), Direction.DOWN, structure); scene.idle(5); for (Direction d : Iterate.directions) if (d.getAxis() != Axis.Z) - scene.effects.superGlue(anchorPos.offset(d, 1), d.getOpposite(), false); + scene.effects.superGlue(anchorPos.relative(d, 1), d.getOpposite(), false); scene.idle(10); scene.overlay.showText(60) @@ -166,7 +166,7 @@ public class BearingScenes { scene.world.showSection(util.select.position(bearingPos), Direction.DOWN); scene.idle(10); ElementLink contraption = - scene.world.showIndependentSection(util.select.position(bearingPos.up()), Direction.DOWN); + scene.world.showIndependentSection(util.select.position(bearingPos.above()), Direction.DOWN); scene.idle(10); scene.world.showSectionAndMerge(util.select.fromTo(3, 2, 2, 3, 3, 1), Direction.SOUTH, contraption); scene.world.showSectionAndMerge(util.select.fromTo(3, 2, 4, 3, 3, 5), Direction.NORTH, contraption); @@ -177,8 +177,8 @@ public class BearingScenes { scene.world.showSectionAndMerge(util.select.position(2, 1, 5), Direction.EAST, contraption); scene.world.showSectionAndMerge(util.select.position(3, 3, 3), Direction.DOWN, contraption); scene.idle(5); - scene.effects.superGlue(bearingPos.up(), Direction.SOUTH, true); - scene.effects.superGlue(bearingPos.up(), Direction.NORTH, true); + scene.effects.superGlue(bearingPos.above(), Direction.SOUTH, true); + scene.effects.superGlue(bearingPos.above(), Direction.NORTH, true); scene.idle(5); scene.effects.superGlue(util.grid.at(3, 1, 5), Direction.UP, true); scene.idle(5); @@ -226,7 +226,7 @@ public class BearingScenes { .add(cog4); BlockPos bearingPos = util.grid.at(3, 2, 3); - scene.overlay.showSelectionWithText(util.select.position(bearingPos.up()), 60) + scene.overlay.showSelectionWithText(util.select.position(bearingPos.above()), 60) .colored(PonderPalette.GREEN) .pointAt(util.vector.blockSurface(bearingPos, Direction.WEST)) .placeNearTarget() @@ -234,7 +234,7 @@ public class BearingScenes { .text("Mechanical Bearings attach to the block in front of them"); scene.idle(50); - ElementLink plank = scene.world.showIndependentSection(util.select.position(bearingPos.up() + ElementLink plank = scene.world.showIndependentSection(util.select.position(bearingPos.above() .east() .north()), Direction.DOWN); scene.world.moveSection(plank, util.vector.of(-1, 0, 1), 0); @@ -244,12 +244,12 @@ public class BearingScenes { scene.world.setKineticSpeed(cog2, 8); scene.world.setKineticSpeed(cog3, -16); scene.world.setKineticSpeed(cog4, 16); - scene.effects.rotationSpeedIndicator(bearingPos.down()); + scene.effects.rotationSpeedIndicator(bearingPos.below()); scene.world.rotateBearing(bearingPos, 360, 37 * 2); scene.world.rotateSection(plank, 0, 360, 0, 37 * 2); scene.overlay.showText(80) - .pointAt(util.vector.topOf(bearingPos.up())) + .pointAt(util.vector.topOf(bearingPos.above())) .placeNearTarget() .attachKeyFrame() .text("Upon receiving Rotational Force, it will assemble it into a Rotating Contraption"); @@ -273,12 +273,12 @@ public class BearingScenes { scene.world.setKineticSpeed(cog2, 8); scene.world.setKineticSpeed(cog3, -16); scene.world.setKineticSpeed(cog4, 16); - scene.effects.rotationSpeedIndicator(bearingPos.down()); + scene.effects.rotationSpeedIndicator(bearingPos.below()); scene.world.rotateBearing(bearingPos, 360 * 2, 37 * 4); scene.world.rotateSection(contraption, 0, 360 * 2, 0, 37 * 4); scene.overlay.showText(120) - .pointAt(util.vector.topOf(bearingPos.up())) + .pointAt(util.vector.topOf(bearingPos.above())) .placeNearTarget() .attachKeyFrame() .sharedText("movement_anchors"); @@ -329,7 +329,7 @@ public class BearingScenes { scene.world.rotateSection(contraption, 0, 35, 0, 0); scene.world.rotateBearing(bearingPos, 35, 0); - Vector3d target = util.vector.topOf(bearingPos.down()); + Vector3d target = util.vector.topOf(bearingPos.below()); scene.overlay.showLine(PonderPalette.RED, target.add(-2.5, 0, 3.5), target, 50); scene.overlay.showLine(PonderPalette.GREEN, target.add(0, 0, 4.5), target, 50); @@ -606,16 +606,16 @@ public class BearingScenes { scene.world.showSection(util.select.position(bearingPos), Direction.DOWN); scene.idle(5); ElementLink plank = - scene.world.showIndependentSection(util.select.position(bearingPos.up()), Direction.DOWN); + scene.world.showIndependentSection(util.select.position(bearingPos.above()), Direction.DOWN); scene.idle(10); for (int i = 0; i < 3; i++) { for (Direction d : Iterate.horizontalDirections) { - BlockPos location = bearingPos.up(i + 1) - .offset(d); + BlockPos location = bearingPos.above(i + 1) + .relative(d); if (frame) scene.world.modifyBlock(location, s -> AllBlocks.SAIL_FRAME.getDefaultState() - .with(SailBlock.FACING, s.get(SailBlock.FACING)), false); + .setValue(SailBlock.FACING, s.getValue(SailBlock.FACING)), false); scene.world.showSectionAndMerge(util.select.position(location), d.getOpposite(), plank); scene.idle(2); } @@ -628,7 +628,7 @@ public class BearingScenes { .attachKeyFrame(); scene.idle(80); - scene.overlay.showSelectionWithText(util.select.position(bearingPos.up()), 80) + scene.overlay.showSelectionWithText(util.select.position(bearingPos.above()), 80) .colored(PonderPalette.GREEN) .text("They will attach to blocks and each other without the need of Super Glue or Chassis Blocks") .attachKeyFrame() @@ -650,7 +650,7 @@ public class BearingScenes { scene.overlay.showControls(input, 30); scene.idle(7); scene.world.setBlock(util.grid.at(2, 3, 1), AllBlocks.DYED_SAILS.get(DyeColor.BLUE).getDefaultState() - .with(SailBlock.FACING, Direction.WEST), false); + .setValue(SailBlock.FACING, Direction.WEST), false); scene.idle(10); scene.overlay.showText(40) .colored(PonderPalette.BLUE) @@ -663,7 +663,7 @@ public class BearingScenes { scene.idle(7); scene.world.replaceBlocks(util.select.fromTo(2, 2, 1, 2, 4, 1), AllBlocks.DYED_SAILS.get(DyeColor.BLUE).getDefaultState() - .with(SailBlock.FACING, Direction.WEST), + .setValue(SailBlock.FACING, Direction.WEST), false); scene.idle(20); @@ -678,7 +678,7 @@ public class BearingScenes { scene.overlay.showControls(input, 30); scene.idle(7); scene.world.setBlock(util.grid.at(3, 3, 2), AllBlocks.SAIL_FRAME.getDefaultState() - .with(SailBlock.FACING, Direction.NORTH), false); + .setValue(SailBlock.FACING, Direction.NORTH), false); scene.idle(10); scene.overlay.showText(40) .text("Right-Click with Shears to turn them back into frames") @@ -689,7 +689,7 @@ public class BearingScenes { scene.overlay.showControls(input, 30); scene.idle(7); scene.world.replaceBlocks(util.select.fromTo(3, 2, 2, 3, 4, 2), AllBlocks.SAIL_FRAME.getDefaultState() - .with(SailBlock.FACING, Direction.NORTH), false); + .setValue(SailBlock.FACING, Direction.NORTH), false); scene.idle(20); } 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 a2d45e769..aabb1480d 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 @@ -61,15 +61,15 @@ public class BeltScenes { Vector3d backEndCenter = util.vector.centerOf(backEnd); AxisAlignedBB connectBB = new AxisAlignedBB(backEndCenter, backEndCenter); AxisAlignedBB shaftBB = AllBlocks.SHAFT.getDefaultState() - .with(ShaftBlock.AXIS, Axis.Z) + .setValue(ShaftBlock.AXIS, Axis.Z) .getShape(null, null) - .getBoundingBox(); + .bounds(); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(backEnd), Pointing.DOWN).rightClick() .withItem(beltItem), 57); scene.idle(7); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, backEnd, shaftBB.offset(backEnd), 42); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, backEnd, shaftBB.move(backEnd), 42); scene.overlay.chaseBoundingBoxOutline(PonderPalette.BLACK, backEndCenter, connectBB, 50); scene.idle(20); @@ -77,8 +77,8 @@ public class BeltScenes { .withItem(beltItem), 37); scene.idle(7); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, frontEnd, shaftBB.offset(frontEnd), 17); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.BLACK, backEndCenter, connectBB.expand(-4, 0, 0), 20); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, frontEnd, shaftBB.move(frontEnd), 17); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.BLACK, backEndCenter, connectBB.expandTowards(-4, 0, 0), 20); scene.idle(20); scene.world.moveSection(shafts, util.vector.of(0, -2, 0), 0); @@ -96,7 +96,7 @@ public class BeltScenes { scene.overlay.showControls(new InputWindowElement(falseSelection, Pointing.DOWN).rightClick() .withItem(beltItem), 37); scene.idle(7); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, backEnd, shaftBB.offset(backEnd.south(1)), 50); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, backEnd, shaftBB.move(backEnd.south(1)), 50); scene.overlay.showText(80) .colored(PonderPalette.RED) @@ -115,7 +115,7 @@ public class BeltScenes { scene.overlay.showControls(new InputWindowElement(util.vector.topOf(shaftLocation), Pointing.DOWN).rightClick() .withItem(AllBlocks.SHAFT.asStack()), 50); scene.idle(7); - scene.world.modifyBlock(shaftLocation, s -> s.with(BeltBlock.PART, BeltPart.PULLEY), true); + scene.world.modifyBlock(shaftLocation, s -> s.setValue(BeltBlock.PART, BeltPart.PULLEY), true); scene.idle(10); scene.overlay.showText(43) @@ -145,7 +145,7 @@ public class BeltScenes { scene.overlay.showControls(new InputWindowElement(util.vector.topOf(shaftLocation), Pointing.DOWN).rightClick() .withWrench(), 50); scene.idle(7); - scene.world.modifyBlock(shaftLocation, s -> s.with(BeltBlock.PART, BeltPart.MIDDLE), true); + scene.world.modifyBlock(shaftLocation, s -> s.setValue(BeltBlock.PART, BeltPart.MIDDLE), true); scene.idle(10); scene.overlay.showText(50) .text("Added shafts can be removed using the wrench") @@ -412,13 +412,13 @@ public class BeltScenes { scene.overlay.showControls(new InputWindowElement(util.vector.topOf(beltPos), Pointing.DOWN).rightClick() .withItem(brassCasingItem), 20); scene.idle(7); - scene.world.modifyBlock(beltPos, s -> s.with(BeltBlock.CASING, true), true); + scene.world.modifyBlock(beltPos, s -> s.setValue(BeltBlock.CASING, true), true); scene.idle(20); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(beltPos2), Pointing.DOWN).rightClick() .withItem(andesiteCasingItem), 20); scene.idle(7); - scene.world.modifyBlock(beltPos2, s -> s.with(BeltBlock.CASING, true), true); + scene.world.modifyBlock(beltPos2, s -> s.setValue(BeltBlock.CASING, true), true); scene.world.modifyTileNBT(util.select.position(beltPos2), BeltTileEntity.class, nbt -> { NBTHelper.writeEnum(nbt, "Casing", BeltTileEntity.CasingType.ANDESITE); }); @@ -429,7 +429,7 @@ public class BeltScenes { .withItem(brassCasingItem), 20); scene.idle(7); - scene.world.modifyBlock(beltPos3, s -> s.with(BeltBlock.CASING, true), true); + scene.world.modifyBlock(beltPos3, s -> s.setValue(BeltBlock.CASING, true), true); scene.idle(20); scene.overlay.showText(80) @@ -446,7 +446,7 @@ public class BeltScenes { brassBelts.add(beltPos.south(z)); for (int x = 1; x <= 3; x++) brassBelts.add(beltPos3.east(x) - .down(x)); + .below(x)); for (int x = 1; x <= 3; x++) andesiteBelts.add(beltPos2.east(x)); @@ -455,14 +455,14 @@ public class BeltScenes { for (BlockPos pos : andesiteBelts) { scene.idle(4); - scene.world.modifyBlock(pos, s -> s.with(BeltBlock.CASING, true), true); + scene.world.modifyBlock(pos, s -> s.setValue(BeltBlock.CASING, true), true); scene.world.modifyTileNBT(util.select.position(pos), BeltTileEntity.class, nbt -> { NBTHelper.writeEnum(nbt, "Casing", BeltTileEntity.CasingType.ANDESITE); }); } for (BlockPos pos : brassBelts) { scene.idle(4); - scene.world.modifyBlock(pos, s -> s.with(BeltBlock.CASING, true), true); + scene.world.modifyBlock(pos, s -> s.setValue(BeltBlock.CASING, true), true); } scene.idle(30); scene.addKeyframe(); @@ -471,7 +471,7 @@ public class BeltScenes { .showControls(new InputWindowElement(util.vector.topOf(beltPos.south()), Pointing.DOWN).rightClick() .withWrench(), 40); scene.idle(7); - scene.world.modifyBlock(beltPos.south(), s -> s.with(BeltBlock.CASING, false), true); + scene.world.modifyBlock(beltPos.south(), s -> s.setValue(BeltBlock.CASING, false), true); scene.overlay.showText(80) .text("A wrench can be used to remove the casing") .placeNearTarget() @@ -483,7 +483,7 @@ public class BeltScenes { scene.configureBasePlate(0, 0, 5); scene.showBasePlate(); scene.idle(5); - scene.world.setBlock(util.grid.at(3, 2, 2), Blocks.WATER.getDefaultState(), false); + scene.world.setBlock(util.grid.at(3, 2, 2), Blocks.WATER.defaultBlockState(), false); BlockPos depotPos = util.grid.at(2, 1, 2); scene.world.showSection(util.select.position(2, 1, 2), Direction.DOWN); @@ -513,31 +513,31 @@ public class BeltScenes { scene.effects.indicateSuccess(depotPos); scene.idle(20); - scene.world.showSection(util.select.position(depotPos.up(2)), Direction.SOUTH); + scene.world.showSection(util.select.position(depotPos.above(2)), Direction.SOUTH); scene.overlay.showText(70) .attachKeyFrame() .text("Just like Mechanical Belts, it can provide items to processing") .placeNearTarget() - .pointAt(util.vector.blockSurface(depotPos.up(2), Direction.WEST)); + .pointAt(util.vector.blockSurface(depotPos.above(2), Direction.WEST)); ItemStack bottle = new ItemStack(Items.BUCKET); scene.world.createItemOnBeltLike(depotPos, Direction.NORTH, bottle); scene.idle(20); - scene.world.modifyTileNBT(util.select.position(depotPos.up(2)), SpoutTileEntity.class, + scene.world.modifyTileNBT(util.select.position(depotPos.above(2)), SpoutTileEntity.class, nbt -> nbt.putInt("ProcessingTicks", 20)); scene.idle(20); scene.world.removeItemsFromBelt(depotPos); scene.world.createItemOnBeltLike(depotPos, Direction.UP, new ItemStack(Items.WATER_BUCKET)); - scene.world.modifyTileNBT(util.select.position(depotPos.up(2)), SpoutTileEntity.class, + scene.world.modifyTileNBT(util.select.position(depotPos.above(2)), SpoutTileEntity.class, nbt -> nbt.putBoolean("Splash", true)); scene.idle(30); scene.world.removeItemsFromBelt(depotPos); - scene.world.hideSection(util.select.position(depotPos.up(2)), Direction.SOUTH); + scene.world.hideSection(util.select.position(depotPos.above(2)), Direction.SOUTH); scene.idle(20); - ElementLink spout = scene.world.showIndependentSection(util.select.position(depotPos.up(2) + ElementLink spout = scene.world.showIndependentSection(util.select.position(depotPos.above(2) .west()), Direction.SOUTH); scene.world.moveSection(spout, util.vector.of(1, 0, 0), 0); - BlockPos pressPos = depotPos.up(2) + BlockPos pressPos = depotPos.above(2) .west(); ItemStack copper = AllItems.COPPER_INGOT.asStack(); scene.world.createItemOnBeltLike(depotPos, Direction.NORTH, copper); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/CartAssemblerScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/CartAssemblerScenes.java index 4da325070..046cde559 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/CartAssemblerScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/CartAssemblerScenes.java @@ -38,7 +38,7 @@ public class CartAssemblerScenes { scene.idle(5); BlockPos assemblerPos = util.grid.at(2, 1, 2); - scene.world.setBlock(assemblerPos, Blocks.RAIL.getDefaultState(), false); + scene.world.setBlock(assemblerPos, Blocks.RAIL.defaultBlockState(), false); for (int z = 0; z < 5; z++) { scene.world.showSection(util.select.position(2, 1, z), Direction.DOWN); scene.idle(2); @@ -54,8 +54,8 @@ public class CartAssemblerScenes { .withItem(AllBlocks.CART_ASSEMBLER.asStack()), 30); scene.idle(7); scene.world.setBlock(assemblerPos, AllBlocks.CART_ASSEMBLER.getDefaultState() - .with(CartAssemblerBlock.RAIL_SHAPE, RailShape.NORTH_SOUTH) - .with(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.REGULAR), true); + .setValue(CartAssemblerBlock.RAIL_SHAPE, RailShape.NORTH_SOUTH) + .setValue(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.REGULAR), true); scene.idle(20); scene.world.showSection(util.select.fromTo(0, 1, 2, 1, 1, 2), Direction.EAST); scene.idle(20); @@ -72,12 +72,12 @@ public class CartAssemblerScenes { ElementLink cart = scene.special.createCart(util.vector.topOf(2, 0, 4), 90, MinecartEntity::new); - scene.world.showSection(util.select.position(assemblerPos.up()), Direction.DOWN); + scene.world.showSection(util.select.position(assemblerPos.above()), Direction.DOWN); scene.idle(10); scene.special.moveCart(cart, util.vector.of(0, 0, -2), 20); scene.idle(20); ElementLink plank = - scene.world.makeSectionIndependent(util.select.position(assemblerPos.up())); + scene.world.makeSectionIndependent(util.select.position(assemblerPos.above())); ElementLink anchor = scene.world.showIndependentSectionImmediately(util.select.position(assemblerPos.east())); scene.world.moveSection(anchor, util.vector.of(-1, 0, 0), 0); @@ -111,7 +111,7 @@ public class CartAssemblerScenes { scene.special.moveCart(cart, util.vector.of(0, 0, 2), 20); scene.idle(30); - scene.world.destroyBlock(assemblerPos.up()); + scene.world.destroyBlock(assemblerPos.above()); scene.idle(5); ElementLink contraption = scene.world.showIndependentSection(util.select.fromTo(1, 4, 2, 3, 3, 2), Direction.DOWN); @@ -187,8 +187,8 @@ public class CartAssemblerScenes { BlockPos assemblerPos = util.grid.at(3, 1, 3); scene.idle(5); scene.world.setBlock(assemblerPos, AllBlocks.CART_ASSEMBLER.getDefaultState() - .with(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) - .with(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.REGULAR), true); + .setValue(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) + .setValue(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.REGULAR), true); scene.idle(5); scene.world.showSection(util.select.fromTo(3, 1, 1, 3, 1, 2), Direction.SOUTH); ElementLink contraption = @@ -317,17 +317,17 @@ public class CartAssemblerScenes { scene.world.showSection(util.select.fromTo(2, 1, 3, 2, 1, 2), Direction.SOUTH); scene.idle(5); ElementLink cart = - scene.special.createCart(util.vector.topOf(assembler1.down()), 0, MinecartEntity::new); + scene.special.createCart(util.vector.topOf(assembler1.below()), 0, MinecartEntity::new); ElementLink cart2 = - scene.special.createCart(util.vector.topOf(assembler2.down()), 0, ChestMinecartEntity::new); + scene.special.createCart(util.vector.topOf(assembler2.below()), 0, ChestMinecartEntity::new); scene.idle(15); scene.world.setBlock(assembler1, AllBlocks.CART_ASSEMBLER.getDefaultState() - .with(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) - .with(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.CONTROLLER_RAIL), true); + .setValue(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) + .setValue(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.CONTROLLER_RAIL), true); scene.idle(5); scene.world.setBlock(assembler2, AllBlocks.CART_ASSEMBLER.getDefaultState() - .with(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) - .with(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.REGULAR), true); + .setValue(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) + .setValue(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.REGULAR), true); scene.idle(5); ElementLink contraption = scene.world.showIndependentSection(chassis, Direction.DOWN); @@ -429,17 +429,17 @@ public class CartAssemblerScenes { .text("Cart Assemblers on Regular Tracks will not affect the passing carts' motion"); scene.idle(10); scene.world.setBlock(assembler, AllBlocks.CART_ASSEMBLER.getDefaultState() - .with(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) - .with(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.REGULAR), true); + .setValue(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) + .setValue(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.REGULAR), true); scene.idle(70); ElementLink cart = scene.special.createCart(util.vector.topOf(assembler.east(2) - .down()), 0, MinecartEntity::new); + .below()), 0, MinecartEntity::new); ElementLink anchor = scene.world.showIndependentSection(util.select.position(assembler.south()), Direction.DOWN); ElementLink contraption = scene.world.showIndependentSection(util.select.position(assembler.south() - .up()), Direction.DOWN); + .above()), Direction.DOWN); scene.world.moveSection(contraption, util.vector.of(2, 0, -1), 0); scene.world.moveSection(anchor, util.vector.of(2, 0, -1), 0); scene.idle(10); @@ -456,8 +456,8 @@ public class CartAssemblerScenes { .withItem(new ItemStack(Items.POWERED_RAIL)), 50); scene.idle(7); scene.world.setBlock(assembler, AllBlocks.CART_ASSEMBLER.getDefaultState() - .with(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) - .with(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.POWERED_RAIL), true); + .setValue(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) + .setValue(CartAssemblerBlock.RAIL_TYPE, CartAssembleRailType.POWERED_RAIL), true); scene.overlay.showText(100) .attachKeyFrame() .pointAt(util.vector.topOf(assembler)) @@ -467,10 +467,10 @@ public class CartAssemblerScenes { scene.world.hideIndependentSection(anchor, Direction.DOWN); cart = scene.special.createCart(util.vector.topOf(assembler.east(2) - .down()), 0, MinecartEntity::new); + .below()), 0, MinecartEntity::new); anchor = scene.world.showIndependentSection(util.select.position(assembler.south()), Direction.DOWN); contraption = scene.world.showIndependentSection(util.select.position(assembler.south() - .up()), Direction.DOWN); + .above()), Direction.DOWN); scene.world.moveSection(contraption, util.vector.of(2, 0, -1), 0); scene.world.moveSection(anchor, util.vector.of(2, 0, -1), 0); scene.idle(10); @@ -495,7 +495,7 @@ public class CartAssemblerScenes { scene.idle(20); cart = scene.special.createCart(util.vector.topOf(assembler.east(2) - .down()), 0, FurnaceMinecartEntity::new); + .below()), 0, FurnaceMinecartEntity::new); scene.idle(10); scene.overlay.showText(50) .attachKeyFrame() @@ -505,14 +505,14 @@ public class CartAssemblerScenes { scene.idle(50); contraption = scene.world.showIndependentSection(chassis, Direction.DOWN); scene.idle(5); - scene.world.glueBlockOnto(assembler.up(2), Direction.DOWN, contraption); + scene.world.glueBlockOnto(assembler.above(2), Direction.DOWN, contraption); scene.idle(15); - scene.overlay.showControls(new InputWindowElement(util.vector.topOf(assembler.up()), Pointing.UP) + scene.overlay.showControls(new InputWindowElement(util.vector.topOf(assembler.above()), Pointing.UP) .withItem(new ItemStack(Items.CHARCOAL)), 40); scene.idle(7); scene.overlay.showText(80) - .pointAt(util.vector.blockSurface(assembler.up(2), Direction.WEST)) + .pointAt(util.vector.blockSurface(assembler.above(2), Direction.WEST)) .placeNearTarget() .text("Furnace Carts will keep themselves powered, pulling fuel from any attached inventories"); scene.idle(85); 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 b20d88216..8ece78aac 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 @@ -57,7 +57,7 @@ public class ChainDriveScenes { Selection shafts = util.select.fromTo(2, 1, 0, 2, 1, 1); BlockPos rotatedECD = util.grid.at(3, 1, 0); - Selection verticalShaft = util.select.fromTo(rotatedECD.up(), rotatedECD.up(2)); + Selection verticalShaft = util.select.fromTo(rotatedECD.above(), rotatedECD.above(2)); scene.world.showSection(shafts, Direction.EAST); scene.idle(10); @@ -77,7 +77,7 @@ public class ChainDriveScenes { scene.overlay.showControls(new InputWindowElement(util.vector.topOf(rotatedECD), Pointing.DOWN).rightClick() .withWrench(), 30); scene.idle(7); - scene.world.modifyBlock(rotatedECD, s -> s.with(EncasedBeltBlock.AXIS, Axis.Y), true); + scene.world.modifyBlock(rotatedECD, s -> s.setValue(EncasedBeltBlock.AXIS, Axis.Y), true); scene.idle(40); scene.world.showSection(verticalShaft, Direction.DOWN); @@ -102,11 +102,11 @@ public class ChainDriveScenes { BlockPos leverPos = util.grid.at(3, 1, 0); BlockPos eastDrive = util.grid.at(3, 1, 2); - BlockPos eastGauge = eastDrive.up(3); + BlockPos eastGauge = eastDrive.above(3); BlockPos middleGauge = eastGauge.west() - .down(); + .below(); BlockPos westGauge = eastGauge.west(2) - .down(2); + .below(2); ElementLink lever = scene.world.showIndependentSection(util.select.fromTo(leverPos, leverPos.south()), Direction.UP); @@ -115,7 +115,7 @@ public class ChainDriveScenes { scene.world.showSection(util.select.fromTo(4, 1, 3, 4, 2, 3), Direction.DOWN); scene.idle(10); scene.world.showSection(util.select.fromTo(eastDrive, eastDrive.west(2)) - .add(util.select.position(eastDrive.up())), Direction.DOWN); + .add(util.select.position(eastDrive.above())), Direction.DOWN); scene.idle(10); scene.overlay.showText(60) @@ -125,9 +125,9 @@ public class ChainDriveScenes { .pointAt(util.vector.blockSurface(eastDrive, Direction.NORTH)); scene.idle(60); - scene.world.showSection(util.select.fromTo(eastGauge, eastGauge.down()), Direction.DOWN); + scene.world.showSection(util.select.fromTo(eastGauge, eastGauge.below()), Direction.DOWN); scene.idle(5); - scene.world.showSection(util.select.fromTo(middleGauge, middleGauge.down()), Direction.DOWN); + scene.world.showSection(util.select.fromTo(middleGauge, middleGauge.below()), Direction.DOWN); scene.idle(5); scene.world.showSection(util.select.position(westGauge), Direction.DOWN); scene.idle(5); @@ -145,14 +145,14 @@ public class ChainDriveScenes { scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.south(2))); scene.effects.indicateRedstone(leverPos); - scene.world.modifyKineticSpeed(util.select.fromTo(westGauge.down(), middleGauge), f -> 2 * f); + scene.world.modifyKineticSpeed(util.select.fromTo(westGauge.below(), middleGauge), f -> 2 * f); scene.idle(10); AxisAlignedBB bb = new AxisAlignedBB(eastDrive); scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, eastDrive, bb, 160); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.FAST, eastDrive.west(), bb.offset(-2, 0, 0) - .expand(15 / 16f, 0, 0), 160); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.FAST, eastDrive.west(), bb.move(-2, 0, 0) + .expandTowards(15 / 16f, 0, 0), 160); scene.idle(20); scene.overlay.showText(80) @@ -180,7 +180,7 @@ public class ChainDriveScenes { Selection newDriveSelect = util.select.fromTo(eastDrive.south(2), eastDrive.south(2) .west(2)); ElementLink drives = scene.world.showIndependentSection(newDriveSelect, Direction.NORTH); - scene.world.modifyKineticSpeed(util.select.fromTo(westGauge.down(), middleGauge), f -> .5f * f); + scene.world.modifyKineticSpeed(util.select.fromTo(westGauge.below(), middleGauge), f -> .5f * f); scene.world.setKineticSpeed(newDriveSelect, -32); scene.world.moveSection(drives, util.vector.of(0, 0, -2), 0); scene.world.moveSection(lever, util.vector.of(-2, 0, 0), 10); @@ -196,8 +196,8 @@ public class ChainDriveScenes { scene.idle(10); bb = new AxisAlignedBB(eastDrive); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, eastDrive, bb.expand(-15 / 16f, 0, 0), 160); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.SLOW, eastDrive.west(), bb.offset(-2, 0, 0), 160); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, eastDrive, bb.expandTowards(-15 / 16f, 0, 0), 160); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.SLOW, eastDrive.west(), bb.move(-2, 0, 0), 160); scene.idle(20); scene.overlay.showText(80) @@ -238,7 +238,7 @@ public class ChainDriveScenes { scene.world.modifyTileNBT(util.select.position(analogPos), AnalogLeverTileEntity.class, nbt -> { nbt.putInt("State", 8); }); - scene.world.modifyBlock(analogPos.south(), s -> s.with(RedstoneWireBlock.POWER, 8), false); + scene.world.modifyBlock(analogPos.south(), s -> s.setValue(RedstoneWireBlock.POWER, 8), false); scene.world.toggleRedstonePower(util.select.position(1, 1, 4)); scene.world.modifyKineticSpeed(util.select.position(westGauge), f -> .75f * f); scene.effects.indicateRedstone(analogPos); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/ChassisScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/ChassisScenes.java index 24c7a768f..831e857a8 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/ChassisScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/ChassisScenes.java @@ -43,9 +43,9 @@ public class ChassisScenes { scene.world.showSectionAndMerge(util.select.position(centralChassis.east() .north()), Direction.SOUTH, chassis); scene.idle(3); - scene.world.showSectionAndMerge(util.select.position(centralChassis.up()), Direction.DOWN, chassis); + scene.world.showSectionAndMerge(util.select.position(centralChassis.above()), Direction.DOWN, chassis); scene.idle(2); - scene.world.showSectionAndMerge(util.select.position(centralChassis.up() + scene.world.showSectionAndMerge(util.select.position(centralChassis.above() .east()), Direction.DOWN, chassis); scene.idle(10); @@ -107,7 +107,7 @@ public class ChassisScenes { .withItem(new ItemStack(Items.SLIME_BALL)); scene.overlay.showControls(input, 30); scene.idle(7); - scene.world.modifyBlock(chassisPos, s -> s.with(LinearChassisBlock.STICKY_BOTTOM, true), false); + scene.world.modifyBlock(chassisPos, s -> s.setValue(LinearChassisBlock.STICKY_BOTTOM, true), false); scene.effects.superGlue(chassisPos, Direction.WEST, false); scene.idle(30); @@ -119,7 +119,7 @@ public class ChassisScenes { scene.overlay.showControls(input, 15); scene.idle(7); - scene.world.modifyBlock(chassisPos, s -> s.with(LinearChassisBlock.STICKY_TOP, true), false); + scene.world.modifyBlock(chassisPos, s -> s.setValue(LinearChassisBlock.STICKY_TOP, true), false); scene.effects.superGlue(chassisPos, Direction.EAST, false); scene.idle(15); @@ -138,7 +138,7 @@ public class ChassisScenes { .whileSneaking(), 30); scene.idle(7); - scene.world.modifyBlock(chassisPos, s -> s.with(LinearChassisBlock.STICKY_BOTTOM, false), false); + scene.world.modifyBlock(chassisPos, s -> s.setValue(LinearChassisBlock.STICKY_BOTTOM, false), false); scene.effects.superGlue(chassisPos, Direction.WEST, false); scene.idle(30); @@ -152,7 +152,7 @@ public class ChassisScenes { scene.idle(20); ElementLink glassSection = - scene.world.showIndependentSection(util.select.position(chassisPos.up()), Direction.DOWN); + scene.world.showIndependentSection(util.select.position(chassisPos.above()), Direction.DOWN); scene.world.moveSection(glassSection, util.vector.of(0, -1, 0), 0); scene.idle(25); scene.addKeyframe(); @@ -281,7 +281,7 @@ public class ChassisScenes { scene.idle(20); scene.overlay.showText(80) - .pointAt(util.vector.topOf(chassisPos.up(2))) + .pointAt(util.vector.topOf(chassisPos.above(2))) .text("Using these mechanics, structures of any shape can move as a Contraption") .placeNearTarget(); scene.idle(30); @@ -307,14 +307,14 @@ public class ChassisScenes { ElementLink contraption = scene.world.showIndependentSection(chassis, Direction.DOWN); scene.idle(5); ElementLink top = - scene.world.showIndependentSection(util.select.position(chassisPos.up()), Direction.DOWN); + scene.world.showIndependentSection(util.select.position(chassisPos.above()), Direction.DOWN); scene.idle(10); scene.overlay.showText(50) .attachKeyFrame() .placeNearTarget() .text("Radial Chassis connect to identical Chassis blocks in a row") - .pointAt(util.vector.topOf(chassisPos.up())); + .pointAt(util.vector.topOf(chassisPos.above())); scene.idle(60); BlockPos bearingPos = util.grid.at(2, 1, 2); @@ -340,7 +340,7 @@ public class ChassisScenes { .withItem(new ItemStack(Items.SLIME_BALL)); scene.overlay.showControls(input, 30); scene.idle(7); - scene.world.modifyBlock(chassisPos, s -> s.with(RadialChassisBlock.STICKY_WEST, true), false); + scene.world.modifyBlock(chassisPos, s -> s.setValue(RadialChassisBlock.STICKY_WEST, true), false); scene.effects.superGlue(chassisPos, Direction.WEST, false); scene.idle(30); @@ -352,9 +352,9 @@ public class ChassisScenes { scene.overlay.showControls(input, 15); scene.idle(7); - scene.world.modifyBlock(chassisPos, s -> s.with(RadialChassisBlock.STICKY_EAST, true) - .with(RadialChassisBlock.STICKY_NORTH, true) - .with(RadialChassisBlock.STICKY_SOUTH, true), false); + scene.world.modifyBlock(chassisPos, s -> s.setValue(RadialChassisBlock.STICKY_EAST, true) + .setValue(RadialChassisBlock.STICKY_NORTH, true) + .setValue(RadialChassisBlock.STICKY_SOUTH, true), false); scene.effects.superGlue(chassisPos, Direction.EAST, false); scene.effects.superGlue(chassisPos, Direction.SOUTH, false); scene.effects.superGlue(chassisPos, Direction.NORTH, false); @@ -375,7 +375,7 @@ public class ChassisScenes { .whileSneaking(), 30); scene.idle(7); - scene.world.modifyBlock(chassisPos, s -> s.with(RadialChassisBlock.STICKY_WEST, false), false); + scene.world.modifyBlock(chassisPos, s -> s.setValue(RadialChassisBlock.STICKY_WEST, false), false); scene.effects.superGlue(chassisPos, Direction.WEST, false); scene.idle(30); @@ -407,7 +407,7 @@ public class ChassisScenes { scene.world.showSection(util.select.fromTo(0, 3, 3, 1, 3, 4), Direction.DOWN); scene.idle(10); Vector3d blockSurface = util.vector.blockSurface(chassisPos, Direction.NORTH); - AxisAlignedBB bb = new AxisAlignedBB(blockSurface, blockSurface).grow(.501, .501, 0); + AxisAlignedBB bb = new AxisAlignedBB(blockSurface, blockSurface).inflate(.501, .501, 0); scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, bb, bb, 60); scene.overlay.showOutline(PonderPalette.WHITE, s, s, 80); scene.overlay.showText(40) @@ -535,7 +535,7 @@ public class ChassisScenes { scene.world.glueBlockOnto(central.north() .east(), Direction.WEST, plank); scene.idle(5); - scene.world.glueBlockOnto(central.up(), Direction.DOWN, plank); + scene.world.glueBlockOnto(central.above(), Direction.DOWN, plank); scene.idle(5); scene.world.glueBlockOnto(central.south() .west(), Direction.EAST, plank); @@ -553,7 +553,7 @@ public class ChassisScenes { scene.idle(90); glueEntity = scene.world.createGlueEntity(central, Direction.UP); - scene.world.destroyBlock(central.up()); + scene.world.destroyBlock(central.above()); scene.idle(20); scene.addKeyframe(); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(central), Pointing.DOWN).leftClick(), 40); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/ChuteScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/ChuteScenes.java index 0c168ee13..766f6beb5 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/ChuteScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/ChuteScenes.java @@ -65,7 +65,7 @@ public class ChuteScenes { .withWrench(), 40); scene.idle(7); - scene.world.modifyBlock(util.grid.at(3, 3, 3), s -> s.with(ChuteBlock.SHAPE, ChuteBlock.Shape.WINDOW), false); + scene.world.modifyBlock(util.grid.at(3, 3, 3), s -> s.setValue(ChuteBlock.SHAPE, ChuteBlock.Shape.WINDOW), false); scene.overlay.showText(50) .attachKeyFrame() .pointAt(util.vector.blockSurface(util.grid.at(2, 3, 2), Direction.WEST)) @@ -73,7 +73,7 @@ public class ChuteScenes { .text("Using the Wrench, a window can be created"); scene.idle(10); - scene.world.modifyBlock(util.grid.at(3, 2, 3), s -> s.with(SHAPE, Shape.WINDOW), false); + scene.world.modifyBlock(util.grid.at(3, 2, 3), s -> s.setValue(SHAPE, Shape.WINDOW), false); for (int i = 0; i < 8; i++) { scene.idle(10); @@ -85,7 +85,7 @@ public class ChuteScenes { scene.idle(15); scene.rotateCameraY(-90); - scene.world.modifyBlock(util.grid.at(2, 2, 1), s -> s.with(SHAPE, Shape.NORMAL), false); + scene.world.modifyBlock(util.grid.at(2, 2, 1), s -> s.setValue(SHAPE, Shape.NORMAL), false); scene.world.showSection(util.select.fromTo(2, 1, 1, 2, 2, 1), Direction.DOWN); scene.idle(30); ItemStack chuteItem = AllBlocks.CHUTE.asStack(); @@ -120,14 +120,14 @@ public class ChuteScenes { Direction offset = Direction.NORTH; for (int i = 0; i < 3; i++) { remove = scene.world.createItemEntity(util.vector.centerOf(util.grid.at(2, 6, 3) - .offset(offset)), util.vector.of(0, 0.1, 0) - .add(Vector3d.of(offset.getDirectionVec()).scale(-.1)), + .relative(offset)), util.vector.of(0, 0.1, 0) + .add(Vector3d.atLowerCornerOf(offset.getNormal()).scale(-.1)), stack); scene.idle(12); scene.world.createItemOnBeltLike(util.grid.at(2, 4, 3), Direction.UP, stack); scene.world.modifyEntity(remove, Entity::remove); scene.idle(3); - offset = offset.rotateY(); + offset = offset.getClockWise(); } scene.idle(10); @@ -143,7 +143,7 @@ public class ChuteScenes { scene.scaleSceneView(.9f); scene.showBasePlate(); Selection chute = util.select.fromTo(1, 2, 2, 1, 4, 2); - scene.world.setBlocks(chute, Blocks.AIR.getDefaultState(), false); + scene.world.setBlocks(chute, Blocks.AIR.defaultBlockState(), false); scene.world.showSection(util.select.position(1, 1, 2), Direction.UP); scene.idle(20); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/CrafterScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/CrafterScenes.java index a4da5da9f..14a0e2cf9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/CrafterScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/CrafterScenes.java @@ -39,7 +39,7 @@ public class CrafterScenes { BlockPos depotPos = util.grid.at(0, 1, 2); Selection crafters = util.select.fromTo(1, 1, 2, 3, 3, 2); - scene.world.modifyBlocks(crafters, s -> s.with(MechanicalCrafterBlock.POINTING, Pointing.DOWN), false); + scene.world.modifyBlocks(crafters, s -> s.setValue(MechanicalCrafterBlock.POINTING, Pointing.DOWN), false); scene.world.setKineticSpeed(crafters, 0); for (int y = 0; y < 3; y++) { @@ -280,7 +280,7 @@ public class CrafterScenes { scene.idle(40); Vector3d v = util.vector.blockSurface(util.grid.at(2, 2, 2), Direction.WEST); - AxisAlignedBB bb = new AxisAlignedBB(v, v).grow(.125f, .5, .5); + AxisAlignedBB bb = new AxisAlignedBB(v, v).inflate(.125f, .5, .5); v = v.add(0, 0, .5); scene.overlay.chaseBoundingBoxOutline(PonderPalette.WHITE, new Object(), bb, 45); @@ -348,7 +348,7 @@ public class CrafterScenes { scene.configureBasePlate(0, 0, 5); scene.world.showSection(util.select.layer(0), Direction.UP); - scene.world.setBlock(util.grid.at(2, 2, 2), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 2, 2), Blocks.AIR.defaultBlockState(), false); Selection kinetics = util.select.fromTo(3, 1, 2, 3, 1, 5); scene.world.setKineticSpeed(util.select.fromTo(1, 2, 2, 3, 1, 2), 0); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/DebugScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/DebugScenes.java index 5261f9437..b2ed9efe7 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/DebugScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/DebugScenes.java @@ -100,7 +100,7 @@ public class DebugScenes { scene.world.replaceBlocks(util.select.fromTo(1, 1, 3, 2, 2, 4), AllBlocks.REFINED_RADIANCE_CASING.getDefaultState(), true); scene.idle(10); - scene.world.replaceBlocks(util.select.position(3, 1, 1), Blocks.GOLD_BLOCK.getDefaultState(), true); + scene.world.replaceBlocks(util.select.position(3, 1, 1), Blocks.GOLD_BLOCK.defaultBlockState(), true); scene.rotateCameraY(180); scene.markAsFinished(); } @@ -121,10 +121,10 @@ public class DebugScenes { Vector3d vec1 = util.vector.topOf(1, 0, 0); Vector3d vec2 = util.vector.topOf(0, 0, 1); - AxisAlignedBB boundingBox1 = new AxisAlignedBB(vec1, vec1).expand(0, 2.5, 0) - .grow(.15, 0, .15); - AxisAlignedBB boundingBox2 = new AxisAlignedBB(vec2, vec2).expand(0, .125, 0) - .grow(.45, 0, .45); + AxisAlignedBB boundingBox1 = new AxisAlignedBB(vec1, vec1).expandTowards(0, 2.5, 0) + .inflate(.15, 0, .15); + AxisAlignedBB boundingBox2 = new AxisAlignedBB(vec2, vec2).expandTowards(0, .125, 0) + .inflate(.45, 0, .45); Vector3d poi1 = boundingBox1.getCenter(); Vector3d poi2 = boundingBox2.getCenter(); @@ -229,7 +229,7 @@ public class DebugScenes { Object chassisEffectHighlight = new Object(); AxisAlignedBB point = new AxisAlignedBB(chassisSurface, chassisSurface); - AxisAlignedBB expanded = point.grow(1 / 4f, 1 / 4f, 1 / 16f); + AxisAlignedBB expanded = point.inflate(1 / 4f, 1 / 4f, 1 / 16f); Selection singleBlock = util.select.position(1, 2, 3); Selection twoBlocks = util.select.fromTo(1, 2, 3, 1, 3, 3); @@ -302,11 +302,11 @@ public class DebugScenes { BlockPos poi1 = util.grid.at(4, 1, 0); BlockPos poi2 = util.grid.at(0, 1, 4); - scene.world.setBlock(poi1, Blocks.GOLD_BLOCK.getDefaultState(), true); + scene.world.setBlock(poi1, Blocks.GOLD_BLOCK.defaultBlockState(), true); scene.special.movePointOfInterest(poi1); scene.idle(20); - scene.world.setBlock(poi2, Blocks.GOLD_BLOCK.getDefaultState(), true); + scene.world.setBlock(poi2, Blocks.GOLD_BLOCK.defaultBlockState(), true); scene.special.movePointOfInterest(poi2); scene.overlay.showText(20) .text("Point of Interest") @@ -419,15 +419,15 @@ public class DebugScenes { scene.idle(20); scene.world.modifyEntities(ItemEntity.class, entity -> { - if (copperItem.isItemEqual(entity.getItem())) + if (copperItem.sameItem(entity.getItem())) entity.setNoGravity(true); }); scene.idle(20); scene.world.modifyEntities(ItemEntity.class, entity -> { - if (brassItem.isItemEqual(entity.getItem())) - entity.setMotion(util.vector.of(-.15f, .5f, 0)); + if (brassItem.sameItem(entity.getItem())) + entity.setDeltaMovement(util.vector.of(-.15f, .5f, 0)); }); scene.idle(27); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/DeployerScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/DeployerScenes.java index 89d1a3f96..543cef424 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/DeployerScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/DeployerScenes.java @@ -37,7 +37,7 @@ public class DeployerScenes { BlockPos deployerPos = util.grid.at(3, 1, 2); Selection deployerSelection = util.select.position(deployerPos); - scene.world.setBlock(potPosition, Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(potPosition, Blocks.AIR.defaultBlockState(), false); scene.world.showSection(util.select.layer(0) .add(util.select.position(1, 1, 2)), Direction.UP); scene.idle(5); @@ -126,10 +126,10 @@ public class DeployerScenes { scene.world.moveDeployer(deployerPos, -1, 25); scene.idle(20); - scene.world.showSection(util.select.position(deployerPos.up()), Direction.DOWN); + scene.world.showSection(util.select.position(deployerPos.above()), Direction.DOWN); ItemStack tulip = new ItemStack(Items.RED_TULIP); - Vector3d entitySpawn = util.vector.topOf(deployerPos.up(3)); + Vector3d entitySpawn = util.vector.topOf(deployerPos.above(3)); ElementLink entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), tulip); @@ -144,13 +144,13 @@ public class DeployerScenes { scene.idle(30); scene.world.moveDeployer(deployerPos, 1, 25); scene.idle(26); - scene.world.setBlock(potPosition, Blocks.POTTED_RED_TULIP.getDefaultState(), false); + scene.world.setBlock(potPosition, Blocks.POTTED_RED_TULIP.defaultBlockState(), false); scene.world.modifyTileNBT(deployerSelection, teType, nbt -> nbt.put("HeldItem", ItemStack.EMPTY.serializeNBT())); scene.world.moveDeployer(deployerPos, -1, 25); scene.idle(25); scene.world.hideSection(util.select.position(potPosition), Direction.UP); - scene.world.hideSection(util.select.position(deployerPos.up()), Direction.EAST); + scene.world.hideSection(util.select.position(deployerPos.above()), Direction.EAST); scene.idle(20); Vector3d filterSlot = frontVec.add(0.375, 0.25, 0); @@ -176,21 +176,21 @@ public class DeployerScenes { ElementLink sheep = scene.world.createEntity(w -> { SheepEntity entity = EntityType.SHEEP.create(w); - entity.setFleeceColor(DyeColor.PINK); + entity.setColor(DyeColor.PINK); Vector3d p = util.vector.topOf(util.grid.at(1, 0, 2)); - entity.setPosition(p.x, p.y, p.z); - entity.prevPosX = p.x; - entity.prevPosY = p.y; - entity.prevPosZ = p.z; - entity.limbSwing = 0; - entity.prevRotationYaw = 210; - entity.rotationYaw = 210; - entity.prevRotationYawHead = 210; - entity.rotationYawHead = 210; + entity.setPos(p.x, p.y, p.z); + entity.xo = p.x; + entity.yo = p.y; + entity.zo = p.z; + entity.animationPosition = 0; + entity.yRotO = 210; + entity.yRot = 210; + entity.yHeadRotO = 210; + entity.yHeadRot = 210; return entity; }); scene.idle(20); - scene.world.showSection(util.select.position(deployerPos.up()), Direction.WEST); + scene.world.showSection(util.select.position(deployerPos.above()), Direction.WEST); entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), shears); scene.idle(17); scene.world.modifyEntity(entity1, Entity::remove); @@ -208,7 +208,7 @@ public class DeployerScenes { scene.world.modifyEntity(sheep, e -> ((SheepEntity) e).setSheared(true)); scene.effects.emitParticles(util.vector.topOf(deployerPos.west(2)) .add(0, -.25, 0), - Emitter.withinBlockSpace(new BlockParticleData(ParticleTypes.BLOCK, Blocks.PINK_WOOL.getDefaultState()), + Emitter.withinBlockSpace(new BlockParticleData(ParticleTypes.BLOCK, Blocks.PINK_WOOL.defaultBlockState()), util.vector.of(0, 0, 0)), 25, 1); scene.world.moveDeployer(deployerPos, -1, 25); @@ -271,7 +271,7 @@ public class DeployerScenes { .text("By default, a Deployer imitates a Right-click interaction"); scene.idle(26); - scene.world.replaceBlocks(grassBlock, Blocks.FARMLAND.getDefaultState(), false); + scene.world.replaceBlocks(grassBlock, Blocks.FARMLAND.defaultBlockState(), false); scene.world.moveDeployer(deployerPos, -1, 25); scene.idle(46); @@ -334,7 +334,7 @@ public class DeployerScenes { scene.idle(10); ItemStack tool = AllItems.SAND_PAPER.asStack(); - scene.overlay.showControls(new InputWindowElement(util.vector.blockSurface(pressPos.down(), Direction.EAST) + scene.overlay.showControls(new InputWindowElement(util.vector.blockSurface(pressPos.below(), Direction.EAST) .add(0, 0.15, 0), Pointing.RIGHT).withItem(tool), 30); scene.idle(7); scene.world.modifyTileNBT(pressS, DeployerTileEntity.class, nbt -> nbt.put("HeldItem", tool.serializeNBT())); @@ -404,8 +404,8 @@ public class DeployerScenes { scene.idle(30); scene.world.moveDeployer(pressPos, -1, 30); scene.debug.enqueueCallback(s -> SandPaperItem.spawnParticles(targetV, quartz, s.getWorld())); - scene.world.removeItemsFromBelt(pressPos.down(2)); - ingot = scene.world.createItemOnBelt(pressPos.down(2), Direction.UP, polished); + scene.world.removeItemsFromBelt(pressPos.below(2)); + ingot = scene.world.createItemOnBelt(pressPos.below(2), Direction.UP, polished); scene.world.stallBeltItem(ingot, true); scene.idle(15); scene.world.stallBeltItem(ingot, false); @@ -415,8 +415,8 @@ public class DeployerScenes { scene.idle(30); scene.world.moveDeployer(pressPos, -1, 30); scene.debug.enqueueCallback(s -> SandPaperItem.spawnParticles(targetV, quartz, s.getWorld())); - scene.world.removeItemsFromBelt(pressPos.down(2)); - ingot2 = scene.world.createItemOnBelt(pressPos.down(2), Direction.UP, polished); + scene.world.removeItemsFromBelt(pressPos.below(2)); + ingot2 = scene.world.createItemOnBelt(pressPos.below(2), Direction.UP, polished); scene.world.stallBeltItem(ingot2, true); scene.idle(15); scene.world.stallBeltItem(ingot2, false); @@ -492,7 +492,7 @@ public class DeployerScenes { scene.configureBasePlate(0, 0, 6); scene.scaleSceneView(.9f); Selection flowers = util.select.fromTo(4, 1, 1, 1, 1, 1); - scene.world.replaceBlocks(flowers, Blocks.AIR.getDefaultState(), false); + scene.world.replaceBlocks(flowers, Blocks.AIR.defaultBlockState(), false); Selection kinetics = util.select.fromTo(5, 1, 6, 5, 1, 3); BlockPos deployerPos = util.grid.at(4, 1, 3); @@ -541,7 +541,7 @@ public class DeployerScenes { scene.world.hideSection(flowers, Direction.UP); scene.idle(15); - scene.world.replaceBlocks(flowers, Blocks.AIR.getDefaultState(), false); + scene.world.replaceBlocks(flowers, Blocks.AIR.defaultBlockState(), false); scene.world.showSection(flowers, Direction.UP); Vector3d frontVec = util.vector.blockSurface(deployerPos.west(3), Direction.NORTH) @@ -570,7 +570,7 @@ public class DeployerScenes { scene.world.moveDeployer(deployerPos, 1, 9); scene.idle(10); scene.world.moveDeployer(deployerPos, -1, 9); - scene.world.setBlock(util.grid.at(1 + x, 1, 1), Blocks.POPPY.getDefaultState(), false); + scene.world.setBlock(util.grid.at(1 + x, 1, 1), Blocks.POPPY.defaultBlockState(), false); scene.idle(18); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/EjectorScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/EjectorScenes.java index 4b31f95fb..2ae78d4a9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/EjectorScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/EjectorScenes.java @@ -77,7 +77,7 @@ public class EjectorScenes { AxisAlignedBB bb = new AxisAlignedBB(ejectorPos.west()); scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, slot, bb, 20); scene.idle(10); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, slot, bb.expand(-15, 15, 0), 100); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, slot, bb.expandTowards(-15, 15, 0), 100); scene.idle(10); scene.overlay.showText(60) @@ -87,7 +87,7 @@ public class EjectorScenes { .pointAt(util.vector.blockSurface(targetPos, Direction.WEST)) .placeNearTarget(); scene.idle(70); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, new Object(), bb.offset(-2, 0, -1), 60); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, new Object(), bb.move(-2, 0, -1), 60); scene.idle(10); scene.overlay.showText(50) .colored(PonderPalette.RED) @@ -303,7 +303,7 @@ public class EjectorScenes { scene.world.showSection(redstone, Direction.EAST); BlockPos ejectorPos = util.grid.at(4, 1, 2); - Vector3d topOf = util.vector.topOf(ejectorPos.up(2)); + Vector3d topOf = util.vector.topOf(ejectorPos.above(2)); ItemStack copper = AllItems.COPPER_INGOT.asStack(); for (int i = 0; i < 3; i++) { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/FanScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/FanScenes.java index 04ac6a0fe..cbdf38ea6 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/FanScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/FanScenes.java @@ -60,7 +60,7 @@ public class FanScenes { BlockPos leverPos = util.grid.at(3, 2, 4); Selection reverse = util.select.fromTo(3, 1, 5, 1, 1, 4); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.effects.indicateRedstone(leverPos); scene.addKeyframe(); scene.world.modifyKineticSpeed(reverse, f -> -f); @@ -76,7 +76,7 @@ public class FanScenes { scene.markAsFinished(); scene.idle(70); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.effects.indicateRedstone(leverPos); scene.world.modifyKineticSpeed(reverse, f -> -f); scene.world.modifyKineticSpeed(util.select.everywhere(), f -> 4 * f); @@ -103,7 +103,7 @@ public class FanScenes { ElementLink blockInFront = scene.world.showIndependentSection(util.select.position(3, 1, 0), Direction.SOUTH); scene.world.moveSection(blockInFront, util.vector.of(1, 0, 2), 0); - scene.world.setBlock(blockPos, Blocks.LAVA.getDefaultState(), false); + scene.world.setBlock(blockPos, Blocks.LAVA.defaultBlockState(), false); scene.idle(10); scene.overlay.showSelectionWithText(util.select.fromTo(blockPos, blockPos.west(2)), 80) @@ -115,9 +115,9 @@ public class FanScenes { ItemStack smelted = new ItemStack(Items.GOLD_INGOT); ElementLink entityLink = scene.world.createItemEntity(util.vector.centerOf(blockPos.west(2) - .up(2)), util.vector.of(0, 0.1, 0), stack); + .above(2)), util.vector.of(0, 0.1, 0), stack); scene.idle(15); - scene.world.modifyEntity(entityLink, e -> e.setMotion(-0.2f, 0, 0)); + scene.world.modifyEntity(entityLink, e -> e.setDeltaMovement(-0.2f, 0, 0)); Vector3d itemVec = util.vector.blockSurface(util.grid.at(1, 1, 2), Direction.EAST) .add(0.1, 0, 0); scene.overlay.showControls(new InputWindowElement(itemVec, Pointing.DOWN).withItem(stack), 20); @@ -149,7 +149,7 @@ public class FanScenes { // smoking start - BlockState campfire = Blocks.FIRE.getDefaultState(); + BlockState campfire = Blocks.FIRE.defaultBlockState(); scene.world.hideIndependentSection(blockInFront, Direction.NORTH); scene.idle(15); scene.world.setBlock(util.grid.at(3, 1, 0), campfire, false); @@ -166,7 +166,7 @@ public class FanScenes { // washing start - BlockState water = Blocks.WATER.getDefaultState(); + BlockState water = Blocks.WATER.defaultBlockState(); scene.world.hideIndependentSection(blockInFront, Direction.NORTH); scene.idle(15); scene.world.setBlock(util.grid.at(3, 1, 0), water, false); @@ -185,9 +185,9 @@ public class FanScenes { ItemStack washed = new ItemStack(Items.GOLD_NUGGET, 16); entityLink = scene.world.createItemEntity(util.vector.centerOf(blockPos.west(2) - .up(2)), util.vector.of(0, 0.1, 0), stack); + .above(2)), util.vector.of(0, 0.1, 0), stack); scene.idle(15); - scene.world.modifyEntity(entityLink, e -> e.setMotion(-0.2f, 0, 0)); + scene.world.modifyEntity(entityLink, e -> e.setDeltaMovement(-0.2f, 0, 0)); scene.overlay.showControls(new InputWindowElement(itemVec, Pointing.DOWN).withItem(stack), 20); scene.idle(20); scene.effects.emitParticles(itemVec.add(0, 0.2f, 0), Emitter.simple(ParticleTypes.SPIT, Vector3d.ZERO), 1, 60); @@ -221,8 +221,8 @@ public class FanScenes { scene.world.moveSection(blockInFront, util.vector.of(0, 1, 0), 15); scene.world.destroyBlock(blockPos.east()); scene.world.showSection(util.select.position(blockPos.east() - .up()), Direction.DOWN); - scene.world.setBlock(blockPos.up(), Blocks.WATER.getDefaultState(), false); + .above()), Direction.DOWN); + scene.world.setBlock(blockPos.above(), Blocks.WATER.defaultBlockState(), false); ItemStack sand = new ItemStack(Items.SAND); ItemStack clay = new ItemStack(Items.CLAY_BALL); @@ -290,8 +290,8 @@ public class FanScenes { scene.idle(10); scene.world.toggleRedstonePower(util.select.position(pos.north())); scene.effects.indicateRedstone(pos.north()); - scene.world.setKineticSpeed(util.select.fromTo(pos, pos.up()), 4); - scene.effects.rotationSpeedIndicator(pos.up()); + scene.world.setKineticSpeed(util.select.fromTo(pos, pos.above()), 4); + scene.effects.rotationSpeedIndicator(pos.above()); } scene.overlay.showText(90) 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 366547173..069484e61 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 @@ -56,7 +56,7 @@ public class FunnelScenes { for (int i = 0; i < 8; i++) { scene.idle(8); scene.world.removeItemsFromBelt(exitBeltPos); - scene.world.flapFunnel(exitBeltPos.up(), false); + scene.world.flapFunnel(exitBeltPos.above(), false); if (i == 2) scene.rotateCameraY(70); if (i < 6) @@ -67,7 +67,7 @@ public class FunnelScenes { scene.idle(10); Selection outputFunnel = util.select.position(1, 2, 4); - scene.world.setBlocks(outputFunnel, Blocks.AIR.getDefaultState(), false); + scene.world.setBlocks(outputFunnel, Blocks.AIR.defaultBlockState(), false); scene.world.setBlocks(util.select.fromTo(2, -1, 4, 2, 0, 4), AllBlocks.ANDESITE_CASING.getDefaultState(), true); ElementLink independentSection = scene.world.showIndependentSection(verticalFunnel, Direction.UP); @@ -88,8 +88,8 @@ public class FunnelScenes { scene.world.moveSection(independentSection, util.vector.of(0, 1, 0), 15); scene.idle(10); scene.world.setBlocks(outputFunnel, AllBlocks.ANDESITE_FUNNEL.getDefaultState() - .with(FunnelBlock.FACING, Direction.WEST) - .with(FunnelBlock.EXTRACTING, true), false); + .setValue(FunnelBlock.FACING, Direction.WEST) + .setValue(FunnelBlock.EXTRACTING, true), false); for (int i = 0; i < 3; i++) { scene.idle(8); @@ -144,7 +144,7 @@ public class FunnelScenes { scene.idle(20); // Placing funnels with sneak - scene.world.modifyBlock(topFunnel, s -> s.with(FunnelBlock.EXTRACTING, false), false); + scene.world.modifyBlock(topFunnel, s -> s.setValue(FunnelBlock.EXTRACTING, false), false); scene.idle(5); scene.world.showSection(topFunnelSelection, Direction.DOWN); @@ -188,7 +188,7 @@ public class FunnelScenes { // Side funnel BlockPos sideFunnel = util.grid.at(3, 2, 1); - Selection sideFunnelSelection = util.select.fromTo(sideFunnel.down(), sideFunnel); + Selection sideFunnelSelection = util.select.fromTo(sideFunnel.below(), sideFunnel); Vector3d sideCenter = util.vector.centerOf(sideFunnel); scene.world.modifyBlock(sideFunnel, s -> s.cycle(FunnelBlock.EXTRACTING), false); @@ -276,9 +276,9 @@ public class FunnelScenes { .text("Vertical Saws") .colored(PonderPalette.BLUE) .placeNearTarget() - .pointAt(util.vector.centerOf(sawFunnel.down())); + .pointAt(util.vector.centerOf(sawFunnel.below())); scene.idle(8); - scene.world.createItemOnBeltLike(sawFunnel.down(), Direction.SOUTH, new ItemStack(Blocks.OAK_LOG)); + scene.world.createItemOnBeltLike(sawFunnel.below(), Direction.SOUTH, new ItemStack(Blocks.OAK_LOG)); scene.idle(40); scene.world.showSection(util.select.position(depotFunnel), Direction.DOWN); @@ -286,9 +286,9 @@ public class FunnelScenes { .text("Depots") .colored(PonderPalette.BLUE) .placeNearTarget() - .pointAt(util.vector.centerOf(depotFunnel.down())); + .pointAt(util.vector.centerOf(depotFunnel.below())); scene.idle(8); - scene.world.createItemOnBeltLike(depotFunnel.down(), Direction.SOUTH, new ItemStack(Items.GOLDEN_PICKAXE)); + scene.world.createItemOnBeltLike(depotFunnel.below(), Direction.SOUTH, new ItemStack(Items.GOLDEN_PICKAXE)); scene.idle(40); scene.world.showSection(util.select.position(drainFunnel), Direction.DOWN); @@ -296,9 +296,9 @@ public class FunnelScenes { .text("Item Drains") .colored(PonderPalette.BLUE) .placeNearTarget() - .pointAt(util.vector.centerOf(drainFunnel.down())); + .pointAt(util.vector.centerOf(drainFunnel.below())); scene.idle(8); - scene.world.createItemOnBeltLike(drainFunnel.down(), Direction.SOUTH, new ItemStack(Items.WATER_BUCKET)); + scene.world.createItemOnBeltLike(drainFunnel.below(), Direction.SOUTH, new ItemStack(Items.WATER_BUCKET)); scene.idle(40); scene.markAsFinished(); @@ -319,8 +319,8 @@ public class FunnelScenes { BlockPos redstone = util.grid.at(2, 2, 2); BlockPos funnel = util.grid.at(3, 2, 2); - AxisAlignedBB redstoneBB = new AxisAlignedBB(funnel).grow(-1 / 16f, -6 / 16f, -1 / 16f) - .offset(0, -5 / 16f, 0); + AxisAlignedBB redstoneBB = new AxisAlignedBB(funnel).inflate(-1 / 16f, -6 / 16f, -1 / 16f) + .move(0, -5 / 16f, 0); for (int i = 0; i < 4; i++) { if (lastItemEntity != null) @@ -330,7 +330,7 @@ public class FunnelScenes { if (i == 3) { scene.world.modifyBlock(lever, s -> s.cycle(LeverBlock.POWERED), false); - scene.world.modifyBlock(redstone, s -> s.with(RedstoneWireBlock.POWER, 15), false); + scene.world.modifyBlock(redstone, s -> s.setValue(RedstoneWireBlock.POWER, 15), false); scene.world.modifyBlock(funnel, s -> s.cycle(FunnelBlock.POWERED), false); scene.effects.indicateRedstone(lever); scene.idle(4); @@ -377,7 +377,7 @@ public class FunnelScenes { .pointAt(util.vector.topOf(andesiteFunnel)) .placeNearTarget(); scene.idle(10); - scene.world.createItemOnBeltLike(andesiteFunnel.down() + scene.world.createItemOnBeltLike(andesiteFunnel.below() .north(), Direction.SOUTH, itemStack); scene.world.flapFunnel(andesiteFunnel, true); scene.idle(60); @@ -388,13 +388,13 @@ public class FunnelScenes { .pointAt(util.vector.topOf(brassFunnel)) .placeNearTarget(); scene.idle(10); - scene.world.createItemOnBeltLike(brassFunnel.down() + scene.world.createItemOnBeltLike(brassFunnel.below() .north(), Direction.SOUTH, ItemHandlerHelper.copyStackWithSize(itemStack, 64)); scene.world.flapFunnel(brassFunnel, true); scene.idle(60); - AxisAlignedBB filterSlot = new AxisAlignedBB(brassFunnel).grow(-.35, -.35, -.35) - .offset(0, 0.2, 0); + AxisAlignedBB filterSlot = new AxisAlignedBB(brassFunnel).inflate(-.35, -.35, -.35) + .move(0, 0.2, 0); scene.overlay.chaseBoundingBoxOutline(PonderPalette.WHITE, filterSlot, filterSlot, 80); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(brassFunnel), Pointing.DOWN).scroll(), 60); scene.idle(10); @@ -422,12 +422,12 @@ public class FunnelScenes { for (int i = 0; i < 14; i++) { if (i < 12) - scene.world.createItemOnBelt(andesiteFunnel.down(), Direction.SOUTH, + scene.world.createItemOnBelt(andesiteFunnel.below(), Direction.SOUTH, i % 3 == 0 ? dirt : i % 3 == 1 ? gravel : emerald); scene.idle(10); if (i > 0 && (i < 3 || i % 3 == 0)) { - scene.world.removeItemsFromBelt(brassFunnel.down()); + scene.world.removeItemsFromBelt(brassFunnel.below()); scene.world.flapFunnel(brassFunnel, false); } @@ -504,7 +504,7 @@ public class FunnelScenes { scene.idle(20); Selection belt = util.select.layer(1); - scene.world.setBlocks(funnelSelect, Blocks.AIR.getDefaultState(), false); + scene.world.setBlocks(funnelSelect, Blocks.AIR.defaultBlockState(), false); scene.world.showSection(belt, Direction.DOWN); scene.world.showSection(util.select.fromTo(0, 2, 2, 4, 2, 2), Direction.DOWN); scene.overlay.showText(120) 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 d1642ccfd..64e0bd06f 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 @@ -122,7 +122,7 @@ public class GantryScenes { scene.overlay.showText(60) .attachKeyFrame() .colored(PonderPalette.RED) - .pointAt(util.vector.centerOf(cogPos.down() + .pointAt(util.vector.centerOf(cogPos.below() .south())) .text("Redstone-powered gantry shafts stop moving their carriages") .placeNearTarget(); @@ -210,7 +210,7 @@ public class GantryScenes { BlockPos leverPos = util.grid.at(4, 1, 0); scene.world.modifyBlocks(util.select.fromTo(1, 1, 0, 3, 1, 1), - s -> s.contains(RedstoneWireBlock.POWER) ? s.with(RedstoneWireBlock.POWER, 15) : s, false); + s -> s.hasProperty(RedstoneWireBlock.POWER) ? s.setValue(RedstoneWireBlock.POWER, 15) : s, false); scene.world.toggleRedstonePower(util.select.position(leverPos)); scene.world.toggleRedstonePower(shafts); scene.effects.indicateRedstone(leverPos); 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 e98d3cc05..427b31083 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 @@ -90,7 +90,7 @@ public class KineticsScenes { .withItem(andesiteCasingItem), 60); scene.idle(7); scene.world.setBlocks(andesite, andesiteEncased.getDefaultState() - .with(EncasedShaftBlock.AXIS, Axis.X), true); + .setValue(EncasedShaftBlock.AXIS, Axis.X), true); scene.world.setKineticSpeed(shaft, 32); scene.idle(10); @@ -101,7 +101,7 @@ public class KineticsScenes { .withItem(brassCasingItem), 60); scene.idle(7); scene.world.setBlocks(brass, brassEncased.getDefaultState() - .with(EncasedShaftBlock.AXIS, Axis.X), true); + .setValue(EncasedShaftBlock.AXIS, Axis.X), true); scene.world.setKineticSpeed(shaft, 32); scene.idle(10); @@ -154,7 +154,7 @@ public class KineticsScenes { scene.title("large_cogwheel", "Relaying rotational force using Large Cogwheels"); scene.configureBasePlate(1, 1, 5); scene.world.setBlock(util.grid.at(4, 2, 3), AllBlocks.LARGE_COGWHEEL.getDefaultState() - .with(CogWheelBlock.AXIS, Axis.X), false); + .setValue(CogWheelBlock.AXIS, Axis.X), false); scene.showBasePlate(); scene.idle(5); @@ -177,7 +177,7 @@ public class KineticsScenes { scene.world.hideSection(util.select.fromTo(3, 2, 1, 3, 2, 5), Direction.SOUTH); scene.idle(15); - scene.world.modifyBlock(util.grid.at(3, 2, 3), s -> s.with(ShaftBlock.AXIS, Axis.X), false); + scene.world.modifyBlock(util.grid.at(3, 2, 3), s -> s.setValue(ShaftBlock.AXIS, Axis.X), false); scene.world.setKineticSpeed(util.select.fromTo(1, 2, 3, 5, 2, 3), 16); scene.world.showSection(util.select.position(4, 2, 3), Direction.WEST); @@ -209,9 +209,9 @@ public class KineticsScenes { BlockPos lowerCog = util.grid.at(3, 1, 2); BlockPos upperCog = util.grid.at(3, 2, 3); BlockState largeCogState = AllBlocks.LARGE_COGWHEEL.getDefaultState() - .with(CogWheelBlock.AXIS, Axis.X); + .setValue(CogWheelBlock.AXIS, Axis.X); BlockState smallCogState = AllBlocks.COGWHEEL.getDefaultState() - .with(CogWheelBlock.AXIS, Axis.X); + .setValue(CogWheelBlock.AXIS, Axis.X); scene.world.setBlock(lowerCog, largeCogState, false); scene.world.setBlock(upperCog, smallCogState, false); @@ -330,10 +330,10 @@ public class KineticsScenes { BlockState defaultState = AllBlocks.SHAFT.getDefaultState(); BlockState cogState = AllBlocks.COGWHEEL.getDefaultState(); - scene.world.setBlock(largeCogBack, defaultState.with(CogWheelBlock.AXIS, Axis.Z), false); - scene.world.setBlock(largeCogFront, defaultState.with(CogWheelBlock.AXIS, Axis.Z), false); - scene.world.setBlock(largeCogRight, defaultState.with(CogWheelBlock.AXIS, Axis.X), false); - scene.world.setBlock(largeCogLeft, defaultState.with(CogWheelBlock.AXIS, Axis.X), false); + scene.world.setBlock(largeCogBack, defaultState.setValue(CogWheelBlock.AXIS, Axis.Z), false); + scene.world.setBlock(largeCogFront, defaultState.setValue(CogWheelBlock.AXIS, Axis.Z), false); + scene.world.setBlock(largeCogRight, defaultState.setValue(CogWheelBlock.AXIS, Axis.X), false); + scene.world.setBlock(largeCogLeft, defaultState.setValue(CogWheelBlock.AXIS, Axis.X), false); scene.world.showSection(util.select.fromTo(4, 2, 2, 2, 2, 4), Direction.DOWN); scene.idle(20); @@ -345,8 +345,8 @@ public class KineticsScenes { .text("A gearbox is the more compact equivalent of this setup"); scene.idle(90); - scene.world.setBlock(largeCogFront.north(), cogState.with(CogWheelBlock.AXIS, Axis.Z), true); - scene.world.setBlock(largeCogRight.west(), cogState.with(CogWheelBlock.AXIS, Axis.X), true); + scene.world.setBlock(largeCogFront.north(), cogState.setValue(CogWheelBlock.AXIS, Axis.Z), true); + scene.world.setBlock(largeCogRight.west(), cogState.setValue(CogWheelBlock.AXIS, Axis.X), true); scene.idle(10); scene.effects.rotationDirectionIndicator(largeCogFront.north()); scene.effects.rotationDirectionIndicator(largeCogRight.west()); @@ -360,7 +360,7 @@ public class KineticsScenes { scene.world.hideSection(util.select.fromTo(1, 2, 3, 2, 2, 3), Direction.WEST); scene.world.hideSection(util.select.fromTo(4, 2, 3, 5, 2, 3), Direction.EAST); - scene.world.setBlock(largeCogBack.south(), cogState.with(CogWheelBlock.AXIS, Axis.Z), true); + scene.world.setBlock(largeCogBack.south(), cogState.setValue(CogWheelBlock.AXIS, Axis.Z), true); scene.idle(10); scene.effects.rotationDirectionIndicator(largeCogFront.north()); @@ -498,7 +498,7 @@ public class KineticsScenes { Vector3d blockSurface = util.vector.blockSurface(motor, Direction.EAST); AxisAlignedBB point = new AxisAlignedBB(blockSurface, blockSurface); - AxisAlignedBB expanded = point.grow(1 / 16f, 1 / 5f, 1 / 5f); + AxisAlignedBB expanded = point.inflate(1 / 16f, 1 / 5f, 1 / 5f); scene.overlay.chaseBoundingBoxOutline(PonderPalette.WHITE, blockSurface, point, 1); scene.idle(1); @@ -533,7 +533,7 @@ public class KineticsScenes { for (int i = 0; i < 4; i++) { scene.idle(5); scene.world.showSection(util.select.fromTo(gaugePos.east(i) - .down(), gaugePos.east(i)), Direction.DOWN); + .below(), gaugePos.east(i)), Direction.DOWN); } scene.idle(10); @@ -557,17 +557,17 @@ public class KineticsScenes { .pointAt(util.vector.topOf(wheel)); scene.idle(50); - AxisAlignedBB bb = new AxisAlignedBB(wheel).grow(.125f, 0, 0); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, new Object(), bb.offset(0, 1.2, 0) + AxisAlignedBB bb = new AxisAlignedBB(wheel).inflate(.125f, 0, 0); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, new Object(), bb.move(0, 1.2, 0) .contract(0, .75, 0), 80); scene.idle(5); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, new Object(), bb.offset(0, 0, 1.2) + scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, new Object(), bb.move(0, 0, 1.2) .contract(0, 0, .75), 80); scene.idle(5); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, new Object(), bb.offset(0, -1.2, 0) + scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, new Object(), bb.move(0, -1.2, 0) .contract(0, -.75, 0), 80); scene.idle(5); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, new Object(), bb.offset(0, 0, -1.2) + scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, new Object(), bb.move(0, 0, -1.2) .contract(0, 0, -.75), 80); scene.idle(5); scene.overlay.showText(50) @@ -595,7 +595,7 @@ public class KineticsScenes { scene.idle(10); scene.world.rotateSection(wheelElement, 0, 180, 0, 5); scene.idle(10); - scene.world.modifyBlock(wheel, s -> s.with(WaterWheelBlock.FACING, Direction.WEST), false); + scene.world.modifyBlock(wheel, s -> s.setValue(WaterWheelBlock.FACING, Direction.WEST), false); scene.world.rotateSection(wheelElement, 0, -180, 0, 0); scene.idle(1); scene.world.moveSection(water, util.vector.of(0, -2, 2), 10); @@ -618,7 +618,7 @@ public class KineticsScenes { scene.rotateCameraY(30); scene.world.rotateSection(wheelElement, 0, 180, 0, 5); scene.idle(10); - scene.world.modifyBlock(wheel, s -> s.with(WaterWheelBlock.FACING, Direction.EAST), false); + scene.world.modifyBlock(wheel, s -> s.setValue(WaterWheelBlock.FACING, Direction.EAST), false); scene.world.rotateSection(wheelElement, 0, -180, 0, 0); scene.idle(1); scene.world.moveSection(water, util.vector.of(0, -2, 2), 10); @@ -641,7 +641,7 @@ public class KineticsScenes { .withItem(new ItemStack(Items.BLUE_DYE)), 40); scene.idle(7); scene.world.modifyBlock(util.grid.at(2, 2, 2), s -> AllBlocks.DYED_VALVE_HANDLES.get(DyeColor.BLUE).getDefaultState() - .with(ValveHandleBlock.FACING, Direction.UP), true); + .setValue(ValveHandleBlock.FACING, Direction.UP), true); scene.idle(10); scene.overlay.showText(70) .text("Valve handles can be dyed for aesthetic purposes") @@ -861,7 +861,7 @@ public class KineticsScenes { scene.world.cycleBlockProperty(gearshiftPos, SequencedGearshiftBlock.STATE); scene.world.cycleBlockProperty(gearshiftPos, SequencedGearshiftBlock.STATE); - scene.world.modifyBlock(wire, s -> s.with(RedstoneWireBlock.POWER, 0), false); + scene.world.modifyBlock(wire, s -> s.setValue(RedstoneWireBlock.POWER, 0), false); scene.world.toggleRedstonePower(util.select.position(5, 1, 1)); scene.world.modifyTileNBT(nixie, NixieTubeTileEntity.class, nbt -> nbt.putInt("RedstoneStrength", 0)); scene.world.setKineticSpeed(outputKinetics, 0); @@ -937,9 +937,9 @@ public class KineticsScenes { scene.idle(10); scene.world.hideSection(furnaceSelect, Direction.NORTH); scene.idle(15); - scene.world.setBlock(furnacePos, Blocks.BLAST_FURNACE.getDefaultState() - .with(FurnaceBlock.FACING, Direction.NORTH) - .with(FurnaceBlock.LIT, true), false); + scene.world.setBlock(furnacePos, Blocks.BLAST_FURNACE.defaultBlockState() + .setValue(FurnaceBlock.FACING, Direction.NORTH) + .setValue(FurnaceBlock.LIT, true), false); scene.world.showSection(furnaceSelect, Direction.NORTH); scene.idle(10); scene.world.moveSection(engine, util.vector.of(0, -1, 0), 15); @@ -1052,7 +1052,7 @@ public class KineticsScenes { scene.idle(10); scene.world.setBlock(gaugePos, (speed ? AllBlocks.SPEEDOMETER : AllBlocks.STRESSOMETER).getDefaultState() - .with(GaugeBlock.FACING, Direction.UP), true); + .setValue(GaugeBlock.FACING, Direction.UP), true); scene.world.setKineticSpeed(util.select.position(gaugePos), 32); scene.idle(10); @@ -1072,7 +1072,7 @@ public class KineticsScenes { } else { BlockState state = AllBlocks.CRUSHING_WHEEL.getDefaultState() - .with(CrushingWheelBlock.AXIS, Axis.X); + .setValue(CrushingWheelBlock.AXIS, Axis.X); scene.world.setBlock(util.grid.at(5, 1, 3), state, true); scene.world.setKineticSpeed(util.select.position(5, 1, 3), 32); scene.world.modifyTileNBT(util.select.position(gaugePos), StressGaugeTileEntity.class, diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/MechanicalDrillScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/MechanicalDrillScenes.java index ea3e48654..6d17ab6cb 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/MechanicalDrillScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/MechanicalDrillScenes.java @@ -60,7 +60,7 @@ public class MechanicalDrillScenes { scene.world.modifyKineticSpeed(util.select.everywhere(), f -> 4 * f); scene.effects.rotationSpeedIndicator(breakingPos.east(3)); scene.idle(5); - scene.world.setBlock(breakingPos, Blocks.OAK_PLANKS.getDefaultState(), false); + scene.world.setBlock(breakingPos, Blocks.OAK_PLANKS.defaultBlockState(), false); scene.world.showSection(util.select.position(breakingPos), Direction.DOWN); scene.idle(5); @@ -161,7 +161,7 @@ public class MechanicalDrillScenes { scene.world.hideSection(planks, Direction.UP); scene.idle(40); - scene.world.setBlocks(planks, Blocks.OAK_PLANKS.getDefaultState(), false); + scene.world.setBlocks(planks, Blocks.OAK_PLANKS.defaultBlockState(), false); scene.world.modifyEntities(ItemEntity.class, Entity::remove); scene.world.glueBlockOnto(util.grid.at(4, 3, 2), Direction.DOWN, contraption); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/MechanicalSawScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/MechanicalSawScenes.java index a916b39e4..6c254844e 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/MechanicalSawScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/MechanicalSawScenes.java @@ -31,7 +31,7 @@ public class MechanicalSawScenes { BlockPos shaftPos = util.grid.at(2, 1, 3); scene.world.setBlock(shaftPos, AllBlocks.SHAFT.getDefaultState() - .with(ShaftBlock.AXIS, Axis.Z), false); + .setValue(ShaftBlock.AXIS, Axis.Z), false); BlockPos sawPos = util.grid.at(2, 1, 2); Selection sawSelect = util.select.position(sawPos); @@ -54,7 +54,7 @@ public class MechanicalSawScenes { ItemStack strippedLog = new ItemStack(Items.STRIPPED_OAK_LOG); ItemStack planks = new ItemStack(Items.OAK_PLANKS); - Vector3d itemSpawn = util.vector.centerOf(sawPos.up() + Vector3d itemSpawn = util.vector.centerOf(sawPos.above() .west()); ElementLink logItem = scene.world.createItemEntity(itemSpawn, util.vector.of(0, 0, 0), log); scene.idle(12); @@ -62,7 +62,7 @@ public class MechanicalSawScenes { scene.overlay.showControls(new InputWindowElement(itemSpawn, Pointing.DOWN).withItem(log), 20); scene.idle(10); - scene.world.modifyEntity(logItem, e -> e.setMotion(util.vector.of(0.05, 0.2, 0))); + scene.world.modifyEntity(logItem, e -> e.setDeltaMovement(util.vector.of(0.05, 0.2, 0))); scene.idle(12); scene.world.modifyEntity(logItem, Entity::remove); @@ -85,7 +85,7 @@ public class MechanicalSawScenes { scene.world.modifyKineticSpeed(util.select.everywhere(), f -> -2 * f); scene.effects.rotationDirectionIndicator(shaftPos); - scene.world.modifyEntity(logItem, e -> e.setMotion(util.vector.of(-0.05, 0.2, 0))); + scene.world.modifyEntity(logItem, e -> e.setDeltaMovement(util.vector.of(-0.05, 0.2, 0))); scene.idle(12); scene.world.modifyEntity(logItem, Entity::remove); @@ -104,7 +104,7 @@ public class MechanicalSawScenes { scene.world.modifyKineticSpeed(util.select.everywhere(), f -> -f); scene.world.modifyEntity(logItem, Entity::remove); scene.world.setBlock(shaftPos, AllBlocks.COGWHEEL.getDefaultState() - .with(ShaftBlock.AXIS, Axis.Z), true); + .setValue(ShaftBlock.AXIS, Axis.Z), true); scene.idle(3); scene.addKeyframe(); @@ -174,7 +174,7 @@ public class MechanicalSawScenes { scene.title("mechanical_saw_breaker", "Cutting Trees with the Mechanical Saw"); scene.configureBasePlate(0, 0, 5); scene.scaleSceneView(.9f); - scene.world.setBlock(util.grid.at(2, 0, 2), Blocks.GRASS_BLOCK.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 0, 2), Blocks.GRASS_BLOCK.defaultBlockState(), false); scene.world.showSection(util.select.layer(0) .add(util.select.position(3, 1, 1)) .add(util.select.position(1, 1, 2)), Direction.UP); @@ -205,7 +205,7 @@ public class MechanicalSawScenes { } } - scene.world.replaceBlocks(util.select.fromTo(2, 2, 2, 2, 6, 2), Blocks.AIR.getDefaultState(), true); + scene.world.replaceBlocks(util.select.fromTo(2, 2, 2, 2, 6, 2), Blocks.AIR.defaultBlockState(), true); scene.world.destroyBlock(util.grid.at(3, 5, 0)); scene.world.destroyBlock(util.grid.at(0, 4, 1)); @@ -215,10 +215,10 @@ public class MechanicalSawScenes { scene.world.destroyBlock(util.grid.at(1, 5, 3)); scene.world.destroyBlock(util.grid.at(0, 4, 3)); - scene.world.replaceBlocks(util.select.layersFrom(4), Blocks.AIR.getDefaultState(), false); + scene.world.replaceBlocks(util.select.layersFrom(4), Blocks.AIR.defaultBlockState(), false); for (int i = 0; i < 5; i++) { - Vector3d dropPos = util.vector.centerOf(breakingPos.up(i)); + Vector3d dropPos = util.vector.centerOf(breakingPos.above(i)); float distance = (float) dropPos.distanceTo(util.vector.centerOf(breakingPos)); scene.world.createItemEntity(dropPos, util.vector.of(-distance / 20, 0, 0), new ItemStack(Items.OAK_LOG)); } @@ -229,7 +229,7 @@ public class MechanicalSawScenes { .add(util.select.fromTo(2, 1, 2, 1, 1, 3)), Direction.UP); scene.world.modifyEntities(ItemEntity.class, Entity::remove); scene.idle(15); - scene.world.setBlocks(util.select.fromTo(2, 1, 2, 1, 20, 3), Blocks.JUNGLE_LOG.getDefaultState(), false); + scene.world.setBlocks(util.select.fromTo(2, 1, 2, 1, 20, 3), Blocks.JUNGLE_LOG.defaultBlockState(), false); scene.world.showSection(util.select.layersFrom(2) .add(util.select.fromTo(2, 1, 2, 1, 1, 3)), Direction.UP); scene.idle(15); @@ -250,7 +250,7 @@ public class MechanicalSawScenes { } for (int i = 0; i < 30; i++) { - scene.world.replaceBlocks(util.select.fromTo(2, i + 1, 2, 1, i + 1, 3), Blocks.AIR.getDefaultState(), true); + scene.world.replaceBlocks(util.select.fromTo(2, i + 1, 2, 1, i + 1, 3), Blocks.AIR.defaultBlockState(), true); for (int x = 1; x <= 2; x++) { for (int z = 2; z <= 3; z++) { Vector3d dropPos = util.vector.centerOf(x, i + 1, z); @@ -267,7 +267,7 @@ public class MechanicalSawScenes { scene.title("mechanical_saw_contraption", "Using Mechanical Saws on Contraptions"); scene.configureBasePlate(1, 0, 6); scene.scaleSceneView(.9f); - scene.world.setBlock(util.grid.at(2, 0, 3), Blocks.GRASS_BLOCK.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 0, 3), Blocks.GRASS_BLOCK.defaultBlockState(), false); scene.world.showSection(util.select.layer(0) .add(util.select.position(3, 1, 1)) .add(util.select.position(1, 1, 2)) @@ -321,7 +321,7 @@ public class MechanicalSawScenes { } } - scene.world.replaceBlocks(util.select.fromTo(2, 2, 3, 2, 6, 3), Blocks.AIR.getDefaultState(), true); + scene.world.replaceBlocks(util.select.fromTo(2, 2, 3, 2, 6, 3), Blocks.AIR.defaultBlockState(), true); scene.world.destroyBlock(util.grid.at(4, 5, 1)); scene.world.destroyBlock(util.grid.at(1, 4, 2)); scene.world.destroyBlock(util.grid.at(3, 6, 2)); @@ -329,10 +329,10 @@ public class MechanicalSawScenes { scene.world.destroyBlock(util.grid.at(2, 6, 3)); scene.world.destroyBlock(util.grid.at(2, 5, 2)); scene.world.destroyBlock(util.grid.at(1, 4, 2)); - scene.world.replaceBlocks(util.select.layersFrom(4), Blocks.AIR.getDefaultState(), false); + scene.world.replaceBlocks(util.select.layersFrom(4), Blocks.AIR.defaultBlockState(), false); for (int i = 0; i < 5; i++) { - Vector3d dropPos = util.vector.centerOf(breakingPos.up(i)); + Vector3d dropPos = util.vector.centerOf(breakingPos.above(i)); float distance = (float) dropPos.distanceTo(util.vector.centerOf(breakingPos)); scene.world.createItemEntity(dropPos, util.vector.of(-distance / 20, 0, 0), new ItemStack(Items.OAK_LOG)); } @@ -372,7 +372,7 @@ public class MechanicalSawScenes { scene.world.incrementBlockBreakingProgress(breakingPos); } - scene.world.replaceBlocks(util.select.fromTo(2, 2, 3, 2, 6, 3), Blocks.AIR.getDefaultState(), true); + scene.world.replaceBlocks(util.select.fromTo(2, 2, 3, 2, 6, 3), Blocks.AIR.defaultBlockState(), true); scene.world.destroyBlock(util.grid.at(4, 5, 1)); scene.world.destroyBlock(util.grid.at(1, 4, 2)); scene.world.destroyBlock(util.grid.at(3, 6, 2)); @@ -380,7 +380,7 @@ public class MechanicalSawScenes { scene.world.destroyBlock(util.grid.at(2, 6, 3)); scene.world.destroyBlock(util.grid.at(2, 5, 2)); scene.world.destroyBlock(util.grid.at(1, 4, 2)); - scene.world.replaceBlocks(util.select.layersFrom(4), Blocks.AIR.getDefaultState(), false); + scene.world.replaceBlocks(util.select.layersFrom(4), Blocks.AIR.defaultBlockState(), false); scene.world.moveSection(pistonHead, util.vector.of(-1, 0, 0), 20); scene.world.moveSection(contraption, util.vector.of(-1, 0, 0), 20); 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 b34014ada..db1125dbe 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 @@ -47,7 +47,7 @@ public class MovementActorScenes { scene.world.rotateBearing(bearing, 360, 70); scene.world.rotateSection(contraption, 0, 360, 0, 70); scene.overlay.showText(60) - .pointAt(util.vector.topOf(bearing.up(2))) + .pointAt(util.vector.topOf(bearing.above(2))) .colored(PonderPalette.RED) .placeNearTarget() .attachKeyFrame() @@ -115,7 +115,7 @@ public class MovementActorScenes { .text("Items can now be inserted..."); ItemStack itemStack = AllItems.COPPER_INGOT.asStack(); - Vector3d entitySpawn = util.vector.topOf(hopper.up(3)); + Vector3d entitySpawn = util.vector.topOf(hopper.above(3)); ElementLink entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), itemStack); @@ -140,7 +140,7 @@ public class MovementActorScenes { scene.world.createItemOnBelt(beltPos, Direction.EAST, itemStack.copy()); scene.overlay.showText(40) .placeNearTarget() - .pointAt(util.vector.topOf(beltPos.up())) + .pointAt(util.vector.topOf(beltPos.above())) .text("...or extracted from the contraption"); scene.idle(15); scene.world.createItemOnBelt(beltPos, Direction.EAST, itemStack); @@ -213,8 +213,8 @@ public class MovementActorScenes { .add(util.select.position(2, 1, 3)) .add(util.select.position(1, 1, 2))); - scene.world.setBlocks(crops, Blocks.WHEAT.getDefaultState() - .with(CropsBlock.AGE, 7), false); + scene.world.setBlocks(crops, Blocks.WHEAT.defaultBlockState() + .setValue(CropsBlock.AGE, 7), false); scene.world.showSection(util.select.layer(0), Direction.UP); BlockPos bearingPos = util.grid.at(4, 1, 4); @@ -247,7 +247,7 @@ public class MovementActorScenes { scene.world.rotateBearing(bearingPos, -360, 140); scene.world.rotateSection(contraption, 0, -360, 0, 140); - BlockState harvested = Blocks.WHEAT.getDefaultState(); + BlockState harvested = Blocks.WHEAT.defaultBlockState(); ItemStack wheatItem = new ItemStack(Items.WHEAT); scene.idle(5); @@ -283,8 +283,8 @@ public class MovementActorScenes { scene.world.hideSection(crops, Direction.DOWN); scene.idle(15); scene.world.modifyEntities(ItemEntity.class, Entity::remove); - scene.world.setBlocks(crops, Blocks.WHEAT.getDefaultState() - .with(CropsBlock.AGE, 7), false); + scene.world.setBlocks(crops, Blocks.WHEAT.defaultBlockState() + .setValue(CropsBlock.AGE, 7), false); scene.world.showSection(crops, Direction.UP); for (int i = 0; i < 3; i++) @@ -399,7 +399,7 @@ public class MovementActorScenes { scene.world.moveSection(contraption, util.vector.of(2, 0, 0), 40); scene.world.hideSection(garbage, Direction.UP); scene.idle(40); - scene.world.setBlocks(garbage, Blocks.SNOW.getDefaultState(), false); + scene.world.setBlocks(garbage, Blocks.SNOW.defaultBlockState(), false); scene.world.modifyEntities(ItemEntity.class, Entity::remove); ElementLink chest = scene.world.showIndependentSection(util.select.position(4, 2, 2), Direction.DOWN); @@ -440,7 +440,7 @@ public class MovementActorScenes { Selection dirt = util.select.fromTo(2, 0, 3, 1, 0, 2); scene.world.hideSection(dirt, Direction.DOWN); scene.idle(15); - scene.world.setBlocks(dirt, Blocks.GRASS_BLOCK.getDefaultState(), false); + scene.world.setBlocks(dirt, Blocks.GRASS_BLOCK.defaultBlockState(), false); scene.world.showSection(dirt, Direction.UP); scene.overlay.showText(60) .placeNearTarget() @@ -454,9 +454,9 @@ public class MovementActorScenes { scene.world.moveSection(contraption, util.vector.of(-2, 0, 0), 60); scene.world.moveSection(chest, util.vector.of(-2, 0, 0), 60); scene.idle(15); - scene.world.setBlocks(util.select.fromTo(2, 0, 2, 2, 0, 3), Blocks.FARMLAND.getDefaultState(), true); + scene.world.setBlocks(util.select.fromTo(2, 0, 2, 2, 0, 3), Blocks.FARMLAND.defaultBlockState(), true); scene.idle(30); - scene.world.setBlocks(util.select.fromTo(1, 0, 2, 1, 0, 3), Blocks.FARMLAND.getDefaultState(), true); + scene.world.setBlocks(util.select.fromTo(1, 0, 2, 1, 0, 3), Blocks.FARMLAND.defaultBlockState(), true); scene.idle(20); scene.world.modifyKineticSpeed(util.select.everywhere(), f -> -f); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PistonScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PistonScenes.java index 65e73a6cf..8994e1667 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PistonScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PistonScenes.java @@ -51,7 +51,7 @@ public class PistonScenes { scene.idle(15); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.modifyKineticSpeed(kinetics, f -> -f); scene.effects.rotationDirectionIndicator(shaft); scene.world.moveSection(contraption, util.vector.of(-2, 0, 0), 40); @@ -66,10 +66,10 @@ public class PistonScenes { .pointAt(util.vector.blockSurface(shaft, Direction.SOUTH)) .placeNearTarget() .text("Speed and direction of movement depend on the Rotational Input"); - scene.world.setBlock(util.grid.at(2, 1, 1), Blocks.AIR.getDefaultState(), false); - scene.world.setBlock(util.grid.at(0, 1, 2), Blocks.OAK_PLANKS.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 1, 1), Blocks.AIR.defaultBlockState(), false); + scene.world.setBlock(util.grid.at(0, 1, 2), Blocks.OAK_PLANKS.defaultBlockState(), false); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.modifyKineticSpeed(kinetics, f -> -f); scene.effects.rotationDirectionIndicator(shaft); scene.world.moveSection(contraption, util.vector.of(2, 0, 0), 40); @@ -80,12 +80,12 @@ public class PistonScenes { .withItem(new ItemStack(Items.SLIME_BALL)), 30); scene.idle(7); - scene.world.modifyBlock(piston.north(), s -> s.with(MechanicalPistonHeadBlock.TYPE, PistonType.STICKY), false); + scene.world.modifyBlock(piston.north(), s -> s.setValue(MechanicalPistonHeadBlock.TYPE, PistonType.STICKY), false); scene.effects.superGlue(piston, Direction.WEST, true); scene.idle(33); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.modifyKineticSpeed(kinetics, f -> -f); scene.effects.rotationDirectionIndicator(shaft); scene.world.moveSection(contraption, util.vector.of(-2, 0, 0), 40); @@ -97,16 +97,16 @@ public class PistonScenes { .attachKeyFrame() .text("Sticky Mechanical Pistons can pull the attached blocks back"); scene.idle(20); - scene.world.setBlock(util.grid.at(2, 1, 1), Blocks.OAK_PLANKS.getDefaultState(), false); - scene.world.setBlock(util.grid.at(0, 1, 2), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 1, 1), Blocks.OAK_PLANKS.defaultBlockState(), false); + scene.world.setBlock(util.grid.at(0, 1, 2), Blocks.AIR.defaultBlockState(), false); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.modifyKineticSpeed(kinetics, f -> -f); scene.effects.rotationDirectionIndicator(shaft); scene.world.moveSection(contraption, util.vector.of(2, 0, 0), 40); scene.idle(50); - scene.world.setBlock(util.grid.at(2, 1, 1), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 1, 1), Blocks.AIR.defaultBlockState(), false); ElementLink chassis = scene.world.showIndependentSection(util.select.fromTo(2, 2, 0, 2, 3, 2), Direction.DOWN); scene.world.moveSection(chassis, util.vector.of(0, -1, 1), 0); @@ -123,7 +123,7 @@ public class PistonScenes { scene.idle(90); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.modifyKineticSpeed(kinetics, f -> -f); scene.effects.rotationDirectionIndicator(shaft); scene.world.moveSection(contraption, util.vector.of(-2, 0, 0), 40); @@ -150,7 +150,7 @@ public class PistonScenes { BlockPos leverPos = util.grid.at(3, 2, 4); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.setKineticSpeed(kinetics, 16); scene.idle(10); @@ -162,7 +162,7 @@ public class PistonScenes { scene.idle(60); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.setKineticSpeed(kinetics, 0); scene.idle(5); scene.world.showSectionAndMerge(util.select.position(piston.north() @@ -189,7 +189,7 @@ public class PistonScenes { scene.idle(15); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.setKineticSpeed(kinetics, 16); scene.world.moveSection(contraption, util.vector.of(-2, 0, 0), 40); scene.special.moveParrot(birb, util.vector.of(-2, 0, 0), 40); @@ -226,13 +226,13 @@ public class PistonScenes { scene.idle(5); scene.world.showSectionAndMerge(util.select.position(piston.north() .west() - .up()), Direction.DOWN, contraption); + .above()), Direction.DOWN, contraption); scene.idle(15); scene.effects.superGlue(piston.west(), Direction.UP, true); scene.idle(10); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.modifyKineticSpeed(kinetics, f -> -f); scene.effects.rotationDirectionIndicator(shaft); scene.world.moveSection(contraption, util.vector.of(-2, 0, 0), 40); @@ -248,16 +248,16 @@ public class PistonScenes { scene.idle(80); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.modifyKineticSpeed(kinetics, f -> -f); scene.effects.rotationDirectionIndicator(shaft); scene.world.moveSection(contraption, util.vector.of(2, 0, 0), 40); scene.world.hideSection(rose, Direction.UP); scene.idle(50); - scene.world.setBlock(util.grid.at(0, 1, 2), Blocks.ROSE_BUSH.getDefaultState(), false); - scene.world.setBlock(util.grid.at(0, 2, 2), Blocks.ROSE_BUSH.getDefaultState() - .with(DoublePlantBlock.HALF, DoubleBlockHalf.UPPER), false); + scene.world.setBlock(util.grid.at(0, 1, 2), Blocks.ROSE_BUSH.defaultBlockState(), false); + scene.world.setBlock(util.grid.at(0, 2, 2), Blocks.ROSE_BUSH.defaultBlockState() + .setValue(DoublePlantBlock.HALF, DoubleBlockHalf.UPPER), false); scene.world.showIndependentSection(rose, Direction.DOWN); scene.overlay.showCenteredScrollInput(piston, Direction.UP, 60); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(piston), Pointing.DOWN).scroll() @@ -270,7 +270,7 @@ public class PistonScenes { scene.idle(80); scene.effects.indicateRedstone(leverPos); - scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.down())); + scene.world.toggleRedstonePower(util.select.fromTo(leverPos, leverPos.below())); scene.world.modifyKineticSpeed(kinetics, f -> -f); scene.effects.rotationDirectionIndicator(shaft); scene.world.moveSection(contraption, util.vector.of(-2, 0, 0), 40); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapter.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapter.java index 616708342..7508bd85a 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapter.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapter.java @@ -23,12 +23,12 @@ public class PonderChapter implements IScreenRenderable { @Override public void draw(MatrixStack ms, AbstractGui screen, int x, int y) { - ms.push(); - Minecraft.getInstance().getTextureManager().bindTexture(icon); + ms.pushPose(); + Minecraft.getInstance().getTextureManager().bind(icon); ms.scale(0.25f, 0.25f, 1); //x and y offset, blit z offset, tex x and y, tex width and height, entire tex sheet width and height - AbstractGui.drawTexture(ms, x, y, 0, 0, 0, 64, 64, 64, 64); - ms.pop(); + AbstractGui.blit(ms, x, y, 0, 0, 0, 64, 64, 64, 64); + ms.popPose(); } @Nonnull 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 3e7936354..ee2141bb4 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 @@ -137,9 +137,9 @@ public class PonderIndexScreen extends NavigatableSimiScreen { PonderUI.ponderTicks++; hoveredItem = ItemStack.EMPTY; - MainWindow w = client.getWindow(); - double mouseX = client.mouseHelper.getMouseX() * w.getScaledWidth() / w.getWidth(); - double mouseY = client.mouseHelper.getMouseY() * w.getScaledHeight() / w.getHeight(); + MainWindow w = minecraft.getWindow(); + double mouseX = minecraft.mouseHandler.xpos() * w.getGuiScaledWidth() / w.getScreenWidth(); + double mouseY = minecraft.mouseHandler.ypos() * w.getGuiScaledHeight() / w.getScreenHeight(); for (Widget widget : widgets) { if (widget instanceof PonderButton) if (widget.isMouseOver(mouseX, mouseY)) { @@ -154,25 +154,25 @@ public class PonderIndexScreen extends NavigatableSimiScreen { int y = (int) (height * chapterYmult); if (!chapters.isEmpty()) { - ms.push(); + ms.pushPose(); ms.translate(x, y, 0); UIRenderHelper.streak(ms, 0, chapterArea.getX() - 10, chapterArea.getY() - 20, 20, 220); - textRenderer.draw(ms, "Topics to Ponder about", chapterArea.getX() - 5, chapterArea.getY() - 25, Theme.i(Theme.Key.TEXT)); + font.draw(ms, "Topics to Ponder about", chapterArea.getX() - 5, chapterArea.getY() - 25, Theme.i(Theme.Key.TEXT)); - ms.pop(); + ms.popPose(); } x = (int) (width * itemXmult); y = (int) (height * itemYmult); - ms.push(); + ms.pushPose(); ms.translate(x, y, 0); UIRenderHelper.streak(ms, 0, itemArea.getX() - 10, itemArea.getY() - 20, 20, 220); - textRenderer.draw(ms, "Items to inspect", itemArea.getX() - 5, itemArea.getY() - 25, Theme.i(Theme.Key.TEXT)); + font.draw(ms, "Items to inspect", itemArea.getX() - 5, itemArea.getY() - 25, Theme.i(Theme.Key.TEXT)); - ms.pop(); + ms.popPose(); } @Override @@ -180,12 +180,12 @@ public class PonderIndexScreen extends NavigatableSimiScreen { if (hoveredItem.isEmpty()) return; - ms.push(); + ms.pushPose(); ms.translate(0, 0, 200); renderTooltip(ms, hoveredItem, mouseX, mouseY); - ms.pop(); + ms.popPose(); } /*@Override diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTag.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTag.java index db8f3385f..2eef66adf 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTag.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTag.java @@ -145,23 +145,23 @@ public class PonderTag implements IScreenRenderable { @Override @OnlyIn(Dist.CLIENT) public void draw(MatrixStack ms, AbstractGui screen, int x, int y) { - ms.push(); + ms.pushPose(); ms.translate(x, y, 0); if (icon != null) { Minecraft.getInstance() .getTextureManager() - .bindTexture(icon); + .bind(icon); ms.scale(0.25f, 0.25f, 1); // x and y offset, blit z offset, tex x and y, tex width and height, entire tex // sheet width and height - AbstractGui.drawTexture(ms, 0, 0, 0, 0, 0, 64, 64, 64, 64); + AbstractGui.blit(ms, 0, 0, 0, 0, 0, 64, 64, 64, 64); } else if (!itemIcon.isEmpty()) { ms.translate(-4, -4, 0); ms.scale(1.5f, 1.5f, 1.5f); GuiGameElement.of(itemIcon) .render(ms); } - ms.pop(); + ms.popPose(); } // Load class diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagIndexScreen.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagIndexScreen.java index ff6ae2a10..24b4dc107 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagIndexScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagIndexScreen.java @@ -83,9 +83,9 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { PonderUI.ponderTicks++; hoveredItem = null; - MainWindow w = client.getWindow(); - double mouseX = client.mouseHelper.getMouseX() * w.getScaledWidth() / w.getWidth(); - double mouseY = client.mouseHelper.getMouseY() * w.getScaledHeight() / w.getHeight(); + MainWindow w = minecraft.getWindow(); + double mouseX = minecraft.mouseHandler.xpos() * w.getGuiScaledWidth() / w.getScreenWidth(); + double mouseY = minecraft.mouseHandler.ypos() * w.getGuiScaledHeight() / w.getScreenHeight(); for (Widget widget : widgets) { if (widget == backTrack) continue; @@ -104,10 +104,10 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { renderItems(ms, mouseX, mouseY, partialTicks); - ms.push(); + ms.pushPose(); ms.translate(width / 2 - 120, height * mainYmult - 40, 0); - ms.push(); + ms.pushPose(); // ms.translate(0, 0, 800); int x = 31 + 20 + 8; int y = 31; @@ -124,32 +124,32 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { .withBounds(30, 30) .render(ms); - textRenderer.draw(ms, title, x + 8, y + 1, Theme.i(Theme.Key.TEXT)); + font.draw(ms, title, x + 8, y + 1, Theme.i(Theme.Key.TEXT)); // y += 8; // x += 0; // ms.translate(x, y, 0); // ms.translate(0, 0, 5); // textRenderer.draw(ms, title, 0, 0, Theme.i(Theme.Key.TEXT)); - ms.pop(); + ms.popPose(); - ms.push(); + ms.pushPose(); ms.translate(23, 23, 10); ms.scale(1.66f, 1.66f, 1.66f); ms.translate(-4, -4, 0); ms.scale(1.5f, 1.5f, 1.5f); GuiGameElement.of(AllItems.WRENCH.asStack()) .render(ms); - ms.pop(); - ms.pop(); + ms.popPose(); + ms.popPose(); - ms.push(); + ms.pushPose(); int w = (int) (width * .45); x = (width - w) / 2; y = getItemsY() - 10 + Math.max(itemArea.getHeight(), 48); String desc = Lang.translate(DESCRIPTION) .getString(); - int h = textRenderer.getWordWrappedHeight(desc, w); + int h = font.wordWrapHeight(desc, w); // PonderUI.renderBox(ms, x - 3, y - 3, w + 6, h + 6, false); new BoxElement().withBackground(Theme.c(Theme.Key.PONDER_BACKGROUND_FLAT)) @@ -159,8 +159,8 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { .render(ms); ms.translate(0, 0, 100); - FontHelper.drawSplitString(ms, textRenderer, desc, x, y, w, Theme.i(Theme.Key.TEXT)); - ms.pop(); + FontHelper.drawSplitString(ms, font, desc, x, y, w, Theme.i(Theme.Key.TEXT)); + ms.popPose(); } protected void renderItems(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { @@ -173,9 +173,9 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { String relatedTitle = Lang.translate(CATEGORIES) .getString(); - int stringWidth = textRenderer.getStringWidth(relatedTitle); + int stringWidth = font.width(relatedTitle); - ms.push(); + ms.pushPose(); ms.translate(x, y, 0); // PonderUI.renderBox(ms, (sWidth - stringWidth) / 2 - 5, itemArea.getY() - 21, // stringWidth + 10, 10, false); @@ -188,14 +188,14 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { ms.translate(0, 0, 200); // UIRenderHelper.streak(0, itemArea.getX() - 10, itemArea.getY() - 20, 20, 180, 0x101010); - drawCenteredString(ms, textRenderer, relatedTitle, windowWidth / 2, itemArea.getY() - 20, Theme.i(Theme.Key.TEXT)); + drawCenteredString(ms, font, relatedTitle, windowWidth / 2, itemArea.getY() - 20, Theme.i(Theme.Key.TEXT)); ms.translate(0, 0, -200); UIRenderHelper.streak(ms, 0, 0, 0, itemArea.getHeight() + 10, itemArea.getWidth() / 2 + 75); UIRenderHelper.streak(ms, 180, 0, 0, itemArea.getHeight() + 10, itemArea.getWidth() / 2 + 75); - ms.pop(); + ms.popPose(); } @@ -205,7 +205,7 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { @Override protected void renderWindowForeground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - ms.push(); + ms.pushPose(); RenderSystem.disableRescaleNormal(); RenderSystem.disableDepthTest(); @@ -214,11 +214,11 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { List list = TooltipHelper.cutStringTextComponent(hoveredItem.getDescription(), TextFormatting.GRAY, TextFormatting.GRAY); list.add(0, new StringTextComponent(hoveredItem.getTitle())); - renderTooltip(ms, list, mouseX, mouseY); + renderComponentTooltip(ms, list, mouseX, mouseY); } RenderSystem.enableDepthTest(); RenderSystem.enableRescaleNormal(); - ms.pop(); + ms.popPose(); } @Override 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 c861360e2..5b85fa1e0 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 @@ -162,9 +162,9 @@ public class PonderTagScreen extends NavigatableSimiScreen { PonderUI.ponderTicks++; hoveredItem = ItemStack.EMPTY; - MainWindow w = client.getWindow(); - double mouseX = client.mouseHelper.getMouseX() * w.getScaledWidth() / w.getWidth(); - double mouseY = client.mouseHelper.getMouseY() * w.getScaledHeight() / w.getHeight(); + MainWindow w = minecraft.getWindow(); + double mouseX = minecraft.mouseHandler.xpos() * w.getGuiScaledWidth() / w.getScreenWidth(); + double mouseY = minecraft.mouseHandler.ypos() * w.getGuiScaledHeight() / w.getScreenHeight(); for (Widget widget : widgets) { if (widget == backTrack) continue; @@ -181,10 +181,10 @@ public class PonderTagScreen extends NavigatableSimiScreen { renderChapters(ms, mouseX, mouseY, partialTicks); - ms.push(); + ms.pushPose(); ms.translate(width / 2 - 120, height * mainYmult - 40, 0); - ms.push(); + ms.pushPose(); //ms.translate(0, 0, 800); int x = 31 + 20 + 8; int y = 31; @@ -201,28 +201,28 @@ public class PonderTagScreen extends NavigatableSimiScreen { .withBounds(30, 30) .render(ms); - textRenderer.draw(ms, Lang.translate(PonderUI.PONDERING), x, y - 6, Theme.i(Theme.Key.TEXT_DARKER)); + font.draw(ms, Lang.translate(PonderUI.PONDERING), x, y - 6, Theme.i(Theme.Key.TEXT_DARKER)); y += 8; x += 0; ms.translate(x, y, 0); ms.translate(0, 0, 5); - textRenderer.draw(ms, title, 0, 0, Theme.i(Theme.Key.TEXT)); - ms.pop(); + font.draw(ms, title, 0, 0, Theme.i(Theme.Key.TEXT)); + ms.popPose(); - ms.push(); + ms.pushPose(); ms.translate(23, 23, 10); ms.scale(1.66f, 1.66f, 1.66f); tag.draw(ms, this, 0, 0); - ms.pop(); - ms.pop(); + ms.popPose(); + ms.popPose(); - ms.push(); + ms.pushPose(); int w = (int) (width * .45); x = (width - w) / 2; y = getItemsY() - 10 + Math.max(itemArea.getHeight(), 48); String desc = tag.getDescription(); - int h = textRenderer.getWordWrappedHeight(desc, w); + int h = font.wordWrapHeight(desc, w); //PonderUI.renderBox(ms, x - 3, y - 3, w + 6, h + 6, false); @@ -234,8 +234,8 @@ public class PonderTagScreen extends NavigatableSimiScreen { .render(ms); ms.translate(0, 0, 100); - FontHelper.drawSplitString(ms, textRenderer, desc, x, y, w, Theme.i(Theme.Key.TEXT)); - ms.pop(); + FontHelper.drawSplitString(ms, font, desc, x, y, w, Theme.i(Theme.Key.TEXT)); + ms.popPose(); } protected void renderItems(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { @@ -246,9 +246,9 @@ public class PonderTagScreen extends NavigatableSimiScreen { int y = getItemsY(); String relatedTitle = Lang.translate(ASSOCIATED).getString(); - int stringWidth = textRenderer.getStringWidth(relatedTitle); + int stringWidth = font.width(relatedTitle); - ms.push(); + ms.pushPose(); ms.translate(x, y, 0); //PonderUI.renderBox(ms, (sWidth - stringWidth) / 2 - 5, itemArea.getY() - 21, stringWidth + 10, 10, false); new BoxElement() @@ -261,14 +261,14 @@ public class PonderTagScreen extends NavigatableSimiScreen { ms.translate(0, 0, 200); // UIRenderHelper.streak(0, itemArea.getX() - 10, itemArea.getY() - 20, 20, 180, 0x101010); - drawCenteredString(ms, textRenderer, relatedTitle, windowWidth / 2, itemArea.getY() - 20, Theme.i(Theme.Key.TEXT)); + drawCenteredString(ms, font, relatedTitle, windowWidth / 2, itemArea.getY() - 20, Theme.i(Theme.Key.TEXT)); ms.translate(0,0, -200); UIRenderHelper.streak(ms, 0, 0, 0, itemArea.getHeight() + 10, itemArea.getWidth() / 2 + 75); UIRenderHelper.streak(ms, 180, 0, 0, itemArea.getHeight() + 10, itemArea.getWidth() / 2 + 75); - ms.pop(); + ms.popPose(); } @@ -283,18 +283,18 @@ public class PonderTagScreen extends NavigatableSimiScreen { int chapterX = (int) (width * chapterXmult); int chapterY = (int) (height * chapterYmult); - ms.push(); + ms.pushPose(); ms.translate(chapterX, chapterY, 0); UIRenderHelper.streak(ms, 0, chapterArea.getX() - 10, chapterArea.getY() - 20, 20, 220); - textRenderer.draw(ms, "More Topics to Ponder about", chapterArea.getX() - 5, chapterArea.getY() - 25, Theme.i(Theme.Key.TEXT_ACCENT_SLIGHT)); + font.draw(ms, "More Topics to Ponder about", chapterArea.getX() - 5, chapterArea.getY() - 25, Theme.i(Theme.Key.TEXT_ACCENT_SLIGHT)); - ms.pop(); + ms.popPose(); } @Override protected void renderWindowForeground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - ms.push(); + ms.pushPose(); RenderSystem.disableRescaleNormal(); RenderSystem.disableDepthTest(); @@ -304,7 +304,7 @@ public class PonderTagScreen extends NavigatableSimiScreen { } RenderSystem.enableDepthTest(); RenderSystem.enableRescaleNormal(); - ms.pop(); + ms.popPose(); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/ProcessingScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/ProcessingScenes.java index 64a4bc8d0..342b530f8 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/ProcessingScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/ProcessingScenes.java @@ -87,7 +87,7 @@ public class ProcessingScenes { scene.idle(70); ItemStack itemStack = new ItemStack(Items.WHEAT); - Vector3d entitySpawn = util.vector.topOf(millstone.up(3)); + Vector3d entitySpawn = util.vector.topOf(millstone.above(3)); ElementLink entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), itemStack); @@ -151,7 +151,7 @@ public class ProcessingScenes { Selection kinetics2 = util.select.fromTo(0, 2, 5, 4, 2, 3); Selection beltCog = util.select.position(5, 0, 1); scene.world.setKineticSpeed(wheels, 0); - scene.world.setBlock(util.grid.at(2, 3, 2), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 3, 2), Blocks.AIR.defaultBlockState(), false); scene.world.showSection(util.select.layer(0) .substract(beltCog), Direction.UP); @@ -203,7 +203,7 @@ public class ProcessingScenes { ItemStack input = new ItemStack(Items.GOLD_ORE); ItemStack output = AllItems.CRUSHED_GOLD.asStack(); - Vector3d entitySpawn = util.vector.topOf(center.up(2)); + Vector3d entitySpawn = util.vector.topOf(center.above(2)); ElementLink entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), input); @@ -254,9 +254,9 @@ public class ProcessingScenes { scene.world.createItemOnBelt(util.grid.at(4, 4, 2), Direction.EAST, input); scene.idle(15); if (i > 0) { - scene.world.createItemOnBelt(center.down(), Direction.UP, output); + scene.world.createItemOnBelt(center.below(), Direction.UP, output); scene.idle(15); - scene.world.createItemOnBelt(center.down(), Direction.UP, output); + scene.world.createItemOnBelt(center.below(), Direction.UP, output); } scene.world.removeItemsFromBelt(util.grid.at(3, 3, 2)); if (i < 4) @@ -354,8 +354,8 @@ public class ProcessingScenes { scene.idle(30); scene.world.modifyTileEntity(pressPos, type, pte -> pte.makePressingParticleEffect(depotCenter.add(0, 8 / 16f, 0), copper)); - scene.world.removeItemsFromBelt(pressPos.down(2)); - ingot = scene.world.createItemOnBelt(pressPos.down(2), Direction.UP, sheet); + scene.world.removeItemsFromBelt(pressPos.below(2)); + ingot = scene.world.createItemOnBelt(pressPos.below(2), Direction.UP, sheet); scene.world.stallBeltItem(ingot, true); scene.idle(15); scene.world.stallBeltItem(ingot, false); @@ -365,8 +365,8 @@ public class ProcessingScenes { scene.idle(30); scene.world.modifyTileEntity(pressPos, type, pte -> pte.makePressingParticleEffect(depotCenter.add(0, 8 / 16f, 0), copper)); - scene.world.removeItemsFromBelt(pressPos.down(2)); - ingot2 = scene.world.createItemOnBelt(pressPos.down(2), Direction.UP, sheet); + scene.world.removeItemsFromBelt(pressPos.below(2)); + ingot2 = scene.world.createItemOnBelt(pressPos.below(2), Direction.UP, sheet); scene.world.stallBeltItem(ingot2, true); scene.idle(15); scene.world.stallBeltItem(ingot2, false); @@ -433,7 +433,7 @@ public class ProcessingScenes { scene.rotateCameraY(-30); scene.idle(10); scene.world.setBlock(util.grid.at(1, 1, 2), AllBlocks.BLAZE_BURNER.getDefaultState() - .with(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.KINDLED), true); + .setValue(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.KINDLED), true); scene.idle(10); scene.overlay.showText(80) @@ -532,7 +532,7 @@ public class ProcessingScenes { scene.rotateCameraY(-30); scene.idle(10); scene.world.setBlock(util.grid.at(1, 1, 2), AllBlocks.BLAZE_BURNER.getDefaultState() - .with(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.KINDLED), true); + .setValue(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.KINDLED), true); scene.idle(10); scene.overlay.showText(80) @@ -564,20 +564,20 @@ public class ProcessingScenes { scene.world.createEntity(w -> { BlazeEntity blazeEntity = EntityType.BLAZE.create(w); Vector3d v = util.vector.topOf(center); - blazeEntity.setPos(v.x, v.y, v.z); - blazeEntity.prevRotationYaw = blazeEntity.rotationYaw = 180; + blazeEntity.setPosRaw(v.x, v.y, v.z); + blazeEntity.yRotO = blazeEntity.yRot = 180; return blazeEntity; }); scene.idle(20); scene.overlay - .showControls(new InputWindowElement(util.vector.centerOf(center.up(2)), Pointing.DOWN).rightClick() + .showControls(new InputWindowElement(util.vector.centerOf(center.above(2)), Pointing.DOWN).rightClick() .withItem(AllItems.EMPTY_BLAZE_BURNER.asStack()), 40); scene.idle(10); scene.overlay.showText(60) .text("Right-click a Blaze with the empty burner to capture it") .attachKeyFrame() - .pointAt(util.vector.blockSurface(center.up(2), Direction.WEST)) + .pointAt(util.vector.blockSurface(center.above(2), Direction.WEST)) .placeNearTarget(); scene.idle(50); @@ -586,13 +586,13 @@ public class ProcessingScenes { scene.world.showSection(util.select.position(2, 1, 2), Direction.DOWN); scene.idle(20); - scene.overlay.showControls(new InputWindowElement(util.vector.topOf(center.up()), Pointing.DOWN).rightClick() + scene.overlay.showControls(new InputWindowElement(util.vector.topOf(center.above()), Pointing.DOWN).rightClick() .withItem(AllItems.EMPTY_BLAZE_BURNER.asStack()), 40); scene.idle(10); scene.overlay.showText(60) .text("Alternatively, Blazes can be collected from their Spawners directly") .attachKeyFrame() - .pointAt(util.vector.blockSurface(center.up(), Direction.WEST)) + .pointAt(util.vector.blockSurface(center.above(), Direction.WEST)) .placeNearTarget(); scene.idle(50); scene.world.hideSection(util.select.position(2, 1, 2), Direction.UP); @@ -600,20 +600,20 @@ public class ProcessingScenes { scene.world.showSection(util.select.position(1, 1, 2), Direction.DOWN); scene.idle(20); - scene.world.modifyBlock(util.grid.at(1, 1, 2), s -> s.with(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.KINDLED), + scene.world.modifyBlock(util.grid.at(1, 1, 2), s -> s.setValue(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.KINDLED), false); scene.overlay.showText(70) .text("You now have an ideal heat source for various machines") .attachKeyFrame() .pointAt(util.vector.blockSurface(center.west() - .up(), Direction.WEST)) + .above(), Direction.WEST)) .placeNearTarget(); scene.idle(80); scene.world.showSection(util.select.position(3, 1, 2), Direction.DOWN); scene.idle(20); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(center.east() - .up()), Pointing.DOWN).rightClick() + .above()), Pointing.DOWN).rightClick() .withItem(new ItemStack(Items.FLINT_AND_STEEL)), 40); scene.idle(7); @@ -623,27 +623,27 @@ public class ProcessingScenes { .text("For Aesthetic purposes, Empty Blaze Burners can also be lit using Flint and Steel") .attachKeyFrame() .pointAt(util.vector.blockSurface(center.east() - .up(), Direction.UP)) + .above(), Direction.UP)) .placeNearTarget(); scene.idle(80); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(center.east() - .up()), Pointing.DOWN).rightClick() + .above()), Pointing.DOWN).rightClick() .withItem(new ItemStack(Items.SOUL_SAND)), 40); scene.idle(7); - scene.world.modifyBlock(util.grid.at(3, 1, 2), s -> s.with(LitBlazeBurnerBlock.FLAME_TYPE, LitBlazeBurnerBlock.FlameType.SOUL), + scene.world.modifyBlock(util.grid.at(3, 1, 2), s -> s.setValue(LitBlazeBurnerBlock.FLAME_TYPE, LitBlazeBurnerBlock.FlameType.SOUL), false); scene.overlay.showText(60) .text("The flame can be transformed using a soul-infused item") .pointAt(util.vector.blockSurface(center.east() - .up(), Direction.UP)) + .above(), Direction.UP)) .placeNearTarget(); scene.idle(80); scene.overlay.showText(90) .colored(PonderPalette.RED) .text("However, without a blaze they are not suitable for industrial heating") .pointAt(util.vector.blockSurface(center.east() - .up(), Direction.UP)) + .above(), Direction.UP)) .placeNearTarget(); scene.idle(70); } @@ -657,7 +657,7 @@ public class ProcessingScenes { BlockPos burner = util.grid.at(2, 1, 2); scene.world.showSection(util.select.position(burner), Direction.DOWN); scene.idle(10); - scene.world.showSection(util.select.position(burner.up()), Direction.DOWN); + scene.world.showSection(util.select.position(burner.above()), Direction.DOWN); scene.idle(10); scene.overlay.showText(70) @@ -667,18 +667,18 @@ public class ProcessingScenes { .placeNearTarget(); scene.idle(80); - scene.world.hideSection(util.select.position(burner.up()), Direction.UP); + scene.world.hideSection(util.select.position(burner.above()), Direction.UP); scene.idle(20); - scene.world.setBlock(burner.up(), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(burner.above(), Blocks.AIR.defaultBlockState(), false); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(burner), Pointing.DOWN).rightClick() .withItem(new ItemStack(Items.OAK_PLANKS)), 15); scene.idle(7); - scene.world.modifyBlock(burner, s -> s.with(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.FADING), false); + scene.world.modifyBlock(burner, s -> s.setValue(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.FADING), false); scene.idle(15); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(burner), Pointing.DOWN).rightClick() .withItem(new ItemStack(Items.OAK_PLANKS)), 15); scene.idle(7); - scene.world.modifyBlock(burner, s -> s.with(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.KINDLED), false); + scene.world.modifyBlock(burner, s -> s.setValue(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.KINDLED), false); scene.idle(20); scene.overlay.showText(70) @@ -692,7 +692,7 @@ public class ProcessingScenes { scene.overlay.showControls(new InputWindowElement(util.vector.topOf(burner), Pointing.DOWN).rightClick() .withItem(AllItems.BLAZE_CAKE.asStack()), 30); scene.idle(7); - scene.world.modifyBlock(burner, s -> s.with(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.SEETHING), false); + scene.world.modifyBlock(burner, s -> s.setValue(BlazeBurnerBlock.HEAT_LEVEL, HeatLevel.SEETHING), false); scene.idle(20); scene.overlay.showText(80) @@ -731,7 +731,7 @@ public class ProcessingScenes { scene.world.showSection(util.select.position(1, 1, 2), Direction.DOWN); scene.idle(10); BlockPos basinPos = util.grid.at(1, 2, 2); - scene.world.modifyBlock(basinPos, s -> s.with(BasinBlock.FACING, Direction.DOWN), false); + scene.world.modifyBlock(basinPos, s -> s.setValue(BasinBlock.FACING, Direction.DOWN), false); scene.world.showSection(util.select.position(basinPos), Direction.DOWN); scene.idle(10); Vector3d basinSide = util.vector.blockSurface(basinPos, Direction.WEST); @@ -744,7 +744,7 @@ public class ProcessingScenes { ItemStack stack = new ItemStack(Items.BRICK); for (int i = 0; i < 4; i++) { - scene.world.createItemEntity(util.vector.centerOf(basinPos.up(3)), util.vector.of(0, 0, 0), stack); + scene.world.createItemEntity(util.vector.centerOf(basinPos.above(3)), util.vector.of(0, 0, 0), stack); scene.idle(10); } scene.idle(10); @@ -753,8 +753,8 @@ public class ProcessingScenes { scene.idle(30); for (Direction d : Iterate.horizontalDirections) { - scene.overlay.showOutline(PonderPalette.GREEN, new Object(), util.select.position(basinPos.down() - .offset(d)), 60); + scene.overlay.showOutline(PonderPalette.GREEN, new Object(), util.select.position(basinPos.below() + .relative(d)), 60); scene.idle(4); } @@ -770,7 +770,7 @@ public class ProcessingScenes { scene.world.showIndependentSection(util.select.position(3, 1, 1), Direction.EAST); scene.world.moveSection(depot, util.vector.of(-2, 0, 0), 0); scene.idle(10); - scene.world.modifyBlock(basinPos, s -> s.with(BasinBlock.FACING, Direction.NORTH), false); + scene.world.modifyBlock(basinPos, s -> s.setValue(BasinBlock.FACING, Direction.NORTH), false); scene.idle(10); scene.overlay.showText(80) @@ -831,7 +831,7 @@ public class ProcessingScenes { .serializeNBT())); }); scene.idle(4); - scene.overlay.showControls(new InputWindowElement(util.vector.topOf(basinPos.down() + scene.overlay.showControls(new InputWindowElement(util.vector.topOf(basinPos.below() .north()), Pointing.RIGHT).withItem(new ItemStack(Items.BRICKS)), 30); scene.overlay.showText(60) @@ -844,7 +844,7 @@ public class ProcessingScenes { scene.world.hideIndependentSection(depot, Direction.NORTH); scene.idle(10); - scene.world.modifyBlock(basinPos, s -> s.with(BasinBlock.FACING, Direction.DOWN), false); + scene.world.modifyBlock(basinPos, s -> s.setValue(BasinBlock.FACING, Direction.DOWN), false); scene.idle(20); scene.overlay.showText(80) 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 b228d4f60..8cc9fff31 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 @@ -123,7 +123,7 @@ public class PulleyScenes { scene.world.showSection(util.select.position(pulleyPos), Direction.SOUTH); ElementLink glass = - scene.world.showIndependentSection(util.select.position(pulleyPos.down()), Direction.UP); + scene.world.showIndependentSection(util.select.position(pulleyPos.below()), Direction.UP); scene.idle(20); scene.world.toggleRedstonePower(redstoneStuff); @@ -152,7 +152,7 @@ public class PulleyScenes { scene.world.hideSection(util.select.position(flowerPos), Direction.DOWN); scene.idle(40); - scene.world.setBlock(flowerPos, Blocks.BLUE_ORCHID.getDefaultState(), false); + scene.world.setBlock(flowerPos, Blocks.BLUE_ORCHID.defaultBlockState(), false); scene.world.showSection(util.select.position(flowerPos), Direction.DOWN); scene.overlay.showCenteredScrollInput(pulleyPos, Direction.UP, 60); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(pulleyPos), Pointing.DOWN).scroll() diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/RedstoneScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/RedstoneScenes.java index 617124dca..b77a3fc5b 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/RedstoneScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/RedstoneScenes.java @@ -67,7 +67,7 @@ public class RedstoneScenes { scene.idle(70); scene.world.toggleRedstonePower(redstone); - scene.world.modifyBlock(stickerPos, s -> s.with(StickerBlock.EXTENDED, true), false); + scene.world.modifyBlock(stickerPos, s -> s.setValue(StickerBlock.EXTENDED, true), false); scene.effects.indicateRedstone(buttonPos); scene.world.modifyTileNBT(stickerSelect, StickerTileEntity.class, nbt -> { }); @@ -93,7 +93,7 @@ public class RedstoneScenes { scene.addKeyframe(); scene.world.toggleRedstonePower(redstone); - scene.world.modifyBlock(stickerPos, s -> s.with(StickerBlock.EXTENDED, false), false); + scene.world.modifyBlock(stickerPos, s -> s.setValue(StickerBlock.EXTENDED, false), false); scene.effects.indicateRedstone(buttonPos); scene.world.modifyTileNBT(stickerSelect, StickerTileEntity.class, nbt -> { }); @@ -402,8 +402,8 @@ public class RedstoneScenes { scene.idle(30); scene.world.toggleRedstonePower(util.select.fromTo(4, 1, 2, 3, 1, 2)); - AxisAlignedBB bb = new AxisAlignedBB(circuitPos).grow(-.48f, -.45f, -.05f) - .offset(.575, -.45, 0); + AxisAlignedBB bb = new AxisAlignedBB(circuitPos).inflate(-.48f, -.45f, -.05f) + .move(.575, -.45, 0); scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, bb, bb, 40); scene.overlay.showText(40) .colored(PonderPalette.GREEN) @@ -419,10 +419,10 @@ public class RedstoneScenes { scene.idle(30); scene.world.toggleRedstonePower(util.select.fromTo(2, 1, 0, 2, 1, 1)); - bb = new AxisAlignedBB(circuitPos).grow(-.05f, -.45f, -.48f) - .offset(0, -.45, .575); - AxisAlignedBB bb2 = new AxisAlignedBB(circuitPos).grow(-.05f, -.45f, -.48f) - .offset(0, -.45, -.575); + bb = new AxisAlignedBB(circuitPos).inflate(-.05f, -.45f, -.48f) + .move(0, -.45, .575); + AxisAlignedBB bb2 = new AxisAlignedBB(circuitPos).inflate(-.05f, -.45f, -.48f) + .move(0, -.45, -.575); scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, bb, bb, 40); scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, bb2, bb2, 40); scene.overlay.showText(40) @@ -482,8 +482,8 @@ public class RedstoneScenes { scene.idle(30); scene.world.toggleRedstonePower(util.select.fromTo(4, 1, 2, 3, 1, 2)); - AxisAlignedBB bb = new AxisAlignedBB(circuitPos).grow(-.48f, -.45f, -.05f) - .offset(.575, -.45, 0); + AxisAlignedBB bb = new AxisAlignedBB(circuitPos).inflate(-.48f, -.45f, -.05f) + .move(.575, -.45, 0); scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, bb, bb, 40); scene.overlay.showText(40) .colored(PonderPalette.GREEN) @@ -565,7 +565,7 @@ public class RedstoneScenes { scene.idle(2); final int state = i + 1; scene.world.modifyTileNBT(leverSelection, AnalogLeverTileEntity.class, nbt -> nbt.putInt("State", state)); - scene.world.modifyBlock(wireLocations[i], s -> s.with(power, 7 - state), false); + scene.world.modifyBlock(wireLocations[i], s -> s.setValue(power, 7 - state), false); scene.effects.indicateRedstone(wireLocations[i]); } scene.idle(20); @@ -588,9 +588,9 @@ public class RedstoneScenes { nbt -> nbt.putInt("State", state)); scene.effects.indicateRedstone(wireLocations[i]); } - scene.world.modifyBlock(wireLocations[i], s -> s.with(power, state > 2 ? 0 : 3 - state), false); + scene.world.modifyBlock(wireLocations[i], s -> s.setValue(power, state > 2 ? 0 : 3 - state), false); } - scene.world.modifyBlock(wireLocations[0], s -> s.with(power, 3), false); + scene.world.modifyBlock(wireLocations[0], s -> s.setValue(power, 3), false); scene.idle(20); scene.overlay.showText(60) @@ -610,7 +610,7 @@ public class RedstoneScenes { nbt -> nbt.putInt("State", state)); scene.effects.indicateRedstone(wireLocations[i]); } - scene.world.modifyBlock(wireLocations[i], s -> s.with(power, 15 - state), false); + scene.world.modifyBlock(wireLocations[i], s -> s.setValue(power, 15 - state), false); } scene.world.toggleRedstonePower(lamp); @@ -633,7 +633,7 @@ public class RedstoneScenes { scene.effects.indicateRedstone(util.grid.at(2, 1, 1)); scene.world.modifyTileNBT(util.select.position(2, 1, 1), AnalogLeverTileEntity.class, nbt -> nbt.putInt("State", 11)); - scene.world.modifyBlock(util.grid.at(2, 1, 2), s -> s.with(RedstoneWireBlock.POWER, 11), false); + scene.world.modifyBlock(util.grid.at(2, 1, 2), s -> s.setValue(RedstoneWireBlock.POWER, 11), false); scene.world.modifyTileNBT(tubes, NixieTubeTileEntity.class, nbt -> nbt.putInt("RedstoneStrength", 11)); scene.idle(20); @@ -689,7 +689,7 @@ public class RedstoneScenes { scene.idle(7); scene.world.setBlocks(util.select.fromTo(1, 1, 3, 3, 1, 3), AllBlocks.NIXIE_TUBES.get(DyeColor.BLUE) .getDefaultState() - .with(NixieTubeBlock.HORIZONTAL_FACING, Direction.NORTH), false); + .setValue(NixieTubeBlock.FACING, Direction.NORTH), false); scene.idle(10); scene.overlay.showText(80) .colored(PonderPalette.BLUE) @@ -809,30 +809,30 @@ public class RedstoneScenes { scene.idle(7); scene.overlay.showControls(new InputWindowElement(frontSlot, Pointing.UP).withItem(sapling), 40); scene.world.modifyTileNBT(link1Select, RedstoneLinkTileEntity.class, - nbt -> nbt.put("FrequencyLast", iron.write(new CompoundNBT()))); + nbt -> nbt.put("FrequencyLast", iron.save(new CompoundNBT()))); scene.idle(7); scene.world.modifyTileNBT(link1Select, RedstoneLinkTileEntity.class, - nbt -> nbt.put("FrequencyFirst", sapling.write(new CompoundNBT()))); + nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundNBT()))); scene.idle(20); scene.overlay.showControls(new InputWindowElement(top2Slot, Pointing.DOWN).withItem(iron), 40); scene.idle(7); scene.overlay.showControls(new InputWindowElement(bottom2Slot, Pointing.UP).withItem(sapling), 40); scene.world.modifyTileNBT(link2Select, RedstoneLinkTileEntity.class, - nbt -> nbt.put("FrequencyLast", iron.write(new CompoundNBT()))); + nbt -> nbt.put("FrequencyLast", iron.save(new CompoundNBT()))); scene.idle(7); scene.world.modifyTileNBT(link2Select, RedstoneLinkTileEntity.class, - nbt -> nbt.put("FrequencyFirst", sapling.write(new CompoundNBT()))); + nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundNBT()))); scene.idle(20); scene.overlay.showControls(new InputWindowElement(top3Slot, Pointing.DOWN).withItem(gold), 40); scene.idle(7); scene.overlay.showControls(new InputWindowElement(bottom3Slot, Pointing.UP).withItem(sapling), 40); scene.world.modifyTileNBT(link3Select, RedstoneLinkTileEntity.class, - nbt -> nbt.put("FrequencyLast", gold.write(new CompoundNBT()))); + nbt -> nbt.put("FrequencyLast", gold.save(new CompoundNBT()))); scene.idle(7); scene.world.modifyTileNBT(link3Select, RedstoneLinkTileEntity.class, - nbt -> nbt.put("FrequencyFirst", sapling.write(new CompoundNBT()))); + nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundNBT()))); scene.idle(20); scene.world.toggleRedstonePower(redstone); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/TunnelScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/TunnelScenes.java index 6c80f52b5..28874b1b0 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/TunnelScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/TunnelScenes.java @@ -268,7 +268,7 @@ public class TunnelScenes { ItemStack item3 = new ItemStack(Items.SWEET_BERRIES); tunnelFilterVec = getTunnelFilterVec(tunnelPos, Direction.WEST); - BlockPos newTunnelPos = tunnelPos.up(2) + BlockPos newTunnelPos = tunnelPos.above(2) .south(); scene.overlay .showControls(new InputWindowElement(tunnelFilterVec.add(0, 0, -1), Pointing.RIGHT).withItem(item1), 20); @@ -313,7 +313,7 @@ public class TunnelScenes { scene.world.showSectionAndMerge(util.select.position(3, 5, 2), Direction.DOWN, newBelt); scene.overlay.showText(80) - .pointAt(util.vector.blockSurface(tunnelPos.up() + .pointAt(util.vector.blockSurface(tunnelPos.above() .north(), Direction.WEST)) .placeNearTarget() .text("For this, items can also be inserted into the Tunnel block directly"); @@ -339,14 +339,14 @@ public class TunnelScenes { protected static Vector3d getTunnelFilterVec(BlockPos pos, Direction d) { return VecHelper.getCenterOf(pos) - .add(Vector3d.of(d.getDirectionVec()).scale(.5)) + .add(Vector3d.atLowerCornerOf(d.getNormal()).scale(.5)) .add(0, 0.3, 0); } public static void brassModes(SceneBuilder scene, SceneBuildingUtil util) { scene.title("brass_tunnel_modes", "Distribution Modes of the Brass Tunnel"); scene.configureBasePlate(0, 1, 5); - BlockState barrier = Blocks.BARRIER.getDefaultState(); + BlockState barrier = Blocks.BARRIER.defaultBlockState(); scene.world.setBlock(util.grid.at(1, 1, 0), barrier, false); scene.world.showSection(util.select.layer(0), Direction.UP); scene.idle(5); @@ -419,7 +419,7 @@ public class TunnelScenes { .colored(PonderPalette.RED); scene.idle(60); scene.world.moveSection(blockage, util.vector.of(-1, 0, 0), 10); - scene.world.setBlock(util.grid.at(1, 1, 0), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(1, 1, 0), Blocks.AIR.defaultBlockState(), false); scene.world.multiplyKineticSpeed(util.select.everywhere(), 1.5f); } @@ -466,7 +466,7 @@ public class TunnelScenes { .colored(PonderPalette.RED); scene.idle(30); scene.world.moveSection(blockage, util.vector.of(-1, 0, 0), 10); - scene.world.setBlock(util.grid.at(1, 1, 0), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(1, 1, 0), Blocks.AIR.defaultBlockState(), false); } if (i == 19) { @@ -486,16 +486,16 @@ public class TunnelScenes { } if (i == 21) { - scene.world.setBlock(util.grid.at(2, 1, 0), Blocks.BARRIER.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 1, 0), Blocks.BARRIER.defaultBlockState(), false); blockage2 = scene.world.showIndependentSection(util.select.position(4, 1, 0), Direction.UP); scene.world.moveSection(blockage2, util.vector.of(-2, 0, 0), 0); } if (i == 25) { scene.world.hideIndependentSection(blockage, Direction.DOWN); - scene.world.setBlock(util.grid.at(1, 1, 0), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(1, 1, 0), Blocks.AIR.defaultBlockState(), false); scene.world.hideIndependentSection(blockage2, Direction.DOWN); - scene.world.setBlock(util.grid.at(2, 1, 0), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(2, 1, 0), Blocks.AIR.defaultBlockState(), false); } if (i == 26) { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/FluidMovementActorScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/FluidMovementActorScenes.java index 05f81806a..a98b6e93c 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/FluidMovementActorScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/FluidMovementActorScenes.java @@ -61,7 +61,7 @@ public class FluidMovementActorScenes { scene.world.rotateBearing(bearing, 360, 70); scene.world.rotateSection(contraption, 0, 360, 0, 70); scene.overlay.showText(60) - .pointAt(util.vector.topOf(bearing.up(2))) + .pointAt(util.vector.topOf(bearing.above(2))) .colored(PonderPalette.RED) .placeNearTarget() .attachKeyFrame() diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/FluidTankScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/FluidTankScenes.java index 68605765d..10a6f4b9b 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/FluidTankScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/FluidTankScenes.java @@ -82,7 +82,7 @@ public class FluidTankScenes { scene.world.hideIndependentSection(chocLink, Direction.DOWN); scene.idle(5); FluidStack content = new FluidStack(AllFluids.CHOCOLATE.get() - .getStillFluid(), 16000); + .getSource(), 16000); scene.world.modifyTileEntity(tankPos, FluidTankTileEntity.class, te -> te.getTankInventory() .fill(content, FluidAction.EXECUTE)); scene.idle(25); @@ -337,7 +337,7 @@ public class FluidTankScenes { .withWrench(), 60); scene.idle(7); - scene.world.modifyBlocks(full2, s -> s.with(FluidTankBlock.SHAPE, FluidTankBlock.Shape.PLAIN), false); + scene.world.modifyBlocks(full2, s -> s.setValue(FluidTankBlock.SHAPE, FluidTankBlock.Shape.PLAIN), false); scene.idle(30); scene.overlay.showText(60) diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/HosePulleyScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/HosePulleyScenes.java index dc09e0e45..a8cacb2f6 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/HosePulleyScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/HosePulleyScenes.java @@ -44,12 +44,12 @@ public class HosePulleyScenes { scene.world.moveSection(hoselink, util.vector.of(0, -1, 0), 0); scene.idle(10); - Vector3d shaftInput = util.vector.blockSurface(hosePos.down(), Direction.WEST); + Vector3d shaftInput = util.vector.blockSurface(hosePos.below(), Direction.WEST); scene.overlay.showText(70) .text("Hose Pulleys can be used to fill or drain large bodies of Fluid") .attachKeyFrame() .placeNearTarget() - .pointAt(util.vector.topOf(hosePos.down())); + .pointAt(util.vector.topOf(hosePos.below())); scene.idle(80); scene.overlay.showText(80) @@ -71,7 +71,7 @@ public class HosePulleyScenes { .text("The Pulley retracts while the input rotation is inverted") .attachKeyFrame() .placeNearTarget() - .pointAt(util.vector.centerOf(hosePos.down(3))); + .pointAt(util.vector.centerOf(hosePos.below(3))); scene.idle(30); scene.world.setKineticSpeed(kinetics, -32); @@ -85,7 +85,7 @@ public class HosePulleyScenes { .text("On the opposite side, pipes can be connected") .attachKeyFrame() .placeNearTarget() - .pointAt(util.vector.blockSurface(hosePos.down(), Direction.EAST)); + .pointAt(util.vector.blockSurface(hosePos.below(), Direction.EAST)); scene.idle(70); scene.rotateCameraY(-70); @@ -116,7 +116,7 @@ public class HosePulleyScenes { } for (BlockPos blockPos : blocks) { - scene.world.setBlock(blockPos, Blocks.WATER.getDefaultState(), false); + scene.world.setBlock(blockPos, Blocks.WATER.defaultBlockState(), false); scene.idle(3); } @@ -176,7 +176,7 @@ public class HosePulleyScenes { } for (BlockPos blockPos : blocks) - scene.world.setBlock(blockPos, Blocks.WATER.getDefaultState(), false); + scene.world.setBlock(blockPos, Blocks.WATER.defaultBlockState(), false); scene.idle(5); Selection water = util.select.fromTo(2, 1, 0, 0, 4, 2); @@ -197,12 +197,12 @@ public class HosePulleyScenes { scene.world.showSectionAndMerge(crank, Direction.EAST, hoselink); scene.idle(20); - scene.overlay.showSelectionWithText(util.select.position(hosePos.down()), 50) + scene.overlay.showSelectionWithText(util.select.position(hosePos.below()), 50) .text("While fully retracted, the Hose Pulley cannot operate") .placeNearTarget() .colored(PonderPalette.RED) .attachKeyFrame() - .pointAt(util.vector.blockSurface(hosePos.down(), Direction.UP)); + .pointAt(util.vector.blockSurface(hosePos.below(), Direction.UP)); scene.idle(55); Selection kinetics = util.select.fromTo(1, 6, 1, 0, 6, 1); @@ -214,7 +214,7 @@ public class HosePulleyScenes { .text("Draining runs from top to bottom") .attachKeyFrame() .placeNearTarget() - .pointAt(util.vector.centerOf(hosePos.down(3))); + .pointAt(util.vector.centerOf(hosePos.below(3))); scene.idle(10); scene.world.showSectionAndMerge(cogs, Direction.NORTH, hoselink); @@ -228,10 +228,10 @@ public class HosePulleyScenes { Vector3d surface = util.vector.topOf(1, 3, 1) .subtract(0, 2 / 8f, 0); - AxisAlignedBB bb = new AxisAlignedBB(surface, surface).grow(1.5, 0, 1.5); + AxisAlignedBB bb = new AxisAlignedBB(surface, surface).inflate(1.5, 0, 1.5); scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, bb, bb, 3); scene.idle(3); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, bb, bb.expand(0, -2, 0), 70); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, bb, bb.expandTowards(0, -2, 0), 70); scene.idle(20); Collections.reverse(blocks); @@ -243,7 +243,7 @@ public class HosePulleyScenes { scene.idle(3); } - scene.overlay.chaseBoundingBoxOutline(PonderPalette.WHITE, bb, bb.offset(0, -2, 0), 60); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.WHITE, bb, bb.move(0, -2, 0), 60); scene.overlay.showText(60) .text("The surface level will end up just below where the hose ends") .attachKeyFrame() @@ -269,22 +269,22 @@ public class HosePulleyScenes { .text("Filling runs from bottom to top") .attachKeyFrame() .placeNearTarget() - .pointAt(util.vector.centerOf(hosePos.down(3))); + .pointAt(util.vector.centerOf(hosePos.below(3))); scene.idle(10); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, bb, bb.offset(0, -3 + 2 / 8f, 0), 3); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, bb, bb.move(0, -3 + 2 / 8f, 0), 3); scene.idle(3); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, bb, bb.expand(0, -3 + 2 / 8f, 0), 120); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, bb, bb.expandTowards(0, -3 + 2 / 8f, 0), 120); scene.idle(20); - scene.world.setBlock(util.grid.at(1, 3, 1), Blocks.WATER.getDefaultState(), false); + scene.world.setBlock(util.grid.at(1, 3, 1), Blocks.WATER.defaultBlockState(), false); scene.idle(3); - scene.world.setBlock(util.grid.at(1, 2, 1), Blocks.WATER.getDefaultState(), false); + scene.world.setBlock(util.grid.at(1, 2, 1), Blocks.WATER.defaultBlockState(), false); scene.idle(3); Collections.reverse(blocks); for (BlockPos blockPos : blocks) { - scene.world.setBlock(blockPos, Blocks.WATER.getDefaultState(), false); + scene.world.setBlock(blockPos, Blocks.WATER.defaultBlockState(), false); scene.idle(3); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/PipeScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/PipeScenes.java index 3dbbcca81..adc80a419 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/PipeScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/PipeScenes.java @@ -48,13 +48,13 @@ public class PipeScenes { scene.idle(5); BlockState pipeState = AllBlocks.FLUID_PIPE.getDefaultState() - .with(FluidPipeBlock.UP, false) - .with(FluidPipeBlock.DOWN, false); + .setValue(FluidPipeBlock.UP, false) + .setValue(FluidPipeBlock.DOWN, false); - scene.world.setBlock(util.grid.at(2, 1, 1), pipeState.with(FluidPipeBlock.NORTH, false) - .with(FluidPipeBlock.SOUTH, false), false); - scene.world.setBlock(util.grid.at(1, 1, 2), pipeState.with(FluidPipeBlock.WEST, false) - .with(FluidPipeBlock.EAST, false), false); + scene.world.setBlock(util.grid.at(2, 1, 1), pipeState.setValue(FluidPipeBlock.NORTH, false) + .setValue(FluidPipeBlock.SOUTH, false), false); + scene.world.setBlock(util.grid.at(1, 1, 2), pipeState.setValue(FluidPipeBlock.WEST, false) + .setValue(FluidPipeBlock.EAST, false), false); Selection largeCog = util.select.position(5, 0, 1); Selection kinetics = util.select.fromTo(5, 1, 0, 3, 1, 0); @@ -108,9 +108,9 @@ public class PipeScenes { scene.idle(40); Vector3d center = util.vector.centerOf(2, 1, 2); - AxisAlignedBB bb = new AxisAlignedBB(center, center).grow(1 / 6f); - AxisAlignedBB bb1 = bb.offset(-0.5, 0, 0); - AxisAlignedBB bb2 = bb.offset(0, 0, -0.5); + AxisAlignedBB bb = new AxisAlignedBB(center, center).inflate(1 / 6f); + AxisAlignedBB bb1 = bb.move(-0.5, 0, 0); + AxisAlignedBB bb2 = bb.move(0, 0, -0.5); scene.world.showSection(strayPipes, Direction.DOWN); scene.idle(10); @@ -132,7 +132,7 @@ public class PipeScenes { BlockPos pumpPos = util.grid.at(3, 1, 1); scene.world.setBlock(pumpPos, AllBlocks.MECHANICAL_PUMP.getDefaultState() - .with(PumpBlock.FACING, Direction.WEST), true); + .setValue(PumpBlock.FACING, Direction.WEST), true); scene.idle(10); scene.world.showSection(largeCog, Direction.UP); scene.world.showSection(kinetics, Direction.SOUTH); @@ -243,21 +243,21 @@ public class PipeScenes { scene.idle(5); scene.world.hideSection(tank, Direction.EAST); scene.idle(5); - scene.world.setBlock(drainPos, Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(drainPos, Blocks.AIR.defaultBlockState(), false); scene.world.propagatePipeChange(pumpPos); scene.world.hideSection(basin, Direction.NORTH); scene.idle(5); - scene.world.setBlock(util.grid.at(3, 1, 1), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(3, 1, 1), Blocks.AIR.defaultBlockState(), false); scene.idle(5); scene.world.setBlock(util.grid.at(3, 1, 3), AllBlocks.GLASS_FLUID_PIPE.getDefaultState() - .with(AxisPipeBlock.AXIS, Axis.Z), false); + .setValue(AxisPipeBlock.AXIS, Axis.Z), false); scene.idle(10); scene.world.multiplyKineticSpeed(util.select.everywhere(), 2); scene.world.propagatePipeChange(pumpPos); ElementLink water = scene.world.showIndependentSection(waterSourceS, Direction.DOWN); scene.world.moveSection(water, util.vector.of(0, 0, 1), 0); scene.idle(10); - scene.world.setBlock(drainPos, Blocks.WATER.getDefaultState(), false); + scene.world.setBlock(drainPos, Blocks.WATER.defaultBlockState(), false); scene.idle(20); scene.overlay.showText(60) @@ -267,7 +267,7 @@ public class PipeScenes { .pointAt(util.vector.blockSurface(drainPos, Direction.SOUTH)); scene.idle(40); - scene.world.setBlock(drainPos.north(), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(drainPos.north(), Blocks.AIR.defaultBlockState(), false); scene.idle(40); ElementLink target = scene.world.showIndependentSection(waterTargetS, Direction.UP); scene.world.moveSection(target, util.vector.of(-1, 0, 0), 0); @@ -283,8 +283,8 @@ public class PipeScenes { scene.idle(80); scene.world.hideIndependentSection(target, Direction.DOWN); scene.idle(5); - scene.world.setBlock(drainPos, Blocks.BEE_NEST.getDefaultState() - .with(BeehiveBlock.HONEY_LEVEL, 5), false); + scene.world.setBlock(drainPos, Blocks.BEE_NEST.defaultBlockState() + .setValue(BeehiveBlock.HONEY_LEVEL, 5), false); scene.world.showSection(drain, Direction.DOWN); scene.world.setBlock(util.grid.at(3, 1, 2), AllBlocks.FLUID_TANK.getDefaultState(), false); scene.world.propagatePipeChange(pumpPos); @@ -297,8 +297,8 @@ public class PipeScenes { .pointAt(util.vector.topOf(drainPos)); scene.idle(60); - scene.world.setBlock(drainPos, Blocks.BEE_NEST.getDefaultState() - .with(BeehiveBlock.HONEY_LEVEL, 0), false); + scene.world.setBlock(drainPos, Blocks.BEE_NEST.defaultBlockState() + .setValue(BeehiveBlock.HONEY_LEVEL, 0), false); } public static void encasing(SceneBuilder scene, SceneBuildingUtil util) { @@ -312,8 +312,8 @@ public class PipeScenes { scene.idle(15); BlockState copperEncased = AllBlocks.ENCASED_FLUID_PIPE.getDefaultState() - .with(FluidPipeBlock.SOUTH, true) - .with(FluidPipeBlock.WEST, true); + .setValue(FluidPipeBlock.SOUTH, true) + .setValue(FluidPipeBlock.WEST, true); ItemStack casingItem = AllBlocks.COPPER_CASING.asStack(); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(3, 1, 1), Pointing.DOWN).rightClick() @@ -330,8 +330,8 @@ public class PipeScenes { scene.idle(70); scene.world.destroyBlock(util.grid.at(2, 1, 1)); - scene.world.modifyBlock(util.grid.at(1, 1, 1), s -> s.with(FluidPipeBlock.EAST, false) - .with(FluidPipeBlock.NORTH, true), false); + scene.world.modifyBlock(util.grid.at(1, 1, 1), s -> s.setValue(FluidPipeBlock.EAST, false) + .setValue(FluidPipeBlock.NORTH, true), false); scene.idle(5); scene.overlay.showLine(PonderPalette.RED, util.vector.of(1.5, 1.75, 1), util.vector.of(1.5, 1.75, 2), 80); @@ -348,17 +348,17 @@ public class PipeScenes { scene.idle(70); BlockState defaultState = AllBlocks.FLUID_PIPE.getDefaultState(); - for (BooleanProperty booleanProperty : FluidPipeBlock.FACING_TO_PROPERTY_MAP.values()) - defaultState = defaultState.with(booleanProperty, false); + for (BooleanProperty booleanProperty : FluidPipeBlock.PROPERTY_BY_DIRECTION.values()) + defaultState = defaultState.setValue(booleanProperty, false); - scene.world.setBlock(util.grid.at(3, 2, 1), defaultState.with(FluidPipeBlock.EAST, true) - .with(FluidPipeBlock.WEST, true), false); - scene.world.setBlock(util.grid.at(1, 2, 1), defaultState.with(FluidPipeBlock.UP, true) - .with(FluidPipeBlock.DOWN, true), false); + scene.world.setBlock(util.grid.at(3, 2, 1), defaultState.setValue(FluidPipeBlock.EAST, true) + .setValue(FluidPipeBlock.WEST, true), false); + scene.world.setBlock(util.grid.at(1, 2, 1), defaultState.setValue(FluidPipeBlock.UP, true) + .setValue(FluidPipeBlock.DOWN, true), false); scene.world.showSection(util.select.layer(2), Direction.DOWN); scene.idle(10); - scene.world.modifyBlock(util.grid.at(1, 1, 1), s -> s.with(FluidPipeBlock.UP, true) - .with(FluidPipeBlock.NORTH, false), false); + scene.world.modifyBlock(util.grid.at(1, 1, 1), s -> s.setValue(FluidPipeBlock.UP, true) + .setValue(FluidPipeBlock.NORTH, false), false); scene.idle(20); scene.overlay.showText(60) @@ -389,9 +389,9 @@ public class PipeScenes { scene.world.propagatePipeChange(pumpPos); scene.world.setBlock(valvePos, AllBlocks.FLUID_PIPE.get() .getAxisState(Axis.X), false); - scene.world.setBlock(util.grid.at(3, 1, 1), Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(util.grid.at(3, 1, 1), Blocks.AIR.defaultBlockState(), false); scene.world.setBlock(util.grid.at(3, 1, 1), AllBlocks.GLASS_FLUID_PIPE.getDefaultState() - .with(GlassFluidPipeBlock.AXIS, Axis.X), false); + .setValue(GlassFluidPipeBlock.AXIS, Axis.X), false); scene.idle(5); scene.world.showSection(tank1, Direction.NORTH); @@ -434,7 +434,7 @@ public class PipeScenes { scene.effects.rotationSpeedIndicator(handlePos); scene.world.modifyTileEntity(valvePos, FluidValveTileEntity.class, te -> te.onSpeedChanged(0)); scene.idle(22); - scene.world.modifyBlock(valvePos, s -> s.with(FluidValveBlock.ENABLED, true), false); + scene.world.modifyBlock(valvePos, s -> s.setValue(FluidValveBlock.ENABLED, true), false); scene.effects.indicateSuccess(valvePos); scene.idle(5); scene.world.setKineticSpeed(valveKinetics, 0); @@ -457,7 +457,7 @@ public class PipeScenes { scene.effects.rotationSpeedIndicator(handlePos); scene.world.modifyTileEntity(valvePos, FluidValveTileEntity.class, te -> te.onSpeedChanged(0)); scene.idle(22); - scene.world.modifyBlock(valvePos, s -> s.with(FluidValveBlock.ENABLED, false), false); + scene.world.modifyBlock(valvePos, s -> s.setValue(FluidValveBlock.ENABLED, false), false); scene.effects.indicateRedstone(valvePos); scene.world.propagatePipeChange(pumpPos); scene.idle(5); @@ -487,11 +487,11 @@ public class PipeScenes { scene.world.setBlock(smartPos, AllBlocks.FLUID_PIPE.get() .getAxisState(Axis.X), false); scene.world.setBlock(util.grid.at(2, 1, 3), AllBlocks.GLASS_FLUID_PIPE.getDefaultState() - .with(GlassFluidPipeBlock.AXIS, Axis.X), false); + .setValue(GlassFluidPipeBlock.AXIS, Axis.X), false); scene.world.setBlock(util.grid.at(1, 1, 3), AllBlocks.FLUID_PIPE.get() .getAxisState(Axis.X) - .with(FluidPipeBlock.NORTH, true) - .with(FluidPipeBlock.WEST, false), false); + .setValue(FluidPipeBlock.NORTH, true) + .setValue(FluidPipeBlock.WEST, false), false); scene.world.showSection(basin, Direction.DOWN); scene.idle(5); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/PumpScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/PumpScenes.java index bc1c1bca0..6c1a89f4f 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/PumpScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/PumpScenes.java @@ -82,17 +82,17 @@ public class PumpScenes { .pointAt(util.vector.topOf(pumpPos) .subtract(0.5f, 0.125f, 0)); - AxisAlignedBB bb1 = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).grow(.25, .25, 0) - .offset(0, 0, .25); - AxisAlignedBB bb2 = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).grow(.25, .25, 1.25); + AxisAlignedBB bb1 = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).inflate(.25, .25, 0) + .move(0, 0, .25); + AxisAlignedBB bb2 = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).inflate(.25, .25, 1.25); scene.idle(65); Object in = new Object(); Object out = new Object(); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb1.offset(util.vector.centerOf(3, 1, 3)), 3); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb1.move(util.vector.centerOf(3, 1, 3)), 3); scene.idle(2); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb2.offset(util.vector.centerOf(3, 1, 2)), 50); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb2.move(util.vector.centerOf(3, 1, 2)), 50); scene.idle(10); scene.overlay.showText(50) @@ -104,10 +104,10 @@ public class PumpScenes { scene.idle(60); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb1.offset(util.vector.centerOf(1, 1, 1) + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb1.move(util.vector.centerOf(1, 1, 1) .add(0, 0, -.5)), 3); scene.idle(2); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb2.offset(util.vector.centerOf(1, 1, 2)), 50); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb2.move(util.vector.centerOf(1, 1, 2)), 50); scene.idle(10); scene.overlay.showText(50) @@ -132,20 +132,20 @@ public class PumpScenes { .subtract(0.5f, 0.125f, 0)); scene.idle(25); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb1.offset(util.vector.centerOf(1, 1, 3)), 3); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb1.move(util.vector.centerOf(1, 1, 3)), 3); scene.idle(2); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb2.offset(util.vector.centerOf(1, 1, 2)), 30); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb2.move(util.vector.centerOf(1, 1, 2)), 30); scene.idle(15); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb1.offset(util.vector.centerOf(3, 1, 1) + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb1.move(util.vector.centerOf(3, 1, 1) .add(0, 0, -.5)), 3); scene.idle(2); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb2.offset(util.vector.centerOf(3, 1, 2)), 30); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb2.move(util.vector.centerOf(3, 1, 2)), 30); scene.idle(55); scene.overlay.showControls(new InputWindowElement(util.vector.topOf(pumpPos), Pointing.DOWN).rightClick() .withWrench(), 40); scene.idle(7); - scene.world.modifyBlock(pumpPos, s -> s.with(PumpBlock.FACING, Direction.EAST), true); + scene.world.modifyBlock(pumpPos, s -> s.setValue(PumpBlock.FACING, Direction.EAST), true); scene.overlay.showText(70) .attachKeyFrame() .pointAt(util.vector.centerOf(2, 1, 1)) @@ -154,14 +154,14 @@ public class PumpScenes { scene.world.propagatePipeChange(pumpPos); scene.idle(40); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb1.offset(util.vector.centerOf(3, 1, 3)), 3); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb1.move(util.vector.centerOf(3, 1, 3)), 3); scene.idle(2); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb2.offset(util.vector.centerOf(3, 1, 2)), 30); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, in, bb2.move(util.vector.centerOf(3, 1, 2)), 30); scene.idle(15); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb1.offset(util.vector.centerOf(1, 1, 1) + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb1.move(util.vector.centerOf(1, 1, 1) .add(0, 0, -.5)), 3); scene.idle(2); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb2.offset(util.vector.centerOf(1, 1, 2)), 30); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, out, bb2.move(util.vector.centerOf(1, 1, 2)), 30); scene.idle(25); } @@ -187,12 +187,12 @@ public class PumpScenes { .drain(3000, FluidAction.EXECUTE)); BlockPos east = pumpPos.east(); - scene.world.setBlock(east, Blocks.AIR.getDefaultState(), false); + scene.world.setBlock(east, Blocks.AIR.defaultBlockState(), false); scene.world.setBlock(east, AllBlocks.GLASS_FLUID_PIPE.getDefaultState() - .with(GlassFluidPipeBlock.AXIS, Axis.X), false); + .setValue(GlassFluidPipeBlock.AXIS, Axis.X), false); scene.world.setBlock(pumpPos.south(), AllBlocks.COGWHEEL.getDefaultState() - .with(CogWheelBlock.AXIS, Axis.X), false); + .setValue(CogWheelBlock.AXIS, Axis.X), false); Selection southPump = util.select.position(pumpPos.south()); scene.world.setKineticSpeed(southPump, 32); @@ -255,34 +255,34 @@ public class PumpScenes { scene.idle(60); BlockState pipeState = AllBlocks.FLUID_PIPE.getDefaultState() - .with(FluidPipeBlock.DOWN, false) - .with(FluidPipeBlock.UP, false); + .setValue(FluidPipeBlock.DOWN, false) + .setValue(FluidPipeBlock.UP, false); scene.world.setKineticSpeed(util.select.everywhere(), 0); scene.idle(10); scene.world.setBlock(east, pipeState, true); scene.world.setBlock(west, pipeState, true); - scene.world.setBlock(east.north(), pipeState.with(FluidPipeBlock.NORTH, false) - .with(FluidPipeBlock.EAST, false), false); - scene.world.setBlock(east.south(), pipeState.with(FluidPipeBlock.SOUTH, false) - .with(FluidPipeBlock.EAST, false), false); + scene.world.setBlock(east.north(), pipeState.setValue(FluidPipeBlock.NORTH, false) + .setValue(FluidPipeBlock.EAST, false), false); + scene.world.setBlock(east.south(), pipeState.setValue(FluidPipeBlock.SOUTH, false) + .setValue(FluidPipeBlock.EAST, false), false); scene.world.showSection(util.select.position(east.north()), Direction.DOWN); scene.world.showSection(util.select.position(east.south()), Direction.DOWN); Selection northPump = util.select.position(pumpPos.north()); - scene.world.setBlock(west.north(), pipeState.with(FluidPipeBlock.NORTH, false) - .with(FluidPipeBlock.WEST, false), false); - scene.world.setBlock(west.south(), pipeState.with(FluidPipeBlock.SOUTH, false) - .with(FluidPipeBlock.WEST, false), false); + scene.world.setBlock(west.north(), pipeState.setValue(FluidPipeBlock.NORTH, false) + .setValue(FluidPipeBlock.WEST, false), false); + scene.world.setBlock(west.south(), pipeState.setValue(FluidPipeBlock.SOUTH, false) + .setValue(FluidPipeBlock.WEST, false), false); scene.world.showSection(util.select.position(west.north()), Direction.DOWN); scene.world.showSection(util.select.position(west.south()), Direction.DOWN); scene.world.restoreBlocks(southPump); - scene.world.modifyBlock(pumpPos.south(), s -> s.with(PumpBlock.FACING, Direction.EAST), false); + scene.world.modifyBlock(pumpPos.south(), s -> s.setValue(PumpBlock.FACING, Direction.EAST), false); scene.world.setKineticSpeed(util.select.everywhere(), 0); scene.world.showSection(northPump, Direction.DOWN); - scene.world.modifyBlock(pumpPos.north(), s -> s.with(PumpBlock.FACING, Direction.EAST), false); + scene.world.modifyBlock(pumpPos.north(), s -> s.setValue(PumpBlock.FACING, Direction.EAST), false); scene.idle(4); scene.world.setKineticSpeed(util.select.everywhere(), -16); @@ -303,13 +303,13 @@ public class PumpScenes { .showControls(new InputWindowElement(util.vector.topOf(pumpPos.south()), Pointing.DOWN).rightClick() .withWrench(), 30); scene.idle(7); - scene.world.modifyBlock(pumpPos.south(), s -> s.with(PumpBlock.FACING, Direction.WEST), true); + scene.world.modifyBlock(pumpPos.south(), s -> s.setValue(PumpBlock.FACING, Direction.WEST), true); scene.idle(30); scene.overlay .showControls(new InputWindowElement(util.vector.topOf(pumpPos.north()), Pointing.DOWN).rightClick() .withWrench(), 30); scene.idle(7); - scene.world.modifyBlock(pumpPos.north(), s -> s.with(PumpBlock.FACING, Direction.WEST), true); + scene.world.modifyBlock(pumpPos.north(), s -> s.setValue(PumpBlock.FACING, Direction.WEST), true); scene.idle(30); scene.overlay.showText(70) diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/SpoutScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/SpoutScenes.java index 6a7f9cd1e..e28dbe06d 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/SpoutScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/SpoutScenes.java @@ -151,8 +151,8 @@ public class SpoutScenes { .add(0, 1 / 16f, 0), Emitter.simple(fluidParticle, VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .1f)), 1, 1); } - scene.world.removeItemsFromBelt(spoutPos.down(2)); - ingot = scene.world.createItemOnBelt(spoutPos.down(2), Direction.UP, potion); + scene.world.removeItemsFromBelt(spoutPos.below(2)); + ingot = scene.world.createItemOnBelt(spoutPos.below(2), Direction.UP, potion); scene.world.stallBeltItem(ingot, true); scene.idle(5); scene.world.stallBeltItem(ingot, false); @@ -165,8 +165,8 @@ public class SpoutScenes { .add(0, 1 / 16f, 0), Emitter.simple(fluidParticle, VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .1f)), 1, 1); } - scene.world.removeItemsFromBelt(spoutPos.down(2)); - ingot2 = scene.world.createItemOnBelt(spoutPos.down(2), Direction.UP, potion); + scene.world.removeItemsFromBelt(spoutPos.below(2)); + ingot2 = scene.world.createItemOnBelt(spoutPos.below(2), Direction.UP, potion); scene.world.stallBeltItem(ingot2, true); scene.idle(5); scene.world.stallBeltItem(ingot2, false); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/AnimatedSceneElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/AnimatedSceneElement.java index d4c619e61..985685916 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/AnimatedSceneElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/AnimatedSceneElement.java @@ -34,27 +34,27 @@ public abstract class AnimatedSceneElement extends PonderSceneElement { @Override public final void renderFirst(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float pt) { - ms.push(); + ms.pushPose(); float currentFade = applyFade(ms, pt); renderFirst(world, buffer, ms, currentFade, pt); - ms.pop(); + ms.popPose(); } @Override public final void renderLayer(PonderWorld world, IRenderTypeBuffer buffer, RenderType type, MatrixStack ms, float pt) { - ms.push(); + ms.pushPose(); float currentFade = applyFade(ms, pt); renderLayer(world, buffer, type, ms, currentFade, pt); - ms.pop(); + ms.popPose(); } @Override public final void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float pt) { - ms.push(); + ms.pushPose(); float currentFade = applyFade(ms, pt); renderLast(world, buffer, ms, currentFade, pt); - ms.pop(); + ms.popPose(); } protected float applyFade(MatrixStack ms, float pt) { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/InputWindowElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/InputWindowElement.java index f87c70c28..b7e2b9e10 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/InputWindowElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/InputWindowElement.java @@ -106,7 +106,7 @@ public class InputWindowElement extends AnimatedOverlayElement { } if (hasText) { - keyWidth = font.getStringWidth(text); + keyWidth = font.width(text); width += keyWidth; } @@ -115,7 +115,7 @@ public class InputWindowElement extends AnimatedOverlayElement { height = 24; } - ms.push(); + ms.pushPose(); ms.translate(sceneToScreen.x + xFade, sceneToScreen.y + yFade, 400); PonderUI.renderSpeechBox(ms, 0, 0, width, height, false, direction, true); @@ -123,15 +123,15 @@ public class InputWindowElement extends AnimatedOverlayElement { ms.translate(0, 0, 100); if (hasText) - font.draw(ms, text, 2, (height - font.FONT_HEIGHT) / 2f + 2, + font.draw(ms, text, 2, (height - font.lineHeight) / 2f + 2, ColorHelper.applyAlpha(PonderPalette.WHITE.getColor(), fade)); if (hasIcon) { - ms.push(); + ms.pushPose(); ms.translate(keyWidth, 0, 0); ms.scale(1.5f, 1.5f, 1.5f); icon.draw(ms, screen, 0, 0); - ms.pop(); + ms.popPose(); } if (hasItem) { @@ -142,7 +142,7 @@ public class InputWindowElement extends AnimatedOverlayElement { RenderSystem.disableDepthTest(); } - ms.pop(); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/MinecartElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/MinecartElement.java index 93c0be467..462686f94 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/MinecartElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/MinecartElement.java @@ -37,13 +37,13 @@ public class MinecartElement extends AnimatedSceneElement { @Override public void reset(PonderScene scene) { super.reset(scene); - entity.setPos(0, 0, 0); - entity.prevPosX = 0; - entity.prevPosY = 0; - entity.prevPosZ = 0; - entity.lastTickPosX = 0; - entity.lastTickPosY = 0; - entity.lastTickPosZ = 0; + entity.setPosRaw(0, 0, 0); + entity.xo = 0; + entity.yo = 0; + entity.zo = 0; + entity.xOld = 0; + entity.yOld = 0; + entity.zOld = 0; rotation.startWithValue(initialRotation); } @@ -53,25 +53,25 @@ public class MinecartElement extends AnimatedSceneElement { if (entity == null) entity = constructor.create(scene.getWorld(), 0, 0, 0); - entity.ticksExisted++; + entity.tickCount++; entity.onGround = true; - entity.prevPosX = entity.getX(); - entity.prevPosY = entity.getY(); - entity.prevPosZ = entity.getZ(); - entity.lastTickPosX = entity.getX(); - entity.lastTickPosY = entity.getY(); - entity.lastTickPosZ = entity.getZ(); + entity.xo = entity.getX(); + entity.yo = entity.getY(); + entity.zo = entity.getZ(); + entity.xOld = entity.getX(); + entity.yOld = entity.getY(); + entity.zOld = entity.getZ(); } public void setPositionOffset(Vector3d position, boolean immediate) { if (entity == null) return; - entity.setPosition(position.x, position.y, position.z); + entity.setPos(position.x, position.y, position.z); if (!immediate) return; - entity.prevPosX = position.x; - entity.prevPosY = position.y; - entity.prevPosZ = position.z; + entity.xo = position.x; + entity.yo = position.y; + entity.zo = position.z; } public void setRotation(float angle, boolean immediate) { @@ -84,7 +84,7 @@ public class MinecartElement extends AnimatedSceneElement { } public Vector3d getPositionOffset() { - return entity != null ? entity.getPositionVec() : Vector3d.ZERO; + return entity != null ? entity.position() : Vector3d.ZERO; } public Vector3d getRotation() { @@ -94,20 +94,20 @@ public class MinecartElement extends AnimatedSceneElement { @Override protected void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float fade, float pt) { EntityRendererManager entityrenderermanager = Minecraft.getInstance() - .getRenderManager(); + .getEntityRenderDispatcher(); if (entity == null) entity = constructor.create(world, 0, 0, 0); - ms.push(); + ms.pushPose(); ms.translate(location.x, location.y, location.z); - ms.translate(MathHelper.lerp(pt, entity.prevPosX, entity.getX()), - MathHelper.lerp(pt, entity.prevPosY, entity.getY()), MathHelper.lerp(pt, entity.prevPosZ, entity.getZ())); + ms.translate(MathHelper.lerp(pt, entity.xo, entity.getX()), + MathHelper.lerp(pt, entity.yo, entity.getY()), MathHelper.lerp(pt, entity.zo, entity.getZ())); MatrixStacker.of(ms) .rotateY(rotation.getValue(pt)); entityrenderermanager.render(entity, 0, 0, 0, 0, pt, ms, buffer, lightCoordsFromFade(fade)); - ms.pop(); + ms.popPose(); } } 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 b43efb782..8c9d88aa4 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 @@ -43,15 +43,15 @@ public class ParrotElement extends AnimatedSceneElement { public void reset(PonderScene scene) { super.reset(scene); setPose(initialPose.get()); - entity.setPos(0, 0, 0); - entity.prevPosX = 0; - entity.prevPosY = 0; - entity.prevPosZ = 0; - entity.lastTickPosX = 0; - entity.lastTickPosY = 0; - entity.lastTickPosZ = 0; - entity.prevRotationPitch = entity.rotationPitch = 0; - entity.prevRotationYaw = entity.rotationYaw = 180; + entity.setPosRaw(0, 0, 0); + entity.xo = 0; + entity.yo = 0; + entity.zo = 0; + entity.xOld = 0; + entity.yOld = 0; + entity.zOld = 0; + entity.xRotO = entity.xRot = 0; + entity.yRotO = entity.yRot = 180; } @Override @@ -59,78 +59,78 @@ public class ParrotElement extends AnimatedSceneElement { super.tick(scene); if (entity == null) { entity = pose.create(scene.getWorld()); - entity.prevRotationYaw = entity.rotationYaw = 180; + entity.yRotO = entity.yRot = 180; } - entity.ticksExisted++; - entity.prevRotationYawHead = entity.rotationYawHead; + entity.tickCount++; + entity.yHeadRotO = entity.yHeadRot; entity.oFlapSpeed = entity.flapSpeed; entity.oFlap = entity.flap; entity.onGround = true; - entity.prevPosX = entity.getX(); - entity.prevPosY = entity.getY(); - entity.prevPosZ = entity.getZ(); - entity.prevRotationYaw = entity.rotationYaw; - entity.prevRotationPitch = entity.rotationPitch; + entity.xo = entity.getX(); + entity.yo = entity.getY(); + entity.zo = entity.getZ(); + entity.yRotO = entity.yRot; + entity.xRotO = entity.xRot; pose.tick(scene, entity, location); - entity.lastTickPosX = entity.getX(); - entity.lastTickPosY = entity.getY(); - entity.lastTickPosZ = entity.getZ(); + entity.xOld = entity.getX(); + entity.yOld = entity.getY(); + entity.zOld = entity.getZ(); } public void setPositionOffset(Vector3d position, boolean immediate) { if (entity == null) return; - entity.setPosition(position.x, position.y, position.z); + entity.setPos(position.x, position.y, position.z); if (!immediate) return; - entity.prevPosX = position.x; - entity.prevPosY = position.y; - entity.prevPosZ = position.z; + entity.xo = position.x; + entity.yo = position.y; + entity.zo = position.z; } public void setRotation(Vector3d eulers, boolean immediate) { if (entity == null) return; - entity.rotationPitch = (float) eulers.x; - entity.rotationYaw = (float) eulers.y; + entity.xRot = (float) eulers.x; + entity.yRot = (float) eulers.y; if (!immediate) return; - entity.prevRotationPitch = entity.rotationPitch; - entity.prevRotationYaw = entity.rotationYaw; + entity.xRotO = entity.xRot; + entity.yRotO = entity.yRot; } public Vector3d getPositionOffset() { - return entity != null ? entity.getPositionVec() : Vector3d.ZERO; + return entity != null ? entity.position() : Vector3d.ZERO; } public Vector3d getRotation() { - return entity != null ? new Vector3d(entity.rotationPitch, entity.rotationYaw, 0) : Vector3d.ZERO; + return entity != null ? new Vector3d(entity.xRot, entity.yRot, 0) : Vector3d.ZERO; } @Override protected void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float fade, float pt) { EntityRendererManager entityrenderermanager = Minecraft.getInstance() - .getRenderManager(); + .getEntityRenderDispatcher(); if (entity == null) { entity = pose.create(world); - entity.prevRotationYaw = entity.rotationYaw = 180; + entity.yRotO = entity.yRot = 180; } - ms.push(); + ms.pushPose(); ms.translate(location.x, location.y, location.z); - ms.translate(MathHelper.lerp(pt, entity.prevPosX, entity.getX()), - MathHelper.lerp(pt, entity.prevPosY, entity.getY()), MathHelper.lerp(pt, entity.prevPosZ, entity.getZ())); + ms.translate(MathHelper.lerp(pt, entity.xo, entity.getX()), + MathHelper.lerp(pt, entity.yo, entity.getY()), MathHelper.lerp(pt, entity.zo, entity.getZ())); MatrixStacker.of(ms) - .rotateY(AngleHelper.angleLerp(pt, entity.prevRotationYaw, entity.rotationYaw)); + .rotateY(AngleHelper.angleLerp(pt, entity.yRotO, entity.yRot)); entityrenderermanager.render(entity, 0, 0, 0, 0, pt, ms, buffer, lightCoordsFromFade(fade)); - ms.pop(); + ms.popPose(); } public void setPose(ParrotPose pose) { @@ -155,14 +155,14 @@ public class ParrotElement extends AnimatedSceneElement { @Override ParrotEntity create(PonderWorld world) { ParrotEntity entity = super.create(world); - entity.setPartying(BlockPos.ZERO, true); + entity.setRecordPlayingNearby(BlockPos.ZERO, true); return entity; } @Override void tick(PonderScene scene, ParrotEntity entity, Vector3d location) { - entity.prevRotationYaw = entity.rotationYaw; - entity.rotationYaw -= 2; + entity.yRotO = entity.yRot; + entity.yRot -= 2; } } @@ -171,8 +171,8 @@ public class ParrotElement extends AnimatedSceneElement { @Override void tick(PonderScene scene, ParrotEntity entity, Vector3d location) { - double length = entity.getPositionVec() - .subtract(entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ) + double length = entity.position() + .subtract(entity.xOld, entity.yOld, entity.zOld) .length(); entity.onGround = false; double phase = Math.min(length * 15, 8); @@ -195,12 +195,12 @@ public class ParrotElement extends AnimatedSceneElement { @Override void tick(PonderScene scene, ParrotEntity entity, Vector3d location) { TileEntity tileEntity = scene.getWorld() - .getTileEntity(componentPos); + .getBlockEntity(componentPos); if (!(tileEntity instanceof KineticTileEntity)) return; float rpm = ((KineticTileEntity) tileEntity).getSpeed(); - entity.prevRotationYaw = entity.rotationYaw; - entity.rotationYaw += (rpm * .3f); + entity.yRotO = entity.yRot; + entity.yRot += (rpm * .3f); } } @@ -220,8 +220,8 @@ public class ParrotElement extends AnimatedSceneElement { float targetYaw = MathHelper.wrapDegrees((float) -(MathHelper.atan2(d2, d0) * (double) (180F / (float) Math.PI)) + 90); - entity.rotationPitch = AngleHelper.angleLerp(.4f, entity.rotationPitch, targetPitch); - entity.rotationYaw = AngleHelper.angleLerp(.4f, entity.rotationYaw, targetYaw); + entity.xRot = AngleHelper.angleLerp(.4f, entity.xRot, targetPitch); + entity.yRot = AngleHelper.angleLerp(.4f, entity.yRot, targetYaw); } protected abstract Vector3d getFacedVec(PonderScene scene); @@ -243,8 +243,8 @@ public class ParrotElement extends AnimatedSceneElement { protected Vector3d getFacedVec(PonderScene scene) { Minecraft minecraft = Minecraft.getInstance(); MainWindow w = minecraft.getWindow(); - double mouseX = minecraft.mouseHelper.getMouseX() * w.getScaledWidth() / w.getWidth(); - double mouseY = minecraft.mouseHelper.getMouseY() * w.getScaledHeight() / w.getHeight(); + double mouseX = minecraft.mouseHandler.xpos() * w.getGuiScaledWidth() / w.getScreenWidth(); + double mouseY = minecraft.mouseHandler.ypos() * w.getGuiScaledHeight() / w.getScreenHeight(); return scene.getTransform() .screenToScene(mouseX, mouseY, 300, 0); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/TextWindowElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/TextWindowElement.java index 31da2fb41..34c20efdc 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/TextWindowElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/TextWindowElement.java @@ -100,16 +100,16 @@ public class TextWindowElement extends AnimatedOverlayElement { int textWidth = Math.min(screen.width - targetX, 180); - List lines = screen.getFontRenderer().getTextHandler().wrapLines(bakedText, textWidth, Style.EMPTY); + List lines = screen.getFontRenderer().getSplitter().splitLines(bakedText, textWidth, Style.EMPTY); int boxWidth = 0; for (ITextProperties line : lines) - boxWidth = Math.max(boxWidth, screen.getFontRenderer().getWidth(line)); + boxWidth = Math.max(boxWidth, screen.getFontRenderer().width(line)); int boxHeight = screen.getFontRenderer() - .getWordWrappedHeight(bakedText, boxWidth); + .wordWrapHeight(bakedText, boxWidth); - ms.push(); + ms.pushPose(); ms.translate(0, sceneToScreen.y, 400); new BoxElement() @@ -123,14 +123,14 @@ public class TextWindowElement extends AnimatedOverlayElement { int brighterColor = ColorHelper.mixAlphaColors(color, 0xFFffffdd, 1 / 2f); if (vec != null) { - ms.push(); + ms.pushPose(); ms.translate(sceneToScreen.x, 0, 0); double lineTarget = (targetX - sceneToScreen.x) * fade; ms.scale((float) lineTarget, 1, 1); - Matrix4f model = ms.peek().getModel(); + Matrix4f model = ms.last().pose(); GuiUtils.drawGradientRect(model, -100, 0, 0, 1, 1, brighterColor, brighterColor); GuiUtils.drawGradientRect(model, -100, 0, 1, 1, 2, 0xFF494949, 0xFF393939); - ms.pop(); + ms.popPose(); } ms.translate(0, 0, 400); @@ -139,7 +139,7 @@ public class TextWindowElement extends AnimatedOverlayElement { .draw(ms, lines.get(i) .getString(), targetX - 10, 3 + 9 * i, ColorHelper.applyAlpha(brighterColor, fade)); } - ms.pop(); + ms.popPose(); } public int getColor() { 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 9646753ee..f9d0c02e7 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 @@ -180,22 +180,22 @@ public class WorldSectionElement extends AnimatedSceneElement { public Pair rayTrace(PonderWorld world, Vector3d source, Vector3d target) { world.setMask(this.section); Vector3d transformedTarget = reverseTransformVec(target); - BlockRayTraceResult rayTraceBlocks = world.rayTraceBlocks(new RayTraceContext(reverseTransformVec(source), + BlockRayTraceResult rayTraceBlocks = world.clip(new RayTraceContext(reverseTransformVec(source), transformedTarget, BlockMode.OUTLINE, FluidMode.NONE, null)); world.clearMask(); if (rayTraceBlocks == null) return null; - if (rayTraceBlocks.getHitVec() == null) + if (rayTraceBlocks.getLocation() == null) return null; - double t = rayTraceBlocks.getHitVec() + double t = rayTraceBlocks.getLocation() .subtract(transformedTarget) - .lengthSquared() + .lengthSqr() / source.subtract(target) - .lengthSquared(); + .lengthSqr(); Vector3d actualHit = VecHelper.lerp((float) t, target, source); - return Pair.of(actualHit, rayTraceBlocks.getPos()); + return Pair.of(actualHit, rayTraceBlocks.getBlockPos()); } private Vector3d reverseTransformVec(Vector3d in) { @@ -256,9 +256,9 @@ public class WorldSectionElement extends AnimatedSceneElement { return; loadTEsIfMissing(scene.getWorld()); renderedTileEntities.removeIf(te -> scene.getWorld() - .getTileEntity(te.getPos()) != te); + .getBlockEntity(te.getBlockPos()) != te); tickableTileEntities.removeIf(te -> scene.getWorld() - .getTileEntity(te.getPos()) != te); + .getBlockEntity(te.getBlockPos()) != te); tickableTileEntities.forEach(te -> { if (te instanceof ITickableTileEntity) ((ITickableTileEntity) te).tick(); @@ -280,12 +280,12 @@ public class WorldSectionElement extends AnimatedSceneElement { tickableTileEntities = new ArrayList<>(); renderedTileEntities = new ArrayList<>(); section.forEach(pos -> { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (tileEntity == null) return; tickableTileEntities.add(tileEntity); renderedTileEntities.add(tileEntity); - tileEntity.updateContainingBlockInfo(); + tileEntity.clearCache(); }); } @@ -323,16 +323,16 @@ public class WorldSectionElement extends AnimatedSceneElement { .apply(overlayMS, pt, true); transformMS(overlayMS, pt); } - ms.push(); + ms.pushPose(); ms.translate(pos.getX(), pos.getY(), pos.getZ()); IVertexBuilder builder = new MatrixApplyingVertexBuilder( - buffer.getBuffer(ModelBakery.BLOCK_DESTRUCTION_RENDER_LAYERS.get(entry.getValue())), - overlayMS.peek().getModel(), - overlayMS.peek().getNormal()); + buffer.getBuffer(ModelBakery.DESTROY_TYPES.get(entry.getValue())), + overlayMS.last().pose(), + overlayMS.last().normal()); Minecraft.getInstance() - .getBlockRendererDispatcher() - .renderModel(world.getBlockState(pos), pos, world, ms, builder, true, world.rand, EmptyModelData.INSTANCE); - ms.pop(); + .getBlockRenderer() + .renderModel(world.getBlockState(pos), pos, world, ms, builder, true, world.random, EmptyModelData.INSTANCE); + ms.popPose(); } } @@ -341,7 +341,7 @@ public class WorldSectionElement extends AnimatedSceneElement { SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE; int code = hashCode() ^ world.hashCode(); - Pair key = Pair.of(code, RenderType.getBlockLayers() + Pair key = Pair.of(code, RenderType.chunkBufferLayers() .indexOf(type)); if (redraw) bufferCache.invalidate(DOC_WORLD_SECTION, key); @@ -364,16 +364,16 @@ public class WorldSectionElement extends AnimatedSceneElement { if (blockState.isAir()) return; VoxelShape shape = - blockState.getShape(world, selectedBlock, ISelectionContext.forEntity(Minecraft.getInstance().player)); + blockState.getShape(world, selectedBlock, ISelectionContext.of(Minecraft.getInstance().player)); if (shape.isEmpty()) return; - ms.push(); + ms.pushPose(); transformMS(ms, pt); RenderSystem.disableTexture(); - WorldRenderer.drawBox(ms, buffer.getBuffer(RenderType.getLines()), shape.getBoundingBox() - .offset(selectedBlock), 1, 1, 1, 0.6f); - ms.pop(); + WorldRenderer.renderLineBox(ms, buffer.getBuffer(RenderType.lines()), shape.bounds() + .move(selectedBlock), 1, 1, 1, 0.6f); + ms.popPose(); } private void renderTileEntities(PonderWorld world, MatrixStack ms, IRenderTypeBuffer buffer, float pt) { @@ -385,8 +385,8 @@ public class WorldSectionElement extends AnimatedSceneElement { ForgeHooksClient.setRenderLayer(layer); MatrixStack ms = new MatrixStack(); BlockRendererDispatcher dispatcher = Minecraft.getInstance() - .getBlockRendererDispatcher(); - BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer(); + .getBlockRenderer(); + BlockModelRenderer blockRenderer = dispatcher.getModelRenderer(); Random random = new Random(); BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); @@ -396,25 +396,25 @@ public class WorldSectionElement extends AnimatedSceneElement { BlockState state = world.getBlockState(pos); FluidState ifluidstate = world.getFluidState(pos); - ms.push(); + ms.pushPose(); ms.translate(pos.getX(), pos.getY(), pos.getZ()); - if (state.getRenderType() != BlockRenderType.ENTITYBLOCK_ANIMATED && state.getBlock() != Blocks.AIR + if (state.getRenderShape() != BlockRenderType.ENTITYBLOCK_ANIMATED && state.getBlock() != Blocks.AIR && RenderTypeLookup.canRenderInLayer(state, layer)) { - TileEntity tileEntity = world.getTileEntity(pos); - blockRenderer.renderModel(world, dispatcher.getModelForState(state), state, pos, ms, builder, true, - random, 42, OverlayTexture.DEFAULT_UV, + TileEntity tileEntity = world.getBlockEntity(pos); + blockRenderer.renderModel(world, dispatcher.getBlockModel(state), state, pos, ms, builder, true, + random, 42, OverlayTexture.NO_OVERLAY, tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE); } if (!ifluidstate.isEmpty() && RenderTypeLookup.canRenderInLayer(ifluidstate, layer)) - dispatcher.renderFluid(pos, world, builder, ifluidstate); + dispatcher.renderLiquid(pos, world, builder, ifluidstate); - ms.pop(); + ms.popPose(); }); world.clearMask(); - builder.finishDrawing(); + builder.end(); return new SuperByteBuffer(builder); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateTileEntityInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateTileEntityInstruction.java index 273d520b2..74d943fd0 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateTileEntityInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateTileEntityInstruction.java @@ -74,7 +74,7 @@ public class AnimateTileEntityInstruction extends TickingInstruction { } private static Optional castIfPresent(PonderWorld world, BlockPos pos, Class teType) { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (teType.isInstance(tileEntity)) return Optional.of(teType.cast(tileEntity)); return Optional.empty(); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/EmitParticlesInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/EmitParticlesInstruction.java index ff4fa77b9..d66a4c2a9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/EmitParticlesInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/EmitParticlesInstruction.java @@ -29,7 +29,7 @@ public class EmitParticlesInstruction extends TickingInstruction { } static ParticleManager paticleManager() { - return Minecraft.getInstance().particles; + return Minecraft.getInstance().particleEngine; } public void create(PonderWorld world, double x, double y, double z); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/FadeIntoSceneInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/FadeIntoSceneInstruction.java index 10a1bbaa9..be5faf3e2 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/FadeIntoSceneInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/FadeIntoSceneInstruction.java @@ -25,7 +25,7 @@ public abstract class FadeIntoSceneInstruction e scene.addElement(element); element.setVisible(true); element.setFade(0); - element.setFadeVec(Vector3d.of(fadeInFrom.getDirectionVec()).scale(.5f)); + element.setFadeVec(Vector3d.atLowerCornerOf(fadeInFrom.getNormal()).scale(.5f)); if (elementLink != null) scene.linkElement(element, elementLink); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/FadeOutOfSceneInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/FadeOutOfSceneInstruction.java index 269ca682a..83680d1a2 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/FadeOutOfSceneInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/FadeOutOfSceneInstruction.java @@ -27,7 +27,7 @@ public class FadeOutOfSceneInstruction extends T return; element.setVisible(true); element.setFade(1); - element.setFadeVec(Vector3d.of(fadeOutTo.getDirectionVec()).scale(.5f)); + element.setFadeVec(Vector3d.atLowerCornerOf(fadeOutTo.getNormal()).scale(.5f)); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/HideAllInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/HideAllInstruction.java index 227893e68..63e0f91ef 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/HideAllInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/HideAllInstruction.java @@ -25,7 +25,7 @@ public class HideAllInstruction extends TickingInstruction { AnimatedSceneElement animatedSceneElement = (AnimatedSceneElement) element; animatedSceneElement.setFade(1); animatedSceneElement - .setFadeVec(fadeOutTo == null ? null : Vector3d.of(fadeOutTo.getDirectionVec()).scale(.5f)); + .setFadeVec(fadeOutTo == null ? null : Vector3d.atLowerCornerOf(fadeOutTo.getNormal()).scale(.5f)); } else if (element instanceof AnimatedOverlayElement) { AnimatedOverlayElement animatedSceneElement = (AnimatedOverlayElement) element; animatedSceneElement.setFade(1); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/HighlightValueBoxInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/HighlightValueBoxInstruction.java index b00f89dd2..95207ad96 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/HighlightValueBoxInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/HighlightValueBoxInstruction.java @@ -21,7 +21,7 @@ public class HighlightValueBoxInstruction extends TickingInstruction { public void tick(PonderScene scene) { super.tick(scene); AxisAlignedBB point = new AxisAlignedBB(vec, vec); - AxisAlignedBB expanded = point.grow(expands.x, expands.y, expands.z); + AxisAlignedBB expanded = point.inflate(expands.x, expands.y, expands.z); scene.getOutliner() .chaseAABB(vec, remainingTicks == totalTicks ? point : expanded) .lineWidth(1 / 32f) diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/ReplaceBlocksInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/ReplaceBlocksInstruction.java index d71ad0919..e2e9d016b 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/ReplaceBlocksInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/ReplaceBlocksInstruction.java @@ -28,14 +28,14 @@ public class ReplaceBlocksInstruction extends WorldModifyInstruction { PonderWorld world = scene.getWorld(); selection.forEach(pos -> { if (!world.getBounds() - .isVecInside(pos)) + .isInside(pos)) return; BlockState prevState = world.getBlockState(pos); - if (!replaceAir && prevState == Blocks.AIR.getDefaultState()) + if (!replaceAir && prevState == Blocks.AIR.defaultBlockState()) return; if (spawnParticles) world.addBlockDestroyEffects(pos, prevState); - world.setBlockState(pos, stateToUse.apply(prevState)); + world.setBlockAndUpdate(pos, stateToUse.apply(prevState)); }); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/TileEntityDataInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/TileEntityDataInstruction.java index 391b73063..2a8a46b3d 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/TileEntityDataInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/TileEntityDataInstruction.java @@ -30,16 +30,16 @@ public class TileEntityDataInstruction extends WorldModifyInstruction { PonderWorld world = scene.getWorld(); selection.forEach(pos -> { if (!world.getBounds() - .isVecInside(pos)) + .isInside(pos)) return; - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getBlockEntity(pos); if (!type.isInstance(tileEntity)) return; - CompoundNBT apply = data.apply(tileEntity.write(new CompoundNBT())); + CompoundNBT apply = data.apply(tileEntity.save(new CompoundNBT())); BlockState state = world.getBlockState(pos); if (tileEntity instanceof SyncedTileEntity) ((SyncedTileEntity) tileEntity).readClientUpdate(state, apply); - tileEntity.fromTag(state, apply); + tileEntity.load(state, apply); }); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/ui/ChapterLabel.java b/src/main/java/com/simibubi/create/foundation/ponder/ui/ChapterLabel.java index c77273bab..7390a2457 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/ui/ChapterLabel.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/ui/ChapterLabel.java @@ -31,7 +31,7 @@ public class ChapterLabel extends AbstractSimiWidget { @Override public void render(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { UIRenderHelper.streak(ms, 0, x, y + height / 2, height - 2, width); - Minecraft.getInstance().fontRenderer.draw(ms, Lang.translate("ponder.chapter." + chapter.getId()), x + 50, + Minecraft.getInstance().font.draw(ms, Lang.translate("ponder.chapter." + chapter.getId()), x + 50, y + 20, Theme.i(Theme.Key.TEXT_ACCENT_SLIGHT)); button.renderButton(ms, mouseX, mouseY, partialTicks); 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 66d348cfe..b26c91ba6 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 @@ -102,7 +102,7 @@ public class PonderButton extends BoxWidget { if (shortcut != null) { ms.translate(0, 0, z + 50); - drawCenteredText(ms, Minecraft.getInstance().fontRenderer, shortcut.getBoundKeyLocalizedText(), x + width / 2 + 8, y + height - 6, ColorHelper.applyAlpha(Theme.i(Theme.Key.TEXT_DARKER), fadeValue)); + drawCenteredString(ms, Minecraft.getInstance().font, shortcut.getTranslatedKeyMessage(), x + width / 2 + 8, y + height - 6, ColorHelper.applyAlpha(Theme.i(Theme.Key.TEXT_DARKER), fadeValue)); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java index 7a8af4c23..6e724722c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java +++ b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java @@ -20,7 +20,7 @@ public class PartialBufferer { } public static SuperByteBuffer getFacing(PartialModel partial, BlockState referenceState) { - Direction facing = referenceState.get(FACING); + Direction facing = referenceState.getValue(FACING); return getFacing(partial, referenceState, facing); } diff --git a/src/main/java/com/simibubi/create/foundation/render/ShadowRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/ShadowRenderHelper.java index e5d31c07f..57296b74b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/ShadowRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/ShadowRenderHelper.java @@ -23,26 +23,26 @@ import net.minecraft.world.IWorldReader; public class ShadowRenderHelper { private static final RenderType SHADOW_LAYER = - RenderType.getEntityNoOutline(new ResourceLocation("textures/misc/shadow.png")); + RenderType.entityNoOutline(new ResourceLocation("textures/misc/shadow.png")); public static void renderShadow(MatrixStack p_229096_0_, IRenderTypeBuffer p_229096_1_, Vector3d pos, float p_229096_3_, float p_229096_6_) { float f = p_229096_6_; - double d2 = pos.getX(); - double d0 = pos.getY(); - double d1 = pos.getZ(); + double d2 = pos.x(); + double d0 = pos.y(); + double d1 = pos.z(); int i = MathHelper.floor(d2 - (double) f); int j = MathHelper.floor(d2 + (double) f); int k = MathHelper.floor(d0 - (double) f); int l = MathHelper.floor(d0); int i1 = MathHelper.floor(d1 - (double) f); int j1 = MathHelper.floor(d1 + (double) f); - MatrixStack.Entry matrixstack$entry = p_229096_0_.peek(); + MatrixStack.Entry matrixstack$entry = p_229096_0_.last(); IVertexBuilder ivertexbuilder = p_229096_1_.getBuffer(SHADOW_LAYER); - for (BlockPos blockpos : BlockPos.getAllInBoxMutable(new BlockPos(i, k, i1), new BlockPos(j, l, j1))) { - renderShadowPart(matrixstack$entry, ivertexbuilder, Minecraft.getInstance().world, blockpos, d2, d0, d1, f, + for (BlockPos blockpos : BlockPos.betweenClosed(new BlockPos(i, k, i1), new BlockPos(j, l, j1))) { + renderShadowPart(matrixstack$entry, ivertexbuilder, Minecraft.getInstance().level, blockpos, d2, d0, d1, f, p_229096_3_); } @@ -51,11 +51,11 @@ public class ShadowRenderHelper { private static void renderShadowPart(MatrixStack.Entry p_229092_0_, IVertexBuilder p_229092_1_, IWorldReader p_229092_2_, BlockPos p_229092_3_, double p_229092_4_, double p_229092_6_, double p_229092_8_, float p_229092_10_, float p_229092_11_) { - BlockPos blockpos = p_229092_3_.down(); + BlockPos blockpos = p_229092_3_.below(); BlockState blockstate = p_229092_2_.getBlockState(blockpos); - if (blockstate.getRenderType() != BlockRenderType.INVISIBLE && p_229092_2_.getLight(p_229092_3_) > 3) { - if (blockstate.isFullCube(p_229092_2_, blockpos)) { - VoxelShape voxelshape = blockstate.getShape(p_229092_2_, p_229092_3_.down()); + if (blockstate.getRenderShape() != BlockRenderType.INVISIBLE && p_229092_2_.getMaxLocalRawBrightness(p_229092_3_) > 3) { + if (blockstate.isCollisionShapeFullBlock(p_229092_2_, blockpos)) { + VoxelShape voxelshape = blockstate.getShape(p_229092_2_, p_229092_3_.below()); if (!voxelshape.isEmpty()) { @SuppressWarnings("deprecation") float f = (float) (((double) p_229092_11_ - (p_229092_6_ - (double) p_229092_3_.getY()) / 2.0D) @@ -65,7 +65,7 @@ public class ShadowRenderHelper { f = 1.0F; } - AxisAlignedBB axisalignedbb = voxelshape.getBoundingBox(); + AxisAlignedBB axisalignedbb = voxelshape.bounds(); double d0 = (double) p_229092_3_.getX() + axisalignedbb.minX; double d1 = (double) p_229092_3_.getX() + axisalignedbb.maxX; double d2 = (double) p_229092_3_.getY() + axisalignedbb.minY; @@ -93,12 +93,12 @@ public class ShadowRenderHelper { private static void shadowVertex(MatrixStack.Entry p_229091_0_, IVertexBuilder p_229091_1_, float p_229091_2_, float p_229091_3_, float p_229091_4_, float p_229091_5_, float p_229091_6_, float p_229091_7_) { - p_229091_1_.vertex(p_229091_0_.getModel(), p_229091_3_, p_229091_4_, p_229091_5_) + p_229091_1_.vertex(p_229091_0_.pose(), p_229091_3_, p_229091_4_, p_229091_5_) .color(1.0F, 1.0F, 1.0F, p_229091_2_) - .texture(p_229091_6_, p_229091_7_) - .overlay(OverlayTexture.DEFAULT_UV) - .light(15728880) - .normal(p_229091_0_.getNormal(), 0.0F, 1.0F, 0.0F) + .uv(p_229091_6_, p_229091_7_) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(15728880) + .normal(p_229091_0_.normal(), 0.0F, 1.0F, 0.0F) .endVertex(); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index b2da5f4bf..2e0b21da8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -44,7 +44,7 @@ public class SuperByteBuffer { // Vertex Overlay Color private boolean hasOverlay; - private int overlay = OverlayTexture.DEFAULT_UV;; + private int overlay = OverlayTexture.NO_OVERLAY;; // Vertex Lighting private boolean useWorldLight; @@ -68,33 +68,33 @@ public class SuperByteBuffer { } public static float getUnInterpolatedU(TextureAtlasSprite sprite, float u) { - float f = sprite.getMaxU() - sprite.getMinU(); - return (u - sprite.getMinU()) / f * 16.0F; + float f = sprite.getU1() - sprite.getU0(); + return (u - sprite.getU0()) / f * 16.0F; } public static float getUnInterpolatedV(TextureAtlasSprite sprite, float v) { - float f = sprite.getMaxV() - sprite.getMinV(); - return (v - sprite.getMinV()) / f * 16.0F; + float f = sprite.getV1() - sprite.getV0(); + return (v - sprite.getV0()) / f * 16.0F; } public void renderInto(MatrixStack input, IVertexBuilder builder) { if (isEmpty()) return; - Matrix4f modelMat = input.peek() - .getModel() + Matrix4f modelMat = input.last() + .pose() .copy(); - Matrix4f localTransforms = transforms.peek() - .getModel(); + Matrix4f localTransforms = transforms.last() + .pose(); modelMat.multiply(localTransforms); Matrix3f normalMat; if (fullNormalTransform) { - normalMat = input.peek().getNormal().copy(); - Matrix3f localNormalTransforms = transforms.peek().getNormal(); - normalMat.multiply(localNormalTransforms); + normalMat = input.last().normal().copy(); + Matrix3f localNormalTransforms = transforms.last().normal(); + normalMat.mul(localNormalTransforms); } else { - normalMat = transforms.peek().getNormal().copy(); + normalMat = transforms.last().normal().copy(); } if (useWorldLight) { @@ -117,16 +117,16 @@ public class SuperByteBuffer { normal.set(normalX, normalY, normalZ); normal.transform(normalMat); - float nx = normal.getX(); - float ny = normal.getY(); - float nz = normal.getZ(); + float nx = normal.x(); + float ny = normal.y(); + float nz = normal.z(); float staticDiffuse = LightUtil.diffuseLight(normalX, normalY, normalZ); float instanceDiffuse = LightUtil.diffuseLight(nx, ny, nz); pos.set(x, y, z, 1F); pos.transform(modelMat); - builder.vertex(pos.getX(), pos.getY(), pos.getZ()); + builder.vertex(pos.x(), pos.y(), pos.z()); if (shouldColor) { if (disableDiffuseMult) { @@ -161,11 +161,11 @@ public class SuperByteBuffer { if (spriteShiftFunc != null) { spriteShiftFunc.shift(builder, u, v); } else { - builder.texture(u, v); + builder.uv(u, v); } if (hasOverlay) { - builder.overlay(overlay); + builder.overlayCoords(overlay); } int light; @@ -176,7 +176,7 @@ public class SuperByteBuffer { lightPos.transform(lightTransform); } - light = getLight(Minecraft.getInstance().world, lightPos); + light = getLight(Minecraft.getInstance().level, lightPos); if (hasCustomLight) { light = maxLight(light, packedLightCoords); } @@ -187,9 +187,9 @@ public class SuperByteBuffer { } if (hybridLight) { - builder.light(maxLight(light, template.getLight(i))); + builder.uv2(maxLight(light, template.getLight(i))); } else { - builder.light(light); + builder.uv2(light); } builder.normal(nx, ny, nz); @@ -211,7 +211,7 @@ public class SuperByteBuffer { disableDiffuseMult = false; spriteShiftFunc = null; hasOverlay = false; - overlay = OverlayTexture.DEFAULT_UV; + overlay = OverlayTexture.NO_OVERLAY; useWorldLight = false; lightTransform = null; hasCustomLight = false; @@ -239,27 +239,27 @@ public class SuperByteBuffer { } public SuperByteBuffer transform(MatrixStack stack) { - transforms.peek() - .getModel() - .multiply(stack.peek() - .getModel()); - transforms.peek() - .getNormal() - .multiply(stack.peek() - .getNormal()); + transforms.last() + .pose() + .multiply(stack.last() + .pose()); + transforms.last() + .normal() + .mul(stack.last() + .normal()); return this; } public SuperByteBuffer rotate(Direction axis, float radians) { if (radians == 0) return this; - transforms.multiply(axis.getUnitVector() - .getRadialQuaternion(radians)); + transforms.mulPose(axis.step() + .rotation(radians)); return this; } public SuperByteBuffer rotate(Quaternion q) { - transforms.multiply(q); + transforms.mulPose(q); return this; } @@ -313,10 +313,10 @@ public class SuperByteBuffer { public SuperByteBuffer shiftUV(SpriteShiftEntry entry) { this.spriteShiftFunc = (builder, u, v) -> { float targetU = entry.getTarget() - .getInterpolatedU((getUnInterpolatedU(entry.getOriginal(), u))); + .getU((getUnInterpolatedU(entry.getOriginal(), u))); float targetV = entry.getTarget() - .getInterpolatedV((getUnInterpolatedV(entry.getOriginal(), v))); - builder.texture(targetU, targetV); + .getV((getUnInterpolatedV(entry.getOriginal(), v))); + builder.uv(targetU, targetV); }; return this; } @@ -324,13 +324,13 @@ public class SuperByteBuffer { public SuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollV) { this.spriteShiftFunc = (builder, u, v) -> { float targetU = u - entry.getOriginal() - .getMinU() + entry.getTarget() - .getMinU(); + .getU0() + entry.getTarget() + .getU0(); float targetV = v - entry.getOriginal() - .getMinV() + entry.getTarget() - .getMinV() + .getV0() + entry.getTarget() + .getV0() + scrollV; - builder.texture(targetU, targetV); + builder.uv(targetU, targetV); }; return this; } @@ -338,10 +338,10 @@ public class SuperByteBuffer { public SuperByteBuffer shiftUVtoSheet(SpriteShiftEntry entry, float uTarget, float vTarget, int sheetSize) { this.spriteShiftFunc = (builder, u, v) -> { float targetU = entry.getTarget() - .getInterpolatedU((getUnInterpolatedU(entry.getOriginal(), u) / sheetSize) + uTarget * 16); + .getU((getUnInterpolatedU(entry.getOriginal(), u) / sheetSize) + uTarget * 16); float targetV = entry.getTarget() - .getInterpolatedV((getUnInterpolatedV(entry.getOriginal(), v) / sheetSize) + vTarget * 16); - builder.texture(targetU, targetV); + .getV((getUnInterpolatedV(entry.getOriginal(), v) / sheetSize) + vTarget * 16); + builder.uv(targetU, targetV); }; return this; } @@ -417,16 +417,16 @@ public class SuperByteBuffer { } public static int maxLight(int packedLight1, int packedLight2) { - int blockLight1 = LightTexture.getBlockLightCoordinates(packedLight1); - int skyLight1 = LightTexture.getSkyLightCoordinates(packedLight1); - int blockLight2 = LightTexture.getBlockLightCoordinates(packedLight2); - int skyLight2 = LightTexture.getSkyLightCoordinates(packedLight2); + int blockLight1 = LightTexture.block(packedLight1); + int skyLight1 = LightTexture.sky(packedLight1); + int blockLight2 = LightTexture.block(packedLight2); + int skyLight2 = LightTexture.sky(packedLight2); return LightTexture.pack(Math.max(blockLight1, blockLight2), Math.max(skyLight1, skyLight2)); } private static int getLight(World world, Vector4f lightPos) { - BlockPos pos = new BlockPos(lightPos.getX(), lightPos.getY(), lightPos.getZ()); - return WORLD_LIGHT_CACHE.computeIfAbsent(pos.toLong(), $ -> WorldRenderer.getLightmapCoordinates(world, pos)); + BlockPos pos = new BlockPos(lightPos.x(), lightPos.y(), lightPos.z()); + return WORLD_LIGHT_CACHE.computeIfAbsent(pos.asLong(), $ -> WorldRenderer.getLightColor(world, pos)); } @FunctionalInterface diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java index d11742f51..6b7131c3f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java @@ -99,8 +99,8 @@ public class SuperByteBufferCache { private SuperByteBuffer standardBlockRender(BlockState renderedState) { BlockRendererDispatcher dispatcher = Minecraft.getInstance() - .getBlockRendererDispatcher(); - return standardModelRender(dispatcher.getModelForState(renderedState), renderedState); + .getBlockRenderer(); + return standardModelRender(dispatcher.getBlockModel(renderedState), renderedState); } private SuperByteBuffer standardModelRender(IBakedModel model, BlockState referenceState) { @@ -115,14 +115,14 @@ public class SuperByteBufferCache { public static BufferBuilder getBufferBuilder(IBakedModel model, BlockState referenceState, MatrixStack ms) { Minecraft mc = Minecraft.getInstance(); - BlockRendererDispatcher dispatcher = mc.getBlockRendererDispatcher(); - BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer(); + BlockRendererDispatcher dispatcher = mc.getBlockRenderer(); + BlockModelRenderer blockRenderer = dispatcher.getModelRenderer(); BufferBuilder builder = new BufferBuilder(512); builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - blockRenderer.renderModel(mc.world, model, referenceState, BlockPos.ZERO.up(255), ms, builder, true, - mc.world.rand, 42, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); - builder.finishDrawing(); + blockRenderer.renderModel(mc.level, model, referenceState, BlockPos.ZERO.above(255), ms, builder, true, + mc.level.random, 42, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); + builder.end(); return builder; } diff --git a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java index cf33b7f0e..bbafddf47 100644 --- a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java @@ -54,8 +54,8 @@ public class TileEntityRenderHelper { continue; } - BlockPos pos = tileEntity.getPos(); - ms.push(); + BlockPos pos = tileEntity.getBlockPos(); + ms.pushPose(); MatrixStacker.of(ms) .translate(pos); @@ -64,12 +64,12 @@ public class TileEntityRenderHelper { if (lightTransform != null) { Vector4f lightVec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1); lightVec.transform(lightTransform); - lightPos = new BlockPos(lightVec.getX(), lightVec.getY(), lightVec.getZ()); + lightPos = new BlockPos(lightVec.x(), lightVec.y(), lightVec.z()); } else { lightPos = pos; } int worldLight = getCombinedLight(world, lightPos, renderWorld, pos); - renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.DEFAULT_UV); + renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY); } catch (Exception e) { iterator.remove(); @@ -83,16 +83,16 @@ public class TileEntityRenderHelper { Create.LOGGER.error(message); } - ms.pop(); + ms.popPose(); } } public static int getCombinedLight(World world, BlockPos worldPos, @Nullable PlacementSimulationWorld renderWorld, BlockPos renderWorldPos) { - int worldLight = WorldRenderer.getLightmapCoordinates(world, worldPos); + int worldLight = WorldRenderer.getLightColor(world, worldPos); if (renderWorld != null) { - int renderWorldLight = WorldRenderer.getLightmapCoordinates(renderWorld, renderWorldPos); + int renderWorldLight = WorldRenderer.getLightColor(renderWorld, renderWorldPos); return SuperByteBuffer.maxLight(worldLight, renderWorldLight); } diff --git a/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java b/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java index 4250dd03c..761271ddb 100644 --- a/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java +++ b/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java @@ -15,82 +15,82 @@ public class RenderTypes extends RenderState { public static RenderType getOutlineTranslucent(ResourceLocation texture, boolean cull) { RenderType.State rendertype$state = RenderType.State.builder() - .texture(new RenderState.TextureState(texture, false, false)) - .transparency(TRANSLUCENT_TRANSPARENCY) - .diffuseLighting(ENABLE_DIFFUSE_LIGHTING) - .alpha(ONE_TENTH_ALPHA) - .cull(cull ? ENABLE_CULLING : DISABLE_CULLING) - .lightmap(ENABLE_LIGHTMAP) - .overlay(ENABLE_OVERLAY_COLOR) - .build(true); - return RenderType.of(createLayerName("outline_translucent" + (cull ? "_cull" : "")), - DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, true, rendertype$state); + .setTextureState(new RenderState.TextureState(texture, false, false)) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setDiffuseLightingState(DIFFUSE_LIGHTING) + .setAlphaState(DEFAULT_ALPHA) + .setCullState(cull ? CULL : NO_CULL) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true); + return RenderType.create(createLayerName("outline_translucent" + (cull ? "_cull" : "")), + DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, rendertype$state); } private static final RenderType OUTLINE_SOLID = - RenderType.of(createLayerName("outline_solid"), DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, + RenderType.create(createLayerName("outline_solid"), DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, false, RenderType.State.builder() - .texture(new RenderState.TextureState(AllSpecialTextures.BLANK.getLocation(), false, false)) - .diffuseLighting(ENABLE_DIFFUSE_LIGHTING) - .lightmap(ENABLE_LIGHTMAP) - .overlay(ENABLE_OVERLAY_COLOR) - .build(true)); + .setTextureState(new RenderState.TextureState(AllSpecialTextures.BLANK.getLocation(), false, false)) + .setDiffuseLightingState(DIFFUSE_LIGHTING) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); public static RenderType getGlowingSolid(ResourceLocation texture) { RenderType.State rendertype$state = RenderType.State.builder() - .texture(new RenderState.TextureState(texture, false, false)) - .lightmap(ENABLE_LIGHTMAP) - .overlay(ENABLE_OVERLAY_COLOR) - .build(true); - return RenderType.of(createLayerName("glowing_solid"), DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, + .setTextureState(new RenderState.TextureState(texture, false, false)) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true); + return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, false, rendertype$state); } public static RenderType getGlowingTranslucent(ResourceLocation texture) { RenderType.State rendertype$state = RenderType.State.builder() - .texture(new RenderState.TextureState(texture, false, false)) - .transparency(TRANSLUCENT_TRANSPARENCY) - .alpha(ONE_TENTH_ALPHA) - .cull(DISABLE_CULLING) - .lightmap(ENABLE_LIGHTMAP) - .overlay(ENABLE_OVERLAY_COLOR) - .build(true); - return RenderType.of(createLayerName("glowing_translucent"), DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, + .setTextureState(new RenderState.TextureState(texture, false, false)) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setAlphaState(DEFAULT_ALPHA) + .setCullState(NO_CULL) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true); + return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, rendertype$state); } - private static final RenderType GLOWING_SOLID = getGlowingSolid(PlayerContainer.BLOCK_ATLAS_TEXTURE); - private static final RenderType GLOWING_TRANSLUCENT = getGlowingTranslucent(PlayerContainer.BLOCK_ATLAS_TEXTURE); + private static final RenderType GLOWING_SOLID = getGlowingSolid(PlayerContainer.BLOCK_ATLAS); + private static final RenderType GLOWING_TRANSLUCENT = getGlowingTranslucent(PlayerContainer.BLOCK_ATLAS); private static final RenderType ITEM_PARTIAL_SOLID = - RenderType.of(createLayerName("item_solid"), DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, + RenderType.create(createLayerName("item_solid"), DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, false, RenderType.State.builder() - .texture(BLOCK_ATLAS_TEXTURE) - .transparency(NO_TRANSPARENCY) - .diffuseLighting(ENABLE_DIFFUSE_LIGHTING) - .lightmap(ENABLE_LIGHTMAP) - .overlay(ENABLE_OVERLAY_COLOR) - .build(true)); + .setTextureState(BLOCK_SHEET) + .setTransparencyState(NO_TRANSPARENCY) + .setDiffuseLightingState(DIFFUSE_LIGHTING) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); - private static final RenderType ITEM_PARTIAL_TRANSLUCENT = RenderType.of(createLayerName("item_translucent"), - DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, true, RenderType.State.builder() - .texture(BLOCK_ATLAS_TEXTURE) - .transparency(TRANSLUCENT_TRANSPARENCY) - .diffuseLighting(ENABLE_DIFFUSE_LIGHTING) - .alpha(ONE_TENTH_ALPHA) - .lightmap(ENABLE_LIGHTMAP) - .overlay(ENABLE_OVERLAY_COLOR) - .build(true)); + private static final RenderType ITEM_PARTIAL_TRANSLUCENT = RenderType.create(createLayerName("item_translucent"), + DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, RenderType.State.builder() + .setTextureState(BLOCK_SHEET) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setDiffuseLightingState(DIFFUSE_LIGHTING) + .setAlphaState(DEFAULT_ALPHA) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); - private static final RenderType FLUID = RenderType.of(createLayerName("fluid"), - DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, true, RenderType.State.builder() - .texture(MIPMAP_BLOCK_ATLAS_TEXTURE) - .transparency(TRANSLUCENT_TRANSPARENCY) - .shadeModel(SMOOTH_SHADE_MODEL) - .alpha(ONE_TENTH_ALPHA) - .lightmap(ENABLE_LIGHTMAP) - .overlay(ENABLE_OVERLAY_COLOR) - .build(true)); + private static final RenderType FLUID = RenderType.create(createLayerName("fluid"), + DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, RenderType.State.builder() + .setTextureState(BLOCK_SHEET_MIPPED) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setShadeModelState(SMOOTH_SHADE) + .setAlphaState(DEFAULT_ALPHA) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); private static String createLayerName(String name) { return Create.ID + ":" + name; diff --git a/src/main/java/com/simibubi/create/foundation/renderState/SuperRenderTypeBuffer.java b/src/main/java/com/simibubi/create/foundation/renderState/SuperRenderTypeBuffer.java index 286dc4423..7a9224afc 100644 --- a/src/main/java/com/simibubi/create/foundation/renderState/SuperRenderTypeBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/renderState/SuperRenderTypeBuffer.java @@ -47,15 +47,15 @@ public class SuperRenderTypeBuffer implements IRenderTypeBuffer { } public void draw() { - earlyBuffer.draw(); - defaultBuffer.draw(); - lateBuffer.draw(); + earlyBuffer.endBatch(); + defaultBuffer.endBatch(); + lateBuffer.endBatch(); } public void draw(RenderType type) { - earlyBuffer.draw(type); - defaultBuffer.draw(type); - lateBuffer.draw(type); + earlyBuffer.endBatch(type); + defaultBuffer.endBatch(type); + lateBuffer.endBatch(type); } private static class SuperRenderTypeBufferPhase extends IRenderTypeBuffer.Impl { @@ -65,28 +65,28 @@ public class SuperRenderTypeBuffer implements IRenderTypeBuffer { static final SortedMap createEntityBuilders() { return Util.make(new Object2ObjectLinkedOpenHashMap<>(), (map) -> { - map.put(Atlases.getEntitySolid(), blockBuilders.get(RenderType.getSolid())); + map.put(Atlases.solidBlockSheet(), blockBuilders.builder(RenderType.solid())); assign(map, RenderTypes.getOutlineSolid()); - map.put(Atlases.getEntityCutout(), blockBuilders.get(RenderType.getCutout())); - map.put(Atlases.getBannerPatterns(), blockBuilders.get(RenderType.getCutoutMipped())); - map.put(Atlases.getEntityTranslucentCull(), blockBuilders.get(RenderType.getTranslucent())); // FIXME new equivalent of getEntityTranslucent() ? - assign(map, Atlases.getShieldPatterns()); - assign(map, Atlases.getBeds()); - assign(map, Atlases.getShulkerBoxes()); - assign(map, Atlases.getSign()); - assign(map, Atlases.getChest()); - assign(map, RenderType.getTranslucentNoCrumbling()); - assign(map, RenderType.getGlint()); - assign(map, RenderType.getEntityGlint()); - assign(map, RenderType.getWaterMask()); - ModelBakery.BLOCK_DESTRUCTION_RENDER_LAYERS.forEach((p_228488_1_) -> { + map.put(Atlases.cutoutBlockSheet(), blockBuilders.builder(RenderType.cutout())); + map.put(Atlases.bannerSheet(), blockBuilders.builder(RenderType.cutoutMipped())); + map.put(Atlases.translucentCullBlockSheet(), blockBuilders.builder(RenderType.translucent())); // FIXME new equivalent of getEntityTranslucent() ? + assign(map, Atlases.shieldSheet()); + assign(map, Atlases.bedSheet()); + assign(map, Atlases.shulkerBoxSheet()); + assign(map, Atlases.signSheet()); + assign(map, Atlases.chestSheet()); + assign(map, RenderType.translucentNoCrumbling()); + assign(map, RenderType.glint()); + assign(map, RenderType.entityGlint()); + assign(map, RenderType.waterMask()); + ModelBakery.DESTROY_TYPES.forEach((p_228488_1_) -> { assign(map, p_228488_1_); }); }); } private static void assign(Object2ObjectLinkedOpenHashMap map, RenderType type) { - map.put(type, new BufferBuilder(type.getExpectedBufferSize())); + map.put(type, new BufferBuilder(type.bufferSize())); } protected SuperRenderTypeBufferPhase() { diff --git a/src/main/java/com/simibubi/create/foundation/sound/ContinuousSound.java b/src/main/java/com/simibubi/create/foundation/sound/ContinuousSound.java index 6055b26db..9f2dceeb1 100644 --- a/src/main/java/com/simibubi/create/foundation/sound/ContinuousSound.java +++ b/src/main/java/com/simibubi/create/foundation/sound/ContinuousSound.java @@ -15,13 +15,13 @@ public class ContinuousSound extends TickableSound { this.scape = scape; this.sharedPitch = sharedPitch; this.relativeVolume = relativeVolume; - this.repeat = true; - this.repeatDelay = 0; - this.global = false; + this.looping = true; + this.delay = 0; + this.relative = false; } public void remove() { - setDone(); + stop(); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/sound/RepeatingSound.java b/src/main/java/com/simibubi/create/foundation/sound/RepeatingSound.java index 0c8d4c97e..61d460214 100644 --- a/src/main/java/com/simibubi/create/foundation/sound/RepeatingSound.java +++ b/src/main/java/com/simibubi/create/foundation/sound/RepeatingSound.java @@ -29,10 +29,10 @@ public class RepeatingSound { if (AnimationTickHolder.getTicks() % repeatDelay != 0) return; - ClientWorld world = Minecraft.getInstance().world; + ClientWorld world = Minecraft.getInstance().level; Vector3d meanPos = scape.getMeanPos(); - world.playSound(meanPos.x, meanPos.y, meanPos.z, event, SoundCategory.AMBIENT, + world.playLocalSound(meanPos.x, meanPos.y, meanPos.z, event, SoundCategory.AMBIENT, scape.getVolume() * relativeVolume, sharedPitch, true); } diff --git a/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java b/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java index 3b68a728b..cdd7c4794 100644 --- a/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java +++ b/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java @@ -52,7 +52,7 @@ class SoundScape { public void play() { continuous.forEach(Minecraft.getInstance() - .getSoundHandler()::play); + .getSoundManager()::play); } public void tick() { @@ -82,10 +82,10 @@ class SoundScape { } public float getVolume() { - Entity renderViewEntity = Minecraft.getInstance().renderViewEntity; + Entity renderViewEntity = Minecraft.getInstance().cameraEntity; float distanceMultiplier = 0; if (renderViewEntity != null) { - double distanceTo = renderViewEntity.getPositionVec() + double distanceTo = renderViewEntity.position() .distanceTo(getMeanPos()); distanceMultiplier = (float) MathHelper.lerp(distanceTo / SoundScapes.MAX_AMBIENT_SOURCE_DISTANCE, 2, 0); } diff --git a/src/main/java/com/simibubi/create/foundation/sound/SoundScapes.java b/src/main/java/com/simibubi/create/foundation/sound/SoundScapes.java index c1065251f..d62449315 100644 --- a/src/main/java/com/simibubi/create/foundation/sound/SoundScapes.java +++ b/src/main/java/com/simibubi/create/foundation/sound/SoundScapes.java @@ -48,7 +48,7 @@ public class SoundScapes { } private static SoundScape kinetic(float pitch, AmbienceGroup group) { - return new SoundScape(pitch, group).continuous(SoundEvents.ENTITY_MINECART_INSIDE, .25f, 1); + return new SoundScape(pitch, group).continuous(SoundEvents.MINECART_INSIDE, .25f, 1); } private static SoundScape cogwheel(float pitch, AmbienceGroup group) { @@ -127,14 +127,14 @@ public class SoundScapes { } protected static boolean outOfRange(BlockPos pos) { - return !getCameraPos().withinDistance(pos, MAX_AMBIENT_SOURCE_DISTANCE); + return !getCameraPos().closerThan(pos, MAX_AMBIENT_SOURCE_DISTANCE); } protected static BlockPos getCameraPos() { - Entity renderViewEntity = Minecraft.getInstance().renderViewEntity; + Entity renderViewEntity = Minecraft.getInstance().cameraEntity; if (renderViewEntity == null) return BlockPos.ZERO; - BlockPos playerLocation = renderViewEntity.getBlockPos(); + BlockPos playerLocation = renderViewEntity.blockPosition(); return playerLocation; } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java b/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java index b25a42e2a..b4ec0bc2c 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java @@ -16,6 +16,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.items.CapabilityItemHandler; @@ -58,7 +59,7 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka @Override public void tick() { - if (!initialized && hasWorld()) { + if (!initialized && hasLevel()) { initialize(); initialized = true; } @@ -77,7 +78,7 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka } @Override - public final CompoundNBT write(CompoundNBT compound) { + public final CompoundNBT save(CompoundNBT compound) { write(compound, false); return compound; } @@ -94,7 +95,7 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka } @Override - public final void fromTag(BlockState state, CompoundNBT tag) { + public final void load(BlockState state, CompoundNBT tag) { fromTag(state, tag, false); } @@ -110,7 +111,7 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka updateBehaviorList(); } - super.fromTag(state, compound); + super.load(state, compound); behaviourList.forEach(tb -> tb.read(compound, clientPacket)); } @@ -118,13 +119,13 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka * Hook only these in future subclasses of STE */ protected void write(CompoundNBT compound, boolean clientPacket) { - super.write(compound); + super.save(compound); behaviourList.forEach(tb -> tb.write(compound, clientPacket)); } @Override public void writeSafe(CompoundNBT compound, boolean clientPacket) { - super.write(compound); + super.save(compound); behaviourList.forEach(tb -> { if (tb.isSafeNBT()) tb.write(compound, clientPacket); @@ -140,9 +141,9 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka } @Override - public void remove() { + public void setRemoved() { forEachBehaviour(TileEntityBehaviour::remove); - super.remove(); + super.setRemoved(); } public void setLazyTickRate(int slowTickRate) { @@ -205,10 +206,13 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka @Override public boolean canPlayerUse(PlayerEntity player) { - if (world == null || world.getTileEntity(pos) != this) { + if (level == null || level.getBlockEntity(worldPosition) != this) { return false; } - return player.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) <= 64.0D; + return player.distanceToSqr(worldPosition.getX() + 0.5D, worldPosition.getY() + 0.5D, worldPosition.getZ() + 0.5D) <= 64.0D; } + public World getWorld() { + return getLevel(); + } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/SyncedTileEntity.java b/src/main/java/com/simibubi/create/foundation/tileEntity/SyncedTileEntity.java index 2c8929358..c4f234d4f 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/SyncedTileEntity.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/SyncedTileEntity.java @@ -28,46 +28,46 @@ public abstract class SyncedTileEntity extends TileEntity { @Override public CompoundNBT getUpdateTag() { - return write(new CompoundNBT()); + return save(new CompoundNBT()); } @Override public void handleUpdateTag(BlockState state, CompoundNBT tag) { - fromTag(state, tag); + load(state, tag); } public void sendData() { - if (world != null) - world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 2 | 4 | 16); + if (level != null) + level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), 2 | 4 | 16); } public void causeBlockUpdate() { - if (world != null) - world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 1); + if (level != null) + level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), 1); } @Override public SUpdateTileEntityPacket getUpdatePacket() { - return new SUpdateTileEntityPacket(getPos(), 1, writeToClient(new CompoundNBT())); + return new SUpdateTileEntityPacket(getBlockPos(), 1, writeToClient(new CompoundNBT())); } @Override public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) { - readClientUpdate(getBlockState(), pkt.getNbtCompound()); + readClientUpdate(getBlockState(), pkt.getTag()); } // Special handling for client update packets public void readClientUpdate(BlockState state, CompoundNBT tag) { - fromTag(state, tag); + load(state, tag); } // Special handling for client update packets public CompoundNBT writeToClient(CompoundNBT tag) { - return write(tag); + return save(tag); } public void notifyUpdate() { - markDirty(); + setChanged(); sendData(); } @@ -76,7 +76,7 @@ public abstract class SyncedTileEntity extends TileEntity { } public Chunk containedChunk() { - SectionPos sectionPos = SectionPos.from(pos); - return world.getChunk(sectionPos.getSectionX(), sectionPos.getSectionZ()); + SectionPos sectionPos = SectionPos.of(worldPosition); + return level.getChunk(sectionPos.x(), sectionPos.z()); } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java index 4f0588e55..5cd951b31 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java @@ -77,20 +77,20 @@ public abstract class TileEntityBehaviour { } public BlockPos getPos() { - return tileEntity.getPos(); + return tileEntity.getBlockPos(); } public World getWorld() { - return tileEntity.getWorld(); + return tileEntity.getLevel(); } public static T get(IBlockReader reader, BlockPos pos, BehaviourType type) { - return get(reader.getTileEntity(pos), type); + return get(reader.getBlockEntity(pos), type); } public static void destroy(IBlockReader reader, BlockPos pos, BehaviourType type) { - T behaviour = get(reader.getTileEntity(pos), type); + T behaviour = get(reader.getBlockEntity(pos), type); if (behaviour != null) behaviour.destroy(); } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java index a81df38bb..92f7300f2 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java @@ -40,7 +40,7 @@ public class ValueBox extends ChasingAABBOutline { super(bb); this.label = label; this.pos = pos; - this.blockState = Minecraft.getInstance().world.getBlockState(pos); + this.blockState = Minecraft.getInstance().level.getBlockState(pos); } public ValueBox transform(ValueBoxTransform transform) { @@ -82,12 +82,12 @@ public class ValueBox extends ChasingAABBOutline { if (hasTransform && !transform.shouldRender(blockState)) return; - ms.push(); + ms.pushPose(); ms.translate(pos.getX(), pos.getY(), pos.getZ()); if (hasTransform) transform.transform(blockState, ms); - transformNormals = ms.peek() - .getNormal() + transformNormals = ms.last() + .normal() .copy(); params.colored(isPassive ? passiveColor : highlightColor); super.render(ms, buffer, pt); @@ -95,12 +95,12 @@ public class ValueBox extends ChasingAABBOutline { float fontScale = hasTransform ? -transform.getFontScale() : -1 / 64f; ms.scale(fontScale, fontScale, fontScale); - ms.push(); + ms.pushPose(); renderContents(ms, buffer); - ms.pop(); + ms.popPose(); if (!isPassive) { - ms.push(); + ms.pushPose(); ms.translate(17.5, -.5, 7); ms.translate(labelOffset.x, labelOffset.y, labelOffset.z); @@ -109,15 +109,15 @@ public class ValueBox extends ChasingAABBOutline { ms.translate(0, 10, 0); renderHoveringText(ms, buffer, sublabel); } - if (!scrollTooltip.getUnformattedComponentText().isEmpty()) { + if (!scrollTooltip.getContents().isEmpty()) { ms.translate(0, 10, 0); renderHoveringText(ms, buffer, scrollTooltip, 0x998899, 0x111111); } - ms.pop(); + ms.popPose(); } - ms.pop(); + ms.popPose(); } public void renderContents(MatrixStack ms, IRenderTypeBuffer buffer) {} @@ -135,14 +135,14 @@ public class ValueBox extends ChasingAABBOutline { @Override public void renderContents(MatrixStack ms, IRenderTypeBuffer buffer) { super.renderContents(ms, buffer); - FontRenderer font = Minecraft.getInstance().fontRenderer; + FontRenderer font = Minecraft.getInstance().font; ITextComponent countString = new StringTextComponent(count == 0 ? "*" : count + ""); ms.translate(17.5f, -5f, 7f); boolean isFilter = stack.getItem() instanceof FilterItem; boolean isEmpty = stack.isEmpty(); float scale = 1.5f; - ms.translate(-font.getWidth(countString), 0, 0); + ms.translate(-font.width(countString), 0, 0); if (isFilter) ms.translate(3, 8, 7.25f); @@ -172,17 +172,17 @@ public class ValueBox extends ChasingAABBOutline { @Override public void renderContents(MatrixStack ms, IRenderTypeBuffer buffer) { super.renderContents(ms, buffer); - FontRenderer font = Minecraft.getInstance().fontRenderer; + FontRenderer font = Minecraft.getInstance().font; float scale = 4; ms.scale(scale, scale, 1); ms.translate(-4, -4, 5); - int stringWidth = font.getWidth(text); - float numberScale = (float) font.FONT_HEIGHT / stringWidth; + int stringWidth = font.width(text); + float numberScale = (float) font.lineHeight / stringWidth; boolean singleDigit = stringWidth < 10; if (singleDigit) numberScale = numberScale / 2; - float verticalMargin = (stringWidth - font.FONT_HEIGHT) / 2f; + float verticalMargin = (stringWidth - font.lineHeight) / 2f; ms.scale(numberScale, numberScale, numberScale); ms.translate(singleDigit ? stringWidth / 2 : 0, singleDigit ? -verticalMargin : verticalMargin, 0); @@ -220,16 +220,16 @@ public class ValueBox extends ChasingAABBOutline { protected void renderHoveringText(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text, int color, int shadowColor) { - ms.push(); + ms.pushPose(); drawString(ms, buffer, text, 0, 0, color); ms.translate(0, 0, -.25); drawString(ms, buffer, text, 1, 1, shadowColor); - ms.pop(); + ms.popPose(); } private static void drawString(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text, float x, float y, int color) { - Minecraft.getInstance().fontRenderer.draw(text, x, y, color, false, ms.peek() - .getModel(), buffer, false, 0, 15728880); + Minecraft.getInstance().font.drawInBatch(text, x, y, color, false, ms.last() + .pose(), buffer, false, 0, 15728880); } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxRenderer.java index fd37abb2a..bac64bc8a 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxRenderer.java @@ -21,13 +21,13 @@ public class ValueBoxRenderer { public static void renderItemIntoValueBox(ItemStack filter, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); - IBakedModel modelWithOverrides = itemRenderer.getItemModelWithOverrides(filter, Minecraft.getInstance().world, null); + IBakedModel modelWithOverrides = itemRenderer.getModel(filter, Minecraft.getInstance().level, null); boolean blockItem = modelWithOverrides.isGui3d(); float scale = (!blockItem ? .5f : 1f) - 1 / 64f; float zOffset = (!blockItem ? -.225f : 0) + customZOffset(filter.getItem()); ms.scale(scale, scale, scale); ms.translate(0, 0, zOffset); - itemRenderer.renderItem(filter, TransformType.FIXED, light, overlay, ms, buffer); + itemRenderer.renderStatic(filter, TransformType.FIXED, light, overlay, ms, buffer); } private static float customZOffset(Item item) { @@ -40,7 +40,7 @@ public class ValueBoxRenderer { return NUDGE; if (block instanceof FenceBlock) return NUDGE; - if (block.isIn(BlockTags.BUTTONS)) + if (block.is(BlockTags.BUTTONS)) return NUDGE; if (block == Blocks.END_ROD) return NUDGE; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxTransform.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxTransform.java index 0d74f4e52..2ffaea5d6 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxTransform.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxTransform.java @@ -46,10 +46,10 @@ public abstract class ValueBoxTransform { protected Vector3d rotateHorizontally(BlockState state, Vector3d vec) { float yRot = 0; - if (state.contains(BlockStateProperties.FACING)) - yRot = AngleHelper.horizontalAngle(state.get(BlockStateProperties.FACING)); - if (state.contains(BlockStateProperties.HORIZONTAL_FACING)) - yRot = AngleHelper.horizontalAngle(state.get(BlockStateProperties.HORIZONTAL_FACING)); + if (state.hasProperty(BlockStateProperties.FACING)) + yRot = AngleHelper.horizontalAngle(state.getValue(BlockStateProperties.FACING)); + if (state.hasProperty(BlockStateProperties.HORIZONTAL_FACING)) + yRot = AngleHelper.horizontalAngle(state.getValue(BlockStateProperties.HORIZONTAL_FACING)); return VecHelper.rotateCentered(vec, yRot, Axis.Y); } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/BeltProcessingBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/BeltProcessingBehaviour.java index 8725bce5d..3d9af3d78 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/BeltProcessingBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/BeltProcessingBehaviour.java @@ -43,10 +43,10 @@ public class BeltProcessingBehaviour extends TileEntityBehaviour { } public static boolean isBlocked(IBlockReader world, BlockPos processingSpace) { - BlockState blockState = world.getBlockState(processingSpace.up()); + BlockState blockState = world.getBlockState(processingSpace.above()); if (AbstractFunnelBlock.isFunnel(blockState)) return false; - return !blockState.getCollisionShape(world, processingSpace.up()) + return !blockState.getCollisionShape(world, processingSpace.above()) .isEmpty(); } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/DirectBeltInputBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/DirectBeltInputBehaviour.java index 823568969..a11f4f4a0 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/DirectBeltInputBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/DirectBeltInputBehaviour.java @@ -99,20 +99,20 @@ public class DirectBeltInputBehaviour extends TileEntityBehaviour { @Nullable public ItemStack tryExportingToBeltFunnel(ItemStack stack, @Nullable Direction side, boolean simulate) { - BlockPos funnelPos = tileEntity.getPos() - .up(); + BlockPos funnelPos = tileEntity.getBlockPos() + .above(); World world = getWorld(); BlockState funnelState = world.getBlockState(funnelPos); if (!(funnelState.getBlock() instanceof BeltFunnelBlock)) return null; - if (funnelState.get(BeltFunnelBlock.SHAPE) != Shape.PULLING) + if (funnelState.getValue(BeltFunnelBlock.SHAPE) != Shape.PULLING) return null; if (side != null && FunnelBlock.getFunnelFacing(funnelState) != side) return null; - TileEntity te = world.getTileEntity(funnelPos); + TileEntity te = world.getBlockEntity(funnelPos); if (!(te instanceof FunnelTileEntity)) return null; - if (funnelState.get(BeltFunnelBlock.POWERED)) + if (funnelState.getValue(BeltFunnelBlock.POWERED)) return stack; ItemStack insert = FunnelBlock.tryInsert(world, funnelPos, stack, simulate); if (insert.getCount() != stack.getCount() && !simulate) diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/TransportedItemStackHandlerBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/TransportedItemStackHandlerBehaviour.java index 56fcc5c91..9e43eca67 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/TransportedItemStackHandlerBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/belt/TransportedItemStackHandlerBehaviour.java @@ -86,7 +86,7 @@ public class TransportedItemStackHandlerBehaviour extends TileEntityBehaviour { public TransportedItemStackHandlerBehaviour(SmartTileEntity te, ProcessingCallback processingCallback) { super(te); this.processingCallback = processingCallback; - positionGetter = t -> VecHelper.getCenterOf(te.getPos()); + positionGetter = t -> VecHelper.getCenterOf(te.getBlockPos()); } public TransportedItemStackHandlerBehaviour withStackPlacement(PositionGetter function) { diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java index 82ca086b9..47bb85727 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java @@ -35,9 +35,9 @@ public class EdgeInteractionHandler { BlockPos pos = event.getPos(); PlayerEntity player = event.getPlayer(); Hand hand = event.getHand(); - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); - if (player.isSneaking() || player.isSpectator()) + if (player.isShiftKeyDown() || player.isSpectator()) return; EdgeInteractionBehaviour behaviour = TileEntityBehaviour.get(world, pos, EdgeInteractionBehaviour.TYPE); if (behaviour == null) @@ -48,28 +48,28 @@ public class EdgeInteractionHandler { if (behaviour.requiredItem.orElse(heldItem.getItem()) != heldItem.getItem()) return; - Direction activatedDirection = getActivatedDirection(world, pos, ray.getFace(), ray.getHitVec(), behaviour); + Direction activatedDirection = getActivatedDirection(world, pos, ray.getDirection(), ray.getLocation(), behaviour); if (activatedDirection == null) return; if (event.getSide() != LogicalSide.CLIENT) - behaviour.connectionCallback.apply(world, pos, pos.offset(activatedDirection)); + behaviour.connectionCallback.apply(world, pos, pos.relative(activatedDirection)); event.setCanceled(true); event.setCancellationResult(ActionResultType.SUCCESS); - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, SoundCategory.BLOCKS, .25f, .1f); + world.playSound(null, pos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundCategory.BLOCKS, .25f, .1f); } public static List getConnectiveSides(World world, BlockPos pos, Direction face, EdgeInteractionBehaviour behaviour) { List sides = new ArrayList<>(6); - if (BlockHelper.hasBlockSolidSide(world.getBlockState(pos.offset(face)), world, pos.offset(face), face.getOpposite())) + if (BlockHelper.hasBlockSolidSide(world.getBlockState(pos.relative(face)), world, pos.relative(face), face.getOpposite())) return sides; for (Direction direction : Iterate.directions) { if (direction.getAxis() == face.getAxis()) continue; - BlockPos neighbourPos = pos.offset(direction); - if (BlockHelper.hasBlockSolidSide(world.getBlockState(neighbourPos.offset(face)), world, neighbourPos.offset(face), + BlockPos neighbourPos = pos.relative(direction); + if (BlockHelper.hasBlockSolidSide(world.getBlockState(neighbourPos.relative(face)), world, neighbourPos.relative(face), face.getOpposite())) continue; if (!behaviour.connectivityPredicate.test(world, pos, face, direction)) @@ -92,7 +92,7 @@ public class EdgeInteractionHandler { static AxisAlignedBB getBB(BlockPos pos, Direction direction) { AxisAlignedBB bb = new AxisAlignedBB(pos); - Vector3i vec = direction.getDirectionVec(); + Vector3i vec = direction.getNormal(); int x = vec.getX(); int y = vec.getY(); int z = vec.getZ(); @@ -102,9 +102,9 @@ public class EdgeInteractionHandler { double absZ = Math.abs(z) * margin; bb = bb.contract(absX, absY, absZ); - bb = bb.offset(absX / 2d, absY / 2d, absZ / 2d); - bb = bb.offset(x / 2d, y / 2d, z / 2d); - bb = bb.grow(1 / 256f); + bb = bb.move(absX / 2d, absY / 2d, absZ / 2d); + bb = bb.move(x / 2d, y / 2d, z / 2d); + bb = bb.inflate(1 / 256f); return bb; } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionRenderer.java index 6cfcd227b..1c6d512ad 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionRenderer.java @@ -25,17 +25,17 @@ public class EdgeInteractionRenderer { public static void tick() { Minecraft mc = Minecraft.getInstance(); - RayTraceResult target = mc.objectMouseOver; + RayTraceResult target = mc.hitResult; if (target == null || !(target instanceof BlockRayTraceResult)) return; BlockRayTraceResult result = (BlockRayTraceResult) target; - ClientWorld world = mc.world; - BlockPos pos = result.getPos(); + ClientWorld world = mc.level; + BlockPos pos = result.getBlockPos(); PlayerEntity player = mc.player; - ItemStack heldItem = player.getHeldItemMainhand(); + ItemStack heldItem = player.getMainHandItem(); - if (player.isSneaking()) + if (player.isShiftKeyDown()) return; EdgeInteractionBehaviour behaviour = TileEntityBehaviour.get(world, pos, EdgeInteractionBehaviour.TYPE); if (behaviour == null) @@ -43,7 +43,7 @@ public class EdgeInteractionRenderer { if (behaviour.requiredItem.orElse(heldItem.getItem()) != heldItem.getItem()) return; - Direction face = result.getFace(); + Direction face = result.getDirection(); List connectiveSides = EdgeInteractionHandler.getConnectiveSides(world, pos, face, behaviour); if (connectiveSides.isEmpty()) return; @@ -52,7 +52,7 @@ public class EdgeInteractionRenderer { double bestDistance = Double.MAX_VALUE; Vector3d center = VecHelper.getCenterOf(pos); for (Direction direction : connectiveSides) { - double distance = Vector3d.of(direction.getDirectionVec()).subtract(target.getHitVec() + double distance = Vector3d.atLowerCornerOf(direction.getNormal()).subtract(target.getLocation() .subtract(center)) .length(); if (distance > bestDistance) @@ -62,9 +62,9 @@ public class EdgeInteractionRenderer { } AxisAlignedBB bb = EdgeInteractionHandler.getBB(pos, closestEdge); - boolean hit = bb.contains(target.getHitVec()); + boolean hit = bb.contains(target.getLocation()); - ValueBox box = new ValueBox(StringTextComponent.EMPTY, bb.offset(-pos.getX(), -pos.getY(), -pos.getZ()), pos); + ValueBox box = new ValueBox(StringTextComponent.EMPTY, bb.move(-pos.getX(), -pos.getY(), -pos.getZ()), pos); Vector3d textOffset = Vector3d.ZERO; boolean positive = closestEdge.getAxisDirection() == AxisDirection.POSITIVE; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java index 1768fd0cd..b7098e455 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java @@ -76,7 +76,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { @Override public void read(CompoundNBT nbt, boolean clientPacket) { - filter = ItemStack.read(nbt.getCompound("Filter")); + filter = ItemStack.of(nbt.getCompound("Filter")); count = nbt.getInt("FilterAmount"); if (nbt.contains("ForceScrollable")) { scrollableValue = count; @@ -89,7 +89,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { public void tick() { super.tick(); - if (!getWorld().isRemote) + if (!getWorld().isClientSide) return; if (ticksUntilScrollPacket == -1) return; @@ -155,7 +155,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { : (filter.getItem() instanceof FilterItem) ? 0 : Math.min(stack.getCount(), stack.getMaxStackSize()); forceClientState = true; - tileEntity.markDirty(); + tileEntity.setChanged(); tileEntity.sendData(); } @@ -164,7 +164,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { if (filter.getItem() instanceof FilterItem) { Vector3d pos = VecHelper.getCenterOf(getPos()); World world = getWorld(); - world.addEntity(new ItemEntity(world, pos.x, pos.y, pos.z, filter.copy())); + world.addFreshEntity(new ItemEntity(world, pos.x, pos.y, pos.z, filter.copy())); } super.destroy(); @@ -192,11 +192,11 @@ public class FilteringBehaviour extends TileEntityBehaviour { } public boolean test(ItemStack stack) { - return !isActive() || filter.isEmpty() || FilterItem.test(tileEntity.getWorld(), stack, filter); + return !isActive() || filter.isEmpty() || FilterItem.test(tileEntity.getLevel(), stack, filter); } public boolean test(FluidStack stack) { - return !isActive() || filter.isEmpty() || FilterItem.test(tileEntity.getWorld(), stack, filter); + return !isActive() || filter.isEmpty() || FilterItem.test(tileEntity.getLevel(), stack, filter); } @Override @@ -206,7 +206,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { public boolean testHit(Vector3d hit) { BlockState state = tileEntity.getBlockState(); - Vector3d localHit = hit.subtract(Vector3d.of(tileEntity.getPos())); + Vector3d localHit = hit.subtract(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); return slotPositioning.testHit(state, localHit); } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringCountUpdatePacket.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringCountUpdatePacket.java index d6548d1e8..562ba13ab 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringCountUpdatePacket.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringCountUpdatePacket.java @@ -36,7 +36,7 @@ public class FilteringCountUpdatePacket extends TileEntityConfigurationPacket { CompoundNBT compound = new CompoundNBT(); compound.putInt("Side", entry.getKey() - .getIndex()); + .get3DDataValue()); entry.getValue() .write(compound, clientPacket); return compound; @@ -75,7 +75,7 @@ public class SidedFilteringBehaviour extends FilteringBehaviour { @Override public void read(CompoundNBT nbt, boolean clientPacket) { NBTHelper.iterateCompoundList(nbt.getList("Filters", NBT.TAG_COMPOUND), compound -> { - Direction face = Direction.byIndex(compound.getInt("Side")); + Direction face = Direction.from3DDataValue(compound.getInt("Side")); if (sidedFilters.containsKey(face)) sidedFilters.get(face) .read(compound, clientPacket); @@ -139,7 +139,7 @@ public class SidedFilteringBehaviour extends FilteringBehaviour { public boolean testHit(Direction direction, Vector3d hit) { ValueBoxTransform.Sided sidedPositioning = (Sided) slotPositioning; BlockState state = tileEntity.getBlockState(); - Vector3d localHit = hit.subtract(Vector3d.of(tileEntity.getPos())); + Vector3d localHit = hit.subtract(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); return sidedPositioning.fromSide(direction) .testHit(state, localHit); } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/fluid/SmartFluidTankBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/fluid/SmartFluidTankBehaviour.java index 9841bbb8d..a78883b78 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/fluid/SmartFluidTankBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/fluid/SmartFluidTankBehaviour.java @@ -20,6 +20,8 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; + public class SmartFluidTankBehaviour extends TileEntityBehaviour { public static BehaviourType @@ -88,7 +90,7 @@ public class SmartFluidTankBehaviour extends TileEntityBehaviour { @Override public void initialize() { super.initialize(); - if (getWorld().isRemote) + if (getWorld().isClientSide) return; foreach(ts -> { ts.fluidLevel.forceNextSync(); @@ -132,7 +134,7 @@ public class SmartFluidTankBehaviour extends TileEntityBehaviour { protected void updateFluids() { fluidUpdateCallback.run(); tileEntity.sendData(); - tileEntity.markDirty(); + tileEntity.setChanged(); } @Override @@ -239,10 +241,10 @@ public class SmartFluidTankBehaviour extends TileEntityBehaviour { } public void onFluidStackChanged() { - if (!tileEntity.hasWorld()) + if (!tileEntity.hasLevel()) return; fluidLevel.chase(tank.getFluidAmount() / (float) tank.getCapacity(), .25, Chaser.EXP); - if (!getWorld().isRemote) + if (!getWorld().isClientSide) sendDataLazily(); if (tileEntity.isVirtual() && !tank.getFluid() .isEmpty()) diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/inventory/InvManipulationBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/inventory/InvManipulationBehaviour.java index 80fcbf014..fa9ae5f95 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/inventory/InvManipulationBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/inventory/InvManipulationBehaviour.java @@ -100,7 +100,7 @@ public class InvManipulationBehaviour extends TileEntityBehaviour { boolean shouldSimulate = simulateNext; simulateNext = false; - if (getWorld().isRemote) + if (getWorld().isClientSide) return ItemStack.EMPTY; IItemHandler inventory = targetCapability.orElse(null); if (inventory == null) @@ -147,7 +147,7 @@ public class InvManipulationBehaviour extends TileEntityBehaviour { @Override public void onNeighborChanged(BlockPos neighborPos) { - BlockFace targetBlockFace = target.getTarget(getWorld(), tileEntity.getPos(), tileEntity.getBlockState()); + BlockFace targetBlockFace = target.getTarget(getWorld(), tileEntity.getBlockPos(), tileEntity.getBlockState()); if (targetBlockFace.getConnectedPos().equals(neighborPos)) onHandlerInvalidated(targetCapability); } @@ -182,16 +182,16 @@ public class InvManipulationBehaviour extends TileEntityBehaviour { } public void findNewCapability() { - BlockFace targetBlockFace = target.getTarget(getWorld(), tileEntity.getPos(), tileEntity.getBlockState()) + BlockFace targetBlockFace = target.getTarget(getWorld(), tileEntity.getBlockPos(), tileEntity.getBlockState()) .getOpposite(); BlockPos pos = targetBlockFace.getPos(); World world = getWorld(); targetCapability = LazyOptional.empty(); - if (!world.isBlockPresent(pos)) + if (!world.isLoaded(pos)) return; - TileEntity invTE = world.getTileEntity(pos); + TileEntity invTE = world.getBlockEntity(pos); if (invTE == null) return; targetCapability = bypassSided ? invTE.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) @@ -209,14 +209,14 @@ public class InvManipulationBehaviour extends TileEntityBehaviour { public interface InterfaceProvider { public static InterfaceProvider towardBlockFacing() { - return (w, p, s) -> new BlockFace(p, s.contains(BlockStateProperties.FACING) ? s.get(BlockStateProperties.FACING) - : s.get(BlockStateProperties.HORIZONTAL_FACING)); + return (w, p, s) -> new BlockFace(p, s.hasProperty(BlockStateProperties.FACING) ? s.getValue(BlockStateProperties.FACING) + : s.getValue(BlockStateProperties.HORIZONTAL_FACING)); } public static InterfaceProvider oppositeOfBlockFacing() { return (w, p, s) -> new BlockFace(p, - (s.contains(BlockStateProperties.FACING) ? s.get(BlockStateProperties.FACING) - : s.get(BlockStateProperties.HORIZONTAL_FACING)).getOpposite()); + (s.hasProperty(BlockStateProperties.FACING) ? s.getValue(BlockStateProperties.FACING) + : s.getValue(BlockStateProperties.HORIZONTAL_FACING)).getOpposite()); } public BlockFace getTarget(World world, BlockPos pos, BlockState blockState); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java index 75aa226e0..e10bc096e 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java @@ -102,7 +102,7 @@ public class LinkBehaviour extends TileEntityBehaviour implements IRedstoneLinka @Override public void initialize() { super.initialize(); - if (getWorld().isRemote) + if (getWorld().isClientSide) return; getHandler().addToNetwork(getWorld(), this); newPosition = true; @@ -116,7 +116,7 @@ public class LinkBehaviour extends TileEntityBehaviour implements IRedstoneLinka @Override public void remove() { super.remove(); - if (getWorld().isRemote) + if (getWorld().isClientSide) return; getHandler().removeFromNetwork(getWorld(), this); } @@ -130,23 +130,23 @@ public class LinkBehaviour extends TileEntityBehaviour implements IRedstoneLinka public void write(CompoundNBT nbt, boolean clientPacket) { super.write(nbt, clientPacket); nbt.put("FrequencyFirst", frequencyFirst.getStack() - .write(new CompoundNBT())); + .save(new CompoundNBT())); nbt.put("FrequencyLast", frequencyLast.getStack() - .write(new CompoundNBT())); - nbt.putLong("LastKnownPosition", tileEntity.getPos() - .toLong()); + .save(new CompoundNBT())); + nbt.putLong("LastKnownPosition", tileEntity.getBlockPos() + .asLong()); } @Override public void read(CompoundNBT nbt, boolean clientPacket) { - long positionInTag = tileEntity.getPos() - .toLong(); + long positionInTag = tileEntity.getBlockPos() + .asLong(); long positionKey = nbt.getLong("LastKnownPosition"); newPosition = positionInTag != positionKey; super.read(nbt, clientPacket); - frequencyFirst = Frequency.of(ItemStack.read(nbt.getCompound("FrequencyFirst"))); - frequencyLast = Frequency.of(ItemStack.read(nbt.getCompound("FrequencyLast"))); + frequencyFirst = Frequency.of(ItemStack.of(nbt.getCompound("FrequencyFirst"))); + frequencyLast = Frequency.of(ItemStack.of(nbt.getCompound("FrequencyLast"))); } public void setFrequency(boolean first, ItemStack stack) { @@ -154,7 +154,7 @@ public class LinkBehaviour extends TileEntityBehaviour implements IRedstoneLinka stack.setCount(1); ItemStack toCompare = first ? frequencyFirst.getStack() : frequencyLast.getStack(); boolean changed = - !ItemStack.areItemsEqual(stack, toCompare) || !ItemStack.areItemStackTagsEqual(stack, toCompare); + !ItemStack.isSame(stack, toCompare) || !ItemStack.tagMatches(stack, toCompare); if (changed) getHandler().removeFromNetwork(getWorld(), this); @@ -201,13 +201,13 @@ public class LinkBehaviour extends TileEntityBehaviour implements IRedstoneLinka public boolean testHit(Boolean first, Vector3d hit) { BlockState state = tileEntity.getBlockState(); - Vector3d localHit = hit.subtract(Vector3d.of(tileEntity.getPos())); + Vector3d localHit = hit.subtract(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); return (first ? firstSlot : secondSlot).testHit(state, localHit); } @Override public boolean isAlive() { - return !tileEntity.isRemoved() && getWorld().getTileEntity(getPos()) == tileEntity; + return !tileEntity.isRemoved() && getWorld().getBlockEntity(getPos()) == tileEntity; } @Override diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java index 1c5e6319f..1c428e62d 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java @@ -30,14 +30,14 @@ public class LinkHandler { PlayerEntity player = event.getPlayer(); Hand hand = event.getHand(); - if (player.isSneaking() || player.isSpectator()) + if (player.isShiftKeyDown() || player.isSpectator()) return; LinkBehaviour behaviour = TileEntityBehaviour.get(world, pos, LinkBehaviour.TYPE); if (behaviour == null) return; - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItem = player.getItemInHand(hand); BlockRayTraceResult ray = RaycastHelper.rayTraceRange(world, player, 10); if (ray == null) return; @@ -47,12 +47,12 @@ public class LinkHandler { return; for (boolean first : Arrays.asList(false, true)) { - if (behaviour.testHit(first, ray.getHitVec())) { + if (behaviour.testHit(first, ray.getLocation())) { if (event.getSide() != LogicalSide.CLIENT) behaviour.setFrequency(first, heldItem); event.setCanceled(true); event.setCancellationResult(ActionResultType.SUCCESS); - world.playSound(null, pos, SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, SoundCategory.BLOCKS, .25f, .1f); + world.playSound(null, pos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundCategory.BLOCKS, .25f, .1f); } } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkRenderer.java index 6386ff9fe..1c51f5861 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkRenderer.java @@ -27,13 +27,13 @@ public class LinkRenderer { public static void tick() { Minecraft mc = Minecraft.getInstance(); - RayTraceResult target = mc.objectMouseOver; + RayTraceResult target = mc.hitResult; if (target == null || !(target instanceof BlockRayTraceResult)) return; BlockRayTraceResult result = (BlockRayTraceResult) target; - ClientWorld world = mc.world; - BlockPos pos = result.getPos(); + ClientWorld world = mc.level; + BlockPos pos = result.getBlockPos(); LinkBehaviour behaviour = TileEntityBehaviour.get(world, pos, LinkBehaviour.TYPE); if (behaviour == null) @@ -43,9 +43,9 @@ public class LinkRenderer { ITextComponent freq2 = Lang.translate("logistics.secondFrequency"); for (boolean first : Iterate.trueAndFalse) { - AxisAlignedBB bb = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).grow(.25f); + AxisAlignedBB bb = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).inflate(.25f); ITextComponent label = first ? freq1 : freq2; - boolean hit = behaviour.testHit(first, target.getHitVec()); + boolean hit = behaviour.testHit(first, target.getLocation()); ValueBoxTransform transform = first ? behaviour.firstSlot : behaviour.secondSlot; ValueBox box = new ValueBox(label, bb, pos).withColors(0x601F18, 0xB73C2D) @@ -54,7 +54,7 @@ public class LinkRenderer { CreateClient.OUTLINER.showValueBox(Pair.of(Boolean.valueOf(first), pos), box.transform(transform)) .lineWidth(1 / 64f) .withFaceTexture(hit ? AllSpecialTextures.THIN_CHECKERED : null) - .highlightFace(result.getFace()); + .highlightFace(result.getDirection()); } } @@ -71,10 +71,10 @@ public class LinkRenderer { ValueBoxTransform transform = first ? behaviour.firstSlot : behaviour.secondSlot; ItemStack stack = first ? behaviour.frequencyFirst.getStack() : behaviour.frequencyLast.getStack(); - ms.push(); + ms.pushPose(); transform.transform(te.getBlockState(), ms); ValueBoxRenderer.renderItemIntoValueBox(stack, ms, buffer, light, overlay); - ms.pop(); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueBehaviour.java index d189a689d..090c32a21 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueBehaviour.java @@ -81,7 +81,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { public void tick() { super.tick(); - if (!getWorld().isRemote) + if (!getWorld().isClientSide) return; if (ticksUntilScrollPacket == -1) return; @@ -154,7 +154,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { this.value = value; forceClientState = true; callback.accept(value); - tileEntity.markDirty(); + tileEntity.setChanged(); tileEntity.sendData(); scrollableValue = value; } @@ -178,7 +178,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { public boolean testHit(Vector3d hit) { BlockState state = tileEntity.getBlockState(); - Vector3d localHit = hit.subtract(Vector3d.of(tileEntity.getPos())); + Vector3d localHit = hit.subtract(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); return slotPositioning.testHit(state, localHit); } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java index 1ae96c132..9ccd62138 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java @@ -30,32 +30,32 @@ public class ScrollValueHandler { @OnlyIn(Dist.CLIENT) public static boolean onScroll(double delta) { - RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver; + RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; if (!(objectMouseOver instanceof BlockRayTraceResult)) return false; BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; Minecraft mc = Minecraft.getInstance(); - ClientWorld world = mc.world; - BlockPos blockPos = result.getPos(); + ClientWorld world = mc.level; + BlockPos blockPos = result.getBlockPos(); ScrollValueBehaviour scrolling = TileEntityBehaviour.get(world, blockPos, ScrollValueBehaviour.TYPE); if (scrolling == null) return false; if (!scrolling.isActive()) return false; - if (!mc.player.isAllowEdit()) + if (!mc.player.mayBuild()) return false; passiveScrollDirection = (float) -delta; wrenchCog.bump(3, -delta * 10); int prev = scrolling.scrollableValue; - if (scrolling.needsWrench && !AllItems.WRENCH.isIn(mc.player.getHeldItemMainhand())) + if (scrolling.needsWrench && !AllItems.WRENCH.isIn(mc.player.getMainHandItem())) return false; if (scrolling.slotPositioning instanceof Sided) - ((Sided) scrolling.slotPositioning).fromSide(result.getFace()); - if (!scrolling.testHit(objectMouseOver.getHitVec())) + ((Sided) scrolling.slotPositioning).fromSide(result.getDirection()); + if (!scrolling.testHit(objectMouseOver.getLocation())) return false; if (scrolling instanceof BulkScrollValueBehaviour && AllKeys.ctrlDown()) { diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java index ab5521204..f157c98fc 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java @@ -25,30 +25,30 @@ public class ScrollValueRenderer { public static void tick() { Minecraft mc = Minecraft.getInstance(); - RayTraceResult target = mc.objectMouseOver; + RayTraceResult target = mc.hitResult; if (target == null || !(target instanceof BlockRayTraceResult)) return; BlockRayTraceResult result = (BlockRayTraceResult) target; - ClientWorld world = mc.world; - BlockPos pos = result.getPos(); - Direction face = result.getFace(); + ClientWorld world = mc.level; + BlockPos pos = result.getBlockPos(); + Direction face = result.getDirection(); ScrollValueBehaviour behaviour = TileEntityBehaviour.get(world, pos, ScrollValueBehaviour.TYPE); if (behaviour == null) return; if (!behaviour.isActive()) return; - if (behaviour.needsWrench && !AllItems.WRENCH.isIn(mc.player.getHeldItemMainhand())) + if (behaviour.needsWrench && !AllItems.WRENCH.isIn(mc.player.getMainHandItem())) return; - boolean highlight = behaviour.testHit(target.getHitVec()); + boolean highlight = behaviour.testHit(target.getLocation()); if (behaviour instanceof BulkScrollValueBehaviour && AllKeys.ctrlDown()) { BulkScrollValueBehaviour bulkScrolling = (BulkScrollValueBehaviour) behaviour; for (SmartTileEntity smartTileEntity : bulkScrolling.getBulk()) { ScrollValueBehaviour other = smartTileEntity.getBehaviour(ScrollValueBehaviour.TYPE); if (other != null) - addBox(world, smartTileEntity.getPos(), face, other, highlight); + addBox(world, smartTileEntity.getBlockPos(), face, other, highlight); } } else addBox(world, pos, face, behaviour, highlight); @@ -56,9 +56,9 @@ public class ScrollValueRenderer { protected static void addBox(ClientWorld world, BlockPos pos, Direction face, ScrollValueBehaviour behaviour, boolean highlight) { - AxisAlignedBB bb = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).grow(.5f) + AxisAlignedBB bb = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).inflate(.5f) .contract(0, 0, -.5f) - .offset(0, 0, -.125f); + .move(0, 0, -.125f); ITextComponent label = behaviour.label; ValueBox box; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java index 2b47c21fb..c6366b8da 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java @@ -19,10 +19,10 @@ public abstract class ColoredOverlayTileEntityRenderer ext protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getWorld())) return; + if (Backend.getInstance().canUseInstancing(te.getLevel())) return; SuperByteBuffer render = render(getOverlayBuffer(te), getColor(te, partialTicks), light); - render.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + render.renderInto(ms, buffer.getBuffer(RenderType.solid())); } protected abstract int getColor(T te, float partialTicks); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/SafeTileEntityRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/SafeTileEntityRenderer.java index 6c02f67f9..d69e54731 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/SafeTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/SafeTileEntityRenderer.java @@ -26,7 +26,7 @@ public abstract class SafeTileEntityRenderer extends TileE int overlay); public boolean isInvalid(T te) { - return !te.hasWorld() || te.getBlockState() + return !te.hasLevel() || te.getBlockState() .getBlock() == Blocks.AIR; } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/AbstractBlockBreakQueue.java b/src/main/java/com/simibubi/create/foundation/utility/AbstractBlockBreakQueue.java index cc4989e8d..4bef24374 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AbstractBlockBreakQueue.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AbstractBlockBreakQueue.java @@ -28,7 +28,7 @@ public abstract class AbstractBlockBreakQueue { public void destroyBlocks(World world, @Nullable LivingEntity entity, BiConsumer drop) { PlayerEntity playerEntity = entity instanceof PlayerEntity ? ((PlayerEntity) entity) : null; ItemStack toDamage = - playerEntity != null && !playerEntity.isCreative() ? playerEntity.getHeldItemMainhand() : ItemStack.EMPTY; + playerEntity != null && !playerEntity.isCreative() ? playerEntity.getMainHandItem() : ItemStack.EMPTY; destroyBlocks(world, toDamage, playerEntity, drop); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java index 3f8723672..4ed984af0 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java @@ -9,7 +9,7 @@ public class AngleHelper { * Legacy method. See {@link #horizontalAngleNew(Direction)} for new method. */ public static float horizontalAngle(Direction facing) { - float angle = facing.getHorizontalAngle(); + float angle = facing.toYRot(); if (facing.getAxis() == Axis.X) angle = -angle; return angle; @@ -22,7 +22,7 @@ public class AngleHelper { if (facing.getAxis().isVertical()) { return 0; } - float angle = facing.getHorizontalAngle(); + float angle = facing.toYRot(); if (facing.getAxis() == Axis.X) angle = -angle; return angle; 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 efc5f90f8..2564c2cc6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java @@ -19,7 +19,7 @@ public class AnimationTickHolder { public static void tick() { if (!Minecraft.getInstance() - .isGamePaused()) { + .isPaused()) { ticks = (ticks + 1) % 1_728_000; // wrap around every 24 hours so we maintain enough floating point precision } else { paused_ticks = (paused_ticks + 1) % 1_728_000; @@ -40,7 +40,7 @@ public class AnimationTickHolder { public static float getPartialTicks() { Minecraft mc = Minecraft.getInstance(); - return (mc.isGamePaused() ? mc.renderPartialTicksPaused : mc.getRenderPartialTicks()); + return (mc.isPaused() ? mc.pausePartialTick : mc.getFrameTime()); } public static int getTicks(IWorld world) { diff --git a/src/main/java/com/simibubi/create/foundation/utility/BlockFace.java b/src/main/java/com/simibubi/create/foundation/utility/BlockFace.java index b26edb76c..a995e5fae 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockFace.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockFace.java @@ -34,7 +34,7 @@ public class BlockFace extends Pair { } public BlockPos getConnectedPos() { - return getPos().offset(getFace()); + return getPos().relative(getFace()); } public CompoundNBT serializeNBT() { diff --git a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java index 929a73904..b8f0102dc 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java @@ -60,10 +60,10 @@ public class BlockHelper { ClientWorld world = (ClientWorld) worldIn; VoxelShape voxelshape = state.getShape(world, pos); MutableInt amtBoxes = new MutableInt(0); - voxelshape.forEachBox((x1, y1, z1, x2, y2, z2) -> amtBoxes.increment()); + voxelshape.forAllBoxes((x1, y1, z1, x2, y2, z2) -> amtBoxes.increment()); double chance = 1d / amtBoxes.getValue(); - voxelshape.forEachBox((x1, y1, z1, x2, y2, z2) -> { + voxelshape.forAllBoxes((x1, y1, z1, x2, y2, z2) -> { double d1 = Math.min(1.0D, x2 - x1); double d2 = Math.min(1.0D, y2 - y1); double d3 = Math.min(1.0D, z2 - z1); @@ -74,7 +74,7 @@ public class BlockHelper { for (int l = 0; l < i; ++l) { for (int i1 = 0; i1 < j; ++i1) { for (int j1 = 0; j1 < k; ++j1) { - if (world.rand.nextDouble() > chance) + if (world.random.nextDouble() > chance) continue; double d4 = ((double) l + 0.5D) / (double) i; @@ -84,8 +84,8 @@ public class BlockHelper { double d8 = d5 * d2 + y1; double d9 = d6 * d3 + z1; manager - .addEffect((new DiggingParticle(world, (double) pos.getX() + d7, (double) pos.getY() + d8, - (double) pos.getZ() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, state)).setBlockPos(pos)); + .add((new DiggingParticle(world, (double) pos.getX() + d7, (double) pos.getY() + d8, + (double) pos.getZ() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, state)).init(pos)); } } } @@ -94,32 +94,32 @@ public class BlockHelper { } public static BlockState setZeroAge(BlockState blockState) { - if (blockState.contains(BlockStateProperties.AGE_0_1)) - return blockState.with(BlockStateProperties.AGE_0_1, 0); - if (blockState.contains(BlockStateProperties.AGE_0_2)) - return blockState.with(BlockStateProperties.AGE_0_2, 0); - if (blockState.contains(BlockStateProperties.AGE_0_3)) - return blockState.with(BlockStateProperties.AGE_0_3, 0); - if (blockState.contains(BlockStateProperties.AGE_0_5)) - return blockState.with(BlockStateProperties.AGE_0_5, 0); - if (blockState.contains(BlockStateProperties.AGE_0_7)) - return blockState.with(BlockStateProperties.AGE_0_7, 0); - if (blockState.contains(BlockStateProperties.AGE_0_15)) - return blockState.with(BlockStateProperties.AGE_0_15, 0); - if (blockState.contains(BlockStateProperties.AGE_0_25)) - return blockState.with(BlockStateProperties.AGE_0_25, 0); - if (blockState.contains(BlockStateProperties.HONEY_LEVEL)) - return blockState.with(BlockStateProperties.HONEY_LEVEL, 0); - if (blockState.contains(BlockStateProperties.HATCH_0_2)) - return blockState.with(BlockStateProperties.HATCH_0_2, 0); - if (blockState.contains(BlockStateProperties.STAGE_0_1)) - return blockState.with(BlockStateProperties.STAGE_0_1, 0); - if (blockState.contains(BlockStateProperties.LEVEL_0_3)) - return blockState.with(BlockStateProperties.LEVEL_0_3, 0); - if (blockState.contains(BlockStateProperties.LEVEL_0_8)) - return blockState.with(BlockStateProperties.LEVEL_0_8, 0); - if (blockState.contains(BlockStateProperties.EXTENDED)) - return blockState.with(BlockStateProperties.EXTENDED, false); + if (blockState.hasProperty(BlockStateProperties.AGE_1)) + return blockState.setValue(BlockStateProperties.AGE_1, 0); + if (blockState.hasProperty(BlockStateProperties.AGE_2)) + return blockState.setValue(BlockStateProperties.AGE_2, 0); + if (blockState.hasProperty(BlockStateProperties.AGE_3)) + return blockState.setValue(BlockStateProperties.AGE_3, 0); + if (blockState.hasProperty(BlockStateProperties.AGE_5)) + return blockState.setValue(BlockStateProperties.AGE_5, 0); + if (blockState.hasProperty(BlockStateProperties.AGE_7)) + return blockState.setValue(BlockStateProperties.AGE_7, 0); + if (blockState.hasProperty(BlockStateProperties.AGE_15)) + return blockState.setValue(BlockStateProperties.AGE_15, 0); + if (blockState.hasProperty(BlockStateProperties.AGE_25)) + return blockState.setValue(BlockStateProperties.AGE_25, 0); + if (blockState.hasProperty(BlockStateProperties.LEVEL_HONEY)) + return blockState.setValue(BlockStateProperties.LEVEL_HONEY, 0); + if (blockState.hasProperty(BlockStateProperties.HATCH)) + return blockState.setValue(BlockStateProperties.HATCH, 0); + if (blockState.hasProperty(BlockStateProperties.STAGE)) + return blockState.setValue(BlockStateProperties.STAGE, 0); + if (blockState.hasProperty(BlockStateProperties.LEVEL_CAULDRON)) + return blockState.setValue(BlockStateProperties.LEVEL_CAULDRON, 0); + if (blockState.hasProperty(BlockStateProperties.LEVEL_COMPOSTER)) + return blockState.setValue(BlockStateProperties.LEVEL_COMPOSTER, 0); + if (blockState.hasProperty(BlockStateProperties.EXTENDED)) + return blockState.setValue(BlockStateProperties.EXTENDED, false); return blockState; } @@ -127,41 +127,41 @@ public class BlockHelper { int amountFound = 0; Item required = getRequiredItem(block).getItem(); - boolean needsTwo = block.contains(BlockStateProperties.SLAB_TYPE) - && block.get(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE; + boolean needsTwo = block.hasProperty(BlockStateProperties.SLAB_TYPE) + && block.getValue(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE; if (needsTwo) amount *= 2; - if (block.contains(BlockStateProperties.EGGS_1_4)) - amount *= block.get(BlockStateProperties.EGGS_1_4); + if (block.hasProperty(BlockStateProperties.EGGS)) + amount *= block.getValue(BlockStateProperties.EGGS); - if (block.contains(BlockStateProperties.PICKLES_1_4)) - amount *= block.get(BlockStateProperties.PICKLES_1_4); + if (block.hasProperty(BlockStateProperties.PICKLES)) + amount *= block.getValue(BlockStateProperties.PICKLES); { // Try held Item first - int preferredSlot = player.inventory.currentItem; - ItemStack itemstack = player.inventory.getStackInSlot(preferredSlot); + int preferredSlot = player.inventory.selected; + ItemStack itemstack = player.inventory.getItem(preferredSlot); int count = itemstack.getCount(); if (itemstack.getItem() == required && count > 0) { int taken = Math.min(count, amount - amountFound); - player.inventory.setInventorySlotContents(preferredSlot, + player.inventory.setItem(preferredSlot, new ItemStack(itemstack.getItem(), count - taken)); amountFound += taken; } } // Search inventory - for (int i = 0; i < player.inventory.getSizeInventory(); ++i) { + for (int i = 0; i < player.inventory.getContainerSize(); ++i) { if (amountFound == amount) break; - ItemStack itemstack = player.inventory.getStackInSlot(i); + ItemStack itemstack = player.inventory.getItem(i); int count = itemstack.getCount(); if (itemstack.getItem() == required && count > 0) { int taken = Math.min(count, amount - amountFound); - player.inventory.setInventorySlotContents(i, new ItemStack(itemstack.getItem(), count - taken)); + player.inventory.setItem(i, new ItemStack(itemstack.getItem(), count - taken)); amountFound += taken; } } @@ -169,7 +169,7 @@ public class BlockHelper { if (needsTwo) { // Give back 1 if uneven amount was removed if (amountFound % 2 != 0) - player.inventory.addItemStackToInventory(new ItemStack(required)); + player.inventory.add(new ItemStack(required)); amountFound /= 2; } @@ -186,7 +186,7 @@ public class BlockHelper { } public static void destroyBlock(World world, BlockPos pos, float effectChance) { - destroyBlock(world, pos, effectChance, stack -> Block.spawnAsEntity(world, pos, stack)); + destroyBlock(world, pos, effectChance, stack -> Block.popResource(world, pos, stack)); } public static void destroyBlock(World world, BlockPos pos, float effectChance, @@ -198,9 +198,9 @@ public class BlockHelper { float effectChance, Consumer droppedItemCallback) { FluidState fluidState = world.getFluidState(pos); BlockState state = world.getBlockState(pos); - if (world.rand.nextFloat() < effectChance) - world.playEvent(2001, pos, Block.getStateId(state)); - TileEntity tileentity = state.hasTileEntity() ? world.getTileEntity(pos) : null; + if (world.random.nextFloat() < effectChance) + world.levelEvent(2001, pos, Block.getId(state)); + TileEntity tileentity = state.hasTileEntity() ? world.getBlockEntity(pos) : null; if (player != null) { BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, player); MinecraftForge.EVENT_BUS.post(event); @@ -209,25 +209,25 @@ public class BlockHelper { if (event.getExpToDrop() > 0 && world instanceof ServerWorld) state.getBlock() - .dropXpOnBlockBreak((ServerWorld) world, pos, event.getExpToDrop()); + .popExperience((ServerWorld) world, pos, event.getExpToDrop()); - usedTool.onBlockDestroyed(world, state, pos, player); - player.addStat(Stats.BLOCK_MINED.get(state.getBlock())); + usedTool.mineBlock(world, state, pos, player); + player.awardStat(Stats.BLOCK_MINED.get(state.getBlock())); } if (world instanceof ServerWorld && world.getGameRules() - .getBoolean(GameRules.DO_TILE_DROPS) && !world.restoringBlockSnapshots + .getBoolean(GameRules.RULE_DOBLOCKDROPS) && !world.restoringBlockSnapshots && (player == null || !player.isCreative())) { for (ItemStack itemStack : Block.getDrops(state, (ServerWorld) world, pos, tileentity, player, usedTool)) droppedItemCallback.accept(itemStack); - state.spawnAdditionalDrops((ServerWorld) world, pos, ItemStack.EMPTY); + state.spawnAfterBreak((ServerWorld) world, pos, ItemStack.EMPTY); } - world.setBlockState(pos, fluidState.getBlockState()); + world.setBlockAndUpdate(pos, fluidState.createLegacyBlock()); } public static boolean isSolidWall(IBlockReader reader, BlockPos fromPos, Direction toDirection) { - return hasBlockSolidSide(reader.getBlockState(fromPos.offset(toDirection)), reader, fromPos.offset(toDirection), + return hasBlockSolidSide(reader.getBlockState(fromPos.relative(toDirection)), reader, fromPos.relative(toDirection), toDirection.getOpposite()); } @@ -248,69 +248,69 @@ public class BlockHelper { chunk.getSections()[j >> 4] = chunksection; } BlockState old = chunksection.setBlockState(i, j & 15, k, state); - chunk.markDirty(); + chunk.markUnsaved(); world.markAndNotifyBlock(target, chunk, old, state, 82, 512); - world.setBlockState(target, state, 82); - world.neighborChanged(target, world.getBlockState(target.down()).getBlock(), target.down()); + world.setBlock(target, state, 82); + world.neighborChanged(target, world.getBlockState(target.below()).getBlock(), target.below()); } public static void placeSchematicBlock(World world, BlockState state, BlockPos target, ItemStack stack, @Nullable CompoundNBT data) { // Piston - if (state.contains(BlockStateProperties.EXTENDED)) - state = state.with(BlockStateProperties.EXTENDED, Boolean.FALSE); - if (state.contains(BlockStateProperties.WATERLOGGED)) - state = state.with(BlockStateProperties.WATERLOGGED, Boolean.FALSE); + if (state.hasProperty(BlockStateProperties.EXTENDED)) + state = state.setValue(BlockStateProperties.EXTENDED, Boolean.FALSE); + if (state.hasProperty(BlockStateProperties.WATERLOGGED)) + state = state.setValue(BlockStateProperties.WATERLOGGED, Boolean.FALSE); if (AllBlocks.BELT.has(state)) { - world.setBlockState(target, state, 2); + world.setBlock(target, state, 2); return; } else if (state.getBlock() == Blocks.COMPOSTER) - state = Blocks.COMPOSTER.getDefaultState(); + state = Blocks.COMPOSTER.defaultBlockState(); else if (state.getBlock() != Blocks.SEA_PICKLE && state.getBlock() instanceof IPlantable) state = ((IPlantable) state.getBlock()).getPlant(world, target); - if (world.getDimension() - .isUltrawarm() + if (world.dimensionType() + .ultraWarm() && state.getFluidState() - .getFluid() - .isIn(FluidTags.WATER)) { + .getType() + .is(FluidTags.WATER)) { int i = target.getX(); int j = target.getY(); int k = target.getZ(); - world.playSound(null, target, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, - 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + world.playSound(null, target, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, + 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { world.addParticle(ParticleTypes.LARGE_SMOKE, i + Math.random(), j + Math.random(), k + Math.random(), 0.0D, 0.0D, 0.0D); } - Block.spawnDrops(state, world, target); + Block.dropResources(state, world, target); return; } if (state.getBlock() instanceof AbstractRailBlock) { placeRailWithoutUpdate(world, state, target); } else { - world.setBlockState(target, state, 18); + world.setBlock(target, state, 18); } if (data != null) { - TileEntity tile = world.getTileEntity(target); + TileEntity tile = world.getBlockEntity(target); if (tile != null) { data.putInt("x", target.getX()); data.putInt("y", target.getY()); data.putInt("z", target.getZ()); if (tile instanceof KineticTileEntity) ((KineticTileEntity) tile).warnOfMovement(); - tile.fromTag(tile.getBlockState(), data); + tile.load(tile.getBlockState(), data); } } try { state.getBlock() - .onBlockPlacedBy(world, target, state, null, stack); + .setPlacedBy(world, target, state, null, stack); } catch (Exception e) { } } @@ -325,16 +325,16 @@ public class BlockHelper { public static boolean hasBlockSolidSide(BlockState p_220056_0_, IBlockReader p_220056_1_, BlockPos p_220056_2_, Direction p_220056_3_) { - return !p_220056_0_.isIn(BlockTags.LEAVES) - && Block.doesSideFillSquare(p_220056_0_.getCollisionShape(p_220056_1_, p_220056_2_), p_220056_3_); + return !p_220056_0_.is(BlockTags.LEAVES) + && Block.isFaceFull(p_220056_0_.getCollisionShape(p_220056_1_, p_220056_2_), p_220056_3_); } public static boolean extinguishFire(World world, @Nullable PlayerEntity p_175719_1_, BlockPos p_175719_2_, Direction p_175719_3_) { - p_175719_2_ = p_175719_2_.offset(p_175719_3_); + p_175719_2_ = p_175719_2_.relative(p_175719_3_); if (world.getBlockState(p_175719_2_) .getBlock() == Blocks.FIRE) { - world.playEvent(p_175719_1_, 1009, p_175719_2_, 0); + world.levelEvent(p_175719_1_, 1009, p_175719_2_, 0); world.removeBlock(p_175719_2_, false); return true; } else { diff --git a/src/main/java/com/simibubi/create/foundation/utility/ColorHandlers.java b/src/main/java/com/simibubi/create/foundation/utility/ColorHandlers.java index 75e429dd1..4022dba98 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ColorHandlers.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ColorHandlers.java @@ -10,7 +10,7 @@ import net.minecraft.world.biome.BiomeColors; public class ColorHandlers { public static IBlockColor getGrassyBlock() { - return (state, world, pos, layer) -> pos != null && world != null ? BiomeColors.getGrassColor(world, pos) + return (state, world, pos, layer) -> pos != null && world != null ? BiomeColors.getAverageGrassColor(world, pos) : GrassColors.get(0.5D, 1.0D); } @@ -20,7 +20,7 @@ public class ColorHandlers { public static IBlockColor getRedstonePower() { return (state, world, pos, layer) -> RedstoneWireBlock - .getWireColor(pos != null && world != null ? state.get(BlockStateProperties.POWER_0_15) : 0); + .getColorForPower(pos != null && world != null ? state.getValue(BlockStateProperties.POWER) : 0); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/Debug.java b/src/main/java/com/simibubi/create/foundation/utility/Debug.java index e6445ae11..f59840d5b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Debug.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Debug.java @@ -18,20 +18,20 @@ public class Debug { @Deprecated public static void debugChat(String message) { if (Minecraft.getInstance().player != null) - Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(message), false); + Minecraft.getInstance().player.displayClientMessage(new StringTextComponent(message), false); } @Deprecated public static void debugChatAndShowStack(String message, int depth) { if (Minecraft.getInstance().player != null) - Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(message).append("@") + Minecraft.getInstance().player.displayClientMessage(new StringTextComponent(message).append("@") .append(debugStack(depth)), false); } @Deprecated public static void debugMessage(String message) { if (Minecraft.getInstance().player != null) - Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(message), true); + Minecraft.getInstance().player.displayClientMessage(new StringTextComponent(message), true); } @Deprecated @@ -50,17 +50,17 @@ public class Debug { StackTraceElement[] stackTraceElements = Thread.currentThread() .getStackTrace(); IFormattableTextComponent text = new StringTextComponent("[") - .append(new StringTextComponent(getLogicalSide()).formatted(TextFormatting.GOLD)) + .append(new StringTextComponent(getLogicalSide()).withStyle(TextFormatting.GOLD)) .append("] "); for (int i = 1; i < depth + 2 && i < stackTraceElements.length; i++) { StackTraceElement e = stackTraceElements[i]; if (e.getClassName() .equals(Debug.class.getName())) continue; - text.append(new StringTextComponent(e.getMethodName()).formatted(TextFormatting.YELLOW)) + text.append(new StringTextComponent(e.getMethodName()).withStyle(TextFormatting.YELLOW)) .append(", "); } - return text.append(new StringTextComponent(" ...").formatted(TextFormatting.GRAY)); + return text.append(new StringTextComponent(" ...").withStyle(TextFormatting.GRAY)); } @Deprecated diff --git a/src/main/java/com/simibubi/create/foundation/utility/DirectionHelper.java b/src/main/java/com/simibubi/create/foundation/utility/DirectionHelper.java index 88ce27061..14996e0ea 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/DirectionHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/DirectionHelper.java @@ -27,7 +27,7 @@ public class DirectionHelper { return dir; case Y: if (dir != UP && dir != DOWN) { - return dir.rotateY(); + return dir.getClockWise(); } return dir; diff --git a/src/main/java/com/simibubi/create/foundation/utility/EmptyNamedTag.java b/src/main/java/com/simibubi/create/foundation/utility/EmptyNamedTag.java index 6e33ff6d1..8e6814ad8 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/EmptyNamedTag.java +++ b/src/main/java/com/simibubi/create/foundation/utility/EmptyNamedTag.java @@ -24,7 +24,7 @@ public class EmptyNamedTag implements Tags.IOptionalNamedTag { } @Override - public ResourceLocation getId() { + public ResourceLocation getName() { return id; } @@ -34,7 +34,7 @@ public class EmptyNamedTag implements Tags.IOptionalNamedTag { } @Override - public List values() { + public List getValues() { return Collections.emptyList(); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/FontHelper.java b/src/main/java/com/simibubi/create/foundation/utility/FontHelper.java index c81ffef70..ce5f20f32 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/FontHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/FontHelper.java @@ -31,7 +31,7 @@ public final class FontHelper { StringBuilder currentLine = new StringBuilder(); int width = 0; for (String word : words) { - int newWidth = font.getStringWidth(word); + int newWidth = font.width(word); if (width + newWidth > maxWidthPerLine) { if (width > 0) { String line = currentLine.toString(); @@ -55,13 +55,13 @@ public final class FontHelper { public static void drawSplitString(MatrixStack ms, FontRenderer font, String text, int x, int y, int width, int color) { List list = cutString(font, text, width); - Matrix4f matrix4f = ms.peek() - .getModel(); + Matrix4f matrix4f = ms.last() + .pose(); for (String s : list) { float f = (float) x; - if (font.getBidiFlag()) { - int i = font.getStringWidth(font.bidiReorder(s)); + if (font.isBidirectional()) { + int i = font.width(font.bidirectionalShaping(s)); f += (float) (width - i); } @@ -76,10 +76,10 @@ public final class FontHelper { return 0; } else { IRenderTypeBuffer.Impl irendertypebuffer$impl = IRenderTypeBuffer.immediate(Tessellator.getInstance() - .getBuffer()); - int i = font.draw(p_228078_1_, p_228078_2_, p_228078_3_, p_228078_4_, p_228078_6_, p_228078_5_, + .getBuilder()); + int i = font.drawInBatch(p_228078_1_, p_228078_2_, p_228078_3_, p_228078_4_, p_228078_6_, p_228078_5_, irendertypebuffer$impl, false, 0, 15728880); - irendertypebuffer$impl.draw(); + irendertypebuffer$impl.endBatch(); return i; } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java b/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java index 1b361b789..fb923c13a 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java @@ -13,7 +13,7 @@ public interface ISimpleReloadListener extends IFutureReloadListener { @Override default CompletableFuture reload(IFutureReloadListener.IStage stage, IResourceManager resourceManager, IProfiler prepareProfiler, IProfiler applyProfiler, Executor prepareExecutor, Executor applyExecutor) { - return stage.markCompleteAwaitingOthers(Unit.INSTANCE).thenRunAsync(() -> { + return stage.wait(Unit.INSTANCE).thenRunAsync(() -> { onReload(resourceManager, applyProfiler); }, applyExecutor); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/Iterate.java b/src/main/java/com/simibubi/create/foundation/utility/Iterate.java index 71b621cd2..138d2642c 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Iterate.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Iterate.java @@ -21,7 +21,7 @@ public class Iterate { private static Direction[] getHorizontals() { Direction[] directions = new Direction[4]; for (int i = 0; i < 4; i++) - directions[i] = Direction.byHorizontalIndex(i); + directions[i] = Direction.from2DDataValue(i); return directions; } @@ -38,10 +38,10 @@ public class Iterate { } public static List hereAndBelow(BlockPos pos) { - return Arrays.asList(pos, pos.down()); + return Arrays.asList(pos, pos.below()); } public static List hereBelowAndAbove(BlockPos pos) { - return Arrays.asList(pos, pos.down(), pos.up()); + return Arrays.asList(pos, pos.below(), pos.above()); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/Lang.java b/src/main/java/com/simibubi/create/foundation/utility/Lang.java index 62384d800..4572424b2 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Lang.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Lang.java @@ -21,7 +21,7 @@ public class Lang { } public static void sendStatus(PlayerEntity player, String key, Object... args) { - player.sendStatusMessage(createTranslationTextComponent(key, args), true); + player.displayClientMessage(createTranslationTextComponent(key, args), true); } public static List translatedOptions(String prefix, String... keys) { diff --git a/src/main/java/com/simibubi/create/foundation/utility/MatrixStacker.java b/src/main/java/com/simibubi/create/foundation/utility/MatrixStacker.java index 11ff390c7..009e20420 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/MatrixStacker.java +++ b/src/main/java/com/simibubi/create/foundation/utility/MatrixStacker.java @@ -25,12 +25,12 @@ public class MatrixStacker { } public MatrixStacker restoreIdentity() { - MatrixStack.Entry entry = ms.peek(); + MatrixStack.Entry entry = ms.last(); - entry.getModel() - .loadIdentity(); - entry.getNormal() - .loadIdentity(); + entry.pose() + .setIdentity(); + entry.normal() + .setIdentity(); return this; } @@ -38,27 +38,27 @@ public class MatrixStacker { public MatrixStacker rotate(Direction axis, float radians) { if (radians == 0) return this; - ms.multiply(axis.getUnitVector() - .getRadialQuaternion(radians)); + ms.mulPose(axis.step() + .rotation(radians)); return this; } public MatrixStacker rotate(double angle, Axis axis) { Vector3f vec = - axis == Axis.X ? Vector3f.POSITIVE_X : axis == Axis.Y ? Vector3f.POSITIVE_Y : Vector3f.POSITIVE_Z; + axis == Axis.X ? Vector3f.XP : axis == Axis.Y ? Vector3f.YP : Vector3f.ZP; return multiply(vec, angle); } public MatrixStacker rotateX(double angle) { - return multiply(Vector3f.POSITIVE_X, angle); + return multiply(Vector3f.XP, angle); } public MatrixStacker rotateY(double angle) { - return multiply(Vector3f.POSITIVE_Y, angle); + return multiply(Vector3f.YP, angle); } public MatrixStacker rotateZ(double angle) { - return multiply(Vector3f.POSITIVE_Z, angle); + return multiply(Vector3f.ZP, angle); } public MatrixStacker centre() { @@ -90,7 +90,7 @@ public class MatrixStacker { } public MatrixStacker multiply(Quaternion quaternion) { - ms.multiply(quaternion); + ms.mulPose(quaternion); return this; } @@ -107,17 +107,17 @@ public class MatrixStacker { public MatrixStacker multiply(Vector3f axis, double angle) { if (angle == 0) return this; - ms.multiply(axis.getDegreesQuaternion((float) angle)); + ms.mulPose(axis.rotationDegrees((float) angle)); return this; } public MatrixStacker push() { - ms.push(); + ms.pushPose(); return this; } public MatrixStacker pop() { - ms.pop(); + ms.popPose(); return this; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/NBTHelper.java b/src/main/java/com/simibubi/create/foundation/utility/NBTHelper.java index abb7f39c5..34d32c713 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/NBTHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/NBTHelper.java @@ -58,17 +58,17 @@ public class NBTHelper { } public static List readItemList(ListNBT stacks) { - return readCompoundList(stacks, ItemStack::read); + return readCompoundList(stacks, ItemStack::of); } public static ListNBT writeAABB(AxisAlignedBB bb) { ListNBT bbtag = new ListNBT(); - bbtag.add(FloatNBT.of((float) bb.minX)); - bbtag.add(FloatNBT.of((float) bb.minY)); - bbtag.add(FloatNBT.of((float) bb.minZ)); - bbtag.add(FloatNBT.of((float) bb.maxX)); - bbtag.add(FloatNBT.of((float) bb.maxY)); - bbtag.add(FloatNBT.of((float) bb.maxZ)); + bbtag.add(FloatNBT.valueOf((float) bb.minX)); + bbtag.add(FloatNBT.valueOf((float) bb.minY)); + bbtag.add(FloatNBT.valueOf((float) bb.minZ)); + bbtag.add(FloatNBT.valueOf((float) bb.maxX)); + bbtag.add(FloatNBT.valueOf((float) bb.maxY)); + bbtag.add(FloatNBT.valueOf((float) bb.maxZ)); return bbtag; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java b/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java index cf919904a..8c1cc871a 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java +++ b/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java @@ -54,14 +54,14 @@ public final class NBTProcessors { ListNBT pages = tag.getList("pages", Constants.NBT.TAG_STRING); for (INBT inbt : pages) { - if (textComponentHasClickEvent(inbt.getString())) + if (textComponentHasClickEvent(inbt.getAsString())) return null; } return data; }); addSurvivalProcessor(AllTileEntities.FUNNEL.get(), data -> { if (data.contains("Filter")) { - ItemStack filter = ItemStack.read(data.getCompound("Filter")); + ItemStack filter = ItemStack.of(data.getCompound("Filter")); if (filter.getItem() instanceof FilterItem) data.remove("Filter"); } @@ -90,7 +90,7 @@ public final class NBTProcessors { .apply(compound); if (tileEntity instanceof MobSpawnerTileEntity) return compound; - if (tileEntity.onlyOpsCanSetNbt()) + if (tileEntity.onlyOpCanSetNbt()) return null; return compound; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/Pointing.java b/src/main/java/com/simibubi/create/foundation/utility/Pointing.java index c9eac4486..c734ab4e5 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Pointing.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Pointing.java @@ -15,7 +15,7 @@ public enum Pointing implements IStringSerializable { } @Override - public String getString() { + public String getSerializedName() { return Lang.asId(name()); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/RaycastHelper.java b/src/main/java/com/simibubi/create/foundation/utility/RaycastHelper.java index 057c2b378..2b8b6af84 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/RaycastHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/RaycastHelper.java @@ -19,7 +19,7 @@ public class RaycastHelper { Vector3d origin = getTraceOrigin(playerIn); Vector3d target = getTraceTarget(playerIn, range, origin); RayTraceContext context = new RayTraceContext(origin, target, BlockMode.COLLIDER, FluidMode.NONE, playerIn); - return worldIn.rayTraceBlocks(context); + return worldIn.clip(context); } public static PredicateTraceResult rayTraceUntil(PlayerEntity playerIn, double range, @@ -30,8 +30,8 @@ public class RaycastHelper { } public static Vector3d getTraceTarget(PlayerEntity playerIn, double range, Vector3d origin) { - float f = playerIn.rotationPitch; - float f1 = playerIn.rotationYaw; + float f = playerIn.xRot; + float f1 = playerIn.yRot; float f2 = MathHelper.cos(-f1 * 0.017453292F - (float) Math.PI); float f3 = MathHelper.sin(-f1 * 0.017453292F - (float) Math.PI); float f4 = -MathHelper.cos(-f * 0.017453292F); @@ -67,7 +67,7 @@ public class RaycastHelper { BlockPos currentPos = new BlockPos(x, y, z); if (predicate.test(currentPos)) - return new PredicateTraceResult(currentPos, Direction.getFacingFromVector(dx - x, dy - y, dz - z)); + return new PredicateTraceResult(currentPos, Direction.getNearest(dx - x, dy - y, dz - z)); int remainingDistance = 200; diff --git a/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java b/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java index 45e7e224b..28038851a 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java @@ -32,9 +32,9 @@ public class ServerSpeedProvider { @OnlyIn(Dist.CLIENT) public static void clientTick() { if (Minecraft.getInstance() - .isSingleplayer() + .hasSingleplayerServer() && Minecraft.getInstance() - .isGamePaused()) + .isPaused()) return; modifier.tick(); clientTimer++; 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 3b7f6e5ea..1fb499a09 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java +++ b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java @@ -69,11 +69,11 @@ public class TreeCutter { List frontier = new LinkedList<>(); // Bamboo, Sugar Cane, Cactus - BlockState stateAbove = reader.getBlockState(pos.up()); + BlockState stateAbove = reader.getBlockState(pos.above()); if (isVerticalPlant(stateAbove)) { - logs.add(pos.up()); + logs.add(pos.above()); for (int i = 1; i < 256; i++) { - BlockPos current = pos.up(i); + BlockPos current = pos.above(i); if (!isVerticalPlant(reader.getBlockState(current))) break; logs.add(current); @@ -84,13 +84,13 @@ public class TreeCutter { // Chorus if (isChorus(stateAbove)) { - frontier.add(pos.up()); + frontier.add(pos.above()); while (!frontier.isEmpty()) { BlockPos current = frontier.remove(0); visited.add(current); logs.add(current); for (Direction direction : Iterate.directions) { - BlockPos offset = current.offset(direction); + BlockPos offset = current.relative(direction); if (visited.contains(offset)) continue; if (!isChorus(reader.getBlockState(offset))) @@ -107,7 +107,7 @@ public class TreeCutter { return NO_TREE; visited.add(pos); - BlockPos.getAllInBox(pos.add(-1, 0, -1), pos.add(1, 1, 1)) + BlockPos.betweenClosedStream(pos.offset(-1, 0, -1), pos.offset(1, 1, 1)) .forEach(p -> frontier.add(new BlockPos(p))); // Find all logs @@ -143,15 +143,15 @@ public class TreeCutter { if (isGenericLeaf) leaves.add(currentPos); - int distance = !isLeaf ? 0 : blockState.get(LeavesBlock.DISTANCE); + int distance = !isLeaf ? 0 : blockState.getValue(LeavesBlock.DISTANCE); for (Direction direction : Iterate.directions) { - BlockPos offset = currentPos.offset(direction); + BlockPos offset = currentPos.relative(direction); if (visited.contains(offset)) continue; BlockState state = reader.getBlockState(offset); BlockPos subtract = offset.subtract(pos); int horizontalDistance = Math.max(Math.abs(subtract.getX()), Math.abs(subtract.getZ())); - if (isLeaf(state) && state.get(LeavesBlock.DISTANCE) > distance + if (isLeaf(state) && state.getValue(LeavesBlock.DISTANCE) > distance || isNonDecayingLeaf(state) && horizontalDistance < 4) frontier.add(offset); } @@ -190,7 +190,7 @@ public class TreeCutter { Set visited = new HashSet<>(); List frontier = new LinkedList<>(); frontier.add(pos); - frontier.add(pos.up()); + frontier.add(pos.above()); int posY = pos.getY(); while (!frontier.isEmpty()) { @@ -200,7 +200,7 @@ public class TreeCutter { if (!isLog(reader.getBlockState(currentPos))) continue; - if (!lowerLayer && !pos.equals(currentPos.down()) && isLog(reader.getBlockState(currentPos.down()))) + if (!lowerLayer && !pos.equals(currentPos.below()) && isLog(reader.getBlockState(currentPos.below()))) return false; for (Direction direction : Iterate.directions) { @@ -208,7 +208,7 @@ public class TreeCutter { continue; if (direction == Direction.UP && !lowerLayer) continue; - BlockPos offset = currentPos.offset(direction); + BlockPos offset = currentPos.relative(direction); if (visited.contains(offset)) continue; frontier.add(offset); @@ -220,21 +220,21 @@ public class TreeCutter { } private static void addNeighbours(BlockPos pos, List frontier, Set visited) { - BlockPos.getAllInBox(pos.add(-1, -1, -1), pos.add(1, 1, 1)) + BlockPos.betweenClosedStream(pos.offset(-1, -1, -1), pos.offset(1, 1, 1)) .filter(((Predicate) visited::contains).negate()) .forEach(p -> frontier.add(new BlockPos(p))); } private static boolean isLog(BlockState state) { - return state.isIn(BlockTags.LOGS) || AllTags.AllBlockTags.SLIMY_LOGS.matches(state); + return state.is(BlockTags.LOGS) || AllTags.AllBlockTags.SLIMY_LOGS.matches(state); } private static boolean isNonDecayingLeaf(BlockState state) { - return state.isIn(BlockTags.WART_BLOCKS) || state.getBlock() == Blocks.SHROOMLIGHT; + return state.is(BlockTags.WART_BLOCKS) || state.getBlock() == Blocks.SHROOMLIGHT; } private static boolean isLeaf(BlockState state) { - return state.contains(LeavesBlock.DISTANCE); + return state.hasProperty(LeavesBlock.DISTANCE); } public static class Tree extends AbstractBlockBreakQueue { diff --git a/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java b/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java index 676e3f7fb..7d273f44e 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java @@ -85,11 +85,11 @@ public class VecHelper { public static Vector3d lookAt(Vector3d vec, Vector3d fwd) { fwd = fwd.normalize(); Vector3d up = new Vector3d(0,1,0); - double dot = fwd.dotProduct(up); + double dot = fwd.dot(up); if (Math.abs(dot) > 1 - 1.0E-3) up = new Vector3d(0, 0, dot > 0 ? 1 : -1); - Vector3d right = fwd.crossProduct(up).normalize(); - up = right.crossProduct(fwd).normalize(); + Vector3d right = fwd.cross(up).normalize(); + up = right.cross(fwd).normalize(); double x = vec.x * right.x + vec.y * up.x + vec.z * fwd.x; double y = vec.x * right.y + vec.y * up.y + vec.z * fwd.y; double z = vec.x * right.z + vec.y * up.z + vec.z * fwd.z; @@ -97,14 +97,14 @@ public class VecHelper { } public static boolean isVecPointingTowards(Vector3d vec, Direction direction) { - return Vector3d.of(direction.getDirectionVec()) - .dotProduct(vec.normalize()) > 0.125; // slight tolerance to activate perpendicular movement actors + return Vector3d.atLowerCornerOf(direction.getNormal()) + .dot(vec.normalize()) > 0.125; // slight tolerance to activate perpendicular movement actors } public static Vector3d getCenterOf(Vector3i pos) { - if (pos.equals(Vector3i.NULL_VECTOR)) + if (pos.equals(Vector3i.ZERO)) return CENTER_OF_ORIGIN; - return Vector3d.of(pos) + return Vector3d.atLowerCornerOf(pos) .add(.5f, .5f, .5f); } @@ -119,14 +119,14 @@ public class VecHelper { } public static Vector3d axisAlingedPlaneOf(Direction face) { - return axisAlingedPlaneOf(Vector3d.of(face.getDirectionVec())); + return axisAlingedPlaneOf(Vector3d.atLowerCornerOf(face.getNormal())); } public static ListNBT writeNBT(Vector3d vec) { ListNBT listnbt = new ListNBT(); - listnbt.add(DoubleNBT.of(vec.x)); - listnbt.add(DoubleNBT.of(vec.y)); - listnbt.add(DoubleNBT.of(vec.z)); + listnbt.add(DoubleNBT.valueOf(vec.x)); + listnbt.add(DoubleNBT.valueOf(vec.y)); + listnbt.add(DoubleNBT.valueOf(vec.z)); return listnbt; } @@ -141,11 +141,11 @@ public class VecHelper { } public static int getCoordinate(Vector3i pos, Axis axis) { - return axis.getCoordinate(pos.getX(), pos.getY(), pos.getZ()); + return axis.choose(pos.getX(), pos.getY(), pos.getZ()); } public static float getCoordinate(Vector3d vec, Axis axis) { - return (float) axis.getCoordinate(vec.x, vec.y, vec.z); + return (float) axis.choose(vec.x, vec.y, vec.z); } public static boolean onSameAxis(BlockPos pos1, BlockPos pos2, Axis axis) { @@ -176,7 +176,7 @@ public class VecHelper { public static Vector3d project(Vector3d vec, Vector3d ontoVec) { if (ontoVec.equals(Vector3d.ZERO)) return Vector3d.ZERO; - return ontoVec.scale(vec.dotProduct(ontoVec) / ontoVec.lengthSquared()); + return ontoVec.scale(vec.dot(ontoVec) / ontoVec.lengthSqr()); } @Nullable @@ -188,8 +188,8 @@ public class VecHelper { lineDirection = lineDirection.normalize(); Vector3d diff = origin.subtract(sphereCenter); - double lineDotDiff = lineDirection.dotProduct(diff); - double delta = lineDotDiff * lineDotDiff - (diff.lengthSquared() - radius * radius); + double lineDotDiff = lineDirection.dot(diff); + double delta = lineDotDiff * lineDotDiff - (diff.lengthSqr() - radius * radius); if (delta < 0) return null; double t = -lineDotDiff + MathHelper.sqrt(delta); @@ -202,52 +202,52 @@ public class VecHelper { * The (centered) location on the screen of the given 3d point in the world. * Result is (dist right of center screen, dist up from center screen, if < 0, then in front of view plane) */ - ActiveRenderInfo ari = Minecraft.getInstance().gameRenderer.getActiveRenderInfo(); - Vector3d camera_pos = ari.getProjectedView(); - Quaternion camera_rotation_conj = ari.getRotation() + ActiveRenderInfo ari = Minecraft.getInstance().gameRenderer.getMainCamera(); + Vector3d camera_pos = ari.getPosition(); + Quaternion camera_rotation_conj = ari.rotation() .copy(); - camera_rotation_conj.conjugate(); + camera_rotation_conj.conj(); Vector3f result3f = new Vector3f((float) (camera_pos.x - target.x), (float) (camera_pos.y - target.y), (float) (camera_pos.z - target.z)); - result3f.func_214905_a(camera_rotation_conj); + result3f.transform(camera_rotation_conj); // ----- compensate for view bobbing (if active) ----- // the following code adapted from GameRenderer::applyBobbing (to invert it) Minecraft mc = Minecraft.getInstance(); - if (mc.gameSettings.viewBobbing) { - Entity renderViewEntity = mc.getRenderViewEntity(); + if (mc.options.bobView) { + Entity renderViewEntity = mc.getCameraEntity(); if (renderViewEntity instanceof PlayerEntity) { PlayerEntity playerentity = (PlayerEntity) renderViewEntity; - float distwalked_modified = playerentity.distanceWalkedModified; + float distwalked_modified = playerentity.walkDist; - float f = distwalked_modified - playerentity.prevDistanceWalkedModified; + float f = distwalked_modified - playerentity.walkDistO; float f1 = -(distwalked_modified + f * partialTicks); - float f2 = MathHelper.lerp(partialTicks, playerentity.prevCameraYaw, playerentity.cameraYaw); - Quaternion q2 = new Quaternion(Vector3f.POSITIVE_X, + float f2 = MathHelper.lerp(partialTicks, playerentity.oBob, playerentity.bob); + Quaternion q2 = new Quaternion(Vector3f.XP, Math.abs(MathHelper.cos(f1 * (float) Math.PI - 0.2F) * f2) * 5.0F, true); - q2.conjugate(); - result3f.func_214905_a(q2); + q2.conj(); + result3f.transform(q2); Quaternion q1 = - new Quaternion(Vector3f.POSITIVE_Z, MathHelper.sin(f1 * (float) Math.PI) * f2 * 3.0F, true); - q1.conjugate(); - result3f.func_214905_a(q1); + new Quaternion(Vector3f.ZP, MathHelper.sin(f1 * (float) Math.PI) * f2 * 3.0F, true); + q1.conj(); + result3f.transform(q1); Vector3f bob_translation = new Vector3f((MathHelper.sin(f1 * (float) Math.PI) * f2 * 0.5F), (-Math.abs(MathHelper.cos(f1 * (float) Math.PI) * f2)), 0.0f); - bob_translation.setY(-bob_translation.getY()); // this is weird but hey, if it works + bob_translation.setY(-bob_translation.y()); // this is weird but hey, if it works result3f.add(bob_translation); } } // ----- adjust for fov ----- - float fov = (float) mc.gameRenderer.getFOVModifier(ari, partialTicks, true); + float fov = (float) mc.gameRenderer.getFov(ari, partialTicks, true); float half_height = (float) mc.getWindow() - .getScaledHeight() / 2; - float scale_factor = half_height / (result3f.getZ() * (float) Math.tan(Math.toRadians(fov / 2))); - return new Vector3d(-result3f.getX() * scale_factor, result3f.getY() * scale_factor, result3f.getZ()); + .getGuiScaledHeight() / 2; + float scale_factor = half_height / (result3f.z() * (float) Math.tan(Math.toRadians(fov / 2))); + return new Vector3d(-result3f.x() * scale_factor, result3f.y() * scale_factor, result3f.z()); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java b/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java index 31e9645ac..7b9b35e71 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java @@ -57,11 +57,11 @@ public class VoxelShaper { } public static Direction axisAsFace(Axis axis) { - return Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); + return Direction.get(AxisDirection.POSITIVE, axis); } protected static float horizontalAngleFromDirection(Direction direction) { - return (float) ((Math.max(direction.getHorizontalIndex(), 0) & 3) * 90); + return (float) ((Math.max(direction.get2DDataValue(), 0) & 3) * 90); } protected static VoxelShaper forDirectionsWithRotation(VoxelShape shape, Direction facing, @@ -79,7 +79,7 @@ public class VoxelShaper { return shape; return rotatedCopy(shape, usingValues.apply(from) - .inverse() + .reverse() .add(usingValues.apply(to))); } @@ -90,7 +90,7 @@ public class VoxelShaper { MutableObject result = new MutableObject<>(VoxelShapes.empty()); Vector3d center = new Vector3d(8, 8, 8); - shape.forEachBox((x1, y1, z1, x2, y2, z2) -> { + shape.forAllBoxes((x1, y1, z1, x2, y2, z2) -> { Vector3d v1 = new Vector3d(x1, y1, z1).scale(16) .subtract(center); Vector3d v2 = new Vector3d(x2, y2, z2).scale(16) @@ -106,7 +106,7 @@ public class VoxelShaper { v2 = VecHelper.rotate(v2, (float) rotation.z, Axis.Z) .add(center); - VoxelShape rotated = Block.makeCuboidShape(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z); + VoxelShape rotated = Block.box(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z); result.setValue(VoxelShapes.or(result.getValue(), rotated)); }); diff --git a/src/main/java/com/simibubi/create/foundation/utility/WorldHelper.java b/src/main/java/com/simibubi/create/foundation/utility/WorldHelper.java index 3cd375ea9..2f256a42b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/WorldHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/WorldHelper.java @@ -6,8 +6,8 @@ import net.minecraft.world.IWorld; public class WorldHelper { public static ResourceLocation getDimensionID(IWorld world) { - return world.getRegistryManager() - .get(Registry.DIMENSION_TYPE_KEY) - .getKey(world.getDimension()); + return world.registryAccess() + .registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY) + .getKey(world.dimensionType()); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/animation/LerpedFloat.java b/src/main/java/com/simibubi/create/foundation/utility/animation/LerpedFloat.java index 087929bb0..bd15f8dcc 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/animation/LerpedFloat.java +++ b/src/main/java/com/simibubi/create/foundation/utility/animation/LerpedFloat.java @@ -55,14 +55,14 @@ public class LerpedFloat { public boolean updateChaseSpeed(double speed) { float prevSpeed = this.chaseSpeed; this.chaseSpeed = (float) speed; - return !MathHelper.epsilonEquals(prevSpeed, speed); + return !MathHelper.equal(prevSpeed, speed); } public void tickChaser() { previousValue = value; if (chaseFunction == null) return; - if (MathHelper.epsilonEquals((double) value, chaseTarget)) { + if (MathHelper.equal((double) value, chaseTarget)) { value = chaseTarget; return; } @@ -83,7 +83,7 @@ public class LerpedFloat { } public boolean settled() { - return MathHelper.epsilonEquals((double) previousValue, value); + return MathHelper.equal((double) previousValue, value); } public float getChaseTarget() { diff --git a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockParams.java b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockParams.java index b83e7f13d..01c6ddc6c 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockParams.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockParams.java @@ -23,7 +23,7 @@ public class GhostBlockParams { } public static GhostBlockParams of(Block block) { - return of(block.getDefaultState()); + return of(block.defaultBlockState()); } public GhostBlockParams at(BlockPos pos) { 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 6878acf40..96e2b4ab3 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 @@ -53,24 +53,24 @@ public abstract class GhostBlockRenderer { private static class DefaultGhostBlockRenderer extends GhostBlockRenderer { public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { - ms.push(); + ms.pushPose(); BlockRendererDispatcher dispatcher = Minecraft.getInstance() - .getBlockRendererDispatcher(); + .getBlockRenderer(); - IBakedModel model = dispatcher.getModelForState(params.state); + IBakedModel model = dispatcher.getBlockModel(params.state); - RenderType layer = RenderTypeLookup.getEntityBlockLayer(params.state, false); + RenderType layer = RenderTypeLookup.getRenderType(params.state, false); 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, + dispatcher.getModelRenderer() + .renderModel(ms.last(), vb, params.state, model, 1f, 1f, 1f, 0xF000F0, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); - ms.pop(); + ms.popPose(); } } @@ -80,17 +80,17 @@ public abstract class GhostBlockRenderer { public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { // prepare - ms.push(); + ms.pushPose(); // RenderSystem.pushMatrix(); Minecraft mc = Minecraft.getInstance(); - BlockRendererDispatcher dispatcher = mc.getBlockRendererDispatcher(); + BlockRendererDispatcher dispatcher = mc.getBlockRenderer(); - IBakedModel model = dispatcher.getModelForState(params.state); + IBakedModel model = dispatcher.getBlockModel(params.state); // RenderType layer = RenderTypeLookup.getEntityBlockLayer(params.state); - RenderType layer = RenderType.getTranslucent(); + RenderType layer = RenderType.translucent(); IVertexBuilder vb = buffer.getEarlyBuffer(layer); BlockPos pos = params.pos; @@ -101,14 +101,14 @@ public abstract class GhostBlockRenderer { ms.translate(-.5, -.5, -.5); // 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, + renderModel(params, ms.last(), vb, params.state, model, 1f, 1f, 1f, + WorldRenderer.getLightColor(mc.level, pos), OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); // buffer.draw(); // clean // RenderSystem.popMatrix(); - ms.pop(); + ms.popPose(); } @@ -139,7 +139,7 @@ public abstract class GhostBlockRenderer { float f; float f1; float f2; - if (bakedquad.hasTintIndex()) { + if (bakedquad.isTinted()) { f = MathHelper.clamp(p_228803_2_, 0.0F, 1.0F); f1 = MathHelper.clamp(p_228803_3_, 0.0F, 1.0F); f2 = MathHelper.clamp(p_228803_4_, 0.0F, 1.0F); @@ -159,17 +159,17 @@ public abstract class GhostBlockRenderer { 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(); + int[] aint = p_227890_2_.getVertices(); + Vector3i Vector3i = p_227890_2_.getDirection() + .getNormal(); 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()); + Matrix4f matrix4f = p_227890_1_.pose(); + vector3f.transform(p_227890_1_.normal()); int vertexSize = DefaultVertexFormats.BLOCK.getIntegerSize(); int j = aint.length / vertexSize; try (MemoryStack memorystack = MemoryStack.stackPush()) { - ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getSize()); + ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getVertexSize()); IntBuffer intbuffer = bytebuffer.asIntBuffer(); for (int k = 0; k < j; ++k) { @@ -191,9 +191,9 @@ public abstract class GhostBlockRenderer { 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.applyBakedNormals(vector3f, bytebuffer, p_227890_1_.normal()); + vb.vertex(vector4f.x(), vector4f.y(), vector4f.z(), r, g, b, alpha, f9, f10, p_227890_8_, + l, vector3f.x(), vector3f.y(), vector3f.z()); } } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java index 9839b890d..6d7998c7b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java @@ -27,10 +27,10 @@ public class AABBOutline extends Outline { } public void renderBB(MatrixStack ms, SuperRenderTypeBuffer buffer, AxisAlignedBB bb) { - Vector3d projectedView = Minecraft.getInstance().gameRenderer.getActiveRenderInfo() - .getProjectedView(); + Vector3d projectedView = Minecraft.getInstance().gameRenderer.getMainCamera() + .getPosition(); boolean noCull = bb.contains(projectedView); - bb = bb.grow(noCull ? -1 / 128d : 1 / 128d); + bb = bb.inflate(noCull ? -1 / 128d : 1 / 128d); noCull |= params.disableCull; Vector3d xyz = new Vector3d(bb.minX, bb.minY, bb.minZ); diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java index 1f91f886f..d1ceb3b23 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java @@ -32,17 +32,17 @@ public class BlockClusterOutline extends Outline { @Override public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, float pt) { for (MergeEntry edge : cluster.visibleEdges) { - Vector3d start = Vector3d.of(edge.pos); - Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, edge.axis); - renderAACuboidLine(ms, buffer, start, Vector3d.of(edge.pos.offset(direction))); + Vector3d start = Vector3d.atLowerCornerOf(edge.pos); + Direction direction = Direction.get(AxisDirection.POSITIVE, edge.axis); + renderAACuboidLine(ms, buffer, start, Vector3d.atLowerCornerOf(edge.pos.relative(direction))); } for (MergeEntry face : cluster.visibleFaces.keySet()) { AxisDirection axisDirection = cluster.visibleFaces.get(face); - Direction direction = Direction.getFacingFromAxis(axisDirection, face.axis); + Direction direction = Direction.get(axisDirection, face.axis); BlockPos pos = face.pos; if (axisDirection == AxisDirection.POSITIVE) - pos = pos.offset(direction.getOpposite()); + pos = pos.relative(direction.getOpposite()); renderBlockFace(ms, buffer, pos, direction); } } @@ -57,7 +57,7 @@ public class BlockClusterOutline extends Outline { IVertexBuilder builder = buffer.getLateBuffer(translucentType); Vector3d center = VecHelper.getCenterOf(pos); - Vector3d offset = Vector3d.of(face.getDirectionVec()); + Vector3d offset = Vector3d.atLowerCornerOf(face.getNormal()); Vector3d plane = VecHelper.axisAlingedPlaneOf(offset); Axis axis = face.getAxis(); @@ -66,7 +66,7 @@ public class BlockClusterOutline extends Outline { .add(offset); int deg = face.getAxisDirection() - .getOffset() * 90; + .getStep() * 90; Vector3d a1 = plane.add(center); plane = VecHelper.rotate(plane, deg, axis); Vector3d a2 = plane.add(center); @@ -92,9 +92,9 @@ public class BlockClusterOutline extends Outline { // 6 FACES for (Axis axis : Axis.values()) { - Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); + Direction direction = Direction.get(AxisDirection.POSITIVE, axis); for (int offset : new int[] { 0, 1 }) { - MergeEntry entry = new MergeEntry(axis, pos.offset(direction, offset)); + MergeEntry entry = new MergeEntry(axis, pos.relative(direction, offset)); if (visibleFaces.remove(entry) == null) visibleFaces.put(entry, offset == 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE); } @@ -111,13 +111,13 @@ public class BlockClusterOutline extends Outline { if (axis2 == axis3) continue; - Direction direction = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis2); - Direction direction2 = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis3); + Direction direction = Direction.get(AxisDirection.POSITIVE, axis2); + Direction direction2 = Direction.get(AxisDirection.POSITIVE, axis3); for (int offset : new int[] { 0, 1 }) { - BlockPos entryPos = pos.offset(direction, offset); + BlockPos entryPos = pos.relative(direction, offset); for (int offset2 : new int[] { 0, 1 }) { - entryPos = entryPos.offset(direction2, offset2); + entryPos = entryPos.relative(direction2, offset2); MergeEntry entry = new MergeEntry(axis, entryPos); if (!visibleEdges.remove(entry)) visibleEdges.add(entry); diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java index d70ef3189..c3d2204e2 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java @@ -13,8 +13,8 @@ public class ChasingAABBOutline extends AABBOutline { public ChasingAABBOutline(AxisAlignedBB bb) { super(bb); - prevBB = bb.grow(0); - targetBB = bb.grow(0); + prevBB = bb.inflate(0); + targetBB = bb.inflate(0); } public void target(AxisAlignedBB target) { diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java index e23c179fc..009f1b7e3 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java @@ -36,15 +36,15 @@ public abstract class Outline { public void renderCuboidLine(MatrixStack ms, SuperRenderTypeBuffer buffer, Vector3d start, Vector3d end) { Vector3d diff = end.subtract(start); float hAngle = AngleHelper.deg(MathHelper.atan2(diff.x, diff.z)); - float hDistance = (float) diff.mul(1, 0, 1) + float hDistance = (float) diff.multiply(1, 0, 1) .length(); float vAngle = AngleHelper.deg(MathHelper.atan2(hDistance, diff.y)) - 90; - ms.push(); + ms.pushPose(); MatrixStacker.of(ms) .translate(start) .rotateY(hAngle).rotateX(vAngle); renderAACuboidLine(ms, buffer, Vector3d.ZERO, new Vector3d(0, 0, diff.length())); - ms.pop(); + ms.popPose(); } public void renderAACuboidLine(MatrixStack ms, SuperRenderTypeBuffer buffer, Vector3d start, Vector3d end) { @@ -65,7 +65,7 @@ public abstract class Outline { Vector3d extension = diff.normalize() .scale(lineWidth / 2); Vector3d plane = VecHelper.axisAlingedPlaneOf(diff); - Direction face = Direction.getFacingFromVector(diff.x, diff.y, diff.z); + Direction face = Direction.getNearest(diff.x, diff.y, diff.z); Axis axis = face.getAxis(); start = start.subtract(extension); @@ -98,16 +98,16 @@ public abstract class Outline { putQuad(ms, builder, b4, b3, b2, b1, face); putQuad(ms, builder, a1, a2, a3, a4, face.getOpposite()); Vector3d vec = a1.subtract(a4); - face = Direction.getFacingFromVector(vec.x, vec.y, vec.z); + face = Direction.getNearest(vec.x, vec.y, vec.z); putQuad(ms, builder, a1, b1, b2, a2, face); vec = VecHelper.rotate(vec, -90, axis); - face = Direction.getFacingFromVector(vec.x, vec.y, vec.z); + face = Direction.getNearest(vec.x, vec.y, vec.z); putQuad(ms, builder, a2, b2, b3, a3, face); vec = VecHelper.rotate(vec, -90, axis); - face = Direction.getFacingFromVector(vec.x, vec.y, vec.z); + face = Direction.getNearest(vec.x, vec.y, vec.z); putQuad(ms, builder, a3, b3, b4, a4, face); vec = VecHelper.rotate(vec, -90, axis); - face = Direction.getFacingFromVector(vec.x, vec.y, vec.z); + face = Direction.getNearest(vec.x, vec.y, vec.z); putQuad(ms, builder, a4, b4, b1, a1, face); } @@ -128,27 +128,27 @@ public abstract class Outline { int i = 15 << 20 | 15 << 4; int j = i >> 16 & '\uffff'; int k = i & '\uffff'; - Entry peek = ms.peek(); + Entry peek = ms.last(); Vector3d rgb = params.rgb; if (transformNormals == null) - transformNormals = peek.getNormal(); + transformNormals = peek.normal(); int xOffset = 0; int yOffset = 0; int zOffset = 0; if (normal != null) { - xOffset = normal.getXOffset(); - yOffset = normal.getYOffset(); - zOffset = normal.getZOffset(); + xOffset = normal.getStepX(); + yOffset = normal.getStepY(); + zOffset = normal.getStepZ(); } - builder.vertex(peek.getModel(), (float) pos.x, (float) pos.y, (float) pos.z) + builder.vertex(peek.pose(), (float) pos.x, (float) pos.y, (float) pos.z) .color((float) rgb.x, (float) rgb.y, (float) rgb.z, params.alpha) - .texture(u, v) - .overlay(OverlayTexture.DEFAULT_UV) - .light(j, k) - .normal(peek.getNormal(), xOffset, yOffset, zOffset) + .uv(u, v) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(j, k) + .normal(peek.normal(), xOffset, yOffset, zOffset) .endVertex(); transformNormals = null; diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java b/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java index 2b3403f0f..63ec2aace 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java @@ -65,7 +65,7 @@ public interface IPlacementHelper { PlacementOffset offset = getOffset(player, world, state, pos, ray); if (heldItem.getItem() instanceof BlockItem) { BlockItem blockItem = (BlockItem) heldItem.getItem(); - offset = offset.withGhostState(blockItem.getBlock().getDefaultState()); + offset = offset.withGhostState(blockItem.getBlock().defaultBlockState()); } return offset; } @@ -89,11 +89,11 @@ public interface IPlacementHelper { } static void renderArrow(Vector3d center, Vector3d target, Direction arrowPlane, double distanceFromCenter) { Vector3d direction = target.subtract(center).normalize(); - Vector3d facing = Vector3d.of(arrowPlane.getDirectionVec()); + Vector3d facing = Vector3d.atLowerCornerOf(arrowPlane.getNormal()); Vector3d start = center.add(direction); Vector3d offset = direction.scale(distanceFromCenter - 1); - Vector3d offsetA = direction.crossProduct(facing).normalize().scale(.25); - Vector3d offsetB = facing.crossProduct(direction).normalize().scale(.25); + Vector3d offsetA = direction.cross(facing).normalize().scale(.25); + Vector3d offsetB = facing.cross(direction).normalize().scale(.25); Vector3d endA = center.add(direction.scale(.75)).add(offsetA); Vector3d endB = center.add(direction.scale(.75)).add(offsetB); CreateClient.OUTLINER.showLine("placementArrowA" + center + target, start.add(offset), endA.add(offset)).lineWidth(1 / 16f); @@ -141,7 +141,7 @@ public interface IPlacementHelper { Vector3d centerToHit = hit.subtract(VecHelper.getCenterOf(pos)); return Arrays.stream(Iterate.directions) .filter(includeDirection) - .map(dir -> Pair.of(dir, Vector3d.of(dir.getDirectionVec()).distanceTo(centerToHit))) + .map(dir -> Pair.of(dir, Vector3d.atLowerCornerOf(dir.getNormal()).distanceTo(centerToHit))) .sorted(Comparator.comparingDouble(Pair::getSecond)) .map(Pair::getFirst) .collect(Collectors.toList()); 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 09f98b72f..1bb88d18d 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 @@ -78,30 +78,30 @@ public class PlacementHelpers { @OnlyIn(Dist.CLIENT) private static void checkHelpers() { Minecraft mc = Minecraft.getInstance(); - ClientWorld world = mc.world; + ClientWorld world = mc.level; if (world == null) return; - if (!(mc.objectMouseOver instanceof BlockRayTraceResult)) + if (!(mc.hitResult instanceof BlockRayTraceResult)) return; - BlockRayTraceResult ray = (BlockRayTraceResult) mc.objectMouseOver; + BlockRayTraceResult ray = (BlockRayTraceResult) mc.hitResult; if (mc.player == null) return; - if (mc.player.isSneaking())//for now, disable all helpers when sneaking TODO add helpers that respect sneaking but still show position + if (mc.player.isShiftKeyDown())//for now, disable all helpers when sneaking TODO add helpers that respect sneaking but still show position return; for (Hand hand : Hand.values()) { - ItemStack heldItem = mc.player.getHeldItem(hand); + ItemStack heldItem = mc.player.getItemInHand(hand); List filteredForHeldItem = helpers.stream().filter(helper -> helper.matchesItem(heldItem)).collect(Collectors.toList()); if (filteredForHeldItem.isEmpty()) continue; - BlockPos pos = ray.getPos(); + BlockPos pos = ray.getBlockPos(); BlockState state = world.getBlockState(pos); List filteredForState = filteredForHeldItem.stream().filter(helper -> helper.matchesState(state)).collect(Collectors.toList()); @@ -155,8 +155,8 @@ public class PlacementHelpers { if (player != null && animationTick > 0) { MainWindow res = event.getWindow(); - float screenY = res.getScaledHeight() / 2f; - float screenX = res.getScaledWidth() / 2f; + float screenY = res.getGuiScaledHeight() / 2f; + float screenX = res.getGuiScaledWidth() / 2f; float progress = getCurrentAlpha(); drawDirectionIndicator(event.getMatrixStack(), event.getPartialTicks(), screenX, screenY, progress); @@ -178,12 +178,12 @@ public class PlacementHelpers { Vector3d target = new Vector3d(projTarget.x, projTarget.y, 0); if (projTarget.z > 0) { - target = target.inverse(); + target = target.reverse(); } Vector3d norm = target.normalize(); Vector3d ref = new Vector3d(0, 1, 0); - float targetAngle = AngleHelper.deg(Math.acos(norm.dotProduct(ref))); + float targetAngle = AngleHelper.deg(Math.acos(norm.dot(ref))); angle.withSpeed(0.25f); @@ -210,7 +210,7 @@ public class PlacementHelpers { } private static void fadedArrow(MatrixStack ms, float centerX, float centerY, float r, float g, float b, float a, float length, float snappedAngle) { - ms.push(); + ms.pushPose(); RenderSystem.disableTexture(); RenderSystem.enableBlend(); RenderSystem.disableAlphaTest(); @@ -218,16 +218,16 @@ public class PlacementHelpers { RenderSystem.shadeModel(GL11.GL_SMOOTH); ms.translate(centerX, centerY, 0); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(angle.get(0))); + ms.mulPose(Vector3f.ZP.rotationDegrees(angle.get(0))); //RenderSystem.rotatef(snappedAngle, 0, 0, 1); double scale = AllConfigs.CLIENT.indicatorScale.get(); RenderSystem.scaled(scale, scale, 1); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); + BufferBuilder bufferbuilder = tessellator.getBuilder(); bufferbuilder.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION_COLOR); - Matrix4f mat = ms.peek().getModel(); + Matrix4f mat = ms.last().pose(); bufferbuilder.vertex(mat, 0, - (10 + length), 0).color(r, g, b, a).endVertex(); @@ -239,16 +239,16 @@ public class PlacementHelpers { bufferbuilder.vertex(mat, 6, -6, 0).color(r, g, b, 0f).endVertex(); bufferbuilder.vertex(mat, 9, -3, 0).color(r, g, b, 0f).endVertex(); - tessellator.draw(); + tessellator.end(); RenderSystem.shadeModel(GL11.GL_FLAT); RenderSystem.disableBlend(); RenderSystem.enableAlphaTest(); RenderSystem.enableTexture(); - ms.pop(); + ms.popPose(); } private static void textured(MatrixStack ms, float centerX, float centerY, float alpha, float snappedAngle) { - ms.push(); + ms.pushPose(); RenderSystem.enableTexture(); AllGuiTextures.PLACEMENT_INDICATOR_SHEET.bind(); RenderSystem.enableBlend(); @@ -270,20 +270,20 @@ public class PlacementHelpers { float th = tex_size; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder buffer = tessellator.getBuffer(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEXTURE); + BufferBuilder buffer = tessellator.getBuilder(); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX); - Matrix4f mat = ms.peek().getModel(); - buffer.vertex(mat, -1, -1, 0).color(1f, 1f, 1f, alpha).texture(tx, ty).endVertex(); - buffer.vertex(mat, -1, 1, 0).color(1f, 1f, 1f, alpha).texture(tx, ty + th).endVertex(); - buffer.vertex(mat, 1, 1, 0).color(1f, 1f, 1f, alpha).texture(tx + tw, ty + th).endVertex(); - buffer.vertex(mat, 1, -1, 0).color(1f, 1f, 1f, alpha).texture(tx + tw, ty).endVertex(); + Matrix4f mat = ms.last().pose(); + buffer.vertex(mat, -1, -1, 0).color(1f, 1f, 1f, alpha).uv(tx, ty).endVertex(); + buffer.vertex(mat, -1, 1, 0).color(1f, 1f, 1f, alpha).uv(tx, ty + th).endVertex(); + buffer.vertex(mat, 1, 1, 0).color(1f, 1f, 1f, alpha).uv(tx + tw, ty + th).endVertex(); + buffer.vertex(mat, 1, -1, 0).color(1f, 1f, 1f, alpha).uv(tx + tw, ty).endVertex(); - tessellator.draw(); + tessellator.end(); RenderSystem.shadeModel(GL11.GL_FLAT); RenderSystem.disableBlend(); - ms.pop(); + ms.popPose(); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java index aebe09f8c..4ab7ef08f 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java @@ -108,23 +108,23 @@ public class PlacementOffset { if (!isReplaceable(world)) return ActionResultType.PASS; - if (world.isRemote) + if (world.isClientSide) return ActionResultType.SUCCESS; ItemUseContext context = new ItemUseContext(player, hand, ray); BlockPos newPos = new BlockPos(pos); - if (!world.isBlockModifiable(player, newPos)) + if (!world.mayInteract(player, newPos)) return ActionResultType.PASS; - BlockState state = stateTransform.apply(blockItem.getBlock().getDefaultState()); - if (state.contains(BlockStateProperties.WATERLOGGED)) { + BlockState state = stateTransform.apply(blockItem.getBlock().defaultBlockState()); + if (state.hasProperty(BlockStateProperties.WATERLOGGED)) { FluidState fluidState = world.getFluidState(newPos); - state = state.with(BlockStateProperties.WATERLOGGED, fluidState.getFluid() == Fluids.WATER); + state = state.setValue(BlockStateProperties.WATERLOGGED, fluidState.getType() == Fluids.WATER); } - BlockSnapshot snapshot = BlockSnapshot.create(world.getRegistryKey(), world, newPos); - world.setBlockState(newPos, state); + BlockSnapshot snapshot = BlockSnapshot.create(world.dimension(), world, newPos); + world.setBlockAndUpdate(newPos, state); BlockEvent.EntityPlaceEvent event = new BlockEvent.EntityPlaceEvent(snapshot, IPlacementHelper.ID, player); if (MinecraftForge.EVENT_BUS.post(event)) { @@ -136,13 +136,13 @@ public class PlacementOffset { SoundType soundtype = newState.getSoundType(world, newPos, player); world.playSound(null, newPos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); - player.addStat(Stats.ITEM_USED.get(blockItem)); + player.awardStat(Stats.ITEM_USED.get(blockItem)); if (player instanceof ServerPlayerEntity) - CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) player, newPos, context.getItem()); + CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) player, newPos, context.getItemInHand()); if (!player.isCreative()) - context.getItem().shrink(1); + context.getItemInHand().shrink(1); return ActionResultType.SUCCESS; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/util/PoleHelper.java b/src/main/java/com/simibubi/create/foundation/utility/placement/util/PoleHelper.java index f362531d3..8488daf3a 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/util/PoleHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/util/PoleHelper.java @@ -41,12 +41,12 @@ public abstract class PoleHelper> implements IPlacementH } public int attachedPoles(World world, BlockPos pos, Direction direction) { - BlockPos checkPos = pos.offset(direction); + BlockPos checkPos = pos.relative(direction); BlockState state = world.getBlockState(checkPos); int count = 0; while (matchesAxis(state, direction.getAxis())) { count++; - checkPos = checkPos.offset(direction); + checkPos = checkPos.relative(direction); state = world.getBlockState(checkPos); } return count; @@ -59,7 +59,7 @@ public abstract class PoleHelper> implements IPlacementH @Override public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { - List directions = IPlacementHelper.orderedByDistance(pos, ray.getHitVec(), dir -> dir.getAxis() == axisFunction.apply(state)); + List directions = IPlacementHelper.orderedByDistance(pos, ray.getLocation(), dir -> dir.getAxis() == axisFunction.apply(state)); for (Direction dir : directions) { int range = AllConfigs.SERVER.curiosities.placementAssistRange.get(); if (player != null) { @@ -71,11 +71,11 @@ public abstract class PoleHelper> implements IPlacementH if (poles >= range) continue; - BlockPos newPos = pos.offset(dir, poles + 1); + BlockPos newPos = pos.relative(dir, poles + 1); BlockState newState = world.getBlockState(newPos); if (newState.getMaterial().isReplaceable()) - return PlacementOffset.success(newPos, bState -> bState.with(property, state.get(property))); + return PlacementOffset.success(newPos, bState -> bState.setValue(property, state.getValue(property))); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeConditions.java b/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeConditions.java index 901ca5dc6..95123ff19 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeConditions.java +++ b/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeConditions.java @@ -31,7 +31,7 @@ public class RecipeConditions { } public static Predicate> outputMatchesFilter(FilteringBehaviour filtering) { - return r -> filtering.test(r.getRecipeOutput()); + return r -> filtering.test(r.getResultItem()); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationServerWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationServerWorld.java index 60b82a4e5..18ce49c0c 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationServerWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationServerWorld.java @@ -21,23 +21,23 @@ public class PlacementSimulationServerWorld extends WrappedServerWorld { } @Override - public boolean setBlockState(BlockPos pos, BlockState newState, int flags) { - blocksAdded.put(pos.toImmutable(), newState); + public boolean setBlock(BlockPos pos, BlockState newState, int flags) { + blocksAdded.put(pos.immutable(), newState); return true; } @Override - public boolean setBlockState(BlockPos pos, BlockState state) { - return setBlockState(pos, state, 0); + public boolean setBlockAndUpdate(BlockPos pos, BlockState state) { + return setBlock(pos, state, 0); } @Override - public boolean hasBlockState(BlockPos pos, Predicate condition) { + public boolean isStateAtPosition(BlockPos pos, Predicate condition) { return condition.test(getBlockState(pos)); } @Override - public boolean isBlockPresent(BlockPos pos) { + public boolean isLoaded(BlockPos pos) { return true; } @@ -50,7 +50,7 @@ public class PlacementSimulationServerWorld extends WrappedServerWorld { public BlockState getBlockState(BlockPos pos) { if (blocksAdded.containsKey(pos)) return blocksAdded.get(pos); - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java index e0f1c9806..57a1462b6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java @@ -40,7 +40,7 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW } @Override - public WorldLightManager getLightingProvider() { + public WorldLightManager getLightEngine() { return lighter; } @@ -50,14 +50,14 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW BlockState state = entry.getValue(); int light = state.getLightValue(this, pos); if (light > 0) { - lighter.func_215573_a(pos, light); + lighter.onBlockEmissionIncrease(pos, light); } } } public void setTileEntities(Collection tileEntities) { tesAdded.clear(); - tileEntities.forEach(te -> tesAdded.put(te.getPos(), te)); + tileEntities.forEach(te -> tesAdded.put(te.getBlockPos(), te)); } public void clear() { @@ -65,10 +65,10 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW } @Override - public boolean setBlockState(BlockPos pos, BlockState newState, int flags) { + public boolean setBlock(BlockPos pos, BlockState newState, int flags) { blocksAdded.put(pos, newState); - SectionPos sectionPos = SectionPos.from(pos); + SectionPos sectionPos = SectionPos.of(pos); if (spannedSections.add(sectionPos)) { lighter.updateSectionStatus(sectionPos, false); } @@ -81,22 +81,22 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW } @Override - public boolean setBlockState(BlockPos pos, BlockState state) { - return setBlockState(pos, state, 0); + public boolean setBlockAndUpdate(BlockPos pos, BlockState state) { + return setBlock(pos, state, 0); } @Override - public TileEntity getTileEntity(BlockPos pos) { + public TileEntity getBlockEntity(BlockPos pos) { return tesAdded.get(pos); } @Override - public boolean hasBlockState(BlockPos pos, Predicate condition) { + public boolean isStateAtPosition(BlockPos pos, Predicate condition) { return condition.test(getBlockState(pos)); } @Override - public boolean isBlockPresent(BlockPos pos) { + public boolean isLoaded(BlockPos pos) { return true; } @@ -106,7 +106,7 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW } public BlockState getBlockState(int x, int y, int z) { - return getBlockState(scratch.setPos(x, y, z)); + return getBlockState(scratch.set(x, y, z)); } @Override @@ -114,6 +114,6 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW BlockState state = blocksAdded.get(pos); if (state != null) return state; - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/RayTraceWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/RayTraceWorld.java index 3a15cc1e7..eb608d262 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/RayTraceWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/RayTraceWorld.java @@ -20,8 +20,8 @@ public class RayTraceWorld implements IBlockReader { } @Override - public TileEntity getTileEntity(BlockPos pos) { - return template.getTileEntity(pos); + public TileEntity getBlockEntity(BlockPos pos) { + return template.getBlockEntity(pos); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java index dbc75fcfd..7d68691b1 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java @@ -38,12 +38,12 @@ public class WrappedChunkProvider extends AbstractChunkProvider { @Nullable @Override - public IBlockReader getChunkForLight(int x, int z) { + public IBlockReader getChunkForLighting(int x, int z) { return getChunk(x, z); } @Override - public IBlockReader getWorld() { + public IBlockReader getLevel() { return world; } @@ -63,12 +63,12 @@ public class WrappedChunkProvider extends AbstractChunkProvider { } @Override - public String makeString() { + public String gatherStats() { return "WrappedChunkProvider"; } @Override - public WorldLightManager getLightManager() { - return world.getLightingProvider(); + public WorldLightManager getLightEngine() { + return world.getLightEngine(); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedClientWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedClientWorld.java index f72f2b771..4e497fdc7 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedClientWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedClientWorld.java @@ -38,7 +38,7 @@ public class WrappedClientWorld extends ClientWorld { protected World world; private WrappedClientWorld(World world) { - super(mc.getConnection(), mc.world.getWorldInfo(), world.getRegistryKey(), world.getDimension(), mc.getConnection().viewDistance, world.getProfilerSupplier(), mc.worldRenderer, world.isDebugWorld(), world.getBiomeAccess().seed); + super(mc.getConnection(), mc.level.getLevelData(), world.dimension(), world.dimensionType(), mc.getConnection().serverChunkRadius, world.getProfilerSupplier(), mc.levelRenderer, world.isDebug(), world.getBiomeManager().biomeZoomSeed); this.world = world; } @@ -47,13 +47,13 @@ public class WrappedClientWorld extends ClientWorld { } @Override - public boolean isBlockLoaded(BlockPos pos) { - return world.isBlockLoaded(pos); + public boolean hasChunkAt(BlockPos pos) { + return world.hasChunkAt(pos); } @Override - public boolean isBlockPresent(BlockPos pos) { - return world.isBlockPresent(pos); + public boolean isLoaded(BlockPos pos) { + return world.isLoaded(pos); } @Override @@ -75,13 +75,13 @@ public class WrappedClientWorld extends ClientWorld { @Override - public int getLightLevel(LightType type, BlockPos pos) { - return world.getLightLevel(type, pos); + public int getBrightness(LightType type, BlockPos pos) { + return world.getBrightness(type, pos); } @Override - public int getLightValue(BlockPos pos) { - return world.getLightValue(pos); + public int getLightEmission(BlockPos pos) { + return world.getLightEmission(pos); } @Override @@ -91,13 +91,13 @@ public class WrappedClientWorld extends ClientWorld { @Nullable @Override - public T getClosestEntity(List p_217361_1_, EntityPredicate p_217361_2_, @Nullable LivingEntity p_217361_3_, double p_217361_4_, double p_217361_6_, double p_217361_8_) { - return world.getClosestEntity(p_217361_1_, p_217361_2_, p_217361_3_, p_217361_4_, p_217361_6_, p_217361_8_); + public T getNearestEntity(List p_217361_1_, EntityPredicate p_217361_2_, @Nullable LivingEntity p_217361_3_, double p_217361_4_, double p_217361_6_, double p_217361_8_) { + return world.getNearestEntity(p_217361_1_, p_217361_2_, p_217361_3_, p_217361_4_, p_217361_6_, p_217361_8_); } @Override - public int getColor(BlockPos p_225525_1_, ColorResolver p_225525_2_) { - return world.getColor(p_225525_1_, p_225525_2_); + public int getBlockTint(BlockPos p_225525_1_, ColorResolver p_225525_2_) { + return world.getBlockTint(p_225525_1_, p_225525_2_); } // FIXME: Emissive Lighting might not light stuff properly @@ -114,18 +114,18 @@ public class WrappedClientWorld extends ClientWorld { } @Override - public void addOptionalParticle(IParticleData p_195589_1_, double p_195589_2_, double p_195589_4_, double p_195589_6_, double p_195589_8_, double p_195589_10_, double p_195589_12_) { - world.addOptionalParticle(p_195589_1_, p_195589_2_, p_195589_4_, p_195589_6_, p_195589_8_, p_195589_10_, p_195589_12_); + public void addAlwaysVisibleParticle(IParticleData p_195589_1_, double p_195589_2_, double p_195589_4_, double p_195589_6_, double p_195589_8_, double p_195589_10_, double p_195589_12_) { + world.addAlwaysVisibleParticle(p_195589_1_, p_195589_2_, p_195589_4_, p_195589_6_, p_195589_8_, p_195589_10_, p_195589_12_); } @Override - public void addOptionalParticle(IParticleData p_217404_1_, boolean p_217404_2_, double p_217404_3_, double p_217404_5_, double p_217404_7_, double p_217404_9_, double p_217404_11_, double p_217404_13_) { - world.addOptionalParticle(p_217404_1_, p_217404_2_, p_217404_3_, p_217404_5_, p_217404_7_, p_217404_9_, p_217404_11_, p_217404_13_); + public void addAlwaysVisibleParticle(IParticleData p_217404_1_, boolean p_217404_2_, double p_217404_3_, double p_217404_5_, double p_217404_7_, double p_217404_9_, double p_217404_11_, double p_217404_13_) { + world.addAlwaysVisibleParticle(p_217404_1_, p_217404_2_, p_217404_3_, p_217404_5_, p_217404_7_, p_217404_9_, p_217404_11_, p_217404_13_); } @Override - public void playSound(double p_184134_1_, double p_184134_3_, double p_184134_5_, SoundEvent p_184134_7_, SoundCategory p_184134_8_, float p_184134_9_, float p_184134_10_, boolean p_184134_11_) { - world.playSound(p_184134_1_, p_184134_3_, p_184134_5_, p_184134_7_,p_184134_8_, p_184134_9_, p_184134_10_, p_184134_11_); + public void playLocalSound(double p_184134_1_, double p_184134_3_, double p_184134_5_, SoundEvent p_184134_7_, SoundCategory p_184134_8_, float p_184134_9_, float p_184134_10_, boolean p_184134_11_) { + world.playLocalSound(p_184134_1_, p_184134_3_, p_184134_5_, p_184134_7_,p_184134_8_, p_184134_9_, p_184134_10_, p_184134_11_); } @Override @@ -135,8 +135,8 @@ public class WrappedClientWorld extends ClientWorld { @Nullable @Override - public TileEntity getTileEntity(BlockPos p_175625_1_) { - return world.getTileEntity(p_175625_1_); + public TileEntity getBlockEntity(BlockPos p_175625_1_) { + return world.getBlockEntity(p_175625_1_); } public World getWrappedWorld() { return world; diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java index ec967e3d7..1ee80a641 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java @@ -37,48 +37,48 @@ public class WrappedServerWorld extends ServerWorld { protected World world; public WrappedServerWorld(World world) { - // Replace null with world.getChunkProvider().chunkManager.field_219266_t ? We had null in 1.15 - super(world.getServer(), Util.getServerExecutor(), getLevelSaveFromWorld(world), (IServerWorldInfo) world.getWorldInfo(), world.getRegistryKey(), world.getDimension(), null, ((ServerChunkProvider) world.getChunkProvider()).getChunkGenerator(), world.isDebugWorld(), world.getBiomeAccess().seed, Collections.EMPTY_LIST, false); //, world.field_25143); + // Replace null with world.getChunkProvider().chunkManager.progressListener ? We had null in 1.15 + super(world.getServer(), Util.backgroundExecutor(), getLevelSaveFromWorld(world), (IServerWorldInfo) world.getLevelData(), world.dimension(), world.dimensionType(), null, ((ServerChunkProvider) world.getChunkSource()).getGenerator(), world.isDebug(), world.getBiomeManager().biomeZoomSeed, Collections.EMPTY_LIST, false); //, world.field_25143); this.world = world; } @Override - public float getCelestialAngleRadians(float p_72826_1_) { + public float getSunAngle(float p_72826_1_) { return 0; } - + @Override - public int getLight(BlockPos pos) { + public int getMaxLocalRawBrightness(BlockPos pos) { return 15; } @Override - public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { - world.notifyBlockUpdate(pos, oldState, newState, flags); + public void sendBlockUpdated(BlockPos pos, BlockState oldState, BlockState newState, int flags) { + world.sendBlockUpdated(pos, oldState, newState, flags); } @Override - public ServerTickList getPendingBlockTicks() { - ITickList tl = world.getPendingBlockTicks(); + public ServerTickList getBlockTicks() { + ITickList tl = world.getBlockTicks(); if (tl instanceof ServerTickList) return (ServerTickList) tl; - return super.getPendingBlockTicks(); + return super.getBlockTicks(); } @Override - public ServerTickList getPendingFluidTicks() { - ITickList tl = world.getPendingFluidTicks(); + public ServerTickList getLiquidTicks() { + ITickList tl = world.getLiquidTicks(); if (tl instanceof ServerTickList) return (ServerTickList) tl; - return super.getPendingFluidTicks(); + return super.getLiquidTicks(); } @Override - public void playEvent(PlayerEntity player, int type, BlockPos pos, int data) { + public void levelEvent(PlayerEntity player, int type, BlockPos pos, int data) { } @Override - public List getPlayers() { + public List players() { return Collections.emptyList(); } @@ -88,12 +88,12 @@ public class WrappedServerWorld extends ServerWorld { } @Override - public void playMovingSound(PlayerEntity p_217384_1_, Entity p_217384_2_, SoundEvent p_217384_3_, + public void playSound(PlayerEntity p_217384_1_, Entity p_217384_2_, SoundEvent p_217384_3_, SoundCategory p_217384_4_, float p_217384_5_, float p_217384_6_) { } @Override - public Entity getEntityByID(int id) { + public Entity getEntity(int id) { return null; } @@ -103,22 +103,22 @@ public class WrappedServerWorld extends ServerWorld { } @Override - public boolean addEntity(Entity entityIn) { - entityIn.setWorld(world); - return world.addEntity(entityIn); + public boolean addFreshEntity(Entity entityIn) { + entityIn.setLevel(world); + return world.addFreshEntity(entityIn); } @Override - public void registerMapData(MapData mapDataIn) { + public void setMapData(MapData mapDataIn) { } @Override - public int getNextMapId() { + public int getFreeMapId() { return 0; } @Override - public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) { + public void destroyBlockProgress(int breakerId, BlockPos pos, int progress) { } @Override @@ -127,16 +127,16 @@ public class WrappedServerWorld extends ServerWorld { } @Override - public ITagCollectionSupplier getTags() { - return world.getTags(); + public ITagCollectionSupplier getTagManager() { + return world.getTagManager(); } @Override - public Biome getGeneratorStoredBiome(int p_225604_1_, int p_225604_2_, int p_225604_3_) { - return world.getGeneratorStoredBiome(p_225604_1_, p_225604_2_, p_225604_3_); + public Biome getUncachedNoiseBiome(int p_225604_1_, int p_225604_2_, int p_225604_3_) { + return world.getUncachedNoiseBiome(p_225604_1_, p_225604_2_, p_225604_3_); } private static SaveFormat.LevelSave getLevelSaveFromWorld(World world) { - return ObfuscationReflectionHelper.getPrivateValue(MinecraftServer.class, world.getServer(), "field_71310_m"); + return ObfuscationReflectionHelper.getPrivateValue(MinecraftServer.class, world.getServer(), "storageSource"); // storageSource } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java index 634da56bd..46b8cdcf6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java @@ -38,8 +38,8 @@ public class WrappedWorld extends World { protected AbstractChunkProvider provider; public WrappedWorld(World world, AbstractChunkProvider provider) { - super((ISpawnWorldInfo) world.getWorldInfo(), world.getRegistryKey(), world.getDimension(), world::getProfiler, - world.isRemote, world.isDebugWorld(), 0); + super((ISpawnWorldInfo) world.getLevelData(), world.dimension(), world.dimensionType(), world::getProfiler, + world.isClientSide, world.isDebug(), 0); this.world = world; this.provider = provider; } @@ -48,13 +48,13 @@ public class WrappedWorld extends World { this(world, null); } - public World getWorld() { + public World getLevel() { return world; } @Override - public WorldLightManager getLightingProvider() { - return world.getLightingProvider(); + public WorldLightManager getLightEngine() { + return world.getLightEngine(); } @Override @@ -63,50 +63,50 @@ public class WrappedWorld extends World { } @Override - public boolean hasBlockState(@Nullable BlockPos p_217375_1_, @Nullable Predicate p_217375_2_) { - return world.hasBlockState(p_217375_1_, p_217375_2_); + public boolean isStateAtPosition(@Nullable BlockPos p_217375_1_, @Nullable Predicate p_217375_2_) { + return world.isStateAtPosition(p_217375_1_, p_217375_2_); } @Override - public TileEntity getTileEntity(@Nullable BlockPos pos) { - return world.getTileEntity(pos); + public TileEntity getBlockEntity(@Nullable BlockPos pos) { + return world.getBlockEntity(pos); } @Override - public boolean setBlockState(@Nullable BlockPos pos, @Nullable BlockState newState, int flags) { - return world.setBlockState(pos, newState, flags); + public boolean setBlock(@Nullable BlockPos pos, @Nullable BlockState newState, int flags) { + return world.setBlock(pos, newState, flags); } @Override - public int getLight(BlockPos pos) { + public int getMaxLocalRawBrightness(BlockPos pos) { return 15; } @Override - public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { - world.notifyBlockUpdate(pos, oldState, newState, flags); + public void sendBlockUpdated(BlockPos pos, BlockState oldState, BlockState newState, int flags) { + world.sendBlockUpdated(pos, oldState, newState, flags); } @Override - public ITickList getPendingBlockTicks() { - return world.getPendingBlockTicks(); + public ITickList getBlockTicks() { + return world.getBlockTicks(); } @Override - public ITickList getPendingFluidTicks() { - return world.getPendingFluidTicks(); + public ITickList getLiquidTicks() { + return world.getLiquidTicks(); } @Override - public AbstractChunkProvider getChunkProvider() { + public AbstractChunkProvider getChunkSource() { return provider; } @Override - public void playEvent(@Nullable PlayerEntity player, int type, BlockPos pos, int data) {} + public void levelEvent(@Nullable PlayerEntity player, int type, BlockPos pos, int data) {} @Override - public List getPlayers() { + public List players() { return Collections.emptyList(); } @@ -115,11 +115,11 @@ public class WrappedWorld extends World { SoundCategory category, float volume, float pitch) {} @Override - public void playMovingSound(@Nullable PlayerEntity p_217384_1_, Entity p_217384_2_, SoundEvent p_217384_3_, + public void playSound(@Nullable PlayerEntity p_217384_1_, Entity p_217384_2_, SoundEvent p_217384_3_, SoundCategory p_217384_4_, float p_217384_5_, float p_217384_6_) {} @Override - public Entity getEntityByID(int id) { + public Entity getEntity(int id) { return null; } @@ -129,23 +129,23 @@ public class WrappedWorld extends World { } @Override - public boolean addEntity(@Nullable Entity entityIn) { + public boolean addFreshEntity(@Nullable Entity entityIn) { if (entityIn == null) return false; - entityIn.setWorld(world); - return world.addEntity(entityIn); + entityIn.setLevel(world); + return world.addFreshEntity(entityIn); } @Override - public void registerMapData(MapData mapDataIn) {} + public void setMapData(MapData mapDataIn) {} @Override - public int getNextMapId() { - return world.getNextMapId(); + public int getFreeMapId() { + return world.getFreeMapId(); } @Override - public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {} + public void destroyBlockProgress(int breakerId, BlockPos pos, int progress) {} @Override public Scoreboard getScoreboard() { @@ -158,36 +158,36 @@ public class WrappedWorld extends World { } @Override - public ITagCollectionSupplier getTags() { - return world.getTags(); + public ITagCollectionSupplier getTagManager() { + return world.getTagManager(); } @Override - public Biome getGeneratorStoredBiome(int p_225604_1_, int p_225604_2_, int p_225604_3_) { - return world.getGeneratorStoredBiome(p_225604_1_, p_225604_2_, p_225604_3_); + public Biome getUncachedNoiseBiome(int p_225604_1_, int p_225604_2_, int p_225604_3_) { + return world.getUncachedNoiseBiome(p_225604_1_, p_225604_2_, p_225604_3_); } @Override - public DynamicRegistries getRegistryManager() { - return world.getRegistryManager(); + public DynamicRegistries registryAccess() { + return world.registryAccess(); } @Override - public float getBrightness(Direction p_230487_1_, boolean p_230487_2_) { - return world.getBrightness(p_230487_1_, p_230487_2_); + public float getShade(Direction p_230487_1_, boolean p_230487_2_) { + return world.getShade(p_230487_1_, p_230487_2_); } @Override - public void markChunkDirty(BlockPos p_175646_1_, TileEntity p_175646_2_) { + public void blockEntityChanged(BlockPos p_175646_1_, TileEntity p_175646_2_) { } @Override - public boolean isBlockLoaded(BlockPos p_175667_1_) { + public boolean hasChunkAt(BlockPos p_175667_1_) { return true; } @Override - public void updateComparatorOutputLevel(BlockPos p_175666_1_, Block p_175666_2_) { + public void updateNeighbourForOutputSignal(BlockPos p_175666_1_, Block p_175666_2_) { return; } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java index 7543375f2..e5a963e2b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java @@ -24,7 +24,7 @@ public class EmptierChunk extends Chunk { } public BlockState getBlockState(BlockPos p_180495_1_) { - return Blocks.VOID_AIR.getDefaultState(); + return Blocks.VOID_AIR.defaultBlockState(); } @Nullable @@ -33,15 +33,15 @@ public class EmptierChunk extends Chunk { } public FluidState getFluidState(BlockPos p_204610_1_) { - return Fluids.EMPTY.getDefaultState(); + return Fluids.EMPTY.defaultFluidState(); } @Nullable - public WorldLightManager getWorldLightManager() { + public WorldLightManager getLightEngine() { return null; } - public int getLightValue(BlockPos p_217298_1_) { + public int getLightEmission(BlockPos p_217298_1_) { return 0; } @@ -49,34 +49,34 @@ public class EmptierChunk extends Chunk { public void removeEntity(Entity p_76622_1_) { } - public void removeEntityAtIndex(Entity p_76608_1_, int p_76608_2_) { } + public void removeEntity(Entity p_76608_1_, int p_76608_2_) { } @Nullable - public TileEntity getTileEntity(BlockPos p_177424_1_, Chunk.CreateEntityType p_177424_2_) { + public TileEntity getBlockEntity(BlockPos p_177424_1_, Chunk.CreateEntityType p_177424_2_) { return null; } - public void addTileEntity(TileEntity p_150813_1_) { } + public void addBlockEntity(TileEntity p_150813_1_) { } - public void addTileEntity(BlockPos p_177426_1_, TileEntity p_177426_2_) { } + public void setBlockEntity(BlockPos p_177426_1_, TileEntity p_177426_2_) { } - public void removeTileEntity(BlockPos p_177425_1_) { } + public void removeBlockEntity(BlockPos p_177425_1_) { } - public void markDirty() { } + public void markUnsaved() { } - public void getEntitiesWithinAABBForEntity(@Nullable Entity p_177414_1_, AxisAlignedBB p_177414_2_, List p_177414_3_, Predicate p_177414_4_) { } + public void getEntities(@Nullable Entity p_177414_1_, AxisAlignedBB p_177414_2_, List p_177414_3_, Predicate p_177414_4_) { } - public void getEntitiesOfTypeWithinAABB(Class p_177430_1_, AxisAlignedBB p_177430_2_, List p_177430_3_, Predicate p_177430_4_) { } + public void getEntitiesOfClass(Class p_177430_1_, AxisAlignedBB p_177430_2_, List p_177430_3_, Predicate p_177430_4_) { } public boolean isEmpty() { return true; } - public boolean isEmptyBetween(int p_76606_1_, int p_76606_2_) { + public boolean isYSpaceEmpty(int p_76606_1_, int p_76606_2_) { return true; } - public ChunkHolder.LocationType getLocationType() { + public ChunkHolder.LocationType getFullStatus() { return ChunkHolder.LocationType.BORDER; } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunk.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunk.java index c7bd8101d..6eaa14f87 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunk.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunk.java @@ -55,7 +55,7 @@ public class WrappedChunk implements IChunk { } @Override - public Stream getLightSources() { + public Stream getLights() { return world.blocksAdded .entrySet() .stream() @@ -84,7 +84,7 @@ public class WrappedChunk implements IChunk { } @Override - public void addTileEntity(BlockPos p_177426_1_, TileEntity p_177426_2_) { + public void setBlockEntity(BlockPos p_177426_1_, TileEntity p_177426_2_) { } @@ -94,12 +94,12 @@ public class WrappedChunk implements IChunk { } @Override - public Set getTileEntitiesPos() { + public Set getBlockEntitiesPos() { return null; } @Override - public Collection> func_217311_f() { + public Collection> getHeightmaps() { return null; } @@ -109,12 +109,12 @@ public class WrappedChunk implements IChunk { } @Override - public Heightmap getHeightmap(Heightmap.Type p_217303_1_) { + public Heightmap getOrCreateHeightmapUnprimed(Heightmap.Type p_217303_1_) { return null; } @Override - public int getTopBlockY(Heightmap.Type p_201576_1_, int p_201576_2_, int p_201576_3_) { + public int getHeight(Heightmap.Type p_201576_1_, int p_201576_2_, int p_201576_3_) { return 0; } @@ -130,49 +130,49 @@ public class WrappedChunk implements IChunk { @Nullable @Override - public BiomeContainer getBiomeArray() { + public BiomeContainer getBiomes() { return null; } @Override - public void setModified(boolean p_177427_1_) { + public void setUnsaved(boolean p_177427_1_) { } @Override - public boolean isModified() { + public boolean isUnsaved() { return false; } @Override - public void removeTileEntity(BlockPos p_177425_1_) { + public void removeBlockEntity(BlockPos p_177425_1_) { } @Override - public ShortList[] getPackedPositions() { + public ShortList[] getPostProcessing() { return new ShortList[0]; } @Nullable @Override - public CompoundNBT getDeferredTileEntity(BlockPos p_201579_1_) { + public CompoundNBT getBlockEntityNbt(BlockPos p_201579_1_) { return null; } @Nullable @Override - public CompoundNBT func_223134_j(BlockPos p_223134_1_) { + public CompoundNBT getBlockEntityNbtForSaving(BlockPos p_223134_1_) { return null; } @Override - public ITickList getBlocksToBeTicked() { + public ITickList getBlockTicks() { return null; } @Override - public ITickList getFluidsToBeTicked() { + public ITickList getLiquidTicks() { return null; } @@ -192,18 +192,18 @@ public class WrappedChunk implements IChunk { } @Override - public boolean hasLight() { + public boolean isLightCorrect() { return needsLight; } @Override - public void setLight(boolean needsLight) { + public void setLightCorrect(boolean needsLight) { this.needsLight = needsLight; } @Nullable @Override - public TileEntity getTileEntity(BlockPos pos) { + public TileEntity getBlockEntity(BlockPos pos) { return null; } @@ -218,42 +218,42 @@ public class WrappedChunk implements IChunk { } @Override - public void addStructureReference(Structure arg0, long arg1) { + public void addReferenceForFeature(Structure arg0, long arg1) { } @Override - public Map, LongSet> getStructureReferences() { + public Map, LongSet> getAllReferences() { return null; } @Override - public LongSet getStructureReferences(Structure arg0) { + public LongSet getReferencesForFeature(Structure arg0) { return null; } @Override - public StructureStart getStructureStart(Structure arg0) { + public StructureStart getStartForFeature(Structure arg0) { return null; } @Override - public void setStructureReferences(Map, LongSet> arg0) { + public void setAllReferences(Map, LongSet> arg0) { } @Override - public void setStructureStart(Structure arg0, StructureStart arg1) { + public void setStartForFeature(Structure arg0, StructureStart arg1) { } @Override - public void setStructureStarts(Map, StructureStart> p_201612_1_) { + public void setAllStarts(Map, StructureStart> p_201612_1_) { } @Override - public Map, StructureStart> getStructureStarts() { + public Map, StructureStart> getAllStarts() { return null; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunkSection.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunkSection.java index e5e90594d..26282a22b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunkSection.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunkSection.java @@ -14,9 +14,9 @@ public class WrappedChunkSection extends ChunkSection { public WrappedChunkSection(WrappedChunk owner, int yBase) { super(yBase); this.owner = owner; - this.xStart = owner.pos.getXStart(); + this.xStart = owner.pos.getMinBlockX(); this.yStart = yBase; - this.zStart = owner.pos.getZStart(); + this.zStart = owner.pos.getMinBlockZ(); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/AllWorldFeatures.java b/src/main/java/com/simibubi/create/foundation/worldgen/AllWorldFeatures.java index 3eab6cd93..9113dd70a 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/AllWorldFeatures.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/AllWorldFeatures.java @@ -77,7 +77,7 @@ public class AllWorldFeatures { if (event.getCategory() == Category.NETHER) return; event.getGeneration() - .feature(GenerationStage.Decoration.UNDERGROUND_ORES, entry.getFeature()); + .addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, entry.getFeature()); }); } diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenDecorator.java b/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenDecorator.java index b9c6509ad..86cfb3fe9 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenDecorator.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenDecorator.java @@ -18,7 +18,7 @@ public class ConfigDrivenDecorator extends SimplePlacement getPositions(Random r, ConfigDrivenOreFeatureConfig config, BlockPos pos) { + protected Stream place(Random r, ConfigDrivenOreFeatureConfig config, BlockPos pos) { float frequency = config.getFrequency(); int floored = MathHelper.floor(frequency); diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenFeatureEntry.java b/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenFeatureEntry.java index e89ff388e..78c8edd04 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenFeatureEntry.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenFeatureEntry.java @@ -10,6 +10,9 @@ import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.OreFeatureConfig.FillerBlockType; import net.minecraftforge.common.ForgeConfigSpec; +import com.simibubi.create.foundation.config.ConfigBase.ConfigFloat; +import com.simibubi.create.foundation.config.ConfigBase.ConfigInt; + public class ConfigDrivenFeatureEntry extends ConfigBase { public final String id; @@ -49,11 +52,11 @@ public class ConfigDrivenFeatureEntry extends ConfigBase { private ConfiguredFeature createFeature() { ConfigDrivenOreFeatureConfig config = - new ConfigDrivenOreFeatureConfig(FillerBlockType.BASE_STONE_OVERWORLD, block.get() - .getDefaultState(), id); + new ConfigDrivenOreFeatureConfig(FillerBlockType.NATURAL_STONE, block.get() + .defaultBlockState(), id); - return ConfigDrivenOreFeature.INSTANCE.configure(config) - .decorate(ConfigDrivenDecorator.INSTANCE.configure(config)); + return ConfigDrivenOreFeature.INSTANCE.configured(config) + .decorated(ConfigDrivenDecorator.INSTANCE.configured(config)); } public void addToConfig(ForgeConfigSpec.Builder builder) { diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenOreFeature.java b/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenOreFeature.java index 959452655..b93026dc8 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenOreFeature.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenOreFeature.java @@ -22,7 +22,7 @@ public class ConfigDrivenOreFeature extends Feature CODEC = RecordCodecBuilder.create((p_236568_0_) -> { - return p_236568_0_.group(RuleTest.field_25012.fieldOf("target") + return p_236568_0_.group(RuleTest.CODEC.fieldOf("target") .forGetter((p_236570_0_) -> { return p_236570_0_.target; }), BlockState.CODEC.fieldOf("state") diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java b/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java index 74345a8a3..6793a7bf9 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java @@ -21,6 +21,8 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; +import net.minecraft.block.AbstractBlock.Properties; + public class OxidizingBlock extends Block { public static final IntegerProperty OXIDIZATION = IntegerProperty.create("oxidization", 0, 7); @@ -29,35 +31,35 @@ public class OxidizingBlock extends Block { public OxidizingBlock(Properties properties, float chance) { super(properties); this.chance = chance; - setDefaultState(getDefaultState().with(OXIDIZATION, 0)); + registerDefaultState(defaultBlockState().setValue(OXIDIZATION, 0)); } @Override - protected void fillStateContainer(Builder builder) { - super.fillStateContainer(builder.add(OXIDIZATION)); + protected void createBlockStateDefinition(Builder builder) { + super.createBlockStateDefinition(builder.add(OXIDIZATION)); } @Override - public boolean ticksRandomly(BlockState state) { - return super.ticksRandomly(state) || state.get(OXIDIZATION) < 7; + public boolean isRandomlyTicking(BlockState state) { + return super.isRandomlyTicking(state) || state.getValue(OXIDIZATION) < 7; } @Override public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { if (worldIn.getRandom() .nextFloat() <= chance) { - int currentState = state.get(OXIDIZATION); + int currentState = state.getValue(OXIDIZATION); boolean canIncrease = false; LinkedList neighbors = new LinkedList<>(); for (Direction facing : Iterate.directions) { - BlockPos neighbourPos = pos.offset(facing); + BlockPos neighbourPos = pos.relative(facing); if (!worldIn.isAreaLoaded(neighbourPos, 0)) continue; - if (!worldIn.isBlockPresent(neighbourPos)) + if (!worldIn.isLoaded(neighbourPos)) continue; BlockState neighborState = worldIn.getBlockState(neighbourPos); - if (neighborState.contains(OXIDIZATION) && neighborState.get(OXIDIZATION) != 0) { - neighbors.add(neighborState.get(OXIDIZATION)); + if (neighborState.hasProperty(OXIDIZATION) && neighborState.getValue(OXIDIZATION) != 0) { + neighbors.add(neighborState.getValue(OXIDIZATION)); } if (BlockHelper.hasBlockSolidSide(neighborState, worldIn, neighbourPos, facing.getOpposite())) { continue; @@ -69,20 +71,20 @@ public class OxidizingBlock extends Block { .mapToInt(v -> v) .average(); if (average.orElse(7d) >= currentState) - worldIn.setBlockState(pos, state.with(OXIDIZATION, Math.min(currentState + 1, 7))); + worldIn.setBlockAndUpdate(pos, state.setValue(OXIDIZATION, Math.min(currentState + 1, 7))); } } } @Override - public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) { - if (state.get(OXIDIZATION) > 0 && player.getHeldItem(hand) + if (state.getValue(OXIDIZATION) > 0 && player.getItemInHand(hand) .getItem() instanceof SandPaperItem) { if (!player.isCreative()) - player.getHeldItem(hand) - .damageItem(1, player, p -> p.sendBreakAnimation(p.getActiveHand())); - world.setBlockState(pos, state.with(OXIDIZATION, 0)); + player.getItemInHand(hand) + .hurtAndBreak(1, player, p -> p.broadcastBreakEvent(p.getUsedItemHand())); + world.setBlockAndUpdate(pos, state.setValue(OXIDIZATION, 0)); return ActionResultType.SUCCESS; } return ActionResultType.PASS; From 9e4198fa797810acf28cfa9e6df8084de9deb3e4 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Thu, 15 Jul 2021 11:39:37 +0200 Subject: [PATCH 2/5] fix mixins --- .../foundation/mixin/BreakProgressMixin.java | 6 +++--- .../EntityContraptionInteractionMixin.java | 20 +++++++++---------- .../mixin/FixNormalScalingMixin.java | 6 ++---- .../mixin/HeavyBootsOnPlayerMixin.java | 2 +- .../foundation/mixin/WindowResizeMixin.java | 6 +++--- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java index 477e8f081..1ff9b0efe 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java @@ -17,11 +17,11 @@ import net.minecraft.util.math.BlockPos; public class BreakProgressMixin { @Shadow @Final - private WorldRenderer worldRenderer; // levelRenderer + private WorldRenderer levelRenderer; // levelRenderer private final ClientWorld self = (ClientWorld) (Object) this; - @Inject(at = @At("HEAD"), method = "sendBlockBreakProgress") // levelRenderer + @Inject(at = @At("HEAD"), method = "destroyBlockProgress") private void onBreakProgress(int playerEntityId, BlockPos pos, int progress, CallbackInfo ci) { - BreakProgressHook.whenBreaking(self, this.worldRenderer, playerEntityId, pos, progress); + BreakProgressHook.whenBreaking(self, this.levelRenderer, playerEntityId, pos, progress); } } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java index 6f4e0f089..ee082eac3 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java @@ -44,16 +44,16 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid @Final @Shadow - protected Random rand; // levelRenderer + protected Random random; @Shadow - private float nextStepDistance; // levelRenderer + private float nextStep; @Shadow - protected abstract float determineNextStepDistance(); // nextStep()F + protected abstract float nextStep(); @Shadow - protected abstract void playStepSound(BlockPos p_180429_1_, BlockState p_180429_2_); // nextStep()F + protected abstract void playStepSound(BlockPos p_180429_1_, BlockState p_180429_2_); private Set getIntersectingContraptions() { Set contraptions = ContraptionHandler.loadedContraptions.get(self.level) @@ -87,7 +87,7 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid } @Inject(at = @At(value = "JUMP", opcode = 154, // IFNE line 587 injecting before `!blockstate.isAir(this.world, blockpos)` - ordinal = 4), method = "move") // nextStep()F + ordinal = 4), method = "move") private void movementMixin(MoverType mover, Vector3d movement, CallbackInfo ci) { Vector3d worldPos = self.position() .add(0, -0.2, 0); @@ -101,10 +101,10 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid }); if (stepped.get()) - this.nextStepDistance = this.determineNextStepDistance(); + this.nextStep = this.nextStep(); } - @Inject(method = { "spawnSprintingParticles" }, at = @At(value = "TAIL")) // spawnSprintParticle()V + @Inject(method = { "spawnSprintParticle" }, at = @At(value = "TAIL")) private void createRunningParticlesMixin(CallbackInfo ci) { Vector3d worldPos = self.position() .add(0, -0.2, 0); @@ -115,14 +115,14 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid && blockstate.getRenderShape() != BlockRenderType.INVISIBLE) { Vector3d vec3d = self.getDeltaMovement(); self.level.addParticle(new BlockParticleData(ParticleTypes.BLOCK, blockstate).setPos(pos), - self.getX() + ((double) rand.nextFloat() - 0.5D) * (double) self.getBbWidth(), self.getY() + 0.1D, - self.getZ() + ((double) rand.nextFloat() - 0.5D) * (double) self.getBbWidth(), vec3d.x * -4.0D, 1.5D, + self.getX() + ((double) random.nextFloat() - 0.5D) * (double) self.getBbWidth(), self.getY() + 0.1D, + self.getZ() + ((double) random.nextFloat() - 0.5D) * (double) self.getBbWidth(), vec3d.x * -4.0D, 1.5D, vec3d.z * -4.0D); } }); } - @Inject(method = "playSound", at = @At("HEAD"), cancellable = true) // playSound(Lnet/minecraft/util/SoundEvent;FF)V + @Inject(method = "playSound", at = @At("HEAD"), cancellable = true) private void playSoundShifted(SoundEvent event, float pitch, float volume, CallbackInfo ci) { if (this.contraption != null && (!self.isSilent() || self instanceof PlayerEntity)) { double x = self.getX(); diff --git a/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java index 12bb65618..b76f2ab3e 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java @@ -17,8 +17,7 @@ public class FixNormalScalingMixin { * applied, which negates the matrix again, resulting in the matrix being the * same as in the beginning. */ - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/vector/Matrix3f;multiply(F)V", shift = Shift.AFTER), method = "scale(FFF)V", cancellable = true) - // At mul(F)V, method: scale(FFF)V + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/vector/Matrix3f;mul(F)V", shift = Shift.AFTER), method = "scale(FFF)V", cancellable = true) private void returnAfterNegate(float x, float y, float z, CallbackInfo ci) { ci.cancel(); } @@ -30,8 +29,7 @@ public class FixNormalScalingMixin { * that would invert all normals. Additionally, Minecraft's fastInverseCbrt method * does not work for negative numbers. */ - @ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;fastInverseCbrt(F)F"), method = "scale(FFF)V") - // at fastInvCubeRoot(F)F, method: fastInvCubeRoot(F)F + @ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;fastInvCubeRoot(F)F"), method = "scale(FFF)V") private float absInvCbrtInput(float input) { return Math.abs(input); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java index 985b74d01..8561b404a 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java @@ -22,7 +22,7 @@ public abstract class HeavyBootsOnPlayerMixin extends AbstractClientPlayerEntity super(p_i50991_1_, p_i50991_2_); } - @Inject(at = @At("HEAD"), method = "canSwim", cancellable = true) // isUnderWater()Z + @Inject(at = @At("HEAD"), method = "isUnderWater", cancellable = true) public void noSwimmingWithHeavyBootsOn(CallbackInfoReturnable cir) { CompoundNBT persistentData = getPersistentData(); if (persistentData.contains("HeavyBoots")) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java index 5d0a60b8c..4af9f1243 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java @@ -18,11 +18,11 @@ import net.minecraftforge.api.distmarker.OnlyIn; @Mixin(Minecraft.class) public class WindowResizeMixin { - @Shadow @Final private MainWindow mainWindow; + @Shadow @Final private MainWindow window; - @Inject(at = @At("TAIL"), method = "updateWindowSize") // resizeDisplay()V + @Inject(at = @At("TAIL"), method = "resizeDisplay") private void updateWindowSize(CallbackInfo ci) { - UIRenderHelper.updateWindowSize(mainWindow); + UIRenderHelper.updateWindowSize(window); } } From d53e89887adfe12ad9d3ee0d11c7ec9f02d372f6 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Thu, 15 Jul 2021 11:45:45 +0200 Subject: [PATCH 3/5] fix obfuscation reflection helper calls --- .../actors/dispenser/MovedProjectileDispenserBehaviour.java | 6 +++--- .../processing/burner/BlazeBurnerBlockItem.java | 4 ++-- .../create/content/curiosities/armor/DivingBootsItem.java | 2 +- .../create/content/curiosities/tools/BlueprintItem.java | 2 +- .../simibubi/create/foundation/command/FlySpeedCommand.java | 2 +- .../utility/worldWrappers/WrappedServerWorld.java | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java index d717dfa63..313253630 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java @@ -81,19 +81,19 @@ public abstract class MovedProjectileDispenserBehaviour extends MovedDefaultDisp } private static Method getProjectileEntityLookup() { - Method getProjectileEntity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "getProjectile", World.class, IPosition.class, ItemStack.class); // getProjectile + Method getProjectileEntity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82499_a", World.class, IPosition.class, ItemStack.class); // getProjectile getProjectileEntity.setAccessible(true); return getProjectileEntity; } private static Method getProjectileInaccuracyLookup() { - Method getProjectileInaccuracy = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "getUncertainty"); // getUncertainty + Method getProjectileInaccuracy = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82498_a"); // getUncertainty getProjectileInaccuracy.setAccessible(true); return getProjectileInaccuracy; } private static Method getProjectileVelocityLookup() { - Method getProjectileVelocity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "getPower"); // getPower + Method getProjectileVelocity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82500_b"); // getPower getProjectileVelocity.setAccessible(true); return getProjectileVelocity; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlockItem.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlockItem.java index 6aad6c4be..f09197d66 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlockItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlockItem.java @@ -91,11 +91,11 @@ public class BlazeBurnerBlockItem extends BlockItem { AbstractSpawner spawner = ((MobSpawnerTileEntity) te).getSpawner(); List possibleSpawns = - ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "spawnPotentials"); // spawnPotentials + ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "field_98285_e"); if (possibleSpawns.isEmpty()) { possibleSpawns = new ArrayList<>(); possibleSpawns - .add(ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "nextSpawnData")); // nextSpawnData + .add(ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "field_98282_f")); } ResourceLocation blazeId = EntityType.BLAZE.getRegistryName(); diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/DivingBootsItem.java b/src/main/java/com/simibubi/create/content/curiosities/armor/DivingBootsItem.java index 2b69e2950..fa47be38b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/DivingBootsItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/DivingBootsItem.java @@ -29,7 +29,7 @@ public class DivingBootsItem extends CopperArmorItem { return; Vector3d motion = entity.getDeltaMovement(); - Boolean isJumping = ObfuscationReflectionHelper.getPrivateValue(LivingEntity.class, entity, "jumping"); // jumping + Boolean isJumping = ObfuscationReflectionHelper.getPrivateValue(LivingEntity.class, entity, "field_70703_bu"); // jumping entity.onGround |= entity.verticalCollision; if (isJumping && entity.onGround) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java index 9846c36b9..c1638fee7 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintItem.java @@ -95,7 +95,7 @@ public class BlueprintItem extends Item { private static ItemStack convertIngredientToFilter(Ingredient ingredient) { Ingredient.IItemList[] acceptedItems = - ObfuscationReflectionHelper.getPrivateValue(Ingredient.class, ingredient, "values"); // values + ObfuscationReflectionHelper.getPrivateValue(Ingredient.class, ingredient, "field_199807_b"); // values if (acceptedItems == null || acceptedItems.length > 18) return ItemStack.EMPTY; if (acceptedItems.length == 0) diff --git a/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java b/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java index a005f379f..a67b5bc19 100644 --- a/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java @@ -36,7 +36,7 @@ public class FlySpeedCommand { private static int sendFlySpeedUpdate(CommandContext ctx, ServerPlayerEntity player, float speed) { SPlayerAbilitiesPacket packet = new SPlayerAbilitiesPacket(player.abilities); // packet.setFlySpeed(speed); - ObfuscationReflectionHelper.setPrivateValue(SPlayerAbilitiesPacket.class, packet, speed, "flyingSpeed"); // flyingSpeed + ObfuscationReflectionHelper.setPrivateValue(SPlayerAbilitiesPacket.class, packet, speed, "field_149116_e"); // flyingSpeed player.connection.send(packet); ctx.getSource() diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java index 1ee80a641..6161cbfc4 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java @@ -137,6 +137,6 @@ public class WrappedServerWorld extends ServerWorld { } private static SaveFormat.LevelSave getLevelSaveFromWorld(World world) { - return ObfuscationReflectionHelper.getPrivateValue(MinecraftServer.class, world.getServer(), "storageSource"); // storageSource + return ObfuscationReflectionHelper.getPrivateValue(MinecraftServer.class, world.getServer(), "field_71310_m"); // storageSource } } From 5610f6337504deeb2c39440e355376255ca259d3 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Thu, 15 Jul 2021 11:53:08 +0200 Subject: [PATCH 4/5] no more outdated gradle --- build.gradle | 9 +++++++-- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index c2d1456ad..9a5dfeab0 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ version = "mc${minecraft_version}_v${mod_version}" + (dev ? "+${buildnumber}" : group = 'com.simibubi.create' archivesBaseName = 'create' -sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' +java.toolchain.languageVersion = JavaLanguageVersion.of(8) minecraft { mappings channel: 'official', version: "${minecraft_version}" @@ -42,7 +42,8 @@ minecraft { //jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling property 'forge.logging.console.level', 'info' property 'fml.earlyprogresswindow', 'false' - property 'mixin.env.disableRefMap', 'true' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" mods { create { source sourceSets.main @@ -54,6 +55,8 @@ minecraft { workingDirectory project.file('run/server') arg '-mixin.config=create.mixins.json' property 'forge.logging.console.level', 'info' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" mods { create { source sourceSets.main @@ -66,6 +69,8 @@ minecraft { property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' property 'fml.earlyprogresswindow', 'false' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" args '--mod', 'create', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources') mods { create { diff --git a/gradle.properties b/gradle.properties index f6faa393e..a7c03ba82 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ minecraft_version = 1.16.5 forge_version = 36.1.32 # build dependency versions -forgegradle_version = 3.+ +forgegradle_version = 4.1.+ mixingradle_version = 0.7-SNAPSHOT shadow_version = 5.2.0 cursegradle_version = 1.4.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5028f28f8..549d84424 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 681791a329a15b71dd8680d1a2cddfafa5f4d63c Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Thu, 15 Jul 2021 11:52:19 -0700 Subject: [PATCH 5/5] Update Gradle wrapper files --- gradle/wrapper/gradle-wrapper.jar | Bin 55616 -> 59203 bytes gradlew | 31 ++++++++++++++---------------- gradlew.bat | 25 +++++++----------------- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf016b3885f6930543d57b744ea8c220a1a..e708b1c023ec8b20f512888fe07c5bd3ff77bb8f 100644 GIT binary patch delta 23334 zcmZ6yQ*_^7)b$%Swr#tyZQHhuU-WHk+qUgAc4J!&nxrusy#I5a=UlvJjD59l*Pe6C zy*_IVG(!&0LN+phBc)L-m3M)If#E@dfw80{QedYjfnx%cY|Q2krta=>YST_jBA9|p zot|vvp%0RvR1srYTl+z-NNCL@5oSg;&!BaMOR}sfJn192cT55<(x!dL7ut~~3^-Ur z4>ora_t}-M=h->qJpjxnx)1EWvn8?z{O>`3f+7iuKL<2+zHP~ldyrmD0P{Z4X%%`W zo_)z~Yy==^IcLFQUXFGeH8WebVkw~L>r{vkbd$z5MQq(ni#a^*>hw=_Z;C^Gfrdev z!mgg_pG zeMQUU+?X~Em$z2qQyLw%`*oeVS_0m|fcm)7q6xUbNU;Eku2#8)2t3}hj!-y+-89iQ z3fZ2srkJN7rV0vd0?Or&O+;oeJrGw6+{`LpB@d3*VpO>Un|q3BNDJspjozc(4hJDz zwgOl$df!`k*;k(~&;GPfVBAD3Hi3C}ZFV~#*$f>4hj%YsCq6tRQfp_Dt-)S_Uj!o= ze~fwe`&6h3{1?2yCfi zXybknxod^Z|~hQkrhOl74q z$G@Js5lv&IFx8Sm%&;&R^ZS012w;u(#-d_d7z}E<_L7JxsnmzL7!JXpt9>W$Br_-E zrt)8pGV-SsMKD!epNc6VMP@dY9SZ~}4KEJ0{AM}D(Ur&6>Xwy(7hK_??ybcBfV^H zx_aQ9cAG-(o3ZK6^5ob$c;XQ+WUNPojJo*4bQPb@#nF;E%h&FNJuVpSRK{}ljl}!b z#w$tS(t%=z)Q_2_4&C(JNz3Z&rgJG<@$5eR{6=#eNx!WXg2rrliM1=mC{vw4N32Vt z(hz+({@Wh2Y$x_R-d{$2XdqlCZW<@Yvix3|nho{g3fcY`x3r&v zC3T%<=pJrdP1&am@lIKma2=I=^4+>BZP8iAC+!5rKrxkP-K0t^lPkRKzej86htd0P z#d#*bI0LJ?=)BWl*(f{h=~UK26R;3?r6Z!LAuS$vtfd9{cVHb61Hh{>!#phiJ%Th9 zF?=-pJ;B(60kgq8M!6s_=E5q^V1BZqUk45QP(0*!5vKTDdWw8Z2W(yF7Cd4q6#8Au zDKAwS7y&OlW39}KP7u;mRY_qmKm6ZlbFdopRZRb2WvuPtfGOrS@2QJ&4I=v~NILZ5 zeRhAPI(ofewJkMGXux=19@_Z8{!gjzB73;zNpU}X|DXwxK^;Cvj0Ph3u|D+PK~V7Z z?T_+HtO$qw$Y7Eiis5+%de#S_2Eg{NT?gs+rEQ*+9;JM`;i65mGIf65%GmAWA1&vF zlc?PlDec;zALdLmib;DC&8{{TV>uUmnkgCuNg83d=~K)66oA^Xl2_g3joQ7h45dDe zhrM9pl;y7z>d~B9=jQH;Q=2Fr{5!6n4(@U2+i4B!LnEVpkskhl8Y&h?h2<}2MvUa(Z=c-L0$s#VLm_n6MN={uuQNF?aO%NJt-w^*Q^v38n zSik;)49a!p_y;?PBm+2+r&6d%&w5wFcSS3i(Q0})76N`VU$9#xpY*=PpEvRJL*_v? zq`fJn6uibh+U?Oh=7TngAZ+QgfVq{*FP4XT@%T4DJXQ3^Q%|A#S*bgV=uQOkLs3B> zPb@_|qGW^GJGUz;Rdk=&!X5<@+IA_92osMhzl2w&pZpOkH2wg6{QNKJ_SprLV)J7~ zswn~v{%5cFd4Dchvot~B4Q=>*(PzriPyl!KvQ;DQT4Jwc7b z@=RK6_wy*9Ls}eOd#i_ifu-1gyG1I4B$wrf0s~uz`Oi=PUk3$X;9w*ytxP=~JW?)j ziGecB9d!at%>E`;fCYBIE`?LXQ%q2#KyT1)F3gKTVQ(^OFF_%e>U9C|Jftsp-L z-uBgv--?x$jQ!7JVOO%A6s_NIULK3t`AUvLNRGy1+2c=*hNLTgEU{(f`aS3R&0c#8 zJ)H~+lk7p>Antxg8%KDw8HA(zRyL7IsRXPZq(&|IG=anACS|u!&ze?(596{Wa^56I z(Hh0)W(B=vPMB&$-+voJG+fh`2n6^ zE<#-hLF2)fS!S>(AgaU7)DA<}B0gb;cUhr}#B$zitS3?I zQ2dfsjc&|!;>ZmeP`tUDacf0iky2%{sdnvR10i;nHt{`{s%AE_Ck=O!`CgKV{TxZt zvGG&6h(`32V2E)jIe5jAb7h61MnLCplX!amDU*7b478F^m0qqf96LN3N^S2xtX@WV zqjdFPUpJ(hHl4?SW`Rxi^WJaHe&^dS6OY9@unu!n*p3<-W-CQ>pb^E?XzN3;LFQ%}E-2`SgWHo)7f-p+JMy`RG3E&3PwN54o9wVP*Nq{9PKSNP@R_eO zKB~SbZXrKS%qqUV1h!p7JvFb&fbotnqw2Q5-wA7wlEq4H?+^~Js$F8pms&<$wDQtJ zl0cD0WH*i-3Lza6dDXZ-#eh8JlXkv(BGQT%ufa%jHyi2P_PS;2Q-5b!JPW(HoNzYg z2(g^gwcm)p-Q2=kK{=bNP4d6yB|A(BM{w}7e~-*Rt}#Z0uO{Xa=nY%!B|uW5EG{vg zbLt&cVKr)8e;2Fjx3r;i#5>@hs!6e6@JKF5xyGp+&#)QM4t?M}2m%79NOpKi>$f_G zEbVBL#9J#iY7hDnU;}~%>)&#&&6NL$+Y}5cc(#RW7pC-r5LDH|vnfahGt*C$(Ng4D z@UDxQAtvS2YmtXYUy%%-_Rv?oQ+J+2A0XduD3tbTMwumZ;T%JDNb|+ing}FNbj9t~ zYGxl7j3TfT+7h#O8vy*@Fq~5xnOT1>jYI=xJWjqnga#r=N9ytv{fvN2b{8`alWjGR zxGp9OJ=YMcpx>2RD*S{iX1{ua$G_fF-G`KzuP(cV`XlqHAo&r7f6owqz}@^MOA{#l z4KRTMsx;y;x}?Yp$|XFTGd=EXS28c9e09?>)%mkh%af}^xQtw8f2@dr7LZh@?Sq?> zcW-rMFZvfi!!af2oBTEFEzu_^TzVv`3!l41E93Syt^yVFVj~8=LJ2f0!YqbD6YAk7 zKmYI0w$QC~$@pI|ANU3a#__+FLk|4sGU%$9UxpGmYm!ka>h~0!kQyrg7CF?}ro^aJ zmM$&Bh_;6e_0pGtO6v>oyxjAmau&Zc6ua{CZ7e(q>9`2LS;159*^j)IQzPWhz;`GU zSQbg2d79#U7UBnOiXWtF-y{&tWCj$`AfDkme-Ah^Uq^Pvn8HXAc8;&8f&=E{f6Wa- z5m0=p;lR})#1J*jtIM;G5V4H*&_e`EX|Te(Bdh7$yW%)UbrRPWEnKA^LUWChkgd#q}YO& z-pbQge_K3HLX{vY(v8Ndy#VD-l=A-7^=uxXfF$iZecnnss~ZngOBXAjT?%fNp=jA@ zJ$hVjBu#m=2~kpYLW_odtK3bm|tv16fZEfF7}7vKNtrxO>y&HXNY zk@aEbvcNc!%FRn9e-n0v=&ZM~tIvl%zUWONu6EzU5^P=>J9d(xjqA&t-4RL^kT$9l zs!&!tAx2x}F{d&--V5*q=Tp4jlGPnDEu6(X`YCrSOJRNsR_>@G$&QqRv*Wj?Cm3z1 z+B)G{0Tpehdc0unLyH^!<{~%!Q{=gk$$^+9v)6?MC%xlIu!lE;cR}zfui*qpu zU^U+QL4`B4A|#i(N|ymR?a!s_^Ah%HmhZ7vH#H{U^TAxnUVzYX*gi{ZONznMsp>8G zlXqmIR+hA;1|j(3Gmj_!Y9i{2*2{s$HMiU;=fA^~lna|G zxh0n{QMbc&j`l3G^&pebs;Ioym)!V;h)pUY*1FX27P^te?Y!%E9}ie*`yK((+Qt;c zOz*W3T1(fUGu(h0!oCiP`+vo+kYS(m;!bZAY%lHmZ{}&ABjSMEp6dA==9@c;=AyCB z8OwPO@f*ZPn$4$P<42s$=c;(mxgY#To)~al#PN04wIJIxvGI~PN*cW*v1o!=EzemPx0zMa zZ;bBC-;*cnZ5Fu(CV*q;^X=o^R6(neD;u2-MbsJ?Kjh~J;wxUx7rv7sMa6 zyXZ?tB}`;n(PPqEne_ZKK8veIPl?3xc=X=iHCs{s?(J;=^q2zSXfX0of1;|Y8-6~E z0M@h~)kmZj8PSo0-SNBm`LprhHawiDmwzvb2zgeBF8{!X^8suvETN+W_L=@4d4A7W zmL_iFGYhIs30Q{ZoSWb6&XY11zMGy$g_^c`Ov>t1n{1aP5GW8ogd;NGaULmfMu9$U zn5j>t{)SjQJ1+Pv?+z~;{rmxa-^X3hY#TYbVk%`~;i=8x^iVpcOtAVRkk1PCE5}rj zt5jc=%`1}Gj}eF_ZP1&r$h2X$*+^*FdG3x&Gi4V-CsNcM+rCV8VyVMXNF&onDL7xn zm~~o?EWwUaEl48ZzDytdEG(h2YrjkwL#z^Apg=RlSF1_HqQhlN_Tu<^R!wgZ19c{V z!-Z~!9%J9k7vj3rc<76Wpe8%K$#2J_8wXpU6c-!0ObhVtB9GoK`}`z}t!-4)Pw>RM zRrO<3PDYzdenBPA`qhZcPNhL=bAxoLm+tI^15f7^8m8KqSoBc7ah`}LWWEl$;5w|Z z!Fx2Q9nGe0=oHdN$Dh=U_D!5*+(Q=AF8$albswx3DM9U%mt9ui3x8Vjn427Oh z<0Ww@!X21VEnjhmXtAxo*TzB>OL5f~);4jMi>wlV*nG6$5a4F#!a{oYr-{P633WH8 zOo-HD6*7Z>P`;2g|F=5pqqDjg{zlHLhxp4*3W>jE;t$s)8wQzC{a5al8z=UxphGwIEah$cFjbEH#H{9_a9S-93G65cv3RM3dFTa!q6L_9(KzDb zR4D*OJ-W&f98>?9*_xEntwV~W_#QtXHeUp4%z+|N4rz{$f!Ho3>#x|1Fw8Q z%=fgQR!p;CNSfpCY2p~9K;&t9EhPUP851Bk zAxxcpgugdR!_lo^8@F4?eV}dX(t=nzMgzQJD$PJUti3p`atbkJvzpu7M2?jRl)Gpg z`Mt!Bv6()f;+<$nKsW1Fg*r-L#@jo%1>343`}n$_$F&I53rk7WCmIj+TT{{hk- zJnV~qI@rH+1`7AlIdqexY%9jF z)q(f5rmv4Yxp^EzJjov|oph-da{!Yt_AAPS$BncKzSe_>+zr%w02^c^eL7W%OPO$* zIxc*nR2bh<^zNxhC%<{96w8ukobU|E!i#DkA~ALjvWNxaJTti7(fDhL%#7~3WY{lJ zo;a49@!Zfk;~wUYVtU9PNGs~?_p6uq)d%SD1B2auw;*cYGSQmKfW@YZNZmR;4Jx`{h%yy)dYQr zt@w6Sex+QF4u@e!9ym`89{(vWzH`&Vt=BnGZA8?Vl!`Iho3K=WF)bNpvza!9Zl5FAhzk;2?O~IOhJz<5C8nJx!boh5 zeRIU;CDx{3AT@eh@*O#VXla?V2=LBc8ls1(3V;3iTf-7)j^(bo?j#`WGJQJ1*h%Zx zR1(z_#qZ}b` z_j*zU3xpSIr`jU`rv4;!#F#3Ic28Ex?YG?cdl~o~OsS0ed2`_93i95wyaqr-xTQ1F zi-iZmY3XQQn#J~Uf8ur_&~4m9I=g$(Z?Ju{9V(Y}|C=9y47Xv4p|vcfMt38s;=AcR zOdh;-S~GdvzW^pn#99R8FWMGoD6qQ*@I_ zHlQZ@RhZSv-X{dsxwIrHRCz`ui+7lbs@cD{C_VlgiT^e~*;|O}1<wPnjA&`|P)rr>99aZ=5x4*D#;(U-K6`Ir zSOW`9F0mTS&-_LSviyZE1#Z>CDqwmO<|7sYp-M#Q0ScV_-$-%W%L0=Ave6)o@9Bk( zWNA)C<>JD8UmEQTIK~eNt)lkg=D6hJ_$}O{^@(;WwLXKRS zqNbV>!OFaoo@j?WLF|YU}0P}K=ani9qJHOnzwAt=SpT=*PFXmu! z@>E_*KCrDO2tO=SZ>=3aRZ3}CS(!g`S6py=36!ikbO&j_rE=8Wb=h$b&2!E!UAvc^ zm#;Q&`ua*bYL41mc`3ifN8b^p^?xtOF3*YR$jA^-9>dbhD1R&{r(#+7c0I{S5g z=KQz3NcG#+4rF>_tB~gFEW2c7yy2-9U}?L#=%44Cv*dAs;L)gw247*jb%W{n{8wg4 zscFt|SL*$ z2!y5c!8O>CSr?+T66REewdMc8fhWNc!Rm*(%x{a!32+ltu{XP_DXFe%&Yu`?t-NCNZ+qV9}-dF%ibhW-Soz?`vjqUhmlsD=_h5QZ*5NSf23 z65X)`bqx_5`3}McHHQVJ3&nB5x9%y=Em$X-!kxXqnMmRyS%uPx^e1Fv$;y=HCaMyq*Sl87b+d6}O1Nl@% z=bYi3;Uwi1%k;})v8!lR&D#NCUJMV=Vf~f!G4KJhMJx;+YC1E_BD07qEEA*27bo3# zxDA-UAzyx(BtWMeD>RAeQ@|VMg10YYn!9}dfc}NZ1)?AVtyD(ONh1$zqX;A5+U1w; z3?tcY4%;}5Un9Ri9j?V2k7Hi-taB>QMXbc zn*=$+py&qwtsNaePb6_b7%vDY4^0tSDGkb~C$*jdex$S>WlelM8T4xcn1E{ogkS@eKF9RDdr z!(#S($E?h#bMf@hY`cybuYL(a5Ul|nsxKj)^yPymlw^SYsN@^q6Rx5}KV^#dL?F`Y zRg@ZEsPd+YYfc*nqk@f6%o_UhZ!k=Hka@OIP$(GuwdR9CA!Etf89q7BHxg?bl*7wc z{10^B53n3#Ddppdu-pa~nV*NqP?4`#Z<_100^2fF>?+3eOSsSvo~n=)R*8c3gm6%@ z{}uM3J7sdtlrk9T+8`K1+qjA=yt3_9vj36Gkn2DA+TQX_$DYIb?l*a}{jnLd`JZD@ z02+8N)RwW>uK;Kl5HE{5*Jx5h<%^)f>xch;04K(x@3T}75BytBOP18+~=(K$L_!W=YNW`AE!kT z;I%`-C#H~$PRZN7i3B-0nB4KP0Cp)AVG`O>dG{_jMuR0imc8f=X35&qK1hGz4%!snx>1ehns-T$;(Ra~dbQoHeA_HbaKh9FN9am&FQFo%Xe&CVI;tzU^C{ft;na zLBGpdTXX27IT6dZN^`nfB=_sHH((L+RP56EFQ`cD%2(R_px^7XVte}=#kt$+JE zo-0ELBc_m%r;S!tLHULc_jJ&yUQ3j>;n{Mw9DR1_DYZ7`;{RmP0m-W3@^+ri=)XyA z$hHfna0MQg$_)mTHoP0JrIZR@=#zAWuV#oiq9vp1a$DX`!uTu68@SVOE5xe~3I6?6 zwoMv2oM!mx_!MK{Lwa(8rEOT|imtU55ndAPun8V7@XCBw1WCxnRD+sf_5A5GT@Brl zUg|~s?Wou9#L{udfOoZQhU8EMWp45fm@dDiuiTJr(6sxk2SvC0O(VAD&b{wLXBD4q z&az{kY@#)or8I}*R`$7s-egp5eW;*YLRx!C_GzhsLw07YNXt$vzE*VMauu(*mcmd4 zmOvyM^pRo0qA?t$Xr7E<5?u9q7XkQ?( zYG2z&Vese$XbawJ{M;i~%CucV{AKDjL;~7wPDm=Gx#5TVseJ?Ut~!|Vk`gR@#3Eq; zkr`U4#o#zntvFq!l+$rBX(v}`H(sp70TWjY(v{4H1G2GcMBDREz4N!Kw3+%)c%{i!h*p(&{7sNpJvXEtDDke+v+ zY_FQ1k#1x_SHxv!Uww2^KME;}pMlhxMrpVd}5U^`LCYO%}FbsToEL*RYo;N8`n(dSDq1I3tUMO@~a z(@B@qY*%b}eL^?ID4oo|a&RVDKiaMKf@ZT3$eJock;T-Kt-l?BT=3xT|q@lFWbbHS_56z5n)Bch5eqJpxnbtzY zVs9D;HPw@Qb666^N#V;H8D6P&IeQ*Gx!~N5;BoG3CWRia%$h`fzR6$2Q+|uTLf3qO zcFSj~_2h&Xc{&g;G=a|G*w;V2tLS1#&tyhUB{(f1!_t#KlKm9D3>ESO2UHqM8A=Ef zLQo9!FLY2UKdH8sLME=x6_1}D7~TAQxfi&L69V~f{12Tf7Qm)RRRKf84_pbuVce-d z_~ZLE2>-_S8xUZ|P%9B&#!+htA|Aj1)${`^yO0r-+7YH@tp$8p5twc;?~&{?(LrU1 zO$xz&eKZq6%RAlBw+mtk-Ea4^Vt+}bySUZAXBv0?$VSADU+T%w3cxeqihg{=(}*w5 z!iHk;C5WMR0a*`2VJDDF7_L+;>4<$`;e|#8+7{5X-U-QkV%+@WTG|#4vNW6qq}c>& z;HE1SY;GeybXCnDw5?|O~ws%h9 zTcL)6*gKU>Fmpg2eTAo%l~g*VrQxZeAsz~I*|o(kE)Z=2G@txgX@nDn%ptz3(!!e# z6HcihI|AkX_H>b?GuWsHMvDU=jiIlKh2N1`C3Czznu$EDrUG^-D3?g+PFfH;6y-GB zqRO5ru7^^{!hWLhGL=_60Go+Vaol48mz3Q z^qA}=JXt?(gbyvd82FIn2rlJ`{g3m|^`N%+BEDwEx+jrOlK-1ptRp5<`a}FTr}rNU1pl7_E`S*pkacqRFm-Scx3M(0{~v^r zmTIVsA&MEkXWL=ey(7jHNLuVKuTQTJpN%?-D;rBK$-=65cH?xuV%zM3&wId7w?+_|O6p*gRmO4r*v=cWXsJ0ccK=*WD>+833#iZTs#T!E zs7%whGkVZp^I3n}vjaISpmwqQrrqH0zai`O86%C;DWnEFXzE%NVrQ-}>#)=?Bm9+x zcKm-D7PXhlqZeL|%0AAo`85Wd4u7>ePbUO=fy%X6g^R$gb~@AbiTrDq%s;m@N;|fK zmYLTfh&I(?R{9ahnuO)S2QOF$yfE?W){$23*SKo@Oim=u_g3qvgPJr5HKXL>WPX;N z7Lr2PJwKA691y|Jgz>ElIpH=5@jX7FsOC1+0zAK4F0R|Q3hGZZ??ASblTkYzrbnq7 z0PLpZmO~wXeE%*k;ou`ypa!WmR_;nfZyjj~##gusHhez1DR zqjpA3d=npHwp7I*uY8vYe8tr3cZojB0FbH0sRqi6n(!#s8KpLI#b%+tD;y#hTA|M_ zD{v7MkqEvv&bZ_M?$h{WXx*D{Q=TuT@gUng@@yKnr-#}r0T7dp+0%&!IW&=cv?gMb zuGVFZ=Z*w(ajmE#M%*)hl2WsOpg1)8fX6_NEYw6@dwcaVe8x{$9;TwRcyjetFG!SMDs#8nqkHnj& zm<~xPxe>|!{c)G*Q8;PcaU6aDNvWm|a$ek`Lvp$7i$i*qKE%7y`9`&C%h(n~uiyZG zskwEc-K*hZE7Un?x9rv_ZjY$}2kP8EP&tw7E)3rov-H?-(!5$}-WM5XFUjV#j}yr=5q6egj--@?H(CQu=6@ z)H6!6r_))WZ`Q92)G&69pcb1`3i^o}C~`E-(JvsAK5sNck_tzHZYfMy$~}T)xY#?W zZS#&6*I=fm&6 z>UNR;)sCb99fw1Zfv>4bv8%h{pr7P(YF7^D33q_g;f=eHinkx2@M%-rvecSs#X(&= zTdg#0laQ?`n7**%sHYichsq9l6_xM9VcN?6%ZtK6CxbXcvm2?W<{SB#Uda#$sNV`@ z>f*@c*tv9!DNjz4|Mi$usk^jlMV*op+gW5$<94J148fV48e>FBU$!Y+(}58BcJ)$H zVhp=OCiOFHxU;A^r4Fss=~wOawh$4cVbC3=JR(dbkNJ1b+j_`vwiVXWh>XSGOmZyo z+q;;PTeGyf>>8IqLq$YMv#FNAdXj{{XVuYzOtG8;dA-dvku|-brPh2U(X@WjYO23; zN3jA1(Ua>^{bqj~IAvHDTKojm6iR>)+$Fe^E*7t(4OiRi5#z-9|jZ9c!Aa|&I{qM>0Rr(JA>&WkKCN-QZ z3uKKmTZYre=imJnNP?XCmxDoUP?L-iqKgjlx@bKOb{O+;HuW(c*|G$^0z?oYLzmS^ zw|`UP(iAAD7gjf6t_j))Igl@j;4;hOlB%_2$>W{c-RdLP*%4nty-CmBXeiJk>K_eqEFle zEl#OaykO)Dq$pfOZcmGW2T$u@Y5}{$>?E@W!@Aq?h!us126P6xSwo}mT1_eR@e`|N z@k{$qCBKyLRH4&cCncur*fm9Bx&3;6acwzhQv_9p$X4QejjPuKe}qI4WN5C4Wvdq` zbV_*_@whKj!$xuPLf3HZ!DwZd>aU@n9N6};m!c(;Wuw4G_HCS0IFuWCn6|EeOgZe? z;a@3zSKPdcO3fRs(en)$ipFcNgY8wN6uvokk|dvFJHcikv+d%-isH*{j9SDqhqD+V zL_^MLQSITo060qkvUsXG4er={`R{|^YKG+4?1z!UL=tceM4tG@2q{v@{1mPZ=JPA+ zYTXESRLP3rV9o|Tc$`!_ddyGYMd=DvSI}yQ4D+kdo{Sg+LgpR%`8QyH@jvjHl}4YX z3U9OOUDGeX3-CJX`fD*#gV@^Ob!&~JDC-6xHweiFlTDie-U{RIC5_Rr&Cza|E92^H z>^Yl)a*WPBbpK-7xl`z4#_IoyBnuba(txkDOL!YAm7D459A*!0Te=s1YXMkG^d`xqC?6-o0^YiK5~QMaLQczA9`L$jQgZosC@1X9JVtyT<9 zUVC>Yk%JcAZd8;4bic}khi@$L+PU|GUmkHGjHhpw(ZadkL!*-RytKy~YJg5fApZP0 zem^oofz}FrO8we7eYai(gKfbW_t`t$Zo_@Wt5h5yOhE$U(I4f!`r6{pZa2{(^3Tll zi8s&rK)*<=K0NaI1c@_^*59K)PB@`(j_4PhnahuQe||vpl;tkNYKgGt`!g)UDy)YL%}G%NjT6nDJ@O8hz6dV7o?bAc$IY2}I1GXrt@ z?=@4Ypkm82@CV8A>lQ1W_f=vu&0@KmAI}1Cz{R<3I?#3H9(^==i~VCOjoRuVtS46f zmrIT9*l;`AMLId@HbzqqHum_+`9O5o74xu^c{onz>L)6WNO&0pymYe47W&2D@2l@r4mzkzc`!lDZ3e!+ox^e?CL~*ORHGP5Z0#zT2&dRU zr|Giw%E6(9t3Zm%u$tji;!@tDrGB?kt(FmZj!PW<(-`8}J5fK{<1g0!_VPn7N-L`i zRJiU46)Z&SJ^bnKZ2;CaivXqE+0^c?5<7_4h5w{4rxEnXPbBf6%LJdZGza zyCMe_@(BJCGkXjZ!PW3FzMkUX3s>CVAL2448Q@BfR@@@+{hVO2eQ%y^xTyj7zLJ5k z1L6vy<=3@$f;?dQr?~7NJ+$)&>(9Pf09E=k=_|GACbL=bbdB=yLw8%iy%mEiq4Ko+ zclp6KS<{#C2obPyPV%6f_cdk=0k53%-vRn+GCL7#Ik(zN2QwWJS0dujhbgW>L}MjnFelrnhW`3*o|5~4t-eY@qd z>0JN)R`@`<#&1+uYk1Sv)2`tZtG06$&eVp(M>z4iSsX>_`+jvEd6S+x<*D{L!B|x< zJiZl$G~6K)Muk+5dv_$TV(U%kFr972&kH|CTSXvW(8p8F)8yrJ49=gFBpyR~VZOtq zRQHM8Mp2ovglp9^t_Q4ZzB~Nt*RgwYHyGu6ywBst+d#PR-JfK`o_^b4y0piDBOo*J za26w5bs$J*BF?1zZB&vJT|(Q)g@2ZH70AF&NTnN)UOJarGNEjU^AiO32W`@oin%>C z2J!TBXi|x@Zc>87G6(&-r2Kd+X5+%*-PO&uZMQ3W3I=Mt5)F{8pI&ZntXM#n$n(7O z6K7<@8(PM@l^|@hT~4yHi<%CLiViQ;(Hr^YxqNe#xN0upuuQa$sNry8aaWuR#d(MA znf>o~Xs!3yjmlfPye}krTihRd`(L(Xpqa4D(h0?^t>N5kq@HX!M2y8K+IvAaeHUNt z={(JH6}5_Wb$DQTMpOSRbPdz(G5L&8SN^FeJDxYoS-$&+bv7U;Uq9>O=4G>?bIk1G z=l&#JnH#i1pTkM*o4ATJ31o4)*&3|PqXt=BpTuLBbc^nYQ4=9{8BK@Dx%F}0i8-ic zByFcQ&b(FPh3KOq935FTcx?9ef_$_+v=^^MVkzImGi8R;t`-8(4 zBYRTO@_AmO_gLFcd^eE3@@euY)=v11CiFdoqpXba80D3IiUFpwv7lT?M$$VzxdoFi zJ;)u}qOKIL6*ZYf&CSV0YkI0H-KkJnl$@ll_yc&bb%9&_-i`M3XySwy5bhLi#a?)7 zeePbEEzf?A-TQj3HS=V4;+Pq7)LDYE7uOFa^@O9qFIS`(!qHde|HFy{q~&u@v(y2x z(l6$`TgTDz{rI9Hi=j7cS3mqy5A6;FUvyj>BL1`bvSI^9w&7`7e&S0+QaDfdim23O z8VvYV^#sy-LHHoMZrZX{6+#N@4f`x3;gNH%X-iyHwgx$u+>-4bOMY-TTTjp!j`BC$ z+z%GfSaiL5i%rOSaOEL@&z0dnKG3#Y6^gYIsnlR#qKTZEb^4&>$*Ss!u;G4>2VvJ0 zQCjJ0B%FSeQ^k0kSNc{p*8?ax#`nh%8XHHM3OCfl$7hT2fHf-8uEy@Tjy5Q^HZbzVa` zvso)Xn7Xp1y3U1Sz+CKiF0_6rpaTS=mKeQZk9k_^;`NZ2oAt;Z^D3Ff#VZOc-JA5G zS%JX#c&uK@(lMo1G=&s6EwLb5OE>lD$hse>^$=T`w{#l~)Zx>)JA4+Jin~U&H?|>` zqlZ@dMfEn&?~vvn zt?eVYUdVVhwM}2ES}w>T3?nwIf6F!=>JXgwM$1%81aS%)XRweETO z{}w3VGg7Q!Wfi8O#@ONle+Y+1Ss}~|Zh-$bldVWN{4#&&Y;hd;5lHnWzRoo(D6%^o zqOq)IbQ2F=y)mK~qOo=Ov*3@O0QANFW3cZFVZHI5fXFE?$RF~K#|=;!2GvubB`BhbwiL_3(~Jt!=5NJG-b8}gp`#*Pp)v`M72u;IEg4pBH)7;IyWO^@&H56Z&< z7aT=NKayHO*nc|-dG`P=Ein|-PsNoVx=bc*7_8l}IvbGA22#QU?=*wws!(UEpLDgWk}V>hc&i3-`scPPeoect z59)7t{_aRN1w{oV&cXu!5Cv-nK2@+GQK}lHL=g}_#De-zD}4cGgePBksPIN7(j)Wt z6(9W5W zh4o(*#dXZ_J@Fmk)RIVQ<8KXJ7s1AsRJ>zr)O}EcOG`KjO|k2u`Vsm+!+N?do{3a1d&Q?oh&GX2#w=Sc@qzxkjYZo%Q}zH zBzP$gte#v;LuhjDZ>?vNMt(8AWumrP;;hh&I>(RxF&6H0p9=p zrVoMSx@hSbW8c-5-8smUlIfd?Rj#=}gsLGgZ$-68x;j{HZZkC)Kfk5oj}ZE$Q$2qH zlcSSafoIFz&AftXSDMBl44>j0w)MPcxL8q;2Rpt~YyHOqul$oIU-$1_8x_ar4RFn44%w%P;yIVb9ef-7}0iV__Wz7o;!E>}S zoaxaqaj|bsGnk?tcIg^)29X}^i-en1Xw%D%Chn#sDLmn(yMHKt*nH#;(v1O}gRE-l zNj!FY8likgX^GzhdF$_Pav7>zSEK4^Oq6IB=)>RiH zy!TV-XP=UVNTNWx2$mjn>zDzw@5aP%Z1iHpDd3blqoAL%<0{< zefvLMTy<1bU)P2Kq`QYf>23s(mhKK|X^`#^7)qq;BGO1pcSuNgGo*A#gP9Si-|y|DEN(ofamDx=H@h3gP&^`Dxi~>F zz;(*HaHsO^{ymGm>C`-PbmCl*U<$2KD(>SCDs?;V-Y?)(&IB9;1crx=Y0*(a=trGB zD8&r1h`A!zN7y)b9-ZG)EkoQwz99`kIXxw5o+qNC#>iwx=e&{CsizuKDMZ+b6G`+rLLIRzc1f_leG8 zvqD@L%3a!qfE>%I+V(3_)000>pqyFwrV8;@V?rc~o@6-VbM)a&or~$h_7Rs&p&{Nn zU5qF4=-FoP)rCp>is*&o#^naqYuT2GPG4q;ahjrWo}A={bB14z2)Qeqy)Zk9>PJ9po=#Q`NPHZ1QGo9&CYrSnF>Pou5!pH3>U zyb5J_Zd5ytZW9+%frh3;j-mlQNS$=|m}TD4a+4qYsMRpOrAwr_S>H}xHOFTr!egG& zn`F)6(XGYLuf@w(Ie)M-SjuCYX0a=7UuoMgtEqL=cKSN1zRPzheQ=Rgf0CPcRz&E! zLMN`Bb`4T{<4AP87Z?@@tq4Pe6zB5qL2{q~@V4b*Qq{)`>A z;ffhp7`u;5N%!hAMwso&U({Dk{c_gTt7j|tQdpn+b^#P7La#U~RA}W?P}6eHaQnt_ zczfTzMVMKf>e*kf92KYS8Ei38>S4ZDBqR>>Q1(*$%lA{}C6=4bf^D{?%|F6KKDSH~ zFbPV8neFNZlXl~;5*pP*HHR@%{UtiqjrbMMb5|xAPOw>!@WqIz@Q>-}N0kQ#?hxM^ zh9m5x;BbIrQ+0iSNT{k_%x`pZLT|Y~@(kirT5{W)*L{GuLLbYvrEnzM^3n1DPe8D) z#g_VKgOw4psYwNtnWR(A*(>q@l~?kEmnfACCyM0lW_#MLG;7n)zns2(m-XSR1DEUp zj2jm`+gz%oqUix@JLjJK(#EiK5Bu6$k?7JM@0082dXI3lc-^%m)_P1D9^-nC`H}*qm!av+;V-%t z5|+zZiR$P^*t6j}r8liJ)}O0u>m0!^noOGU5At6iCcu>e+;qumP`rM%ce}a@DPO3u z!M<}qX>QEaq1i4;i8G-)+7}CxitjM}hHGYONPB!>pQ9HH{^IH7yclB=Sqb#SS_=`t zMtqj5O|emTcT(Yz7%9~xUBBg3TIf7~=6%e<%FWf%HWI0o3I zYkbGNPMh@0+#>TzM4TFJ^7nn-YpTDQM7h#zlMCi_oaVjfR;^D{kEu!g}&Js96;>vsD4% z!cTn2>BKDIi%+0YZ8 z7o^FZhM3qgy%geo7jSp?i@1YIhweG;l$@lN z1SSoE8QGZ`+J!*a%VW&ZFUYanv8a$ug4UEIs&(pq+F0f%aaRiL$hlb1W%=a+Y1gof zQPu<{;~2WLa(2C825n`%l9qe2+FHmgL&HgmfuR>8 z;EJWyl_SuWYCepitN9d)E(uhWr`4DiHYjV)2@qhF|M~7ItpHRRpE11HnscS&wEH?x zV*5p(!62QB zo9M_Uv*ah(3|I6^0-p+pxA12r^)tcJV!x(HyWn{m`kK6u_bexrGeoz13@Mr7TKWYB zuk7Tpn8VhgCDr<7H6kiULt(Bwg>NG}Ye}(xd~+koOhazK|B;$8$n;*~&2t4kK`lws zvjxj$^O7qx?T=ropoAcnoeVRcvn0=GEnmsOln>U5(vaclMwQS%4H}g%Ke)0v2-cJQ zlu-7s)Tw(mcJYn|s*1$H-*oT6yF*su`OT8*{gbhg}e!%ab?AoKYMVjYC77z{yS}>qXrz!7P z*Eu^B@Qn*J<5i-sxJ+P;6$M$(ve@);>QK8f9yhLbk#$(66%9J@iqs0qyM}D1JED7` zgtiB%^l*VrzeQ5xoX$t$dz|t_nSMX&0*%Tyo}oU}DKAZeYp4A;LFmy@%7i!Yo6Q60 z2$X@kE^6W3#g=b1)l3N%%2QCSJt>m+i*U0`pSM*^G>)JkU3!w?3J}kHsV<0RgM9X(rx5W>+=Z-DdJ~cTk#jVgQ`zFmTp#~>xKR7|s7R#r_II{P020@S4?HU7r^wif zJYiJ>2>`XJo(##S?xx^U$g{{%jQ$d}76wUZpGPbO_0m=o{U*O?B6pxiY-=E#ha(95UCF@a&(zwOsyIlw3*|vCXbr?pV@5{YN>6ZjA@4d>@zHpxtyH z>QOY$^umFMsZm+8ajxWTTLthvmvg{dSCYu~wUFA8go-sA7E-dFyVfGJuqW2=)@7*a zgu%OSyA#v~2EdiHTx{!IHwgb6-D~u%~l=xIcY{e$O~ZzYU8F zV#0C&mAoZhHWgUKfDI?|OA(*ZDo$5Bi2Em_*7^T69%tD`|6F zRf_dABa#a^1fD@grvvt$?z`$<{_W1L`_mo>{d(X2MUk?f#cWy#E~C*)gRkCdODrWm z?aI}v++t9NJ5@%PC`KJGSLlg<6Z8kMRdQ3_rEhz(p9If}^n_zDY%ltZTLIdzUhyS4 zF?t;-!%6=Z6XO58^j*BdAkm`qs?3Hga#o($Ij=VYC;pHE?bOed^B%@;vhKL9%<_xQ z!Dk<>-;ps%t17f_Xfda7h{{@!hH(DDV=s`+*VT6taYG_dTc!Q_13iCWo2i02#`diOuVZ{rd%|YCfJ6~3 z705b0heS>{H??J{8tM4@y(#~Wpo%xk-`JP+9oB~Zkl!5d%<2O%kLSMbes2oBur-zr z|Mn)i3zJIacN5+97F*&p&N!N80-jWM>yt?oYZuhq?6D1V=0HxHJB`G9M3h?O_w68T zzeA0&33$CA13m(R2r%hS2b_I?Ku2Hic@e@@irV-`^I?dJ2`thsQoD)nLBT>gcG6{a z(&Z$q99V<#IQhIDR#U+g$1UNJa_Y{KE~LU5Woy1mxc6Z@moK~p_S<-Ydb9(5_@AF0k{nPi+zDx9Zh+c|KvNFv4NrY0Hmb9EM#ssaq(arJ_P@Z5!^ss2@ zdA2-|!DUk9n<@|kn+!NnJ?h;REO~9{OP@0`Esxnei#f&dX8K>trD#;L(@wOfW&?jP zmV!U{_(*l-`Q4J4h#3blRvC2xO4muD@K<5l&#xsbOjFw`98%=b$MG$WkkR}-(+VBE z@}KulQU)b+468KIIj|>8K@B#T^9s7bkm(VrPp11XY#Z_xqZp@5nDPG5qp=BM7pqFn z6Q4q=5F!|9xP#*5h9J6b9_ZtQ^_3EwNXThX2ZD&%+LW^zwhc8kcD4Lv_4!7$GgFoV z9Lpas!19`IFn(@h;UB&Q_nA{87K(4YC~6ICQ^FP*oIeMI8M7W2LpNemQ%|w|K{+_A zuVyoQnMC$FW19U-8@Q$8OE_373a+0ouKh$Hb4A5+)jkKqz})`j3_kb2HZX`7=*I_> z7aSR3Aa&FEp0vgNER{;t|D{Lx#hY6G!#0ikT#h1$eW4_5ji&DptByD$@_4 zq$mM@?{^Gc4lRw1lkJU$hIx$jee}kLF)F%kovA)t=-Ucam^eAVDgEu7_L7pwFydqD zAyG9ObHY=cY0?-@l5j$TWQTpOK<-~x=~9PLh5!`wBQGJI%wrhcXpLD_fkT*wy= z+=_G!_sVM{jdFvH>0)$6FD;m>w(eqXXblCWp_Q<5F3_eC?-GjM7HM&eD1I zs+wi3^G<3ngJdPjNr=ZlLs(2`mf8!w2C&%sT`TlT=J^nH6r)|ODpEV5)>uA*6}+bW zFO4nO{W*ree!qt*;plg^20PFCJaaj!9+Of>`FmOz+DOzI<3-dOwTywYCW7+QjqZCh zjCt-ec(}%M8h?4VX!M3kRPBV?;2vKzYs;hEkjSqK=bk8A{?bsKT}K!LXT7SUzc-Zdr}IX~(^WGTuqsS(XMhkBlB zMb2@nwg!Q#aY@5(U(>Ag%!Jlv^{9!{Q=NUJ4f}eW()U|^>dTfrV zH(u}SsY|W|dXpv!h^Mv3>AT=LY)HCC#tCDV`0wdq`c`4g0gk165Q#w)%soFOK_rJ4 z-rtcF<+7fK)yi^b)5igBT#^|)xtZ|IyI0Df$c~qJi=8?Eog_xhHP|rc9r5y zwE8J#TVg=B%c)QR0d!5*rR%qDl3z{KuZHvu!^q98uTO`x#>NSQa2KnP>|8YCQ84jh zGq)J$Mj6#P)|1=S-3TJR1lkF-Y#N`e8-15jVqTzR;{RPYcBD2EyDQUE7Iq998)xXA_> z4zqx?_#Z%-!_Od(h>(xQ6n*gkf^y&jH^X?4|0OEGYrg+;22p7mt_rZ-(zhOU`)e*z#^b9^9M6qhZ3k9WdSAIJh&&LQlJF8e@s+BV@v>a=nkA%(*tPZ5MXo+ z2c+ZysM)Z>T^7(s58(N@5U9rka2YoOsd~dtf$qy0^gPXK~)g&q8zq=_22ttppo$aO6XXeu@V2pBF<+1O(wndEa6lK)Zny4|&y7U=UH_L+E6R5Ata3_$aS833vsw z1)ZcnV8>z7pr2X5t2AanY+4+2mIDM$n}d)G9wN9iLLkH0$G1_KWJsQ>j};n6?p>kbBp_A`>G WDWbsF$p{Gi@ZUasP|4|kdH)CXgbPdn delta 19998 zcmZ6SV|Snp6Qnb-ZQHhO+qSKV?ul)4V%wTbY}*stcJ?{%*)O~2^l#{{zN%_q8mzYw zte)-%Lgkv}Di{O^$QcX>2t#s#8D_HL4|IUh%-+P!Eml)c3r!3CD=yRA7$3q+I5;Yp z3zadlWm&VnS@sX{4~8H1;v0x#Br%GX^J9Z@*I2%vP(4p2N(NQ_FwM2=ODkW|U(td# z&zWPws6kcq%b9HN7aPx){!a(jR)2*coMDBiBld!Ve#nn|%MD9F{An-VVXdXk=+^)m zAr;&NAw8QxNkY&lSaEfKRgy(BxOm5d~Z8G`p-x_6-tcR!1 zj|#7__x>=ZY-$wsCrqv?vKY8O1dRa;&jf$;j}+g69J(;l4K3XV#ydOrU9ECR^ilM} z%pyxB2|n}kI6bN|raR+IFh=|%P0E;XD2bl$=5k3TRyQOwMQ+6m8{|?Zt}M;M6u%!T zuauvDZn(aJdCf1tX)RTXd2l=`v$e7`CRKaTah2TRD>zRM18BkP z-i7_W1UOzA8PsF->Z{aMFTw!5)Xr#mxwDFf3(_-<#aU*GQDKVCNK)s;pJ;t`{$8iuC5<%0GZFD2O9AeVZzYhjVrcW%dxWrx~c6pNn(26n!?4dCC~&c!-KvZWBl zJQ-RzWmj9Uj!Gle#T##Zh{G_1M{x`X-@C9n1gh+STV z^_AnH+red%76@YkUFAHkja7Pw2ALk~S#kLDJpc60H~S){Z$tLi%IG9L3H8P9b{2Rk zJxEzRaY9>LeHX@3bJC8IOmk80s_4_r$;V;vYsb_?1sSi?s03gn&y#<5E2vqr?)f zXKd*H?uq04)i@AZxV47+6eF>RA{k`O$S!~F>oi#M7ulD7GC&L|SX%Kei7!x5_nrFX zN52d5z{8wSY=C~h3BB-uL%(i5TH*(WP@m78DOU^%67mSODmc05U%dHdxWpldoIyGC zL-v}o8`eNfL8X0+d0w@$ej(q~X+ts@p;b3n$_ea*IR>C;O%S;cjZ2}QPC-M4u8 zS#hHf>pi3!DV*z+AOv=aXA`TVZMSIwFUO;m>uaGOnn1H^Y*Aw^~{qBecUcYD-L=jfNYP4rJ}f_L+iV!PnszDE12D1e2Q z7A^A(KB&7{iaMU-l8ZW5_!~s%&Lu=78vgYj71u33sOS+v_E(n4@&$Wn<>eLj)&_Qr&Rq zD{B2Du?W*I#UC~7U@GI3a5!)A&p|{kFqVP>ApH6z9Fg>{{&#dyS^8H{sMp;G zB*Wbf7;OV2}L?_A@AKi+yK zuXsy+oACrb;AL=cc1g5-P@ zDj-(}#!r7l=Np*6>M2`V*nRBiX;i$>Ubf+jBbbOplj|{`NUBaf828-cmrsoXwAOtVY6|x(sgXW6 zVs|>qb~@_%W@~!gY%_d=|CM{UOuW3m0tB7(Syioe6=bcb-=9~$B5=I(p#8-eblPo0 z@Dq$64xozoH*^hg3m;&_0pxpsDRThmgNPpuflSyh$;4^(GeO>jM(PVjs#CwS zU!sY(t5PyKlr}LBCKwIQ+~;*eCb_2a7esn1=i8|e@StCS7m*xO>wE;huQX2WI55~ zI%bJBy-CPdFqh0D8zH~n>ZpBu$o`@?EzgtTlF>jmKxHrCjj%J#R5g>XAzjK;bsA>{ zQ^H1t9e33+8JBH2rxnx0YaC7i>S^o{bgahTh{Mc-Y48*}Brfp^C>zI8^b|U#Ql?7n zSq?qbTC?W!Iae*Ei%1ketLPG)H>cZkWqD{s%4ZY|^LP@TD04%w@LK*9)0N|0@N6&m zRvvH87JON2IU%ie&TL>^wzlVHSV#Lf(z7%uDKBKo7xVM&BCOpuo5?l-`K@(-pQXPG ztRM7`RUAnZYGn`YL_9`zb_c@WW+b{4i7LTyrC|q?(a;bNYt9ur(Hzif1u(tV89SaH zn)h2h&Sj!lxUU+@@ZZw^kc=n{CBcY%HfQHJ=c-rorQPL(te2H+3PL5Pquv$^EVup2 z<%7D4qcGhL5Rn={#ii#2{8=nE5_(rM@r#l?wi-eflJjs~Hh=h%Ur`@ZNL{`pTn;aC zOFjHdW_be!RB6?Q4wAC`xsG~t*p}ld(e@i6o6qUx5iXy`A&1n_9xvwLs4h-(IF7Ux zt9R1EE_z@_?C>tG$7LcZHV{Yl;?j&)&CFyuO66$in#?CI6GhX_ zSqFP>-IKK;$L%nDiih)#etorD`kL8_JXe7*ROuD)AJRU4`WEs-nTTh}(n^nfvd_5d zicUYb6ixfH&FSxXmNVt)NG6ZX4oHFRDMYQ;_Net*8kC83Y3?Ff4O-<)dEX!n2sfXF zZTIz}1p?ow1q>E|(MTubQg%`acivRGio_wzp36L(gs;MBoX`t$E5mpn)W}KiM2VN& za+DxN;kVan#p+4Fw<8^1?T}=7FN74FS(rXg3mr=yd1=fljn#9lSfq-3iI@0zFtj=?~d)hqQ#j+|`8#(wZZG zX}cz-3kE99OnX@bOFr4e^jRSWE^F5#cu}KVeT;-aR@_D&oA%9M%^{eoZR?Z1C|MTI zlmZilfi4>Dnxa*ev4q$fK~NOu0r@bxu9g)PkG4LikVZa4QU(1lO$xQ4L9i?8WPWUg z(k&IKRBShZ@AqnrEfHM$ZMiLB(+;Uc-@s2enkMmDUV5(a7i~9;-2?qf`&RTFT32Mkhv&s&SPg8N z`U>;|rjyips_#U~3gHyFuCx8&HzsgQCUK0)QEk@1Z#`FOL_JsWxI2B_eh|6NgA9t1 zl8pqkvZ8zRlH4+y4n&q#WoJ;9@HD2d@vhFb zM~yXs9j!Sz9acuPAi6TdhiCUk{7CrH4C}-qFff0VSlmR_)d+GXUdKU2<&6}!@gh>z zcz6^hoG~)DkZ4k=W-u}{{)o+0Y2Djq$+ta37BL37A#IgJcM;>}RGsocimlZFo&?=L z^^m;t4ehnF!kPkyxiWA<@$uTIYMOcJaA|`;=&N$wa;vI+cZ=9S3I&Ww1>|vGxbWZn zX@<?f!J5&Te={7}6-8 zj>kLoZV&P_Y&!vK-&QWROXQSOe}7zt>?24+%@#z$>??Q__kgAVLfr>~mnkGJ6d5jBxskF};FNu^~7tUP5k zeLw)CeIjkLoOV%o*@p$nPSY_ZxT^EQ**4FVT&+e29idT6w3Va2W+TaVBPojAUgmP) z+kx&(_pY8_l%7Uy*8mF6D-%JEWEBz6JbLomI=l&sFt~~-dp(R_GL@G`Z@|KG^O6aI zm+u^tTa#Pq+>45zCg*>5RVmj>6X=w^cM9_oldZC(L5{b{f2QgR&D$Tbt+cA zX%Yavsbx8pDPb4orSs6NeV==DGNQd_dIu`@w=ITfCdI{}Vph>__y>YA5Uzvd zgV!DS!ULEGzTnq&9rF`YE}3>(pE~dE!?KW8{(KZFcFyd3bY6J)X#h9aI^NNR7)t44{$n#`(eRD>Ci}E)@7%oWr9#=DA)= z%+7E?X-@OEY>c05L%JNzQzMNA$&xqfwOC1c^K|V^bYz)zvJusDRe9%FtQ~wcSN%XQ z8vvQdaT5SGgX6s|{5KE{ndorSJeF~YBI_LQq+Lb+rq?x_#S$`aSYjSk2n`{xPDmTLT#?_2s!UgvwF?Vy=sz^7K!fk=UKRHMhI$k5xUx(kRO49rECHB{`x)uJa;EAIRo4^QbzLq_+9$ zKZ6s=^i=_vi{x^rDwqpq^yG(iO~6AhuImTrL|f8k8;dPb3EorEo7{_qq;rzs^gN;2 zV%?s^(;Eybk(rXo(>{ceQ0?b99rPi9|2sc!d_bYRUFJ5GmrDnBMO{|P=}!L^Lz>*0 zHr<>#o3A+UNE*UT$~q%_F>=P<~BiHXwZ3!qBAr*2BM04?IZ;leGl*PJ!Ld|DER*^~lvH zAW>A^bepL2H?C(m;p}>z+IkqF`NkF8+Sxu*Y`GFKyROq22-~;+oC%T8*9r3iIWInR zlT`@VoJkW6uRf8rrCGChoq?Hs4{Vdh4gcc@$YNb8Nt$~`rq35+&BNHa!X|0w6qoI%8l85Ex_-5YqpF6XA8J*uG#{mDL}!97qmq!IS+!TI z{8d;U0XtszMGznedUij3;mDcoVE<|I@7|aH`rW_hpVw0h@b`xFmx8w)4xSjNltps# zRI$DM8h*41z*dT`%~GDBX*_~Fkdnjgnxb`!vexBVLX4-xDY1qhPZEsAk~2ty@jRXy z|KC)+w5z|0!$0pPyB?}dy|4?CL0qLT%y8~A3$Dbt_!)85PKX@Dm&2GCLV;I~Z;&X}KQs{uK_O^H&>7_K|_sjCk199Gbh^ZBAZu zF^KI%J+OSX=dtFdSzhIp2a;I?HagCty^BYlfJn-f|IqIl7mf2))I|ja^$-yvohe$S!>oC14N2_?n!G`$e z(mVP8TyKu;+j|JvC7h=+$6udkr7!BV8~^!}gMEcNgjcLuw~++c1D6+8}c;PFX| z+Ao$85wd+)S`fR>@muG1)GkK8ZG~L!a4MNkNrg5TxdmUxB79TtalMJ-P0fWvYRsn8 z4HFPx70CDGs~d^TqYt z$3)Pp*BIbj>n7UZcrXqR%UvxoLF!S`YpG@b0Qm&fT1h@%F0`>g&>BFxB|}i!WgpnM zl(+HLoqpaK!3_xdZR;(`DU@s{G|~jXPFs5;&cKOx-glncyo7EFM(g<0fM*T!6%Qo^ zx#1o;8xFv==kKKB283d9bcdvKeBl0_yMYa;+Vz_6uWHZUJYl0BNIpBjsateWnw!18 zg@OPUZ*aegcRfCI28?dBV7Z8iGZ)U$YwW`>y$K}V4cY#Q9JzZV^35^iBjNx)eGR_W zj|e{txo)`-fb=h?WUpqQ3i^V}w*F!oN`?YL<<5~qZ+qge|{Y~8_~{BpvIq4y&G>*Y$ZuY0r(8}hfc z;=#17))kWiw3T^i^f3CrtU$vSX%$!CS=sG8o`pHXN4L2eu)c{8>4X29R=ZW2-b)`eO&3*Pc3uz-@GwkA2x7piV_5H0L~H9f6sGatn$7#nN8g_2fSHly z>sQ=+CXtB00;_VDdOWyNXy{K|lq)l$TFkPi(G$G8l}M1mkMWT%mJ8GaS*QbGz&WTc-FZH$1hKn{O&DQcR5@Wl-e zI}}?@NLnl1YD)bFzEEX5F0IKB{Bku@fdk~FKC&yzYP&0*6}V+ zHNL(;a0SI@v)1QB$o?*BEn)KV@l9T%wO$UW0foL;0jefMc2&u%_Y41W2r?4XaxFns zZ`Oc^z!&51>pVc3-<9whBcqRz$LDwNgtBj;hhlA6vUiFV%xnt5P?4K9pXZwpQ!0a$ zYAGr!$vcAvs%Wbb_9TM@Can zT2WA3Gmk>ekV0#lSn5k;%4?Qt+4#41_$O)PhB%WWmKeA6gbhpBk6RGPp(bwPypaTN zh=Dy1d{igXMXOyD`l2np8xc#9jI`x_&$zc+LwE6S`st> zJNzBGZ3fHxkFvgt8aHiP_nDRA3Q-l5Mo6OfgVtm}Gc2yZy4%d1(8QnnO)MxRlsWvbQH714?d)X5 zI5bn#Hj-9A(O9Boj9;9G8p$y&|Fq=CnVF-jTV70T`tbe{48Ka2jAP!U+NL|0QtEKk zjf^Ai#De+P7_5?)OHVf84i4;$`vN$l^8z7bN*<|A6b7Tqg8HWM7IFdEII-;%h z+^><`#c*%^5D=4)a>sX0(M)zvRxJ^!UEXyXfJLPD5zyNFK=xF(yJ%FnwnQ%)% zA?F;}!~EGQ%QiCQfbV?!lX08Y9;%6F&;*5XZ_o2*9uvO=MqEdQ2KxH=F!Ni+{=B_f z`+$N-ZEC3+r6*0d!ERmGsbA*CG}dU4Q$#mb=P6o`v>;PbTl5e+7R`qOWeX?%a*>7z z!+!!;KJP3GBlY}j*|E0PLBFfi^R=_3r3x3|tgF@UN}?&d;&;f_BwXyTIgFKLM|L!r zWbdX$jlxN8c@Fgw9 zjXn1vug0oSU85K?!FZW9rwM~8HYHNP&#(}*bm~@b9khK4H*6N@@D?SkT=($$pj{0Z z!r4(e9cEH5;(PoU(Ul*vD*;-+0jgj5J_eO3r zPME@8|I%STiH0iJW)CaFfG<|f81uDv@S#G3y3vA@Yt1-l5_OIoTYkv6ik1SvB(;7D z)I$?%Lg_wckkIK3o^(_Q*bZE}fVq1xgs6n!=1kqDVFvmv48^^*_WX_g&rM1H7xjcLbZS4kj<9xM{v8hm5^(`4|B)A2?Q0%si~btW#wHh8w4_bjb%`M~@f+?{_Zj zTO?LY>$UT%{3jZEWmIGrK!-aF50E<+6I(m}Aw@;72{TcwheG)yT=oYikz2u{st6^r zYGOYyUm|iNa~M9CnCuNCq)xVDYcC~r3Zuou9w)Xl{o zSblIgF6uU?mlSJ(3;* zxs4}J)Uf$PJq}S9PVzUzZOC%wFD?UZnKGZaTA|RR-bfB)aykL7D8pfm3U0hGdQeHW zv23no;UwiPAaH`!EuZL5MBF&h^jq_-=V~(7a|P{|=}S9fI_NS_6uBSFJ*JZ^TiM;- z+Oin*EEJQ+YFH_I)IE~P*`=Tvcw9tJmz0v0H_aA!C5cbVIFzhY^Pp?o-mqrUhpY%j z_RtUtb#mR_y>tNLE_y)|x3VsUq{V);G)+vdtcH!Co~#Tl$^~_wtUQ%d0w1jsLm%yu ze+xwFJ~?^Hr>JjfvRDgT8a@exs;90!uz0_fD`=v7%I4cnSyMfc8?T-P1|tze@JNkQU29w>bj(IyzCd5{E?hQ#Y3nbL>(O z5ToO5H#M~XhTE$ApuWN9DBRZaZ*pn>4S7{{M_;SF8h%xyAG)g{I{66f%yeN$$9fxOwOvSi~>ZZ3T zY?S(Ddk9=`G%I%%J2*-8TGLG+WkdXAKj2tr2a5%+ax)t?^G+S&CF^HT?nD<18q*=_ z=fQi&QTLHI=p?GRkb_+dNy*^%(p)hNkEtq16ySADTa1*YoCKPthyx(gCX3W5qNrTI^| za+H=n1sH2h3SXA^Vr=7Q%_<`ZWXoA&y zxE@YMrfLYUThG6i(lVilaIT6#Ki36BsOu-Ik1;$)9dS5LV(KRsO9w;?PQ(5nO8JsC z8w-PPTp5U)M$Vs zrQ|^z8|Erw9IPIEqJRZW84w`2=VyOOx|7R! zQ2T%vy0laJt#8$Q@>5~%Ib_yPu( zMbygox~gTqYKm@NIp3eiJl>yAvDh92j|FR44wh3?O1Xfs2Ba3c1J*ylUWrWB!~tFK zDLJ?wU`{9_R)QT90cLOEs9K`)=cs?n*{=Q5a*!>2-`A3Ye4j%}b zwRX-;mFxF;{*;F|M*ECyrLftv3v7s;3E~>6cgLp`Cix%G({4$TJ!SCuVO@f|7UqVf z8sf@P1&5!qhu+So(BLiZ%sJ3F3Jgd7Q?3_PZ4tC*YkB3J~0G|ElJRLWEz{4I8yK!KG2xqnm?gy9TWqKex~&yF%&3KhRn)Utg>^$J!o+g%L^ zj|=#$m#xq4x!nxhm^PKDG|YV)yKJ&PIdP9vB&W_wlexUnPqTVV!lS(&|LmxA(ikn8 zvMn_R0g^>q;H@(yiOo2(tDtDM?5SBcl&|^JLb;+f%2K}+%kHfa9EM_udqmv@CCcIa zu~Zh-P2j*&mfFN**4!bd%J@#G4p0l!Z2zQOg(U6ZYI|U9AsogOJ2XdM{Se|oFY;~Z zN5mC*quGLLVH~RMx;+|nqxp;pKxErO;w?Ei0S4I1L^m+T)lPndKGlo*Mwa@C6x|li zstby;p;vyygdx?B1wSZ*n*9Z35wQ|Ok>9nZ77%8`wj}r`$Cm91dl9c}l3Y{lBGg9` zMKoj$(?3=dxjWxC&H)Qby{pd!sZOXF(-fNcblY_qgs*Bn4QqoR z4CkiEfbn8O1U2Dc3eL^H4(~kBe>#wVD}b=y`ZhkvX#TVUpcVMq4H1aD3dMCYGDc$Y zS#xsRgUOAPZ6osWUH@X7KAe!{)9+n;NJ);XyraOhp5{flM`=)5FfWTcyw%xL2z8Cy z7@QCKhpvd7Y--IELl^chN{9Gl7;d?dW|QdG>j!>3dp8yT^HGxz;`_0KXYwbz90bsx z>VJy93BVQ3Yc~F&f1-{3EsH6FrXkimpGDXTMk#`B9X(Ux@WZMOKApK<{ej%>yU z4S2vfywTs@e+v&W7^O{NW<~Z7M35JX67cH_az7P@c;tLfntdEkN-PwnrOF$}(wgug zrz(PYOqR}u2`d}+j$j8Bupb_Bn+t(-P0mMEhh)Fsb7EFc%DLhhKGgLEq9_P8ww2BT z3O@-ctXe|7;;S06r`LaZlLwkB3@~PyCmKX+i64D7_hfTQkE|j5(kC%(nwL|^_g0)9 zc6`eshL3k#UsO0AH=efaz6cEI_%(O9Xf0S*;sKMNEBDj-I*8^fZ0|~Byb}vxy8;{a zRD;;-a}^IkP(Hw14<2pCQaL24zJ@4qw6213zJO@?gx-WQjtgeq7|4Huc6Nil`p&Q! z^aODQ!@t*gqj2wn7(3@-V{e`_=Y@aisNcZ#$us=bKzAbVGxtzQ$NX&Z#_?7gu47cH zCC^Qy_+y8enFa(qI2SPM=fMI#J~$zcaa}v!>g(uiety)cTW5;a(KM?T_!N?{L-_kA zr7uvSFld$E!iO#+FoCbFoW_bnIt`?IPle<#yvuCJO>G@i(M{iaCFgli@mzE{bg2>M zm^HqWYXeckKTP+3Fslr6M~jNWr%KLV%h#c&8H6P88gh>&{RTztx(WwK@x2-8IRz@= zT6{s*WPv|rGp>8fnx(-_K#!NQ;3{Y-|RW!ZpWLX};&V88JfA9y5!_^N( zJ2$2$gy)s<%;wc|BW)a-Efbw8A)A8tS03QtEl=iioieEX3Z>zrFBZ!7ME(($eCdW; zFuTG3%7#3a^qUj)_0voLlWimW1@#J25RRA0IppUGLK+(CYrQPoO{;Rar;fim>r&*rOi)aJ zJ#rD~gc5ZW&58}`qQ*H|K**Pa@WQEVn^1+d2U&$qa}nbx%7+DzQdn}g!|t{V)JRTQ zeUMVNp=yv4I)%VXkP=b_#UmAs)2$C$f&i)B?o6A#4WGacO=pP=^X?mOnzL z(xG1ztrZvV>PrH%HNSAop8!9}H68!@PBIP%qM9RRBKl+OW>h_LHVLxT7phOXL>foQ z-@P0_Gl7McmU-;zVo z2Xep5gkcJ46b{U;1WGCIPJw)uvH#qp!ePkKqq*;_&}rbaG@c}!?CV-Uv}1GTff~#6 zjlItuK{K*6wb1mySqsoPXK%}}Zro`powb6&M1T7ZVL@l6I~1q&3VK0dcI0v9$zz=$ zx#ecFS;{g_9NuFpXBsd)c3~LyQ>3qz2B$C6`DJ0~06}ggOIt>Pabn)UfJX3sg;s24 zB_%plRiI7)6U|tT6ArzR7n4%mIF(v>07_Bi>>@Iwxw~gthI6{WJ`LN&n#D$U&uQd1 zojpGZQ|-*z#YPj%wjdbAN*x_O=BKGrAsaU;iro6O)th`OHTd1+tJMVx>*R=o()t4g z#274DSXT&8)sw>$LI0YzY^pld+^_tzCRZpp_}D1%wyX*rr3~FVyC?RKax6h!-)q3U z=%o%FUXI0hoSEUP_kNM+ z&4z6Ppyl5$T0}K1QQi0=O>y^G>|V~^H_>HV|C$EWZ;!fDU0Kg5n)?+<{AKd^kT}?S zGbWzNid>Aj7c5slB!YQdzj(5lKeav&*&#G{kkPg;S0_Z8$x;Q-;K@T`t0|Ju3Q{Af zWLBUl=-1XsCRQqWCN@O}XuW8@f#T37%0HCLR>L95Q1>AB4zFa2e+PyDo7_nBnaYpGr4|TjaQw}ewX!6{QnO$6UeUaVg6_D>irjLru-j7=GVsn zY|QYqFa*rxaCHbr;!LSp%&>-7YUtN6Vc3N?A-g$L?AH49T;`Vv^w55y{w$7@j6|@Y zNl5djQKn956k9W}E>;HnoOUwh^RlF0tCinC^11FQd%xoG`uRL1^nE`p1d=oKj||_H zA;L@m6m5kp#c?zt-9#*uVgo`4U4x$h5CP{|YmlG~-5u4B6CP4n>!BDZjjDl;+eJh1 zQ~iqG&tw+F=qtO;gm(ASEVk0{Q#_iHaz-^u*lmqER_7-g#v+T@l{4|vN%>1UpfxnR zBL3DH;Sf%>TL5ZA%l818YEhe ziREaC0Y!u5+(#Cl77>MPVX6K10*D#`EAIFG22>~Wa~7x4wv|c!wPgt}_ZtTlsBKi| z$hCDtI#}E+8|ZT4?#lES90O3C>G^7^*7Z=(t@=Nyw1D%WoYrJv(Ao>2*YwQzVW04` z#r~M-w8TR;rhsZ|1*Bwmw-upCeco-jIFn5_E=W+R!n``wVPQ?y;^|A_bLT9LY-!Ei zLqAZIsOw2PcU_+?D!@;a0xJmmKCZ`;tO)B<)TS*qwqL=_c7dfj3GeCGp`@INdkVYR ziB=HSK)^q=31`)4w^K1dlz7*m`M#xad#Uu6bV7It30>UUD@Vo+Z65Icb%sSs%yZQD zD!OLKW}ZCsx2{_9AS6tMzkGLqyKXNWm-41DY~(g1EZ$6040oY>!*5VnC!8dXE3I1QRC^P_nmzYsowjotNn+ zJXD1n5d6>fg&?4A7wM%aNHKj0(xGH{N`KuoCP(=#nL5T)@1(nQM>}|u?xf;+I+bB$ zllkdmjZcO8xQV4|XK-1koMnMFEjL4pmdx~h#y!2?=%zD_uiUyks>=(U@yYXw_Jn(t zjbn4jNQWqZ?Z5zFX!?#dSI`^6!}TN=DSE-1(4gJ-i&?^AlWS=77@*xG{TJ8C)>O3; z%VG6zx!Y*(`R~B{#K3J|Foe&A@IIcGT`k*o{VWn~^fx(^vZiL=4PWO|K%@+s8*GTil;SD@o2&!*DiSBM)eBJ+UdGv5{H;-t2 zqJJK_+Y>VaNmdLlHCkt@pu_m%teqLw!oOLW|MJp(XaRvO*?Mv1oDc5Yb2p7$cx6sg z@Q(a92d7nC2kFU5&Hl4RV~n6Rgi+l5mc6sYCT@hE|M!MCeO865j43WEJYh ztP*;cRpk?C7Q!|g4stalMQxLZDj3BwZEC#9b;Had!9@y*I>u*RsmCL#yW^$ti(PN_ zT9^0A<~>auRaev$G`VN$8&&4ek1w%0zavVRlI1^Z+nJIjr<&AVupZ1q=L=SAt}%Gj z6{AMq2BTRb-uVR4xjg?*RNQ@^!B)|``+s9#QyxIw9Beibd1dTX9yNWL#U}vm60?vh z(o7bJ7IOw3Rv&4y(jrHAnq}9~YLilxBsk*s@+orYHb@|I&}O^H1&g&jnE z*$nKe$dcIJS=s`ElNdiwBG37FI=k`+Oa9S#@PJo$zV@_)YB)Th zv8?=7Sh=Gq{Sau@ir>N>acQ1EMx^ZeJqnaXGJFUMe~XTjXjW-^%_{Kg&PSHr^R=6vEudcf4EHgTWbVkdzpB~!vvK8sqNuXc zB$e4>Q)rI;sgo`@$)_iFKG+yts=5zbi#j&)iM9UHLh%nx@T!TQhSL|j?44CCDGLaM z^9LtdCp?4W*XaB7c-ViyeqfRQX7^bY`Ca%>kXMt38%)R_iD3#p7h1L{JMY~QBG)ug z0x|vmGRI!>=rXDVqg3b1-(Ad8j#B;clxxa5 z^o`kXkpF(PIx?8d+2I;RFc6T#WWjJbK#$u(FJE1xn@lsLbrz14I07>z8XZ@RTw1{s)GX=!N^0%4{rmj{_`&!{++h^p%%mdyWN{<-IAOZyEt)ap0M2?- zSf6_|}ApK-Rc4_8EeIUy=e{n~6=>G|TYp!E782s&2?*BU=~k z-$XPBof#@jdbNdnvD6$!uNk`fF{nEGBZ)oQo0AEgRzV&OOx@Z+zS9jpUQ*%4!s@9} zyr;4q@BVsEMvWapyYX7|nT=v?RZ|%@@yd=7Vg~H&(!w~qLO)$vcOUUuAP9P26q$tG zg&)Bb9}PcQM1B`XEL+bO8`6N_XF=WRa9V)4Kr>h0`%!p-qf&qd&5!gT1ocykF zP&e2J-Kr1j%`6PLxPohW0Zj$@xS`23`^s=LUd04K{{`jCF0Hvpi5+T{+_9)a%;>~G zat#|NjM%xu=F`#=4Aeyppl|?@r9Ah(a%fgXki~VPs?zjwi^0lea&D6seZ8y5a*C(f z>~*%H^=DaCmhV#GC-1-xPe;F!DpPFlcWUR0jq;r2-w#P2{CZ_+c=p2Xn}}D)H-~wf zq-n$T;JH;Q@4|)`#BQRK3lX*&1kqtiN3ML%1<%qI747|JqPl@`GmWip%(m z&o={7zLak$c{4XdfAfcfugh~UzXERH{`B zwcAlKf7wGS*kex7heKz#ZAJ2iJ#CHcV6KlLh-^`gi-}O7^bz!*64w%4aFOD-kOZ#j zxN=LW1`b@p*9XHd%E3}|8d^qOXYZYmI$Nr#@IeJdkvJZ=Zw#OGS*%Nq*@FoT>qfc- zKV=KTctMDdDsicvgnNgUFpJ-TTq2QdJJH0v@n@6@oF{*QHcdqR07EDq8QJ;qUtu#F z4g`chxgmfc*?1Q!`7@RfP~DJ3|60bZCW{_y&j@KPM&$V6*SDEuoJ|gqrRUgezr~8YMq2;q4=A3q3z^fj~Jf-9gneTuskK(XVI3x`)Q7oP_6(k z@b!KU2jb>UYz7@ob&{Bf(nl(#7#2c-qoa?w2V3jvM~*pxPY3!0G{EDmaMwaP2k)20 z=)H&!gDi93vG!{pQ#)^(oV5LA!)?F`Yw+8uET&8A)L2^3U6QU_w&PgZ9LFmSkZQs0 zOeK3rGQoYq2*XR>zF9$u`&osMp1p3Ipn0yxJ3wQi?X*1J>7m7-HHJF9!qL)Mpc|&$ z7L$}efvht}w8-!YbeeEnm^N+Rjpc8$Ds1W2RK|uW)=MZQHPptP6pJ_ztxM!gH!;I6 zP8HVZdhRAVEGop!U_)+o;6-yf+_msz0_6d9rB(l@i}Ma^Vrly@E}Z}gH6er!3P@2v zN~i{;DIf^Ppny`8P!&Pxgh)LE1zdVl550-fLhnUE6jWL$fl#b8D~I}GKF)bxzWryO z=QsE4%r#rCo!ObE)Yb&E($qv!|x zDha<(&^i+vT#veJmR&q79*^~yB#juo>RXgn@@z|K{;Jbi4hFX#Q>LCgF6_(x%wfhk zk@%yq!17gWBxhe6m zu+h~!>qp=9w3k}GahAs}rRv9*u5Sg8%whp`|`{O91b+Xk2PqUz`;_ z{O5Xaw~9Va*A}uE(|FxCq)hLOt-(8lLZGnQaw0v4KLr+6g0%~&rVc^G)E2%vkGz3$ zqdlEhHb^-N8UBsJ8R`nLjul05?>-kiurYfpcyFA_ZvW(O;gxU6f@N-kBPx9KmIzKn zajA`8)?A3Dnc4-1mPx!f*)@@iy*JqL>5J1rOwi&jeKngI%ttrH@fLSvP!4N~ujyc> zX_ZUkS~I@JD!4%N&7wWm>Z+P_m+&6zsz~Ral=oM42d;t@S&W$gB+4MLC__ZYa=Bwo zp~CwO*&>hIVjH-kl{7`zJ9cSnO<3C^PFpoWr!HKyDg4(9)pPjZ$Uf=6qm}dA&#Fd4 zeOecPC^8Hg<+Vael8vi`zE||&qgMqs!Pgz38$yI~74aQ{?N|uaDAHdnjk|`um$g!B zx<^kY#A=hH$aL3wT>ztr2x%bRG-*ykCOL>v0zaWlhqNK)e#!=?h?c2ch|8D<_J;TE z3zmF(9=FYMPvY|`odM9`^2DNb$RwAyu;jLxCi9P-2vkfr7lMsoknJTz z(!>5~xbmUz=a0|u`xDtb>MNL^fUkS9g(g8`Nr^9Vd!(QkO&hgD>#9^=kwNeW4o zJBjR*8a8uHdQ=!_SkJ~N+W65X)I)CT0S=}QN~{d~L)s25Iy&uxw}u3M8oTAsJ0i3<%b`NjKz{dl*?&f=?IVXMDxx4mxK8X3dy2!@-Viy305jZfVXi{t`fP%%3Ey^{&+ z4`#2$!gJE-&*9HwlwuuO4OvK??5BHK^b?pJQ@WzN3`$_g6aAAXSz|ERsACZUvXT5+ zLY>M1sTR2qN42p2NL>i^eSBam3OWmKZWf(8qq8d|vR8^~>;1;<;53>h)hs?|b7TVL zw(eo#))lzNOBO8!MlO8tWW>l;xjoVD6vdjhnR#l^)$Mz!g>Qna>eLMFp$|M(ZpOc zAsbMp_1c+*aCB*15lVYPc-SlERsZIX$j4|IBE#6A=FFF6urvwx3%@$uL(LYOe)73~ zcTgLW9#rl9!91-!?OxOixIk2AuHu&uJsQ<+dZI(ly)P~gq)TQZXDV%*Ms`d(tqotM zXQIx_=ls%9YMc%#(B$n>V^IB)$6%RV}*e`RvASI7WC~JsTsFsEfok% zX`nKs!W_R`eTb$~yzw%9nA+@O)s;jUKeF0x*rE z*>ho0Rbh`Y_Hq69EScklULzX2BN{4R*{75m*XRYZe4zSmTzG8KvfOlPfiU%Fr%}wc zsXxt>GKUrN=s#aWY6-e{b_*$O!uW8lb!HzUCzOQWZnKZiijauaS1KOzGo%o|b!LC)Hv972QWY&#Nd@A=Mk0UM>{h_>`A4c`epgx~nk0q)y2x zBQMB~cswB^l^fp_{YjOz&!w3-uXIOTe4gPiC3A7vIe&lz_X~XJJ(+Cdur!piQ)ih1 zf33Qgn{PO{>Qo$mL0x`MTVQoQK3;dWI3Bw8I9~UbWaFlliBVC|%hD|fgLX>BCJe!}w(s^r%oe+NQE@P)p^_U@w!WdYQiIGCOi?j!1WkP9lr3@Frj0F8pMN#F zElyv!x(a0DlQi$cKegXF#sAi`$$O`l^HZ-jWHd$KW1yDCo|T3G2C9AQ652xe#r#I+ zh2ySIuXr@S$?F?^cr}MN?#SMy7pp69|{Fqdj#JU42>&~=Jnk{sp1B8Xl!{Ze?FLsAcQ+PFDF)`z#2 ziWrT<`&%mB&$G>LZ!xIml9ChA9tY}SllBW3&%kGpXUj+6PM^;{Z>*?)OA)~|dw{N183#zD_F z$mov)2B)t~PMq^J6|jh_x_h@(wBt2X!jin>z|0hpXq@>B#guKe`0%XSYX$$}87rjQqiMlh|HVe~LVXj%rk)9= z(A7_R@n$-)&?C0$v;jF_DQgdg=ttLr-kd(H$Gflf_gTo4KAf{$*XZqrf4AOaKH8n8 zesnkLES0i>35mkT9e>i+xd4)6ApVxwL?8U0TK;VhOD=|p+?li4M(l*~mlwWlj1%I% zbLC7%B=c?pxh&Cswvg@U%zVtiUr&uui8p=EdYC;bbU{+Ln-g0WGoKFT4M^t1KRo|8 z8yxu^V%!_iYOC~flTmVBj1-OtLL}5L?iQChijeKnlC6^NC217V{K~iz_!Ssx&tJ#m9cs)E1jRgi8;tZocfM@m~RcU+++rUM0BVHMWkA z<0C#-le#-#|1Z{5)QCEW96bSeFo6U)KCqPq1{O`jP=`XS>_^M^=g23RGarDzBd$oJ z{u@Mtj!x_!YCp{k(z(t-0pP3Lr9ooWls6KNA8uWiVnh>Z%E2!%JtHNei4X5J^G zQ2+fSLPw{5h-WdQL0Wbk;0Lla>d-9vA&}SN0OSD?b1=|l5(#+!L6b<%LNqBK2V?)I zNIoI#GA+}5iWz)`;{iFQWPw1314$Qn=L#lFSpX_HaCXWD2*rVF)0#l}zIR(0gw4P} z(lioK^VoL)Trvv8&YT9qd}!vYFenWiok0RKw`dY4MHP??+&3jaHwql} z@07=W*fGt2+O?nN6QDsfsEuL()P)|Hj3AWA0itJNs6%79L*+`sY4FZHL2!Zs18ZiH z07Dc_`ZjwCb?9sEP`TQeeMlFySb%}x91`G7pp{X~76g~)WC5NBG*_>P2~>H=Por>D zB!EcySFWI<0qOLAU6TSX8l^ms1f((#WNzC11S$RBOCXkWkjV~G=FtG`5zWOv=4HCH4Ee&F+Fwk!i2{5*UiHlf3rVA7s(xUbJ z`{DnsYo{ChF|0|;$XP-HL%m?b(pf;f4@AB@2Fkx@;Z&wmrt8}O&~@$m-8cUMZ39{l diff --git a/gradlew b/gradlew index 83f2acfdc..4f906e0c8 100755 --- a/gradlew +++ b/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -129,6 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9618d8d96..107acd32c 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell