From 741fa401d8f445b9301abf3af5abb0382f80adde Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 2 Nov 2021 00:08:20 +0100 Subject: [PATCH] Move to official class names - also updated buildscript to 1.17 - some remap corruption from compilation errors in flw/next --- build.gradle | 72 ++-- gradle.properties | 12 +- gradle/wrapper/gradle-wrapper.jar | Bin 59203 -> 59536 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 269 +++++++++------ .../com/simibubi/create/AllBlockPartials.java | 4 +- .../java/com/simibubi/create/AllBlocks.java | 118 +++---- .../simibubi/create/AllContainerTypes.java | 8 +- .../com/simibubi/create/AllEnchantments.java | 14 +- .../com/simibubi/create/AllEntityTypes.java | 24 +- .../java/com/simibubi/create/AllFluids.java | 20 +- .../create/AllInteractionBehaviours.java | 6 +- .../java/com/simibubi/create/AllItems.java | 22 +- .../java/com/simibubi/create/AllKeys.java | 10 +- .../create/AllMovementBehaviours.java | 8 +- .../com/simibubi/create/AllParticleTypes.java | 16 +- .../com/simibubi/create/AllRecipeTypes.java | 48 +-- .../java/com/simibubi/create/AllShapes.java | 29 +- .../com/simibubi/create/AllSoundEvents.java | 142 ++++---- .../simibubi/create/AllSpecialTextures.java | 2 +- .../com/simibubi/create/AllSpriteShifts.java | 4 +- .../simibubi/create/AllStitchedTextures.java | 2 +- .../java/com/simibubi/create/AllTags.java | 48 +-- src/main/java/com/simibubi/create/Create.java | 22 +- .../com/simibubi/create/CreateClient.java | 44 +-- .../api/behaviour/BlockSpoutingBehaviour.java | 8 +- .../api/event/TileEntityBehaviourEvent.java | 2 +- .../compat/dynamictrees/DynamicTree.java | 10 +- .../compat/jei/BlueprintTransferHandler.java | 10 +- .../create/compat/jei/ConversionRecipe.java | 10 +- .../simibubi/create/compat/jei/CreateJEI.java | 90 ++--- .../create/compat/jei/DoubleItemIcon.java | 10 +- .../create/compat/jei/EmptyBackground.java | 4 +- .../compat/jei/GhostIngredientHandler.java | 14 +- .../compat/jei/ScreenResourceWrapper.java | 8 +- .../simibubi/create/compat/jei/SlotMover.java | 4 +- .../compat/jei/category/BasinCategory.java | 10 +- .../jei/category/BlockCuttingCategory.java | 22 +- .../jei/category/CreateRecipeCategory.java | 36 +- .../compat/jei/category/CrushingCategory.java | 4 +- .../jei/category/DeployingCategory.java | 8 +- .../jei/category/FanBlastingCategory.java | 10 +- .../jei/category/FanSmokingCategory.java | 10 +- .../jei/category/FanWashingCategory.java | 12 +- .../jei/category/ItemDrainCategory.java | 14 +- .../category/MechanicalCraftingCategory.java | 74 ++-- .../compat/jei/category/MillingCategory.java | 4 +- .../compat/jei/category/MixingCategory.java | 12 +- .../MysteriousItemConversionCategory.java | 4 +- .../compat/jei/category/PackingCategory.java | 14 +- .../jei/category/PolishingCategory.java | 14 +- .../compat/jei/category/PressingCategory.java | 4 +- .../category/ProcessingViaFanCategory.java | 18 +- .../compat/jei/category/SawingCategory.java | 6 +- .../category/SequencedAssemblyCategory.java | 40 +-- .../compat/jei/category/SpoutCategory.java | 14 +- .../animations/AnimatedBlazeBurner.java | 10 +- .../category/animations/AnimatedCrafter.java | 4 +- .../animations/AnimatedCrushingWheels.java | 12 +- .../category/animations/AnimatedDeployer.java | 10 +- .../animations/AnimatedItemDrain.java | 16 +- .../category/animations/AnimatedKinetics.java | 6 +- .../animations/AnimatedMillstone.java | 4 +- .../category/animations/AnimatedMixer.java | 10 +- .../category/animations/AnimatedPress.java | 8 +- .../jei/category/animations/AnimatedSaw.java | 10 +- .../category/animations/AnimatedSpout.java | 18 +- .../SequencedAssemblySubCategory.java | 16 +- .../compat/tconstruct/SpoutCasting.java | 14 +- .../simibubi/create/content/AllSections.java | 8 +- .../create/content/CreateItemGroup.java | 2 +- .../content/contraptions/KineticDebugger.java | 40 +-- .../contraptions/RotationPropagator.java | 38 +- .../contraptions/TorquePropagator.java | 8 +- .../base/BackHalfShaftInstance.java | 4 +- .../contraptions/base/CasingBlock.java | 22 +- .../base/CutoutRotatingInstance.java | 2 + .../base/DirectionalAxisKineticBlock.java | 36 +- .../base/DirectionalKineticBlock.java | 24 +- .../base/GeneratingKineticTileEntity.java | 26 +- .../contraptions/base/HalfShaftInstance.java | 2 +- .../base/HorizontalAxisKineticBlock.java | 34 +- .../base/HorizontalHalfShaftInstance.java | 4 +- .../base/HorizontalKineticBlock.java | 24 +- .../content/contraptions/base/IRotate.java | 46 +-- .../contraptions/base/KineticBlock.java | 44 +-- .../contraptions/base/KineticData.java | 4 +- .../base/KineticEffectHandler.java | 36 +- .../contraptions/base/KineticTileEntity.java | 88 ++--- .../base/KineticTileEntityRenderer.java | 36 +- .../base/KineticTileInstance.java | 6 +- .../base/RotatedPillarKineticBlock.java | 26 +- .../contraptions/base/RotatingData.java | 4 +- .../base/SingleRotatingInstance.java | 2 +- .../components/AssemblyOperatorBlockItem.java | 28 +- .../AssemblyOperatorUseContext.java | 16 +- .../components/actors/ActorData.java | 6 +- .../components/actors/AttachedActorBlock.java | 44 +-- .../actors/BellMovementBehaviour.java | 18 +- .../BlockBreakingKineticTileEntity.java | 58 ++-- .../BlockBreakingMovementBehaviour.java | 76 ++-- .../actors/CampfireMovementBehaviour.java | 4 +- .../components/actors/DrillActorInstance.java | 2 +- .../components/actors/DrillBlock.java | 54 +-- .../components/actors/DrillInstance.java | 9 +- .../actors/DrillMovementBehaviour.java | 20 +- .../components/actors/DrillRenderer.java | 16 +- .../components/actors/DrillTileEntity.java | 6 +- .../actors/HarvesterActorInstance.java | 11 +- .../components/actors/HarvesterBlock.java | 10 +- .../actors/HarvesterMovementBehaviour.java | 60 +++- .../components/actors/HarvesterRenderer.java | 32 +- .../actors/HarvesterTileEntity.java | 10 +- .../components/actors/PloughBlock.java | 6 +- .../actors/PloughMovementBehaviour.java | 61 +++- .../PortableFluidInterfaceTileEntity.java | 8 +- .../PortableItemInterfaceTileEntity.java | 8 +- .../actors/PortableStorageInterfaceBlock.java | 30 +- .../PortableStorageInterfaceMovement.java | 44 +-- .../PortableStorageInterfaceRenderer.java | 36 +- .../PortableStorageInterfaceTileEntity.java | 26 +- .../actors/SawMovementBehaviour.java | 32 +- .../components/actors/SeatBlock.java | 100 +++--- .../components/actors/SeatEntity.java | 52 +-- .../actors/SeatMovementBehaviour.java | 18 +- .../dispenser/ContraptionBlockSource.java | 20 +- .../dispenser/DispenserMovementBehaviour.java | 34 +- .../dispenser/DropperMovementBehaviour.java | 14 +- .../IMovedDispenseItemBehaviour.java | 94 ++--- .../MovedDefaultDispenseItemBehaviour.java | 40 +-- .../MovedOptionalDispenseBehaviour.java | 6 +- .../MovedProjectileDispenserBehaviour.java | 38 +- .../actors/dispenser/SimplePos.java | 4 +- .../components/clock/CuckooClockBlock.java | 46 +-- .../components/clock/CuckooClockRenderer.java | 24 +- .../clock/CuckooClockTileEntity.java | 36 +- .../crafter/ConnectedInputHandler.java | 44 +-- .../crafter/CrafterCTBehaviour.java | 14 +- .../components/crafter/CrafterHelper.java | 12 +- .../crafter/MechanicalCrafterBlock.java | 98 +++--- .../crafter/MechanicalCrafterInstance.java | 2 +- .../crafter/MechanicalCrafterRenderer.java | 60 ++-- .../crafter/MechanicalCrafterTileEntity.java | 68 ++-- .../crafter/MechanicalCraftingInventory.java | 14 +- .../crafter/MechanicalCraftingRecipe.java | 36 +- .../components/crafter/RecipeGridHandler.java | 44 +-- .../components/crank/HandCrankBlock.java | 62 ++-- .../components/crank/HandCrankInstance.java | 8 +- .../components/crank/HandCrankRenderer.java | 19 +- .../components/crank/HandCrankTileEntity.java | 14 +- .../components/crank/ValveHandleBlock.java | 36 +- .../components/crusher/CrushingRecipe.java | 4 +- .../crusher/CrushingWheelBlock.java | 54 +-- .../crusher/CrushingWheelControllerBlock.java | 98 +++--- .../CrushingWheelControllerTileEntity.java | 80 ++++- .../crusher/CrushingWheelTileEntity.java | 20 +- .../deployer/BeltDeployerCallbacks.java | 30 +- .../deployer/DeployerActorInstance.java | 4 +- .../deployer/DeployerApplicationRecipe.java | 40 +-- .../components/deployer/DeployerBlock.java | 70 ++-- .../deployer/DeployerFakePlayer.java | 64 ++-- .../deployer/DeployerFilterSlot.java | 16 +- .../components/deployer/DeployerHandler.java | 188 +++++----- .../components/deployer/DeployerInstance.java | 8 +- .../deployer/DeployerItemHandler.java | 6 +- .../deployer/DeployerMovementBehaviour.java | 60 ++-- .../deployer/DeployerMovingInteraction.java | 24 +- .../deployer/DeployerRecipeSearchEvent.java | 10 +- .../components/deployer/DeployerRenderer.java | 60 ++-- .../deployer/DeployerTileEntity.java | 98 +++--- .../components/fan/AirCurrent.java | 124 +++---- .../components/fan/AirCurrentSound.java | 10 +- .../components/fan/EncasedFanBlock.java | 48 +-- .../components/fan/EncasedFanRenderer.java | 33 +- .../components/fan/EncasedFanTileEntity.java | 26 +- .../components/fan/FanInstance.java | 7 +- .../components/fan/IAirCurrentSource.java | 14 +- .../components/fan/NozzleBlock.java | 48 +-- .../components/fan/NozzleTileEntity.java | 68 ++-- .../components/fan/SplashingRecipe.java | 4 +- .../components/flywheel/FlyWheelInstance.java | 8 +- .../components/flywheel/FlywheelBlock.java | 48 +-- .../flywheel/FlywheelGenerator.java | 4 +- .../components/flywheel/FlywheelRenderer.java | 38 +- .../flywheel/FlywheelTileEntity.java | 16 +- .../flywheel/engine/EngineBlock.java | 46 +-- .../flywheel/engine/EngineInstance.java | 12 +- .../flywheel/engine/EngineRenderer.java | 14 +- .../flywheel/engine/EngineTileEntity.java | 20 +- .../flywheel/engine/FurnaceEngineBlock.java | 32 +- .../engine/FurnaceEngineModifiers.java | 6 +- .../engine/FurnaceEngineTileEntity.java | 8 +- .../components/millstone/MillingRecipe.java | 4 +- .../components/millstone/MillstoneBlock.java | 60 ++-- .../millstone/MillstoneRenderer.java | 4 +- .../millstone/MillstoneTileEntity.java | 38 +- .../mixer/MechanicalMixerBlock.java | 37 +- .../mixer/MechanicalMixerRenderer.java | 18 +- .../mixer/MechanicalMixerTileEntity.java | 68 ++-- .../components/mixer/MixerInstance.java | 2 + .../components/motor/CreativeMotorBlock.java | 34 +- .../motor/CreativeMotorGenerator.java | 6 +- .../motor/CreativeMotorRenderer.java | 4 +- .../motor/CreativeMotorTileEntity.java | 4 +- .../press/MechanicalPressBlock.java | 40 ++- .../press/MechanicalPressRenderer.java | 19 +- .../press/MechanicalPressTileEntity.java | 84 ++--- .../components/press/PressInstance.java | 6 +- .../components/press/PressingRecipe.java | 14 +- .../components/saw/CuttingRecipe.java | 14 +- .../contraptions/components/saw/SawBlock.java | 54 +-- .../components/saw/SawFilterSlot.java | 16 +- .../components/saw/SawGenerator.java | 6 +- .../components/saw/SawInstance.java | 10 +- .../components/saw/SawRenderer.java | 58 +++- .../components/saw/SawTileEntity.java | 134 ++++---- .../AbstractContraptionEntity.java | 168 ++++----- .../structureMovement/AssemblyException.java | 30 +- .../BlockMovementChecks.java | 132 +++---- .../structureMovement/Contraption.java | 324 +++++++++--------- .../ContraptionCollider.java | 216 ++++++------ .../ContraptionDisassemblyPacket.java | 6 +- .../ContraptionEntityRenderer.java | 16 +- .../structureMovement/ContraptionHandler.java | 20 +- .../ContraptionHandlerClient.java | 52 +-- .../structureMovement/ContraptionLighter.java | 2 + .../ContraptionStallPacket.java | 8 +- .../structureMovement/ContraptionWorld.java | 28 +- .../ControlledContraptionEntity.java | 60 ++-- .../DirectionalExtenderScrollOptionSlot.java | 16 +- .../IControlContraption.java | 2 +- .../IDisplayAssemblyExceptions.java | 12 +- .../MountedFluidStorage.java | 28 +- .../structureMovement/MountedStorage.java | 40 +-- .../structureMovement/MovementBehaviour.java | 20 +- .../structureMovement/MovementContext.java | 38 +- .../MovingInteractionBehaviour.java | 14 +- .../OrientedContraptionEntity.java | 182 +++++----- .../OrientedContraptionEntityRenderer.java | 8 +- .../structureMovement/StructureTransform.java | 84 ++--- .../TranslatingContraption.java | 14 +- .../bearing/BearingBlock.java | 26 +- .../bearing/BearingContraption.java | 22 +- .../bearing/BearingInstance.java | 10 +- .../bearing/BearingRenderer.java | 14 +- .../bearing/ClockworkBearingBlock.java | 40 ++- .../bearing/ClockworkBearingTileEntity.java | 26 +- .../bearing/ClockworkContraption.java | 22 +- .../bearing/IBearingTileEntity.java | 2 +- .../bearing/MechanicalBearingBlock.java | 36 +- .../bearing/MechanicalBearingTileEntity.java | 35 +- .../structureMovement/bearing/SailBlock.java | 76 ++-- .../bearing/StabilizedBearingInstance.java | 12 +- .../StabilizedBearingMovementBehaviour.java | 12 +- .../bearing/StabilizedContraption.java | 16 +- .../bearing/WindmillBearingBlock.java | 36 +- .../bearing/WindmillBearingTileEntity.java | 16 +- .../chassis/AbstractChassisBlock.java | 66 ++-- .../chassis/ChassisRangeDisplay.java | 28 +- .../chassis/ChassisTileEntity.java | 29 +- .../chassis/LinearChassisBlock.java | 38 +- .../chassis/RadialChassisBlock.java | 14 +- .../chassis/StickerBlock.java | 68 ++-- .../chassis/StickerInstance.java | 12 +- .../chassis/StickerRenderer.java | 14 +- .../chassis/StickerTileEntity.java | 12 +- .../gantry/GantryCarriageBlock.java | 58 ++-- .../gantry/GantryCarriageInstance.java | 16 +- .../gantry/GantryCarriageRenderer.java | 22 +- .../gantry/GantryCarriageTileEntity.java | 27 +- .../gantry/GantryContraption.java | 20 +- .../gantry/GantryContraptionEntity.java | 62 ++-- .../gantry/GantryContraptionUpdatePacket.java | 6 +- .../glue/GlueEffectPacket.java | 10 +- .../structureMovement/glue/GlueInstance.java | 4 +- .../glue/SuperGlueEntity.java | 146 ++++---- .../glue/SuperGlueHandler.java | 60 ++-- .../structureMovement/glue/SuperGlueItem.java | 72 ++-- .../glue/SuperGlueRenderer.java | 76 ++-- .../interaction/DoorMovingInteraction.java | 22 +- .../interaction/LeverMovingInteraction.java | 12 +- .../SimpleBlockMovingInteraction.java | 26 +- .../TrapdoorMovingInteraction.java | 14 +- .../mounted/CartAssembleRailType.java | 12 +- .../mounted/CartAssemblerBlock.java | 180 +++++----- .../mounted/CartAssemblerBlockItem.java | 46 +-- .../mounted/CartAssemblerTileEntity.java | 66 ++-- .../ItemHandlerModifiableFromIInventory.java | 8 +- .../mounted/MinecartContraptionItem.java | 114 +++--- .../mounted/MountedContraption.java | 76 ++-- .../piston/LinearActuatorTileEntity.java | 40 ++- .../piston/MechanicalPistonBlock.java | 88 ++--- .../piston/MechanicalPistonGenerator.java | 14 +- .../piston/MechanicalPistonHeadBlock.java | 62 ++-- .../piston/MechanicalPistonRenderer.java | 6 +- .../piston/MechanicalPistonTileEntity.java | 40 +-- .../piston/PistonContraption.java | 68 ++-- .../piston/PistonExtensionPoleBlock.java | 76 ++-- .../piston/PistonLighter.java | 4 +- .../pulley/AbstractPulleyRenderer.java | 38 +- .../structureMovement/pulley/PulleyBlock.java | 94 ++--- .../pulley/PulleyContraption.java | 14 +- .../pulley/PulleyLighter.java | 8 +- .../pulley/PulleyRenderer.java | 10 +- .../pulley/PulleyTileEntity.java | 52 +-- .../render/ActorInstance.java | 4 +- .../render/ContraptionMatrices.java | 34 +- .../render/ContraptionProgram.java | 8 +- .../render/ContraptionRenderDispatcher.java | 58 ++-- .../render/ContraptionRenderInfo.java | 12 +- .../render/ContraptionRenderManager.java | 10 +- .../render/FlwContraptionManager.java | 4 +- .../render/RenderedContraption.java | 8 +- .../render/SBBContraptionManager.java | 4 +- .../sync/ClientMotionPacket.java | 18 +- .../sync/ContraptionFluidPacket.java | 10 +- .../sync/ContraptionInteractionPacket.java | 24 +- .../sync/ContraptionSeatMappingPacket.java | 8 +- .../sync/LimbSwingUpdatePacket.java | 24 +- .../train/CouplingCreationPacket.java | 14 +- .../train/CouplingHandler.java | 30 +- .../train/CouplingHandlerClient.java | 36 +- .../train/CouplingPhysics.java | 86 ++--- .../train/CouplingRenderer.java | 78 +++-- .../train/MinecartCouplingItem.java | 36 +- .../train/MinecartSim2020.java | 89 +++-- .../CapabilityMinecartController.java | 70 ++-- .../train/capability/MinecartController.java | 88 ++--- .../MinecartControllerUpdatePacket.java | 16 +- .../tracks/ControllerRailBlock.java | 88 +++-- .../tracks/ControllerRailGenerator.java | 8 +- .../tracks/ReinforcedRailBlock.java | 78 +++-- .../components/turntable/TurntableBlock.java | 64 ++-- .../turntable/TurntableHandler.java | 16 +- .../turntable/TurntableTileEntity.java | 4 +- .../waterwheel/WaterWheelBlock.java | 76 ++-- .../waterwheel/WaterWheelTileEntity.java | 22 +- .../contraptions/fluids/FlowSource.java | 14 +- .../fluids/FluidBottleItemHook.java | 38 +- .../content/contraptions/fluids/FluidFX.java | 54 +-- .../contraptions/fluids/FluidNetwork.java | 10 +- .../contraptions/fluids/FluidPropagator.java | 42 +-- .../contraptions/fluids/FluidReactions.java | 18 +- .../fluids/FluidTransportBehaviour.java | 26 +- .../contraptions/fluids/OpenEndedPipe.java | 70 ++-- .../fluids/PipeAttachmentModel.java | 22 +- .../contraptions/fluids/PipeConnection.java | 70 ++-- .../contraptions/fluids/PumpBlock.java | 74 ++-- .../contraptions/fluids/PumpCogInstance.java | 9 +- .../contraptions/fluids/PumpRenderer.java | 22 +- .../contraptions/fluids/PumpTileEntity.java | 28 +- .../contraptions/fluids/VirtualFluid.java | 14 +- .../fluids/actors/FillingBySpout.java | 16 +- .../fluids/actors/FillingRecipe.java | 22 +- .../fluids/actors/FluidDrainingBehaviour.java | 52 +-- .../fluids/actors/FluidFillingBehaviour.java | 74 ++-- .../actors/FluidManipulationBehaviour.java | 58 ++-- .../fluids/actors/FluidSplashPacket.java | 12 +- .../fluids/actors/GenericItemFilling.java | 24 +- .../fluids/actors/HosePulleyBlock.java | 38 +- .../fluids/actors/HosePulleyFluidHandler.java | 4 +- .../fluids/actors/HosePulleyRenderer.java | 6 +- .../fluids/actors/HosePulleyTileEntity.java | 24 +- .../fluids/actors/ItemDrainBlock.java | 68 ++-- .../fluids/actors/ItemDrainItemHandler.java | 4 +- .../fluids/actors/ItemDrainRenderer.java | 56 +-- .../fluids/actors/ItemDrainTileEntity.java | 32 +- .../fluids/actors/SpoutBlock.java | 30 +- .../fluids/actors/SpoutRenderer.java | 20 +- .../fluids/actors/SpoutTileEntity.java | 46 +-- .../fluids/particle/BasinFluidParticle.java | 36 +- .../fluids/particle/FluidParticleData.java | 32 +- .../fluids/particle/FluidStackParticle.java | 28 +- .../fluids/pipes/AxisPipeBlock.java | 78 +++-- .../fluids/pipes/BracketBlock.java | 20 +- .../fluids/pipes/BracketBlockItem.java | 40 ++- .../fluids/pipes/BracketGenerator.java | 6 +- .../fluids/pipes/EncasedPipeBlock.java | 72 ++-- .../fluids/pipes/FluidPipeBlock.java | 118 +++---- .../fluids/pipes/FluidPipeTileEntity.java | 16 +- .../fluids/pipes/FluidValveBlock.java | 58 ++-- .../fluids/pipes/FluidValveInstance.java | 12 +- .../fluids/pipes/FluidValveRenderer.java | 20 +- .../fluids/pipes/FluidValveTileEntity.java | 18 +- .../fluids/pipes/GlassFluidPipeBlock.java | 52 +-- .../contraptions/fluids/pipes/IAxisPipe.java | 4 +- .../fluids/pipes/SmartFluidPipeBlock.java | 68 ++-- .../fluids/pipes/SmartFluidPipeGenerator.java | 6 +- .../pipes/SmartFluidPipeTileEntity.java | 22 +- .../fluids/pipes/StraightPipeTileEntity.java | 20 +- .../TransparentStraightPipeRenderer.java | 12 +- .../fluids/potion/PotionFluid.java | 39 ++- .../fluids/potion/PotionFluidHandler.java | 74 ++-- .../fluids/recipe/FluidTransferRecipes.java | 4 +- .../recipe/PotionMixingRecipeManager.java | 14 +- .../tank/CreativeFluidTankTileEntity.java | 10 +- .../fluids/tank/FluidTankBlock.java | 112 +++--- .../fluids/tank/FluidTankCTBehaviour.java | 10 +- .../tank/FluidTankConnectivityHandler.java | 42 +-- .../fluids/tank/FluidTankGenerator.java | 4 +- .../fluids/tank/FluidTankItem.java | 42 +-- .../fluids/tank/FluidTankModel.java | 20 +- .../fluids/tank/FluidTankRenderer.java | 14 +- .../fluids/tank/FluidTankTileEntity.java | 44 +-- .../goggles/GoggleConfigScreen.java | 38 +- .../goggles/GoggleOverlayRenderer.java | 60 ++-- .../contraptions/goggles/GogglesItem.java | 38 +- .../contraptions/goggles/GogglesModel.java | 12 +- .../goggles/IHaveGoggleInformation.java | 30 +- .../goggles/IHaveHoveringInformation.java | 4 +- .../itemAssembly/IAssemblyRecipe.java | 10 +- .../itemAssembly/SequencedAssemblyItem.java | 20 +- .../itemAssembly/SequencedAssemblyRecipe.java | 76 ++-- .../SequencedAssemblyRecipeBuilder.java | 30 +- .../SequencedAssemblyRecipeSerializer.java | 32 +- .../itemAssembly/SequencedRecipe.java | 20 +- .../particle/AirFlowParticle.java | 56 +-- .../particle/AirFlowParticleData.java | 26 +- .../contraptions/particle/AirParticle.java | 46 +-- .../particle/AirParticleData.java | 24 +- .../contraptions/particle/CubeParticle.java | 72 ++-- .../particle/CubeParticleData.java | 22 +- .../contraptions/particle/HeaterParticle.java | 30 +- .../particle/HeaterParticleData.java | 24 +- .../particle/ICustomParticleData.java | 18 +- .../ICustomParticleDataWithSprite.java | 22 +- .../particle/RotationIndicatorParticle.java | 42 +-- .../RotationIndicatorParticleData.java | 26 +- .../contraptions/processing/BasinBlock.java | 98 +++--- .../processing/BasinGenerator.java | 4 +- .../processing/BasinInventory.java | 2 +- .../processing/BasinMovementBehaviour.java | 16 +- .../processing/BasinOperatingTileEntity.java | 24 +- .../contraptions/processing/BasinRecipe.java | 18 +- .../processing/BasinRenderer.java | 52 +-- .../processing/BasinTileEntity.java | 84 ++--- .../processing/EmptyingByBasin.java | 14 +- .../processing/EmptyingRecipe.java | 4 +- .../processing/InWorldProcessing.java | 90 ++--- .../processing/ProcessingInventory.java | 10 +- .../processing/ProcessingOutput.java | 26 +- .../processing/ProcessingRecipe.java | 32 +- .../processing/ProcessingRecipeBuilder.java | 40 +-- .../ProcessingRecipeSerializer.java | 38 +- .../processing/burner/BlazeBurnerBlock.java | 144 ++++---- .../burner/BlazeBurnerBlockItem.java | 102 +++--- .../processing/burner/BlazeBurnerHandler.java | 60 ++-- .../burner/BlazeBurnerRenderer.java | 16 +- .../burner/BlazeBurnerTileEntity.java | 30 +- .../burner/LitBlazeBurnerBlock.java | 80 ++--- .../relays/advanced/GantryShaftBlock.java | 102 +++--- .../advanced/GantryShaftTileEntity.java | 18 +- .../relays/advanced/SpeedControllerBlock.java | 50 +-- .../advanced/SpeedControllerRenderer.java | 32 +- .../advanced/SpeedControllerTileEntity.java | 14 +- .../ConfigureSequencedGearshiftPacket.java | 20 +- .../advanced/sequencer/Instruction.java | 18 +- .../sequencer/InstructionSpeedModifiers.java | 14 +- .../sequencer/SequencedGearshiftBlock.java | 78 +++-- .../SequencedGearshiftGenerator.java | 6 +- .../sequencer/SequencedGearshiftScreen.java | 22 +- .../SequencedGearshiftTileEntity.java | 14 +- .../sequencer/SequencerInstructions.java | 6 +- .../contraptions/relays/belt/BeltBlock.java | 212 ++++++------ .../contraptions/relays/belt/BeltData.java | 2 +- .../relays/belt/BeltGenerator.java | 10 +- .../contraptions/relays/belt/BeltHelper.java | 44 +-- .../relays/belt/BeltInstance.java | 10 +- .../contraptions/relays/belt/BeltModel.java | 18 +- .../contraptions/relays/belt/BeltPart.java | 4 +- .../relays/belt/BeltRenderer.java | 68 ++-- .../contraptions/relays/belt/BeltShapes.java | 43 ++- .../contraptions/relays/belt/BeltSlicer.java | 134 ++++---- .../contraptions/relays/belt/BeltSlope.java | 4 +- .../relays/belt/BeltTileEntity.java | 18 +- .../belt/item/BeltConnectorHandler.java | 68 ++-- .../relays/belt/item/BeltConnectorItem.java | 78 +++-- .../BeltCrusherInteractionHandler.java | 20 +- .../BeltFunnelInteractionHandler.java | 20 +- .../relays/belt/transport/BeltInventory.java | 34 +- .../belt/transport/BeltMovementHandler.java | 67 ++-- .../BeltTunnelInteractionHandler.java | 20 +- .../transport/ItemHandlerBeltSegment.java | 2 +- .../belt/transport/TransportedItemStack.java | 12 +- .../relays/elementary/AbstractShaftBlock.java | 64 ++-- .../BracketedKineticBlockModel.java | 24 +- .../BracketedTileEntityBehaviour.java | 26 +- .../relays/elementary/CogWheelBlock.java | 40 ++- .../relays/elementary/CogwheelBlockItem.java | 52 +-- .../relays/elementary/ICogWheel.java | 10 +- .../relays/elementary/ShaftBlock.java | 42 +-- .../elementary/SimpleKineticTileEntity.java | 14 +- .../encased/AbstractEncasedShaftBlock.java | 26 +- .../relays/encased/AdjustablePulleyBlock.java | 30 +- .../encased/AdjustablePulleyTileEntity.java | 12 +- .../relays/encased/CasingConnectivity.java | 6 +- .../relays/encased/ClutchBlock.java | 18 +- .../relays/encased/ClutchTileEntity.java | 8 +- .../DirectionalShaftHalvesTileEntity.java | 8 +- .../relays/encased/EncasedBeltBlock.java | 54 +-- .../relays/encased/EncasedBeltGenerator.java | 6 +- .../relays/encased/EncasedCTBehaviour.java | 10 +- .../relays/encased/EncasedShaftBlock.java | 24 +- .../relays/encased/EncasedShaftRenderer.java | 6 +- .../encased/EncasedShaftTileEntity.java | 4 +- .../relays/encased/GearshiftBlock.java | 40 ++- .../relays/encased/ShaftInstance.java | 2 +- .../relays/encased/SplitShaftRenderer.java | 18 +- .../relays/encased/SplitShaftTileEntity.java | 6 +- .../contraptions/relays/gauge/GaugeBlock.java | 78 +++-- .../relays/gauge/GaugeGenerator.java | 4 +- .../relays/gauge/GaugeInstance.java | 4 +- .../relays/gauge/GaugeRenderer.java | 26 +- .../relays/gauge/GaugeShaper.java | 8 +- .../relays/gauge/GaugeTileEntity.java | 16 +- .../relays/gauge/SpeedGaugeTileEntity.java | 20 +- .../relays/gauge/StressGaugeTileEntity.java | 32 +- .../relays/gearbox/GearboxBlock.java | 44 +-- .../relays/gearbox/GearboxInstance.java | 10 +- .../relays/gearbox/GearboxRenderer.java | 18 +- .../relays/gearbox/GearboxTileEntity.java | 4 +- .../relays/gearbox/GearshiftTileEntity.java | 8 +- .../relays/gearbox/VerticalGearboxItem.java | 32 +- .../contraptions/wrench/IWrenchable.java | 52 +-- .../wrench/IWrenchableWithBracket.java | 34 +- .../contraptions/wrench/WrenchItem.java | 54 +-- .../wrench/WrenchItemRenderer.java | 18 +- .../contraptions/wrench/WrenchModel.java | 4 +- .../content/curiosities/BuildersTeaItem.java | 44 +-- .../curiosities/ChromaticCompoundColor.java | 14 +- .../curiosities/ChromaticCompoundItem.java | 76 ++-- .../content/curiosities/CombustibleItem.java | 6 +- .../curiosities/NoGravMagicalDohickyItem.java | 34 +- .../curiosities/RefinedRadianceItem.java | 10 +- .../content/curiosities/ShadowSteelItem.java | 14 +- .../curiosities/TreeFertilizerItem.java | 32 +- .../curiosities/armor/AllArmorMaterials.java | 20 +- .../curiosities/armor/BackTankUtil.java | 28 +- .../armor/CapacityEnchantment.java | 12 +- .../curiosities/armor/CopperArmorItem.java | 18 +- .../armor/CopperBacktankArmorLayer.java | 68 ++-- .../armor/CopperBacktankBlock.java | 122 +++---- .../curiosities/armor/CopperBacktankItem.java | 32 +- .../armor/CopperBacktankRenderer.java | 14 +- .../armor/CopperBacktankTileEntity.java | 74 ++-- .../curiosities/armor/DivingBootsItem.java | 20 +- .../curiosities/armor/DivingHelmetItem.java | 24 +- .../curiosities/bell/AbstractBellBlock.java | 40 ++- .../bell/AbstractBellTileEntity.java | 12 +- .../curiosities/bell/BasicParticleData.java | 30 +- .../curiosities/bell/BellRenderer.java | 26 +- .../bell/CustomRotationParticle.java | 34 +- .../curiosities/bell/HauntedBellBlock.java | 18 +- .../bell/HauntedBellMovementBehaviour.java | 2 +- .../curiosities/bell/HauntedBellPulser.java | 12 +- .../bell/HauntedBellTileEntity.java | 28 +- .../curiosities/bell/PeculiarBellBlock.java | 48 +-- .../bell/PeculiarBellTileEntity.java | 4 +- .../curiosities/bell/SoulBaseParticle.java | 22 +- .../curiosities/bell/SoulParticle.java | 28 +- .../curiosities/bell/SoulPulseEffect.java | 40 +-- .../bell/SoulPulseEffectHandler.java | 6 +- .../bell/SoulPulseEffectPacket.java | 8 +- .../symmetry/ConfigureSymmetryWandPacket.java | 20 +- .../symmetry/SymmetryEffectPacket.java | 12 +- .../curiosities/symmetry/SymmetryHandler.java | 92 ++--- .../symmetry/SymmetryWandItem.java | 100 +++--- .../symmetry/SymmetryWandScreen.java | 32 +- .../client/SymmetryWandItemRenderer.java | 22 +- .../symmetry/client/SymmetryWandModel.java | 4 +- .../symmetry/mirror/CrossPlaneMirror.java | 20 +- .../symmetry/mirror/EmptyMirror.java | 16 +- .../symmetry/mirror/PlaneMirror.java | 20 +- .../symmetry/mirror/SymmetryMirror.java | 70 ++-- .../symmetry/mirror/TriplePlaneMirror.java | 16 +- .../toolbox/ItemReturnInvWrapper.java | 6 +- .../toolbox/RadialToolboxMenu.java | 40 +-- .../curiosities/toolbox/ToolboxBlock.java | 92 +++-- .../curiosities/toolbox/ToolboxContainer.java | 44 +-- .../toolbox/ToolboxDisposeAllPacket.java | 30 +- .../toolbox/ToolboxDyeingRecipe.java | 24 +- .../toolbox/ToolboxEquipPacket.java | 32 +- .../curiosities/toolbox/ToolboxHandler.java | 68 ++-- .../toolbox/ToolboxHandlerClient.java | 72 ++-- .../curiosities/toolbox/ToolboxInventory.java | 10 +- .../curiosities/toolbox/ToolboxRenderer.java | 20 +- .../curiosities/toolbox/ToolboxScreen.java | 32 +- .../toolbox/ToolboxTileEntity.java | 126 +++---- .../BlueprintAssignCompleteRecipePacket.java | 12 +- .../curiosities/tools/BlueprintContainer.java | 56 +-- .../curiosities/tools/BlueprintEntity.java | 186 +++++----- .../curiosities/tools/BlueprintItem.java | 78 +++-- .../tools/BlueprintOverlayRenderer.java | 58 ++-- .../curiosities/tools/BlueprintRenderer.java | 30 +- .../curiosities/tools/BlueprintScreen.java | 42 +-- .../tools/ExtendoGripInteractionPacket.java | 28 +- .../curiosities/tools/ExtendoGripItem.java | 116 ++++--- .../tools/ExtendoGripItemRenderer.java | 26 +- .../curiosities/tools/ExtendoGripModel.java | 4 +- .../tools/ExtendoGripRenderHandler.java | 38 +- .../curiosities/tools/SandPaperItem.java | 94 ++--- .../tools/SandPaperItemRenderer.java | 32 +- .../tools/SandPaperPolishingRecipe.java | 18 +- .../weapons/BuiltinPotatoProjectileTypes.java | 108 +++--- .../curiosities/weapons/PotatoCannonItem.java | 118 +++---- .../weapons/PotatoCannonItemRenderer.java | 32 +- .../weapons/PotatoCannonModel.java | 4 +- .../weapons/PotatoCannonPacket.java | 20 +- .../weapons/PotatoCannonProjectileType.java | 44 +-- .../weapons/PotatoCannonRenderHandler.java | 30 +- .../weapons/PotatoProjectileEntity.java | 110 +++--- .../weapons/PotatoProjectileRenderMode.java | 38 +- .../weapons/PotatoProjectileRenderer.java | 16 +- .../weapons/PotatoProjectileTypeManager.java | 32 +- .../weapons/PotatoRecoveryEnchantment.java | 12 +- .../zapper/ConfigureZapperPacket.java | 20 +- .../curiosities/zapper/PlacementPatterns.java | 8 +- .../curiosities/zapper/ShootGadgetPacket.java | 28 +- .../zapper/ShootableGadgetItemMethods.java | 40 +-- .../zapper/ShootableGadgetRenderHandler.java | 76 ++-- .../curiosities/zapper/ZapperBeamPacket.java | 18 +- .../zapper/ZapperInteractionHandler.java | 54 +-- .../curiosities/zapper/ZapperItem.java | 126 +++---- .../zapper/ZapperItemRenderer.java | 30 +- .../content/curiosities/zapper/ZapperLog.java | 20 +- .../zapper/ZapperRenderHandler.java | 30 +- .../curiosities/zapper/ZapperScreen.java | 42 +-- .../zapper/terrainzapper/Brush.java | 16 +- .../ConfigureWorldshaperPacket.java | 12 +- .../zapper/terrainzapper/CuboidBrush.java | 10 +- .../zapper/terrainzapper/CylinderBrush.java | 14 +- .../zapper/terrainzapper/DynamicBrush.java | 14 +- .../zapper/terrainzapper/FlattenTool.java | 18 +- .../zapper/terrainzapper/ShapedBrush.java | 8 +- .../zapper/terrainzapper/SphereBrush.java | 12 +- .../zapper/terrainzapper/TerrainTools.java | 16 +- .../zapper/terrainzapper/WorldshaperItem.java | 40 ++- .../WorldshaperItemRenderer.java | 30 +- .../terrainzapper/WorldshaperModel.java | 4 +- .../WorldshaperRenderHandler.java | 40 +-- .../terrainzapper/WorldshaperScreen.java | 38 +- .../content/logistics/IRedstoneLinkable.java | 2 +- .../logistics/RedstoneLinkNetworkHandler.java | 26 +- .../content/logistics/block/FlapData.java | 4 +- .../block/belts/tunnel/BeltTunnelBlock.java | 82 ++--- .../belts/tunnel/BeltTunnelInstance.java | 8 +- .../block/belts/tunnel/BeltTunnelItem.java | 32 +- .../belts/tunnel/BeltTunnelRenderer.java | 26 +- .../block/belts/tunnel/BeltTunnelShapes.java | 26 +- .../belts/tunnel/BeltTunnelTileEntity.java | 54 +-- .../block/belts/tunnel/BrassTunnelBlock.java | 54 +-- .../belts/tunnel/BrassTunnelCTBehaviour.java | 18 +- .../belts/tunnel/BrassTunnelFilterSlot.java | 4 +- .../belts/tunnel/BrassTunnelItemHandler.java | 2 +- .../belts/tunnel/BrassTunnelTileEntity.java | 62 ++-- .../block/chute/AbstractChuteBlock.java | 76 ++-- .../logistics/block/chute/ChuteBlock.java | 56 +-- .../logistics/block/chute/ChuteGenerator.java | 6 +- .../logistics/block/chute/ChuteItem.java | 30 +- .../block/chute/ChuteItemHandler.java | 2 +- .../logistics/block/chute/ChuteRenderer.java | 20 +- .../logistics/block/chute/ChuteShapes.java | 26 +- .../block/chute/ChuteTileEntity.java | 98 +++--- .../block/chute/SmartChuteBlock.java | 38 +- .../SmartChuteFilterSlotPositioning.java | 16 +- .../block/chute/SmartChuteRenderer.java | 12 +- .../block/chute/SmartChuteTileEntity.java | 12 +- .../logistics/block/depot/DepotBehaviour.java | 40 +-- .../logistics/block/depot/DepotBlock.java | 48 +-- .../block/depot/DepotItemHandler.java | 2 +- .../logistics/block/depot/DepotRenderer.java | 50 +-- .../block/depot/DepotTileEntity.java | 6 +- .../logistics/block/depot/EjectorBlock.java | 74 ++-- .../block/depot/EjectorElytraPacket.java | 20 +- .../block/depot/EjectorInstance.java | 6 +- .../logistics/block/depot/EjectorItem.java | 36 +- .../block/depot/EjectorPlacementPacket.java | 24 +- .../block/depot/EjectorRenderer.java | 32 +- .../block/depot/EjectorTargetHandler.java | 86 ++--- .../block/depot/EjectorTileEntity.java | 134 ++++---- .../block/depot/EjectorTriggerPacket.java | 10 +- .../logistics/block/depot/EntityLauncher.java | 26 +- .../block/depot/SharedDepotBlockMethods.java | 58 ++-- .../block/diodes/AbstractDiodeBlock.java | 8 +- .../block/diodes/AbstractDiodeGenerator.java | 10 +- .../AdjustablePulseRepeaterTileEntity.java | 4 +- .../block/diodes/AdjustableRepeaterBlock.java | 26 +- .../diodes/AdjustableRepeaterGenerator.java | 6 +- .../diodes/AdjustableRepeaterInstance.java | 6 +- .../diodes/AdjustableRepeaterRenderer.java | 4 +- .../diodes/AdjustableRepeaterScrollSlot.java | 12 +- .../diodes/AdjustableRepeaterTileEntity.java | 20 +- .../block/diodes/PoweredLatchBlock.java | 44 +-- .../block/diodes/PoweredLatchGenerator.java | 6 +- .../block/diodes/PulseRepeaterBlock.java | 26 +- .../block/diodes/PulseRepeaterGenerator.java | 6 +- .../block/diodes/ToggleLatchBlock.java | 50 +-- .../block/diodes/ToggleLatchGenerator.java | 6 +- .../AbstractDirectionalFunnelBlock.java | 18 +- .../block/funnel/AbstractFunnelBlock.java | 54 +-- .../funnel/AbstractHorizontalFunnelBlock.java | 18 +- .../block/funnel/AndesiteFunnelBlock.java | 12 +- .../block/funnel/BeltFunnelBlock.java | 80 ++--- .../block/funnel/BeltFunnelGenerator.java | 8 +- .../block/funnel/BrassFunnelBlock.java | 12 +- .../logistics/block/funnel/FunnelBlock.java | 78 +++-- .../funnel/FunnelFilterSlotPositioning.java | 20 +- .../block/funnel/FunnelGenerator.java | 10 +- .../block/funnel/FunnelInstance.java | 8 +- .../logistics/block/funnel/FunnelItem.java | 20 +- .../block/funnel/FunnelMovementBehaviour.java | 36 +- .../block/funnel/FunnelRenderer.java | 24 +- .../block/funnel/FunnelTileEntity.java | 42 +-- .../inventories/AdjustableCrateBlock.java | 54 +-- .../inventories/AdjustableCrateContainer.java | 36 +- .../inventories/AdjustableCrateScreen.java | 26 +- .../AdjustableCrateTileEntity.java | 40 +-- .../inventories/BottomlessItemHandler.java | 2 +- .../block/inventories/CrateBlock.java | 38 +- .../block/inventories/CrateTileEntity.java | 8 +- .../block/inventories/CreativeCrateBlock.java | 16 +- .../inventories/CreativeCrateTileEntity.java | 24 +- .../block/mechanicalArm/ArmAngleTarget.java | 34 +- .../block/mechanicalArm/ArmBlock.java | 62 ++-- .../block/mechanicalArm/ArmInstance.java | 2 + .../mechanicalArm/ArmInteractionPoint.java | 178 +++++----- .../ArmInteractionPointHandler.java | 58 ++-- .../block/mechanicalArm/ArmItem.java | 32 +- .../mechanicalArm/ArmPlacementPacket.java | 32 +- .../block/mechanicalArm/ArmRenderer.java | 34 +- .../block/mechanicalArm/ArmTileEntity.java | 68 ++-- .../block/redstone/AnalogLeverBlock.java | 76 ++-- .../block/redstone/AnalogLeverInstance.java | 2 + .../block/redstone/AnalogLeverRenderer.java | 20 +- .../block/redstone/AnalogLeverTileEntity.java | 20 +- .../redstone/ContactMovementBehaviour.java | 26 +- .../block/redstone/ContentObserverBlock.java | 60 ++-- .../redstone/ContentObserverTileEntity.java | 20 +- .../redstone/FilteredDetectorFilterSlot.java | 16 +- .../block/redstone/NixieTubeBlock.java | 106 +++--- .../block/redstone/NixieTubeGenerator.java | 4 +- .../block/redstone/NixieTubeRenderer.java | 36 +- .../block/redstone/NixieTubeTileEntity.java | 60 ++-- .../block/redstone/RedstoneContactBlock.java | 40 ++- .../block/redstone/RedstoneLinkBlock.java | 88 ++--- .../redstone/RedstoneLinkFrequencySlot.java | 20 +- .../block/redstone/RedstoneLinkGenerator.java | 6 +- .../redstone/RedstoneLinkTileEntity.java | 19 +- .../block/redstone/StockpileSwitchBlock.java | 78 +++-- .../block/redstone/StockpileSwitchScreen.java | 16 +- .../redstone/StockpileSwitchTileEntity.java | 30 +- .../logistics/item/CardboardBoxItem.java | 62 ++-- .../item/LecternControllerBlock.java | 52 +-- .../item/LecternControllerRenderer.java | 18 +- .../item/LecternControllerTileEntity.java | 70 ++-- .../item/LinkedControllerBindPacket.java | 16 +- .../item/LinkedControllerClientHandler.java | 54 +-- .../item/LinkedControllerContainer.java | 36 +- .../item/LinkedControllerInputPacket.java | 20 +- .../logistics/item/LinkedControllerItem.java | 78 +++-- .../item/LinkedControllerItemRenderer.java | 34 +- .../logistics/item/LinkedControllerModel.java | 4 +- .../item/LinkedControllerPacketBase.java | 22 +- .../item/LinkedControllerScreen.java | 32 +- .../item/LinkedControllerServerHandler.java | 8 +- .../LinkedControllerStopLecternPacket.java | 14 +- .../item/filter/AbstractFilterContainer.java | 22 +- .../item/filter/AbstractFilterScreen.java | 32 +- .../item/filter/AttributeFilterContainer.java | 48 +-- .../item/filter/AttributeFilterScreen.java | 82 ++--- .../item/filter/FilterContainer.java | 20 +- .../logistics/item/filter/FilterItem.java | 110 +++--- .../logistics/item/filter/FilterScreen.java | 36 +- .../item/filter/FilterScreenPacket.java | 20 +- .../logistics/item/filter/ItemAttribute.java | 90 ++--- .../filter/attribute/BookAuthorAttribute.java | 10 +- .../filter/attribute/BookCopyAttribute.java | 12 +- .../item/filter/attribute/ColorAttribute.java | 26 +- .../filter/attribute/EnchantAttribute.java | 18 +- .../attribute/FluidContentsAttribute.java | 16 +- .../filter/attribute/ItemNameAttribute.java | 14 +- .../attribute/ShulkerFillLevelAttribute.java | 20 +- .../AstralSorceryAmuletAttribute.java | 32 +- .../AstralSorceryAttunementAttribute.java | 22 +- .../AstralSorceryCrystalAttribute.java | 28 +- .../AstralSorceryPerkGemAttribute.java | 28 +- .../packet/ConfigureFlexcratePacket.java | 10 +- .../packet/ConfigureStockswitchPacket.java | 10 +- .../logistics/packet/FunnelFlapPacket.java | 6 +- .../logistics/packet/TunnelFlapPacket.java | 8 +- .../content/palettes/AllPaletteBlocks.java | 12 +- .../content/palettes/ConnectedGlassBlock.java | 16 +- .../palettes/ConnectedGlassPaneBlock.java | 6 +- .../content/palettes/GlassPaneBlock.java | 6 +- .../content/palettes/PaletteBlockPartial.java | 44 +-- .../content/palettes/PaletteBlockPattern.java | 30 +- .../palettes/PaletteStoneVariants.java | 4 +- .../content/palettes/PalettesItemGroup.java | 4 +- .../palettes/PalettesVariantEntry.java | 12 +- .../create/content/palettes/PavedBlock.java | 22 +- .../create/content/palettes/WindowBlock.java | 10 +- .../schematics/ClientSchematicLoader.java | 14 +- .../ISpecialBlockItemRequirement.java | 6 +- .../content/schematics/ItemRequirement.java | 62 ++-- .../content/schematics/MaterialChecklist.java | 70 ++-- .../content/schematics/SchematicPrinter.java | 88 ++--- .../schematics/SchematicProcessor.java | 46 +-- .../content/schematics/SchematicWorld.java | 104 +++--- .../schematics/ServerSchematicLoader.java | 60 ++-- .../schematics/block/LaunchedItem.java | 74 ++-- .../schematics/block/SchematicTableBlock.java | 64 ++-- .../block/SchematicTableContainer.java | 36 +- .../block/SchematicTableScreen.java | 62 ++-- .../block/SchematicTableTileEntity.java | 42 +-- .../schematics/block/SchematicannonBlock.java | 48 +-- .../block/SchematicannonContainer.java | 38 +- .../block/SchematicannonInstance.java | 2 + .../block/SchematicannonInventory.java | 4 +- .../block/SchematicannonRenderer.java | 64 ++-- .../block/SchematicannonScreen.java | 103 ++++-- .../block/SchematicannonTileEntity.java | 96 +++--- .../client/SchematicAndQuillHandler.java | 82 ++--- .../client/SchematicEditScreen.java | 54 +-- .../schematics/client/SchematicHandler.java | 72 ++-- .../client/SchematicHotbarSlotOverlay.java | 12 +- .../client/SchematicPromptScreen.java | 20 +- .../schematics/client/SchematicRenderer.java | 30 +- .../client/SchematicTransformation.java | 50 +-- .../schematics/client/tools/DeployTool.java | 38 +- .../schematics/client/tools/FlipTool.java | 24 +- .../client/tools/ISchematicTool.java | 10 +- .../schematics/client/tools/MoveTool.java | 6 +- .../client/tools/PlacementToolBase.java | 8 +- .../schematics/client/tools/RotateTool.java | 16 +- .../client/tools/SchematicToolBase.java | 50 +-- .../schematics/client/tools/Tools.java | 8 +- .../filtering/SchematicInstances.java | 26 +- .../item/SchematicAndQuillItem.java | 10 +- .../schematics/item/SchematicItem.java | 92 ++--- .../packet/ConfigureSchematicannonPacket.java | 10 +- .../packet/InstantSchematicPacket.java | 12 +- .../packet/SchematicPlacePacket.java | 20 +- .../packet/SchematicSyncPacket.java | 30 +- .../packet/SchematicUploadPacket.java | 12 +- .../simibubi/create/events/ClientEvents.java | 56 +-- .../simibubi/create/events/CommonEvents.java | 38 +- .../ClientResourceReloadListener.java | 6 +- .../advancement/AllAdvancements.java | 56 +-- .../foundation/advancement/AllTriggers.java | 32 +- .../advancement/CriterionTriggerBase.java | 22 +- .../foundation/advancement/ITriggerable.java | 4 +- .../advancement/RegistryTrigger.java | 2 +- .../foundation/advancement/SimpleTrigger.java | 14 +- .../StringSerializableTrigger.java | 16 +- .../foundation/block/BlockStressDefaults.java | 4 +- .../foundation/block/BlockStressValues.java | 4 +- .../foundation/block/BreakProgressHook.java | 8 +- .../foundation/block/DyedBlockList.java | 4 +- .../simibubi/create/foundation/block/ITE.java | 22 +- .../foundation/block/ItemUseOverrides.java | 16 +- .../block/WrenchableDirectionalBlock.java | 20 +- .../connected/BakedModelWrapperWithData.java | 16 +- .../foundation/block/connected/CTModel.java | 26 +- .../block/connected/CTSpriteShifter.java | 2 +- .../connected/ConnectedTextureBehaviour.java | 24 +- .../block/connected/GlassPaneCTBehaviour.java | 14 +- .../connected/HorizontalCTBehaviour.java | 4 +- .../block/connected/StandardCTBehaviour.java | 4 +- .../block/render/ColoredVertexModel.java | 26 +- .../block/render/CustomBlockModels.java | 14 +- .../foundation/block/render/QuadHelper.java | 2 +- .../block/render/SpriteShiftEntry.java | 6 +- .../block/render/SpriteShifter.java | 12 +- .../collision/ContinuousOBBCollider.java | 50 +-- .../create/foundation/collision/Matrix3d.java | 22 +- .../foundation/collision/OBBCollider.java | 30 +- .../foundation/collision/OrientedBB.java | 38 +- .../foundation/command/AllCommands.java | 26 +- .../create/foundation/command/ChunkUtil.java | 24 +- .../foundation/command/ChunkUtilCommand.java | 32 +- .../command/ClearBufferCacheCommand.java | 10 +- .../foundation/command/CloneCommand.java | 90 ++--- .../foundation/command/ConfigCommand.java | 24 +- .../command/ConfigureConfigCommand.java | 16 +- .../foundation/command/CouplingCommand.java | 52 +-- .../command/FabulousWarningCommand.java | 10 +- .../command/FixLightingCommand.java | 14 +- .../foundation/command/FlySpeedCommand.java | 22 +- .../foundation/command/GlueCommand.java | 16 +- .../foundation/command/HighlightCommand.java | 60 ++-- .../foundation/command/HighlightPacket.java | 12 +- .../foundation/command/KillTPSCommand.java | 6 +- .../command/OverlayConfigCommand.java | 18 +- .../foundation/command/PonderCommand.java | 26 +- .../ReplaceInCommandBlocksCommand.java | 42 +-- .../command/SConfigureConfigPacket.java | 52 +-- .../command/ToggleDebugCommand.java | 4 +- .../create/foundation/config/CStress.java | 4 +- .../config/ContraptionMovementSetting.java | 12 +- .../config/ui/BaseConfigScreen.java | 26 +- .../config/ui/CConfigureConfigPacket.java | 10 +- .../config/ui/ConfigModListScreen.java | 18 +- .../foundation/config/ui/ConfigScreen.java | 42 +-- .../config/ui/ConfigScreenList.java | 46 +-- .../foundation/config/ui/ConfigTextField.java | 4 +- .../config/ui/HintableTextFieldWidget.java | 22 +- .../config/ui/OpenCreateMenuButton.java | 24 +- .../config/ui/SubMenuConfigScreen.java | 56 +-- .../config/ui/entries/BooleanEntry.java | 4 +- .../config/ui/entries/EnumEntry.java | 4 +- .../config/ui/entries/NumberEntry.java | 18 +- .../config/ui/entries/SubMenuEntry.java | 4 +- .../config/ui/entries/ValueEntry.java | 20 +- .../create/foundation/data/AssetLookup.java | 12 +- .../create/foundation/data/BlockStateGen.java | 18 +- .../foundation/data/BuilderTransformers.java | 24 +- .../foundation/data/CreateEntityBuilder.java | 10 +- .../foundation/data/CreateRegistrate.java | 46 +-- .../data/CreateTileEntityBuilder.java | 12 +- .../data/DirectionalAxisBlockStateGen.java | 8 +- .../create/foundation/data/LangMerger.java | 16 +- .../create/foundation/data/ModelGen.java | 6 +- .../create/foundation/data/NamedTag.java | 10 +- .../foundation/data/SharedProperties.java | 10 +- .../foundation/data/SpecialBlockStateGen.java | 8 +- .../foundation/data/VirtualFluidBuilder.java | 4 +- .../create/foundation/data/WindowGen.java | 30 +- .../data/recipe/CompactingRecipeGen.java | 6 +- .../data/recipe/CreateRecipeProvider.java | 76 ++-- .../data/recipe/CrushingRecipeGen.java | 6 +- .../data/recipe/CuttingRecipeGen.java | 4 +- .../data/recipe/EmptyingRecipeGen.java | 2 +- .../data/recipe/FillingRecipeGen.java | 6 +- .../MechanicalCraftingRecipeBuilder.java | 34 +- .../recipe/MechanicalCraftingRecipeGen.java | 14 +- .../data/recipe/MillingRecipeGen.java | 6 +- .../data/recipe/MixingRecipeGen.java | 6 +- .../create/foundation/data/recipe/Mods.java | 2 +- .../data/recipe/PressingRecipeGen.java | 4 +- .../data/recipe/ProcessingRecipeGen.java | 20 +- .../recipe/SequencedAssemblyRecipeGen.java | 6 +- .../data/recipe/StandardRecipeGen.java | 108 +++--- .../data/recipe/WashingRecipeGen.java | 16 +- .../foundation/fluid/CombinedTankWrapper.java | 2 + .../create/foundation/fluid/FluidHelper.java | 34 +- .../foundation/fluid/FluidIngredient.java | 46 +-- .../foundation/fluid/FluidRenderer.java | 54 +-- .../gui/AbstractSimiContainerScreen.java | 80 ++--- .../foundation/gui/AbstractSimiScreen.java | 46 +-- .../create/foundation/gui/AllGuiTextures.java | 10 +- .../create/foundation/gui/AllIcons.java | 34 +- .../create/foundation/gui/BoxElement.java | 20 +- .../foundation/gui/ClearContainerPacket.java | 10 +- .../gui/CombinedStencilElement.java | 6 +- .../foundation/gui/ConfirmationScreen.java | 38 +- .../create/foundation/gui/ContainerBase.java | 30 +- .../gui/CustomLightingSettings.java | 4 +- .../gui/DelegatedStencilElement.java | 8 +- .../foundation/gui/GhostItemContainer.java | 22 +- .../foundation/gui/GhostItemSubmitPacket.java | 12 +- .../create/foundation/gui/GuiGameElement.java | 118 +++---- .../foundation/gui/IInteractionChecker.java | 4 +- .../foundation/gui/ILightingSettings.java | 6 +- .../foundation/gui/IScreenRenderable.java | 8 +- .../create/foundation/gui/RenderElement.java | 14 +- .../create/foundation/gui/ScreenOpener.java | 2 +- .../create/foundation/gui/StencilElement.java | 16 +- .../foundation/gui/TextStencilElement.java | 30 +- .../foundation/gui/ToolSelectionScreen.java | 20 +- .../create/foundation/gui/UIRenderHelper.java | 72 ++-- .../gui/mainMenu/CreateMainMenuScreen.java | 62 ++-- .../gui/widgets/AbstractSimiWidget.java | 24 +- .../foundation/gui/widgets/BoxWidget.java | 6 +- .../foundation/gui/widgets/ElementWidget.java | 6 +- .../foundation/gui/widgets/IconButton.java | 8 +- .../foundation/gui/widgets/Indicator.java | 8 +- .../gui/widgets/InterpolatedValue.java | 4 +- .../create/foundation/gui/widgets/Label.java | 30 +- .../foundation/gui/widgets/ScrollInput.java | 24 +- .../gui/widgets/SelectionScrollInput.java | 26 +- .../foundation/item/CreateItemGroupBase.java | 26 +- .../foundation/item/HiddenIngredientItem.java | 14 +- .../IItemHandlerModifiableIntermediate.java | 2 +- .../foundation/item/ItemDescription.java | 118 +++---- .../foundation/item/ItemHandlerWrapper.java | 2 +- .../create/foundation/item/ItemHelper.java | 20 +- .../foundation/item/SmartInventory.java | 10 +- .../item/TagDependentIngredientItem.java | 18 +- .../create/foundation/item/TooltipHelper.java | 88 ++--- .../render/CreateCustomRenderedItemModel.java | 4 +- .../item/render/CustomItemModels.java | 12 +- .../item/render/CustomRenderedItemModel.java | 26 +- .../CustomRenderedItemModelRenderer.java | 22 +- .../item/render/CustomRenderedItems.java | 12 +- .../item/render/PartialItemModelRenderer.java | 38 +- .../foundation/mixin/BreakProgressMixin.java | 12 +- .../EntityContraptionInteractionMixin.java | 44 +-- .../mixin/FixNormalScalingMixin.java | 4 +- .../mixin/HeavyBootsOnPlayerMixin.java | 16 +- .../mixin/ModelDataRefreshMixin.java | 8 +- .../foundation/mixin/PlayerListMixin.java | 8 +- .../foundation/mixin/WindowResizeMixin.java | 4 +- .../foundation/networking/AllPackets.java | 18 +- .../networking/ISyncPersistentData.java | 14 +- .../networking/LeftClickPacket.java | 6 +- .../networking/SimplePacketBase.java | 4 +- .../TileEntityConfigurationPacket.java | 24 +- .../networking/TileEntityDataPacket.java | 18 +- .../ponder/NavigatableSimiScreen.java | 30 +- .../foundation/ponder/PonderLocalization.java | 4 +- .../foundation/ponder/PonderProgressBar.java | 16 +- .../ponder/PonderRegistrationHelper.java | 2 +- .../foundation/ponder/PonderRegistry.java | 36 +- .../create/foundation/ponder/PonderScene.java | 84 ++--- .../ponder/PonderStoryBoardEntry.java | 2 +- .../ponder/PonderTooltipHandler.java | 44 +-- .../create/foundation/ponder/PonderUI.java | 94 ++--- .../create/foundation/ponder/PonderWorld.java | 128 +++---- .../ponder/PonderWorldParticles.java | 22 +- .../foundation/ponder/SceneBuilder.java | 110 +++--- .../foundation/ponder/SceneBuildingUtil.java | 40 +-- .../create/foundation/ponder/Selection.java | 38 +- .../foundation/ponder/content/ArmScenes.java | 34 +- .../ponder/content/BearingScenes.java | 20 +- .../foundation/ponder/content/BeltScenes.java | 40 +-- .../ponder/content/CartAssemblerScenes.java | 48 +-- .../ponder/content/ChainDriveScenes.java | 16 +- .../ponder/content/ChassisScenes.java | 24 +- .../ponder/content/ChuteScenes.java | 22 +- .../ponder/content/CrafterScenes.java | 28 +- .../ponder/content/DebugScenes.java | 46 +-- .../ponder/content/DeployerScenes.java | 50 +-- .../ponder/content/EjectorScenes.java | 28 +- .../foundation/ponder/content/FanScenes.java | 36 +- .../ponder/content/FunnelScenes.java | 44 +-- .../ponder/content/GantryScenes.java | 14 +- .../ponder/content/KineticsScenes.java | 60 ++-- .../ponder/content/MechanicalDrillScenes.java | 18 +- .../ponder/content/MechanicalSawScenes.java | 28 +- .../ponder/content/MovementActorScenes.java | 28 +- .../ponder/content/PistonScenes.java | 16 +- .../ponder/content/PonderChapter.java | 10 +- .../ponder/content/PonderChapterRegistry.java | 2 +- .../ponder/content/PonderIndex.java | 4 +- .../ponder/content/PonderIndexScreen.java | 34 +- .../foundation/ponder/content/PonderTag.java | 22 +- .../ponder/content/PonderTagIndexScreen.java | 38 +- .../ponder/content/PonderTagRegistry.java | 6 +- .../ponder/content/PonderTagScreen.java | 38 +- .../ponder/content/ProcessingScenes.java | 56 +-- .../ponder/content/PulleyScenes.java | 6 +- .../ponder/content/RedstoneScenes.java | 82 ++--- .../foundation/ponder/content/SharedText.java | 2 +- .../ponder/content/TemplateScenes.java | 2 +- .../ponder/content/TunnelScenes.java | 36 +- .../ponder/content/fluid/DrainScenes.java | 10 +- .../fluid/FluidMovementActorScenes.java | 6 +- .../ponder/content/fluid/FluidTankScenes.java | 16 +- .../content/fluid/HosePulleyScenes.java | 20 +- .../ponder/content/fluid/PipeScenes.java | 34 +- .../ponder/content/fluid/PumpScenes.java | 18 +- .../ponder/content/fluid/SpoutScenes.java | 24 +- .../elements/AnimatedOverlayElement.java | 6 +- .../ponder/elements/AnimatedSceneElement.java | 28 +- .../ponder/elements/EntityElement.java | 2 +- .../ponder/elements/InputWindowElement.java | 22 +- .../ponder/elements/MinecartElement.java | 40 +-- .../ponder/elements/ParrotElement.java | 88 ++--- .../ponder/elements/PonderOverlayElement.java | 4 +- .../ponder/elements/PonderSceneElement.java | 10 +- .../ponder/elements/TextWindowElement.java | 32 +- .../ponder/elements/TrackedElement.java | 10 +- .../ponder/elements/WorldSectionElement.java | 168 ++++----- .../AnimateElementInstruction.java | 16 +- .../AnimateMinecartInstruction.java | 10 +- .../AnimateParrotInstruction.java | 10 +- .../AnimateTileEntityInstruction.java | 6 +- .../AnimateWorldSectionInstruction.java | 10 +- .../instructions/ChaseAABBInstruction.java | 6 +- .../CreateMinecartInstruction.java | 2 +- .../instructions/CreateParrotInstruction.java | 2 +- .../DisplayWorldSectionInstruction.java | 4 +- .../EmitParticlesInstruction.java | 16 +- .../FadeIntoSceneInstruction.java | 6 +- .../FadeOutOfSceneInstruction.java | 6 +- .../instructions/HideAllInstruction.java | 6 +- .../HighlightValueBoxInstruction.java | 14 +- .../ponder/instructions/LineInstruction.java | 8 +- .../instructions/MovePoiInstruction.java | 6 +- .../ReplaceBlocksInstruction.java | 4 +- .../TileEntityDataInstruction.java | 18 +- .../foundation/ponder/ui/ChapterLabel.java | 4 +- .../foundation/ponder/ui/LayoutHelper.java | 6 +- .../foundation/ponder/ui/PonderButton.java | 22 +- .../foundation/render/AllMaterialSpecs.java | 2 + .../foundation/render/AllProgramSpecs.java | 2 +- .../create/foundation/render/Compartment.java | 4 +- .../foundation/render/CreateContexts.java | 2 +- .../foundation/render/PartialBufferer.java | 13 +- .../render/RainbowDebugStateProvider.java | 2 +- .../create/foundation/render/RenderTypes.java | 46 +-- .../foundation/render/ShadowRenderHelper.java | 60 ++-- .../foundation/render/SuperByteBuffer.java | 48 +-- .../render/SuperByteBufferCache.java | 38 +- .../render/SuperRenderTypeBuffer.java | 44 +-- .../render/TileEntityRenderHelper.java | 48 +-- .../foundation/sound/ContinuousSound.java | 10 +- .../foundation/sound/RepeatingSound.java | 14 +- .../create/foundation/sound/SoundScape.java | 22 +- .../create/foundation/sound/SoundScapes.java | 6 +- .../foundation/tileEntity/ComparatorUtil.java | 10 +- .../tileEntity/SmartTileEntity.java | 38 +- .../tileEntity/SyncedTileEntity.java | 40 +-- .../tileEntity/TileEntityBehaviour.java | 26 +- .../CenteredSideValueBoxTransform.java | 8 +- .../tileEntity/behaviour/ValueBox.java | 66 ++-- .../behaviour/ValueBoxRenderer.java | 26 +- .../behaviour/ValueBoxTransform.java | 42 +-- .../belt/BeltProcessingBehaviour.java | 8 +- .../belt/DirectBeltInputBehaviour.java | 16 +- .../TransportedItemStackHandlerBehaviour.java | 8 +- .../EdgeInteractionBehaviour.java | 12 +- .../EdgeInteractionHandler.java | 50 +-- .../EdgeInteractionRenderer.java | 42 +-- .../filtering/FilteringBehaviour.java | 34 +- .../filtering/FilteringCountUpdatePacket.java | 10 +- .../behaviour/filtering/FilteringHandler.java | 58 ++-- .../filtering/FilteringRenderer.java | 50 +-- .../filtering/SidedFilteringBehaviour.java | 20 +- .../fluid/SmartFluidTankBehaviour.java | 20 +- .../CapManipulationBehaviourBase.java | 16 +- .../inventory/InvManipulationBehaviour.java | 2 +- .../behaviour/linked/LinkBehaviour.java | 36 +- .../behaviour/linked/LinkHandler.java | 30 +- .../behaviour/linked/LinkRenderer.java | 42 +-- .../scrollvalue/BulkScrollValueBehaviour.java | 4 +- .../scrollvalue/ScrollOptionBehaviour.java | 4 +- .../scrollvalue/ScrollValueBehaviour.java | 36 +- .../scrollvalue/ScrollValueHandler.java | 24 +- .../scrollvalue/ScrollValueRenderer.java | 38 +- .../scrollvalue/ScrollValueUpdatePacket.java | 10 +- .../behaviour/simple/DeferralBehaviour.java | 6 +- .../ColoredOverlayTileEntityRenderer.java | 14 +- .../renderer/SafeTileEntityRenderer.java | 20 +- .../renderer/SmartTileEntityRenderer.java | 10 +- .../utility/AbstractBlockBreakQueue.java | 24 +- .../foundation/utility/AngleHelper.java | 4 +- .../utility/AnimationTickHolder.java | 8 +- .../create/foundation/utility/BlockFace.java | 18 +- .../foundation/utility/BlockHelper.java | 128 +++---- .../create/foundation/utility/Color.java | 30 +- .../foundation/utility/ColorHandlers.java | 24 +- .../create/foundation/utility/Couple.java | 8 +- .../create/foundation/utility/Debug.java | 24 +- .../foundation/utility/DirectionHelper.java | 8 +- .../create/foundation/utility/DyeHelper.java | 8 +- .../foundation/utility/FilesHelper.java | 6 +- .../create/foundation/utility/FontHelper.java | 18 +- .../foundation/utility/ICoordinate.java | 2 +- .../foundation/utility/IPartialSafeNBT.java | 4 +- .../utility/ISimpleReloadListener.java | 12 +- .../foundation/utility/IntAttached.java | 8 +- .../create/foundation/utility/Iterate.java | 6 +- .../create/foundation/utility/Lang.java | 18 +- .../foundation/utility/ModelSwapper.java | 24 +- .../create/foundation/utility/NBTHelper.java | 60 ++-- .../foundation/utility/NBTProcessors.java | 44 +-- .../create/foundation/utility/Pointing.java | 10 +- .../foundation/utility/RaycastHelper.java | 76 ++-- .../foundation/utility/RemapHelper.java | 8 +- .../utility/ServerSpeedProvider.java | 6 +- .../create/foundation/utility/TreeCutter.java | 44 +-- .../create/foundation/utility/VecHelper.java | 166 ++++----- .../foundation/utility/VoxelShaper.java | 46 +-- .../foundation/utility/WorldAttached.java | 16 +- .../foundation/utility/WorldHelper.java | 8 +- .../utility/animation/LerpedFloat.java | 26 +- .../utility/animation/PhysicalFloat.java | 6 +- .../utility/ghost/GhostBlockParams.java | 6 +- .../utility/ghost/GhostBlockRenderer.java | 76 ++-- .../foundation/utility/ghost/GhostBlocks.java | 10 +- .../utility/outliner/AABBOutline.java | 54 +-- .../utility/outliner/BlockClusterOutline.java | 38 +- .../utility/outliner/ChasingAABBOutline.java | 26 +- .../utility/outliner/LineOutline.java | 22 +- .../foundation/utility/outliner/Outline.java | 66 ++-- .../foundation/utility/outliner/Outliner.java | 26 +- .../utility/placement/IPlacementHelper.java | 66 ++-- .../utility/placement/PlacementHelpers.java | 64 ++-- .../utility/placement/PlacementOffset.java | 64 ++-- .../utility/placement/util/PoleHelper.java | 22 +- .../utility/recipe/IRecipeTypeInfo.java | 10 +- .../utility/recipe/RecipeConditions.java | 16 +- .../utility/recipe/RecipeFinder.java | 12 +- .../worldWrappers/DummyStatusListener.java | 8 +- .../PlacementSimulationServerWorld.java | 10 +- .../PlacementSimulationWorld.java | 32 +- .../utility/worldWrappers/RayTraceWorld.java | 20 +- .../worldWrappers/WrappedChunkProvider.java | 26 +- .../worldWrappers/WrappedClientWorld.java | 64 ++-- .../worldWrappers/WrappedServerWorld.java | 74 ++-- .../utility/worldWrappers/WrappedWorld.java | 88 ++--- .../worldWrappers/chunk/EmptierChunk.java | 40 +-- .../worldWrappers/chunk/WrappedChunk.java | 82 ++--- .../chunk/WrappedChunkSection.java | 6 +- .../foundation/worldgen/AllWorldFeatures.java | 24 +- .../worldgen/ConfigDrivenDecorator.java | 10 +- .../worldgen/ConfigDrivenFeatureEntry.java | 11 +- .../worldgen/ConfigDrivenOreFeature.java | 50 +-- .../ConfigDrivenOreFeatureConfig.java | 10 +- .../foundation/worldgen/OxidizingBlock.java | 36 +- .../resources/META-INF/accesstransformer.cfg | 118 +++---- 1212 files changed, 19450 insertions(+), 18462 deletions(-) diff --git a/build.gradle b/build.gradle index d8cd566cd..6550e1409 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' apply plugin: 'org.spongepowered.mixin' +apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle' boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equals('false'); @@ -29,7 +30,7 @@ version = "mc${minecraft_version}_v${mod_version}" + (dev && !buildnumber.equals group = 'com.simibubi.create' archivesBaseName = 'create' -java.toolchain.languageVersion = JavaLanguageVersion.of(8) +java.toolchain.languageVersion = JavaLanguageVersion.of(16) minecraft { mappings channel: 'official', version: "${minecraft_version}" @@ -107,7 +108,7 @@ repositories { maven { // Location of the maven for vazkii's mods name = "blamejared" - url = "http://maven.blamejared.com/" + url = "https://maven.blamejared.com/" } maven { // Location of the maven for mixed mappings, Registrate, and Flywheel @@ -122,7 +123,7 @@ repositories { } maven { //location of the maven for dynamic trees - url "http://harleyoconnor.com/maven" + url "https://harleyoconnor.com/maven" } } @@ -133,7 +134,7 @@ configurations { dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - def registrate = "com.tterrag.registrate:Registrate:MC1.16.5-${registrate_version}" + def registrate = "com.tterrag.registrate:Registrate:${registrate_version}" implementation fg.deobf(registrate) shade registrate @@ -143,20 +144,15 @@ dependencies { implementation fg.deobf("com.jozufozu.flywheel:Flywheel:${flywheel_version}") } - // Compile against the JEI API but do not include it at runtime - compileOnly fg.deobf("mezz.jei:jei-1.16.5:${jei_version}:api") - // At runtime, use the full JEI jar - runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:${jei_version}") + compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}:api") + runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") // implementation fg.deobf("curse.maven:druidcraft-340991:3101903") - implementation fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-1.16.5:0.10.0-Beta12.1") - - - // i'll leave this here commented for easier testing - //runtimeOnly fg.deobf("vazkii.arl:AutoRegLib:1.4-35.69") - //runtimeOnly fg.deobf("vazkii.quark:Quark:r2.0-212.984") - //runtimeOnly fg.deobf("slimeknights.mantle:Mantle:1.16.5-1.6.115") - //runtimeOnly fg.deobf("slimeknights.tconstruct:TConstruct:1.16.5-3.1.1.252") + // implementation fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-1.16.5:0.10.0-Beta12.1") + // runtimeOnly fg.deobf("vazkii.arl:AutoRegLib:1.4-35.69") + // runtimeOnly fg.deobf("vazkii.quark:Quark:r2.0-212.984") + // runtimeOnly fg.deobf("slimeknights.mantle:Mantle:1.16.5-1.6.115") + // runtimeOnly fg.deobf("slimeknights.tconstruct:TConstruct:1.16.5-3.1.1.252") annotationProcessor 'org.spongepowered:mixin:0.8.2:processor' } @@ -252,26 +248,24 @@ String getChangelogText() { return str } -//changelog debugging -//new File("changelog.html").write getChangelogText() - -tasks.curseforge.enabled = !dev && project.hasProperty('simi_curseforge_key') - -curseforge { - if (project.hasProperty('simi_curseforge_key')) { - apiKey = project.simi_curseforge_key - } - - project { - id = project.projectId - changelog = System.getenv('CHANGELOG') == null || System.getenv('CHANGELOG').equals('none') ? getChangelogText() : System.getenv('CHANGELOG') - changelogType = 'html' - releaseType = project.curse_type - mainArtifact(shadowJar) { - displayName = "Create - ${version}" - } - relations { - optionalDependency 'jei' - } - } -} +// changelog debugging +// new File("changelog.html").write getChangelogText() +// tasks.curseforge.enabled = !dev && project.hasProperty('simi_curseforge_key') +// curseforge { +// if (project.hasProperty('simi_curseforge_key')) { +// apiKey = project.simi_curseforge_key +// } +// +// project { +// id = project.projectId +// changelog = System.getenv('CHANGELOG') == null || System.getenv('CHANGELOG').equals('none') ? getChangelogText() : System.getenv('CHANGELOG') +// changelogType = 'html' +// releaseType = project.curse_type +// mainArtifact(shadowJar) { +// displayName = "Create - ${version}" +// } +// relations { +// optionalDependency 'jei' +// } +// } +// } diff --git a/gradle.properties b/gradle.properties index 861b6fc61..643f94ccb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,19 +5,19 @@ org.gradle.daemon = false # mod version info mod_version = 0.3.2f -minecraft_version = 1.16.5 -forge_version = 36.2.0 +minecraft_version = 1.17.1 +forge_version = 37.0.104 # build dependency versions -forgegradle_version = 4.1.+ +forgegradle_version = 5.1.+ mixingradle_version = 0.7-SNAPSHOT shadow_version = 6.1.0 cursegradle_version = 1.4.0 # dependency versions -registrate_version = 1.0.10 -flywheel_version = 1.16-0.2.3.44 -jei_version = 7.7.1.116 +registrate_version = MC1.17.1-1.0.13 +flywheel_version = 1.17-0.3.0.9 +jei_version = 8.1.0.31 # curseforge information projectId = 328085 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c023ec8b20f512888fe07c5bd3ff77bb8f..7454180f2ae8848c63b8b4dea2cb829da983f2fa 100644 GIT binary patch delta 18435 zcmY&<19zBR)MXm8v2EM7ZQHi-#I|kQZfv7Tn#Q)%81v4zX3d)U4d4 zYYc!v@NU%|U;_sM`2z(4BAilWijmR>4U^KdN)D8%@2KLcqkTDW%^3U(Wg>{qkAF z&RcYr;D1I5aD(N-PnqoEeBN~JyXiT(+@b`4Pv`;KmkBXYN48@0;iXuq6!ytn`vGp$ z6X4DQHMx^WlOek^bde&~cvEO@K$oJ}i`T`N;M|lX0mhmEH zuRpo!rS~#&rg}ajBdma$$}+vEhz?JAFUW|iZEcL%amAg_pzqul-B7Itq6Y_BGmOCC zX*Bw3rFz3R)DXpCVBkI!SoOHtYstv*e-May|+?b80ZRh$MZ$FerlC`)ZKt} zTd0Arf9N2dimjs>mg5&@sfTPsRXKXI;0L~&t+GH zkB<>wxI9D+k5VHHcB7Rku{Z>i3$&hgd9Mt_hS_GaGg0#2EHzyV=j=u5xSyV~F0*qs zW{k9}lFZ?H%@4hII_!bzao!S(J^^ZZVmG_;^qXkpJb7OyR*sPL>))Jx{K4xtO2xTr@St!@CJ=y3q2wY5F`77Tqwz8!&Q{f7Dp zifvzVV1!Dj*dxG%BsQyRP6${X+Tc$+XOG zzvq5xcC#&-iXlp$)L=9t{oD~bT~v^ZxQG;FRz|HcZj|^L#_(VNG)k{=_6|6Bs-tRNCn-XuaZ^*^hpZ@qwi`m|BxcF6IWc?_bhtK_cDZRTw#*bZ2`1@1HcB`mLUmo_>@2R&nj7&CiH zF&laHkG~7#U>c}rn#H)q^|sk+lc!?6wg0xy`VPn!{4P=u@cs%-V{VisOxVqAR{XX+ zw}R;{Ux@6A_QPka=48|tph^^ZFjSHS1BV3xfrbY84^=?&gX=bmz(7C({=*oy|BEp+ zYgj;<`j)GzINJA>{HeSHC)bvp6ucoE`c+6#2KzY9)TClmtEB1^^Mk)(mXWYvup02e%Ghm9qyjz#fO3bNGBX} zFiB>dvc1+If!>I10;qZk`?6pEd*(?bI&G*3YLt;MWw&!?=Mf7%^Op?qnyXWur- zwX|S^P>jF?{m9c&mmK-epCRg#WB+-VDe!2d2~YVoi%7_q(dyC{(}zB${!ElKB2D}P z7QNFM!*O^?FrPMGZ}wQ0TrQAVqZy!weLhu_Zq&`rlD39r*9&2sJHE(JT0EY5<}~x@ z1>P0!L2IFDqAB!($H9s2fI`&J_c+5QT|b#%99HA3@zUWOuYh(~7q7!Pf_U3u!ij5R zjFzeZta^~RvAmd_TY+RU@e}wQaB_PNZI26zmtzT4iGJg9U(Wrgrl>J%Z3MKHOWV(? zj>~Ph$<~8Q_sI+)$DOP^9FE6WhO09EZJ?1W|KidtEjzBX3RCLUwmj9qH1CM=^}MaK z59kGxRRfH(n|0*lkE?`Rpn6d^u5J6wPfi0WF(rucTv(I;`aW)3;nY=J=igkjsn?ED ztH&ji>}TW8)o!Jg@9Z}=i2-;o4#xUksQHu}XT~yRny|kg-$Pqeq!^78xAz2mYP9+4 z9gwAoti2ICvUWxE&RZ~}E)#M8*zy1iwz zHqN%q;u+f6Ti|SzILm0s-)=4)>eb5o-0K zbMW8ecB4p^6OuIX@u`f{>Yn~m9PINEl#+t*jqalwxIx=TeGB9(b6jA}9VOHnE$9sC zH`;epyH!k-3kNk2XWXW!K`L_G!%xOqk0ljPCMjK&VweAxEaZ==cT#;!7)X&C|X{dY^IY(e4D#!tx^vV3NZqK~--JW~wtXJ8X19adXim?PdN(|@o(OdgH3AiHts~?#QkolO?*=U_buYC&tQ3sc(O5HGHN~=6wB@dgIAVT$ z_OJWJ^&*40Pw&%y^t8-Wn4@l9gOl`uU z{Uda_uk9!Iix?KBu9CYwW9Rs=yt_lE11A+k$+)pkY5pXpocxIEJe|pTxwFgB%Kpr&tH;PzgOQ&m|(#Otm?@H^r`v)9yiR8v&Uy>d#TNdRfyN4Jk;`g zp+jr5@L2A7TS4=G-#O<`A9o;{En5!I8lVUG?!PMsv~{E_yP%QqqTxxG%8%KxZ{uwS zOT+EA5`*moN8wwV`Z=wp<3?~f#frmID^K?t7YL`G^(X43gWbo!6(q*u%HxWh$$^2EOq`Hj zp=-fS#Av+s9r-M)wGIggQ)b<@-BR`R8l1G@2+KODmn<_$Tzb7k35?e8;!V0G>`(!~ zY~qZz!6*&|TupOcnvsQYPbcMiJ!J{RyfezB^;fceBk znpA1XS)~KcC%0^_;ihibczSxwBuy;^ksH7lwfq7*GU;TLt*WmUEVQxt{ zKSfJf;lk$0XO8~48Xn2dnh8tMC9WHu`%DZj&a`2!tNB`5%;Md zBs|#T0Ktf?vkWQ)Y+q!At1qgL`C|nbzvgc(+28Q|4N6Geq)Il%+I5c@t02{9^=QJ?=h2BTe`~BEu=_u3xX2&?^zwcQWL+)7dI>JK0g8_`W1n~ zMaEP97X>Ok#=G*nkPmY`VoP8_{~+Rp7DtdSyWxI~?TZHxJ&=6KffcO2Qx1?j7=LZA z?GQt`oD9QpXw+s7`t+eeLO$cpQpl9(6h3_l9a6OUpbwBasCeCw^UB6we!&h9Ik@1zvJ`j4i=tvG9X8o34+N|y(ay~ho$f=l z514~mP>Z>#6+UxM<6@4z*|hFJ?KnkQBs_9{H(-v!_#Vm6Z4(xV5WgWMd3mB9A(>@XE292#k(HdI7P zJkQ2)`bQXTKlr}{VrhSF5rK9TsjtGs0Rs&nUMcH@$ZX_`Hh$Uje*)(Wd&oLW($hZQ z_tPt`{O@f8hZ<}?aQc6~|9iHt>=!%We3=F9yIfiqhXqp=QUVa!@UY@IF5^dr5H8$R zIh{=%S{$BHG+>~a=vQ={!B9B=<-ID=nyjfA0V8->gN{jRL>Qc4Rc<86;~aY+R!~Vs zV7MI~gVzGIY`B*Tt@rZk#Lg}H8sL39OE31wr_Bm%mn}8n773R&N)8B;l+-eOD@N$l zh&~Wz`m1qavVdxwtZLACS(U{rAa0;}KzPq9r76xL?c{&GaG5hX_NK!?)iq`t7q*F# zFoKI{h{*8lb>&sOeHXoAiqm*vV6?C~5U%tXR8^XQ9Y|(XQvcz*>a?%HQ(Vy<2UhNf zVmGeOO#v159KV@1g`m%gJ)XGPLa`a|?9HSzSSX{j;)xg>G(Ncc7+C>AyAWYa(k}5B3mtzg4tsA=C^Wfezb1&LlyrBE1~kNfeiubLls{C)!<%#m@f}v^o+7<VZ6!FZ;JeiAG@5vw7Li{flC8q1%jD_WP2ApBI{fQ}kN zhvhmdZ0bb5(qK@VS5-)G+@GK(tuF6eJuuV5>)Odgmt?i_`tB69DWpC~e8gqh!>jr_ zL1~L0xw@CbMSTmQflpRyjif*Y*O-IVQ_OFhUw-zhPrXXW>6X}+73IoMsu2?uuK3lT>;W#38#qG5tDl66A7Y{mYh=jK8Se!+f=N7%nv zYSHr6a~Nxd`jqov9VgII{%EpC_jFCEc>>SND0;}*Ja8Kv;G)MK7?T~h((c&FEBcQq zvUU1hW2^TX(dDCeU@~a1LF-(+#lz3997A@pipD53&Dr@III2tlw>=!iGabjXzbyUJ z4Hi~M1KCT-5!NR#I%!2Q*A>mqI{dpmUa_mW)%SDs{Iw1LG}0y=wbj@0ba-`q=0!`5 zr(9q1p{#;Rv2CY!L#uTbs(UHVR5+hB@m*zEf4jNu3(Kj$WwW|v?YL*F_0x)GtQC~! zzrnZRmBmwt+i@uXnk05>uR5&1Ddsx1*WwMrIbPD3yU*2By`71pk@gt{|H0D<#B7&8 z2dVmXp*;B)SWY)U1VSNs4ds!yBAj;P=xtatUx^7_gC5tHsF#vvdV;NmKwmNa1GNWZ zi_Jn-B4GnJ%xcYWD5h$*z^haku#_Irh818x^KB)3-;ufjf)D0TE#6>|zFf@~pU;Rs zNw+}c9S+6aPzxkEA6R%s*xhJ37wmgc)-{Zd1&mD5QT}4BQvczWr-Xim>(P^)52`@R z9+Z}44203T5}`AM_G^Snp<_KKc!OrA(5h7{MT^$ZeDsSr(R@^kI?O;}QF)OU zQ9-`t^ys=6DzgLcWt0U{Q(FBs22=r zKD%fLQ^5ZF24c-Z)J{xv?x$&4VhO^mswyb4QTIofCvzq+27*WlYm;h@;Bq%i;{hZA zM97mHI6pP}XFo|^pRTuWQzQs3B-8kY@ajLV!Fb?OYAO3jFv*W-_;AXd;G!CbpZt04iW`Ie^_+cQZGY_Zd@P<*J9EdRsc>c=edf$K|;voXRJ zk*aC@@=MKwR120(%I_HX`3pJ+8GMeO>%30t?~uXT0O-Tu-S{JA;zHoSyXs?Z;fy58 zi>sFtI7hoxNAdOt#3#AWFDW)4EPr4kDYq^`s%JkuO7^efX+u#-qZ56aoRM!tC^P6O zP(cFuBnQGjhX(^LJ(^rVe4-_Vk*3PkBCj!?SsULdmVr0cGJM^=?8b0^DuOFq>0*yA zk1g|C7n%pMS0A8@Aintd$fvRbH?SNdRaFrfoAJ=NoX)G5Gr}3-$^IGF+eI&t{I-GT zp=1fj)2|*ur1Td)+s&w%p#E6tDXX3YYOC{HGHLiCvv?!%%3DO$B$>A}aC;8D0Ef#b z{7NNqC8j+%1n95zq8|hFY`afAB4E)w_&7?oqG0IPJZv)lr{MT}>9p?}Y`=n+^CZ6E zKkjIXPub5!82(B-O2xQojW^P(#Q*;ETpEr^+Wa=qDJ9_k=Wm@fZB6?b(u?LUzX(}+ zE6OyapdG$HC& z&;oa*ALoyIxVvB2cm_N&h&{3ZTuU|aBrJlGOLtZc3KDx)<{ z27@)~GtQF@%6B@w3emrGe?Cv_{iC@a#YO8~OyGRIvp@%RRKC?fclXMP*6GzBFO z5U4QK?~>AR>?KF@I;|(rx(rKxdT9-k-anYS+#S#e1SzKPslK!Z&r8iomPsWG#>`Ld zJ<#+8GFHE!^wsXt(s=CGfVz5K+FHYP5T0E*?0A-z*lNBf)${Y`>Gwc@?j5{Q|6;Bl zkHG1%r$r&O!N^><8AEL+=y(P$7E6hd=>BZ4ZZ9ukJ2*~HR4KGvUR~MUOe$d>E5UK3 z*~O2LK4AnED}4t1Fs$JgvPa*O+WeCji_cn1@Tv7XQ6l@($F1K%{E$!naeX)`bfCG> z8iD<%_M6aeD?a-(Qqu61&fzQqC(E8ksa%CulMnPvR35d{<`VsmaHyzF+B zF6a@1$CT0xGVjofcct4SyxA40uQ`b#9kI)& z?B67-12X-$v#Im4CVUGZHXvPWwuspJ610ITG*A4xMoRVXJl5xbk;OL(;}=+$9?H`b z>u2~yd~gFZ*V}-Q0K6E@p}mtsri&%Zep?ZrPJmv`Qo1>94Lo||Yl)nqwHXEbe)!g( zo`w|LU@H14VvmBjjkl~=(?b{w^G$~q_G(HL`>|aQR%}A64mv0xGHa`S8!*Wb*eB}` zZh)&rkjLK!Rqar)UH)fM<&h&@v*YyOr!Xk2OOMV%$S2mCRdJxKO1RL7xP_Assw)bb z9$sQ30bapFfYTS`i1PihJZYA#0AWNmp>x(;C!?}kZG7Aq?zp!B+gGyJ^FrXQ0E<>2 zCjqZ(wDs-$#pVYP3NGA=en<@_uz!FjFvn1&w1_Igvqs_sL>ExMbcGx4X5f%`Wrri@ z{&vDs)V!rd=pS?G(ricfwPSg(w<8P_6=Qj`qBC7_XNE}1_5>+GBjpURPmvTNE7)~r)Y>ZZecMS7Ro2` z0}nC_GYo3O7j|Wux?6-LFZs%1IV0H`f`l9or-8y0=5VGzjPqO2cd$RRHJIY06Cnh- ztg@Pn1OeY=W`1Mv3`Ti6!@QIT{qcC*&vptnX4Pt1O|dWv8u2s|(CkV`)vBjAC_U5` zCw1f&c4o;LbBSp0=*q z3Y^horBAnR)u=3t?!}e}14%K>^562K!)Vy6r~v({5{t#iRh8WIL|U9H6H97qX09xp zjb0IJ^9Lqxop<-P*VA0By@In*5dq8Pr3bTPu|ArID*4tWM7w+mjit0PgmwLV4&2PW z3MnIzbdR`3tPqtUICEuAH^MR$K_u8~-U2=N1)R=l>zhygus44>6V^6nJFbW-`^)f} zI&h$FK)Mo*x?2`0npTD~jRd}5G~-h8=wL#Y-G+a^C?d>OzsVl7BFAaM==(H zR;ARWa^C3J)`p~_&FRsxt|@e+M&!84`eq)@aO9yBj8iifJv0xVW4F&N-(#E=k`AwJ z3EFXWcpsRlB%l_0Vdu`0G(11F7( zsl~*@XP{jS@?M#ec~%Pr~h z2`M*lIQaolzWN&;hkR2*<=!ORL(>YUMxOzj(60rQfr#wTrkLO!t{h~qg% zv$R}0IqVIg1v|YRu9w7RN&Uh7z$ijV=3U_M(sa`ZF=SIg$uY|=NdC-@%HtkUSEqJv zg|c}mKTCM=Z8YmsFQu7k{VrXtL^!Cts-eb@*v0B3M#3A7JE*)MeW1cfFqz~^S6OXFOIP&iL;Vpy z4dWKsw_1Wn%Y;eW1YOfeP_r1s4*p1C(iDG_hrr~-I%kA>ErxnMWRYu{IcG{sAW;*t z9T|i4bI*g)FXPpKM@~!@a7LDVVGqF}C@mePD$ai|I>73B+9!Ks7W$pw;$W1B%-rb; zJ*-q&ljb=&41dJ^*A0)7>Wa@khGZ;q1fL(2qW=|38j43mTl_;`PEEw07VKY%71l6p z@F|jp88XEnm1p~<5c*cVXvKlj0{THF=n3sU7g>Ki&(ErR;!KSmfH=?49R5(|c_*xw z4$jhCJ1gWT6-g5EV)Ahg?Nw=}`iCyQ6@0DqUb%AZEM^C#?B-@Hmw?LhJ^^VU>&phJ zlB!n5&>I>@sndh~v$2I2Ue23F?0!0}+9H~jg7E`?CS_ERu75^jSwm%!FTAegT`6s7 z^$|%sj2?8wtPQR>@D3sA0-M-g-vL@47YCnxdvd|1mPymvk!j5W1jHnVB&F-0R5e-vs`@u8a5GKdv`LF7uCfKncI4+??Z4iG@AxuX7 z6+@nP^TZ5HX#*z(!y+-KJ3+Ku0M90BTY{SC^{ z&y2#RZPjfX_PE<<>XwGp;g4&wcXsQ0T&XTi(^f+}4qSFH1%^GYi+!rJo~t#ChTeAX zmR0w(iODzQOL+b&{1OqTh*psAb;wT*drr^LKdN?c?HJ*gJl+%kEH&48&S{s28P=%p z7*?(xFW_RYxJxxILS!kdLIJYu@p#mnQ(?moGD1)AxQd66X6b*KN?o&e`u9#N4wu8% z^Gw#G!@|>c740RXziOR=tdbkqf(v~wS_N^CS^1hN-N4{Dww1lvSWcBTX*&9}Cz|s@ z*{O@jZ4RVHq19(HC9xSBZI0M)E;daza+Q*zayrX~N5H4xJ33BD4gn5Ka^Hj{995z4 zzm#Eo?ntC$q1a?)dD$qaC_M{NW!5R!vVZ(XQqS67xR3KP?rA1^+s3M$60WRTVHeTH z6BJO$_jVx0EGPXy}XK_&x597 zt(o6ArN8vZX0?~(lFGHRtHP{gO0y^$iU6Xt2e&v&ugLxfsl;GD)nf~3R^ACqSFLQ< zV7`cXgry((wDMJB55a6D4J;13$z6pupC{-F+wpToW%k1qKjUS^$Mo zN3@}T!ZdpiV7rkNvqP3KbpEn|9aB;@V;gMS1iSb@ zwyD7!5mfj)q+4jE1dq3H`sEKgrVqk|y8{_vmn8bMOi873!rmnu5S=1=-DFx+Oj)Hi zx?~ToiJqOrvSou?RVALltvMADodC7BOg7pOyc4m&6yd(qIuV5?dYUpYzpTe!BuWKi zpTg(JHBYzO&X1e{5o|ZVU-X5e?<}mh=|eMY{ldm>V3NsOGwyxO2h)l#)rH@BI*TN; z`yW26bMSp=k6C4Ja{xB}s`dNp zE+41IwEwo>7*PA|7v-F#jLN>h#a`Er9_86!fwPl{6yWR|fh?c%qc44uP~Ocm2V*(* zICMpS*&aJjxutxKC0Tm8+FBz;3;R^=ajXQUB*nTN*Lb;mruQHUE<&=I7pZ@F-O*VMkJbI#FOrBM8`QEL5Uy=q5e2 z_BwVH%c0^uIWO0*_qD;0jlPoA@sI7BPwOr-mrp7y`|EF)j;$GYdOtEPFRAKyUuUZS z(N4)*6R*ux8s@pMdC*TP?Hx`Zh{{Ser;clg&}CXriXZCr2A!wIoh;j=_eq3_%n7V} za?{KhXg2cXPpKHc90t6=`>s@QF-DNcTJRvLTS)E2FTb+og(wTV7?$kI?QZYgVBn)& zdpJf@tZ{j>B;<MVHiPl_U&KlqBT)$ic+M0uUQWK|N1 zCMl~@o|}!!7yyT%7p#G4?T^Azxt=D(KP{tyx^lD_(q&|zNFgO%!i%7T`>mUuU^FeR zHP&uClWgXm6iXgI8*DEA!O&X#X(zdrNctF{T#pyax16EZ5Lt5Z=RtAja!x+0Z31U8 zjfaky?W)wzd+66$L>o`n;DISQNs09g{GAv%8q2k>2n8q)O^M}=5r#^WR^=se#WSCt zQ`7E1w4qdChz4r@v6hgR?nsaE7pg2B6~+i5 zcTTbBQ2ghUbC-PV(@xvIR(a>Kh?{%YAsMV#4gt1nxBF?$FZ2~nFLKMS!aK=(`WllA zHS<_7ugqKw!#0aUtQwd#A$8|kPN3Af?Tkn)dHF?_?r#X68Wj;|$aw)Wj2Dkw{6)*^ zZfy!TWwh=%g~ECDCy1s8tTgWCi}F1BvTJ9p3H6IFq&zn#3FjZoecA_L_bxGWgeQup zAAs~1IPCnI@H>g|6Lp^Bk)mjrA3_qD4(D(65}l=2RzF-8@h>|Aq!2K-qxt(Q9w7c^ z;gtx`I+=gKOl;h=#fzSgw-V*YT~2_nnSz|!9hIxFb{~dKB!{H zSi??dnmr@%(1w^Be=*Jz5bZeofEKKN&@@uHUMFr-DHS!pb1I&;x9*${bmg6=2I4Zt zHb5LSvojY7ubCNGhp)=95jQ00sMAC{IZdAFsN!lAVQDeiec^HAu=8);2AKqNTT!&E zo+FAR`!A1#T6w@0A+o%&*yzkvxsrqbrfVTG+@z8l4+mRi@j<&)U9n6L>uZoezW>qS zA4YfO;_9dQSyEYpkWnsk0IY}Nr2m(ql@KuQjLgY-@g z4=$uai6^)A5+~^TvLdvhgfd+y?@+tRE^AJabamheJFnpA#O*5_B%s=t8<;?I;qJ}j z&g-9?hbwWEez-!GIhqpB>nFvyi{>Yv>dPU=)qXnr;3v-cd`l}BV?6!v{|cHDOx@IG z;TSiQQ(8=vlH^rCEaZ@Yw}?4#a_Qvx=}BJuxACxm(E7tP4hki^jU@8A zUS|4tTLd)gr@T|F$1eQXPY%fXb7u}(>&9gsd3It^B{W#6F2_g40cgo1^)@-xO&R5X z>qKon+Nvp!4v?-rGQu#M_J2v+3e+?N-WbgPQWf`ZL{Xd9KO^s{uIHTJ6~@d=mc7i z+##ya1p+ZHELmi%3C>g5V#yZt*jMv( zc{m*Y;7v*sjVZ-3mBuaT{$g+^sbs8Rp7BU%Ypi+c%JxtC4O}|9pkF-p-}F{Z7-+45 zDaJQx&CNR)8x~0Yf&M|-1rw%KW3ScjWmKH%J1fBxUp(;F%E+w!U470e_3%+U_q7~P zJm9VSWmZ->K`NfswW(|~fGdMQ!K2z%k-XS?Bh`zrjZDyBMu74Fb4q^A=j6+Vg@{Wc zPRd5Vy*-RS4p1OE-&8f^Fo}^yDj$rb+^>``iDy%t)^pHSV=En5B5~*|32#VkH6S%9 zxgIbsG+|{-$v7mhOww#v-ejaS>u(9KV9_*X!AY#N*LXIxor9hDv%aie@+??X6@Et=xz>6ev9U>6Pn$g4^!}w2Z%Kpqpp+M%mk~?GE-jL&0xLC zy(`*|&gm#mLeoRU8IU?Ujsv=;ab*URmsCl+r?%xcS1BVF*rP}XRR%MO_C!a9J^fOe>U;Y&3aj3 zX`3?i12*^W_|D@VEYR;h&b^s#Kd;JMNbZ#*x8*ZXm(jgw3!jyeHo14Zq!@_Q`V;Dv zKik~!-&%xx`F|l^z2A92aCt4x*I|_oMH9oeqsQgQDgI0j2p!W@BOtCTK8Jp#txi}7 z9kz);EX-2~XmxF5kyAa@n_$YYP^Hd4UPQ>O0-U^-pw1*n{*kdX`Jhz6{!W=V8a$0S z9mYboj#o)!d$gs6vf8I$OVOdZu7L5%)Vo0NhN`SwrQFhP3y4iXe2uV@(G{N{yjNG( zKvcN{k@pXkxyB~9ucR(uPSZ7{~sC=lQtz&V(^A^HppuN!@B4 zS>B=kb14>M-sR>{`teApuHlca6YXs6&sRvRV;9G!XI08CHS~M$=%T~g5Xt~$exVk` zWP^*0h{W%`>K{BktGr@+?ZP}2t0&smjKEVw@3=!rSjw5$gzlx`{dEajg$A58m|Okx zG8@BTPODSk@iqLbS*6>FdVqk}KKHuAHb0UJNnPm!(XO{zg--&@#!niF4T!dGVdNif z3_&r^3+rfQuV^8}2U?bkI5Ng*;&G>(O4&M<86GNxZK{IgKNbRfpg>+32I>(h`T&uv zUN{PRP&onFj$tn1+Yh|0AF330en{b~R+#i9^QIbl9fBv>pN|k&IL2W~j7xbkPyTL^ z*TFONZUS2f33w3)fdzr?)Yg;(s|||=aWZV(nkDaACGSxNCF>XLJSZ=W@?$*` z#sUftY&KqTV+l@2AP5$P-k^N`Bme-xcWPS|5O~arUq~%(z8z87JFB|llS&h>a>Som zC34(_uDViE!H2jI3<@d+F)LYhY)hoW6)i=9u~lM*WH?hI(yA$X#ip}yYld3RAv#1+sBt<)V_9c4(SN9Fn#$}_F}A-}P>N+8io}I3mh!}> z*~*N}ZF4Zergb;`R_g49>ZtTCaEsCHiFb(V{9c@X0`YV2O^@c6~LXg2AE zhA=a~!ALnP6aO9XOC^X15(1T)3!1lNXBEVj5s*G|Wm4YBPV`EOhU&)tTI9-KoLI-U zFI@adu6{w$dvT(zu*#aW*4F=i=!7`P!?hZy(9iL;Z^De3?AW`-gYTPALhrZ*K2|3_ zfz;6xQN9?|;#_U=4t^uS2VkQ8$|?Ub5CgKOj#Ni5j|(zX>x#K(h7LgDP-QHwok~-I zOu9rn%y97qrtKdG=ep)4MKF=TY9^n6CugQ3#G2yx;{))hvlxZGE~rzZ$qEHy-8?pU#G;bwufgSN6?*BeA!7N3RZEh{xS>>-G1!C(e1^ zzd#;39~PE_wFX3Tv;zo>5cc=md{Q}(Rb?37{;YPtAUGZo7j*yHfGH|TOVR#4ACaM2 z;1R0hO(Gl}+0gm9Bo}e@lW)J2OU4nukOTVKshHy7u)tLH^9@QI-jAnDBp(|J8&{fKu=_97$v&F67Z zq+QsJ=gUx3_h_%=+q47msQ*Ub=gMzoSa@S2>`Y9Cj*@Op4plTc!jDhu51nSGI z^sfZ(4=yzlR}kP2rcHRzAY9@T7f`z>fdCU0zibx^gVg&fMkcl)-0bRyWe12bT0}<@ z^h(RgGqS|1y#M;mER;8!CVmX!j=rfNa6>#_^j{^C+SxGhbSJ_a0O|ae!ZxiQCN2qA zKs_Z#Zy|9BOw6x{0*APNm$6tYVG2F$K~JNZ!6>}gJ_NLRYhcIsxY1z~)mt#Yl0pvC zO8#Nod;iow5{B*rUn(0WnN_~~M4|guwfkT(xv;z)olmj=f=aH#Y|#f_*d1H!o( z!EXNxKxth9w1oRr0+1laQceWfgi8z`YS#uzg#s9-QlTT7y2O^^M1PZx z3YS7iegfp6Cs0-ixlG93(JW4wuE7)mfihw}G~Uue{Xb+#F!BkDWs#*cHX^%(We}3% zT%^;m&Juw{hLp^6eyM}J({luCL_$7iRFA6^8B!v|B9P{$42F>|M`4Z_yA{kK()WcM zu#xAZWG%QtiANfX?@+QQOtbU;Avr*_>Yu0C2>=u}zhH9VLp6M>fS&yp*-7}yo8ZWB z{h>ce@HgV?^HgwRThCYnHt{Py0MS=Ja{nIj5%z;0S@?nGQ`z`*EVs&WWNwbzlk`(t zxDSc)$dD+4G6N(p?K>iEKXIk>GlGKTH{08WvrehnHhh%tgpp&8db4*FLN zETA@<$V=I7S^_KxvYv$Em4S{gO>(J#(Wf;Y%(NeECoG3n+o;d~Bjme-4dldKukd`S zRVAnKxOGjWc;L#OL{*BDEA8T=zL8^`J=2N)d&E#?OMUqk&9j_`GX*A9?V-G zdA5QQ#(_Eb^+wDkDiZ6RXL`fck|rVy%)BVv;dvY#`msZ}{x5fmd! zInmWSxvRgXbJ{unxAi*7=Lt&7_e0B#8M5a=Ad0yX#0rvMacnKnXgh>4iiRq<&wit93n!&p zeq~-o37qf)L{KJo3!{l9l9AQb;&>)^-QO4RhG>j`rBlJ09~cbfNMR_~pJD1$UzcGp zOEGTzz01j$=-kLC+O$r8B|VzBotz}sj(rUGOa7PDYwX~9Tum^sW^xjjoncxSz;kqz z$Pz$Ze|sBCTjk7oM&`b5g2mFtuTx>xl{dj*U$L%y-xeQL~|i>KzdUHeep-Yd@}p&L*ig< zgg__3l9T=nbM3bw0Sq&Z2*FA)P~sx0h634BXz0AxV69cED7QGTbK3?P?MENkiy-mV zZ1xV5ry3zIpy>xmThBL0Q!g+Wz@#?6fYvzmEczs(rcujrfCN=^!iWQ6$EM zaCnRThqt~gI-&6v@KZ78unqgv9j6-%TOxpbV`tK{KaoBbhc}$h+rK)5h|bT6wY*t6st-4$e99+Egb#3ip+ERbve08G@Ref&hP)qB&?>B94?eq5i3k;dOuU#!y-@+&5>~!FZik=z4&4|YHy=~!F254 zQAOTZr26}Nc7jzgJ;V~+9ry#?7Z0o*;|Q)k+@a^87lC}}1C)S))f5tk+lMNqw>vh( z`A9E~5m#b9!ZDBltf7QIuMh+VheCoD7nCFhuzThlhA?|8NCt3w?oWW|NDin&&eDU6 zwH`aY=))lpWG?{fda=-auXYp1WIPu&3 zwK|t(Qiqvc@<;1_W#ALDJ}bR;3&v4$9rP)eAg`-~iCte`O^MY+SaP!w%~+{{1tMo` zbp?T%ENs|mHP)Lsxno=nWL&qizR+!Ib=9i%4=B@(Umf$|7!WVxkD%hfRjvxV`Co<; zG*g4QG_>;RE{3V_DOblu$GYm&!+}%>G*yO{-|V9GYG|bH2JIU2iO}ZvY>}Fl%1!OE zZFsirH^$G>BDIy`8;R?lZl|uu@qWj2T5}((RG``6*05AWsVVa2Iu>!F5U>~7_Tlv{ zt=Dpgm~0QVa5mxta+fUt)I0gToeEm9eJX{yYZ~3sLR&nCuyuFWuiDIVJ+-lwViO(E zH+@Rg$&GLueMR$*K8kOl>+aF84Hss5p+dZ8hbW$=bWNIk0paB!qEK$xIm5{*^ad&( zgtA&gb&6FwaaR2G&+L+Pp>t^LrG*-B&Hv;-s(h0QTuYWdnUObu8LRSZoAVd7SJ;%$ zh%V?58mD~3G2X<$H7I)@x?lmbeeSY7X~QiE`dfQ5&K^FB#9e!6!@d9vrSt!);@ZQZ zO#84N5yH$kjm9X4iY#f+U`FKhg=x*FiDoUeu1O5LcC2w&$~5hKB9ZnH+8BpbTGh5T zi_nfmyQY$vQh%ildbR7T;7TKPxSs#vhKR|uup`qi1PufMa(tNCjRbllakshQgn1)a8OO-j8W&aBc_#q1hKDF5-X$h`!CeT z+c#Ial~fDsGAenv7~f@!icm(~)a3OKi((=^zcOb^qH$#DVciGXslUwTd$gt{7)&#a`&Lp ze%AnL0#U?lAl8vUkv$n>bxH*`qOujO0HZkPWZnE0;}0DSEu1O!hg-d9#{&#B1Dm)L zvN%r^hdEt1vR<4zwshg*0_BNrDWjo65be1&_82SW8#iKWs7>TCjUT;-K~*NxpG2P% zovXUo@S|fMGudVSRQrP}J3-Wxq;4xIxJJC|Y#TQBr>pwfy*%=`EUNE*dr-Y?9y9xK zmh1zS@z{^|UL}v**LNYY!?1qIRPTvr!gNXzE{%=-`oKclPrfMKwn` zUwPeIvLcxkIV>(SZ-SeBo-yw~{p!<&_}eELG?wxp zee-V59%@BtB+Z&Xs=O(@P$}v_qy1m=+`!~r^aT> zY+l?+6(L-=P%m4ScfAYR8;f9dyVw)@(;v{|nO#lAPI1xDHXMYt~-BGiP&9y2OQsYdh7-Q1(vL<$u6W0nxVn-qh=nwuRk}{d!uACozccRGx6~xZQ;=#JCE?OuA@;4 zadp$sm}jfgW4?La(pb!3f0B=HUI{5A4b$2rsB|ZGb?3@CTA{|zBf07pYpQ$NM({C6Srv6%_{rVkCndT=1nS}qyEf}Wjtg$e{ng7Wgz$7itYy0sWW_$qld);iUm85GBH)fk3b=2|5mvflm?~inoVo zDH_%e;y`DzoNj|NgZ`U%a9(N*=~8!qqy0Etkxo#`r!!{|(NyT0;5= z8nVZ6AiM+SjMG8J@6c4_f-KXd_}{My?Se1GWP|@wROFpD^5_lu?I%CBzpwi(`x~xh B8dv}T delta 17845 zcmV)CK*GO}(F4QI1F(Jx4W$DjNjn4p0N4ir06~)x5+0MO2`GQvQyWzj|J`gh3(E#l zNGO!HfVMRRN~%`0q^)g%XlN*vP!O#;m*h5VyX@j-1N|HN;8S1vqEAj=eCdn`)tUB9 zXZjcT^`bL6qvL}gvXj%9vrOD+x!Gc_0{$Zg+6lTXG$bmoEBV z*%y^c-mV0~Rjzv%e6eVI)yl>h;TMG)Ft8lqpR`>&IL&`>KDi5l$AavcVh9g;CF0tY zw_S0eIzKD?Nj~e4raA8wxiiImTRzv6;b6|LFmw)!E4=CiJ4I%&axSey4zE-MIh@*! z*P;K2Mx{xVYPLeagKA}Hj=N=1VrWU`ukuBnc14iBG?B}Uj>?=2UMk4|42=()8KOnc zrJzAxxaEIfjw(CKV6F$35u=1qyf(%cY8fXaS9iS?yetY{mQ#Xyat*7sSoM9fJlZqq zyasQ3>D>6p^`ck^Y|kYYZB*G})uAbQ#7)Jeb~glGz@2rPu}zBWDzo5K$tP<|meKV% z{Swf^eq6NBioF)v&~9NLIxHMTKe6gJ@QQ^A6fA!n#u1C&n`aG7TDXKM1Jly-DwTB` z+6?=Y)}hj;C#r5>&x;MCM4U13nuXVK*}@yRY~W3X%>U>*CB2C^K6_OZsXD!nG2RSX zQg*0)$G3%Es$otA@p_1N!hIPT(iSE=8OPZG+t)oFyD~{nevj0gZen$p>U<7}uRE`t5Mk1f4M0K*5 zbn@3IG5I2mk;8K>*RZ zPV6iL006)S001s%0eYj)9hu1 z9o)iQT9(v*sAuZ|ot){RrZ0Qw4{E0A+!Yx_M~#Pj&OPUM&i$RU=Uxu}e*6Sr2ror= z&?lmvFCO$)BY+^+21E>ENWe`I0{02H<-lz&?})gIVFyMWxX0B|0b?S6?qghp3lDgz z2?0|ALJU=7s-~Lb3>9AA5`#UYCl!Xeh^i@bxs5f&SdiD!WN}CIgq&WI4VCW;M!UJL zX2};d^sVj5oVl)OrkapV-C&SrG)*x=X*ru!2s04TjZ`pY$jP)4+%)7&MlpiZ`lgoF zo_p>^4qGz^(Y*uB10dY2kcIbt=$FIdYNqk;~47wf@)6|nJp z1cocL3zDR9N2Pxkw)dpi&_rvMW&Dh0@T*_}(1JFSc0S~Ph2Sr=vy)u*=TY$i_IHSo zR+&dtWFNxHE*!miRJ%o5@~GK^G~4$LzEYR-(B-b(L*3jyTq}M3d0g6sdx!X3-m&O% zK5g`P179KHJKXpIAAX`A2MFUA;`nXx^b?mboVbQgigIHTU8FI>`q53AjWaD&aowtj z{XyIX>c)*nLO~-WZG~>I)4S1d2q@&?nwL)CVSWqWi&m1&#K1!gt`g%O4s$u^->Dwq ziKc&0O9KQ7000OG0000%03-m(e&Y`S09YWC4iYDSty&3q8^?8ij|8zxaCt!zCFq1@ z9TX4Hl68`nY>}cQNW4Ullqp$~SHO~l1!CdFLKK}ij_t^a?I?C^CvlvnZkwiVn>dl2 z2$V(JN{`5`-8ShF_ek6HNRPBlPuIPYu>TAeAV5O2)35r3*_k(Q-h1+h5pb(Zu%oJ__pBsW0n5ILw`!&QR&YV`g0Fe z(qDM!FX_7;`U3rxX#QHT{f%h;)Eursw=*#qvV)~y%^Uo^% zi-%sMe^uz;#Pe;@{JUu05zT*i=u7mU9{MkT`ft(vPdQZoK&2mg=tnf8FsaNQ+QcPg zB>vP8Rd6Z0JoH5_Q`zldg;hx4azQCq*rRZThqlqTRMzn1O3_rQTrHk8LQ<{5UYN~` zM6*~lOGHyAnx&#yCK{i@%N1Us@=6cw=UQxpSE;<(LnnES%6^q^QhBYQ-VCSmIu8wh z@_LmwcFDfAhIn>`%h7L{)iGBzu`Md4dj-m3C8mA9+BL*<>q z#$7^ttIBOE-=^|zmG`K8yUKT{yjLu2SGYsreN0*~9yhFxn4U};Nv1XXj1fH*v-g=3 z@tCPc`YdzQGLp%zXwo*o$m9j-+~nSWls#s|?PyrHO%SUGdk**X9_=|b)Y%^j_V$3S z>mL2A-V)Q}qb(uZipEFVm?}HWc+%G6_K+S+87g-&RkRQ8-{0APDil115eG|&>WQhU zufO*|e`hFks^cJJmx_qNx{ltSp3aT|XgD5-VxGGXb7gkiOG$w^qMVBDjR8%!Sbh72niHRDV* ziFy8LE+*$j?t^6aZP9qt-ow;hzkmhvy*Hn-X^6?yVMbtNbyqZQ^rXg58`gk+I%Wv} zn_)dRq+3xjc8D%}EQ%nnTF7L7m}o9&*^jf`_qvUhVKY7w9Zgxr-0YHWFRd3$l_6UX zpXt^U&TiC*qZWx#pOG6k?3Tg)pra*fw(O6_45>lUBN1U5Qmc>^DHt)5b~Ntjsw!NI z1n4{$HWFeIi)*qvgK^ui;(81VQc1(wJ8C#tjR>Dkjf{xYC^_B^#qrdCc)uZxtgua6 zk98UGQF|;;k`c+0_z)tQ&9DwLB~&12@D1!*mTz_!3Mp=cg;B7Oq4cKN>5v&dW7q@H zal=g6Ipe`siZN4NZiBrkJCU*x216gmbV(FymgHuG@%%|8sgD?gR&0*{y4n=pukZnd z4=Nl~_>jVfbIehu)pG)WvuUpLR}~OKlW|)=S738Wh^a&L+Vx~KJU25o6%G7+Cy5mB zgmYsgkBC|@K4Jm_PwPoz`_|5QSk}^p`XV`649#jr4Lh^Q>Ne~#6Cqxn$7dNMF=%Va z%z9Ef6QmfoXAlQ3)PF8#3Y% zadcE<1`fd1&Q9fMZZnyI;&L;YPuy#TQ8b>AnXr*SGY&xUb>2678A+Y z8K%HOdgq_4LRFu_M>Ou|kj4W%sPPaV)#zDzN~25klE!!PFz_>5wCxglj7WZI13U5| zEq_YLKPH;v8sEhyG`dV_jozR);a6dBvkauhC;1dk%mr+J*Z6MMH9jqxFk@)&h{mHl zrf^i_d-#mTF=6-T8Rk?(1+rPGgl$9=j%#dkf@x6>czSc`jk7$f!9SrV{do%m!t8{? z_iAi$Qe&GDR#Nz^#uJ>-_?(E$ns)(3)X3cYY)?gFvU+N>nnCoBSmwB2<4L|xH19+4 z`$u#*Gt%mRw=*&|em}h_Y`Pzno?k^8e*hEwfM`A_yz-#vJtUfkGb=s>-!6cHfR$Mz z`*A8jVcz7T{n8M>ZTb_sl{EZ9Ctau4naX7TX?&g^VLE?wZ+}m)=YW4ODRy*lV4%-0 zG1XrPs($mVVfpnqoSihnIFkLdxG9um&n-U|`47l{bnr(|8dmglO7H~yeK7-wDwZXq zaHT($Qy2=MMuj@lir(iyxI1HnMlaJwpX86je}e=2n|Esb6hB?SmtDH3 z2qH6o`33b{;M{mDa5@@~1or8+Zcio*97pi1Jkx6v5MXCaYsb~Ynq)eWpKnF{n)FXZ z?Xd;o7ESu&rtMFr5(yJ(B7V>&0gnDdL*4MZH&eO+r*t!TR98ssbMRaw`7;`SLI8mT z=)hSAt~F=mz;JbDI6g~J%w!;QI(X14AnOu;uve^4wyaP3>(?jSLp+LQ7uU(iib%IyB(d&g@+hg;78M>h7yAeq$ALRoHGkKXA+E z$Sk-hd$Fs2nL4w9p@O*Y$c;U)W#d~)&8Js;i^Dp^* z0*7*zEGj~VehF4sRqSGny*K_CxeF=T^8;^lb}HF125G{kMRV?+hYktZWfNA^Mp7y8 zK~Q?ycf%rr+wgLaHQ|_<6z^eTG7izr@99SG9Q{$PCjJabSz`6L_QJJe7{LzTc$P&pwTy<&3RRUlSHmK;?}=QAhQaDW3#VWcNAH3 zeBPRTDf3?3mfdI$&WOg(nr9Gyzg`&u^o!f2rKJ57D_>p z6|?Vg?h(@(*X=o071{g^le>*>qSbVam`o}sAK8>b|11%e&;%`~b2OP7--q%0^2YDS z`2M`{2QYr1VC)sIW9WOu8<~7Q>^$*Og{KF+kI;wFegvaIDkB%3*%PWtWKSq7l`1YcDxQQ2@nv{J!xWV?G+w6C zhUUxUYVf%(Q(40_xrZB@rbxL=Dj3RV^{*yHd>4n-TOoHVRnazDOxxkS9kiZyN}IN3 zB^5N=* zRSTO+rA<{*P8-$GZdyUNOB=MzddG$*@q>mM;pUIiQ_z)hbE#Ze-IS)9G}Rt$5PSB{ zZZ;#h9nS7Rf1ecW&n(Gpu9}{vXQZ-f`UHIvD?cTbF`YvH*{rgE(zE22pLAQfhg-`U zuh612EpByB(~{w7svCylrBk%5$LCIyuhrGi=yOfca`=8ltKxHcSNfDRt@62QH^R_0 z&eQL6rRk>Dvf6rjMQv5ZXzg}S`HqV69hJT^pPHtdhqsrPJWs|IT9>BvpQa@*(FX6v zG}TYjreQCnH(slMt5{NgUf)qsS1F&Bb(M>$X}tWI&yt2I&-rJbqveuj?5J$`Dyfa2 z)m6Mq0XH@K)Y2v8X=-_4=4niodT&Y7W?$KLQhjA<+R}WTdYjX9>kD+SRS^oOY1{A= zZTId-(@wF^UEWso($wZtrs%e7t<}YaC_;#@`r0LUzKY&|qPJz*y~RHG`E6bypP5AX zN!p0^AUu8uDR>xM-ALFzBxXM~Q3z=}fHWCIG>0&I6x2Iu7&U)49j7qeMI&?qb$=4I zdMmhAJrO%@0f%YW! z^gLByEGSk+R0v4*d4w*N$Ju6z#j%HBI}6y$2en=-@S3=6+yZX94m&1j@s- z7T6|#0$c~dYq9IkA!P)AGkp~S$zYJ1SXZ#RM0|E~Q0PSm?DsT4N3f^)b#h(u9%_V5 zX*&EIX|gD~P!vtx?ra71pl%v)F!W~X2hcE!h8cu@6uKURdmo1-7icN4)ej4H1N~-C zjXgOK+mi#aJv4;`DZ%QUbVVZclkx;9`2kgbAhL^d{@etnm+5N8pB#fyH)bxtZGCAv z(%t0kPgBS{Q2HtjrfI0B$$M0c?{r~2T=zeXo7V&&aprCzww=i*}Atu7g^(*ivauMz~kkB%Vt{Wydlz%%2c26%>0PAbZO zVHx%tK(uzDl#ZZK`cW8TD2)eD77wB@gum{B2bO_jnqGl~01EF_^jx4Uqu1yfA~*&g zXJ`-N?D-n~5_QNF_5+Un-4&l$1b zVlHFqtluoN85b^C{A==lp#hS9J(npJ#6P4aY41r) zzCmv~c77X5L}H%sj>5t&@0heUDy;S1gSOS>JtH1v-k5l}z2h~i3^4NF6&iMb;ZYVE zMw*0%-9GdbpF1?HHim|4+)Zed=Fk<2Uz~GKc^P(Ig@x0&XuX0<-K(gA*KkN&lY2Xu zG054Q8wbK~$jE32#Ba*Id2vkqmfV{U$Nx9vJ;jeI`X+j1kh7hB8$CBTe@ANmT^tI8 z%U>zrTKuECin-M|B*gy(SPd`(_xvxjUL?s137KOyH>U{z01cBcFFt=Fp%d+BK4U;9 zQG_W5i)JASNpK)Q0wQpL<+Ml#cei41kCHe&P9?>p+KJN>I~`I^vK1h`IKB7k^xi`f z$H_mtr_+@M>C5+_xt%v}{#WO{86J83;VS@Ei3JLtp<*+hsY1oGzo z0?$?OJO$79;{|@aP!fO6t9TJ!?8i&|c&UPWRMbkwT3nEeFH`Yyyh6b%Rm^nBuTt@9 z+$&-4lf!G|@LCo3<8=yN@5dYbc%uq|Hz|0tiiLQKiUoM9g14zyECKGv0}3AWv2WJ zUAXGUhvkNk`0-H%ACsRSmy4fJ@kxBD3ZKSj6g(n1KPw?g{v19phcBr3BEF>J%lL|d zud3LNuL;cR*xS+;X+N^Br+x2{&hDMhb-$6_fKU(Pt0FQUXgNrZvzsVCnsFqv?#L z4-FYsQ-?D>;LdjHu_TT1CHN~aGkmDjWJkJg4G^!+V_APd%_48tErDv6BW5;ji^UDD zRu5Sw7wwplk`w{OGEKWJM&61c-AWn!SeUP8G#+beH4_Ov*)NUV?eGw&GHNDI6G(1Y zTfCv?T*@{QyK|!Q09wbk5koPD>=@(cA<~i4pSO?f(^5sSbdhUc+K$DW#_7^d7i%At z?KBg#vm$?P4h%?T=XymU;w*AsO_tJr)`+HUll+Uk_zx6vNw>G3jT){w3ck+Z=>7f0 zZVkM*!k^Z_E@_pZK6uH#|vzoL{-j1VFlUHP&5~q?j=UvJJNQG ztQdiCF$8_EaN_Pu8+afN6n8?m5UeR_p_6Log$5V(n9^W)-_vS~Ws`RJhQNPb1$C?| zd9D_ePe*`aI9AZ~Ltbg)DZ;JUo@-tu*O7CJ=T)ZI1&tn%#cisS85EaSvpS~c#CN9B z#Bx$vw|E@gm{;cJOuDi3F1#fxWZ9+5JCqVRCz5o`EDW890NUfNCuBn)3!&vFQE{E$L`Cf7FMSSX%ppLH+Z}#=p zSow$)$z3IL7frW#M>Z4|^9T!=Z8}B0h*MrWXXiVschEA=$a|yX9T~o!=%C?T+l^Cc zJx&MB$me(a*@lLLWZ=>PhKs!}#!ICa0! zq%jNgnF$>zrBZ3z%)Y*yOqHbKzEe_P=@<5$u^!~9G2OAzi#}oP&UL9JljG!zf{JIK z++G*8j)K=$#57N)hj_gSA8golO7xZP|KM?elUq)qLS)i(?&lk{oGMJh{^*FgklBY@Xfl<_Q zXP~(}ST6V01$~VfOmD6j!Hi}lsE}GQikW1YmBH)`f_+)KI!t#~B7=V;{F*`umxy#2Wt8(EbQ~ks9wZS(KV5#5Tn3Ia90r{}fI%pfbqBAG zhZ)E7)ZzqA672%@izC5sBpo>dCcpXi$VNFztSQnmI&u`@zQ#bqFd9d&ls?RomgbSh z9a2rjfNiKl2bR!$Y1B*?3Ko@s^L5lQN|i6ZtiZL|w5oq%{Fb@@E*2%%j=bcma{K~9 z*g1%nEZ;0g;S84ZZ$+Rfurh;Nhq0;{t~(EIRt}D@(Jb7fbe+_@H=t&)I)gPCtj*xI z9S>k?WEAWBmJZ|gs}#{3*pR`-`!HJ)1Dkx8vAM6Tv1bHZhH=MLI;iC#Y!$c|$*R>h zjP{ETat(izXB{@tTOAC4nWNhh1_%7AVaf!kVI5D=Jf5I1!?}stbx_Yv23hLf$iUTb z-)WrTtd2X+;vBW_q*Z6}B!10fs=2FA=3gy*dljsE43!G*3Uw(Is>(-a*5E!T4}b-Y zfvOC)-HYjNfcpi`=kG%(X3XcP?;p&=pz+F^6LKqRom~pA}O* zitR+Np{QZ(D2~p_Jh-k|dL!LPmexLM?tEqI^qRDq9Mg z5XBftj3z}dFir4oScbB&{m5>s{v&U=&_trq#7i&yQN}Z~OIu0}G)>RU*`4<}@7bB% zKYxGx0#L#u199YKSWZwV$nZd>D>{mDTs4qDNyi$4QT6z~D_%Bgf?>3L#NTtvX;?2D zS3IT*2i$Snp4fjDzR#<)A``4|dA(}wv^=L?rB!;kiotwU_gma`w+@AUtkSyhwp{M} z!e`jbUR3AG4XvnBVcyIZht6Vi~?pCC!$XF2 z*V~)DBVm8H7$*OZQJYl3482hadhsI2NCz~_NINtpC?|KI6H3`SG@1d%PsDdw{u}hq zN;OU~F7L1jT&KAitilb&Fl3X12zfSuFm;X)xQWOHL&7d)Q5wgn{78QJ6k5J;is+XP zCPO8_rlGMJB-kuQ*_=Yo1TswG4xnZd&eTjc8=-$6J^8TAa~kEnRQ@Zp-_W&B(4r@F zA==}0vBzsF1mB~743XqBmL9=0RSkGn$cvHf*hyc{<2{@hW+jKjbC|y%CNupHY_NC% zivz^btBLP-cDyV8j>u)=loBs>HoI5ME)xg)oK-Q0wAy|8WD$fm>K{-`0|W{H00;;G z000j`0OWQ8aHA9e04^;603eeQIvtaXMG=2tcr1y8Fl-J;AS+=<0%DU8Bp3oEEDhA^ zOY)M8%o5+cF$rC?trfMcty*f)R;^v=f~}||Xe!#;T3eTDZELN&-50xk+J1heP5AQ>h5O#S_uO;O@;~REd*_G$x$hVeE#bchX)otXQy|S5(oB)2a2%Sc(iDHm z=d>V|a!BLp9^#)o7^EQ2kg=K4%nI^sK2w@-kmvB+ARXYdq?xC2age6)e4$^UaY=wn zgLD^{X0A+{ySY+&7RpldwpC6=E zSPq?y(rl8ZN%(A*sapd4PU+dIakIwT0=zxIJEUW0kZSo|(zFEWdETY*ZjIk9uNMUA ze11=mHu8lUUlgRx!hItf0dAF#HfdIB+#aOuY--#QN9Ry zbx|XkG?PrBb@l6Owl{9Oa9w{x^R}%GwcEEfY;L-6OU8|9RXvu`-ECS`jcO1x1MP{P zcr;Bw##*Dod9K@pEx9z9G~MiNi>8v1OU-}vk*HbI)@CM? zn~b=jWUF%HP=CS+VCP>GiAU_UOz$aq3%%Z2laq^Gx`WAEmuNScCN)OlW>YHGYFgV2 z42lO5ZANs5VMXLS-RZTvBJkWy*OeV#L;7HwWg51*E|RpFR=H}h(|N+79g)tIW!RBK ze08bg^hlygY$C2`%N>7bDm`UZ(5M~DTanh3d~dg+OcNdUanr8azO?})g}EfnUB;5- zE1FX=ru?X=zAk4_6@__o1fE+ml1r&u^f1Kb24Jf-)zKla%-dbd>UZ1 zrj3!RR!Jg`ZnllKJ)4Yfg)@z>(fFepeOcp=F-^VHv?3jSxfa}-NB~*qkJ5Uq(yn+( z<8)qbZh{C!xnO@-XC~XMNVnr-Z+paowv!$H7>`ypMwA(X4(knx7z{UcWWe-wXM!d? zYT}xaVy|7T@yCbNOoy)$D=E%hUNTm(lPZqL)?$v+-~^-1P8m@Jm2t^L%4#!JK#Vtg zyUjM+Y*!$);1<)0MUqL00L0*EZcsE&usAK-?|{l|-)b7|PBKl}?TM6~#j9F+eZq25_L&oSl}DOMv^-tacpDI)l*Ws3u+~jO@;t(T)P=HCEZ#s_5q=m zOsVY!QsOJn)&+Ge6Tm)Ww_Bd@0PY(78ZJ)7_eP-cnXYk`>j9q`x2?Xc6O@55wF+6R zUPdIX!2{VGA;FSivN@+;GNZ7H2(pTDnAOKqF*ARg+C54vZ@Ve`i?%nDDvQRh?m&`1 zq46gH)wV=;UrwfCT3F(m!Q5qYpa!#f6qr0wF=5b9rk%HF(ITc!*R3wIFaCcftGwPt z(kzx{$*>g5L<;u}HzS4XD%ml zmdStbJcY@pn`!fUmkzJ8N>*8Y+DOO^r}1f4ix-`?x|khoRvF%jiA)8)P{?$8j2_qN zcl3Lm9-s$xdYN9)>3j6BPFK)Jbovl|Sf_p((CHe!4hx@F)hd&&*Xb&{TBj>%pT;-n z{3+hA^QZYnjXxtF2XwxPZ`S#J8h>5qLwtwM-{5abbEnRS z`9_`Zq8FJiI#0syE_V_3M&trw$P=ezkHosV$8&I5c0(*-9KBE5DJOC-Xv zw}1bq~AD0_Xerm`%ryiG9_$S z5G|btfiAUNdV09SO2l9v+e#(H6HYOdQs=^ z@xwZQU)~;p1L*~ciC}9ao{nQ-@B>rpUzKBxv=cUusOP5Trs3QnvHxGh9e>s7AM{V1|HfYe z3QwH;nHHR49fYzuGc3W3l5xrDAI392SFXx>lWE3V9Ds9il3PyZaN5>oC3>9W-^7vC z3~KZ-@iD?tIkhg+6t{m;RGk2%>@I0&kf)o$+-^ls0(YABNbM(=l#ad@nKp_j=b~Xs ziR;xu_+)lxy6|+af!@}gO2H_x)p;nZ-tYxW5Omq=l`GzMp*GTLr>vZN1?e}^C$t*Z zvzEdIc2|HA2RFN_4#EkzMqKnbbw!?!?%B@M0^^5Z;K?x-%lg?Z>}wMV8zEqHZ$cr~Y#Wv>9+)KMUZatUqbRU8 z8t9qrek(H^C0Tuzq|cP2$WL7tzj+Dj5y^2SF1D154CnsB$xbz`$wV||n-cG%rsT$p z+3RHdadK(3-noj(2L#8c5lODg)V8pv(GEnNb@F>dEHQr>!qge@L>#qg)RAUtiOYqF ziiV_ETExwD)bQ<))?-9$)E(FiRBYyC@}issHS!j9n)~I1tarxnQ2LfjdIJ)*jp{0E z&1oTd%!Qbw$W58s!6ms>F z=p0!~_Mv~8jyaicOS*t(ntw`5uFi0Bc4*mH8kSkk$>!f0;FM zX_t14I55!ZVsg0O$D2iuEDb7(J>5|NKW^Z~kzm@dax z9(|As$U7^}LF%#`6r&UPB*6`!Rf74h~*C=ami6xUxYCwiJxdr$+`z zKSC4A%8!s%R&j*2si(OEc*fy!q)?%=TjDZJ2}O zxT6o>jlKXz_7_Y$N})}IG`*#KfMzs#R(SI#)3*ZEzCv%_tu(VTZ5J| zw2$5kK)xTa>xGFgS0?X(NecjzFVKG%VVn?neu=&eQ+DJ1APlY1E?Q1s!Kk=yf7Uho z>8mg_!U{cKqpvI3ucSkC2V`!d^XMDk;>GG~>6>&X_z75-kv0UjevS5ORHV^e8r{tr z-9z*y&0eq3k-&c_AKw~<`8dtjsP0XgFv6AnG?0eo5P14T{xW#b*Hn2gEnt5-KvN1z zy!TUSi>IRbD3u+h@;fn7fy{F&hAKx7dG4i!c?5_GnvYV|_d&F16p;)pzEjB{zL-zr z(0&AZUkQ!(A>ghC5U-)t7(EXb-3)tNgb=z`>8m8n+N?vtl-1i&*ftMbE~0zsKG^I$ zSbh+rUiucsb!Ax@yB}j>yGeiKIZk1Xj!i#K^I*LZW_bWQIA-}FmJ~^}>p=K$bX9F{}z{s^KWc~OK(zl_X57aB^J9v}yQ5h#BE$+C)WOglV)nd0WWtaF{7`_Ur`my>4*NleQG#xae4fIo(b zW(&|g*#YHZNvDtE|6}yHvu(hDekJ-t*f!2RK;FZHRMb*l@Qwkh*~CqQRNLaepXypX z1?%ATf_nHIu3z6gK<7Dmd;{`0a!|toT0ck|TL$U;7Wr-*piO@R)KrbUz8SXO0vr1K z>76arfrqImq!ny+VkH!4?x*IR$d6*;ZA}Mhro(mzUa?agrFZpHi*)P~4~4N;XoIvH z9N%4VK|j4mV2DRQUD!_-9fmfA2(YVYyL#S$B;vqu7fnTbAFMqH``wS7^B5=|1O&fL z)qq(oV6_u4x(I(**#mD}MnAy(C&B4a1n6V%$&=vrIDq^F_KhE5Uw8_@{V`_#M0vCu zaNUXB=n0HT@D+ppDXi8-vp{tj)?7+k>1j}VvEKRgQ~DWva}8*pp`W8~KRo*kJ*&X} zP!~2fxQr@dM*q0dI|)Fux=pZWBk==RI7i{^BQf`kWlD2%|@R9!JA7& zLbM$uJ12y}_62$|T|{)@OJZtzfpL^t@1nMTYHutrF#D+^?~CN~9`YQ@#&&@c_Zf)( zbC~y8!2LO8jHwQXv>G~1q?c68ipT*%dY&c{8wd_!Y#~tMJ7yk!F8| zt?m_CLVw6cU@@p(#h4cY&Qsfz2Xp3w^4Cg%m03Tmq~9n%hyoMH^KY7{(QkRyn_!YB zzZa!Tgr~5$MAG$x)Fs71#6j}Kvcv3=9VUX8CH< zbP3|fY8f#$K*<5JQ7whM(v=GN2k26Xsh)#0!HKS(koLgAp-;)8z0w&_Z=nG4v6n8u z&Tm0Fi){4_!Y5Kp?!zv$FKfUifQ{%c82uYfrvE{%ejUd72aNYmI*0z3-a-EYr+bB->oH3#t(AY3 zV{Z=(SJr;D#0(`u*dc*~9T7D8Pudw894%!>c4wU&V1m<~0InidR6fbi?yPl(z+sKa zdF*kS>_4^1UO>y4T%Ar>epSr5&vp`$KdY7B(F%P0@VyHk@1fJ=6X0=aGjD-)BrOJD zW}IU@hg~^2r>a1fQvjTtvL*mKJ7q;pfP*U2=URL`VB_Y_JojbZ+MS=vaVN0C6L_MV zG1#5=35-E`KsD%r>-Q_ndvJ2tOYcMMP9f*t0iJ`(Z`^+YP)h>@lR(@Wvrt-`0tHG+ zuP2R@@mx=T@fPoQ1s`e^1I0H*kQPBGDky@!ZQG@8jY-+2ihreG5q$6i{3vmDTg0j$ zzRb*-nKN@{_wD`V6+i*YS)?$XfrA-sW?js?SYU8#vXxxQCc|*K!EbpWfu)3~jwq6_@KC0m;3A%jH^18_a0;ksC2DEwa@2{9@{ z9@T??<4QwR69zk{UvcHHX;`ICOwrF;@U;etd@YE)4MzI1WCsadP=`%^B>xPS-{`=~ zZ+2im8meb#4p~XIL9}ZOBg7D8R=PC8V}ObDcxEEK(4yGKcyCQWUe{9jCs+@k!_y|I z%s{W(&>P4w@hjQ>PQL$zY+=&aDU6cWr#hG)BVCyfP)h>@3IG5I2mk;8K>)Ppba*!h z005B=001VF5fT=Y4_ytCUk`sv8hJckqSy&Gc2Jx^WJ$J~08N{il-M$fz_ML$)Cpil z(nOv_nlZB^c4s&&O3h=OLiCz&(|f0 zxWU_-JZy>hxP*gvR>CLnNeQ1~g;6{g#-}AbkIzWR;j=8=6!AHpKQCbjFYxf9h%bov zVi;eNa1>t-<14KERUW>^KwoF+8zNo`Y*WiQwq}3m0_2RYtL9Wmu`JaRaQMQ)`Si^6+VbM`!rH~T?DX2=(n4nT zf`G`(Rpq*pDk*v~wMYPZ@vMNZDMPnxMYmU!lA{Xfo?n=Ibb4y3eyY1@Dut4|Y^ml& zqs$r}jAo=B(Ml>ogeEjyv(E`=kBzPf2uv9TQtO$~bamD#=Tv`lNy(K|w$J2O6jS51 zzZtOCHDWz7W0=L1XDW5WR5mtLGc~W+>*vX5{e~U@rE~?7e>vKU-v8bj;F4#abtcV(3ZtwXo9ia93HiETyQXwW4a-0){;$OU*l` zW^bjkyZTJ6_DL^0}`*)#EZ|2nvKRzMLH9-~@Z6$v#t8Dm%(qpP+DgzNe6d)1q zBqhyF$jJTyYFvl_=a>#I8jhJ)d6SBNPg#xg2^kZ3NX8kQ74ah(Y5Z8mlXyzTD&}Q8 ziY(pj-N-V2f>&hZQJ`Di%wp2fN(I%F@l)3M8GcSdNy+#HuO{$I8NXubRlFkL)cY@b z#`v{}-^hRXEq*8B_cG=%PZvI$eo(|8Wc(2o8L#0_GX9L$1@yV>%7mGk)QTD1R*OvS z4OW;ym1)%k9Bfem0tOqq3yyAUWp&q|LsN!RDnxa|j;>R|Mm2rIv7=tej5GFaa+`#| z;7u9Z_^XV+vD@2hF8Xe63+Qd`oig6S9jX(*DbjzPb*K-H7c^7E-(~!R6E%TrgW;RvG;WS{Ziv*W*a*`9Bb;$Er3?MyF~5GcXv`k>U)n}lwv$Sp+H@IKA5$mKk0g*4Ln{!tfvITeY zzr%8JJ5BdcEYsR9eGzJ4B&$}4FMmbRU6{8{_w7Kl77@PNe7|Bc#c?5(C5&Z=kJ#(oM90D4`rh2S!|^L!P#e#1hkD5@~-- z`63GV0~*rOZSqw7k^#-Y$Q4z3Oa2SPRURqEahB1B^h{7~+p03SwzqL9QU#$3-X zdYtQ?-K5xDAdfomEd6(yPtZ!yY_<35bMedeq`z2JWorljz5-f9<^93HM-$#+acw%9r!JOM%O<|BR`W& zd-%j_?b^q7Kl6{q^N{cg2u;11rFB5EP+oqG9&pHD#_Mo@aNMj;LUvsl&nK(ca(hT( zzFc2oHC6WQv8g7jo+3ZSwK+9G$cvfRnql)?g=XeQ3+LTh3)79nhEle8OqS3T$qn(> z(=5Bg?EWq-ldEywgzXW965%H(9^ik*rH(8dNdkbcS9|ow&_r`X~R^R?B+(oTiMzzlx8KnHqUi z8Rh-)VAnS-CO+3}yxqm8)X+N+uzieFVm-F#syP#M1p5&$wX3MJ8 z+R@grZ*5G^Uh4I@VT=>C4RJNc^~3mx$kS1F{L?3)BzdduD2MZKdu#jNno&f2&d{?` zW(>$oktzY@GO{|Ln~Bt^A4)(%?l-&(Dm!iL#$K_xOyhwAf=K2<+Bom zw7|hl6E5}B$d%n0sfZvfQRy9Fyz2~ z83#=#LaHnf1th^k*p|ux8!!8pfHE!)x*%=_hAddl)P%4h4%&8!5-W#xqqb}c=H(i|wqcIS&oDQ{ zhI7N-$f$ra3=RjPmMh?-IEkJYQ<}R9Z!}wmp$#~Uc%u1oh#TP}wF*kJJmQX2#27kL z_dz(yKufo<=m71bZfLp^Ll#t3(IHkrgMcvx@~om%Ib(h(<$Da7urTI`x|%`wD--sN zJEEa>4DGSEG?0ulkosfj8IMNN4)B=ZtvGG{|4Fp=Xhg!wPNgYzS>{Bp%%Qa+624X@ X49Luk)baa85H9$5YCsTPT`SVRWMtMW diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 549d84424..ffed3a254 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-6.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0c8..c53aefaa5 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -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 - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - 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" ;; +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. -# 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" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/src/main/java/com/simibubi/create/AllBlockPartials.java b/src/main/java/com/simibubi/create/AllBlockPartials.java index e1624bb5c..fffc1e3cd 100644 --- a/src/main/java/com/simibubi/create/AllBlockPartials.java +++ b/src/main/java/com/simibubi/create/AllBlockPartials.java @@ -9,8 +9,8 @@ import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlo import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.item.DyeColor; -import net.minecraft.util.Direction; +import net.minecraft.world.item.DyeColor; +import net.minecraft.core.Direction; public class AllBlockPartials { diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 72b09b2b7..c923dc205 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -177,30 +177,30 @@ import com.simibubi.create.foundation.worldgen.OxidizingBlock; import com.tterrag.registrate.providers.RegistrateRecipeProvider; import com.tterrag.registrate.util.entry.BlockEntry; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.MaterialColor; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.material.MaterialColor; import net.minecraft.client.renderer.RenderType; -import net.minecraft.data.ShapedRecipeBuilder; -import net.minecraft.item.DyeColor; -import net.minecraft.item.Item; -import net.minecraft.item.Rarity; -import net.minecraft.loot.ConstantRange; -import net.minecraft.loot.ItemLootEntry; -import net.minecraft.loot.LootPool; -import net.minecraft.loot.LootTable; -import net.minecraft.loot.LootTable.Builder; -import net.minecraft.loot.conditions.ILootCondition.IBuilder; -import net.minecraft.loot.conditions.SurvivesExplosion; -import net.minecraft.loot.functions.CopyName; -import net.minecraft.loot.functions.CopyNbt; -import net.minecraft.state.properties.PistonType; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Rarity; +import net.minecraft.world.level.storage.loot.ConstantIntValue; +import net.minecraft.world.level.storage.loot.entries.LootItem; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.LootTable.Builder; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition.Builder; +import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition; +import net.minecraft.world.level.storage.loot.functions.CopyNameFunction; +import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction; +import net.minecraft.world.level.block.state.properties.PistonType; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.ResourceLocation; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.Tags; @@ -223,13 +223,13 @@ public class AllBlocks { .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), AssetLookup.partialBaseModel(ctx, prov))) .loot((lt, block) -> { Builder builder = LootTable.lootTable(); - IBuilder survivesExplosion = SurvivesExplosion.survivesExplosion(); + Builder survivesExplosion = ExplosionCondition.survivesExplosion(); lt.add(block, builder.withPool(LootPool.lootPool() .when(survivesExplosion) - .setRolls(ConstantRange.exactly(1)) - .add(ItemLootEntry.lootTableItem(AllBlocks.SCHEMATICANNON.get() + .setRolls(ConstantIntValue.exactly(1)) + .add(LootItem.lootTableItem(AllBlocks.SCHEMATICANNON.get() .asItem()) - .apply(CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY) + .apply(CopyNbtFunction.copyData(CopyNbtFunction.DataSource.BLOCK_ENTITY) .copy("Options", "BlockEntityTag.Options"))))); }) .item() @@ -291,7 +291,7 @@ public class AllBlocks { public static final BlockEntry GEARBOX = REGISTRATE.block("gearbox", GearboxBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .transform(BlockStressDefaults.setNoImpact()) .onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(AllSpriteShifts.ANDESITE_CASING))) .onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, AllSpriteShifts.ANDESITE_CASING, @@ -303,7 +303,7 @@ public class AllBlocks { public static final BlockEntry CLUTCH = REGISTRATE.block("clutch", ClutchBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .transform(BlockStressDefaults.setNoImpact()) .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) .item() @@ -312,7 +312,7 @@ public class AllBlocks { public static final BlockEntry GEARSHIFT = REGISTRATE.block("gearshift", GearshiftBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .transform(BlockStressDefaults.setNoImpact()) .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) .item() @@ -322,7 +322,7 @@ public class AllBlocks { public static final BlockEntry ENCASED_CHAIN_DRIVE = REGISTRATE.block("encased_chain_drive", EncasedBeltBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .transform(BlockStressDefaults.setNoImpact()) .blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> p.models() .getExistingFile(p.modLoc("block/" + c.getName() + "/" + suffix))).generate(c, p)) @@ -333,7 +333,7 @@ public class AllBlocks { public static final BlockEntry ADJUSTABLE_CHAIN_GEARSHIFT = REGISTRATE.block("adjustable_chain_gearshift", AdjustablePulleyBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .transform(BlockStressDefaults.setNoImpact()) .blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> { String powered = state.getValue(AdjustablePulleyBlock.POWERED) ? "_powered" : ""; @@ -370,7 +370,7 @@ public class AllBlocks { public static final BlockEntry WATER_WHEEL = REGISTRATE.block("water_wheel", WaterWheelBlock::new) .initialProperties(SharedProperties::wooden) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.directionalBlockProviderIgnoresWaterlogged(false)) .addLayer(() -> RenderType::cutoutMipped) .transform(BlockStressDefaults.setCapacity(16.0)) @@ -436,7 +436,7 @@ public class AllBlocks { public static final BlockEntry CRUSHING_WHEEL = REGISTRATE.block("crushing_wheel", CrushingWheelBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.axisBlockProvider(false)) .addLayer(() -> RenderType::cutoutMipped) .transform(BlockStressDefaults.setImpact(8.0)) @@ -456,7 +456,7 @@ public class AllBlocks { public static final BlockEntry MECHANICAL_PRESS = REGISTRATE.block("mechanical_press", MechanicalPressBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.horizontalBlockProvider(true)) .transform(BlockStressDefaults.setImpact(8.0)) .item(AssemblyOperatorBlockItem::new) @@ -466,7 +466,7 @@ public class AllBlocks { public static final BlockEntry MECHANICAL_MIXER = REGISTRATE.block("mechanical_mixer", MechanicalMixerBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p))) .addLayer(() -> RenderType::cutoutMipped) .transform(BlockStressDefaults.setImpact(4.0)) @@ -523,7 +523,7 @@ public class AllBlocks { public static final BlockEntry WEIGHTED_EJECTOR = REGISTRATE.block("weighted_ejector", EjectorBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate((c, p) -> p.horizontalBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p), 180)) .transform(BlockStressDefaults.setImpact(2.0)) .item(EjectorItem::new) @@ -588,7 +588,7 @@ public class AllBlocks { public static final BlockEntry ENCASED_FLUID_PIPE = REGISTRATE.block("encased_fluid_pipe", EncasedPipeBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.encasedPipe()) .onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(AllSpriteShifts.COPPER_CASING))) .onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, AllSpriteShifts.COPPER_CASING, @@ -657,7 +657,7 @@ public class AllBlocks { public static final BlockEntry FLUID_TANK = REGISTRATE.block("fluid_tank", FluidTankBlock::regular) .initialProperties(SharedProperties::softMetal) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(new FluidTankGenerator()::generate) .onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::standard)) .addLayer(() -> RenderType::cutoutMipped) @@ -670,7 +670,7 @@ public class AllBlocks { REGISTRATE.block("creative_fluid_tank", FluidTankBlock::creative) .initialProperties(SharedProperties::softMetal) .tag(AllBlockTags.SAFE_NBT.tag) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(new FluidTankGenerator("creative_")::generate) .onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::creative)) .addLayer(() -> RenderType::cutoutMipped) @@ -748,7 +748,7 @@ public class AllBlocks { public static final BlockEntry GANTRY_CARRIAGE = REGISTRATE.block("gantry_carriage", GantryCarriageBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.directionalAxisBlockProvider()) .item() .transform(customItemModel()) @@ -827,7 +827,7 @@ public class AllBlocks { public static final BlockEntry CART_ASSEMBLER = REGISTRATE.block("cart_assembler", CartAssemblerBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.cartAssembler()) .addLayer(() -> RenderType::cutoutMipped) .tag(BlockTags.RAILS, AllBlockTags.SAFE_NBT.tag) @@ -838,7 +838,7 @@ public class AllBlocks { public static final BlockEntry REINFORCED_RAIL = REGISTRATE.block("reinforced_rail", ReinforcedRailBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.reinforcedRail()) .addLayer(() -> RenderType::cutoutMipped) .tag(BlockTags.RAILS) @@ -901,7 +901,7 @@ public class AllBlocks { public static final BlockEntry STICKER = REGISTRATE.block("sticker", StickerBlock::new) .initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .addLayer(() -> RenderType::cutoutMipped) .blockstate((c, p) -> p.directionalBlock(c.get(), AssetLookup.forPowered(c, p))) .item() @@ -1010,7 +1010,7 @@ public class AllBlocks { public static final BlockEntry SAIL_FRAME = REGISTRATE.block("sail_frame", p -> SailBlock.frame(p)) .initialProperties(SharedProperties::wooden) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.directionalBlockProvider(false)) .tag(AllBlockTags.WINDMILL_SAILS.tag) .tag(AllBlockTags.FAN_TRANSPARENT.tag) @@ -1019,7 +1019,7 @@ public class AllBlocks { public static final BlockEntry SAIL = REGISTRATE.block("white_sail", p -> SailBlock.withCanvas(p, DyeColor.WHITE)) .initialProperties(SharedProperties::wooden) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.directionalBlockProvider(false)) .tag(AllBlockTags.WINDMILL_SAILS.tag) .simpleItem() @@ -1031,7 +1031,7 @@ public class AllBlocks { } String colourName = colour.getSerializedName(); return REGISTRATE.block(colourName + "_sail", p -> SailBlock.withCanvas(p, colour)) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .initialProperties(SharedProperties::wooden) .blockstate((c, p) -> p.directionalBlock(c.get(), p.models() .withExistingParent(colourName + "_sail", p.modLoc("block/white_sail")) @@ -1070,7 +1070,7 @@ public class AllBlocks { public static final BlockEntry MECHANICAL_CRAFTER = REGISTRATE.block("mechanical_crafter", MechanicalCrafterBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate(BlockStateGen.horizontalBlockProvider(true)) .transform(BlockStressDefaults.setImpact(2.0)) .onRegister(CreateRegistrate.connectedTextures(new CrafterCTBehaviour())) @@ -1083,7 +1083,7 @@ public class AllBlocks { REGISTRATE.block("sequenced_gearshift", SequencedGearshiftBlock::new) .initialProperties(SharedProperties::stone) .tag(AllBlockTags.SAFE_NBT.tag) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .transform(BlockStressDefaults.setNoImpact()) .blockstate(new SequencedGearshiftGenerator()::generate) .item() @@ -1092,7 +1092,7 @@ public class AllBlocks { public static final BlockEntry FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new) .initialProperties(SharedProperties::softMetal) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .transform(BlockStressDefaults.setNoImpact()) .blockstate(new FlywheelGenerator()::generate) .item() @@ -1325,15 +1325,15 @@ public class AllBlocks { .transform(BlockStressDefaults.setImpact(4.0)) .loot((lt, block) -> { Builder builder = LootTable.lootTable(); - IBuilder survivesExplosion = SurvivesExplosion.survivesExplosion(); + Builder survivesExplosion = ExplosionCondition.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) + .setRolls(ConstantIntValue.exactly(1)) + .add(LootItem.lootTableItem(AllItems.COPPER_BACKTANK.get()) + .apply(CopyNameFunction.copyName(CopyNameFunction.NameSource.BLOCK_ENTITY)) + .apply(CopyNbtFunction.copyData(CopyNbtFunction.DataSource.BLOCK_ENTITY) .copy("Air", "Air")) - .apply(CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY) + .apply(CopyNbtFunction.copyData(CopyNbtFunction.DataSource.BLOCK_ENTITY) .copy("Enchantments", "Enchantments"))))); }) .register(); @@ -1358,13 +1358,13 @@ public class AllBlocks { .addLayer(() -> RenderType::cutoutMipped) .loot((lt, block) -> { Builder builder = LootTable.lootTable(); - IBuilder survivesExplosion = SurvivesExplosion.survivesExplosion(); + Builder survivesExplosion = ExplosionCondition.survivesExplosion(); lt.add(block, builder.withPool(LootPool.lootPool() .when(survivesExplosion) - .setRolls(ConstantRange.exactly(1)) - .add(ItemLootEntry.lootTableItem(block) - .apply(CopyName.copyName(CopyName.Source.BLOCK_ENTITY)) - .apply(CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY) + .setRolls(ConstantIntValue.exactly(1)) + .add(LootItem.lootTableItem(block) + .apply(CopyNameFunction.copyName(CopyNameFunction.NameSource.BLOCK_ENTITY)) + .apply(CopyNbtFunction.copyData(CopyNbtFunction.DataSource.BLOCK_ENTITY) .copy("Inventory", "Inventory"))))); }) .blockstate((c, p) -> { diff --git a/src/main/java/com/simibubi/create/AllContainerTypes.java b/src/main/java/com/simibubi/create/AllContainerTypes.java index 79e5745f3..6ac450e91 100644 --- a/src/main/java/com/simibubi/create/AllContainerTypes.java +++ b/src/main/java/com/simibubi/create/AllContainerTypes.java @@ -21,9 +21,9 @@ import com.tterrag.registrate.builders.ContainerBuilder.ScreenFactory; import com.tterrag.registrate.util.entry.ContainerEntry; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.client.gui.IHasContainer; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.inventory.container.Container; +import net.minecraft.client.gui.screens.inventory.MenuAccess; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.world.inventory.AbstractContainerMenu; public class AllContainerTypes { @@ -51,7 +51,7 @@ public class AllContainerTypes { public static final ContainerEntry TOOLBOX = register("toolbox", ToolboxContainer::new, () -> ToolboxScreen::new); - private static > ContainerEntry register(String name, ForgeContainerFactory factory, NonNullSupplier> screenFactory) { + private static > ContainerEntry register(String name, ForgeContainerFactory factory, NonNullSupplier> screenFactory) { return Create.registrate().container(name, factory, screenFactory).register(); } diff --git a/src/main/java/com/simibubi/create/AllEnchantments.java b/src/main/java/com/simibubi/create/AllEnchantments.java index eae8bf6e0..0bce6731c 100644 --- a/src/main/java/com/simibubi/create/AllEnchantments.java +++ b/src/main/java/com/simibubi/create/AllEnchantments.java @@ -5,24 +5,24 @@ import com.simibubi.create.content.curiosities.weapons.PotatoRecoveryEnchantment import com.simibubi.create.foundation.data.CreateRegistrate; import com.tterrag.registrate.util.entry.RegistryEntry; -import net.minecraft.enchantment.Enchantment.Rarity; -import net.minecraft.enchantment.EnchantmentType; -import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.world.item.enchantment.Enchantment.Rarity; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import net.minecraft.world.entity.EquipmentSlot; public class AllEnchantments { private static final CreateRegistrate REGISTRATE = Create.registrate(); public static final RegistryEntry POTATO_RECOVERY = REGISTRATE.object("potato_recovery") - .enchantment(EnchantmentType.BOW, PotatoRecoveryEnchantment::new) - .addSlots(EquipmentSlotType.MAINHAND, EquipmentSlotType.OFFHAND) + .enchantment(EnchantmentCategory.BOW, PotatoRecoveryEnchantment::new) + .addSlots(EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND) .lang("Potato Recovery") .rarity(Rarity.UNCOMMON) .register(); public static final RegistryEntry CAPACITY = REGISTRATE.object("capacity") - .enchantment(EnchantmentType.ARMOR_CHEST, CapacityEnchantment::new) - .addSlots(EquipmentSlotType.CHEST) + .enchantment(EnchantmentCategory.ARMOR_CHEST, CapacityEnchantment::new) + .addSlots(EquipmentSlot.CHEST) .lang("Capacity") .rarity(Rarity.COMMON) .register(); diff --git a/src/main/java/com/simibubi/create/AllEntityTypes.java b/src/main/java/com/simibubi/create/AllEntityTypes.java index c67800ab2..8cd7df0e7 100644 --- a/src/main/java/com/simibubi/create/AllEntityTypes.java +++ b/src/main/java/com/simibubi/create/AllEntityTypes.java @@ -20,10 +20,10 @@ import com.tterrag.registrate.util.entry.EntityEntry; import com.tterrag.registrate.util.nullness.NonNullConsumer; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.EntityType.IFactory; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityType.EntityFactory; import net.minecraftforge.fml.client.registry.IRenderFactory; public class AllEntityTypes { @@ -37,31 +37,31 @@ public class AllEntityTypes { GantryContraptionEntity::new, () -> ContraptionEntityRenderer::new, 10, 40, false); public static final EntityEntry SUPER_GLUE = - register("super_glue", SuperGlueEntity::new, () -> SuperGlueRenderer::new, EntityClassification.MISC, 10, + register("super_glue", SuperGlueEntity::new, () -> SuperGlueRenderer::new, MobCategory.MISC, 10, Integer.MAX_VALUE, false, true, SuperGlueEntity::build).instance(() -> GlueInstance::new) .register(); public static final EntityEntry CRAFTING_BLUEPRINT = - register("crafting_blueprint", BlueprintEntity::new, () -> BlueprintRenderer::new, EntityClassification.MISC, + register("crafting_blueprint", BlueprintEntity::new, () -> BlueprintRenderer::new, MobCategory.MISC, 10, Integer.MAX_VALUE, false, true, BlueprintEntity::build).register(); public static final EntityEntry POTATO_PROJECTILE = register("potato_projectile", PotatoProjectileEntity::new, () -> PotatoProjectileRenderer::new, - EntityClassification.MISC, 4, 20, true, false, PotatoProjectileEntity::build).register(); + MobCategory.MISC, 4, 20, true, false, PotatoProjectileEntity::build).register(); public static final EntityEntry SEAT = register("seat", SeatEntity::new, () -> SeatEntity.Render::new, - EntityClassification.MISC, 0, Integer.MAX_VALUE, false, true, SeatEntity::build).register(); + MobCategory.MISC, 0, Integer.MAX_VALUE, false, true, SeatEntity::build).register(); // - private static EntityEntry contraption(String name, IFactory factory, + private static EntityEntry contraption(String name, EntityFactory factory, NonNullSupplier> renderer, int range, int updateFrequency, boolean sendVelocity) { - return register(name, factory, renderer, EntityClassification.MISC, range, updateFrequency, sendVelocity, true, + return register(name, factory, renderer, MobCategory.MISC, range, updateFrequency, sendVelocity, true, AbstractContraptionEntity::build).register(); } - private static CreateEntityBuilder register(String name, IFactory factory, - NonNullSupplier> renderer, EntityClassification group, int range, int updateFrequency, + private static CreateEntityBuilder register(String name, EntityFactory factory, + NonNullSupplier> renderer, MobCategory group, int range, int updateFrequency, boolean sendVelocity, boolean immuneToFire, NonNullConsumer> propertyBuilder) { String id = Lang.asId(name); return (CreateEntityBuilder) Create.registrate() diff --git a/src/main/java/com/simibubi/create/AllFluids.java b/src/main/java/com/simibubi/create/AllFluids.java index 5cc52de55..fdea20553 100644 --- a/src/main/java/com/simibubi/create/AllFluids.java +++ b/src/main/java/com/simibubi/create/AllFluids.java @@ -10,18 +10,20 @@ import com.simibubi.create.content.palettes.AllPaletteBlocks; import com.simibubi.create.foundation.data.CreateRegistrate; import com.tterrag.registrate.util.entry.FluidEntry; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; 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(); @@ -73,8 +75,8 @@ public class AllFluids { @OnlyIn(Dist.CLIENT) private static void makeTranslucent(FluidEntry entry) { ForgeFlowingFluid fluid = entry.get(); - RenderTypeLookup.setRenderLayer(fluid, RenderType.translucent()); - RenderTypeLookup.setRenderLayer(fluid.getSource(), RenderType.translucent()); + ItemBlockRenderTypes.setRenderLayer(fluid, RenderType.translucent()); + ItemBlockRenderTypes.setRenderLayer(fluid.getSource(), RenderType.translucent()); } @Nullable @@ -102,7 +104,7 @@ public class AllFluids { } @Override - public int getColor(IBlockDisplayReader world, BlockPos pos) { + public int getColor(BlockAndTintGetter world, BlockPos pos) { return 0x00ffffff; } diff --git a/src/main/java/com/simibubi/create/AllInteractionBehaviours.java b/src/main/java/com/simibubi/create/AllInteractionBehaviours.java index 7848d908e..b2f6ab018 100644 --- a/src/main/java/com/simibubi/create/AllInteractionBehaviours.java +++ b/src/main/java/com/simibubi/create/AllInteractionBehaviours.java @@ -12,9 +12,9 @@ import com.simibubi.create.content.contraptions.components.structureMovement.int import com.simibubi.create.content.contraptions.components.structureMovement.interaction.LeverMovingInteraction; import com.simibubi.create.content.contraptions.components.structureMovement.interaction.TrapdoorMovingInteraction; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.resources.ResourceLocation; public class AllInteractionBehaviours { private static final HashMap> INTERACT_BEHAVIOURS = diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 90a9e2030..4a84419c4 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -56,13 +56,13 @@ import com.simibubi.create.foundation.item.TagDependentIngredientItem; import com.simibubi.create.foundation.item.TooltipHelper; import com.tterrag.registrate.util.entry.ItemEntry; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Food; -import net.minecraft.item.Item; -import net.minecraft.item.Rarity; -import net.minecraft.tags.ITag; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Rarity; +import net.minecraft.tags.Tag; import net.minecraft.tags.ItemTags; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags; public class AllItems { @@ -115,26 +115,26 @@ 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().nutrition(6) + .properties(p -> p.food(new FoodProperties.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().nutrition(6) + .properties(p -> p.food(new FoodProperties.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().nutrition(7) + .properties(p -> p.food(new FoodProperties.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().nutrition(8) + .properties(p -> p.food(new FoodProperties.Builder().nutrition(8) .saturationMod(0.8F) .build())) .register(); @@ -359,7 +359,7 @@ public class AllItems { // } @SafeVarargs - private static ItemEntry taggedIngredient(String name, ITag.INamedTag... tags) { + private static ItemEntry taggedIngredient(String name, Tag.Named... tags) { return REGISTRATE.item(name, Item::new) .tag(tags) .register(); diff --git a/src/main/java/com/simibubi/create/AllKeys.java b/src/main/java/com/simibubi/create/AllKeys.java index e323ba47c..bb3fde41a 100644 --- a/src/main/java/com/simibubi/create/AllKeys.java +++ b/src/main/java/com/simibubi/create/AllKeys.java @@ -3,8 +3,8 @@ package com.simibubi.create; import org.lwjgl.glfw.GLFW; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.settings.KeyBinding; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.KeyMapping; import net.minecraftforge.fml.client.registry.ClientRegistry; public enum AllKeys { @@ -15,7 +15,7 @@ public enum AllKeys { ; - private KeyBinding keybind; + private KeyMapping keybind; private String description; private int key; private boolean modifiable; @@ -28,7 +28,7 @@ public enum AllKeys { public static void register() { for (AllKeys key : values()) { - key.keybind = new KeyBinding(key.description, key.key, Create.NAME); + key.keybind = new KeyMapping(key.description, key.key, Create.NAME); if (!key.modifiable) continue; @@ -36,7 +36,7 @@ public enum AllKeys { } } - public KeyBinding getKeybind() { + public KeyMapping getKeybind() { return keybind; } diff --git a/src/main/java/com/simibubi/create/AllMovementBehaviours.java b/src/main/java/com/simibubi/create/AllMovementBehaviours.java index ece2e1f65..b35d55806 100644 --- a/src/main/java/com/simibubi/create/AllMovementBehaviours.java +++ b/src/main/java/com/simibubi/create/AllMovementBehaviours.java @@ -11,10 +11,10 @@ import com.simibubi.create.content.contraptions.components.actors.dispenser.Drop import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.tterrag.registrate.util.nullness.NonNullConsumer; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.resources.ResourceLocation; public class AllMovementBehaviours { private static final HashMap MOVEMENT_BEHAVIOURS = new HashMap<>(); diff --git a/src/main/java/com/simibubi/create/AllParticleTypes.java b/src/main/java/com/simibubi/create/AllParticleTypes.java index d2ceade86..21c6ea9c0 100644 --- a/src/main/java/com/simibubi/create/AllParticleTypes.java +++ b/src/main/java/com/simibubi/create/AllParticleTypes.java @@ -14,10 +14,10 @@ import com.simibubi.create.content.curiosities.bell.SoulParticle; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleType; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; @@ -42,7 +42,7 @@ public enum AllParticleTypes { private ParticleEntry entry; - AllParticleTypes(Supplier> typeFactory) { + AllParticleTypes(Supplier> typeFactory) { String asId = Lang.asId(this.name()); entry = new ParticleEntry<>(new ResourceLocation(Create.ID, asId), typeFactory); } @@ -54,7 +54,7 @@ public enum AllParticleTypes { @OnlyIn(Dist.CLIENT) public static void registerFactories(ParticleFactoryRegisterEvent event) { - ParticleManager particles = Minecraft.getInstance().particleEngine; + ParticleEngine particles = Minecraft.getInstance().particleEngine; for (AllParticleTypes particle : values()) particle.entry.registerFactory(particles); } @@ -67,7 +67,7 @@ public enum AllParticleTypes { return Lang.asId(name()); } - private class ParticleEntry { + private class ParticleEntry { Supplier> typeFactory; ParticleType type; ResourceLocation id; @@ -91,7 +91,7 @@ public enum AllParticleTypes { } @OnlyIn(Dist.CLIENT) - void registerFactory(ParticleManager particles) { + void registerFactory(ParticleEngine particles) { typeFactory.get() .register(getOrCreateType(), particles); } diff --git a/src/main/java/com/simibubi/create/AllRecipeTypes.java b/src/main/java/com/simibubi/create/AllRecipeTypes.java index 58a14dbb5..cba3f3d5e 100644 --- a/src/main/java/com/simibubi/create/AllRecipeTypes.java +++ b/src/main/java/com/simibubi/create/AllRecipeTypes.java @@ -24,15 +24,15 @@ import com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.item.crafting.SpecialRecipeSerializer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; +import net.minecraft.world.Container; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.ShapedRecipe; +import net.minecraft.world.item.crafting.SimpleRecipeSerializer; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; +import net.minecraft.world.level.Level; import net.minecraftforge.event.RegistryEvent; public enum AllRecipeTypes implements IRecipeTypeInfo { @@ -54,27 +54,27 @@ public enum AllRecipeTypes implements IRecipeTypeInfo { MECHANICAL_CRAFTING(MechanicalCraftingRecipe.Serializer::new), SEQUENCED_ASSEMBLY(SequencedAssemblyRecipeSerializer::new), - TOOLBOX_DYEING(() -> new SpecialRecipeSerializer<>(ToolboxDyeingRecipe::new), IRecipeType.CRAFTING); + TOOLBOX_DYEING(() -> new SimpleRecipeSerializer<>(ToolboxDyeingRecipe::new), RecipeType.CRAFTING); ; private ResourceLocation id; - private Supplier> serializerSupplier; - private Supplier> typeSupplier; - private IRecipeSerializer serializer; - private IRecipeType type; + private Supplier> serializerSupplier; + private Supplier> typeSupplier; + private RecipeSerializer serializer; + private RecipeType type; - AllRecipeTypes(Supplier> serializerSupplier, Supplier> typeSupplier) { + AllRecipeTypes(Supplier> serializerSupplier, Supplier> typeSupplier) { this.id = Create.asResource(Lang.asId(name())); this.serializerSupplier = serializerSupplier; this.typeSupplier = typeSupplier; } - AllRecipeTypes(Supplier> serializerSupplier, IRecipeType existingType) { + AllRecipeTypes(Supplier> serializerSupplier, RecipeType existingType) { this(serializerSupplier, () -> existingType); } - AllRecipeTypes(Supplier> serializerSupplier) { + AllRecipeTypes(Supplier> serializerSupplier) { this.id = Create.asResource(Lang.asId(name())); this.serializerSupplier = serializerSupplier; this.typeSupplier = () -> simpleType(id); @@ -91,22 +91,22 @@ public enum AllRecipeTypes implements IRecipeTypeInfo { @SuppressWarnings("unchecked") @Override - public > T getSerializer() { + public > T getSerializer() { return (T) serializer; } @SuppressWarnings("unchecked") @Override - public > T getType() { + public > T getType() { return (T) type; } - public > Optional find(C inv, World world) { + public > Optional find(C inv, Level world) { return world.getRecipeManager() .getRecipeFor(getType(), inv, world); } - public static void register(RegistryEvent.Register> event) { + public static void register(RegistryEvent.Register> event) { ShapedRecipe.setCraftingSize(9, 9); for (AllRecipeTypes r : AllRecipeTypes.values()) { @@ -118,13 +118,13 @@ public enum AllRecipeTypes implements IRecipeTypeInfo { } } - private static Supplier> processingSerializer(ProcessingRecipeFactory factory) { + private static Supplier> processingSerializer(ProcessingRecipeFactory factory) { return () -> new ProcessingRecipeSerializer<>(factory); } - public static > IRecipeType simpleType(ResourceLocation id) { + public static > RecipeType simpleType(ResourceLocation id) { String stringId = id.toString(); - return Registry.register(Registry.RECIPE_TYPE, id, new IRecipeType() { + return Registry.register(Registry.RECIPE_TYPE, id, new RecipeType() { @Override public String toString() { return stringId; diff --git a/src/main/java/com/simibubi/create/AllShapes.java b/src/main/java/com/simibubi/create/AllShapes.java index 09bfd18cc..30e72e77b 100644 --- a/src/main/java/com/simibubi/create/AllShapes.java +++ b/src/main/java/com/simibubi/create/AllShapes.java @@ -1,23 +1,24 @@ package com.simibubi.create; import static net.minecraft.util.Direction.NORTH; -import static net.minecraft.util.Direction.SOUTH; +import staticnet.minecraft.core.Directionn.SOUTH; import static net.minecraft.util.Direction.UP; -import java.util.function.BiFunction; - +import javanet.minecraft.core.Direction import com.simibubi.create.content.logistics.block.chute.ChuteShapes; import com.simibubi.create.foundation.utility.VoxelShaper; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.DirectionalBlock; -import net.minecraft.block.PistonHeadBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.level.block.piston.PistonHeadBlock; import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.shapes.IBooleanFunction; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; + +import java.util.function.BiFunction; public class AllShapes { @@ -161,7 +162,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.block()).erase(4, 0, 4, 12, 16, 12) + MECHANICAL_PROCESSOR_SHAPE = shape(Shapes.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(), @@ -251,7 +252,7 @@ public class AllShapes { } public Builder add(VoxelShape shape) { - this.shape = VoxelShapes.or(this.shape, shape); + this.shape = Shapes.or(this.shape, shape); return this; } @@ -260,7 +261,7 @@ public class AllShapes { } public Builder erase(double x1, double y1, double z1, double x2, double y2, double z2) { - this.shape = VoxelShapes.join(shape, cuboid(x1, y1, z1, x2, y2, z2), IBooleanFunction.ONLY_FIRST); + this.shape = Shapes.join(shape, cuboid(x1, y1, z1, x2, y2, z2), BooleanOp.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 0dbe9ba98..a21d983e8 100644 --- a/src/main/java/com/simibubi/create/AllSoundEvents.java +++ b/src/main/java/com/simibubi/create/AllSoundEvents.java @@ -15,17 +15,17 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Pair; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.data.HashCache; +import net.minecraft.data.DataProvider; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.registries.IForgeRegistry; @@ -37,193 +37,193 @@ public class AllSoundEvents { SCHEMATICANNON_LAUNCH_BLOCK = create("schematicannon_launch_block").subtitle("Schematicannon fires") .playExisting(SoundEvents.GENERIC_EXPLODE, .1f, 1.1f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), SCHEMATICANNON_FINISH = create("schematicannon_finish").subtitle("Schematicannon dings") .playExisting(SoundEvents.NOTE_BLOCK_BELL, 1, .7f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), DEPOT_SLIDE = create("depot_slide").subtitle("Item slides") .playExisting(SoundEvents.SAND_BREAK, .125f, 1.5f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), DEPOT_PLOP = create("depot_plop").subtitle("Item lands") .playExisting(SoundEvents.ITEM_FRAME_ADD_ITEM, .25f, 1.25f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), FUNNEL_FLAP = create("funnel_flap").subtitle("Funnel flaps") .playExisting(SoundEvents.ITEM_FRAME_ROTATE_ITEM, .125f, 1.5f) .playExisting(SoundEvents.WOOL_BREAK, .0425f, .75f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), SLIME_ADDED = create("slime_added").subtitle("Slime squishes") .playExisting(SoundEvents.SLIME_BLOCK_PLACE) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), MECHANICAL_PRESS_ACTIVATION = create("mechanical_press_activation").subtitle("Mechanical Press clangs") .playExisting(SoundEvents.ANVIL_LAND, .125f, 1f) .playExisting(SoundEvents.ITEM_BREAK, .5f, 1f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), MECHANICAL_PRESS_ACTIVATION_ON_BELT = create("mechanical_press_activation_belt").subtitle("Mechanical Press bonks") .playExisting(SoundEvents.WOOL_HIT, .75f, 1f) .playExisting(SoundEvents.ITEM_BREAK, .15f, .75f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), MIXING = create("mixing").subtitle("Mixing noises") .playExisting(SoundEvents.GILDED_BLACKSTONE_BREAK, .125f, .5f) .playExisting(SoundEvents.NETHERRACK_BREAK, .125f, .5f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CRANKING = create("cranking").subtitle("Hand Crank turns") .playExisting(SoundEvents.WOOD_PLACE, .075f, .5f) .playExisting(SoundEvents.WOODEN_BUTTON_CLICK_OFF, .025f, .5f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), WORLDSHAPER_PLACE = create("worldshaper_place").subtitle("Worldshaper zaps") .playExisting(SoundEvents.NOTE_BLOCK_BASEDRUM) - .category(SoundCategory.PLAYERS) + .category(SoundSource.PLAYERS) .build(), SCROLL_VALUE = create("scroll_value").subtitle("Scroll-input clicks") .playExisting(SoundEvents.NOTE_BLOCK_HAT, .124f, 1f) - .category(SoundCategory.PLAYERS) + .category(SoundSource.PLAYERS) .build(), CONFIRM = create("confirm").subtitle("Affirmative ding") .playExisting(SoundEvents.NOTE_BLOCK_BELL, 0.5f, 0.8f) - .category(SoundCategory.PLAYERS) + .category(SoundSource.PLAYERS) .build(), DENY = create("deny").subtitle("Declining boop") .playExisting(SoundEvents.NOTE_BLOCK_BASS, 1f, 0.5f) - .category(SoundCategory.PLAYERS) + .category(SoundSource.PLAYERS) .build(), COGS = create("cogs").subtitle("Cogwheels rumble") - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), FWOOMP = create("fwoomp").subtitle("Potato Launcher fwoomps") - .category(SoundCategory.PLAYERS) + .category(SoundSource.PLAYERS) .build(), POTATO_HIT = create("potato_hit").subtitle("Vegetable impacts") .playExisting(SoundEvents.ITEM_FRAME_BREAK, .75f, .75f) .playExisting(SoundEvents.WEEPING_VINES_BREAK, .75f, 1.25f) - .category(SoundCategory.PLAYERS) + .category(SoundSource.PLAYERS) .build(), CONTRAPTION_ASSEMBLE = create("contraption_assemble").subtitle("Contraption moves") .playExisting(SoundEvents.WOODEN_TRAPDOOR_OPEN, .5f, .5f) .playExisting(SoundEvents.CHEST_OPEN, .045f, .74f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CONTRAPTION_DISASSEMBLE = create("contraption_disassemble").subtitle("Contraption stops") .playExisting(SoundEvents.IRON_TRAPDOOR_CLOSE, .35f, .75f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), WRENCH_ROTATE = create("wrench_rotate").subtitle("Wrench used") .playExisting(SoundEvents.WOODEN_TRAPDOOR_CLOSE, .25f, 1.25f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), WRENCH_REMOVE = create("wrench_remove").subtitle("Component breaks") .playExisting(SoundEvents.ITEM_PICKUP, .25f, .75f) .playExisting(SoundEvents.NETHERITE_BLOCK_HIT, .25f, .75f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CRAFTER_CLICK = create("crafter_click").subtitle("Crafter clicks") .playExisting(SoundEvents.NETHERITE_BLOCK_HIT, .25f, 1) .playExisting(SoundEvents.WOODEN_TRAPDOOR_OPEN, .125f, 1) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CRAFTER_CRAFT = create("crafter_craft").subtitle("Crafter crafts") .playExisting(SoundEvents.ITEM_BREAK, .125f, .75f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), COPPER_ARMOR_EQUIP = create("copper_armor_equip").subtitle("Diving equipment clinks") .playExisting(SoundEvents.ARMOR_EQUIP_GOLD, 1f, 1f) - .category(SoundCategory.PLAYERS) + .category(SoundSource.PLAYERS) .build(), AUTO_POLISH = create("deployer_polish").subtitle("Deployer applies polish") .playExisting(SoundEvents.UI_STONECUTTER_TAKE_RESULT, 1f, 1f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CONTROLLER_CLICK = create("controller_click").subtitle("Controller clicks") .playExisting(SoundEvents.ITEM_FRAME_ADD_ITEM, .35f, 1f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CONTROLLER_PUT = create("controller_put").subtitle("Controller thumps") .playExisting(SoundEvents.BOOK_PUT, 1f, 1f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CONTROLLER_TAKE = create("controller_take").subtitle("Lectern empties") .playExisting(SoundEvents.ITEM_FRAME_REMOVE_ITEM, 1f, 1f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), SAW_ACTIVATE_WOOD = create("saw_activate_wood").subtitle("Mechanical Saw activates") .playExisting(SoundEvents.BOAT_PADDLE_LAND, .75f, 1.5f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), SAW_ACTIVATE_STONE = create("saw_activate_stone").subtitle("Mechanical Saw activates") .playExisting(SoundEvents.UI_STONECUTTER_TAKE_RESULT, .125f, 1.25f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), BLAZE_MUNCH = create("blaze_munch").subtitle("Blaze Burner munches") .playExisting(SoundEvents.GENERIC_EAT, .5f, 1f) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CRUSHING_1 = create("crushing_1").subtitle("Crushing noises") .playExisting(SoundEvents.NETHERRACK_HIT) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CRUSHING_2 = create("crushing_2").noSubtitle() .playExisting(SoundEvents.GRAVEL_PLACE) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), CRUSHING_3 = create("crushing_3").noSubtitle() .playExisting(SoundEvents.NETHERITE_BLOCK_BREAK) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), PECULIAR_BELL_USE = create("peculiar_bell_use").subtitle("Peculiar Bell tolls") .playExisting(SoundEvents.BELL_BLOCK) - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), HAUNTED_BELL_CONVERT = create("haunted_bell_convert").subtitle("Haunted Bell awakens") - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(), HAUNTED_BELL_USE = create("haunted_bell_use").subtitle("Haunted Bell tolls") - .category(SoundCategory.BLOCKS) + .category(SoundSource.BLOCKS) .build(); public static SoundEntryBuilder create(String id) { @@ -263,7 +263,7 @@ public class AllSoundEvents { // // } - private static class SoundEntryProvider implements IDataProvider { + private static class SoundEntryProvider implements DataProvider { private DataGenerator generator; @@ -272,7 +272,7 @@ public class AllSoundEvents { } @Override - public void run(DirectoryCache cache) throws IOException { + public void run(HashCache cache) throws IOException { generate(generator.getOutputFolder(), cache); } @@ -281,7 +281,7 @@ public class AllSoundEvents { return "Create's Custom Sounds"; } - public void generate(Path path, DirectoryCache cache) { + public void generate(Path path, HashCache cache) { Gson GSON = (new GsonBuilder()).setPrettyPrinting() .disableHtmlEscaping() .create(); @@ -296,7 +296,7 @@ public class AllSoundEvents { entry.getValue() .write(json); }); - IDataProvider.save(GSON, cache, json, path.resolve("sounds.json")); + DataProvider.save(GSON, cache, json, path.resolve("sounds.json")); } catch (IOException e) { e.printStackTrace(); @@ -309,7 +309,7 @@ public class AllSoundEvents { protected String id; protected String subtitle = "unregistered"; - protected SoundCategory category = SoundCategory.BLOCKS; + protected SoundSource category = SoundSource.BLOCKS; List>> wrappedEvents; public SoundEntryBuilder(String id) { @@ -327,7 +327,7 @@ public class AllSoundEvents { return this; } - public SoundEntryBuilder category(SoundCategory category) { + public SoundEntryBuilder category(SoundSource category) { this.category = category; return this; } @@ -354,9 +354,9 @@ public class AllSoundEvents { protected String id; protected String subtitle; - protected SoundCategory category; + protected SoundSource category; - public SoundEntry(String id, String subtitle, SoundCategory category) { + public SoundEntry(String id, String subtitle, SoundSource category) { this.id = id; this.subtitle = subtitle; this.category = category; @@ -390,15 +390,15 @@ public class AllSoundEvents { return subtitle; } - public void playOnServer(World world, BlockPos pos) { + public void playOnServer(Level world, BlockPos pos) { playOnServer(world, pos, 1, 1); } - public void playOnServer(World world, BlockPos pos, float volume, float pitch) { + public void playOnServer(Level world, BlockPos pos, float volume, float pitch) { play(world, null, pos, volume, pitch); } - public void play(World world, PlayerEntity entity, BlockPos pos) { + public void play(Level world, Player entity, BlockPos pos) { play(world, entity, pos, 1, 1); } @@ -411,25 +411,25 @@ public class AllSoundEvents { play(entity.level, null, entity.blockPosition(), volume, pitch); } - public void play(World world, PlayerEntity entity, BlockPos pos, float volume, float pitch) { + public void play(Level world, Player entity, BlockPos pos, float volume, float pitch) { play(world, entity, pos.getX(), pos.getY(), pos.getZ(), volume, pitch); } - public void play(World world, PlayerEntity entity, Vector3d pos, float volume, float pitch) { + public void play(Level world, Player entity, Vec3 pos, float volume, float 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); + public abstract void play(Level world, Player entity, double x, double y, double z, float volume, float pitch); - public void playAt(World world, BlockPos pos, float volume, float pitch, boolean fade) { + public void playAt(Level world, BlockPos pos, float volume, float pitch, boolean fade) { playAt(world, pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5, volume, pitch, fade); } - public void playAt(World world, Vector3d pos, float volume, float pitch, boolean fade) { + public void playAt(Level world, Vec3 pos, float volume, float pitch, boolean 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); + public abstract void playAt(Level world, double x, double y, double z, float volume, float pitch, boolean fade); } @@ -439,7 +439,7 @@ public class AllSoundEvents { private List>> compiledEvents; public WrappedSoundEntry(String id, String subtitle, List>> wrappedEvents, - SoundCategory category) { + SoundSource category) { super(id, subtitle, category); this.wrappedEvents = wrappedEvents; compiledEvents = Lists.newArrayList(); @@ -491,7 +491,7 @@ public class AllSoundEvents { } @Override - public void play(World world, PlayerEntity entity, double x, double y, double z, float volume, float pitch) { + public void play(Level world, Player entity, double x, double y, double z, float volume, float pitch) { for (Pair> pair : compiledEvents) { Couple volPitch = pair.getSecond(); world.playSound(entity, x, y, z, pair.getFirst(), category, volPitch.getFirst() * volume, @@ -500,7 +500,7 @@ public class AllSoundEvents { } @Override - public void playAt(World world, double x, double y, double z, float volume, float pitch, boolean fade) { + public void playAt(Level world, double x, double y, double z, float volume, float pitch, boolean fade) { for (Pair> pair : compiledEvents) { Couple volPitch = pair.getSecond(); world.playLocalSound(x, y, z, pair.getFirst(), category, volPitch.getFirst() * volume, @@ -513,7 +513,7 @@ public class AllSoundEvents { protected SoundEvent event; - public CustomSoundEntry(String id, String subtitle, SoundCategory category) { + public CustomSoundEntry(String id, String subtitle, SoundSource category) { super(id, subtitle, category); } @@ -544,12 +544,12 @@ public class AllSoundEvents { } @Override - public void play(World world, PlayerEntity entity, double x, double y, double z, float volume, float pitch) { + public void play(Level world, Player entity, double x, double y, double z, float volume, float pitch) { world.playSound(entity, x, y, z, event, category, volume, pitch); } @Override - public void playAt(World world, double x, double y, double z, float volume, float pitch, boolean fade) { + public void playAt(Level world, double x, double y, double z, float volume, float pitch, boolean 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 4a0117b8f..025eb8c68 100644 --- a/src/main/java/com/simibubi/create/AllSpecialTextures.java +++ b/src/main/java/com/simibubi/create/AllSpecialTextures.java @@ -1,7 +1,7 @@ package com.simibubi.create; import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public enum AllSpecialTextures { diff --git a/src/main/java/com/simibubi/create/AllSpriteShifts.java b/src/main/java/com/simibubi/create/AllSpriteShifts.java index dfae3fdd4..b9e0d4235 100644 --- a/src/main/java/com/simibubi/create/AllSpriteShifts.java +++ b/src/main/java/com/simibubi/create/AllSpriteShifts.java @@ -18,8 +18,8 @@ import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.block.render.SpriteShifter; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.WoodType; -import net.minecraft.item.DyeColor; +import net.minecraft.world.level.block.state.properties.WoodType; +import net.minecraft.world.item.DyeColor; public class AllSpriteShifts { diff --git a/src/main/java/com/simibubi/create/AllStitchedTextures.java b/src/main/java/com/simibubi/create/AllStitchedTextures.java index 30482c457..f18196e89 100644 --- a/src/main/java/com/simibubi/create/AllStitchedTextures.java +++ b/src/main/java/com/simibubi/create/AllStitchedTextures.java @@ -3,7 +3,7 @@ package com.simibubi.create; import com.jozufozu.flywheel.core.AtlasStitcher; import com.jozufozu.flywheel.core.StitchedSprite; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class AllStitchedTextures { diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index 62a7af3ed..c577a4248 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -13,19 +13,19 @@ import com.tterrag.registrate.builders.ItemBuilder; import com.tterrag.registrate.providers.ProviderType; import com.tterrag.registrate.util.nullness.NonNullFunction; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; -import net.minecraft.tags.ITag; +import net.minecraft.tags.Tag; import net.minecraft.tags.ItemTags; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags; public class AllTags { @@ -33,24 +33,24 @@ public class AllTags { private static final CreateRegistrate REGISTRATE = Create.registrate() .itemGroup(() -> Create.BASE_CREATIVE_TAB); - public static ITag.INamedTag tag(Function> wrapperFactory, String namespace, + public static Tag.Named tag(Function> wrapperFactory, String namespace, String path) { return wrapperFactory.apply(new ResourceLocation(namespace, path)); } - public static ITag.INamedTag forgeTag(Function> wrapperFactory, String path) { + public static Tag.Named forgeTag(Function> wrapperFactory, String path) { return tag(wrapperFactory, "forge", path); } - public static ITag.INamedTag forgeBlockTag(String path) { + public static Tag.Named forgeBlockTag(String path) { return forgeTag(BlockTags::createOptional, path); } - public static ITag.INamedTag forgeItemTag(String path) { + public static Tag.Named forgeItemTag(String path) { return forgeTag(ItemTags::createOptional, path); } - public static ITag.INamedTag forgeFluidTag(String path) { + public static Tag.Named forgeFluidTag(String path) { return forgeTag(FluidTags::createOptional, path); } @@ -105,7 +105,7 @@ public class AllTags { ; - public final ITag.INamedTag tag; + public final Tag.Named tag; AllBlockTags() { this(MOD); @@ -148,7 +148,7 @@ public class AllTags { .add(values)); } - public void includeIn(ITag.INamedTag parent) { + public void includeIn(Tag.Named parent) { REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.tag(parent) .addTag(tag)); } @@ -157,7 +157,7 @@ public class AllTags { includeIn(parent.tag); } - public void includeAll(ITag.INamedTag child) { + public void includeAll(Tag.Named child) { REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.tag(tag) .addTag(child)); } @@ -179,7 +179,7 @@ public class AllTags { ; - public final ITag.INamedTag tag; + public final Tag.Named tag; AllItemTags() { this(MOD); @@ -218,7 +218,7 @@ public class AllTags { .add(values)); } - public void includeIn(ITag.INamedTag parent) { + public void includeIn(Tag.Named parent) { REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.tag(parent) .addTag(tag)); } @@ -227,7 +227,7 @@ public class AllTags { includeIn(parent.tag); } - public void includeAll(ITag.INamedTag child) { + public void includeAll(Tag.Named child) { REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.tag(tag) .addTag(child)); } @@ -242,7 +242,7 @@ public class AllTags { ; - public final ITag.INamedTag tag; + public final Tag.Named tag; AllFluidTags() { this(MOD); @@ -281,7 +281,7 @@ public class AllTags { .add(values)); } - public void includeIn(ITag.INamedTag parent) { + public void includeIn(Tag.Named parent) { REGISTRATE.addDataGenerator(ProviderType.FLUID_TAGS, prov -> prov.tag(parent) .addTag(tag)); } @@ -290,7 +290,7 @@ public class AllTags { includeIn(parent.tag); } - public void includeAll(ITag.INamedTag child) { + public void includeAll(Tag.Named child) { REGISTRATE.addDataGenerator(ProviderType.FLUID_TAGS, prov -> prov.tag(tag) .addTag(child)); } diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index cf6320f66..ebe51172a 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -35,13 +35,13 @@ import com.simibubi.create.foundation.worldgen.AllWorldFeatures; import com.tterrag.registrate.util.NonNullLazyValue; import net.minecraft.data.DataGenerator; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.particles.ParticleType; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.placement.Placement; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.placement.FeatureDecorator; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.MinecraftForge; @@ -68,8 +68,8 @@ public class Create { .disableHtmlEscaping() .create(); - public static final ItemGroup BASE_CREATIVE_TAB = new CreateItemGroup(); - public static final ItemGroup PALETTES_CREATIVE_TAB = new PalettesItemGroup(); + public static final CreativeModeTab BASE_CREATIVE_TAB = new CreateItemGroup(); + public static final CreativeModeTab PALETTES_CREATIVE_TAB = new PalettesItemGroup(); public static final ServerSchematicLoader SCHEMATIC_RECEIVER = new ServerSchematicLoader(); public static final RedstoneLinkNetworkHandler REDSTONE_LINK_NETWORK_HANDLER = new RedstoneLinkNetworkHandler(); @@ -112,8 +112,8 @@ public class Create { modEventBus.addListener(Create::init); modEventBus.addGenericListener(Feature.class, AllWorldFeatures::registerOreFeatures); - modEventBus.addGenericListener(Placement.class, AllWorldFeatures::registerDecoratorFeatures); - modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipeTypes::register); + modEventBus.addGenericListener(FeatureDecorator.class, AllWorldFeatures::registerDecoratorFeatures); + modEventBus.addGenericListener(RecipeSerializer.class, AllRecipeTypes::register); modEventBus.addGenericListener(ParticleType.class, AllParticleTypes::register); modEventBus.addGenericListener(SoundEvent.class, AllSoundEvents::register); modEventBus.addListener(AllConfigs::onLoad); diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index e9177402e..9d1e66ffb 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -26,18 +26,18 @@ import com.simibubi.create.foundation.utility.ghost.GhostBlocks; import com.simibubi.create.foundation.utility.outliner.Outliner; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.client.settings.GraphicsFanciness; -import net.minecraft.resources.IReloadableResourceManager; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.text.ChatType; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextComponentUtils; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.event.ClickEvent; -import net.minecraft.util.text.event.HoverEvent; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.client.GraphicsStatus; +import net.minecraft.server.packs.resources.ReloadableResourceManager; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.network.chat.ChatType; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.ComponentUtils; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.HoverEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -46,7 +46,7 @@ public class CreateClient { public static final SuperByteBufferCache BUFFER_CACHE = new SuperByteBufferCache(); public static final Outliner OUTLINER = new Outliner(); public static final GhostBlocks GHOST_BLOCKS = new GhostBlocks(); - public static final Screen EMPTY_SCREEN = new Screen(new StringTextComponent("")) {}; + public static final Screen EMPTY_SCREEN = new Screen(new TextComponent("")) {}; public static final ModelSwapper MODEL_SWAPPER = new ModelSwapper(); public static final CasingConnectivity CASING_CONNECTIVITY = new CasingConnectivity(); @@ -80,9 +80,9 @@ public class CreateClient { // null during datagen if (mc == null) return; - IResourceManager resourceManager = mc.getResourceManager(); - if (resourceManager instanceof IReloadableResourceManager) - ((IReloadableResourceManager) resourceManager).registerReloadListener(RESOURCE_RELOAD_LISTENER); + ResourceManager resourceManager = mc.getResourceManager(); + if (resourceManager instanceof ReloadableResourceManager) + ((ReloadableResourceManager) resourceManager).registerReloadListener(RESOURCE_RELOAD_LISTENER); } public static void clientInit(final FMLClientSetupEvent event) { @@ -106,7 +106,7 @@ public class CreateClient { }); } - protected static void registerLayerRenderers(EntityRendererManager renderManager) { + protected static void registerLayerRenderers(EntityRenderDispatcher renderManager) { CopperBacktankArmorLayer.registerOnAll(renderManager); } @@ -121,20 +121,20 @@ public class CreateClient { if (mc.player == null) return; - if (mc.options.graphicsMode != GraphicsFanciness.FABULOUS) + if (mc.options.graphicsMode != GraphicsStatus.FABULOUS) return; if (AllConfigs.CLIENT.ignoreFabulousWarning.get()) return; - IFormattableTextComponent text = TextComponentUtils.wrapInSquareBrackets(new StringTextComponent("WARN")) - .withStyle(TextFormatting.GOLD) - .append(new StringTextComponent( + MutableComponent text = ComponentUtils.wrapInSquareBrackets(new TextComponent("WARN")) + .withStyle(ChatFormatting.GOLD) + .append(new TextComponent( " Some of Create's visual features will not be available while Fabulous graphics are enabled!")) .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")))); + new TextComponent("Click here to disable this warning")))); mc.gui.handleChat(ChatType.CHAT, text, mc.player.getUUID()); } diff --git a/src/main/java/com/simibubi/create/api/behaviour/BlockSpoutingBehaviour.java b/src/main/java/com/simibubi/create/api/behaviour/BlockSpoutingBehaviour.java index 61b11e4fa..5b3a78c4b 100644 --- a/src/main/java/com/simibubi/create/api/behaviour/BlockSpoutingBehaviour.java +++ b/src/main/java/com/simibubi/create/api/behaviour/BlockSpoutingBehaviour.java @@ -7,9 +7,9 @@ import com.simibubi.create.Create; import com.simibubi.create.compat.tconstruct.SpoutCasting; import com.simibubi.create.content.contraptions.fluids.actors.SpoutTileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; public abstract class BlockSpoutingBehaviour { @@ -42,7 +42,7 @@ public abstract class BlockSpoutingBehaviour { * @param simulate whether the spout is testing or actually performing this behaviour * @return amount filled into the block, 0 to idle/cancel */ - public abstract int fillBlock(World world, BlockPos pos, SpoutTileEntity spout, FluidStack availableFluid, + public abstract int fillBlock(Level world, BlockPos pos, SpoutTileEntity spout, FluidStack availableFluid, boolean simulate); public static void register() { diff --git a/src/main/java/com/simibubi/create/api/event/TileEntityBehaviourEvent.java b/src/main/java/com/simibubi/create/api/event/TileEntityBehaviourEvent.java index 03e6e4dc9..c19e78080 100644 --- a/src/main/java/com/simibubi/create/api/event/TileEntityBehaviourEvent.java +++ b/src/main/java/com/simibubi/create/api/event/TileEntityBehaviourEvent.java @@ -7,7 +7,7 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.eventbus.api.GenericEvent; /** 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 2238c7d76..48aaa558f 100644 --- a/src/main/java/com/simibubi/create/compat/dynamictrees/DynamicTree.java +++ b/src/main/java/com/simibubi/create/compat/dynamictrees/DynamicTree.java @@ -12,11 +12,11 @@ import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class DynamicTree extends AbstractBlockBreakQueue { private BlockPos startCutPos; @@ -26,7 +26,7 @@ public class DynamicTree extends AbstractBlockBreakQueue { } @Override - public void destroyBlocks(World world, ItemStack toDamage, @Nullable PlayerEntity playerEntity, BiConsumer drop) { + public void destroyBlocks(Level world, ItemStack toDamage, @Nullable Player playerEntity, BiConsumer drop) { BranchBlock start = TreeHelper.getBranch(world.getBlockState(startCutPos)); if (start == null) //if start is null, it was not a branch start = setBranchToShellMuse(world, world.getBlockState(startCutPos)); //we check for a trunk shell instead diff --git a/src/main/java/com/simibubi/create/compat/jei/BlueprintTransferHandler.java b/src/main/java/com/simibubi/create/compat/jei/BlueprintTransferHandler.java index d4d4facd0..9cf175006 100644 --- a/src/main/java/com/simibubi/create/compat/jei/BlueprintTransferHandler.java +++ b/src/main/java/com/simibubi/create/compat/jei/BlueprintTransferHandler.java @@ -7,8 +7,8 @@ import com.simibubi.create.foundation.networking.AllPackets; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.recipe.transfer.IRecipeTransferError; import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.crafting.Recipe; public class BlueprintTransferHandler implements IRecipeTransferHandler { @@ -19,12 +19,12 @@ public class BlueprintTransferHandler implements IRecipeTransferHandler iRecipe = (IRecipe) recipe; + Recipe iRecipe = (Recipe) recipe; // Continued server-side in BlueprintItem.assignCompleteRecipe() AllPackets.channel.sendToServer(new BlueprintAssignCompleteRecipePacket(iRecipe.getId())); return null; 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 a59c356e1..ff1eef99e 100644 --- a/src/main/java/com/simibubi/create/compat/jei/ConversionRecipe.java +++ b/src/main/java/com/simibubi/create/compat/jei/ConversionRecipe.java @@ -8,10 +8,10 @@ import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import net.minecraftforge.items.wrapper.RecipeWrapper; /** @@ -35,7 +35,7 @@ public class ConversionRecipe extends ProcessingRecipe { } @Override - public boolean matches(RecipeWrapper inv, World worldIn) { + public boolean matches(RecipeWrapper inv, Level worldIn) { return false; } 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 39d2c68f7..cea161b7c 100644 --- a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java +++ b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java @@ -64,15 +64,15 @@ import mezz.jei.api.registration.IRecipeRegistration; import mezz.jei.api.registration.IRecipeTransferRegistration; import mezz.jei.api.runtime.IIngredientManager; import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.ICraftingRecipe; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.ShapedRecipe; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.ModList; @JeiPlugin @@ -102,14 +102,14 @@ public class CreateJEI implements IModPlugin { .catalystStack(ProcessingViaFanCategory.getFan("fan_washing")) .build(), - smoking = register("fan_smoking", FanSmokingCategory::new).recipes(() -> IRecipeType.SMOKING) + smoking = register("fan_smoking", FanSmokingCategory::new).recipes(() -> RecipeType.SMOKING) .catalystStack(ProcessingViaFanCategory.getFan("fan_smoking")) .build(), blasting = register("fan_blasting", FanBlastingCategory::new) - .recipesExcluding(() -> IRecipeType.SMELTING, () -> IRecipeType.BLASTING) - .recipes(() -> IRecipeType.BLASTING) - .removeRecipes(() -> IRecipeType.SMOKING) + .recipesExcluding(() -> RecipeType.SMELTING, () -> RecipeType.BLASTING) + .recipes(() -> RecipeType.BLASTING) + .removeRecipes(() -> RecipeType.SMOKING) .catalystStack(ProcessingViaFanCategory.getFan("fan_blasting")) .build(), @@ -123,7 +123,7 @@ public class CreateJEI implements IModPlugin { .build(), autoShapeless = register("automatic_shapeless", MixingCategory::autoShapeless) - .recipes(r -> r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE && r.getIngredients() + .recipes(r -> r.getSerializer() == RecipeSerializer.SHAPELESS_RECIPE && r.getIngredients() .size() > 1 && !MechanicalPressTileEntity.canCompress(r), BasinRecipe::convertShapeless) .catalyst(AllBlocks.MECHANICAL_MIXER::get) @@ -142,7 +142,7 @@ public class CreateJEI implements IModPlugin { .build(), blockCutting = register("block_cutting", () -> new BlockCuttingCategory(Items.STONE_BRICK_STAIRS)) - .recipeList(() -> CondensedBlockCuttingRecipe.condenseRecipes(findRecipesByType(IRecipeType.STONECUTTING))) + .recipeList(() -> CondensedBlockCuttingRecipe.condenseRecipes(findRecipesByType(RecipeType.STONECUTTING))) .catalyst(AllBlocks.MECHANICAL_SAW::get) .enableWhen(c -> c.allowStonecuttingOnSaw) .build(), @@ -161,7 +161,7 @@ public class CreateJEI implements IModPlugin { .build(), autoSquare = register("automatic_packing", PackingCategory::autoSquare) - .recipes(r -> (r instanceof ICraftingRecipe) && MechanicalPressTileEntity.canCompress(r), + .recipes(r -> (r instanceof CraftingRecipe) && MechanicalPressTileEntity.canCompress(r), BasinRecipe::convertShapeless) .catalyst(AllBlocks.MECHANICAL_PRESS::get) .catalyst(AllBlocks.BASIN::get) @@ -198,10 +198,10 @@ public class CreateJEI implements IModPlugin { .build(), autoShaped = register("automatic_shaped", MechanicalCraftingCategory::new) - .recipes(r -> r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE && r.getIngredients() + .recipes(r -> r.getSerializer() == RecipeSerializer.SHAPELESS_RECIPE && r.getIngredients() .size() == 1) .recipes( - r -> (r.getType() == IRecipeType.CRAFTING && r.getType() != AllRecipeTypes.MECHANICAL_CRAFTING.getType()) + r -> (r.getType() == RecipeType.CRAFTING && r.getType() != AllRecipeTypes.MECHANICAL_CRAFTING.getType()) && (r instanceof ShapedRecipe)) .catalyst(AllBlocks.MECHANICAL_CRAFTER::get) .enableWhen(c -> c.allowRegularCraftingInCrafter) @@ -212,7 +212,7 @@ public class CreateJEI implements IModPlugin { .catalyst(AllBlocks.MECHANICAL_CRAFTER::get) .build(); - private > CategoryBuilder register(String name, + private > CategoryBuilder register(String name, Supplier> supplier) { return new CategoryBuilder(name, supplier); } @@ -261,9 +261,9 @@ public class CreateJEI implements IModPlugin { registration.addGhostIngredientHandler(BlueprintScreen.class, new GhostIngredientHandler()); } - private class CategoryBuilder> { + private class CategoryBuilder> { private CreateRecipeCategory category; - private List>>> recipeListConsumers = new ArrayList<>(); + private List>>> recipeListConsumers = new ArrayList<>(); private Predicate pred; public CategoryBuilder(String name, Supplier> category) { @@ -276,7 +276,7 @@ public class CreateJEI implements IModPlugin { return recipes(recipeTypeEntry::getType); } - public CategoryBuilder recipes(Supplier> recipeType) { + public CategoryBuilder recipes(Supplier> recipeType) { return recipes(r -> r.getType() == recipeType.get()); } @@ -286,22 +286,22 @@ public class CreateJEI implements IModPlugin { .equals(serializer)); } - public CategoryBuilder recipes(Predicate> pred) { + public CategoryBuilder recipes(Predicate> pred) { return recipeList(() -> findRecipes(pred)); } - public CategoryBuilder recipes(Predicate> pred, Function, T> converter) { + public CategoryBuilder recipes(Predicate> pred, Function, T> converter) { return recipeList(() -> findRecipes(pred), converter); } - public CategoryBuilder recipeList(Supplier>> list) { + public CategoryBuilder recipeList(Supplier>> list) { return recipeList(list, null); } - public CategoryBuilder recipeList(Supplier>> list, - Function, T> converter) { + public CategoryBuilder recipeList(Supplier>> list, + Function, T> converter) { recipeListConsumers.add(recipes -> { - List> toAdd = list.get(); + List> toAdd = list.get(); if (converter != null) toAdd = toAdd.stream() .map(converter) @@ -311,22 +311,22 @@ public class CreateJEI implements IModPlugin { return this; } - public CategoryBuilder recipesExcluding(Supplier> recipeType, - Supplier> excluded) { + public CategoryBuilder recipesExcluding(Supplier> recipeType, + Supplier> excluded) { recipeListConsumers.add(recipes -> { recipes.addAll(findRecipesByTypeExcluding(recipeType.get(), excluded.get())); }); return this; } - public CategoryBuilder removeRecipes(Supplier> recipeType) { + public CategoryBuilder removeRecipes(Supplier> recipeType) { recipeListConsumers.add(recipes -> { removeRecipesByType(recipes, recipeType.get()); }); return this; } - public CategoryBuilder catalyst(Supplier supplier) { + public CategoryBuilder catalyst(Supplier supplier) { return catalystStack(() -> new ItemStack(supplier.get() .asItem())); } @@ -350,8 +350,8 @@ public class CreateJEI implements IModPlugin { public CreateRecipeCategory build() { if (pred.test(AllConfigs.SERVER.recipes)) category.recipes.add(() -> { - List> recipes = new ArrayList<>(); - for (Consumer>> consumer : recipeListConsumers) + List> recipes = new ArrayList<>(); + for (Consumer>> consumer : recipeListConsumers) consumer.accept(recipes); return recipes; }); @@ -361,7 +361,7 @@ public class CreateJEI implements IModPlugin { } - public static List> findRecipes(Predicate> predicate) { + public static List> findRecipes(Predicate> predicate) { return Minecraft.getInstance().level.getRecipeManager() .getRecipes() .stream() @@ -369,34 +369,34 @@ public class CreateJEI implements IModPlugin { .collect(Collectors.toList()); } - public static List> findRecipesByType(IRecipeType type) { + public static List> findRecipesByType(RecipeType type) { return findRecipes(recipe -> recipe.getType() == type); } - public static List> findRecipesByTypeExcluding(IRecipeType type, IRecipeType excludingType) { - List> byType = findRecipesByType(type); + public static List> findRecipesByTypeExcluding(RecipeType type, RecipeType excludingType) { + List> byType = findRecipesByType(type); removeRecipesByType(byType, excludingType); return byType; } - public static List> findRecipesByTypeExcluding(IRecipeType type, IRecipeType... excludingTypes) { - List> byType = findRecipesByType(type); - for (IRecipeType excludingType : excludingTypes) + public static List> findRecipesByTypeExcluding(RecipeType type, RecipeType... excludingTypes) { + List> byType = findRecipesByType(type); + for (RecipeType excludingType : excludingTypes) removeRecipesByType(byType, excludingType); return byType; } - public static void removeRecipesByType(List> recipes, IRecipeType type) { - List> byType = findRecipesByType(type); + public static void removeRecipesByType(List> recipes, RecipeType type) { + List> byType = findRecipesByType(type); recipes.removeIf(recipe -> { - for (IRecipe r : byType) + for (Recipe r : byType) if (doInputsMatch(recipe, r)) return true; return false; }); } - public static boolean doInputsMatch(IRecipe recipe1, IRecipe recipe2) { + public static boolean doInputsMatch(Recipe recipe1, Recipe recipe2) { ItemStack[] matchingStacks = recipe1.getIngredients() .get(0) .getItems(); 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 84ae49721..462725d7d 100644 --- a/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java +++ b/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java @@ -2,13 +2,13 @@ package com.simibubi.create.compat.jei; import java.util.function.Supplier; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.gui.GuiGameElement; import mezz.jei.api.gui.drawable.IDrawable; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.item.ItemStack; +import com.mojang.blaze3d.platform.Lighting; +import net.minecraft.world.item.ItemStack; public class DoubleItemIcon implements IDrawable { @@ -33,13 +33,13 @@ public class DoubleItemIcon implements IDrawable { } @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { if (primaryStack == null) { primaryStack = primarySupplier.get(); secondaryStack = secondarySupplier.get(); } - RenderHelper.turnBackOn(); + Lighting.turnBackOn(); RenderSystem.color4f(1, 1, 1, 1); RenderSystem.enableDepthTest(); matrixStack.pushPose(); diff --git a/src/main/java/com/simibubi/create/compat/jei/EmptyBackground.java b/src/main/java/com/simibubi/create/compat/jei/EmptyBackground.java index f574b23cc..0373423c5 100644 --- a/src/main/java/com/simibubi/create/compat/jei/EmptyBackground.java +++ b/src/main/java/com/simibubi/create/compat/jei/EmptyBackground.java @@ -1,6 +1,6 @@ package com.simibubi.create.compat.jei; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import mezz.jei.api.gui.drawable.IDrawable; @@ -25,6 +25,6 @@ public class EmptyBackground implements IDrawable { } @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {} + public void draw(PoseStack matrixStack, int xOffset, int yOffset) {} } 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 5732d4bff..e3d2a3707 100644 --- a/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java +++ b/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java @@ -13,9 +13,11 @@ import com.simibubi.create.foundation.networking.AllPackets; import mcp.MethodsReturnNonnullByDefault; import mezz.jei.api.gui.handlers.IGhostIngredientHandler; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; + +import mezz.jei.api.gui.handlers.IGhostIngredientHandler.Target; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault @@ -52,7 +54,7 @@ public class GhostIngredientHandler> private static class GhostTarget> implements Target { - private final Rectangle2d area; + private final Rect2i area; private final AbstractSimiContainerScreen gui; private final int slotIndex; private final boolean isAttributeFilter; @@ -62,11 +64,11 @@ public class GhostIngredientHandler> this.slotIndex = slotIndex; this.isAttributeFilter = isAttributeFilter; Slot slot = gui.getMenu().slots.get(slotIndex + 36); - this.area = new Rectangle2d(gui.getGuiLeft() + slot.x, gui.getGuiTop() + slot.y, 16, 16); + this.area = new Rect2i(gui.getGuiLeft() + slot.x, gui.getGuiTop() + slot.y, 16, 16); } @Override - public Rectangle2d getArea() { + public Rect2i getArea() { return area; } 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 a4f2989c5..bc7bd4aa4 100644 --- a/src/main/java/com/simibubi/create/compat/jei/ScreenResourceWrapper.java +++ b/src/main/java/com/simibubi/create/compat/jei/ScreenResourceWrapper.java @@ -1,10 +1,10 @@ package com.simibubi.create.compat.jei; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.AllGuiTextures; import mezz.jei.api.gui.drawable.IDrawable; -import net.minecraft.client.gui.AbstractGui; +import net.minecraft.client.gui.GuiComponent; public class ScreenResourceWrapper implements IDrawable { @@ -25,9 +25,9 @@ public class ScreenResourceWrapper implements IDrawable { } @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { resource.bind(); - AbstractGui.blit(matrixStack, xOffset, yOffset, 0, resource.startX, resource.startY, resource.width, + GuiComponent.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/SlotMover.java b/src/main/java/com/simibubi/create/compat/jei/SlotMover.java index 622114746..d99a44ec8 100644 --- a/src/main/java/com/simibubi/create/compat/jei/SlotMover.java +++ b/src/main/java/com/simibubi/create/compat/jei/SlotMover.java @@ -5,7 +5,7 @@ import java.util.List; import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; import mezz.jei.api.gui.handlers.IGuiContainerHandler; -import net.minecraft.client.renderer.Rectangle2d; +import net.minecraft.client.renderer.Rect2i; /** * Allows a {@link AbstractSimiContainerScreen} to specify an area in getExtraArea() that will be avoided by JEI @@ -15,7 +15,7 @@ import net.minecraft.client.renderer.Rectangle2d; public class SlotMover implements IGuiContainerHandler> { @Override - public List getGuiExtraAreas(AbstractSimiContainerScreen containerScreen) { + public List getGuiExtraAreas(AbstractSimiContainerScreen containerScreen) { return containerScreen.getExtraAreas(); } } 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 ddbec7c2c..ca2732c14 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 @@ -6,7 +6,7 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.mutable.MutableInt; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.content.contraptions.processing.BasinRecipe; @@ -25,9 +25,9 @@ import mezz.jei.api.gui.ingredient.IGuiFluidStackGroup; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.NonNullList; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.core.NonNullList; import net.minecraftforge.fluids.FluidStack; public class BasinCategory extends CreateRecipeCategory { @@ -146,7 +146,7 @@ public class BasinCategory extends CreateRecipeCategory { } @Override - public void draw(BasinRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) { + public void draw(BasinRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) { List> actualIngredients = ItemHelper.condenseIngredients(recipe.getIngredients()); int size = actualIngredients.size() + recipe.getFluidIngredients() 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 95dd72956..1fa69efcd 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 @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.compat.jei.category.BlockCuttingCategory.CondensedBlockCuttingRecipe; import com.simibubi.create.compat.jei.category.animations.AnimatedSaw; @@ -15,12 +15,12 @@ import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.StonecuttingRecipe; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.StonecutterRecipe; +import net.minecraft.resources.ResourceLocation; public class BlockCuttingCategory extends CreateRecipeCategory { @@ -58,7 +58,7 @@ public class BlockCuttingCategory extends CreateRecipeCategory outputs = new ArrayList<>(); @@ -104,9 +104,9 @@ public class BlockCuttingCategory extends CreateRecipeCategory condenseRecipes(List> stoneCuttingRecipes) { + public static List condenseRecipes(List> stoneCuttingRecipes) { List condensed = new ArrayList<>(); - Recipes: for (IRecipe recipe : stoneCuttingRecipes) { + Recipes: for (Recipe recipe : stoneCuttingRecipes) { Ingredient i1 = recipe.getIngredients().get(0); for (CondensedBlockCuttingRecipe condensedRecipe : condensed) { if (ItemHelper.matchIngredients(i1, condensedRecipe.getIngredients().get(0))) { diff --git a/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java index a309a6955..86ae1aa97 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java @@ -20,18 +20,18 @@ import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.ingredient.IGuiFluidStackGroup; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.recipe.category.IRecipeCategory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.fluids.FluidStack; -public abstract class CreateRecipeCategory> implements IRecipeCategory { +public abstract class CreateRecipeCategory> implements IRecipeCategory { - public final List>>> recipes = new ArrayList<>(); + public final List>>> recipes = new ArrayList<>(); public final List> recipeCatalysts = new ArrayList<>(); protected ResourceLocation uid; @@ -70,7 +70,7 @@ public abstract class CreateRecipeCategory> implements IRec return icon; } - public static AllGuiTextures getRenderedSlot(IRecipe recipe, int index) { + public static AllGuiTextures getRenderedSlot(Recipe recipe, int index) { AllGuiTextures jeiSlot = AllGuiTextures.JEI_SLOT; if (!(recipe instanceof ProcessingRecipe)) return jeiSlot; @@ -89,11 +89,11 @@ public abstract class CreateRecipeCategory> implements IRec return new EmptyBackground(width, height); } - public static IDrawable doubleItemIcon(IItemProvider item1, IItemProvider item2) { + public static IDrawable doubleItemIcon(ItemLike item1, ItemLike item2) { return new DoubleItemIcon(() -> new ItemStack(item1), () -> new ItemStack(item2)); } - public static IDrawable itemIcon(IItemProvider item) { + public static IDrawable itemIcon(ItemLike item) { return new DoubleItemIcon(() -> new ItemStack(item), () -> ItemStack.EMPTY); } @@ -111,7 +111,7 @@ public abstract class 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)) - .withStyle(TextFormatting.GOLD)); + .withStyle(ChatFormatting.GOLD)); }); } @@ -145,26 +145,26 @@ public abstract class CreateRecipeCategory> implements IRec if (fluid.getFluid() .isSame(AllFluids.POTION.get())) { - ITextComponent name = fluid.getDisplayName(); + Component name = fluid.getDisplayName(); if (tooltip.isEmpty()) tooltip.add(0, name); else tooltip.set(0, name); - ArrayList potionTooltip = new ArrayList<>(); + ArrayList potionTooltip = new ArrayList<>(); PotionFluidHandler.addPotionTooltip(fluid, potionTooltip, 1); tooltip.addAll(1, potionTooltip.stream() .collect(Collectors.toList())); } int amount = amounts.get(index != -1 ? 0 : slotIndex); - ITextComponent text = (Lang.translate("generic.unit.millibuckets", amount)).withStyle(TextFormatting.GOLD); + Component text = (Lang.translate("generic.unit.millibuckets", amount)).withStyle(ChatFormatting.GOLD); if (tooltip.isEmpty()) tooltip.add(0, text); else { - List siblings = tooltip.get(0) + List siblings = tooltip.get(0) .getSiblings(); - siblings.add(new StringTextComponent(" ")); + siblings.add(new TextComponent(" ")); siblings.add(text); } }); 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 794b43cfd..289dd9e34 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 @@ -3,7 +3,7 @@ package com.simibubi.create.compat.jei.category; import java.util.Arrays; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.compat.jei.category.animations.AnimatedCrushingWheels; @@ -56,7 +56,7 @@ public class CrushingCategory extends CreateRecipeCategory results = recipe.getRollableResults(); AllGuiTextures.JEI_SLOT.draw(matrixStack, 50, 2); AllGuiTextures.JEI_DOWN_ARROW.draw(matrixStack, 72, 7); 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 4e88e2ca2..49b754466 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 @@ -3,7 +3,7 @@ package com.simibubi.create.compat.jei.category; import java.util.Arrays; import java.util.stream.Collectors; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.compat.jei.category.animations.AnimatedDeployer; import com.simibubi.create.content.contraptions.components.deployer.DeployerApplicationRecipe; @@ -15,7 +15,7 @@ import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.ChatFormatting; public class DeployingCategory extends CreateRecipeCategory { @@ -63,7 +63,7 @@ public class DeployingCategory extends CreateRecipeCategory { @@ -20,7 +20,7 @@ public class FanBlastingCategory extends ProcessingViaFanCategory { @@ -20,7 +20,7 @@ public class FanSmokingCategory extends ProcessingViaFanCategory } @Override - public void renderAttachedBlock(MatrixStack matrixStack) { + public void renderAttachedBlock(PoseStack matrixStack) { GuiGameElement.of(Blocks.FIRE.defaultBlockState()) .scale(24) .atLocal(0, 0, 2) 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 939071a61..6785f600d 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 @@ -3,7 +3,7 @@ package com.simibubi.create.compat.jei.category; import java.util.Arrays; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.content.contraptions.components.fan.SplashingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingOutput; @@ -14,8 +14,8 @@ import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.Items; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.Items; public class FanWashingCategory extends ProcessingViaFanCategory { @@ -58,7 +58,7 @@ public class FanWashingCategory extends ProcessingViaFanCategory { } @Override - public void draw(EmptyingRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) { + public void draw(EmptyingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) { AllGuiTextures.JEI_SLOT.draw(matrixStack, 131, 7); AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 7); getRenderedSlot(recipe, 0).draw(matrixStack, 131, 26); 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 545184839..726660fd9 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 @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; import com.simibubi.create.compat.jei.category.animations.AnimatedCrafter; @@ -16,21 +16,21 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredientRenderer; import mezz.jei.api.ingredients.IIngredients; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.ICraftingRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.util.NonNullList; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.client.renderer.entity.ItemRenderer; +import com.mojang.blaze3d.platform.Lighting; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.ShapedRecipe; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; -public class MechanicalCraftingCategory extends CreateRecipeCategory { +public class MechanicalCraftingCategory extends CreateRecipeCategory { private final AnimatedCrafter crafter = new AnimatedCrafter(); @@ -39,13 +39,13 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory recipeIngredients = recipe.getIngredients(); @@ -73,30 +73,30 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory getRecipeClass() { - return ICraftingRecipe.class; + public Class getRecipeClass() { + return CraftingRecipe.class; } private static final class CrafterIngredientRenderer implements IIngredientRenderer { - private final ICraftingRecipe recipe; + private final CraftingRecipe recipe; - public CrafterIngredientRenderer(ICraftingRecipe recipe) { + public CrafterIngredientRenderer(CraftingRecipe recipe) { this.recipe = recipe; } @Override - public void render(MatrixStack matrixStack, int xPosition, int yPosition, ItemStack ingredient) { + public void render(PoseStack matrixStack, int xPosition, int yPosition, ItemStack ingredient) { matrixStack.pushPose(); matrixStack.translate(xPosition, yPosition, 0); float scale = getScale(recipe); @@ -158,14 +158,14 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory getTooltip(ItemStack ingredient, ITooltipFlag tooltipFlag) { + public List getTooltip(ItemStack ingredient, TooltipFlag tooltipFlag) { Minecraft minecraft = Minecraft.getInstance(); - PlayerEntity player = minecraft.player; + Player player = minecraft.player; try { return ingredient.getTooltipLines(player, tooltipFlag); } catch (RuntimeException | LinkageError e) { - List list = new ArrayList<>(); - TranslationTextComponent crash = new TranslationTextComponent("jei.tooltip.error.crash"); - list.add(crash.withStyle(TextFormatting.RED)); + List list = new ArrayList<>(); + TranslatableComponent crash = new TranslatableComponent("jei.tooltip.error.crash"); + list.add(crash.withStyle(ChatFormatting.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 fda2f0e9b..940cd6a13 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 @@ -3,7 +3,7 @@ package com.simibubi.create.compat.jei.category; import java.util.Arrays; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.compat.jei.category.animations.AnimatedMillstone; @@ -58,7 +58,7 @@ public class MillingCategory extends CreateRecipeCategory { @@ -56,7 +56,7 @@ public class PolishingCategory extends CreateRecipeCategory { } @Override - public void draw(PressingRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) { + public void draw(PressingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) { AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 50); getRenderedSlot(recipe, 0).draw(matrixStack, 131, 50); if (recipe.getRollableResults() 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 4d0467a57..0d083f364 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 @@ -5,7 +5,7 @@ import java.util.function.Supplier; import javax.annotation.Nullable; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.compat.jei.category.animations.AnimatedKinetics; @@ -17,11 +17,11 @@ import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import com.mojang.math.Vector3f; -public abstract class ProcessingViaFanCategory> extends CreateRecipeCategory { +public abstract class ProcessingViaFanCategory> extends CreateRecipeCategory { public ProcessingViaFanCategory(IDrawable icon) { this(177, icon); @@ -54,7 +54,7 @@ public abstract class ProcessingViaFanCategory> extends Cre itemStacks.set(1, recipe.getResultItem()); } - protected void renderWidgets(MatrixStack matrixStack, T recipe, double mouseX, double mouseY) { + protected void renderWidgets(PoseStack matrixStack, T recipe, double mouseX, double mouseY) { AllGuiTextures.JEI_SLOT.draw(matrixStack, 20, 47); AllGuiTextures.JEI_SLOT.draw(matrixStack, 139, 47); AllGuiTextures.JEI_SHADOW.draw(matrixStack, 47, 29); @@ -63,7 +63,7 @@ public abstract class ProcessingViaFanCategory> extends Cre } @Override - public void draw(@Nullable T recipe, @Nullable MatrixStack matrixStack, double mouseX, double mouseY) { + public void draw(@Nullable T recipe, @Nullable PoseStack matrixStack, double mouseX, double mouseY) { if (matrixStack == null) return; renderWidgets(matrixStack, recipe, mouseX, mouseY); @@ -89,10 +89,10 @@ public abstract class ProcessingViaFanCategory> extends Cre matrixStack.popPose(); } - protected void translateFan(MatrixStack matrixStack) { + protected void translateFan(PoseStack matrixStack) { matrixStack.translate(56, 33, 0); } - public abstract void renderAttachedBlock(MatrixStack matrixStack); + public abstract void renderAttachedBlock(PoseStack 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 83a6275e4..6689047a0 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 @@ -3,7 +3,7 @@ package com.simibubi.create.compat.jei.category; import java.util.Arrays; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.compat.jei.category.animations.AnimatedSaw; import com.simibubi.create.content.contraptions.components.saw.CuttingRecipe; @@ -14,7 +14,7 @@ import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; -import net.minecraft.item.Items; +import net.minecraft.world.item.Items; public class SawingCategory extends CreateRecipeCategory { @@ -57,7 +57,7 @@ public class SawingCategory extends CreateRecipeCategory { } @Override - public void draw(CuttingRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) { + public void draw(CuttingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) { AllGuiTextures.JEI_SLOT.draw(matrixStack, 43, 4); int size = recipe.getRollableResults() .size(); 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 74a81570f..987093c37 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 @@ -8,7 +8,7 @@ import java.util.Map; import java.util.stream.Collectors; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; import com.simibubi.create.compat.jei.EmptyBackground; @@ -26,14 +26,14 @@ import mezz.jei.api.gui.ingredient.IGuiFluidStackGroup; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; public class SequencedAssemblyCategory extends CreateRecipeCategory { @@ -107,7 +107,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory sequencedRecipe = sequence.get(i); SequencedAssemblySubCategory subCategory = getSubCategory(sequencedRecipe); int subWidth = subCategory.getWidth(); - StringTextComponent component = new StringTextComponent("" + romans[Math.min(i, 6)]); + TextComponent component = new TextComponent("" + romans[Math.min(i, 6)]); 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); @@ -177,10 +177,10 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory getTooltipStrings(SequencedAssemblyRecipe recipe, double mouseX, double mouseY) { - List tooltip = new ArrayList(); + public List getTooltipStrings(SequencedAssemblyRecipe recipe, double mouseX, double mouseY) { + List tooltip = new ArrayList(); - TranslationTextComponent junk = Lang.translate("recipe.assembly.junk"); + TranslatableComponent junk = Lang.translate("recipe.assembly.junk"); boolean singleOutput = recipe.getOutputChance() == 1; boolean willRepeat = recipe.getLoops() > 1; @@ -194,7 +194,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory { } @Override - public void draw(FillingRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) { + public void draw(FillingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) { AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 31); AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 50); getRenderedSlot(recipe, 0).draw(matrixStack, 131, 50); 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 84302d924..dca873483 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 @@ -1,14 +1,14 @@ package com.simibubi.create.compat.jei.category.animations; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.util.Mth; +import com.mojang.math.Vector3f; public class AnimatedBlazeBurner extends AnimatedKinetics { @@ -19,7 +19,7 @@ public class AnimatedBlazeBurner extends AnimatedKinetics { return this; } - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 200); matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); @@ -31,7 +31,7 @@ public class AnimatedBlazeBurner extends AnimatedKinetics { .scale(scale) .render(matrixStack); - float offset = (MathHelper.sin(AnimationTickHolder.getRenderTime() / 16f) + 0.5f) / 16f; + float offset = (Mth.sin(AnimationTickHolder.getRenderTime() / 16f) + 0.5f) / 16f; PartialModel blaze = AllBlockPartials.BLAZES.get(heatLevel); blockElement(blaze) .atLocal(1, 1.65 + offset, 1) 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 ecee0a86f..ff52e9dda 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 @@ -1,14 +1,14 @@ package com.simibubi.create.compat.jei.category.animations; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.gui.AllGuiTextures; public class AnimatedCrafter extends AnimatedKinetics { @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 0); AllGuiTextures.JEI_SHADOW.draw(matrixStack, -16, 13); 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 29ef44198..1c4a25183 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 @@ -1,12 +1,12 @@ package com.simibubi.create.compat.jei.category.animations; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction.Axis; +import com.mojang.math.Vector3f; public class AnimatedCrushingWheels extends AnimatedKinetics { @@ -14,7 +14,7 @@ public class AnimatedCrushingWheels extends AnimatedKinetics { .setValue(BlockStateProperties.AXIS, Axis.X); @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 100); matrixStack.mulPose(Vector3f.YP.rotationDegrees(-22.5f)); 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 e5236ee95..25b144a3d 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 @@ -1,19 +1,19 @@ package com.simibubi.create.compat.jei.category.animations; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.deployer.DeployerBlock; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import com.mojang.math.Vector3f; public class AnimatedDeployer extends AnimatedKinetics { @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 100); matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); 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 3186ad0c7..a23449e67 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 @@ -1,13 +1,13 @@ package com.simibubi.create.compat.jei.category.animations; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.fluid.FluidRenderer; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.IRenderTypeBuffer.Impl; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.MultiBufferSource.BufferSource; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.math.Vector3f; import net.minecraftforge.fluids.FluidStack; public class AnimatedItemDrain extends AnimatedKinetics { @@ -20,7 +20,7 @@ public class AnimatedItemDrain extends AnimatedKinetics { } @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 100); matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); @@ -31,9 +31,9 @@ public class AnimatedItemDrain extends AnimatedKinetics { .scale(scale) .render(matrixStack); - Impl buffer = IRenderTypeBuffer.immediate(Tessellator.getInstance() + BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance() .getBuilder()); - MatrixStack ms = new MatrixStack(); + PoseStack ms = new PoseStack(); ms.scale(scale, -scale, scale); float from = 2/16f; float to = 1f - from; 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 069a397e2..568915de4 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 @@ -9,9 +9,9 @@ import com.simibubi.create.foundation.gui.ILightingSettings; import com.simibubi.create.foundation.utility.AnimationTickHolder; import mezz.jei.api.gui.drawable.IDrawable; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction.Axis; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction.Axis; public abstract class AnimatedKinetics implements IDrawable { 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 4c9b87063..90553ec26 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 @@ -1,6 +1,6 @@ package com.simibubi.create.compat.jei.category.animations; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.gui.AllGuiTextures; @@ -8,7 +8,7 @@ import com.simibubi.create.foundation.gui.AllGuiTextures; public class AnimatedMillstone extends AnimatedKinetics { @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 0); AllGuiTextures.JEI_SHADOW.draw(matrixStack, -16, 13); 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 1b95917a9..523fc7366 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 @@ -1,17 +1,17 @@ package com.simibubi.create.compat.jei.category.animations; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.util.Mth; +import com.mojang.math.Vector3f; public class AnimatedMixer extends AnimatedKinetics { @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 200); matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); @@ -29,7 +29,7 @@ public class AnimatedMixer extends AnimatedKinetics { .scale(scale) .render(matrixStack); - float animation = ((MathHelper.sin(AnimationTickHolder.getRenderTime() / 32f) + 1) / 5) + .5f; + float animation = ((Mth.sin(AnimationTickHolder.getRenderTime() / 32f) + 1) / 5) + .5f; blockElement(AllBlockPartials.MECHANICAL_MIXER_POLE) .atLocal(0, animation, 0) 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 a812afaa8..81ece518d 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 @@ -1,12 +1,12 @@ package com.simibubi.create.compat.jei.category.animations; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.core.Direction.Axis; +import com.mojang.math.Vector3f; public class AnimatedPress extends AnimatedKinetics { @@ -17,7 +17,7 @@ public class AnimatedPress extends AnimatedKinetics { } @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 200); matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); 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 de5e9dd97..5bd14f282 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 @@ -1,18 +1,18 @@ package com.simibubi.create.compat.jei.category.animations; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.saw.SawBlock; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import com.mojang.math.Vector3f; public class AnimatedSaw extends AnimatedKinetics { @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 0); matrixStack.translate(0, 0, 200); 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 0e09a4c51..0ebe12f9c 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 @@ -2,17 +2,17 @@ package com.simibubi.create.compat.jei.category.animations; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.IRenderTypeBuffer.Impl; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.MultiBufferSource.BufferSource; +import com.mojang.blaze3d.vertex.Tesselator; +import net.minecraft.util.Mth; +import com.mojang.math.Vector3f; import net.minecraftforge.fluids.FluidStack; public class AnimatedSpout extends AnimatedKinetics { @@ -25,7 +25,7 @@ public class AnimatedSpout extends AnimatedKinetics { } @Override - public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { + public void draw(PoseStack matrixStack, int xOffset, int yOffset) { matrixStack.pushPose(); matrixStack.translate(xOffset, yOffset, 100); matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f)); @@ -37,7 +37,7 @@ public class AnimatedSpout extends AnimatedKinetics { .render(matrixStack); float cycle = (AnimationTickHolder.getRenderTime() - offset * 8) % 30; - float squeeze = cycle < 20 ? MathHelper.sin((float) (cycle / 20f * Math.PI)) : 0; + float squeeze = cycle < 20 ? Mth.sin((float) (cycle / 20f * Math.PI)) : 0; squeeze *= 20; matrixStack.pushPose(); @@ -62,7 +62,7 @@ public class AnimatedSpout extends AnimatedKinetics { .scale(scale) .render(matrixStack); - Impl buffer = IRenderTypeBuffer.immediate(Tessellator.getInstance() + BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance() .getBuilder()); matrixStack.pushPose(); matrixStack.scale(16, -16, 16); 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 bf4345225..199f4a0c9 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 @@ -4,7 +4,7 @@ import java.util.Arrays; import java.util.Collections; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.compat.jei.category.CreateRecipeCategory; import com.simibubi.create.compat.jei.category.animations.AnimatedDeployer; import com.simibubi.create.compat.jei.category.animations.AnimatedPress; @@ -19,7 +19,7 @@ import com.simibubi.create.foundation.utility.Lang; import mezz.jei.api.gui.ingredient.IGuiFluidStackGroup; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.ChatFormatting; public abstract class SequencedAssemblySubCategory { @@ -41,7 +41,7 @@ public abstract class SequencedAssemblySubCategory { return 0; } - public abstract void draw(SequencedRecipe recipe, MatrixStack ms, double mouseX, double mouseY, int index); + public abstract void draw(SequencedRecipe recipe, PoseStack ms, double mouseX, double mouseY, int index); public static class AssemblyPressing extends SequencedAssemblySubCategory { @@ -53,7 +53,7 @@ public abstract class SequencedAssemblySubCategory { } @Override - public void draw(SequencedRecipe recipe, MatrixStack ms, double mouseX, double mouseY, int index) { + public void draw(SequencedRecipe recipe, PoseStack ms, double mouseX, double mouseY, int index) { press.offset = index; ms.pushPose(); ms.translate(-5, 50, 0); @@ -87,7 +87,7 @@ public abstract class SequencedAssemblySubCategory { } @Override - public void draw(SequencedRecipe recipe, MatrixStack ms, double mouseX, double mouseY, int index) { + public void draw(SequencedRecipe recipe, PoseStack ms, double mouseX, double mouseY, int index) { spout.offset = index; AllGuiTextures.JEI_SLOT.draw(ms, 3, 14); ms.pushPose(); @@ -128,7 +128,7 @@ public abstract class SequencedAssemblySubCategory { if (slotIndex != index) return; tooltip.add(1, Lang.translate("recipe.deploying.not_consumed") - .withStyle(TextFormatting.GOLD)); + .withStyle(ChatFormatting.GOLD)); }); } @@ -136,7 +136,7 @@ public abstract class SequencedAssemblySubCategory { } @Override - public void draw(SequencedRecipe recipe, MatrixStack ms, double mouseX, double mouseY, int index) { + public void draw(SequencedRecipe recipe, PoseStack ms, double mouseX, double mouseY, int index) { deployer.offset = index; ms.pushPose(); ms.translate(-7, 50, 0); @@ -158,7 +158,7 @@ public abstract class SequencedAssemblySubCategory { } @Override - public void draw(SequencedRecipe recipe, MatrixStack ms, double mouseX, double mouseY, int index) { + public void draw(SequencedRecipe recipe, PoseStack ms, double mouseX, double mouseY, int index) { ms.pushPose(); ms.translate(0, 51.5f, 0); ms.scale(.6f, .6f, .6f); diff --git a/src/main/java/com/simibubi/create/compat/tconstruct/SpoutCasting.java b/src/main/java/com/simibubi/create/compat/tconstruct/SpoutCasting.java index 88f47a402..a031bad25 100644 --- a/src/main/java/com/simibubi/create/compat/tconstruct/SpoutCasting.java +++ b/src/main/java/com/simibubi/create/compat/tconstruct/SpoutCasting.java @@ -6,11 +6,11 @@ import com.simibubi.create.content.contraptions.fluids.actors.SpoutTileEntity; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.fluid.FluidHelper; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -24,12 +24,12 @@ public class SpoutCasting extends BlockSpoutingBehaviour { ResourceLocation BASIN = new ResourceLocation("tconstruct", "basin"); @Override - public int fillBlock(World level, BlockPos pos, SpoutTileEntity spout, FluidStack availableFluid, + public int fillBlock(Level level, BlockPos pos, SpoutTileEntity spout, FluidStack availableFluid, boolean simulate) { if (!enabled()) return 0; - TileEntity te = level.getBlockEntity(pos); + BlockEntity te = level.getBlockEntity(pos); if (te == null) return 0; diff --git a/src/main/java/com/simibubi/create/content/AllSections.java b/src/main/java/com/simibubi/create/content/AllSections.java index 5b04c6380..a1f00978b 100644 --- a/src/main/java/com/simibubi/create/content/AllSections.java +++ b/src/main/java/com/simibubi/create/content/AllSections.java @@ -3,10 +3,10 @@ package com.simibubi.create.content; import com.simibubi.create.Create; import com.simibubi.create.foundation.item.ItemDescription.Palette; -import net.minecraft.block.Block; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; public enum AllSections { diff --git a/src/main/java/com/simibubi/create/content/CreateItemGroup.java b/src/main/java/com/simibubi/create/content/CreateItemGroup.java index b36ce6945..ed03bc689 100644 --- a/src/main/java/com/simibubi/create/content/CreateItemGroup.java +++ b/src/main/java/com/simibubi/create/content/CreateItemGroup.java @@ -5,7 +5,7 @@ import java.util.EnumSet; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.item.CreateItemGroupBase; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; public class CreateItemGroup extends CreateItemGroupBase { 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 32ca513d9..f20ac52ca 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java +++ b/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java @@ -8,19 +8,19 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; public class KineticDebugger { @@ -37,7 +37,7 @@ public class KineticDebugger { if (te == null) return; - World world = Minecraft.getInstance().level; + Level world = Minecraft.getInstance().level; BlockPos toOutline = te.hasSource() ? te.source : te.getBlockPos(); BlockState state = te.getBlockState(); VoxelShape shape = world.getBlockState(toOutline) @@ -51,9 +51,9 @@ public class KineticDebugger { if (state.getBlock() instanceof IRotate) { Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state); - Vector3d vec = Vector3d.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, axis) + Vec3 vec = Vec3.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, axis) .getNormal()); - Vector3d center = VecHelper.getCenterOf(te.getBlockPos()); + Vec3 center = VecHelper.getCenterOf(te.getBlockPos()); CreateClient.OUTLINER.showLine("rotationAxis", center.add(vec), center.subtract(vec)) .lineWidth(1 / 16f); } @@ -65,17 +65,17 @@ public class KineticDebugger { } public static KineticTileEntity getSelectedTE() { - RayTraceResult obj = Minecraft.getInstance().hitResult; - ClientWorld world = Minecraft.getInstance().level; + HitResult obj = Minecraft.getInstance().hitResult; + ClientLevel world = Minecraft.getInstance().level; if (obj == null) return null; if (world == null) return null; - if (!(obj instanceof BlockRayTraceResult)) + if (!(obj instanceof BlockHitResult)) return null; - BlockRayTraceResult ray = (BlockRayTraceResult) obj; - TileEntity te = world.getBlockEntity(ray.getBlockPos()); + BlockHitResult ray = (BlockHitResult) obj; + BlockEntity te = world.getBlockEntity(ray.getBlockPos()); if (!(te instanceof KineticTileEntity)) return null; 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 c12e8a081..40fba175d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/RotationPropagator.java @@ -2,10 +2,30 @@ package com.simibubi.create.content.contraptions; import static net.minecraft.state.properties.BlockStateProperties.AXIS; +import javanet.minimport com.simibubi.create.AllBlocks; +import com.simibubi.create.content.contraptions.base.IRotate; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; +import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerBlock; +import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerTileEntity; +import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock; +import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; +import com.simibubi.create.content.contraptions.relays.encased.DirectionalShaftHalvesTileEntity; +import com.simibubi.create.content.contraptions.relays.encased.EncasedBeltBlock; +import com.simibubi.create.content.contraptions.relays.encased.SplitShaftTileEntity; +import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity; +import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.utility.Iterate; import java.util.LinkedList; import java.util.List; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; -import com.simibubi.create.AllBlocks; +ecraft.world.level.block.state.properties.BlockStateProperties com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerBlock; @@ -54,7 +74,7 @@ public class RotationPropagator { final BlockPos diff = to.getBlockPos() .subtract(from.getBlockPos()); final Direction direction = Direction.getNearest(diff.getX(), diff.getY(), diff.getZ()); - final World world = from.getLevel(); + final Level world = from.getLevel(); boolean alignedAxes = true; for (Axis axis : Axis.values()) @@ -204,7 +224,7 @@ public class RotationPropagator { * @param worldIn * @param pos */ - public static void handleAdded(World worldIn, BlockPos pos, KineticTileEntity addedTE) { + public static void handleAdded(Level worldIn, BlockPos pos, KineticTileEntity addedTE) { if (worldIn.isClientSide) return; if (!worldIn.isLoaded(pos)) @@ -219,7 +239,7 @@ public class RotationPropagator { */ private static void propagateNewSource(KineticTileEntity currentTE) { BlockPos pos = currentTE.getBlockPos(); - World world = currentTE.getLevel(); + Level world = currentTE.getLevel(); for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) { float speedOfCurrent = currentTE.getTheoreticalSpeed(); @@ -304,7 +324,7 @@ public class RotationPropagator { * @param pos * @param removedTE */ - public static void handleRemoved(World worldIn, BlockPos pos, KineticTileEntity removedTE) { + public static void handleRemoved(Level worldIn, BlockPos pos, KineticTileEntity removedTE) { if (worldIn.isClientSide) return; if (removedTE == null) @@ -316,7 +336,7 @@ public class RotationPropagator { BlockState neighbourState = worldIn.getBlockState(neighbourPos); if (!(neighbourState.getBlock() instanceof IRotate)) continue; - TileEntity tileEntity = worldIn.getBlockEntity(neighbourPos); + BlockEntity tileEntity = worldIn.getBlockEntity(neighbourPos); if (!(tileEntity instanceof KineticTileEntity)) continue; @@ -336,7 +356,7 @@ public class RotationPropagator { * @param updateTE */ private static void propagateMissingSource(KineticTileEntity updateTE) { - final World world = updateTE.getLevel(); + final Level world = updateTE.getLevel(); List potentialNewSources = new LinkedList<>(); List frontier = new LinkedList<>(); @@ -345,7 +365,7 @@ public class RotationPropagator { while (!frontier.isEmpty()) { final BlockPos pos = frontier.remove(0); - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity tileEntity = world.getBlockEntity(pos); if (!(tileEntity instanceof KineticTileEntity)) continue; final KineticTileEntity currentTE = (KineticTileEntity) tileEntity; @@ -387,7 +407,7 @@ public class RotationPropagator { return null; if (!neighbourState.hasTileEntity()) return null; - TileEntity neighbourTE = currentTE.getLevel() + BlockEntity neighbourTE = currentTE.getLevel() .getBlockEntity(neighbourPos); if (!(neighbourTE instanceof KineticTileEntity)) return null; 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 72b8fd57c..ecaac86c3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java @@ -7,18 +7,18 @@ import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.utility.WorldHelper; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.LevelAccessor; public class TorquePropagator { - static Map> networks = new HashMap<>(); + static Map> networks = new HashMap<>(); - public void onLoadWorld(IWorld world) { + public void onLoadWorld(LevelAccessor world) { networks.put(world, new HashMap<>()); Create.LOGGER.debug("Prepared Kinetic Network Space for " + WorldHelper.getDimensionID(world)); } - public void onUnloadWorld(IWorld world) { + public void onUnloadWorld(LevelAccessor world) { networks.remove(world); Create.LOGGER.debug("Removed Kinetic Network Space for " + WorldHelper.getDimensionID(world)); } 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 f4af13f20..9e1988bbb 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 @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.material.MaterialManager; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; public class BackHalfShaftInstance extends HalfShaftInstance { public BackHalfShaftInstance(MaterialManager modelManager, KineticTileEntity tile) { 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 e3e1e4a0a..06f58ae01 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 @@ -2,15 +2,17 @@ package com.simibubi.create.content.contraptions.base; import com.simibubi.create.content.contraptions.wrench.IWrenchable; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; import net.minecraftforge.common.ToolType; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class CasingBlock extends Block implements IWrenchable { public CasingBlock(Properties p_i48440_1_) { @@ -18,8 +20,8 @@ public class CasingBlock extends Block implements IWrenchable { } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - return ActionResultType.FAIL; + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + return InteractionResult.FAIL; } @Override @@ -28,7 +30,7 @@ public class CasingBlock extends Block implements IWrenchable { } @Override - public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) { + public boolean canHarvestBlock(BlockState state, BlockGetter world, BlockPos pos, Player player) { for (ToolType toolType : player.getMainHandItem().getToolTypes()) { if (isToolEffective(state, toolType)) return true; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/CutoutRotatingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/CutoutRotatingInstance.java index c8c720bd1..3efa6d34f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/CutoutRotatingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/CutoutRotatingInstance.java @@ -4,6 +4,8 @@ import com.jozufozu.flywheel.backend.material.Material; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.foundation.render.AllMaterialSpecs; +import Material; + public class CutoutRotatingInstance extends SingleRotatingInstance { public CutoutRotatingInstance(MaterialManager modelManager, KineticTileEntity tile) { super(modelManager, tile); 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 b51c78b95..fd96a66c3 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 @@ -3,17 +3,19 @@ package com.simibubi.create.content.contraptions.base; import com.simibubi.create.foundation.utility.DirectionHelper; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBlock { @@ -29,7 +31,7 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc super.createBlockStateDefinition(builder); } - protected Direction getFacingForPlacement(BlockItemUseContext context) { + protected Direction getFacingForPlacement(BlockPlaceContext context) { Direction facing = context.getNearestLookingDirection() .getOpposite(); if (context.getPlayer() != null && context.getPlayer() @@ -38,16 +40,16 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc return facing; } - protected boolean getAxisAlignmentForPlacement(BlockItemUseContext context) { + protected boolean getAxisAlignmentForPlacement(BlockPlaceContext context) { return context.getHorizontalDirection() .getAxis() == Axis.X; } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Direction facing = getFacingForPlacement(context); BlockPos pos = context.getClickedPos(); - World world = context.getLevel(); + Level world = context.getLevel(); boolean alongFirst = false; Axis faceAxis = facing.getAxis(); @@ -88,7 +90,7 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc .setValue(AXIS_ALONG_FIRST_COORDINATE, alongFirst); } - protected boolean prefersConnectionTo(IWorldReader reader, BlockPos pos, Direction facing, boolean shaftAxis) { + protected boolean prefersConnectionTo(LevelReader reader, BlockPos pos, Direction facing, boolean shaftAxis) { if (!shaftAxis) return false; BlockPos neighbourPos = pos.relative(facing); @@ -122,7 +124,7 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == getRotationAxis(state); } 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 a95b29bda..0d87c6e50 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 @@ -2,15 +2,17 @@ package com.simibubi.create.content.contraptions.base; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public abstract class DirectionalKineticBlock extends KineticBlock { @@ -26,7 +28,7 @@ public abstract class DirectionalKineticBlock extends KineticBlock { super.createBlockStateDefinition(builder); } - public Direction getPreferredFacing(BlockItemUseContext context) { + public Direction getPreferredFacing(BlockPlaceContext context) { Direction prefferedSide = null; for (Direction side : Iterate.directions) { BlockState blockState = context.getLevel() @@ -47,7 +49,7 @@ public abstract class DirectionalKineticBlock extends KineticBlock { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Direction preferred = getPreferredFacing(context); if (preferred == null || (context.getPlayer() != null && context.getPlayer() .isShiftKeyDown())) { 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 b96f34fff..9d5c597d6 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 @@ -7,18 +7,18 @@ import com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; public abstract class GeneratingKineticTileEntity extends KineticTileEntity { public boolean reActivateSource; - public GeneratingKineticTileEntity(TileEntityType typeIn) { + public GeneratingKineticTileEntity(BlockEntityType typeIn) { super(typeIn); } @@ -36,7 +36,7 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { @Override public void setSource(BlockPos source) { super.setSource(source); - TileEntity tileEntity = level.getBlockEntity(source); + BlockEntity tileEntity = level.getBlockEntity(source); if (!(tileEntity instanceof KineticTileEntity)) return; KineticTileEntity sourceTe = (KineticTileEntity) tileEntity; @@ -54,13 +54,13 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { boolean added = super.addToGoggleTooltip(tooltip, isPlayerSneaking); float stressBase = calculateAddedStressCapacity(); if (stressBase != 0 && IRotate.StressImpact.isEnabled()) { tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.goggles.generator_stats"))); - tooltip.add(componentSpacing.plainCopy().append(Lang.translate("tooltip.capacityProvided").withStyle(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("tooltip.capacityProvided").withStyle(ChatFormatting.GRAY))); float speed = getTheoreticalSpeed(); if (speed != getGeneratedSpeed() && speed != 0) @@ -71,11 +71,11 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { tooltip.add( componentSpacing.plainCopy() - .append(new StringTextComponent(" " + IHaveGoggleInformation.format(stressTotal)) + .append(new TextComponent(" " + IHaveGoggleInformation.format(stressTotal)) .append(Lang.translate("generic.unit.stress")) - .withStyle(TextFormatting.AQUA)) + .withStyle(ChatFormatting.AQUA)) .append(" ") - .append(Lang.translate("gui.goggles.at_current_speed").withStyle(TextFormatting.DARK_GRAY))); + .append(Lang.translate("gui.goggles.at_current_speed").withStyle(ChatFormatting.DARK_GRAY))); added = true; } 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 819f9133e..91328875d 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 @@ -5,7 +5,7 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.AllBlockPartials; import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; public class HalfShaftInstance extends SingleRotatingInstance { public HalfShaftInstance(MaterialManager modelManager, KineticTileEntity tile) { 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 1aceb4799..c5e9f1641 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 @@ -2,19 +2,21 @@ package com.simibubi.create.content.contraptions.base; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.Property; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelReader; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public abstract class HorizontalAxisKineticBlock extends KineticBlock { @@ -31,14 +33,14 @@ public abstract class HorizontalAxisKineticBlock extends KineticBlock { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Axis preferredAxis = getPreferredHorizontalAxis(context); if (preferredAxis != null) return this.defaultBlockState().setValue(HORIZONTAL_AXIS, preferredAxis); return this.defaultBlockState().setValue(HORIZONTAL_AXIS, context.getHorizontalDirection().getClockWise().getAxis()); } - public static Axis getPreferredHorizontalAxis(BlockItemUseContext context) { + public static Axis getPreferredHorizontalAxis(BlockPlaceContext context) { Direction prefferedSide = null; for (Direction side : Iterate.horizontalDirections) { BlockState blockState = context.getLevel().getBlockState(context.getClickedPos().relative(side)); @@ -62,7 +64,7 @@ public abstract class HorizontalAxisKineticBlock extends KineticBlock { } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.getValue(HORIZONTAL_AXIS); } 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 b0d38884d..99555bbe4 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 @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.material.MaterialManager; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; public class HorizontalHalfShaftInstance extends HalfShaftInstance { 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 fb844a7f9..35405d03a 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 @@ -2,15 +2,17 @@ package com.simibubi.create.content.contraptions.base; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.Property; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public abstract class HorizontalKineticBlock extends KineticBlock { @@ -27,13 +29,13 @@ public abstract class HorizontalKineticBlock extends KineticBlock { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { return this.defaultBlockState() .setValue(HORIZONTAL_FACING, context.getHorizontalDirection() .getOpposite()); } - public Direction getPreferredHorizontalFacing(BlockItemUseContext context) { + public Direction getPreferredHorizontalFacing(BlockPlaceContext context) { Direction prefferedSide = null; for (Direction side : Iterate.horizontalDirections) { BlockState blockState = context.getLevel() 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 2f2540eb7..550cafea2 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 @@ -6,15 +6,15 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.world.level.LevelReader; public interface IRotate extends IWrenchable { @@ -23,9 +23,9 @@ public interface IRotate extends IWrenchable { MEDIUM, FAST; - public TextFormatting getTextColor() { - return this == NONE ? TextFormatting.GREEN - : this == MEDIUM ? TextFormatting.AQUA : TextFormatting.LIGHT_PURPLE; + public ChatFormatting getTextColor() { + return this == NONE ? ChatFormatting.GREEN + : this == MEDIUM ? ChatFormatting.AQUA : ChatFormatting.LIGHT_PURPLE; } public int getColor() { @@ -59,10 +59,10 @@ public interface IRotate extends IWrenchable { } } - public static ITextComponent getFormattedSpeedText(float speed, boolean overstressed){ + public static Component getFormattedSpeedText(float speed, boolean overstressed){ SpeedLevel speedLevel = of(speed); - IFormattableTextComponent level = new StringTextComponent(ItemDescription.makeProgressBar(3, speedLevel.ordinal())); + MutableComponent level = new TextComponent(ItemDescription.makeProgressBar(3, speedLevel.ordinal())); if (speedLevel == SpeedLevel.MEDIUM) level.append(Lang.translate("tooltip.speedRequirement.medium")); @@ -72,7 +72,7 @@ public interface IRotate extends IWrenchable { level.append(" (" + IHaveGoggleInformation.format(Math.abs(speed))).append(Lang.translate("generic.unit.rpm")).append(") "); if (overstressed) - level.withStyle(TextFormatting.DARK_GRAY, TextFormatting.STRIKETHROUGH); + level.withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.STRIKETHROUGH); else level.withStyle(speedLevel.getTextColor()); @@ -87,12 +87,12 @@ public interface IRotate extends IWrenchable { HIGH, OVERSTRESSED; - public TextFormatting getAbsoluteColor() { - return this == LOW ? TextFormatting.YELLOW : this == MEDIUM ? TextFormatting.GOLD : TextFormatting.RED; + public ChatFormatting getAbsoluteColor() { + return this == LOW ? ChatFormatting.YELLOW : this == MEDIUM ? ChatFormatting.GOLD : ChatFormatting.RED; } - public TextFormatting getRelativeColor() { - return this == LOW ? TextFormatting.GREEN : this == MEDIUM ? TextFormatting.YELLOW : this == HIGH ? TextFormatting.GOLD : TextFormatting.RED; + public ChatFormatting getRelativeColor() { + return this == LOW ? ChatFormatting.GREEN : this == MEDIUM ? ChatFormatting.YELLOW : this == HIGH ? ChatFormatting.GOLD : ChatFormatting.RED; } public static StressImpact of(double stressPercent){ @@ -106,11 +106,11 @@ public interface IRotate extends IWrenchable { return !AllConfigs.SERVER.kinetics.disableStress.get(); } - public static ITextComponent getFormattedStressText(double stressPercent){ + public static Component getFormattedStressText(double stressPercent){ StressImpact stressLevel = of(stressPercent); - TextFormatting color = stressLevel.getRelativeColor(); + ChatFormatting color = stressLevel.getRelativeColor(); - IFormattableTextComponent level = new StringTextComponent(ItemDescription.makeProgressBar(3, Math.min(stressLevel.ordinal(), 2))); + MutableComponent level = new TextComponent(ItemDescription.makeProgressBar(3, Math.min(stressLevel.ordinal(), 2))); level.append(Lang.translate("tooltip.stressImpact." + Lang.asId(stressLevel.name()))); level.append(String.format(" (%s%%) ", (int) (stressPercent * 100))); @@ -119,7 +119,7 @@ public interface IRotate extends IWrenchable { } } - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face); + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face); public Axis getRotationAxis(BlockState state); 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 c2dc5f863..7d6739e83 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 @@ -2,20 +2,22 @@ package com.simibubi.create.content.contraptions.base; import com.simibubi.create.foundation.item.ItemDescription.Palette; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ToolType; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public abstract class KineticBlock extends Block implements IRotate { protected static final Palette color = Palette.Red; @@ -30,7 +32,7 @@ public abstract class KineticBlock extends Block implements IRotate { } @Override - public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) { + public boolean canHarvestBlock(BlockState state, BlockGetter world, BlockPos pos, Player player) { for (ToolType toolType : player.getMainHandItem() .getToolTypes()) { if (isToolEffective(state, toolType)) @@ -45,13 +47,13 @@ public abstract class KineticBlock extends Block implements IRotate { } @Override - public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level 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.getBlockEntity(pos); + BlockEntity tileEntity = worldIn.getBlockEntity(pos); if (tileEntity instanceof KineticTileEntity) { KineticTileEntity kineticTileEntity = (KineticTileEntity) tileEntity; kineticTileEntity.preventSpeedUpdate = 0; @@ -68,7 +70,7 @@ public abstract class KineticBlock extends Block implements IRotate { } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return false; } @@ -84,14 +86,14 @@ public abstract class KineticBlock extends Block implements IRotate { } @Override - public abstract TileEntity createTileEntity(BlockState state, IBlockReader world); + public abstract BlockEntity createTileEntity(BlockState state, BlockGetter world); @Override - public void updateIndirectNeighbourShapes(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) { + public void updateIndirectNeighbourShapes(BlockState stateIn, LevelAccessor worldIn, BlockPos pos, int flags, int count) { if (worldIn.isClientSide()) return; - TileEntity tileEntity = worldIn.getBlockEntity(pos); + BlockEntity 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 setPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { + public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { if (worldIn.isClientSide) return; - TileEntity tileEntity = worldIn.getBlockEntity(pos); + BlockEntity 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 d9cfa63d4..46bd1ca0f 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 @@ -4,8 +4,8 @@ import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.core.materials.BasicData; import com.simibubi.create.foundation.utility.Color; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.core.BlockPos; +import com.mojang.math.Vector3f; public class KineticData extends BasicData { private float x; 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 6709d540e..e72d94eda 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 @@ -7,15 +7,15 @@ import com.simibubi.create.content.contraptions.particle.RotationIndicatorPartic import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; public class KineticEffectHandler { @@ -29,7 +29,7 @@ public class KineticEffectHandler { } public void tick() { - World world = kte.getLevel(); + Level world = kte.getLevel(); if (world.isClientSide) { if (overStressedTime > 0) @@ -58,16 +58,16 @@ public class KineticEffectHandler { particleSpawnCountdown = 2; } - public void spawnEffect(IParticleData particle, float maxMotion, int amount) { - World world = kte.getLevel(); + public void spawnEffect(ParticleOptions particle, float maxMotion, int amount) { + Level world = kte.getLevel(); if (world == null) return; if (!world.isClientSide) return; Random r = world.random; for (int i = 0; i < amount; i++) { - Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, r, maxMotion); - Vector3d position = VecHelper.getCenterOf(kte.getBlockPos()); + Vec3 motion = VecHelper.offsetRandomly(Vec3.ZERO, r, maxMotion); + Vec3 position = VecHelper.getCenterOf(kte.getBlockPos()); world.addParticle(particle, position.x, position.y, position.z, motion.x, motion.y, motion.z); } } @@ -88,24 +88,24 @@ public class KineticEffectHandler { Axis axis = kb.getRotationAxis(state); BlockPos pos = kte.getBlockPos(); - World world = kte.getLevel(); + Level world = kte.getLevel(); if (axis == null) return; if (world == null) return; char axisChar = axis.name().charAt(0); - Vector3d vec = VecHelper.getCenterOf(pos); + Vec3 vec = VecHelper.getCenterOf(pos); SpeedLevel speedLevel = SpeedLevel.of(speed); int color = speedLevel.getColor(); int particleSpeed = speedLevel.getParticleSpeed(); particleSpeed *= Math.signum(speed); - if (world instanceof ServerWorld) { + if (world instanceof ServerLevel) { AllTriggers.triggerForNearbyPlayers(AllTriggers.ROTATION, world, pos, 5); RotationIndicatorParticleData particleData = new RotationIndicatorParticleData(color, particleSpeed, radius1, radius2, 10, axisChar); - ((ServerWorld) world).sendParticles(particleData, vec.x, vec.y, vec.z, 20, 0, 0, 0, 1); + ((ServerLevel) 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 930e89411..f6ad4f675 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 @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.base; import static net.minecraft.util.text.TextFormatting.GOLD; -import static net.minecraft.util.text.TextFormatting.GRAY; +import staticnet.minecraft.ChatFormattingg.GRAY; import java.util.List; @@ -27,30 +27,30 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.client.resources.I18n; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.TickableBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; public abstract class KineticTileEntity extends SmartTileEntity - implements ITickableTileEntity, IHaveGoggleInformation, IHaveHoveringInformation, IInstanceRendered { + implements TickableBlockEntity, IHaveGoggleInformation, IHaveHoveringInformation, IInstanceRendered { public @Nullable Long network; public @Nullable BlockPos source; @@ -71,7 +71,7 @@ public abstract class KineticTileEntity extends SmartTileEntity protected float lastStressApplied; protected float lastCapacityProvided; - public KineticTileEntity(TileEntityType typeIn) { + public KineticTileEntity(BlockEntityType typeIn) { super(typeIn); effects = new KineticEffectHandler(this); updateSpeed = true; @@ -128,7 +128,7 @@ public abstract class KineticTileEntity extends SmartTileEntity if (!level.isLoaded(source)) return; - TileEntity tileEntity = level.getBlockEntity(source); + BlockEntity tileEntity = level.getBlockEntity(source); KineticTileEntity sourceTe = tileEntity instanceof KineticTileEntity ? (KineticTileEntity) tileEntity : null; if (sourceTe == null || sourceTe.speed == 0) { @@ -195,17 +195,17 @@ public abstract class KineticTileEntity extends SmartTileEntity } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { compound.putFloat("Speed", speed); if (needsSpeedUpdate()) compound.putBoolean("NeedsSpeedUpdate", true); if (hasSource()) - compound.put("Source", NBTUtil.writeBlockPos(source)); + compound.put("Source", NbtUtils.writeBlockPos(source)); if (hasNetwork()) { - CompoundNBT networkTag = new CompoundNBT(); + CompoundTag networkTag = new CompoundTag(); networkTag.putLong("Id", this.network); networkTag.putFloat("Stress", stress); networkTag.putFloat("Capacity", capacity); @@ -227,7 +227,7 @@ public abstract class KineticTileEntity extends SmartTileEntity } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { boolean overStressedBefore = overStressed; clearKineticInformation(); @@ -240,10 +240,10 @@ public abstract class KineticTileEntity extends SmartTileEntity speed = compound.getFloat("Speed"); if (compound.contains("Source")) - source = NBTUtil.readBlockPos(compound.getCompound("Source")); + source = NbtUtils.readBlockPos(compound.getCompound("Source")); if (compound.contains("Network")) { - CompoundNBT networkTag = compound.getCompound("Network"); + CompoundTag networkTag = compound.getCompound("Network"); network = networkTag.getLong("Id"); stress = networkTag.getFloat("Stress"); capacity = networkTag.getFloat("Capacity"); @@ -293,7 +293,7 @@ public abstract class KineticTileEntity extends SmartTileEntity if (level == null || level.isClientSide) return; - TileEntity tileEntity = level.getBlockEntity(source); + BlockEntity tileEntity = level.getBlockEntity(source); if (!(tileEntity instanceof KineticTileEntity)) { removeSource(); return; @@ -362,11 +362,11 @@ public abstract class KineticTileEntity extends SmartTileEntity return true; } - public static void switchToBlockState(World world, BlockPos pos, BlockState state) { + public static void switchToBlockState(Level world, BlockPos pos, BlockState state) { if (world.isClientSide) return; - TileEntity tileEntityIn = world.getBlockEntity(pos); + BlockEntity tileEntityIn = world.getBlockEntity(pos); BlockState currentState = world.getBlockState(pos); boolean isKinetic = tileEntityIn instanceof KineticTileEntity; @@ -394,15 +394,15 @@ public abstract class KineticTileEntity extends SmartTileEntity public void addBehaviours(List behaviours) {} @Override - public boolean addToTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToTooltip(List tooltip, boolean isPlayerSneaking) { boolean notFastEnough = !isSpeedRequirementFulfilled() && getSpeed() != 0; if (overStressed && AllConfigs.CLIENT.enableOverstressedTooltip.get()) { tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.stressometer.overstressed") .withStyle(GOLD))); - ITextComponent hint = Lang.translate("gui.contraptions.network_overstressed"); - List cutString = TooltipHelper.cutTextComponent(hint, GRAY, TextFormatting.WHITE); + Component hint = Lang.translate("gui.contraptions.network_overstressed"); + List cutString = TooltipHelper.cutTextComponent(hint, GRAY, ChatFormatting.WHITE); for (int i = 0; i < cutString.size(); i++) tooltip.add(componentSpacing.plainCopy() .append(cutString.get(i))); @@ -413,10 +413,10 @@ public abstract class KineticTileEntity extends SmartTileEntity tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.speedRequirement") .withStyle(GOLD))); - ITextComponent hint = + Component hint = Lang.translate("gui.contraptions.not_fast_enough", I18n.get(getBlockState().getBlock() .getDescriptionId())); - List cutString = TooltipHelper.cutTextComponent(hint, GRAY, TextFormatting.WHITE); + List cutString = TooltipHelper.cutTextComponent(hint, GRAY, ChatFormatting.WHITE); for (int i = 0; i < cutString.size(); i++) tooltip.add(componentSpacing.plainCopy() .append(cutString.get(i))); @@ -427,7 +427,7 @@ public abstract class KineticTileEntity extends SmartTileEntity } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { boolean added = false; float stressAtBase = calculateStressApplied(); @@ -436,17 +436,17 @@ public abstract class KineticTileEntity extends SmartTileEntity .append(Lang.translate("gui.goggles.kinetic_stats"))); tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.stressImpact") - .withStyle(TextFormatting.GRAY))); + .withStyle(ChatFormatting.GRAY))); float stressTotal = stressAtBase * Math.abs(getTheoreticalSpeed()); tooltip.add(componentSpacing.plainCopy() - .append(new StringTextComponent(" " + IHaveGoggleInformation.format(stressTotal)) + .append(new TextComponent(" " + IHaveGoggleInformation.format(stressTotal)) .append(Lang.translate("generic.unit.stress")) .append(" ") - .withStyle(TextFormatting.AQUA)) + .withStyle(ChatFormatting.AQUA)) .append(Lang.translate("gui.goggles.at_current_speed") - .withStyle(TextFormatting.DARK_GRAY))); + .withStyle(ChatFormatting.DARK_GRAY))); added = true; } @@ -565,17 +565,17 @@ public abstract class KineticTileEntity extends SmartTileEntity DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); } - protected AxisAlignedBB cachedBoundingBox; + protected AABB cachedBoundingBox; @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { + public AABB getRenderBoundingBox() { if (cachedBoundingBox == null) { cachedBoundingBox = makeRenderBoundingBox(); } return cachedBoundingBox; } - protected AxisAlignedBB makeRenderBoundingBox() { + protected AABB makeRenderBoundingBox() { return super.getRenderBoundingBox(); } @@ -584,7 +584,7 @@ public abstract class KineticTileEntity extends SmartTileEntity float componentSpeed = Math.abs(getSpeed()); if (componentSpeed == 0) return; - float pitch = MathHelper.clamp((componentSpeed / 256f) + .45f, .85f, 1f); + float pitch = Mth.clamp((componentSpeed / 256f) + .45f, .85f, 1f); if (isNoisy()) SoundScapes.play(AmbienceGroup.KINETIC, worldPosition, pitch); 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 5961777ca..9a74da278 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 @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.KineticDebugger; @@ -13,16 +13,16 @@ import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -32,28 +32,28 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer KINETIC_TILE = new Compartment<>(); public static boolean rainbowMode = false; - public KineticTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public KineticTileEntityRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; for (RenderType type : RenderType.chunkBufferLayers()) - if (RenderTypeLookup.canRenderInLayer(te.getBlockState(), type)) + if (ItemBlockRenderTypes.canRenderInLayer(te.getBlockState(), type)) renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(type), light); } - public static void renderRotatingKineticBlock(KineticTileEntity te, BlockState renderedState, MatrixStack ms, - IVertexBuilder buffer, int light) { + public static void renderRotatingKineticBlock(KineticTileEntity te, BlockState renderedState, PoseStack ms, + VertexConsumer buffer, int light) { SuperByteBuffer superByteBuffer = CreateClient.BUFFER_CACHE.renderBlockIn(KINETIC_TILE, renderedState); renderRotatingBuffer(te, superByteBuffer, ms, buffer, light); } - public static void renderRotatingBuffer(KineticTileEntity te, SuperByteBuffer superBuffer, MatrixStack ms, - IVertexBuilder buffer, int light) { + public static void renderRotatingBuffer(KineticTileEntity te, SuperByteBuffer superBuffer, PoseStack ms, + VertexConsumer buffer, int light) { standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, buffer); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java index 65750db4b..94e52c0a9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java @@ -8,8 +8,10 @@ import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock; import com.simibubi.create.foundation.render.AllMaterialSpecs; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; + +import Material; public abstract class KineticTileInstance extends TileEntityInstance { 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 16dbd32a3..f402458b6 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 @@ -2,15 +2,17 @@ package com.simibubi.create.content.contraptions.base; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Rotation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.level.block.Rotation; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public abstract class RotatedPillarKineticBlock extends KineticBlock { @@ -40,7 +42,7 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock { } } - public static Axis getPreferredAxis(BlockItemUseContext context) { + public static Axis getPreferredAxis(BlockPlaceContext context) { Axis prefferedAxis = null; for (Direction side : Iterate.directions) { BlockState blockState = context.getLevel() @@ -61,12 +63,12 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock { } @Override - protected void createBlockStateDefinition(StateContainer.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(AXIS); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Axis preferredAxis = getPreferredAxis(context); if (preferredAxis != null && (context.getPlayer() == null || !context.getPlayer() .isShiftKeyDown())) 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 0cf848211..022b45063 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 @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.core.Direction; +import com.mojang.math.Vector3f; public class RotatingData extends KineticData { private byte rotationAxisX; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/SingleRotatingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/SingleRotatingInstance.java index c8327bcc2..c25f168f1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/SingleRotatingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/SingleRotatingInstance.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; public class SingleRotatingInstance extends KineticTileInstance { 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 b39595fb7..7bbdd360c 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 @@ -4,15 +4,17 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltSlope; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; + +import net.minecraft.world.item.Item.Properties; public class AssemblyOperatorBlockItem extends BlockItem { @@ -21,7 +23,7 @@ public class AssemblyOperatorBlockItem extends BlockItem { } @Override - public ActionResultType place(BlockItemUseContext context) { + public InteractionResult place(BlockPlaceContext context) { BlockPos placedOnPos = context.getClickedPos() .relative(context.getClickedFace() .getOpposite()); @@ -34,15 +36,15 @@ public class AssemblyOperatorBlockItem extends BlockItem { .isReplaceable()) context = adjustContext(context, placedOnPos); else - return ActionResultType.FAIL; + return InteractionResult.FAIL; } return super.place(context); } - protected BlockItemUseContext adjustContext(BlockItemUseContext context, BlockPos placedOnPos) { + protected BlockPlaceContext adjustContext(BlockPlaceContext context, BlockPos placedOnPos) { 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)); + return new AssemblyOperatorUseContext(context.getLevel(), context.getPlayer(), context.getHand(), context.getItemInHand(), new BlockHitResult(new Vec3((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/AssemblyOperatorUseContext.java b/src/main/java/com/simibubi/create/content/contraptions/components/AssemblyOperatorUseContext.java index 80fde6127..6e483e92e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/AssemblyOperatorUseContext.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/AssemblyOperatorUseContext.java @@ -2,15 +2,15 @@ package com.simibubi.create.content.contraptions.components; import javax.annotation.Nullable; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.Level; -public class AssemblyOperatorUseContext extends BlockItemUseContext { - public AssemblyOperatorUseContext(World p_i50056_1_, @Nullable PlayerEntity p_i50056_2_, Hand p_i50056_3_, ItemStack p_i50056_4_, BlockRayTraceResult p_i50056_5_) { +public class AssemblyOperatorUseContext extends BlockPlaceContext { + public AssemblyOperatorUseContext(Level p_i50056_1_, @Nullable Player p_i50056_2_, InteractionHand p_i50056_3_, ItemStack p_i50056_4_, BlockHitResult p_i50056_5_) { super(p_i50056_1_, p_i50056_2_, p_i50056_3_, p_i50056_4_, p_i50056_5_); } } 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 d40318663..23c6d9f0c 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 @@ -3,9 +3,9 @@ package com.simibubi.create.content.contraptions.components.actors; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.core.BlockPos; +import com.mojang.math.Quaternion; +import com.mojang.math.Vector3f; public class ActorData extends InstanceData { private float x; 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 827540eac..8864274c5 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 @@ -7,36 +7,38 @@ import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.utility.BlockHelper; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public abstract class AttachedActorBlock extends HorizontalBlock implements IWrenchable { +public abstract class AttachedActorBlock extends HorizontalDirectionalBlock implements IWrenchable { protected AttachedActorBlock(Properties p_i48377_1_) { super(p_i48377_1_); } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - return ActionResultType.FAIL; + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + return InteractionResult.FAIL; } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { Direction direction = state.getValue(FACING); return AllShapes.HARVESTER_BASE.get(direction); } @@ -48,14 +50,14 @@ public abstract class AttachedActorBlock extends HorizontalBlock implements IWre } @Override - public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader 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) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Direction facing; if (context.getClickedFace().getAxis().isVertical()) facing = context.getHorizontalDirection().getOpposite(); @@ -71,7 +73,7 @@ public abstract class AttachedActorBlock extends HorizontalBlock implements IWre } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 b635039d8..3a711e6ba 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 @@ -4,12 +4,12 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.curiosities.bell.AbstractBellBlock; -import net.minecraft.block.Block; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; public class BellMovementBehaviour extends MovementBehaviour { @@ -19,7 +19,7 @@ public class BellMovementBehaviour extends MovementBehaviour { } @Override - public void onSpeedChanged(MovementContext context, Vector3d oldMotion, Vector3d motion) { + public void onSpeedChanged(MovementContext context, Vec3 oldMotion, Vec3 motion) { double dotProduct = oldMotion.dot(motion); if (dotProduct <= 0 && (context.relativeMotion.length() != 0) || context.firstMovement) @@ -33,7 +33,7 @@ public class BellMovementBehaviour extends MovementBehaviour { } public static void playSound(MovementContext context) { - World world = context.world; + Level world = context.world; BlockPos pos = new BlockPos(context.position); Block block = context.state.getBlock(); @@ -42,7 +42,7 @@ public class BellMovementBehaviour extends MovementBehaviour { } else { // Vanilla bell sound world.playSound(null, pos, SoundEvents.BELL_BLOCK, - SoundCategory.BLOCKS, 2f, 1f); + SoundSource.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 a9b11e083..c1cea6a77 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 @@ -5,22 +5,22 @@ import java.util.concurrent.atomic.AtomicInteger; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.AirBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.GameRules; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.AirBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.sounds.SoundSource; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.GameRules; +import net.minecraft.server.level.ServerLevel; public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity { @@ -30,7 +30,7 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity { protected int breakerId = -NEXT_BREAKER_ID.incrementAndGet(); protected BlockPos breakingPos; - public BlockBreakingKineticTileEntity(TileEntityType typeIn) { + public BlockBreakingKineticTileEntity(BlockEntityType typeIn) { super(typeIn); } @@ -59,20 +59,20 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("Progress", destroyProgress); compound.putInt("NextTick", ticksUntilNextProgress); if (breakingPos != null) - compound.put("Breaking", NBTUtil.writeBlockPos(breakingPos)); + compound.put("Breaking", NbtUtils.writeBlockPos(breakingPos)); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { destroyProgress = compound.getInt("Progress"); ticksUntilNextProgress = compound.getInt("NextTick"); if (compound.contains("Breaking")) - breakingPos = NBTUtil.readBlockPos(compound.getCompound("Breaking")); + breakingPos = NbtUtils.readBlockPos(compound.getCompound("Breaking")); super.fromTag(state, compound, clientPacket); } @@ -113,8 +113,8 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity { } float breakSpeed = getBreakSpeed(); - destroyProgress += MathHelper.clamp((int) (breakSpeed / blockHardness), 1, 10 - destroyProgress); - level.playSound(null, worldPosition, stateToBreak.getSoundType().getHitSound(), SoundCategory.NEUTRAL, .25f, 1); + destroyProgress += Mth.clamp((int) (breakSpeed / blockHardness), 1, 10 - destroyProgress); + level.playSound(null, worldPosition, stateToBreak.getSoundType().getHitSound(), SoundSource.NEUTRAL, .25f, 1); if (destroyProgress >= 10) { onBlockBroken(stateToBreak); @@ -140,20 +140,20 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity { public void onBlockBroken(BlockState stateToBreak) { 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); + BlockEntity tileentity = stateToBreak.hasTileEntity() ? level.getBlockEntity(breakingPos) : null; + Vec3 vec = VecHelper.offsetRandomly(VecHelper.getCenterOf(breakingPos), level.random, .125f); - Block.getDrops(stateToBreak, (ServerWorld) level, breakingPos, tileentity).forEach((stack) -> { + Block.getDrops(stateToBreak, (ServerLevel) 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); + itementity.setDeltaMovement(Vec3.ZERO); level.addFreshEntity(itementity); } }); - if (level instanceof ServerWorld) - stateToBreak.spawnAfterBreak((ServerWorld) level, breakingPos, ItemStack.EMPTY); + if (level instanceof ServerLevel) + stateToBreak.spawnAfterBreak((ServerLevel) level, breakingPos, ItemStack.EMPTY); level.setBlock(breakingPos, FluidState.createLegacyBlock(), 3); } 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 b23ce8153..e9ded461b 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 @@ -5,21 +5,21 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.foundation.utility.BlockHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.FallingBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.DamageSource; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.FallingBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.player.Player; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; public class BlockBreakingMovementBehaviour extends MovementBehaviour { @@ -32,7 +32,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { @Override public void visitNewPosition(MovementContext context, BlockPos pos) { - World world = context.world; + Level world = context.world; BlockState stateVisited = world.getBlockState(pos); if (!stateVisited.isRedstoneConductor(world, pos)) @@ -42,31 +42,31 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { if (!canBreak(world, pos, stateVisited)) return; - context.data.put("BreakingPos", NBTUtil.writeBlockPos(pos)); + context.data.put("BreakingPos", NbtUtils.writeBlockPos(pos)); context.stall = true; } - public void damageEntities(MovementContext context, BlockPos pos, World world) { + public void damageEntities(MovementContext context, BlockPos pos, Level world) { DamageSource damageSource = getDamageSource(); if (damageSource == null && !throwsEntities()) return; - Entities: for (Entity entity : world.getEntitiesOfClass(Entity.class, new AxisAlignedBB(pos))) { + Entities: for (Entity entity : world.getEntitiesOfClass(Entity.class, new AABB(pos))) { if (entity instanceof ItemEntity) continue; if (entity instanceof AbstractContraptionEntity) continue; - if (entity instanceof AbstractMinecartEntity) + if (entity instanceof AbstractMinecart) for (Entity passenger : entity.getIndirectPassengers()) if (passenger instanceof AbstractContraptionEntity && ((AbstractContraptionEntity) passenger).getContraption() == context.contraption) continue Entities; if (damageSource != null && !world.isClientSide) { - float damage = (float) MathHelper.clamp(6 * Math.pow(context.relativeMotion.length(), 0.4) + 1, 2, 10); + float damage = (float) Mth.clamp(6 * Math.pow(context.relativeMotion.length(), 0.4) + 1, 2, 10); entity.hurt(damageSource, damage); } - if (throwsEntities() && (world.isClientSide == (entity instanceof PlayerEntity))) { - Vector3d motionBoost = context.motion.add(0, context.motion.length() / 4f, 0); + if (throwsEntities() && (world.isClientSide == (entity instanceof Player))) { + Vec3 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)); @@ -87,15 +87,15 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { @Override public void stopMoving(MovementContext context) { - CompoundNBT data = context.data; + CompoundTag data = context.data; if (context.world.isClientSide) return; if (!data.contains("BreakingPos")) return; - World world = context.world; + Level world = context.world; int id = data.getInt("BreakerId"); - BlockPos breakingPos = NBTUtil.readBlockPos(data.getCompound("BreakingPos")); + BlockPos breakingPos = NbtUtils.readBlockPos(data.getCompound("BreakingPos")); data.remove("Progress"); data.remove("TicksUntilNextProgress"); @@ -109,7 +109,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { public void tick(MovementContext context) { tickBreaker(context); - CompoundNBT data = context.data; + CompoundTag data = context.data; if (!data.contains("WaitingTicks")) return; @@ -120,7 +120,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { return; } - BlockPos pos = NBTUtil.readBlockPos(data.getCompound("LastPos")); + BlockPos pos = NbtUtils.readBlockPos(data.getCompound("LastPos")); data.remove("WaitingTicks"); data.remove("LastPos"); context.stall = false; @@ -128,12 +128,12 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { } public void tickBreaker(MovementContext context) { - CompoundNBT data = context.data; + CompoundTag data = context.data; if (context.world.isClientSide) return; if (!data.contains("BreakingPos")) return; - if (context.relativeMotion.equals(Vector3d.ZERO)) { + if (context.relativeMotion.equals(Vec3.ZERO)) { context.stall = false; return; } @@ -144,8 +144,8 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { return; } - World world = context.world; - BlockPos breakingPos = NBTUtil.readBlockPos(data.getCompound("BreakingPos")); + Level world = context.world; + BlockPos breakingPos = NbtUtils.readBlockPos(data.getCompound("BreakingPos")); int destroyProgress = data.getInt("Progress"); int id = data.getInt("BreakerId"); BlockState stateToBreak = world.getBlockState(breakingPos); @@ -163,9 +163,9 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { return; } - float breakSpeed = MathHelper.clamp(Math.abs(context.getAnimationSpeed()) / 500f, 1 / 128f, 16f); - destroyProgress += MathHelper.clamp((int) (breakSpeed / blockHardness), 1, 10 - destroyProgress); - world.playSound(null, breakingPos, stateToBreak.getSoundType().getHitSound(), SoundCategory.NEUTRAL, .25f, 1); + float breakSpeed = Mth.clamp(Math.abs(context.getAnimationSpeed()) / 500f, 1 / 128f, 16f); + destroyProgress += Mth.clamp((int) (breakSpeed / blockHardness), 1, 10 - destroyProgress); + world.playSound(null, breakingPos, stateToBreak.getSoundType().getHitSound(), SoundSource.NEUTRAL, .25f, 1); if (destroyProgress >= 10) { world.destroyBlockProgress(id, breakingPos, -1); @@ -200,7 +200,7 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { return true; } - public boolean canBreak(World world, BlockPos breakingPos, BlockState state) { + public boolean canBreak(Level world, BlockPos breakingPos, BlockState state) { float blockHardness = state.getDestroySpeed(world, breakingPos); return BlockBreakingKineticTileEntity.isBreakable(state, blockHardness); } @@ -210,9 +210,9 @@ public class BlockBreakingMovementBehaviour extends MovementBehaviour { if (!(brokenState.getBlock() instanceof FallingBlock)) return; - CompoundNBT data = context.data; + CompoundTag data = context.data; data.putInt("WaitingTicks", 10); - data.put("LastPos", NBTUtil.writeBlockPos(pos)); + data.put("LastPos", NbtUtils.writeBlockPos(pos)); context.stall = true; } 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 39ac14bce..4388e0baa 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 @@ -5,8 +5,8 @@ import java.util.Random; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; -import net.minecraft.block.CampfireBlock; -import net.minecraft.particles.ParticleTypes; +import net.minecraft.world.level.block.CampfireBlock; +import net.minecraft.core.particles.ParticleTypes; public class CampfireMovementBehaviour extends MovementBehaviour { @Override 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 88b0e00b6..85f1260e7 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 @@ -11,7 +11,7 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; import net.minecraft.util.math.vector.Quaternion; public class DrillActorInstance extends ActorInstance { 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 0e0a95fba..8b896aa63 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 @@ -8,24 +8,26 @@ import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; import com.simibubi.create.foundation.block.ITE; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -42,10 +44,10 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE { if (te.getSpeed() == 0) @@ -55,17 +57,17 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE type) { + public DrillTileEntity(BlockEntityType type) { super(type); } 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 00dab9822..b46d7601a 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 @@ -2,8 +2,15 @@ package com.simibubi.create.content.contraptions.components.actors; import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; -import com.jozufozu.flywheel.backend.material.Material; +import com.net.minimport ModelData; import com.jozufozu.flywheel.backend.material.MaterialManager; +import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.Vec3; + +ecraft.world.level.block.state.properties.BlockStatePropertiest com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; @@ -23,7 +30,7 @@ import net.minecraft.util.math.vector.Vector3d; public class HarvesterActorInstance extends ActorInstance { static double oneOverRadius = 16.0 / 6.5; static float originOffset = 1 / 16f; - static Vector3d rotOffset = new Vector3d(0.5f, -2 * originOffset + 0.5f, originOffset + 0.5f); + static Vec3 rotOffset = new Vec3(0.5f, -2 * originOffset + 0.5f, originOffset + 0.5f); ModelData harvester; 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..5df20c54d 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 @@ -2,9 +2,11 @@ package com.simibubi.create.content.contraptions.components.actors; import com.simibubi.create.AllTileEntities; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.BlockGetter; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class HarvesterBlock extends AttachedActorBlock { @@ -18,7 +20,7 @@ public class HarvesterBlock extends AttachedActorBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return new HarvesterTileEntity(AllTileEntities.HARVESTER.get()); } 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 0a83a4ba8..e7a623870 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 @@ -2,10 +2,40 @@ package com.simibubi.create.content.contraptions.components.actors; import static net.minecraft.block.HorizontalBlock.FACING; +import javanet.minecrafimport com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.material.MaterialManager; +import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; +import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; +import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.utility.BlockHelper; +import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import javax.annotation.Nullable; - +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.core.BlockPos; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.CocoaBlock; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.GrowingPlantBlock; +import net.minecraft.world.level.block.SugarCaneBlock; +import net.minecraft.world.level.block.SweetBerryBushBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.common.IPlantable; import org.apache.commons.lang3.mutable.MutableBoolean; +t.world.level.block.HorizontalDirectionalBlockg.apache.commons.lang3.mutable.MutableBoolean; + import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; @@ -59,22 +89,22 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { @Override public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - ContraptionMatrices matrices, IRenderTypeBuffer buffers) { + ContraptionMatrices matrices, MultiBufferSource buffers) { if (!Backend.getInstance() .canUseInstancing()) HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers); } @Override - public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.atLowerCornerOf(context.state.getValue(FACING) + public Vec3 getActiveAreaOffset(MovementContext context) { + return Vec3.atLowerCornerOf(context.state.getValue(FACING) .getNormal()) .scale(.45); } @Override public void visitNewPosition(MovementContext context, BlockPos pos) { - World world = context.world; + Level world = context.world; BlockState stateVisited = world.getBlockState(pos); boolean notCropButCuttable = false; @@ -111,12 +141,12 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { world.setBlockAndUpdate(pos, cutCrop(world, pos, stateVisited)); } - private boolean isValidCrop(World world, BlockPos pos, BlockState state) { + private boolean isValidCrop(Level world, BlockPos pos, BlockState state) { boolean harvestPartial = AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get(); boolean replant = AllConfigs.SERVER.kinetics.harvesterReplants.get(); - if (state.getBlock() instanceof CropsBlock) { - CropsBlock crop = (CropsBlock) state.getBlock(); + if (state.getBlock() instanceof CropBlock) { + CropBlock crop = (CropBlock) state.getBlock(); if (harvestPartial) return state.getValue(crop.getAgeProperty()) != 0 || !replant; return crop.isMaxAge(state); @@ -145,8 +175,8 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { return false; } - private boolean isValidOther(World world, BlockPos pos, BlockState state) { - if (state.getBlock() instanceof CropsBlock) + private boolean isValidOther(Level world, BlockPos pos, BlockState state) { + if (state.getBlock() instanceof CropBlock) return false; if (state.getBlock() instanceof SugarCaneBlock) return true; @@ -156,7 +186,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { if (state.getCollisionShape(world, pos) .isEmpty() || state.getBlock() instanceof CocoaBlock) { - if (state.getBlock() instanceof AbstractPlantBlock) + if (state.getBlock() instanceof GrowingPlantBlock) return true; for (Property property : state.getProperties()) { @@ -175,7 +205,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { return false; } - private BlockState cutCrop(World world, BlockPos pos, BlockState state) { + private BlockState cutCrop(Level world, BlockPos pos, BlockState state) { if (!AllConfigs.SERVER.kinetics.harvesterReplants.get()) { if (state.getFluidState() .isEmpty()) @@ -185,14 +215,14 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { } Block block = state.getBlock(); - if (block instanceof CropsBlock) { - CropsBlock crop = (CropsBlock) block; + if (block instanceof CropBlock) { + CropBlock crop = (CropBlock) block; return crop.getStateForAge(0); } if (block == Blocks.SWEET_BERRY_BUSH) { return state.setValue(BlockStateProperties.AGE_3, Integer.valueOf(1)); } - if (block == Blocks.SUGAR_CANE || block instanceof AbstractPlantBlock) { + if (block == Blocks.SUGAR_CANE || block instanceof GrowingPlantBlock) { if (state.getFluidState() .isEmpty()) return Blocks.AIR.defaultBlockState(); 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 0aac5f333..fc4ebdae3 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 @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors; import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.net.minimport com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; @@ -14,6 +14,26 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; + +ecraft.world.level.block.state.properties.BlockStatePropertiesbubi.create.AllBlockPartials; +import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; +import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; +import com.simibubi.create.foundation.utility.AngleHelper; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -26,12 +46,12 @@ import net.minecraft.world.World; public class HarvesterRenderer extends SafeTileEntityRenderer { - public HarvesterRenderer(TileEntityRendererDispatcher dispatcher) { + public HarvesterRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(HarvesterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(HarvesterTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { BlockState blockState = te.getBlockState(); SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.HARVESTER_BLADE, blockState); @@ -42,7 +62,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer type) { + public HarvesterTileEntity(BlockEntityType type) { super(type); } @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { + public AABB getRenderBoundingBox() { return RENDER_BOX.move(worldPosition); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughBlock.java index 31a5ffad3..a0758cc5f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughBlock.java @@ -4,9 +4,11 @@ import java.util.UUID; import com.mojang.authlib.GameProfile; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.util.FakePlayer; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class PloughBlock extends AttachedActorBlock { public PloughBlock(Properties p_i48377_1_) { @@ -21,7 +23,7 @@ public class PloughBlock extends AttachedActorBlock { public static final GameProfile PLOUGH_PROFILE = new GameProfile(UUID.fromString("9e2faded-eeee-4ec2-c314-dad129ae971d"), "Plough"); - public PloughFakePlayer(ServerWorld world) { + public PloughFakePlayer(ServerLevel world) { super(world, PLOUGH_PROFILE); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughMovementBehaviour.java index 8c5603afb..cef84a1f9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughMovementBehaviour.java @@ -2,7 +2,30 @@ package com.simibubi.create.content.contraptions.components.actors; import static net.minecraft.block.HorizontalBlock.FACING; -import com.simibubi.create.content.contraptions.components.actors.PloughBlock.PloughFakePlayer; +import com.net.minecrafimport com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.foundation.utility.VecHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.BubbleColumnBlock; +import net.minecraft.world.level.block.FarmBlock; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.world.phys.Vec3; + +t.world.level.block.HorizontalDirectionalBlocks.components.actors.PloughBlock.PloughFakePlayer; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.foundation.utility.VecHelper; @@ -38,31 +61,31 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour { @Override public void visitNewPosition(MovementContext context, BlockPos pos) { super.visitNewPosition(context, pos); - World world = context.world; + Level world = context.world; if (world.isClientSide) return; BlockPos below = pos.below(); if (!world.isLoaded(below)) return; - Vector3d vec = VecHelper.getCenterOf(pos); + Vec3 vec = VecHelper.getCenterOf(pos); PloughFakePlayer player = getPlayer(context); if (player == null) return; - BlockRayTraceResult ray = world - .clip(new RayTraceContext(vec, vec.add(0, -1, 0), BlockMode.OUTLINE, FluidMode.NONE, player)); + BlockHitResult ray = world + .clip(new ClipContext(vec, vec.add(0, -1, 0), Block.OUTLINE, Fluid.NONE, player)); if (ray.getType() != Type.BLOCK) return; - ItemUseContext ctx = new ItemUseContext(player, Hand.MAIN_HAND, ray); + UseOnContext ctx = new UseOnContext(player, InteractionHand.MAIN_HAND, ray); new ItemStack(Items.DIAMOND_HOE).useOn(ctx); } @Override - public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.atLowerCornerOf(context.state.getValue(FACING) + public Vec3 getActiveAreaOffset(MovementContext context) { + return Vec3.atLowerCornerOf(context.state.getValue(FACING) .getNormal()).scale(.45); } @@ -72,11 +95,11 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour { } @Override - public boolean canBreak(World world, BlockPos breakingPos, BlockState state) { + public boolean canBreak(Level world, BlockPos breakingPos, BlockState state) { if (world.getBlockState(breakingPos.below()) - .getBlock() instanceof FarmlandBlock) + .getBlock() instanceof FarmBlock) return false; - if (state.getBlock() instanceof FlowingFluidBlock) + if (state.getBlock() instanceof LiquidBlock) return false; if (state.getBlock() instanceof BubbleColumnBlock) return false; @@ -88,12 +111,12 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour { protected void onBlockBroken(MovementContext context, BlockPos pos, BlockState brokenState) { super.onBlockBroken(context, pos, brokenState); - if (brokenState.getBlock() == Blocks.SNOW && context.world instanceof ServerWorld) { - ServerWorld world = (ServerWorld) context.world; - brokenState.getDrops(new LootContext.Builder(world).withParameter(LootParameters.BLOCK_STATE, brokenState) - .withParameter(LootParameters.ORIGIN, Vector3d.atCenterOf(pos)) - .withParameter(LootParameters.THIS_ENTITY, getPlayer(context)) - .withParameter(LootParameters.TOOL, new ItemStack(Items.IRON_SHOVEL))) + if (brokenState.getBlock() == Blocks.SNOW && context.world instanceof ServerLevel) { + ServerLevel world = (ServerLevel) context.world; + brokenState.getDrops(new LootContext.Builder(world).withParameter(LootContextParams.BLOCK_STATE, brokenState) + .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos)) + .withParameter(LootContextParams.THIS_ENTITY, getPlayer(context)) + .withParameter(LootContextParams.TOOL, new ItemStack(Items.IRON_SHOVEL))) .forEach(s -> dropItem(context, s)); } } @@ -107,8 +130,8 @@ 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.setItemInHand(Hand.MAIN_HAND, new ItemStack(Items.DIAMOND_HOE)); + PloughFakePlayer player = new PloughFakePlayer((ServerLevel) context.world); + player.setItemInHand(InteractionHand.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..f2936deef 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 @@ -2,19 +2,21 @@ package com.simibubi.create.content.contraptions.components.actors; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; 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; - public PortableFluidInterfaceTileEntity(TileEntityType tileEntityTypeIn) { + public PortableFluidInterfaceTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); capability = createEmptyHandler(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableItemInterfaceTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableItemInterfaceTileEntity.java index 227c42dee..6d3200a61 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableItemInterfaceTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableItemInterfaceTileEntity.java @@ -3,9 +3,9 @@ package com.simibubi.create.content.contraptions.components.actors; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.foundation.item.ItemHandlerWrapper; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandlerModifiable; @@ -15,7 +15,7 @@ public class PortableItemInterfaceTileEntity extends PortableStorageInterfaceTil protected LazyOptional capability; - public PortableItemInterfaceTileEntity(TileEntityType tileEntityTypeIn) { + public PortableItemInterfaceTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); capability = LazyOptional.empty(); } 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 147ae09bf..aa8ff91d6 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 @@ -8,15 +8,17 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -44,25 +46,25 @@ public class PortableStorageInterfaceBlock extends WrenchableDirectionalBlock } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return (fluids ? AllTileEntities.PORTABLE_FLUID_INTERFACE : AllTileEntities.PORTABLE_STORAGE_INTERFACE) .create(); } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { withTileEntityDo(world, pos, PortableStorageInterfaceTileEntity::neighbourChanged); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { return defaultBlockState().setValue(FACING, context.getNearestLookingDirection() .getOpposite()); } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.PORTABLE_STORAGE_INTERFACE.get(state.getValue(FACING)); } @@ -72,7 +74,7 @@ public class PortableStorageInterfaceBlock extends WrenchableDirectionalBlock } @Override - public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { + public int getAnalogOutputSignal(BlockState blockState, Level 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 c0d2a2a19..f0b0b65b5 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 @@ -8,14 +8,14 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -25,15 +25,15 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { static final String _clientPrevPos_ = "ClientPrevPos"; @Override - public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.atLowerCornerOf(context.state.getValue(PortableStorageInterfaceBlock.FACING) + public Vec3 getActiveAreaOffset(MovementContext context) { + return Vec3.atLowerCornerOf(context.state.getValue(PortableStorageInterfaceBlock.FACING) .getNormal()).scale(1.85f); } @Override @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - ContraptionMatrices matrices, IRenderTypeBuffer buffer) { + ContraptionMatrices matrices, MultiBufferSource buffer) { PortableStorageInterfaceRenderer.renderInContraption(context, renderWorld, matrices, buffer); } @@ -57,15 +57,15 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { if ((psi.isTransferring() || psi.isPowered()) && !context.world.isClientSide) return false; - context.data.put(_workingPos_, NBTUtil.writeBlockPos(psi.getBlockPos())); + context.data.put(_workingPos_, NbtUtils.writeBlockPos(psi.getBlockPos())); if (!context.world.isClientSide) { - Vector3d diff = VecHelper.getCenterOf(psi.getBlockPos()) + Vec3 diff = VecHelper.getCenterOf(psi.getBlockPos()) .subtract(context.position); - diff = VecHelper.project(diff, Vector3d.atLowerCornerOf(currentFacing.getNormal())); + diff = VecHelper.project(diff, Vec3.atLowerCornerOf(currentFacing.getNormal())); float distance = (float) (diff.length() + 1.85f - 1); psi.startTransferringTo(context.contraption, distance); } else { - context.data.put(_clientPrevPos_, NBTUtil.writeBlockPos(pos)); + context.data.put(_clientPrevPos_, NbtUtils.writeBlockPos(pos)); } return true; } @@ -77,7 +77,7 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { if (stalled && !context.data.contains(_workingPos_)) { BlockPos pos = new BlockPos(context.position); if (!context.data.contains(_clientPrevPos_) - || !NBTUtil.readBlockPos(context.data.getCompound(_clientPrevPos_)) + || !NbtUtils.readBlockPos(context.data.getCompound(_clientPrevPos_)) .equals(pos)) findInterface(context, pos); } @@ -89,7 +89,7 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { if (!context.data.contains(_workingPos_)) return; - BlockPos pos = NBTUtil.readBlockPos(context.data.getCompound(_workingPos_)); + BlockPos pos = NbtUtils.readBlockPos(context.data.getCompound(_workingPos_)); Optional currentFacingIfValid = getCurrentFacingIfValid(context); if (!currentFacingIfValid.isPresent()) return; @@ -113,7 +113,7 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { context.stall = false; } - private PortableStorageInterfaceTileEntity findStationaryInterface(World world, BlockPos pos, BlockState state, + private PortableStorageInterfaceTileEntity findStationaryInterface(Level world, BlockPos pos, BlockState state, Direction facing) { for (int i = 0; i < 2; i++) { PortableStorageInterfaceTileEntity interfaceAt = @@ -125,9 +125,9 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { return null; } - private PortableStorageInterfaceTileEntity getStationaryInterfaceAt(World world, BlockPos pos, BlockState state, + private PortableStorageInterfaceTileEntity getStationaryInterfaceAt(Level world, BlockPos pos, BlockState state, Direction facing) { - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (!(te instanceof PortableStorageInterfaceTileEntity)) return null; BlockState blockState = world.getBlockState(pos); @@ -139,11 +139,11 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour { } private Optional getCurrentFacingIfValid(MovementContext context) { - Vector3d directionVec = Vector3d.atLowerCornerOf(context.state.getValue(PortableStorageInterfaceBlock.FACING) + Vec3 directionVec = Vec3.atLowerCornerOf(context.state.getValue(PortableStorageInterfaceBlock.FACING) .getNormal()); directionVec = context.rotation.apply(directionVec); Direction facingFromVector = Direction.getNearest(directionVec.x, directionVec.y, directionVec.z); - if (directionVec.distanceTo(Vector3d.atLowerCornerOf(facingFromVector.getNormal())) > 1 / 2f) + if (directionVec.distanceTo(Vec3.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 6bdabeae9..ba3d7a2c3 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 @@ -3,8 +3,8 @@ package com.simibubi.create.content.contraptions.components.actors; import java.util.function.Consumer; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; @@ -17,36 +17,36 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer { - public PortableStorageInterfaceRenderer(TileEntityRendererDispatcher dispatcher) { + public PortableStorageInterfaceRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(PortableStorageInterfaceTileEntity te, float partialTicks, MatrixStack ms, - IRenderTypeBuffer buffer, int light, int overlay) { + protected void renderSafe(PortableStorageInterfaceTileEntity te, float partialTicks, PoseStack ms, + MultiBufferSource buffer, int light, int overlay) { BlockState blockState = te.getBlockState(); float progress = te.getExtensionDistance(partialTicks); - IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); render(blockState, te.isConnected(), progress, null, sbb -> sbb.light(light) .renderInto(ms, vb)); } public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - ContraptionMatrices matrices, IRenderTypeBuffer buffer) { + ContraptionMatrices matrices, MultiBufferSource buffer) { BlockState blockState = context.state; PortableStorageInterfaceTileEntity te = getTargetPSI(context); - IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); float renderPartialTicks = AnimationTickHolder.getPartialTicks(); float progress = 0; @@ -62,7 +62,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer drawCallback) { + PoseStack local, Consumer drawCallback) { SuperByteBuffer middle = PartialBufferer.get(getMiddleForState(blockState, lit), blockState); SuperByteBuffer top = PartialBufferer.get(getTopForState(blockState), blockState); @@ -93,8 +93,8 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer tileEntityTypeIn) { + public PortableStorageInterfaceTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); transferTimer = 0; connectionAnimation = LerpedFloat.linear() @@ -72,9 +72,9 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity if (isConnected) progress = 1; else if (transferTimer >= timeUnit * 3) - progress = MathHelper.lerp((transferTimer - timeUnit * 3) / (float) timeUnit, 1, 0); + progress = Mth.lerp((transferTimer - timeUnit * 3) / (float) timeUnit, 1, 0); else if (transferTimer < timeUnit) - progress = MathHelper.lerp(transferTimer / (float) timeUnit, 0, 1); + progress = Mth.lerp(transferTimer / (float) timeUnit, 0, 1); connectionAnimation.setValue(progress); } @@ -85,7 +85,7 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); transferTimer = compound.getInt("Timer"); distance = compound.getFloat("Distance"); @@ -93,7 +93,7 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); compound.putInt("Timer", transferTimer); compound.putFloat("Distance", distance); @@ -112,11 +112,11 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity return powered; } - protected AxisAlignedBB cachedBoundingBox; + protected AABB cachedBoundingBox; @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { + public AABB getRenderBoundingBox() { if (cachedBoundingBox == null) { cachedBoundingBox = super.getRenderBoundingBox().inflate(2); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index d86291925..abed590bf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -12,16 +12,16 @@ import com.simibubi.create.foundation.utility.TreeCutter; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; import net.minecraft.tags.BlockTags; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.ItemHandlerHelper; @@ -35,14 +35,14 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { } @Override - public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.atLowerCornerOf(context.state.getValue(SawBlock.FACING).getNormal()).scale(.65f); + public Vec3 getActiveAreaOffset(MovementContext context) { + return Vec3.atLowerCornerOf(context.state.getValue(SawBlock.FACING).getNormal()).scale(.65f); } @Override public void visitNewPosition(MovementContext context, BlockPos pos) { super.visitNewPosition(context, pos); - Vector3d facingVec = Vector3d.atLowerCornerOf(context.state.getValue(SawBlock.FACING).getNormal()); + Vec3 facingVec = Vec3.atLowerCornerOf(context.state.getValue(SawBlock.FACING).getNormal()); facingVec = context.rotation.apply(facingVec); Direction closestToFacing = Direction.getNearest(facingVec.x, facingVec.y, facingVec.z); @@ -53,7 +53,7 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { } @Override - public boolean canBreak(World world, BlockPos breakingPos, BlockState state) { + public boolean canBreak(Level world, BlockPos breakingPos, BlockState state) { return super.canBreak(world, breakingPos, state) && SawTileEntity.isSawable(state); } @@ -76,8 +76,8 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { if (remainder.isEmpty()) return; - World world = context.world; - Vector3d dropPos = VecHelper.getCenterOf(pos); + Level world = context.world; + Vec3 dropPos = VecHelper.getCenterOf(pos); float distance = (float) dropPos.distanceTo(context.position); ItemEntity entity = new ItemEntity(world, dropPos.x, dropPos.y, dropPos.z, remainder); entity.setDeltaMovement(context.relativeMotion.scale(distance / 20f)); @@ -87,7 +87,7 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { @Override @OnlyIn(value = Dist.CLIENT) public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - ContraptionMatrices matrices, IRenderTypeBuffer buffer) { + ContraptionMatrices matrices, MultiBufferSource buffer) { SawRenderer.renderInContraption(context, renderWorld, matrices, buffer); } 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 19ec6e276..f6a43579a 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 @@ -10,27 +10,29 @@ import com.simibubi.create.AllShapes; import com.simibubi.create.foundation.utility.BlockHelper; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.pathfinding.PathNodeType; -import net.minecraft.pathfinding.PathType; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.pathfinder.BlockPathTypes; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.NonNullList; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -46,21 +48,21 @@ public class SeatBlock extends Block { } @Override - public void fillItemCategory(ItemGroup group, NonNullList p_149666_2_) { - if (group != ItemGroup.TAB_SEARCH && !inCreativeTab) + public void fillItemCategory(CreativeModeTab group, NonNullList p_149666_2_) { + if (group != CreativeModeTab.TAB_SEARCH && !inCreativeTab) return; super.fillItemCategory(group, p_149666_2_); } @Override - public void fallOn(World p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { + public void fallOn(Level 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 updateEntityAfterFallOn(IBlockReader reader, Entity entity) { + public void updateEntityAfterFallOn(BlockGetter reader, Entity entity) { BlockPos pos = entity.blockPosition(); - if (entity instanceof PlayerEntity || !(entity instanceof LivingEntity) || !canBePickedUp(entity) || isSeatOccupied(entity.level, pos)) { + if (entity instanceof Player || !(entity instanceof LivingEntity) || !canBePickedUp(entity) || isSeatOccupied(entity.level, pos)) { super.updateEntityAfterFallOn(reader, entity); return; } @@ -71,68 +73,68 @@ public class SeatBlock extends Block { } @Override - public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, - @Nullable MobEntity entity) { - return PathNodeType.RAIL; + public BlockPathTypes getAiPathNodeType(BlockState state, BlockGetter world, BlockPos pos, + @Nullable Mob entity) { + return BlockPathTypes.RAIL; } @Override - public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return AllShapes.SEAT; } @Override - public VoxelShape getCollisionShape(BlockState p_220071_1_, IBlockReader p_220071_2_, BlockPos p_220071_3_, - ISelectionContext p_220071_4_) { + public VoxelShape getCollisionShape(BlockState p_220071_1_, BlockGetter p_220071_2_, BlockPos p_220071_3_, + CollisionContext p_220071_4_) { return AllShapes.SEAT_COLLISION; } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult p_225533_6_) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult p_225533_6_) { if (player.isShiftKeyDown()) - return ActionResultType.PASS; + return InteractionResult.PASS; ItemStack heldItem = player.getItemInHand(hand); DyeColor color = DyeColor.getColor(heldItem); if (color != null && color != this.color) { if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; BlockState newState = BlockHelper.copyProperties(state, AllBlocks.SEATS.get(color).getDefaultState()); world.setBlockAndUpdate(pos, newState); - return ActionResultType.sidedSuccess(world.isClientSide); + return InteractionResult.sidedSuccess(world.isClientSide); } - List seats = world.getEntitiesOfClass(SeatEntity.class, new AxisAlignedBB(pos)); + List seats = world.getEntitiesOfClass(SeatEntity.class, new AABB(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 (!passengers.isEmpty() && passengers.get(0) instanceof Player) + return InteractionResult.PASS; if (!world.isClientSide) { seatEntity.ejectPassengers(); player.startRiding(seatEntity); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; sitDown(world, pos, player); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - public static boolean isSeatOccupied(World world, BlockPos pos) { - return !world.getEntitiesOfClass(SeatEntity.class, new AxisAlignedBB(pos)) + public static boolean isSeatOccupied(Level world, BlockPos pos) { + return !world.getEntitiesOfClass(SeatEntity.class, new AABB(pos)) .isEmpty(); } public static boolean canBePickedUp(Entity passenger) { - return !(passenger instanceof PlayerEntity) && (passenger instanceof LivingEntity); + return !(passenger instanceof Player) && (passenger instanceof LivingEntity); } - public static void sitDown(World world, BlockPos pos, Entity entity) { + public static void sitDown(Level world, BlockPos pos, Entity entity) { if (world.isClientSide) return; SeatEntity seat = new SeatEntity(world, pos); @@ -146,7 +148,7 @@ public class SeatBlock extends Block { } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 9777aedd8..eb9221ea1 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 @@ -2,30 +2,30 @@ package com.simibubi.create.content.contraptions.components.actors; import com.simibubi.create.AllEntityTypes; -import net.minecraft.client.renderer.culling.ClippingHelper; +import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.IPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.network.NetworkHooks; public class SeatEntity extends Entity implements IEntityAdditionalSpawnData { - public SeatEntity(EntityType p_i48580_1_, World p_i48580_2_) { + public SeatEntity(EntityType p_i48580_1_, Level p_i48580_2_) { super(p_i48580_1_, p_i48580_2_); } - public SeatEntity(World world, BlockPos pos) { + public SeatEntity(Level world, BlockPos pos) { this(AllEntityTypes.SEAT.get(), world); noPhysics = true; } @@ -37,20 +37,20 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData { } @Override - public AxisAlignedBB getBoundingBox() { + public AABB getBoundingBox() { return super.getBoundingBox(); } @Override 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()); + AABB bb = getBoundingBox(); + Vec3 diff = new Vec3(x, y, z).subtract(bb.getCenter()); setBoundingBox(bb.move(diff)); } @Override - public void setDeltaMovement(Vector3d p_213317_1_) {} + public void setDeltaMovement(Vec3 p_213317_1_) {} @Override public void tick() { @@ -72,7 +72,7 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData { @Override protected void removePassenger(Entity entity) { super.removePassenger(entity); - Vector3d pos = entity.position(); + Vec3 pos = entity.position(); entity.setPos(pos.x, pos.y + 0.85f, pos.z); } @@ -80,24 +80,24 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData { protected void defineSynchedData() {} @Override - protected void readAdditionalSaveData(CompoundNBT p_70037_1_) {} + protected void readAdditionalSaveData(CompoundTag p_70037_1_) {} @Override - protected void addAdditionalSaveData(CompoundNBT p_213281_1_) {} + protected void addAdditionalSaveData(CompoundTag p_213281_1_) {} @Override - public IPacket getAddEntityPacket() { + public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } public static class Render extends EntityRenderer { - public Render(EntityRendererManager p_i46179_1_) { + public Render(EntityRenderDispatcher p_i46179_1_) { super(p_i46179_1_); } @Override - public boolean shouldRender(SeatEntity p_225626_1_, ClippingHelper p_225626_2_, double p_225626_3_, double p_225626_5_, double p_225626_7_) { + public boolean shouldRender(SeatEntity p_225626_1_, Frustum p_225626_2_, double p_225626_3_, double p_225626_5_, double p_225626_7_) { return false; } @@ -108,8 +108,8 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData { } @Override - public void writeSpawnData(PacketBuffer buffer) {} + public void writeSpawnData(FriendlyByteBuf buffer) {} @Override - public void readSpawnData(PacketBuffer additionalData) {} + public void readSpawnData(FriendlyByteBuf additionalData) {} } 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 84776eb68..6cfbe49ec 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 @@ -9,13 +9,13 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.entity.Entity; -import net.minecraft.state.properties.SlabType; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.state.properties.SlabType; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class SeatMovementBehaviour extends MovementBehaviour { @@ -60,7 +60,7 @@ public class SeatMovementBehaviour extends MovementBehaviour { } if (toDismount != null) { toDismount.stopRiding(); - Vector3d position = VecHelper.getCenterOf(pos) + Vec3 position = VecHelper.getCenterOf(pos) .add(0, slab ? .5f : 1f, 0); toDismount.teleportTo(position.x, position.y, position.z); toDismount.getPersistentData() @@ -73,7 +73,7 @@ public class SeatMovementBehaviour extends MovementBehaviour { return; List nearbyEntities = context.world.getEntitiesOfClass(Entity.class, - new AxisAlignedBB(pos).deflate(1 / 16f), SeatBlock::canBePickedUp); + new AABB(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 d7660c434..abd6de618 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 @@ -5,17 +5,17 @@ import javax.annotation.Nullable; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockState; -import net.minecraft.dispenser.IBlockSource; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockSource; import net.minecraft.server.MinecraftServer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; @MethodsReturnNonnullByDefault -public class ContraptionBlockSource implements IBlockSource { +public class ContraptionBlockSource implements BlockSource { private final BlockPos pos; private final MovementContext context; private final Direction overrideFacing; @@ -59,13 +59,13 @@ public class ContraptionBlockSource implements IBlockSource { @Override @Nullable - public T getEntity() { + public T getEntity() { return null; } @Override @Nullable - public ServerWorld getLevel() { + public ServerLevel getLevel() { MinecraftServer server = context.world.getServer(); 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 a423fb7e7..41b9b1048 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 @@ -7,17 +7,17 @@ import javax.annotation.ParametersAreNonnullByDefault; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Blocks; -import net.minecraft.block.DispenserBlock; -import net.minecraft.dispenser.DefaultDispenseItemBehavior; -import net.minecraft.dispenser.IDispenseItemBehavior; -import net.minecraft.dispenser.ProjectileDispenseBehavior; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DispenserBlock; +import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; +import net.minecraft.core.dispenser.DispenseItemBehavior; +import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class DispenserMovementBehaviour extends DropperMovementBehaviour { private static final HashMap MOVED_DISPENSE_ITEM_BEHAVIOURS = new HashMap<>(); @@ -59,15 +59,15 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { return; } - 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); + DispenseItemBehavior idispenseitembehavior = BEHAVIOUR_LOOKUP.getDispenseMethod(itemstack); + if (idispenseitembehavior instanceof AbstractProjectileDispenseBehavior) { // Projectile behaviours can be converted most of the time + IMovedDispenseItemBehaviour iMovedDispenseItemBehaviour = MovedProjectileDispenserBehaviour.of((AbstractProjectileDispenseBehavior) idispenseitembehavior); setItemStackAt(location, iMovedDispenseItemBehaviour.dispense(itemstack, context, pos), context); MOVED_PROJECTILE_DISPENSE_BEHAVIOURS.put(itemstack.getItem(), iMovedDispenseItemBehaviour); // buffer conversion if successful return; } - Vector3d facingVec = Vector3d.atLowerCornerOf(context.state.getValue(DispenserBlock.FACING).getNormal()); + Vec3 facingVec = Vec3.atLowerCornerOf(context.state.getValue(DispenserBlock.FACING).getNormal()); facingVec = context.rotation.apply(facingVec); facingVec.normalize(); Direction clostestFacing = Direction.getNearest(facingVec.x, facingVec.y, facingVec.z); @@ -89,10 +89,10 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { @MethodsReturnNonnullByDefault private static class DispenserLookup extends DispenserBlock { protected DispenserLookup() { - super(AbstractBlock.Properties.copy(Blocks.DISPENSER)); + super(BlockBehaviour.Properties.copy(Blocks.DISPENSER)); } - public IDispenseItemBehavior getDispenseMethod(ItemStack itemStack) { + public DispenseItemBehavior 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 e9771be43..a5f8dc4fb 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 @@ -8,11 +8,11 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.foundation.item.ItemHelper; -import net.minecraft.inventory.ItemStackHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.NonNullList; +import net.minecraft.core.BlockPos; public class DropperMovementBehaviour extends MovementBehaviour { protected static final MovedDefaultDispenseItemBehaviour defaultBehaviour = new MovedDefaultDispenseItemBehaviour(); @@ -43,7 +43,7 @@ public class DropperMovementBehaviour extends MovementBehaviour { private void updateTemporaryData(MovementContext context) { if (!(context.temporaryData instanceof NonNullList) && context.world != null) { NonNullList stacks = NonNullList.withSize(getInvSize(), ItemStack.EMPTY); - ItemStackHelper.loadAllItems(context.tileData, stacks); + ContainerHelper.loadAllItems(context.tileData, stacks); context.temporaryData = stacks; } } @@ -76,7 +76,7 @@ public class DropperMovementBehaviour extends MovementBehaviour { NonNullList stacks = getStacks(context); if (stacks == null) return; - ItemStackHelper.saveAllItems(context.tileData, stacks); + ContainerHelper.saveAllItems(context.tileData, stacks); } @Override 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 bfb7e7e9f..0dd3b4df1 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 @@ -4,36 +4,36 @@ import java.util.Random; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; -import net.minecraft.block.BeehiveBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.IBucketPickupHandler; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.item.TNTEntity; -import net.minecraft.entity.projectile.FireworkRocketEntity; -import net.minecraft.entity.projectile.PotionEntity; -import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.entity.projectile.SmallFireballEntity; -import net.minecraft.fluid.FlowingFluid; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.SpawnEggItem; -import net.minecraft.potion.PotionUtils; -import net.minecraft.potion.Potions; +import net.minecraft.world.level.block.BeehiveBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.BucketPickup; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.item.PrimedTnt; +import net.minecraft.world.entity.projectile.FireworkRocketEntity; +import net.minecraft.world.entity.projectile.ThrownPotion; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.entity.projectile.SmallFireball; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; -import net.minecraft.tileentity.BeehiveTileEntity; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.Util; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.entity.BeehiveBlockEntity; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; public interface IMovedDispenseItemBehaviour { @@ -41,13 +41,13 @@ public interface IMovedDispenseItemBehaviour { final IMovedDispenseItemBehaviour spawnEggDispenseBehaviour = new MovedDefaultDispenseItemBehaviour() { @Override protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, - Vector3d facing) { + Vec3 facing) { if (!(itemStack.getItem() instanceof SpawnEggItem)) return super.dispenseStack(itemStack, context, pos, facing); - if (context.world instanceof ServerWorld) { + if (context.world instanceof ServerLevel) { EntityType entityType = ((SpawnEggItem) itemStack.getItem()).getType(itemStack.getTag()); - Entity spawnedEntity = entityType.spawn((ServerWorld) context.world, itemStack, null, - pos.offset(facing.x + .7, facing.y + .7, facing.z + .7), SpawnReason.DISPENSER, facing.y < .5, + Entity spawnedEntity = entityType.spawn((ServerLevel) context.world, itemStack, null, + pos.offset(facing.x + .7, facing.y + .7, facing.z + .7), MobSpawnType.DISPENSER, facing.y < .5, false); if (spawnedEntity != null) spawnedEntity.setDeltaMovement(context.motion.scale(2)); @@ -64,9 +64,9 @@ public interface IMovedDispenseItemBehaviour { static void init() { MovedProjectileDispenserBehaviour movedPotionDispenseItemBehaviour = new MovedProjectileDispenserBehaviour() { @Override - protected ProjectileEntity getProjectileEntity(World world, double x, double y, double z, + protected Projectile getProjectileEntity(Level world, double x, double y, double z, ItemStack itemStack) { - return Util.make(new PotionEntity(world, x, y, z), (p_218411_1_) -> p_218411_1_.setItem(itemStack)); + return Util.make(new ThrownPotion(world, x, y, z), (p_218411_1_) -> p_218411_1_.setItem(itemStack)); } protected float getProjectileInaccuracy() { @@ -87,15 +87,15 @@ public interface IMovedDispenseItemBehaviour { new MovedDefaultDispenseItemBehaviour() { @Override protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, - Vector3d facing) { + Vec3 facing) { double x = pos.getX() + facing.x * .7 + .5; 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); + PrimedTnt tntentity = new PrimedTnt(context.world, x, y, z, null); 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.TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); + SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); itemStack.shrink(1); return itemStack; } @@ -105,7 +105,7 @@ public interface IMovedDispenseItemBehaviour { new MovedDefaultDispenseItemBehaviour() { @Override protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, - Vector3d facing) { + Vec3 facing) { double x = pos.getX() + facing.x * .7 + .5; double y = pos.getY() + facing.y * .7 + .5; double z = pos.getZ() + facing.z * .7 + .5; @@ -118,7 +118,7 @@ public interface IMovedDispenseItemBehaviour { } @Override - protected void playDispenseSound(IWorld world, BlockPos pos) { + protected void playDispenseSound(LevelAccessor world, BlockPos pos) { world.levelEvent(1004, pos, 0); } }); @@ -126,19 +126,19 @@ public interface IMovedDispenseItemBehaviour { DispenserMovementBehaviour.registerMovedDispenseItemBehaviour(Items.FIRE_CHARGE, new MovedDefaultDispenseItemBehaviour() { @Override - protected void playDispenseSound(IWorld world, BlockPos pos) { + protected void playDispenseSound(LevelAccessor world, BlockPos pos) { world.levelEvent(1018, pos, 0); } @Override protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, - Vector3d facing) { + Vec3 facing) { 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.addFreshEntity(Util.make( - new SmallFireballEntity(context.world, x, y, z, + new SmallFireball(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), @@ -152,7 +152,7 @@ public interface IMovedDispenseItemBehaviour { new MovedOptionalDispenseBehaviour() { @Override protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, - Vector3d facing) { + Vec3 facing) { this.successful = false; BlockPos interactAt = pos.relative(getClosestFacingDirection(facing)); BlockState state = context.world.getBlockState(interactAt); @@ -160,7 +160,7 @@ public interface IMovedDispenseItemBehaviour { if (block.is(BlockTags.BEEHIVES) && state.getValue(BeehiveBlock.HONEY_LEVEL) >= 5) { ((BeehiveBlock) block).releaseBeesAndResetHoneyLevel(context.world, state, interactAt, null, - BeehiveTileEntity.State.BEE_RELEASED); + BeehiveBlockEntity.BeeReleaseStatus.BEE_RELEASED); this.successful = true; return placeItemInInventory(itemStack, new ItemStack(Items.HONEY_BOTTLE), context, pos, facing); @@ -180,12 +180,12 @@ public interface IMovedDispenseItemBehaviour { new MovedDefaultDispenseItemBehaviour() { @Override protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, - Vector3d facing) { + Vec3 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).takeLiquid(context.world, interactAt, state); + if (block instanceof BucketPickup) { + Fluid fluid = ((BucketPickup) block).takeLiquid(context.world, interactAt, state); if (fluid instanceof FlowingFluid) return placeItemInInventory(itemStack, new ItemStack(fluid.getBucket()), 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 d12d2d31a..1e62540e1 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 @@ -2,22 +2,22 @@ package com.simibubi.create.content.contraptions.components.actors.dispenser; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; -import net.minecraft.block.DispenserBlock; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.HopperTileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.DispenserBlock; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.HopperBlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.items.ItemHandlerHelper; public class MovedDefaultDispenseItemBehaviour implements IMovedDispenseItemBehaviour { private static final MovedDefaultDispenseItemBehaviour defaultInstance = new MovedDefaultDispenseItemBehaviour(); - public static void doDispense(World p_82486_0_, ItemStack p_82486_1_, int p_82486_2_, Vector3d facing, BlockPos p_82486_4_, MovementContext context) { + public static void doDispense(Level p_82486_0_, ItemStack p_82486_1_, int p_82486_2_, Vec3 facing, BlockPos p_82486_4_, MovementContext context) { 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; @@ -35,18 +35,18 @@ public class MovedDefaultDispenseItemBehaviour implements IMovedDispenseItemBeha @Override public ItemStack dispense(ItemStack itemStack, MovementContext context, BlockPos pos) { - Vector3d facingVec = Vector3d.atLowerCornerOf(context.state.getValue(DispenserBlock.FACING).getNormal()); + Vec3 facingVec = Vec3.atLowerCornerOf(context.state.getValue(DispenserBlock.FACING).getNormal()); facingVec = context.rotation.apply(facingVec); facingVec.normalize(); Direction closestToFacing = getClosestFacingDirection(facingVec); - IInventory iinventory = HopperTileEntity.getContainerAt(context.world, pos.relative(closestToFacing)); + Container iinventory = HopperBlockEntity.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.addItem(null, iinventory, itemStack.copy().split(1), closestToFacing.getOpposite()).isEmpty()) + if (HopperBlockEntity.addItem(null, iinventory, itemStack.copy().split(1), closestToFacing.getOpposite()).isEmpty()) itemStack.shrink(1); return itemStack; } @@ -55,7 +55,7 @@ public class MovedDefaultDispenseItemBehaviour implements IMovedDispenseItemBeha /** * Dispense the specified stack, play the dispense sound and spawn particles. */ - protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, Vector3d facing) { + protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, Vec3 facing) { ItemStack itemstack = itemStack.split(1); doDispense(context.world, itemstack, 6, facing, pos, context); return itemStack; @@ -64,26 +64,26 @@ public class MovedDefaultDispenseItemBehaviour implements IMovedDispenseItemBeha /** * Play the dispense sound from the specified block. */ - protected void playDispenseSound(IWorld world, BlockPos pos) { + protected void playDispenseSound(LevelAccessor world, BlockPos pos) { world.levelEvent(1000, pos, 0); } /** * Order clients to display dispense particles from the specified block and facing. */ - protected void spawnDispenseParticles(IWorld world, BlockPos pos, Vector3d facing) { + protected void spawnDispenseParticles(LevelAccessor world, BlockPos pos, Vec3 facing) { spawnDispenseParticles(world, pos, getClosestFacingDirection(facing)); } - protected void spawnDispenseParticles(IWorld world, BlockPos pos, Direction direction) { + protected void spawnDispenseParticles(LevelAccessor world, BlockPos pos, Direction direction) { world.levelEvent(2000, pos, direction.get3DDataValue()); } - protected Direction getClosestFacingDirection(Vector3d exactFacing) { + protected Direction getClosestFacingDirection(Vec3 exactFacing) { return Direction.getNearest(exactFacing.x, exactFacing.y, exactFacing.z); } - protected ItemStack placeItemInInventory(ItemStack consumedFrom, ItemStack output, MovementContext context, BlockPos pos, Vector3d facing) { + protected ItemStack placeItemInInventory(ItemStack consumedFrom, ItemStack output, MovementContext context, BlockPos pos, Vec3 facing) { consumedFrom.shrink(1); ItemStack remainder = ItemHandlerHelper.insertItem(context.contraption.inventory, output.copy(), false); if (!remainder.isEmpty()) 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 9b8ecef5e..b1af00626 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 @@ -1,13 +1,13 @@ package com.simibubi.create.content.contraptions.components.actors.dispenser; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; public class MovedOptionalDispenseBehaviour extends MovedDefaultDispenseItemBehaviour { protected boolean successful = true; @Override - protected void playDispenseSound(IWorld world, BlockPos pos) { + protected void playDispenseSound(LevelAccessor world, BlockPos pos) { 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 313253630..bb067c3f0 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 @@ -6,27 +6,27 @@ import javax.annotation.Nullable; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; -import net.minecraft.dispenser.IPosition; -import net.minecraft.dispenser.ProjectileDispenseBehavior; -import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.core.Position; +import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; public abstract class MovedProjectileDispenserBehaviour extends MovedDefaultDispenseItemBehaviour { @Override - protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, Vector3d facing) { + protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, Vec3 facing) { double x = pos.getX() + facing.x * .7 + .5; double y = pos.getY() + facing.y * .7 + .5; double z = pos.getZ() + facing.z * .7 + .5; - ProjectileEntity ProjectileEntity = this.getProjectileEntity(context.world, x, y, z, itemStack.copy()); + Projectile ProjectileEntity = this.getProjectileEntity(context.world, x, y, z, itemStack.copy()); if (ProjectileEntity == null) return itemStack; - Vector3d effectiveMovementVec = facing.scale(getProjectileVelocity()).add(context.motion); + Vec3 effectiveMovementVec = facing.scale(getProjectileVelocity()).add(context.motion); ProjectileEntity.shoot(effectiveMovementVec.x, effectiveMovementVec.y, effectiveMovementVec.z, (float) effectiveMovementVec.length(), this.getProjectileInaccuracy()); context.world.addFreshEntity(ProjectileEntity); itemStack.shrink(1); @@ -34,12 +34,12 @@ public abstract class MovedProjectileDispenserBehaviour extends MovedDefaultDisp } @Override - protected void playDispenseSound(IWorld world, BlockPos pos) { + protected void playDispenseSound(LevelAccessor world, BlockPos pos) { world.levelEvent(1002, pos, 0); } @Nullable - protected abstract ProjectileEntity getProjectileEntity(World world, double x, double y, double z, ItemStack itemStack); + protected abstract Projectile getProjectileEntity(Level world, double x, double y, double z, ItemStack itemStack); protected float getProjectileInaccuracy() { return 6.0F; @@ -49,12 +49,12 @@ public abstract class MovedProjectileDispenserBehaviour extends MovedDefaultDisp return 1.1F; } - public static MovedProjectileDispenserBehaviour of(ProjectileDispenseBehavior vanillaBehaviour) { + public static MovedProjectileDispenserBehaviour of(AbstractProjectileDispenseBehavior vanillaBehaviour) { return new MovedProjectileDispenserBehaviour() { @Override - protected ProjectileEntity getProjectileEntity(World world, double x, double y, double z, ItemStack itemStack) { + protected Projectile getProjectileEntity(Level world, double x, double y, double z, ItemStack itemStack) { try { - return (ProjectileEntity) MovedProjectileDispenserBehaviour.getProjectileEntityLookup().invoke(vanillaBehaviour, world, new SimplePos(x, y, z) , itemStack); + return (Projectile) MovedProjectileDispenserBehaviour.getProjectileEntityLookup().invoke(vanillaBehaviour, world, new SimplePos(x, y, z) , itemStack); } catch (Throwable ignored) { } return null; @@ -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); // getProjectile + Method getProjectileEntity = ObfuscationReflectionHelper.findMethod(AbstractProjectileDispenseBehavior.class, "func_82499_a", Level.class, Position.class, ItemStack.class); // getProjectile getProjectileEntity.setAccessible(true); return getProjectileEntity; } private static Method getProjectileInaccuracyLookup() { - Method getProjectileInaccuracy = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82498_a"); // getUncertainty + Method getProjectileInaccuracy = ObfuscationReflectionHelper.findMethod(AbstractProjectileDispenseBehavior.class, "func_82498_a"); // getUncertainty getProjectileInaccuracy.setAccessible(true); return getProjectileInaccuracy; } private static Method getProjectileVelocityLookup() { - Method getProjectileVelocity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82500_b"); // getPower + Method getProjectileVelocity = ObfuscationReflectionHelper.findMethod(AbstractProjectileDispenseBehavior.class, "func_82500_b"); // 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 a751cc024..3d62bd8c7 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 @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.components.actors.dispenser; -import net.minecraft.dispenser.IPosition; +import net.minecraft.core.Position; -public class SimplePos implements IPosition { +public class SimplePos implements Position { private final double x; private final double y; private final double 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 9782accaf..882f69c29 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 @@ -4,21 +4,23 @@ import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.NonNullList; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class CuckooClockBlock extends HorizontalKineticBlock { @@ -38,24 +40,24 @@ public class CuckooClockBlock extends HorizontalKineticBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.CUCKOO_CLOCK.create(); } @Override - public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return AllShapes.CUCKOO_CLOCK; } @Override - public void fillItemCategory(ItemGroup group, NonNullList items) { + public void fillItemCategory(CreativeModeTab group, NonNullList items) { if (!mysterious) super.fillItemCategory(group, items); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Direction preferred = getPreferredHorizontalFacing(context); if (preferred != null) return defaultBlockState().setValue(HORIZONTAL_FACING, preferred.getOpposite()); @@ -63,7 +65,7 @@ public class CuckooClockBlock extends HorizontalKineticBlock { } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face == state.getValue(HORIZONTAL_FACING).getOpposite(); } @@ -78,7 +80,7 @@ public class CuckooClockBlock extends HorizontalKineticBlock { } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 935baf026..845aeda2d 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 @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.components.clock; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -11,21 +11,21 @@ import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; public class CuckooClockRenderer extends KineticTileEntityRenderer { - public CuckooClockRenderer(TileEntityRendererDispatcher dispatcher) { + public CuckooClockRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); if (!(te instanceof CuckooClockTileEntity)) @@ -35,7 +35,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { BlockState blockState = te.getBlockState(); Direction direction = blockState.getValue(CuckooClockBlock.HORIZONTAL_FACING); - IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); // Render Hands SuperByteBuffer hourHand = PartialBufferer.get(AllBlockPartials.CUCKOO_HOUR_HAND, blockState); @@ -61,11 +61,11 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { if (local < -step / 3) continue; else if (local < 0) - angle = MathHelper.lerp(((value - (phase - 5)) / 5), 0, 135); + angle = Mth.lerp(((value - (phase - 5)) / 5), 0, 135); else if (local < step / 3) angle = 135; else if (local < 2 * step / 3) - angle = MathHelper.lerp(((value - (phase + 5)) / 5), 135, 0); + angle = Mth.lerp(((value - (phase + 5)) / 5), 135, 0); } } 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 a38d44ee1..46cb82565 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 @@ -12,16 +12,16 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.DamageSource; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.Explosion; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Explosion; public class CuckooClockTileEntity extends KineticTileEntity { @@ -37,13 +37,13 @@ public class CuckooClockTileEntity extends KineticTileEntity { PIG, CREEPER, SURPRISE, NONE; } - public CuckooClockTileEntity(TileEntityType type) { + public CuckooClockTileEntity(BlockEntityType type) { super(type); animationType = Animation.NONE; } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); if (clientPacket && compound.contains("Animation")) { animationType = NBTHelper.readEnum(compound, "Animation", Animation.class); @@ -53,7 +53,7 @@ public class CuckooClockTileEntity extends KineticTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { if (clientPacket && sendAnimationUpdate) NBTHelper.writeEnum(compound, "Animation", animationType); sendAnimationUpdate = false; @@ -97,10 +97,10 @@ public class CuckooClockTileEntity extends KineticTileEntity { animationType = Animation.NONE; if (animationType == Animation.SURPRISE && animationProgress.value == 50) { - Vector3d center = VecHelper.getCenterOf(worldPosition); + Vec3 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); + Explosion.BlockInteraction.BREAK); } } @@ -130,7 +130,7 @@ public class CuckooClockTileEntity extends KineticTileEntity { playSound(SoundEvents.NOTE_BLOCK_CHIME, 2, 0.793701f); if (value > 30 && isSurprise) { - Vector3d pos = VecHelper.offsetRandomly(VecHelper.getCenterOf(this.worldPosition), level.random, .5f); + Vec3 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) @@ -183,8 +183,8 @@ public class CuckooClockTileEntity extends KineticTileEntity { } private void playSound(SoundEvent sound, float volume, float pitch) { - Vector3d vec = VecHelper.getCenterOf(worldPosition); - level.playLocalSound(vec.x, vec.y, vec.z, sound, SoundCategory.BLOCKS, volume, pitch, false); + Vec3 vec = VecHelper.getCenterOf(worldPosition); + level.playLocalSound(vec.x, vec.y, vec.z, sound, SoundSource.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 2c4c78fa2..e7b899ca3 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 @@ -17,16 +17,16 @@ import java.util.stream.Collectors; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; @@ -35,7 +35,7 @@ import net.minecraftforge.items.wrapper.CombinedInvWrapper; public class ConnectedInputHandler { - public static boolean shouldConnect(World world, BlockPos pos, Direction face, Direction direction) { + public static boolean shouldConnect(Level world, BlockPos pos, Direction face, Direction direction) { BlockState refState = world.getBlockState(pos); if (!refState.hasProperty(HORIZONTAL_FACING)) return false; @@ -52,7 +52,7 @@ public class ConnectedInputHandler { return true; } - public static void toggleConnection(World world, BlockPos pos, BlockPos pos2) { + public static void toggleConnection(Level world, BlockPos pos, BlockPos pos2) { MechanicalCrafterTileEntity crafter1 = CrafterHelper.getCrafter(world, pos); MechanicalCrafterTileEntity crafter2 = CrafterHelper.getCrafter(world, pos2); @@ -114,7 +114,7 @@ public class ConnectedInputHandler { crafter2.connectivityChanged(); } - public static void initAndAddAll(World world, MechanicalCrafterTileEntity crafter, Collection positions) { + public static void initAndAddAll(Level world, MechanicalCrafterTileEntity crafter, Collection positions) { crafter.input = new ConnectedInput(); positions.forEach(splitPos -> { modifyAndUpdate(world, splitPos, input -> { @@ -124,7 +124,7 @@ public class ConnectedInputHandler { }); } - public static void connectControllers(World world, MechanicalCrafterTileEntity crafter1, + public static void connectControllers(Level world, MechanicalCrafterTileEntity crafter1, MechanicalCrafterTileEntity crafter2) { crafter1.input.data.forEach(offset -> { @@ -149,8 +149,8 @@ public class ConnectedInputHandler { 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.getBlockEntity(pos); + private static void modifyAndUpdate(Level world, BlockPos pos, Consumer callback) { + BlockEntity te = world.getBlockEntity(pos); if (!(te instanceof MechanicalCrafterTileEntity)) return; @@ -175,7 +175,7 @@ public class ConnectedInputHandler { data.add(controllerPos.subtract(myPos)); } - public IItemHandler getItemHandler(World world, BlockPos pos) { + public IItemHandler getItemHandler(Level world, BlockPos pos) { if (!isController) { BlockPos controllerPos = pos.offset(data.get(0)); ConnectedInput input = CrafterHelper.getInput(world, controllerPos); @@ -209,18 +209,18 @@ public class ConnectedInputHandler { return new CombinedInvWrapper(Arrays.copyOf(list.toArray(), list.size(), IItemHandlerModifiable[].class)); } - public void write(CompoundNBT nbt) { + public void write(CompoundTag nbt) { nbt.putBoolean("Controller", isController); - ListNBT list = new ListNBT(); - data.forEach(pos -> list.add(NBTUtil.writeBlockPos(pos))); + ListTag list = new ListTag(); + data.forEach(pos -> list.add(NbtUtils.writeBlockPos(pos))); nbt.put("Data", list); } - public void read(CompoundNBT nbt) { + public void read(CompoundTag nbt) { isController = nbt.getBoolean("Controller"); data.clear(); nbt.getList("Data", NBT.TAG_COMPOUND) - .forEach(inbt -> data.add(NBTUtil.readBlockPos((CompoundNBT) inbt))); + .forEach(inbt -> data.add(NbtUtils.readBlockPos((CompoundTag) inbt))); } } 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 3649a3ab4..a0d832b26 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 @@ -7,17 +7,17 @@ import com.simibubi.create.content.contraptions.components.crafter.ConnectedInpu import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; public class CrafterCTBehaviour extends ConnectedTextureBehaviour { @Override - public boolean connectsTo(BlockState state, BlockState other, IBlockDisplayReader reader, BlockPos pos, BlockPos otherPos, + public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, Direction face) { if (state.getBlock() != other.getBlock()) return false; 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 b954fe412..25a01ceb6 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 @@ -1,19 +1,19 @@ package com.simibubi.create.content.contraptions.components.crafter; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; public class CrafterHelper { - public static MechanicalCrafterTileEntity getCrafter(IBlockDisplayReader reader, BlockPos pos) { - TileEntity te = reader.getBlockEntity(pos); + public static MechanicalCrafterTileEntity getCrafter(BlockAndTintGetter reader, BlockPos pos) { + BlockEntity te = reader.getBlockEntity(pos); if (!(te instanceof MechanicalCrafterTileEntity)) return null; return (MechanicalCrafterTileEntity) te; } - public static ConnectedInputHandler.ConnectedInput getInput(IBlockDisplayReader reader, BlockPos pos) { + public static ConnectedInputHandler.ConnectedInput getInput(BlockAndTintGetter reader, BlockPos pos) { MechanicalCrafterTileEntity crafter = getCrafter(reader, pos); return crafter == null ? null : crafter.input; } 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 d732ea2e2..620a916ff 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 @@ -16,31 +16,33 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pointing; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class MechanicalCrafterBlock extends HorizontalKineticBlock implements ITE, ICogWheel { public static final EnumProperty POINTING = EnumProperty.create("pointing", Pointing.class); @@ -56,7 +58,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.MECHANICAL_CRAFTER.create(); } @@ -67,7 +69,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Direction face = context.getClickedFace(); BlockPos placedOnPos = context.getClickedPos() .relative(face.getOpposite()); @@ -90,7 +92,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT } @Override - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() == newState.getBlock()) { if (getTargetDirection(state) != getTargetDirection(newState)) { MechanicalCrafterTileEntity crafter = CrafterHelper.getCrafter(worldIn, pos); @@ -145,94 +147,94 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onWrenched(BlockState state, UseOnContext context) { if (context.getClickedFace() == state.getValue(HORIZONTAL_FACING)) { if (!context.getLevel().isClientSide) KineticTileEntity.switchToBlockState(context.getLevel(), context.getClickedPos(), state.cycle(POINTING)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { ItemStack heldItem = player.getItemInHand(handIn); - boolean isHand = heldItem.isEmpty() && handIn == Hand.MAIN_HAND; + boolean isHand = heldItem.isEmpty() && handIn == InteractionHand.MAIN_HAND; - TileEntity te = worldIn.getBlockEntity(pos); + BlockEntity te = worldIn.getBlockEntity(pos); if (!(te instanceof MechanicalCrafterTileEntity)) - return ActionResultType.PASS; + return InteractionResult.PASS; MechanicalCrafterTileEntity crafter = (MechanicalCrafterTileEntity) te; boolean wrenched = AllItems.WRENCH.isIn(heldItem); if (AllBlocks.MECHANICAL_ARM.isIn(heldItem)) - return ActionResultType.PASS; + return InteractionResult.PASS; if (hit.getDirection() == state.getValue(HORIZONTAL_FACING)) { if (crafter.phase != Phase.IDLE && !wrenched) { crafter.ejectWholeGrid(); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (crafter.phase == Phase.IDLE && !isHand && !wrenched) { if (worldIn.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; if (AllItems.CRAFTER_SLOT_COVER.isIn(heldItem)) { if (crafter.covered) - return ActionResultType.PASS; + return InteractionResult.PASS; if (!crafter.inventory.isEmpty()) - return ActionResultType.PASS; + return InteractionResult.PASS; crafter.covered = true; crafter.setChanged(); crafter.sendData(); if (!player.isCreative()) heldItem.shrink(1); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } LazyOptional capability = crafter.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); if (!capability.isPresent()) - return ActionResultType.PASS; + return InteractionResult.PASS; ItemStack remainder = ItemHandlerHelper.insertItem(capability.orElse(new ItemStackHandler()), heldItem.copy(), false); if (remainder.getCount() != heldItem.getCount()) player.setItemInHand(handIn, remainder); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } ItemStack inSlot = crafter.getInventory().getItem(0); if (inSlot.isEmpty()) { if (crafter.covered && !wrenched) { if (worldIn.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; crafter.covered = false; crafter.setChanged(); crafter.sendData(); if (!player.isCreative()) player.inventory.placeItemBackInInventory(worldIn, AllItems.CRAFTER_SLOT_COVER.asStack()); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } if (!isHand && !ItemHandlerHelper.canItemStacksStack(heldItem, inSlot)) - return ActionResultType.PASS; + return InteractionResult.PASS; if (worldIn.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; player.inventory.placeItemBackInInventory(worldIn, inSlot); crafter.getInventory().setStackInSlot(0, ItemStack.EMPTY); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { InvManipulationBehaviour behaviour = TileEntityBehaviour.get(worldIn, pos, InvManipulationBehaviour.TYPE); if (behaviour != null) @@ -254,13 +256,13 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT return Direction.UP; Direction facing = state.getValue(HORIZONTAL_FACING); Pointing point = state.getValue(POINTING); - Vector3d targetVec = new Vector3d(0, 1, 0); + Vec3 targetVec = new Vec3(0, 1, 0); targetVec = VecHelper.rotate(targetVec, -point.getXRotation(), Axis.Z); targetVec = VecHelper.rotate(targetVec, AngleHelper.horizontalAngle(facing), Axis.Y); return Direction.getNearest(targetVec.x, targetVec.y, targetVec.z); } - public static boolean isValidTarget(World world, BlockPos targetPos, BlockState crafterState) { + public static boolean isValidTarget(Level world, BlockPos targetPos, BlockState crafterState) { BlockState targetState = world.getBlockState(targetPos); if (!world.isLoaded(targetPos)) return false; 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 f5da491fb..85ebb4b78 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 @@ -12,7 +12,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; public class MechanicalCrafterInstance extends SingleRotatingInstance { 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 67e38873d..51070a94e 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 @@ -6,8 +6,8 @@ import static com.simibubi.create.content.contraptions.base.KineticTileEntityRen import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllSpriteShifts; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase; @@ -19,40 +19,40 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; public class MechanicalCrafterRenderer extends SafeTileEntityRenderer { - public MechanicalCrafterRenderer(TileEntityRendererDispatcher dispatcher) { + public MechanicalCrafterRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, - IRenderTypeBuffer buffer, int light, int overlay) { + protected void renderSafe(MechanicalCrafterTileEntity te, float partialTicks, PoseStack ms, + MultiBufferSource buffer, int light, int overlay) { ms.pushPose(); Direction facing = te.getBlockState() .getValue(HORIZONTAL_FACING); - Vector3d vec = Vector3d.atLowerCornerOf(facing.getNormal()) + Vec3 vec = Vec3.atLowerCornerOf(facing.getNormal()) .scale(.58) .add(.5, .5, .5); if (te.phase == Phase.EXPORTING) { Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(te.getBlockState()); float progress = - MathHelper.clamp((1000 - te.countDown + te.getCountDownSpeed() * partialTicks) / 1000f, 0, 1); - vec = vec.add(Vector3d.atLowerCornerOf(targetDirection.getNormal()) + Mth.clamp((1000 - te.countDown + te.getCountDownSpeed() * partialTicks) / 1000f, 0, 1); + vec = vec.add(Vec3.atLowerCornerOf(targetDirection.getNormal()) .scale(progress * .75f)); } @@ -66,8 +66,8 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer type) { + public MechanicalCrafterTileEntity(BlockEntityType type) { super(type); setLazyTickRate(20); phase = Phase.IDLE; @@ -124,7 +124,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { attachBehaviourLate(inserting); } - public BlockFace getTargetFace(World world, BlockPos pos, BlockState state) { + public BlockFace getTargetFace(Level world, BlockPos pos, BlockState state) { return new BlockFace(pos, MechanicalCrafterBlock.getTargetDirection(state)); } @@ -133,14 +133,14 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.put("Inventory", inventory.serializeNBT()); - CompoundNBT inputNBT = new CompoundNBT(); + CompoundTag inputNBT = new CompoundTag(); input.write(inputNBT); compound.put("ConnectedInput", inputNBT); - CompoundNBT groupedItemsNBT = new CompoundNBT(); + CompoundTag groupedItemsNBT = new CompoundTag(); groupedItems.write(groupedItemsNBT); compound.put("GroupedItems", groupedItemsNBT); @@ -157,7 +157,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { Phase phaseBefore = phase; GroupedItems before = this.groupedItems; @@ -181,11 +181,11 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { groupedItemsBeforeCraft = before; if (phaseBefore == Phase.EXPORTING && phase == Phase.WAITING) { Direction facing = getBlockState().getValue(MechanicalCrafterBlock.HORIZONTAL_FACING); - Vector3d vec = Vector3d.atLowerCornerOf(facing.getNormal()) + Vec3 vec = Vec3.atLowerCornerOf(facing.getNormal()) .scale(.75) .add(VecHelper.getCenterOf(worldPosition)); Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(getBlockState()); - vec = vec.add(Vector3d.atLowerCornerOf(targetDirection.getNormal()) + vec = vec.add(Vec3.atLowerCornerOf(targetDirection.getNormal()) .scale(1)); level.addParticle(ParticleTypes.CRIT, vec.x, vec.y, vec.z, 0, 0, 0); } @@ -200,7 +200,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { public int getCountDownSpeed() { if (getSpeed() == 0) return 0; - return MathHelper.clamp((int) Math.abs(getSpeed()), 4, 250); + return Mth.clamp((int) Math.abs(getSpeed()), 4, 250); } @Override @@ -303,10 +303,10 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { if (onClient) { Direction facing = getBlockState().getValue(MechanicalCrafterBlock.HORIZONTAL_FACING); float progress = countDown / 2000f; - Vector3d facingVec = Vector3d.atLowerCornerOf(facing.getNormal()); - Vector3d vec = facingVec.scale(.65) + Vec3 facingVec = Vec3.atLowerCornerOf(facing.getNormal()); + Vec3 vec = facingVec.scale(.65) .add(VecHelper.getCenterOf(worldPosition)); - Vector3d offset = VecHelper.offsetRandomly(Vector3d.ZERO, level.random, .125f) + Vec3 offset = VecHelper.offsetRandomly(Vec3.ZERO, level.random, .125f) .multiply(VecHelper.axisAlingedPlaneOf(facingVec)) .normalize() .scale(progress * .5f) @@ -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, level.random, .125f) + Vec3 randVec = VecHelper.offsetRandomly(Vec3.ZERO, level.random, .125f) .multiply(VecHelper.axisAlingedPlaneOf(facingVec)) .normalize() .scale(.25f); - Vector3d offset2 = randVec.add(vec); + Vec3 offset2 = randVec.add(vec); randVec = randVec.scale(.35f); - level.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), offset2.x, offset2.y, + level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), offset2.x, offset2.y, offset2.z, randVec.x, randVec.y, randVec.z); } } @@ -411,10 +411,10 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { public void eject() { BlockState blockState = getBlockState(); boolean present = AllBlocks.MECHANICAL_CRAFTER.has(blockState); - Vector3d vec = present ? Vector3d.atLowerCornerOf(blockState.getValue(HORIZONTAL_FACING) + Vec3 vec = present ? Vec3.atLowerCornerOf(blockState.getValue(HORIZONTAL_FACING) .getNormal()) - .scale(.75f) : Vector3d.ZERO; - Vector3d ejectPos = VecHelper.getCenterOf(worldPosition) + .scale(.75f) : Vec3.ZERO; + Vec3 ejectPos = VecHelper.getCenterOf(worldPosition) .add(vec); groupedItems.grid.forEach((pair, stack) -> dropItem(ejectPos, stack)); if (!inventory.getItem(0) @@ -426,7 +426,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { sendData(); } - public void dropItem(Vector3d ejectPos, ItemStack stack) { + public void dropItem(Vec3 ejectPos, ItemStack stack) { ItemEntity itemEntity = new ItemEntity(level, ejectPos.x, ejectPos.y, ejectPos.z, stack); itemEntity.setDefaultPickUpDelay(); level.addFreshEntity(itemEntity); 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 21cf5d725..d9f5713d7 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 @@ -4,15 +4,15 @@ import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.content.contraptions.components.crafter.RecipeGridHandler.GroupedItems; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; -public class MechanicalCraftingInventory extends CraftingInventory { +public class MechanicalCraftingInventory extends CraftingContainer { - private static Container dummyContainer = new Container(null, -1) { - public boolean stillValid(PlayerEntity playerIn) { + private static AbstractContainerMenu dummyContainer = new AbstractContainerMenu(null, -1) { + public boolean stillValid(Player playerIn) { return false; } }; 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 4eef6c570..d7b8c9ee7 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 @@ -3,17 +3,17 @@ package com.simibubi.create.content.contraptions.components.crafter; import com.google.gson.JsonObject; import com.simibubi.create.AllRecipeTypes; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.ShapedRecipe; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.util.GsonHelper; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; public class MechanicalCraftingRecipe extends ShapedRecipe { @@ -31,7 +31,7 @@ public class MechanicalCraftingRecipe extends ShapedRecipe { } @Override - public boolean matches(CraftingInventory inv, World worldIn) { + public boolean matches(CraftingContainer inv, Level worldIn) { if (!(inv instanceof MechanicalCraftingInventory)) return false; if (acceptsMirrored()) @@ -46,7 +46,7 @@ public class MechanicalCraftingRecipe extends ShapedRecipe { } // From ShapedRecipe - private boolean matchesSpecific(CraftingInventory inv, int p_77573_2_, int p_77573_3_) { + private boolean matchesSpecific(CraftingContainer inv, int p_77573_2_, int p_77573_3_) { NonNullList ingredients = getIngredients(); int width = getWidth(); int height = getHeight(); @@ -65,7 +65,7 @@ public class MechanicalCraftingRecipe extends ShapedRecipe { } @Override - public IRecipeType getType() { + public RecipeType getType() { return AllRecipeTypes.MECHANICAL_CRAFTING.getType(); } @@ -75,7 +75,7 @@ public class MechanicalCraftingRecipe extends ShapedRecipe { } @Override - public IRecipeSerializer getSerializer() { + public RecipeSerializer getSerializer() { return AllRecipeTypes.MECHANICAL_CRAFTING.getSerializer(); } @@ -87,16 +87,16 @@ public class MechanicalCraftingRecipe extends ShapedRecipe { @Override public ShapedRecipe fromJson(ResourceLocation recipeId, JsonObject json) { - return fromShaped(super.fromJson(recipeId, json), JSONUtils.getAsBoolean(json, "acceptMirrored", true)); + return fromShaped(super.fromJson(recipeId, json), GsonHelper.getAsBoolean(json, "acceptMirrored", true)); } @Override - public ShapedRecipe fromNetwork(ResourceLocation recipeId, PacketBuffer buffer) { + public ShapedRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) { return fromShaped(super.fromNetwork(recipeId, buffer), buffer.readBoolean() && buffer.readBoolean()); } @Override - public void toNetwork(PacketBuffer p_199427_1_, ShapedRecipe p_199427_2_) { + public void toNetwork(FriendlyByteBuf p_199427_1_, ShapedRecipe p_199427_2_) { super.toNetwork(p_199427_1_, p_199427_2_); if (p_199427_2_ instanceof MechanicalCraftingRecipe) { p_199427_1_.writeBoolean(true); 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 12a0ee73a..20e9cb78c 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 @@ -20,17 +20,17 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.BlockState; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FireworkRocketRecipe; -import net.minecraft.item.crafting.ICraftingRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.FireworkRocketRecipe; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.Constants.NBT; public class RecipeGridHandler { @@ -105,7 +105,7 @@ public class RecipeGridHandler { public static List getPrecedingCrafters(MechanicalCrafterTileEntity crafter) { BlockPos pos = crafter.getBlockPos(); - World world = crafter.getLevel(); + Level world = crafter.getLevel(); List crafters = new ArrayList<>(); BlockState blockState = crafter.getBlockState(); if (!isCrafter(blockState)) @@ -141,13 +141,13 @@ public class RecipeGridHandler { return AllBlocks.MECHANICAL_CRAFTER.has(state); } - public static ItemStack tryToApplyRecipe(World world, GroupedItems items) { + public static ItemStack tryToApplyRecipe(Level world, GroupedItems items) { items.calcStats(); - CraftingInventory craftinginventory = new MechanicalCraftingInventory(items); + CraftingContainer craftinginventory = new MechanicalCraftingInventory(items); ItemStack result = null; if (AllConfigs.SERVER.recipes.allowRegularCraftingInCrafter.get()) result = world.getRecipeManager() - .getRecipeFor(IRecipeType.CRAFTING, craftinginventory, world) + .getRecipeFor(RecipeType.CRAFTING, craftinginventory, world) .filter(r -> isRecipeAllowed(r, craftinginventory)) .map(r -> r.assemble(craftinginventory)) .orElse(null); @@ -158,7 +158,7 @@ public class RecipeGridHandler { return result; } - public static boolean isRecipeAllowed(ICraftingRecipe recipe, CraftingInventory inventory) { + public static boolean isRecipeAllowed(CraftingRecipe recipe, CraftingContainer inventory) { if (!AllConfigs.SERVER.recipes.allowBiggerFireworksInCrafter.get() && recipe instanceof FireworkRocketRecipe) { int numItems = IntStream.range(0, inventory.getContainerSize()) .map(i -> inventory.getItem(i).isEmpty() ? 0 : 1) @@ -188,10 +188,10 @@ public class RecipeGridHandler { other.statsReady = false; } - public void write(CompoundNBT nbt) { - ListNBT gridNBT = new ListNBT(); + public void write(CompoundTag nbt) { + ListTag gridNBT = new ListTag(); grid.forEach((pair, stack) -> { - CompoundNBT entry = new CompoundNBT(); + CompoundTag entry = new CompoundTag(); entry.putInt("x", pair.getKey()); entry.putInt("y", pair.getValue()); entry.put("item", stack.serializeNBT()); @@ -200,11 +200,11 @@ public class RecipeGridHandler { nbt.put("Grid", gridNBT); } - public static GroupedItems read(CompoundNBT nbt) { + public static GroupedItems read(CompoundTag nbt) { GroupedItems items = new GroupedItems(); - ListNBT gridNBT = nbt.getList("Grid", NBT.TAG_COMPOUND); + ListTag gridNBT = nbt.getList("Grid", NBT.TAG_COMPOUND); gridNBT.forEach(inbt -> { - CompoundNBT entry = (CompoundNBT) inbt; + CompoundTag entry = (CompoundTag) inbt; int x = entry.getInt("x"); int y = entry.getInt("y"); ItemStack stack = ItemStack.of(entry.getCompound("item")); 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 916e384b0..8c3f84f42 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 @@ -8,27 +8,29 @@ import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.config.AllConfigs; -import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class HandCrankBlock extends DirectionalKineticBlock implements ITE { public HandCrankBlock(Properties properties) { @@ -36,7 +38,7 @@ public class HandCrankBlock extends DirectionalKineticBlock implements ITE te.turn(player.isShiftKeyDown())); player.causeFoodExhaustion(getRotationSpeed() * AllConfigs.SERVER.kinetics.crankHungerMultiplier.getF()); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Direction preferred = getPreferredFacing(context); if (preferred == null || (context.getPlayer() != null && context.getPlayer() .isShiftKeyDown())) @@ -73,7 +75,7 @@ public class HandCrankBlock extends DirectionalKineticBlock implements ITE type) { + public HandCrankTileEntity(BlockEntityType type) { super(type); } @@ -46,13 +46,13 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("InUse", inUse); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { inUse = compound.getInt("InUse"); super.fromTag(state, compound, clientPacket); } 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 aa0881ffb..9af576055 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 @@ -6,20 +6,22 @@ import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.utility.BlockHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.NonNullList; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + @ParametersAreNonnullByDefault public class ValveHandleBlock extends HandCrankBlock { @@ -41,24 +43,24 @@ public class ValveHandleBlock extends HandCrankBlock { } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult hit) { ItemStack heldItem = player.getItemInHand(hand); DyeColor color = DyeColor.getColor(heldItem); if (color != null && color != this.color) { if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; BlockState newState = BlockHelper.copyProperties(state, AllBlocks.DYED_VALVE_HANDLES.get(color).getDefaultState()); world.setBlockAndUpdate(pos, newState); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } return super.use(state, world, pos, player, hand, hit); } @Override - public void fillItemCategory(ItemGroup group, NonNullList p_149666_2_) { - if (group != ItemGroup.TAB_SEARCH && !inCreativeTab) + public void fillItemCategory(CreativeModeTab group, NonNullList p_149666_2_) { + if (group != CreativeModeTab.TAB_SEARCH && !inCreativeTab) return; super.fillItemCategory(group, p_149666_2_); } 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 e4bfa6be3..5833d160b 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 @@ -5,7 +5,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraftforge.items.wrapper.RecipeWrapper; @ParametersAreNonnullByDefault @@ -16,7 +16,7 @@ public class CrushingRecipe extends AbstractCrushingRecipe { } @Override - public boolean matches(RecipeWrapper inv, World worldIn) { + public boolean matches(RecipeWrapper inv, Level worldIn) { if (inv.isEmpty()) return false; return ingredients.get(0) 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 c0afc346b..7b5f78413 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 @@ -10,20 +10,22 @@ import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE { @@ -32,7 +34,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.CRUSHING_WHEEL.create(); } @@ -42,18 +44,18 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE } @Override - public BlockRenderType getRenderShape(BlockState state) { - return BlockRenderType.ENTITYBLOCK_ANIMATED; + public RenderShape getRenderShape(BlockState state) { + return RenderShape.ENTITYBLOCK_ANIMATED; } @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, - ISelectionContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos, + CollisionContext context) { return AllShapes.CRUSHING_WHEEL_COLLISION_SHAPE; } @Override - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { for (Direction d : Iterate.directions) { if (d.getAxis() == state.getValue(AXIS)) @@ -67,7 +69,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE } } - public void updateControllers(BlockState state, World world, BlockPos pos, Direction side) { + public void updateControllers(BlockState state, Level world, BlockPos pos, Direction side) { if (side.getAxis() == state.getValue(AXIS)) return; if (world == null) @@ -100,10 +102,10 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE Axis wheelAxis = state.getValue(AXIS); Axis sideAxis = side.getAxis(); int controllerADO = Math.round(Math.signum(te.getSpeed())) * side.getAxisDirection().getStep(); - Vector3d controllerDirVec = new Vector3d(wheelAxis == Axis.X ? 1 : 0 + Vec3 controllerDirVec = new Vec3(wheelAxis == Axis.X ? 1 : 0 , wheelAxis == Axis.Y ? 1 : 0 , wheelAxis == Axis.Z ? 1 : 0) - .cross(new Vector3d(sideAxis == Axis.X ? 1 : 0 + .cross(new Vec3(sideAxis == Axis.X ? 1 : 0 , sideAxis == Axis.Y ? 1 : 0 , sideAxis == Axis.Z ? 1 : 0)); @@ -143,7 +145,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE } @Override - public void entityInside(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) { if (entityIn.getY() < pos.getY() + 1.25f || !entityIn.isOnGround()) return; @@ -166,7 +168,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE } @Override - public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) { for (Direction direction : Iterate.directions) { BlockPos neighbourPos = pos.relative(direction); BlockState neighbourState = worldIn.getBlockState(neighbourPos); @@ -183,7 +185,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.getValue(AXIS); } 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 b136458b1..ed97e5c73 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 @@ -10,32 +10,34 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.DirectionalBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.Vec3; import net.minecraft.world.Difficulty; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class CrushingWheelControllerBlock extends DirectionalBlock implements ITE { @@ -52,17 +54,17 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - public boolean canBeReplaced(BlockState state, BlockItemUseContext useContext) { + public boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) { return false; } @Override - public boolean addRunningEffects(BlockState state, World world, BlockPos pos, Entity entity) { + public boolean addRunningEffects(BlockState state, Level world, BlockPos pos, Entity entity) { return true; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.CRUSHING_WHEEL_CONTROLLER.create(); } @@ -73,7 +75,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock super.createBlockStateDefinition(builder); } - public void entityInside(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) { if (!state.getValue(VALID)) return; @@ -85,13 +87,13 @@ public class CrushingWheelControllerBlock extends DirectionalBlock withTileEntityDo(worldIn, pos, te -> { if (te.processingEntity == entityIn) - entityIn.makeStuckInBlock(state, new Vector3d(axis == Axis.X ? (double) 0.05F : 0.25D + entityIn.makeStuckInBlock(state, new Vec3(axis == Axis.X ? (double) 0.05F : 0.25D , axis == Axis.Y ? (double) 0.05F : 0.25D , axis == Axis.Z ? (double) 0.05F : 0.25D)); }); } - public void checkEntityForProcessing(World worldIn, BlockPos pos, Entity entityIn) { + public void checkEntityForProcessing(Level worldIn, BlockPos pos, Entity entityIn) { CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos); if (te == null) return; @@ -99,15 +101,15 @@ public class CrushingWheelControllerBlock extends DirectionalBlock return; if (entityIn instanceof ItemEntity) ((ItemEntity) entityIn).setPickUpDelay(10); - CompoundNBT data = entityIn.getPersistentData(); + CompoundTag data = entityIn.getPersistentData(); if (data.contains("BypassCrushingWheel")) { - if (pos.equals(NBTUtil.readBlockPos(data.getCompound("BypassCrushingWheel")))) + if (pos.equals(NbtUtils.readBlockPos(data.getCompound("BypassCrushingWheel")))) return; } if (te.isOccupied()) return; - boolean isPlayer = entityIn instanceof PlayerEntity; - if (isPlayer && ((PlayerEntity) entityIn).isCreative()) + boolean isPlayer = entityIn instanceof Player; + if (isPlayer && ((Player) entityIn).isCreative()) return; if (isPlayer && entityIn.level.getDifficulty() == Difficulty.PEACEFUL) return; @@ -116,13 +118,13 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + public void updateEntityAfterFallOn(BlockGetter 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) { + public void animateTick(BlockState stateIn, Level worldIn, BlockPos pos, Random rand) { if (!stateIn.getValue(VALID)) return; if (rand.nextInt(1) != 0) @@ -134,13 +136,13 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { updateSpeed(stateIn, worldIn, currentPos); return stateIn; } - public void updateSpeed(BlockState state, IWorld world, BlockPos pos) { + public void updateSpeed(BlockState state, LevelAccessor world, BlockPos pos) { withTileEntityDo(world, pos, te -> { if (!state.getValue(VALID)) { if (te.crushingspeed != 0) { @@ -156,7 +158,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock continue; if (neighbour.getValue(BlockStateProperties.AXIS) == d.getAxis()) continue; - TileEntity adjTe = world.getBlockEntity(pos.relative(d)); + BlockEntity adjTe = world.getBlockEntity(pos.relative(d)); if (!(adjTe instanceof KineticTileEntity)) continue; te.crushingspeed = Math.abs(((KineticTileEntity) adjTe).getSpeed() / 50f); @@ -167,8 +169,8 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, - ISelectionContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos, + CollisionContext context) { VoxelShape standardShape = AllShapes.CRUSHING_WHEEL_CONTROLLER_COLLISION.get(state.getValue(FACING)); if (!state.getValue(VALID)) @@ -178,21 +180,21 @@ public class CrushingWheelControllerBlock extends DirectionalBlock if (entity == null) return standardShape; - CompoundNBT data = entity.getPersistentData(); + CompoundTag data = entity.getPersistentData(); if (data.contains("BypassCrushingWheel")) - if (pos.equals(NBTUtil.readBlockPos(data.getCompound("BypassCrushingWheel")))) + if (pos.equals(NbtUtils.readBlockPos(data.getCompound("BypassCrushingWheel")))) if (state.getValue(FACING) != Direction.UP) // Allow output items to land on top of the block rather than falling back through. - return VoxelShapes.empty(); + return Shapes.empty(); CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos); if (te != null && te.processingEntity == entity) - return VoxelShapes.empty(); + return Shapes.empty(); return standardShape; } @Override - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (!state.hasTileEntity() || state.getBlock() == newState.getBlock()) return; @@ -206,7 +208,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 5928a5838..0db552782 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 @@ -2,11 +2,55 @@ package com.simibubi.create.content.contraptions.components.crusher; import static net.minecraft.block.DirectionalBlock.FACING; +import javanimport com.simibubi.create.AllRecipeTypes; +import com.simibubi.create.content.contraptions.processing.ProcessingInventory; +import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; +import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.item.ItemHelper; +import com.simibubi.create.foundation.sound.SoundScapes; +import com.simibubi.create.foundation.sound.SoundScapes.AmbienceGroup; +import com.simibubi.create.foundation.tileEntity.SmartTileEntity; +import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; +import com.simibubi.create.foundation.utility.NBTHelper; +import com.simibubi.create.foundation.utility.VecHelper; import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.Random; import java.util.UUID; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.wrapper.RecipeWrapper; + +et.minecraft.world.level.block.DirectionalBlockist; +import java.util.Optional; +import java.util.Random; +import java.util.UUID; import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.content.contraptions.processing.ProcessingInventory; @@ -60,7 +104,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { private RecipeWrapper wrapper; public float crushingspeed; - public CrushingWheelControllerTileEntity(TileEntityType type) { + public CrushingWheelControllerTileEntity(BlockEntityType type) { super(type); inventory = new ProcessingInventory(this::itemInserted) { @@ -91,7 +135,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { super.tick(); if (searchForEntity) { searchForEntity = false; - List search = level.getEntities((Entity) null, new AxisAlignedBB(getBlockPos()), + List search = level.getEntities((Entity) null, new AABB(getBlockPos()), e -> entityUUID.equals(e.getUUID())); if (search.isEmpty()) clear(); @@ -109,23 +153,23 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { float speed = crushingspeed * 4; - Vector3d centerPos = VecHelper.getCenterOf(worldPosition); + Vec3 centerPos = VecHelper.getCenterOf(worldPosition); Direction facing = getBlockState().getValue(FACING); int offset = facing.getAxisDirection() .getStep(); - Vector3d outSpeed = new Vector3d((facing.getAxis() == Axis.X ? 0.25D : 0.0D) * offset, + Vec3 outSpeed = new Vec3((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 // properly. , (facing.getAxis() == Axis.Z ? 0.25D : 0.0D) * offset); // No downwards speed, so downwards crushing wheels // drop the items as before. - Vector3d outPos = centerPos.add((facing.getAxis() == Axis.X ? .55f * offset : 0f), + Vec3 outPos = centerPos.add((facing.getAxis() == Axis.X ? .55f * offset : 0f), (facing.getAxis() == Axis.Y ? .55f * offset : 0f), (facing.getAxis() == Axis.Z ? .55f * offset : 0f)); if (!hasEntity()) { float processingSpeed = - MathHelper.clamp((speed) / (!inventory.appliedRecipe ? MathHelper.log2(inventory.getStackInSlot(0) + Mth.clamp((speed) / (!inventory.appliedRecipe ? Mth.log2(inventory.getStackInSlot(0) .getCount()) : 1), .25f, 20); inventory.remainingTime -= processingSpeed; spawnParticles(inventory.getStackInSlot(0)); @@ -182,7 +226,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { ItemEntity entityIn = new ItemEntity(level, outPos.x, outPos.y, outPos.z, stack); entityIn.setDeltaMovement(outSpeed); entityIn.getPersistentData() - .put("BypassCrushingWheel", NBTUtil.writeBlockPos(worldPosition)); + .put("BypassCrushingWheel", NbtUtils.writeBlockPos(worldPosition)); level.addFreshEntity(entityIn); } inventory.clear(); @@ -192,7 +236,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { } if (!processingEntity.isAlive() || !processingEntity.getBoundingBox() - .intersects(new AxisAlignedBB(worldPosition).inflate(.5f))) { + .intersects(new AABB(worldPosition).inflate(.5f))) { clear(); return; } @@ -203,7 +247,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { xMotion = zMotion = 0; double movement = Math.max(-speed / 4f, -.5f) * -offset; processingEntity.setDeltaMovement( - new Vector3d(facing.getAxis() == Axis.X ? movement : xMotion, facing.getAxis() == Axis.Y ? movement : 0f // Do + new Vec3(facing.getAxis() == Axis.X ? movement : xMotion, facing.getAxis() == Axis.Y ? movement : 0f // Do // not // move // entities @@ -219,7 +263,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { return; if (!(processingEntity instanceof ItemEntity)) { - Vector3d entityOutPos = outPos.add(facing.getAxis() == Axis.X ? .5f * offset : 0f, + Vec3 entityOutPos = outPos.add(facing.getAxis() == Axis.X ? .5f * offset : 0f, facing.getAxis() == Axis.Y ? .5f * offset : 0f, facing.getAxis() == Axis.Z ? .5f * offset : 0f); int crusherDamage = AllConfigs.SERVER.kinetics.crushingDamage.get(); @@ -259,7 +303,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { @OnlyIn(Dist.CLIENT) public void tickAudio() { - float pitch = MathHelper.clamp((crushingspeed / 256f) + .45f, .85f, 1f); + float pitch = Mth.clamp((crushingspeed / 256f) + .45f, .85f, 1f); if (entityUUID == null && inventory.getStackInSlot(0) .isEmpty()) return; @@ -279,12 +323,12 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { if (stack == null || stack.isEmpty()) return; - IParticleData particleData = null; + ParticleOptions particleData = null; if (stack.getItem() instanceof BlockItem) - particleData = new BlockParticleData(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock() + particleData = new BlockParticleOption(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock() .defaultBlockState()); else - particleData = new ItemParticleData(ParticleTypes.ITEM, stack); + particleData = new ItemParticleOption(ParticleTypes.ITEM, stack); Random r = level.random; for (int i = 0; i < 4; i++) @@ -324,19 +368,19 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { if (hasEntity()) - compound.put("Entity", NBTUtil.createUUID(entityUUID)); + compound.put("Entity", NbtUtils.createUUID(entityUUID)); compound.put("Inventory", inventory.serializeNBT()); compound.putFloat("Speed", crushingspeed); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); if (compound.contains("Entity") && !isOccupied()) { - entityUUID = NBTUtil.loadUUID(NBTHelper.getINBT(compound, "Entity")); + entityUUID = NbtUtils.loadUUID(NBTHelper.getINBT(compound, "Entity")); this.searchForEntity = true; } crushingspeed = compound.getFloat("Speed"); 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 fa0fa32af..e57e58c0e 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 @@ -3,12 +3,12 @@ package com.simibubi.create.content.contraptions.components.crusher; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LootingLevelEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -20,7 +20,7 @@ public class CrushingWheelTileEntity extends KineticTileEntity { public static DamageSource damageSource = new DamageSource("create.crush").bypassArmor() .setScalesWithDifficulty(); - public CrushingWheelTileEntity(TileEntityType type) { + public CrushingWheelTileEntity(BlockEntityType type) { super(type); setLazyTickRate(20); } @@ -38,8 +38,8 @@ public class CrushingWheelTileEntity extends KineticTileEntity { } @Override - public AxisAlignedBB makeRenderBoundingBox() { - return new AxisAlignedBB(worldPosition).inflate(1); + public AABB makeRenderBoundingBox() { + return new AABB(worldPosition).inflate(1); } @Override @@ -59,7 +59,7 @@ public class CrushingWheelTileEntity extends KineticTileEntity { public static void handleCrushedMobDrops(LivingDropsEvent event) { if (event.getSource() != CrushingWheelTileEntity.damageSource) return; - Vector3d outSpeed = Vector3d.ZERO; + Vec3 outSpeed = Vec3.ZERO; for (ItemEntity outputItem : event.getDrops()) { 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 697089b22..c6ee4a431 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 @@ -17,15 +17,15 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBe import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.items.ItemHandlerHelper; public class BeltDeployerCallbacks { @@ -71,7 +71,7 @@ public class BeltDeployerCallbacks { if (held.isEmpty()) return ProcessingResult.HOLD; - IRecipe recipe = deployerTileEntity.getRecipe(s.stack); + Recipe recipe = deployerTileEntity.getRecipe(s.stack); if (recipe == null) return ProcessingResult.PASS; @@ -90,7 +90,7 @@ public class BeltDeployerCallbacks { } public static void activate(TransportedItemStack transported, TransportedItemStackHandlerBehaviour handler, - DeployerTileEntity deployerTileEntity, IRecipe recipe) { + DeployerTileEntity deployerTileEntity, Recipe recipe) { List collect = InWorldProcessing.applyRecipeOn(ItemHandlerHelper.copyStackWithSize(transported.stack, 1), recipe) @@ -126,16 +126,16 @@ public class BeltDeployerCallbacks { if (!unbreakable && !keepHeld) { if (heldItem.isDamageableItem()) - heldItem.hurtAndBreak(1, deployerTileEntity.player, s -> s.broadcastBreakEvent(Hand.MAIN_HAND)); + heldItem.hurtAndBreak(1, deployerTileEntity.player, s -> s.broadcastBreakEvent(InteractionHand.MAIN_HAND)); else heldItem.shrink(1); } BlockPos pos = deployerTileEntity.getBlockPos(); - World world = deployerTileEntity.getLevel(); + Level world = deployerTileEntity.getLevel(); if (heldItem.isEmpty()) - world.playSound(null, pos, SoundEvents.ITEM_BREAK, SoundCategory.BLOCKS, .25f, 1); - world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.BLOCKS, .25f, .75f); + world.playSound(null, pos, SoundEvents.ITEM_BREAK, SoundSource.BLOCKS, .25f, 1); + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundSource.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 f05287d0e..151021044 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 @@ -24,11 +24,13 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; +import ModelData; + public class DeployerActorInstance extends ActorInstance { Direction facing; 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 aabfa2846..7d11369a2 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 @@ -16,17 +16,17 @@ import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuild import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.ItemLike; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.wrapper.RecipeWrapper; @@ -41,7 +41,7 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i } @Override - public boolean matches(RecipeWrapper inv, World p_77569_2_) { + public boolean matches(RecipeWrapper inv, Level p_77569_2_) { return ingredients.get(0) .test(inv.getItem(0)) && ingredients.get(1) @@ -74,7 +74,7 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i return ingredients.get(0); } - public static List convert(List> sandpaperRecipes) { + public static List convert(List> sandpaperRecipes) { return sandpaperRecipes.stream() .map(r -> new ProcessingRecipeBuilder<>(DeployerApplicationRecipe::new, new ResourceLocation(r.getId() .getNamespace(), @@ -95,7 +95,7 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i @Override public void readAdditional(JsonObject json) { super.readAdditional(json); - keepHeldItem = JSONUtils.getAsBoolean(json, "keepHeldItem", false); + keepHeldItem = GsonHelper.getAsBoolean(json, "keepHeldItem", false); } @Override @@ -106,30 +106,30 @@ public class DeployerApplicationRecipe extends ProcessingRecipe i } @Override - public void readAdditional(PacketBuffer buffer) { + public void readAdditional(FriendlyByteBuf buffer) { super.readAdditional(buffer); keepHeldItem = buffer.readBoolean(); } @Override - public void writeAdditional(PacketBuffer buffer) { + public void writeAdditional(FriendlyByteBuf buffer) { super.writeAdditional(buffer); buffer.writeBoolean(keepHeldItem); } @Override @OnlyIn(Dist.CLIENT) - public ITextComponent getDescriptionForAssembly() { + public Component getDescriptionForAssembly() { ItemStack[] matchingStacks = ingredients.get(1) .getItems(); if (matchingStacks.length == 0) - return new StringTextComponent("Invalid"); + return new TextComponent("Invalid"); return Lang.translate("recipe.assembly.deploying_item", - new TranslationTextComponent(matchingStacks[0].getDescriptionId()).getString()); + new TranslatableComponent(matchingStacks[0].getDescriptionId()).getString()); } @Override - public void addRequiredMachines(Set list) { + public void addRequiredMachines(Set list) { list.add(AllBlocks.DEPLOYER.get()); } 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 d6bc343a6..9e26b5431 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 @@ -12,24 +12,26 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -40,7 +42,7 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE { if (te.player != null && !isMoving) { @@ -82,17 +84,17 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE { ItemStack heldByDeployer = te.player.getMainHandItem() @@ -101,11 +103,11 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE blockBreakingProgress; ItemStack spawnedItemEffects; - public DeployerFakePlayer(ServerWorld world) { + public DeployerFakePlayer(ServerLevel world) { super(world, DEPLOYER_PROFILE); connection = new FakePlayNetHandler(world.getServer(), this); } @Override - public OptionalInt openMenu(INamedContainerProvider container) { + public OptionalInt openMenu(MenuProvider container) { return OptionalInt.empty(); } @Override - public ITextComponent getDisplayName() { + public Component getDisplayName() { return Lang.translate("block.deployer.damage_source_name"); } @@ -73,8 +73,8 @@ public class DeployerFakePlayer extends FakePlayer { } @Override - public Vector3d position() { - return new Vector3d(getX(), getY(), getZ()); + public Vec3 position() { + return new Vec3(getX(), getY(), getZ()); } @Override @@ -88,7 +88,7 @@ public class DeployerFakePlayer extends FakePlayer { } @Override - public ItemStack eat(World world, ItemStack stack) { + public ItemStack eat(Level world, ItemStack stack) { stack.shrink(1); return stack; } @@ -134,9 +134,9 @@ public class DeployerFakePlayer extends FakePlayer { if (!(event.getTarget() instanceof DeployerFakePlayer)) return; LivingEntity entityLiving = event.getEntityLiving(); - if (!(entityLiving instanceof MobEntity)) + if (!(entityLiving instanceof Mob)) return; - MobEntity mob = (MobEntity) entityLiving; + Mob mob = (Mob) entityLiving; CKinetics.DeployerAggroSetting setting = AllConfigs.SERVER.kinetics.ignoreDeployerAttacks.get(); @@ -145,7 +145,7 @@ public class DeployerFakePlayer extends FakePlayer { mob.setTarget(null); break; case CREEPERS: - if (mob instanceof CreeperEntity) + if (mob instanceof Creeper) mob.setTarget(null); break; case NONE: @@ -153,16 +153,16 @@ public class DeployerFakePlayer extends FakePlayer { } } - private static class FakePlayNetHandler extends ServerPlayNetHandler { - public FakePlayNetHandler(MinecraftServer server, ServerPlayerEntity playerIn) { + private static class FakePlayNetHandler extends ServerGamePacketListenerImpl { + public FakePlayNetHandler(MinecraftServer server, ServerPlayer playerIn) { super(server, NETWORK_MANAGER, playerIn); } @Override - public void send(IPacket packetIn) {} + public void send(Packet packetIn) {} @Override - public void send(IPacket packetIn, + public void send(Packet 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 b65aaff17..005044433 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 @@ -1,22 +1,22 @@ package com.simibubi.create.content.contraptions.components.deployer; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.Vec3; public class DeployerFilterSlot extends ValueBoxTransform { @Override - protected Vector3d getLocalOffset(BlockState state) { + protected Vec3 getLocalOffset(BlockState state) { Direction facing = state.getValue(DeployerBlock.FACING); - Vector3d vec = VecHelper.voxelSpace(8f, 13.5f, 11.5f); + Vec3 vec = VecHelper.voxelSpace(8f, 13.5f, 11.5f); float yRot = AngleHelper.horizontalAngle(facing); float zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; @@ -27,7 +27,7 @@ public class DeployerFilterSlot extends ValueBoxTransform { } @Override - protected void rotate(BlockState state, MatrixStack ms) { + protected void rotate(BlockState state, PoseStack ms) { Direction facing = state.getValue(DeployerBlock.FACING); float xRot = facing == Direction.UP ? 90 : facing == Direction.DOWN ? 270 : 0; float yRot = AngleHelper.horizontalAngle(facing) + 180; 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 60809d55c..14e9b3730 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 @@ -22,51 +22,51 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.AbstractFireBlock; -import net.minecraft.block.BeehiveBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.DoublePlantBlock; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.merchant.villager.AbstractVillagerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.Fluids; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.BucketItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.server.management.PlayerInteractionManager; -import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceContext.BlockMode; -import net.minecraft.util.math.RayTraceContext.FluidMode; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.GameType; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.BaseFireBlock; +import net.minecraft.world.level.block.BeehiveBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DoublePlantBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.npc.AbstractVillager; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerPlayerGameMode; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.GameType; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock; import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; @@ -79,16 +79,16 @@ public class DeployerHandler { private final BlockPos pos; boolean rayMode = false; - private ItemUseWorld(World world, Direction face, BlockPos pos) { + private ItemUseWorld(Level world, Direction face, BlockPos pos) { super(world, world.getChunkSource()); this.face = face; this.pos = pos; } @Override - public BlockRayTraceResult clip(RayTraceContext context) { + public BlockHitResult clip(ClipContext context) { rayMode = true; - BlockRayTraceResult rayTraceBlocks = super.clip(context); + BlockHitResult rayTraceBlocks = super.clip(context); rayMode = false; return rayTraceBlocks; } @@ -104,7 +104,7 @@ public class DeployerHandler { } } - static boolean shouldActivate(ItemStack held, World world, BlockPos targetPos, @Nullable Direction facing) { + static boolean shouldActivate(ItemStack held, Level world, BlockPos targetPos, @Nullable Direction facing) { if (held.getItem() instanceof BlockItem) if (world.getBlockState(targetPos) .getBlock() == ((BlockItem) held.getItem()).getBlock()) @@ -125,10 +125,10 @@ public class DeployerHandler { return true; } - static void activate(DeployerFakePlayer player, Vector3d vec, BlockPos clickedPos, Vector3d extensionVector, + static void activate(DeployerFakePlayer player, Vec3 vec, BlockPos clickedPos, Vec3 extensionVector, Mode mode) { Multimap attributeModifiers = player.getMainHandItem() - .getAttributeModifiers(EquipmentSlotType.MAINHAND); + .getAttributeModifiers(EquipmentSlot.MAINHAND); player.getAttributes() .addTransientAttributeModifiers(attributeModifiers); activateInner(player, vec, clickedPos, extensionVector, mode); @@ -136,22 +136,22 @@ public class DeployerHandler { .addTransientAttributeModifiers(attributeModifiers); } - private static void activateInner(DeployerFakePlayer player, Vector3d vec, BlockPos clickedPos, - Vector3d extensionVector, Mode mode) { + private static void activateInner(DeployerFakePlayer player, Vec3 vec, BlockPos clickedPos, + Vec3 extensionVector, Mode mode) { - Vector3d rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f)); - Vector3d rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f)); + Vec3 rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f)); + Vec3 rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f)); player.setPos(rayOrigin.x, rayOrigin.y, rayOrigin.z); BlockPos pos = new BlockPos(vec); ItemStack stack = player.getMainHandItem(); Item item = stack.getItem(); // Check for entities - final ServerWorld world = player.getLevel(); - List entities = world.getEntitiesOfClass(Entity.class, new AxisAlignedBB(clickedPos)).stream() + final ServerLevel world = player.getLevel(); + List entities = world.getEntitiesOfClass(Entity.class, new AABB(clickedPos)).stream() .filter(e -> !(e instanceof AbstractContraptionEntity)) .collect(Collectors.toList()); - Hand hand = Hand.MAIN_HAND; + InteractionHand hand = InteractionHand.MAIN_HAND; if (!entities.isEmpty()) { Entity entity = entities.get(world.random.nextInt(entities.size())); List capturedDrops = new ArrayList<>(); @@ -160,16 +160,16 @@ public class DeployerHandler { // Use on entity if (mode == Mode.USE) { - ActionResultType cancelResult = ForgeHooks.onInteractEntity(player, entity, hand); - if (cancelResult == ActionResultType.FAIL) { + InteractionResult cancelResult = ForgeHooks.onInteractEntity(player, entity, hand); + if (cancelResult == InteractionResult.FAIL) { entity.captureDrops(null); return; } if (cancelResult == null) { if (entity.interact(player, hand) .consumesAction()){ - if (entity instanceof AbstractVillagerEntity) { - AbstractVillagerEntity villager = ((AbstractVillagerEntity) entity); + if (entity instanceof AbstractVillager) { + AbstractVillager villager = ((AbstractVillager) entity); if (villager.getTradingPlayer() instanceof DeployerFakePlayer) villager.setTradingPlayer(null); } @@ -179,8 +179,8 @@ public class DeployerHandler { .consumesAction()) success = true; } - if (!success && stack.isEdible() && entity instanceof PlayerEntity) { - PlayerEntity playerEntity = (PlayerEntity) entity; + if (!success && stack.isEdible() && entity instanceof Player) { + Player playerEntity = (Player) entity; if (playerEntity.canEat(item.getFoodProperties() .canAlwaysEat())) { playerEntity.eat(world, stack); @@ -204,11 +204,11 @@ public class DeployerHandler { } // Shoot ray - RayTraceContext rayTraceContext = - new RayTraceContext(rayOrigin, rayTarget, BlockMode.OUTLINE, FluidMode.NONE, player); - BlockRayTraceResult result = world.clip(rayTraceContext); + ClipContext rayTraceContext = + new ClipContext(rayOrigin, rayTarget, Block.OUTLINE, Fluid.NONE, player); + BlockHitResult result = world.clip(rayTraceContext); if (result.getBlockPos() != clickedPos) - result = new BlockRayTraceResult(result.getLocation(), result.getDirection(), clickedPos, result.isInside()); + result = new BlockHitResult(result.getLocation(), result.getDirection(), clickedPos, result.isInside()); BlockState clickedState = world.getBlockState(clickedPos); Direction face = result.getDirection(); if (face == null) @@ -241,7 +241,7 @@ public class DeployerHandler { before = blockBreakingProgress.getValue(); progress += before; world.playSound(null, clickedPos, clickedState.getSoundType() - .getHitSound(), SoundCategory.NEUTRAL, .25f, 1); + .getHitSound(), SoundSource.NEUTRAL, .25f, 1); if (progress >= 1) { tryHarvestBlock(player.gameMode, clickedPos); @@ -261,7 +261,7 @@ public class DeployerHandler { } // Right click - ItemUseContext itemusecontext = new ItemUseContext(player, hand, result); + UseOnContext itemusecontext = new UseOnContext(player, hand, result); Event.Result useBlock = DEFAULT; Event.Result useItem = DEFAULT; if (!clickedState.getShape(world, clickedPos) @@ -273,8 +273,8 @@ public class DeployerHandler { // Item has custom active use if (useItem != DENY) { - ActionResultType actionresult = stack.onItemUseFirst(itemusecontext); - if (actionresult != ActionResultType.PASS) + InteractionResult actionresult = stack.onItemUseFirst(itemusecontext); + if (actionresult != InteractionResult.PASS) return; } @@ -293,41 +293,41 @@ public class DeployerHandler { return; if (item instanceof BlockItem && !(item instanceof CartAssemblerBlockItem) - && !clickedState.canBeReplaced(new BlockItemUseContext(itemusecontext))) + && !clickedState.canBeReplaced(new BlockPlaceContext(itemusecontext))) return; // Reposition fire placement for convenience if (item == Items.FLINT_AND_STEEL) { Direction newFace = result.getDirection(); BlockPos newPos = result.getBlockPos(); - if (!AbstractFireBlock.canBePlacedAt(world, clickedPos, newFace)) + if (!BaseFireBlock.canBePlacedAt(world, clickedPos, newFace)) newFace = Direction.UP; if (clickedState.getMaterial() == Material.AIR) newPos = newPos.relative(face.getOpposite()); - result = new BlockRayTraceResult(result.getLocation(), newFace, newPos, result.isInside()); - itemusecontext = new ItemUseContext(player, hand, result); + result = new BlockHitResult(result.getLocation(), newFace, newPos, result.isInside()); + itemusecontext = new UseOnContext(player, hand, result); } // 'Inert' item use behaviour & block placement - ActionResultType onItemUse = stack.useOn(itemusecontext); + InteractionResult onItemUse = stack.useOn(itemusecontext); if (onItemUse.consumesAction()) return; if (item == Items.ENDER_PEARL) return; // buckets create their own ray, We use a fake wall to contain the active area - World itemUseWorld = world; + Level itemUseWorld = world; if (item instanceof BucketItem || item instanceof SandPaperItem) itemUseWorld = new ItemUseWorld(world, face, pos); - ActionResult onItemRightClick = item.use(itemUseWorld, player, hand); + InteractionResultHolder onItemRightClick = item.use(itemUseWorld, player, hand); ItemStack resultStack = onItemRightClick.getObject(); if (resultStack != stack || resultStack.getCount() != stack.getCount() || resultStack.getUseDuration() > 0 || resultStack.getDamageValue() != stack.getDamageValue()) { player.setItemInHand(hand, onItemRightClick.getObject()); } - CompoundNBT tag = stack.getTag(); + CompoundTag tag = stack.getTag(); if (tag != null && stack.getItem() instanceof SandPaperItem && tag.contains("Polishing")) { player.spawnedItemEffects = ItemStack.of(tag.getCompound("Polishing")); AllSoundEvents.AUTO_POLISH.playOnServer(world, pos, .25f, 1f); @@ -340,18 +340,18 @@ public class DeployerHandler { player.stopUsingItem(); } - public static boolean tryHarvestBlock(PlayerInteractionManager interactionManager, BlockPos pos) { + public static boolean tryHarvestBlock(ServerPlayerGameMode interactionManager, BlockPos pos) { // <> PlayerInteractionManager#tryHarvestBlock - ServerWorld world = interactionManager.level; - ServerPlayerEntity player = interactionManager.player; + ServerLevel world = interactionManager.level; + ServerPlayer player = interactionManager.player; BlockState blockstate = world.getBlockState(pos); GameType gameType = interactionManager.getGameModeForPlayer(); if (net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(world, gameType, player, pos) == -1) return false; - TileEntity tileentity = world.getBlockEntity(pos); + BlockEntity tileentity = world.getBlockEntity(pos); if (player.getMainHandItem() .onBlockStartBreak(pos, player)) return false; @@ -364,7 +364,7 @@ public class DeployerHandler { boolean canHarvest = blockstate.canHarvestBlock(world, pos, player); prevHeldItem.mineBlock(world, blockstate, pos, player); if (prevHeldItem.isEmpty() && !heldItem.isEmpty()) - net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, heldItem, Hand.MAIN_HAND); + net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, heldItem, InteractionHand.MAIN_HAND); BlockPos posUp = pos.above(); @@ -393,15 +393,15 @@ public class DeployerHandler { return true; } - public static ActionResultType safeOnUse(BlockState state, World world, BlockPos pos, PlayerEntity player, - Hand hand, BlockRayTraceResult ray) { + public static InteractionResult safeOnUse(BlockState state, Level world, BlockPos pos, Player player, + InteractionHand hand, BlockHitResult ray) { if (state.getBlock() instanceof BeehiveBlock) return safeOnBeehiveUse(state, world, pos, player, hand); return state.use(world, player, hand, ray); } - protected static ActionResultType safeOnBeehiveUse(BlockState state, World world, BlockPos pos, PlayerEntity player, - Hand hand) { + protected static InteractionResult safeOnBeehiveUse(BlockState state, Level world, BlockPos pos, Player player, + InteractionHand hand) { // <> BeehiveBlock#onUse BeehiveBlock block = (BeehiveBlock) state.getBlock(); @@ -409,11 +409,11 @@ public class DeployerHandler { int honeyLevel = state.getValue(BeehiveBlock.HONEY_LEVEL); boolean success = false; if (honeyLevel < 5) - return ActionResultType.PASS; + return InteractionResult.PASS; if (prevHeldItem.getItem() == Items.SHEARS) { world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, - SoundCategory.NEUTRAL, 1.0F, 1.0F); + SoundSource.NEUTRAL, 1.0F, 1.0F); // <> BeehiveBlock#dropHoneycomb player.inventory.placeItemBackInInventory(world, new ItemStack(Items.HONEYCOMB, 3)); prevHeldItem.hurtAndBreak(1, player, s -> s.broadcastBreakEvent(hand)); @@ -423,7 +423,7 @@ public class DeployerHandler { if (prevHeldItem.getItem() == Items.GLASS_BOTTLE) { prevHeldItem.shrink(1); world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL, - SoundCategory.NEUTRAL, 1.0F, 1.0F); + SoundSource.NEUTRAL, 1.0F, 1.0F); ItemStack honeyBottle = new ItemStack(Items.HONEY_BOTTLE); if (prevHeldItem.isEmpty()) player.setItemInHand(hand, honeyBottle); @@ -433,10 +433,10 @@ public class DeployerHandler { } if (!success) - return ActionResultType.PASS; + return InteractionResult.PASS; block.resetHoneyLevel(world, state, pos); - return ActionResultType.SUCCESS; + return InteractionResult.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 7d5e5474d..b115edda8 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 @@ -14,12 +14,14 @@ import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import net.minecraft.util.math.vector.Quaternion; import net.minecraft.util.math.vector.Vector3i; +import OrientedData; + public class DeployerInstance extends ShaftInstance implements IDynamicInstance, ITickableInstance { final DeployerTileEntity tile; @@ -68,7 +70,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, float newProgress = getProgress(AnimationTickHolder.getPartialTicks()); - if (!newHand && MathHelper.equal(newProgress, progress)) return; + if (!newHand && Mth.equal(newProgress, progress)) return; progress = newProgress; newHand = false; 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 55dfa8d48..f09e04a8b 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 @@ -4,8 +4,8 @@ import java.util.Iterator; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; @@ -40,7 +40,7 @@ public class DeployerItemHandler implements IItemHandlerModifiable { return; if (te.getLevel().isClientSide) return; - player.setItemInHand(Hand.MAIN_HAND, stack); + player.setItemInHand(InteractionHand.MAIN_HAND, stack); te.setChanged(); te.sendData(); } 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 94563e986..e8027eeb4 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 @@ -29,19 +29,19 @@ import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTProcessors; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.event.ForgeEventFactory; @@ -50,8 +50,8 @@ import net.minecraftforge.items.IItemHandler; public class DeployerMovementBehaviour extends MovementBehaviour { @Override - public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.atLowerCornerOf(context.state.getValue(DeployerBlock.FACING) + public Vec3 getActiveAreaOffset(MovementContext context) { + return Vec3.atLowerCornerOf(context.state.getValue(DeployerBlock.FACING) .getNormal()) .scale(2); } @@ -73,16 +73,16 @@ public class DeployerMovementBehaviour extends MovementBehaviour { } public void activate(MovementContext context, BlockPos pos, DeployerFakePlayer player, Mode mode) { - World world = context.world; + Level world = context.world; ItemStack filter = getFilter(context); if (AllItems.SCHEMATIC.isIn(filter)) activateAsSchematicPrinter(context, pos, player, world, filter); - Vector3d facingVec = Vector3d.atLowerCornerOf(context.state.getValue(DeployerBlock.FACING) + Vec3 facingVec = Vec3.atLowerCornerOf(context.state.getValue(DeployerBlock.FACING) .getNormal()); facingVec = context.rotation.apply(facingVec); - Vector3d vec = context.position.subtract(facingVec.scale(2)); + Vec3 vec = context.position.subtract(facingVec.scale(2)); player.yRot = AbstractContraptionEntity.yawFromVector(facingVec); player.xRot = AbstractContraptionEntity.pitchFromVector(facingVec) - 90; @@ -90,7 +90,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { } protected void activateAsSchematicPrinter(MovementContext context, BlockPos pos, DeployerFakePlayer player, - World world, ItemStack filter) { + Level world, ItemStack filter) { if (!filter.hasTag()) return; if (!world.getBlockState(pos) @@ -98,7 +98,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { .isReplaceable()) return; - CompoundNBT tag = filter.getTag(); + CompoundTag tag = filter.getTag(); if (!tag.getBoolean("Deployed")) return; SchematicWorld schematicWorld = SchematicInstances.get(world, filter); @@ -132,11 +132,11 @@ public class DeployerMovementBehaviour extends MovementBehaviour { required.item.getCount(), false); } - CompoundNBT data = null; + CompoundTag data = null; if (AllBlockTags.SAFE_NBT.matches(blockState)) { - TileEntity tile = schematicWorld.getBlockEntity(pos); + BlockEntity tile = schematicWorld.getBlockEntity(pos); if (tile != null) { - data = tile.save(new CompoundNBT()); + data = tile.save(new CompoundTag()); data = NBTProcessors.process(tile, data, true); } } @@ -183,7 +183,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { if (player == null) return; - context.tileData.put("Inventory", player.inventory.save(new ListNBT())); + context.tileData.put("Inventory", player.inventory.save(new ListTag())); player.remove(); } @@ -198,7 +198,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { return; ItemStack held = ItemHelper.extract(context.contraption.inventory, stack -> FilterItem.test(context.world, stack, filter), 1, false); - player.setItemInHand(Hand.MAIN_HAND, held); + player.setItemInHand(InteractionHand.MAIN_HAND, held); } } @@ -206,7 +206,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { DeployerFakePlayer player = getPlayer(context); if (player == null) return; - PlayerInventory inv = player.inventory; + Inventory inv = player.inventory; ItemStack filter = getFilter(context); for (List list : Arrays.asList(inv.armor, inv.offhand, inv.items)) { @@ -235,11 +235,11 @@ public class DeployerMovementBehaviour extends MovementBehaviour { } private DeployerFakePlayer getPlayer(MovementContext context) { - if (!(context.temporaryData instanceof DeployerFakePlayer) && context.world instanceof ServerWorld) { - DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerWorld) context.world); + if (!(context.temporaryData instanceof DeployerFakePlayer) && context.world instanceof ServerLevel) { + DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) context.world); deployerFakePlayer.inventory.load(context.tileData.getList("Inventory", NBT.TAG_COMPOUND)); if (context.data.contains("HeldItem")) - deployerFakePlayer.setItemInHand(Hand.MAIN_HAND, ItemStack.of(context.data.getCompound("HeldItem"))); + deployerFakePlayer.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.of(context.data.getCompound("HeldItem"))); context.tileData.remove("Inventory"); context.temporaryData = deployerFakePlayer; } @@ -256,7 +256,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { @Override public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - ContraptionMatrices matrices, IRenderTypeBuffer buffers) { + ContraptionMatrices matrices, MultiBufferSource buffers) { if (!Backend.getInstance().canUseInstancing()) DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovingInteraction.java index c942df926..d5fca0e0b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovingInteraction.java @@ -8,27 +8,27 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.MovingInteractionBehaviour; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.util.Constants; public class DeployerMovingInteraction extends MovingInteractionBehaviour { @Override - public boolean handlePlayerInteraction(PlayerEntity player, Hand activeHand, BlockPos localPos, + public boolean handlePlayerInteraction(Player player, InteractionHand activeHand, BlockPos localPos, AbstractContraptionEntity contraptionEntity) { - BlockInfo info = contraptionEntity.getContraption() + StructureBlockInfo info = contraptionEntity.getContraption() .getBlocks() .get(localPos); if (info == null) return false; MovementContext ctx = null; int index = -1; - for (MutablePair pair : contraptionEntity.getContraption() + for (MutablePair pair : contraptionEntity.getContraption() .getActors()) { if (info.equals(pair.left)) { ctx = pair.right; @@ -53,8 +53,8 @@ public class DeployerMovingInteraction extends MovingInteractionBehaviour { return true; // we'll try again on the server side DeployerFakePlayer fake = null; - if (!(ctx.temporaryData instanceof DeployerFakePlayer) && ctx.world instanceof ServerWorld) { - DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerWorld) ctx.world); + if (!(ctx.temporaryData instanceof DeployerFakePlayer) && ctx.world instanceof ServerLevel) { + DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) ctx.world); deployerFakePlayer.inventory.load(ctx.tileData.getList("Inventory", Constants.NBT.TAG_COMPOUND)); ctx.temporaryData = fake = deployerFakePlayer; ctx.tileData.remove("Inventory"); @@ -66,7 +66,7 @@ public class DeployerMovingInteraction extends MovingInteractionBehaviour { ItemStack deployerItem = fake.getMainHandItem(); player.setItemInHand(activeHand, deployerItem.copy()); - fake.setItemInHand(Hand.MAIN_HAND, heldStack.copy()); + fake.setItemInHand(InteractionHand.MAIN_HAND, heldStack.copy()); ctx.tileData.put("HeldItem", heldStack.serializeNBT()); ctx.data.put("HeldItem", heldStack.serializeNBT()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRecipeSearchEvent.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRecipeSearchEvent.java index 0b204fc4f..e1c6db1fa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRecipeSearchEvent.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRecipeSearchEvent.java @@ -5,8 +5,8 @@ import java.util.function.Supplier; import javax.annotation.Nullable; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.Container; +import net.minecraft.world.item.crafting.Recipe; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.items.wrapper.RecipeWrapper; @@ -14,7 +14,7 @@ public class DeployerRecipeSearchEvent extends Event { private final DeployerTileEntity tileEntity; private final RecipeWrapper inventory; @Nullable - IRecipe recipe = null; + Recipe recipe = null; private int maxPriority = 0; public DeployerRecipeSearchEvent(DeployerTileEntity tileEntity, RecipeWrapper inventory) { @@ -41,13 +41,13 @@ public class DeployerRecipeSearchEvent extends Event { } @Nullable - public IRecipe getRecipe() { + public Recipe getRecipe() { if (isCanceled()) return null; return recipe; } - public void addRecipe(Supplier>> recipeSupplier, int priority) { + public void addRecipe(Supplier>> recipeSupplier, int priority) { if (!shouldAddRecipeWithPriority(priority)) return; recipeSupplier.get().ifPresent(newRecipe -> { 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 03c0d1ffc..9486f1714 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 @@ -5,8 +5,8 @@ import static com.simibubi.create.content.contraptions.base.DirectionalKineticBl import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -24,29 +24,29 @@ import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.item.BlockItem; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.item.BlockItem; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; public class DeployerRenderer extends SafeTileEntityRenderer { - public DeployerRenderer(TileEntityRendererDispatcher dispatcher) { + public DeployerRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(DeployerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { renderItem(te, partialTicks, ms, buffer, light, overlay); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); @@ -56,13 +56,13 @@ public class DeployerRenderer extends SafeTileEntityRenderer renderComponents(te, partialTicks, ms, buffer, light, overlay); } - protected void renderItem(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderItem(DeployerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (te.heldItem.isEmpty()) return; BlockState deployerState = te.getBlockState(); - Vector3d offset = getHandOffset(te, partialTicks, deployerState).add(VecHelper.getCenterOf(BlockPos.ZERO)); + Vec3 offset = getHandOffset(te, partialTicks, deployerState).add(VecHelper.getCenterOf(BlockPos.ZERO)); ms.pushPose(); ms.translate(offset.x, offset.y, offset.z); @@ -107,15 +107,15 @@ public class DeployerRenderer extends SafeTileEntityRenderer ms.popPose(); } - protected void renderComponents(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderComponents(DeployerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); if (!Backend.getInstance().canUseInstancing(te.getLevel())) { KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light); } BlockState blockState = te.getBlockState(); - Vector3d offset = getHandOffset(te, partialTicks, blockState); + Vec3 offset = getHandOffset(te, partialTicks, blockState); SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState); @@ -128,9 +128,9 @@ public class DeployerRenderer extends SafeTileEntityRenderer .renderInto(ms, vb); } - protected Vector3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) { + protected Vec3 getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) { float distance = te.getHandOffset(partialTicks); - return Vector3d.atLowerCornerOf(blockState.getValue(FACING).getNormal()).scale(distance); + return Vec3.atLowerCornerOf(blockState.getValue(FACING).getNormal()).scale(distance); } protected BlockState getRenderedBlockState(KineticTileEntity te) { @@ -153,8 +153,8 @@ public class DeployerRenderer extends SafeTileEntityRenderer } public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - ContraptionMatrices matrices, IRenderTypeBuffer buffer) { - IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); + ContraptionMatrices matrices, MultiBufferSource buffer) { + VertexConsumer builder = buffer.getBuffer(RenderType.solid()); BlockState blockState = context.state; Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class); PartialModel handPose = getHandPose(mode); @@ -164,19 +164,19 @@ public class DeployerRenderer extends SafeTileEntityRenderer double factor; if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) { - factor = MathHelper.sin(AnimationTickHolder.getRenderTime() * .5f) * .25f + .25f; + factor = Mth.sin(AnimationTickHolder.getRenderTime() * .5f) * .25f + .25f; } else { - Vector3d center = VecHelper.getCenterOf(new BlockPos(context.position)); + Vec3 center = VecHelper.getCenterOf(new BlockPos(context.position)); double distance = context.position.distanceTo(center); double nextDistance = context.position.add(context.motion) .distanceTo(center); - factor = .5f - MathHelper.clamp(MathHelper.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1); + factor = .5f - Mth.clamp(Mth.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1); } - Vector3d offset = Vector3d.atLowerCornerOf(blockState.getValue(FACING) + Vec3 offset = Vec3.atLowerCornerOf(blockState.getValue(FACING) .getNormal()).scale(factor); - MatrixStack m = matrices.getModel(); + PoseStack m = matrices.getModel(); m.pushPose(); m.translate(offset.x, offset.y, offset.z); 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 22e7c28e7..2d5fac280 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 @@ -25,27 +25,27 @@ import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceContext.BlockMode; -import net.minecraft.util.math.RayTraceContext.FluidMode; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.Constants.NBT; @@ -67,7 +67,7 @@ public class DeployerTileEntity extends KineticTileEntity { protected FilteringBehaviour filtering; protected boolean redstoneLocked; private LazyOptional invHandler; - private ListNBT deferredInventoryList; + private ListTag deferredInventoryList; private LerpedFloat animatedOffset; @@ -81,7 +81,7 @@ public class DeployerTileEntity extends KineticTileEntity { PUNCH, USE } - public DeployerTileEntity(TileEntityType type) { + public DeployerTileEntity(BlockEntityType type) { super(type); state = State.WAITING; mode = Mode.USE; @@ -106,27 +106,27 @@ public class DeployerTileEntity extends KineticTileEntity { public void initialize() { super.initialize(); if (!level.isClientSide) { - player = new DeployerFakePlayer((ServerWorld) level); + player = new DeployerFakePlayer((ServerLevel) level); if (deferredInventoryList != null) { player.inventory.load(deferredInventoryList); deferredInventoryList = null; heldItem = player.getMainHandItem(); sendData(); } - Vector3d initialPos = VecHelper.getCenterOf(worldPosition.relative(getBlockState().getValue(FACING))); + Vec3 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.setItemInHand(Hand.MAIN_HAND, stack.copy()); + player.setItemInHand(InteractionHand.MAIN_HAND, stack.copy()); sendData(); setChanged(); } protected int getTimerSpeed() { - return (int) (getSpeed() == 0 ? 0 : MathHelper.clamp(Math.abs(getSpeed() * 2), 8, 512)); + return (int) (getSpeed() == 0 ? 0 : Mth.clamp(Math.abs(getSpeed() * 2), 8, 512)); } @Override @@ -213,14 +213,14 @@ public class DeployerTileEntity extends KineticTileEntity { protected void start() { state = State.EXPANDING; - Vector3d movementVector = getMovementVector(); - Vector3d rayOrigin = VecHelper.getCenterOf(worldPosition) + Vec3 movementVector = getMovementVector(); + Vec3 rayOrigin = VecHelper.getCenterOf(worldPosition) .add(movementVector.scale(3 / 2f)); - Vector3d rayTarget = VecHelper.getCenterOf(worldPosition) + Vec3 rayTarget = VecHelper.getCenterOf(worldPosition) .add(movementVector.scale(5 / 2f)); - RayTraceContext rayTraceContext = - new RayTraceContext(rayOrigin, rayTarget, BlockMode.OUTLINE, FluidMode.NONE, player); - BlockRayTraceResult result = level.clip(rayTraceContext); + ClipContext rayTraceContext = + new ClipContext(rayOrigin, rayTarget, Block.OUTLINE, Fluid.NONE, player); + BlockHitResult result = level.clip(rayTraceContext); reach = (float) (.5f + Math.min(result.getLocation() .subtract(rayOrigin) .length(), .75f)); @@ -234,7 +234,7 @@ public class DeployerTileEntity extends KineticTileEntity { BlockPos otherDeployer = worldPosition.relative(facing, 4); if (!level.isLoaded(otherDeployer)) return false; - TileEntity otherTile = level.getBlockEntity(otherDeployer); + BlockEntity otherTile = level.getBlockEntity(otherDeployer); if (!(otherTile instanceof DeployerTileEntity)) return false; DeployerTileEntity deployerTile = (DeployerTileEntity) otherTile; @@ -252,7 +252,7 @@ public class DeployerTileEntity extends KineticTileEntity { } public void triggerBoop() { - TileEntity otherTile = level.getBlockEntity(worldPosition.relative(getBlockState().getValue(FACING), 4)); + BlockEntity otherTile = level.getBlockEntity(worldPosition.relative(getBlockState().getValue(FACING), 4)); if (!(otherTile instanceof DeployerTileEntity)) return; @@ -270,15 +270,15 @@ public class DeployerTileEntity extends KineticTileEntity { deployerTile.sendData(); // award nearby players - List players = - level.getEntitiesOfClass(ServerPlayerEntity.class, new AxisAlignedBB(worldPosition).inflate(9)); + List players = + level.getEntitiesOfClass(ServerPlayer.class, new AABB(worldPosition).inflate(9)); players.forEach(AllTriggers.DEPLOYER_BOOP::trigger); } protected void activate() { - Vector3d movementVector = getMovementVector(); + Vec3 movementVector = getMovementVector(); Direction direction = getBlockState().getValue(FACING); - Vector3d center = VecHelper.getCenterOf(worldPosition); + Vec3 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; @@ -292,15 +292,15 @@ public class DeployerTileEntity extends KineticTileEntity { heldItem = player.getMainHandItem(); } - protected Vector3d getMovementVector() { + protected Vec3 getMovementVector() { if (!AllBlocks.DEPLOYER.has(getBlockState())) - return Vector3d.ZERO; - return Vector3d.atLowerCornerOf(getBlockState().getValue(FACING) + return Vec3.ZERO; + return Vec3.atLowerCornerOf(getBlockState().getValue(FACING) .getNormal()); } @Override - protected void fromTag(BlockState blockState, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState blockState, CompoundTag compound, boolean clientPacket) { state = NBTHelper.readEnum(compound, "State", State.class); mode = NBTHelper.readEnum(compound, "Mode", Mode.class); timer = compound.getInt("Timer"); @@ -323,14 +323,14 @@ public class DeployerTileEntity extends KineticTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { NBTHelper.writeEnum(compound, "Mode", mode); NBTHelper.writeEnum(compound, "State", state); compound.putInt("Timer", timer); compound.putBoolean("Powered", redstoneLocked); if (player != null) { - ListNBT invNBT = new ListNBT(); + ListTag invNBT = new ListTag(); player.inventory.save(invNBT); compound.put("Inventory", invNBT); compound.put("HeldItem", player.getMainHandItem().serializeNBT()); @@ -374,7 +374,7 @@ public class DeployerTileEntity extends KineticTileEntity { } @Override - public AxisAlignedBB makeRenderBoundingBox() { + public AABB makeRenderBoundingBox() { return super.makeRenderBoundingBox().inflate(3); } @@ -399,7 +399,7 @@ public class DeployerTileEntity extends KineticTileEntity { } @Override - public boolean addToTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToTooltip(List tooltip, boolean isPlayerSneaking) { if (super.addToTooltip(tooltip, isPlayerSneaking)) return true; if (getSpeed() == 0) @@ -429,7 +429,7 @@ public class DeployerTileEntity extends KineticTileEntity { progress = (timer - partialTicks * timerSpeed) / 1000f; float handLength = handPose == AllBlockPartials.DEPLOYER_HAND_POINTING ? 0 : handPose == AllBlockPartials.DEPLOYER_HAND_HOLDING ? 4 / 16f : 3 / 16f; - float distance = Math.min(MathHelper.clamp(progress, 0, 1) * (reach + handLength), 21 / 16f); + float distance = Math.min(Mth.clamp(progress, 0, 1) * (reach + handLength), 21 / 16f); return distance; } @@ -442,7 +442,7 @@ public class DeployerTileEntity extends KineticTileEntity { SandPaperInv sandpaperInv = new SandPaperInv(ItemStack.EMPTY); @Nullable - public IRecipe getRecipe(ItemStack stack) { + public Recipe getRecipe(ItemStack stack) { // safety checks if (player == null || level == null) return 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 97f522e18..eed778872 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 @@ -18,28 +18,28 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.monster.EndermanEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.world.World; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; @@ -52,7 +52,7 @@ public class AirCurrent { .setIsFire(); public final IAirCurrentSource source; - public AxisAlignedBB bounds = new AxisAlignedBB(0, 0, 0, 0, 0, 0); + public AABB bounds = new AABB(0, 0, 0, 0, 0, 0); public List segments = new ArrayList<>(); public Direction direction; public boolean pushing; @@ -71,12 +71,12 @@ public class AirCurrent { public void tick() { if (direction == null) rebuild(); - World world = source.getAirCurrentWorld(); + Level world = source.getAirCurrentWorld(); Direction facing = direction; if (world != null && world.isClientSide) { float offset = pushing ? 0.5f : maxDistance + .5f; - Vector3d pos = VecHelper.getCenterOf(source.getAirCurrentPos()) - .add(Vector3d.atLowerCornerOf(facing.getNormal()) + Vec3 pos = VecHelper.getCenterOf(source.getAirCurrentPos()) + .add(Vec3.atLowerCornerOf(facing.getNormal()) .scale(offset)); if (world.random.nextFloat() < AllConfigs.CLIENT.fanParticleDensity.get()) world.addParticle(new AirFlowParticleData(source.getAirCurrentPos()), pos.x, pos.y, pos.z, 0, 0, 0); @@ -86,7 +86,7 @@ public class AirCurrent { tickAffectedHandlers(); } - protected void tickAffectedEntities(World world, Direction facing) { + protected void tickAffectedEntities(Level world, Direction facing) { for (Iterator iterator = caughtEntities.iterator(); iterator.hasNext();) { Entity entity = iterator.next(); if (!entity.isAlive() || !entity.getBoundingBox().intersects(bounds) || isPlayerCreativeFlying(entity)) { @@ -94,37 +94,37 @@ public class AirCurrent { continue; } - Vector3d center = VecHelper.getCenterOf(source.getAirCurrentPos()); - Vector3i flow = (pushing ? facing : facing.getOpposite()).getNormal(); + Vec3 center = VecHelper.getCenterOf(source.getAirCurrentPos()); + Vec3i flow = (pushing ? facing : facing.getOpposite()).getNormal(); float sneakModifier = entity.isShiftKeyDown() ? 4096f : 512f; float speed = Math.abs(source.getSpeed()); double entityDistance = entity.position() .distanceTo(center); float acceleration = (float) (speed / sneakModifier / (entityDistance / maxDistance)); - Vector3d previousMotion = entity.getDeltaMovement(); + Vec3 previousMotion = entity.getDeltaMovement(); float maxAcceleration = 5; double xIn = - MathHelper.clamp(flow.getX() * acceleration - previousMotion.x, -maxAcceleration, maxAcceleration); + Mth.clamp(flow.getX() * acceleration - previousMotion.x, -maxAcceleration, maxAcceleration); double yIn = - MathHelper.clamp(flow.getY() * acceleration - previousMotion.y, -maxAcceleration, maxAcceleration); + Mth.clamp(flow.getY() * acceleration - previousMotion.y, -maxAcceleration, maxAcceleration); double zIn = - MathHelper.clamp(flow.getZ() * acceleration - previousMotion.z, -maxAcceleration, maxAcceleration); + Mth.clamp(flow.getZ() * acceleration - previousMotion.z, -maxAcceleration, maxAcceleration); - entity.setDeltaMovement(previousMotion.add(new Vector3d(xIn, yIn, zIn).scale(1 / 8f))); + entity.setDeltaMovement(previousMotion.add(new Vec3(xIn, yIn, zIn).scale(1 / 8f))); entity.fallDistance = 0; DistExecutor.unsafeRunWhenOn(Dist.CLIENT, - () -> () -> enableClientPlayerSound(entity, MathHelper.clamp(speed / 128f * .4f, 0.01f, .4f))); + () -> () -> enableClientPlayerSound(entity, Mth.clamp(speed / 128f * .4f, 0.01f, .4f))); - if (entity instanceof ServerPlayerEntity) - ((ServerPlayerEntity) entity).connection.aboveGroundTickCount = 0; + if (entity instanceof ServerPlayer) + ((ServerPlayer) entity).connection.aboveGroundTickCount = 0; entityDistance -= .5f; InWorldProcessing.Type processingType = getSegmentAt((float) entityDistance); - if (entity instanceof ServerPlayerEntity) + if (entity instanceof ServerPlayer) AllTriggers.triggerFor(AllTriggers.FAN_PROCESSING.constructTriggerFor(processingType), - (PlayerEntity) entity); + (Player) entity); if (processingType == null || processingType == Type.NONE) { continue; @@ -157,7 +157,7 @@ public class AirCurrent { } break; case SPLASHING: - if (entity instanceof EndermanEntity || entity.getType() == EntityType.SNOW_GOLEM + if (entity instanceof EnderMan || entity.getType() == EntityType.SNOW_GOLEM || entity.getType() == EntityType.BLAZE) { entity.hurt(DamageSource.DROWN, 2); } @@ -165,7 +165,7 @@ public class AirCurrent { break; 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); + SoundSource.NEUTRAL, 0.7F, 1.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.4F); break; default: break; @@ -178,7 +178,7 @@ public class AirCurrent { if (source.getSpeed() == 0) { maxDistance = 0; segments.clear(); - bounds = new AxisAlignedBB(0, 0, 0, 0, 0, 0); + bounds = new AABB(0, 0, 0, 0, 0, 0); return; } @@ -186,11 +186,11 @@ public class AirCurrent { pushing = source.getAirFlowDirection() == direction; maxDistance = source.getMaxDistance(); - World world = source.getAirCurrentWorld(); + Level world = source.getAirCurrentWorld(); BlockPos start = source.getAirCurrentPos(); float max = this.maxDistance; Direction facing = direction; - Vector3d directionVec = Vector3d.atLowerCornerOf(facing.getNormal()); + Vec3 directionVec = Vec3.atLowerCornerOf(facing.getNormal()); maxDistance = getFlowLimit(world, start, max, facing); // Determine segments with transported fluids/gases @@ -223,27 +223,27 @@ public class AirCurrent { // Build Bounding Box if (maxDistance < 0.25f) - bounds = new AxisAlignedBB(0, 0, 0, 0, 0, 0); + bounds = new AABB(0, 0, 0, 0, 0, 0); else { float factor = maxDistance - 1; - Vector3d scale = directionVec.scale(factor); + Vec3 scale = directionVec.scale(factor); if (factor > 0) - bounds = new AxisAlignedBB(start.relative(direction)).expandTowards(scale); + bounds = new AABB(start.relative(direction)).expandTowards(scale); else { - bounds = new AxisAlignedBB(start.relative(direction)).contract(scale.x, scale.y, scale.z) + bounds = new AABB(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.atLowerCornerOf(facing.getNormal()); - Vector3d planeVec = VecHelper.axisAlingedPlaneOf(directionVec); + public static float getFlowLimit(Level world, BlockPos start, float max, Direction facing) { + Vec3 directionVec = Vec3.atLowerCornerOf(facing.getNormal()); + Vec3 planeVec = VecHelper.axisAlingedPlaneOf(directionVec); // 4 Rays test for holes in the shapes blocking the flow float offsetDistance = .25f; - Vector3d[] offsets = new Vector3d[] { planeVec.multiply(offsetDistance, offsetDistance, offsetDistance), + Vec3[] offsets = new Vec3[] { planeVec.multiply(offsetDistance, offsetDistance, offsetDistance), planeVec.multiply(-offsetDistance, -offsetDistance, offsetDistance), planeVec.multiply(offsetDistance, -offsetDistance, -offsetDistance), planeVec.multiply(-offsetDistance, offsetDistance, -offsetDistance), }; @@ -258,20 +258,20 @@ public class AirCurrent { BlockState state = world.getBlockState(currentPos); if (shouldAlwaysPass(state)) continue; - VoxelShape voxelshape = state.getCollisionShape(world, currentPos, ISelectionContext.empty()); + VoxelShape voxelshape = state.getCollisionShape(world, currentPos, CollisionContext.empty()); if (voxelshape.isEmpty()) continue; - if (voxelshape == VoxelShapes.block()) { + if (voxelshape == Shapes.block()) { max = i - 1; break; } - for (Vector3d offset : offsets) { - Vector3d rayStart = VecHelper.getCenterOf(currentPos) + for (Vec3 offset : offsets) { + Vec3 rayStart = VecHelper.getCenterOf(currentPos) .subtract(directionVec.scale(.5f + 1 / 32f)) .add(offset); - Vector3d rayEnd = rayStart.add(directionVec.scale(1 + 1 / 32f)); - BlockRayTraceResult blockraytraceresult = + Vec3 rayEnd = rayStart.add(directionVec.scale(1 + 1 / 32f)); + BlockHitResult blockraytraceresult = world.clipWithInteractionOverride(rayStart, rayEnd, currentPos, voxelshape, state); if (blockraytraceresult == null) continue Outer; @@ -295,7 +295,7 @@ public class AirCurrent { } public void findAffectedHandlers() { - World world = source.getAirCurrentWorld(); + Level world = source.getAirCurrentWorld(); BlockPos start = source.getAirCurrentPos(); affectedItemHandlers.clear(); for (int i = 0; i < maxDistance + 1; i++) { @@ -320,7 +320,7 @@ public class AirCurrent { public void tickAffectedHandlers() { for (Pair pair : affectedItemHandlers) { TransportedItemStackHandlerBehaviour handler = pair.getKey(); - World world = handler.getWorld(); + Level world = handler.getWorld(); InWorldProcessing.Type processingType = pair.getRight(); handler.handleProcessingOnAllItems((transported) -> { @@ -365,7 +365,7 @@ public class AirCurrent { isClientPlayerInAirCurrent = true; - float pitch = (float) MathHelper.clamp(e.getDeltaMovement() + float pitch = (float) Mth.clamp(e.getDeltaMovement() .length() * .5f, .5f, 2f); if (flyingSound == null || flyingSound.isStopped()) { @@ -389,8 +389,8 @@ public class AirCurrent { } public static boolean isPlayerCreativeFlying(Entity entity) { - if (entity instanceof PlayerEntity) { - PlayerEntity player = (PlayerEntity) entity; + if (entity instanceof Player) { + Player player = (Player) entity; 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 72a39910b..1bc4064da 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 @@ -1,15 +1,15 @@ package com.simibubi.create.content.contraptions.components.fan; -import net.minecraft.client.audio.TickableSound; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; +import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; -public class AirCurrentSound extends TickableSound { +public class AirCurrentSound extends AbstractTickableSoundInstance { private float pitch; protected AirCurrentSound(SoundEvent p_i46532_1_, float pitch) { - super(p_i46532_1_, SoundCategory.BLOCKS); + super(p_i46532_1_, SoundSource.BLOCKS); this.pitch = pitch; volume = 0.01f; looping = true; 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 6cd3cc491..6c1c22c78 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 @@ -6,18 +6,20 @@ import com.simibubi.create.content.logistics.block.chute.AbstractChuteBlock; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class EncasedFanBlock extends DirectionalKineticBlock implements ITE { @@ -26,24 +28,24 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements ITE te.queueGeneratorUpdate()); } - protected void notifyFanTile(IWorld world, BlockPos pos) { + protected void notifyFanTile(LevelAccessor world, BlockPos pos) { withTileEntityDo(world, pos, EncasedFanTileEntity::blockInFrontChanged); } @Override - public BlockState updateAfterWrenched(BlockState newState, ItemUseContext context) { + public BlockState updateAfterWrenched(BlockState newState, UseOnContext context) { blockUpdate(newState, context.getLevel(), context.getClickedPos()); return newState; } @@ -102,7 +104,7 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements ITE 0) - speed = MathHelper.clamp(speed, 80, 64 * 20); + speed = Mth.clamp(speed, 80, 64 * 20); if (speed < 0) - speed = MathHelper.clamp(speed, -64 * 20, -80); + speed = Mth.clamp(speed, -64 * 20, -80); float angle = (time * speed * 3 / 10f) % 360; angle = angle / 180f * (float) Math.PI; 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 fc1730c97..1e46f9f89 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 @@ -10,14 +10,14 @@ import com.simibubi.create.content.logistics.block.chute.ChuteTileEntity; import com.simibubi.create.foundation.config.AllConfigs; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; @MethodsReturnNonnullByDefault public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements IAirCurrentSource { @@ -29,7 +29,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements protected boolean updateAirFlow; protected boolean updateGenerator; - public EncasedFanTileEntity(TileEntityType type) { + public EncasedFanTileEntity(BlockEntityType type) { super(type); isGenerator = false; airCurrent = new AirCurrent(this); @@ -38,7 +38,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); if (!wasMoved) isGenerator = compound.getBoolean("Generating"); @@ -47,7 +47,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("Generating", isGenerator); super.write(compound, clientPacket); } @@ -116,7 +116,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements @Nullable @Override - public World getAirCurrentWorld() { + public Level getAirCurrentWorld() { return level; } @@ -158,7 +158,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements if (!direction.getAxis() .isVertical()) return; - TileEntity poweredChute = level.getBlockEntity(worldPosition.relative(direction)); + BlockEntity poweredChute = level.getBlockEntity(worldPosition.relative(direction)); if (!(poweredChute instanceof ChuteTileEntity)) return; ChuteTileEntity chuteTE = (ChuteTileEntity) poweredChute; 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 2ae33df60..b18361921 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 @@ -2,7 +2,12 @@ package com.simibubi.create.content.contraptions.components.fan; import static net.minecraft.state.properties.BlockStateProperties.FACING; -import com.jozufozu.flywheel.backend.material.MaterialManager; +import com.net.minimport com.jozufozu.flywheel.backend.material.MaterialManager; +import com.simibubi.create.content.contraptions.base.KineticTileInstance; +import com.simibubi.create.content.contraptions.base.RotatingData; +import net.minecraft.core.Direction; + +ecraft.world.level.block.state.properties.BlockStateProperties import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.RotatingData; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/IAirCurrentSource.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/IAirCurrentSource.java index bee9d4852..2a7f25eea 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/IAirCurrentSource.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/IAirCurrentSource.java @@ -6,10 +6,10 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.CKinetics; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; @MethodsReturnNonnullByDefault public interface IAirCurrentSource { @@ -17,7 +17,7 @@ public interface IAirCurrentSource { AirCurrent getAirCurrent(); @Nullable - World getAirCurrentWorld(); + Level getAirCurrentWorld(); BlockPos getAirCurrentPos(); @@ -32,8 +32,8 @@ public interface IAirCurrentSource { float speed = Math.abs(this.getSpeed()); CKinetics config = AllConfigs.SERVER.kinetics; float distanceFactor = Math.min(speed / config.fanRotationArgmax.get(), 1); - float pushDistance = MathHelper.lerp(distanceFactor, 3, config.fanPushDistance.get()); - float pullDistance = MathHelper.lerp(distanceFactor, 3f, config.fanPullDistance.get()); + float pushDistance = Mth.lerp(distanceFactor, 3, config.fanPushDistance.get()); + float pullDistance = Mth.lerp(distanceFactor, 3f, config.fanPullDistance.get()); return this.getSpeed() > 0 ? pushDistance : pullDistance; } 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 f37c808c2..4f17b3770 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 @@ -7,20 +7,22 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault @@ -36,27 +38,27 @@ public class NozzleBlock extends WrenchableDirectionalBlock { } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - return ActionResultType.FAIL; + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + return InteractionResult.FAIL; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.NOZZLE.create(); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { return defaultBlockState().setValue(FACING, context.getClickedFace()); } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.NOZZLE.get(state.getValue(FACING)); } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { if (worldIn.isClientSide) return; @@ -69,15 +71,15 @@ public class NozzleBlock extends WrenchableDirectionalBlock { } @Override - public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) { Direction towardsFan = state.getValue(FACING).getOpposite(); - TileEntity te = worldIn.getBlockEntity(pos.relative(towardsFan)); + BlockEntity te = worldIn.getBlockEntity(pos.relative(towardsFan)); return te instanceof IAirCurrentSource && ((IAirCurrentSource) te).getAirflowOriginSide() == towardsFan.getOpposite(); } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 1ca0d1ee5..5dc70b8d1 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 @@ -9,22 +9,22 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceContext.BlockMode; -import net.minecraft.util.math.RayTraceContext.FluidMode; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.Explosion.Mode; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Explosion.BlockInteraction; public class NozzleTileEntity extends SmartTileEntity { @@ -33,7 +33,7 @@ public class NozzleTileEntity extends SmartTileEntity { private boolean pushing; private BlockPos fanPos; - public NozzleTileEntity(TileEntityType type) { + public NozzleTileEntity(BlockEntityType type) { super(type); setLazyTickRate(5); } @@ -42,7 +42,7 @@ public class NozzleTileEntity extends SmartTileEntity { public void addBehaviours(List behaviours) {} @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); if (!clientPacket) return; @@ -51,7 +51,7 @@ public class NozzleTileEntity extends SmartTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); if (!clientPacket) return; @@ -74,24 +74,24 @@ public class NozzleTileEntity extends SmartTileEntity { if (this.range != range) setRange(range); - Vector3d center = VecHelper.getCenterOf(worldPosition); + Vec3 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, level.random, pushing ? 1 : range / 2); - Vector3d motion = center.subtract(start) + Mth.clamp((AllConfigs.SERVER.kinetics.fanPushDistance.get() - (int) range), 1, 10)) == 0) { + Vec3 start = VecHelper.offsetRandomly(center, level.random, pushing ? 1 : range / 2); + Vec3 motion = center.subtract(start) .normalize() - .scale(MathHelper.clamp(range * (pushing ? .025f : 1f), 0, .5f) * (pushing ? -1 : 1)); + .scale(Mth.clamp(range * (pushing ? .025f : 1f), 0, .5f) * (pushing ? -1 : 1)); 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.position() + Vec3 diff = entity.position() .subtract(center); - if (!(entity instanceof PlayerEntity) && level.isClientSide) + if (!(entity instanceof Player) && level.isClientSide) continue; double distance = diff.length(); @@ -104,7 +104,7 @@ public class NozzleTileEntity extends SmartTileEntity { continue; float factor = (entity instanceof ItemEntity) ? 1 / 128f : 1 / 32f; - Vector3d pushVec = diff.normalize() + Vec3 pushVec = diff.normalize() .scale((range - distance) * (pushing ? 1 : -1)); entity.setDeltaMovement(entity.getDeltaMovement() .add(pushVec.scale(factor))); @@ -122,7 +122,7 @@ public class NozzleTileEntity extends SmartTileEntity { } private float calcRange() { - TileEntity te = level.getBlockEntity(fanPos); + BlockEntity te = level.getBlockEntity(fanPos); if (!(te instanceof IAirCurrentSource)) return 0; @@ -144,11 +144,11 @@ public class NozzleTileEntity extends SmartTileEntity { if (range == 0) return; - Vector3d center = VecHelper.getCenterOf(worldPosition); - AxisAlignedBB bb = new AxisAlignedBB(center, center).inflate(range / 2f); + Vec3 center = VecHelper.getCenterOf(worldPosition); + AABB bb = new AABB(center, center).inflate(range / 2f); for (Entity entity : level.getEntitiesOfClass(Entity.class, bb)) { - Vector3d diff = entity.position() + Vec3 diff = entity.position() .subtract(center); double distance = diff.length(); @@ -173,7 +173,7 @@ public class NozzleTileEntity extends SmartTileEntity { } if (!pushing && pushingEntities.size() > 256 && !level.isClientSide) { - level.explode(null, center.x, center.y, center.z, 2, Mode.NONE); + level.explode(null, center.x, center.y, center.z, 2, BlockInteraction.NONE); for (Iterator iterator = pushingEntities.iterator(); iterator.hasNext();) { Entity entity = iterator.next(); entity.remove(); @@ -184,8 +184,8 @@ public class NozzleTileEntity extends SmartTileEntity { } private boolean canSee(Entity entity) { - RayTraceContext context = new RayTraceContext(entity.position(), VecHelper.getCenterOf(worldPosition), - BlockMode.COLLIDER, FluidMode.NONE, entity); + ClipContext context = new ClipContext(entity.position(), VecHelper.getCenterOf(worldPosition), + Block.COLLIDER, Fluid.NONE, entity); 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 499f6c8ff..4918ddb82 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 @@ -8,7 +8,7 @@ import com.simibubi.create.content.contraptions.processing.InWorldProcessing.Spl import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; @ParametersAreNonnullByDefault public class SplashingRecipe extends ProcessingRecipe { @@ -18,7 +18,7 @@ public class SplashingRecipe extends ProcessingRecipe type) { + public FlywheelTileEntity(BlockEntityType type) { super(type); } @@ -49,12 +49,12 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity { } @Override - public AxisAlignedBB makeRenderBoundingBox() { + public AABB makeRenderBoundingBox() { return super.makeRenderBoundingBox().inflate(2); } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putFloat("GeneratedSpeed", generatedSpeed); compound.putFloat("GeneratedCapacity", generatedCapacity); compound.putInt("Cooldown", stoppingCooldown); @@ -62,7 +62,7 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { generatedSpeed = compound.getFloat("GeneratedSpeed"); generatedCapacity = compound.getFloat("GeneratedCapacity"); stoppingCooldown = compound.getInt("Cooldown"); 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 483c3f0da..b27a874b5 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 @@ -6,30 +6,32 @@ import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public abstract class EngineBlock extends HorizontalBlock implements IWrenchable { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public abstract class EngineBlock extends HorizontalDirectionalBlock implements IWrenchable { protected EngineBlock(Properties builder) { super(builder); } @Override - public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) { return isValidPosition(state, worldIn, pos, state.getValue(FACING)); } @@ -39,15 +41,15 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - return ActionResultType.FAIL; + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + return InteractionResult.FAIL; } @Override - public abstract TileEntity createTileEntity(BlockState state, IBlockReader world); + public abstract BlockEntity createTileEntity(BlockState state, BlockGetter world); @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Direction facing = context.getClickedFace(); return defaultBlockState().setValue(FACING, facing.getAxis().isVertical() ? context.getHorizontalDirection().getOpposite() : facing); @@ -59,7 +61,7 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { if (worldIn.isClientSide) return; @@ -72,7 +74,7 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable } } - private boolean isValidPosition(BlockState state, IBlockReader world, BlockPos pos, Direction facing) { + private boolean isValidPosition(BlockState state, BlockGetter world, BlockPos pos, Direction facing) { BlockPos baseBlockPos = getBaseBlockPos(state, pos); if (!isValidBaseBlock(world.getBlockState(baseBlockPos), world, pos)) return false; @@ -97,6 +99,6 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable @OnlyIn(Dist.CLIENT) public abstract PartialModel getFrameModel(); - protected abstract boolean isValidBaseBlock(BlockState baseBlock, IBlockReader world, BlockPos pos); + protected abstract boolean isValidBaseBlock(BlockState baseBlock, BlockGetter world, BlockPos pos); } 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 c7cdcba60..e5e88ea3c 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 @@ -5,12 +5,14 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.block.Block; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; + +import ModelData; public class EngineInstance extends TileEntityInstance { @@ -33,7 +35,7 @@ public class EngineInstance extends TileEntityInstance { float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing)); - MatrixStack ms = new MatrixStack(); + PoseStack ms = new PoseStack(); MatrixTransformStack msr = MatrixTransformStack.of(ms); msr.translate(getInstancePosition()) 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 a91ba53d3..b087221ba 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 @@ -2,25 +2,25 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.Block; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; public class EngineRenderer extends SafeTileEntityRenderer { - public EngineRenderer(TileEntityRendererDispatcher dispatcher) { + public EngineRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, + protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; 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 43eb4ee7c..1d47a9004 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 @@ -9,12 +9,12 @@ import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTile import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -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.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -24,7 +24,7 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender public float appliedSpeed; protected FlywheelTileEntity poweredWheel; - public EngineTileEntity(TileEntityType tileEntityTypeIn) { + public EngineTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } @@ -32,10 +32,10 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender public void addBehaviours(List behaviours) { } - protected AxisAlignedBB cachedBoundingBox; + protected AABB cachedBoundingBox; @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { + public AABB getRenderBoundingBox() { if (cachedBoundingBox == null) { cachedBoundingBox = super.getRenderBoundingBox().inflate(1.5f); } @@ -65,7 +65,7 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender if (FlywheelBlock.isConnected(wheelState) && FlywheelBlock.getConnection(wheelState) != engineFacing.getOpposite()) return; - TileEntity te = level.getBlockEntity(wheelPos); + BlockEntity te = level.getBlockEntity(wheelPos); if (te.isRemoved()) return; if (te instanceof FlywheelTileEntity) { 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 6c034f883..06f6b57fd 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 @@ -8,22 +8,24 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.AbstractFurnaceBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.AbstractFurnaceBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + @EventBusSubscriber public class FurnaceEngineBlock extends EngineBlock implements ITE { @@ -32,12 +34,12 @@ public class FurnaceEngineBlock extends EngineBlock implements ITE type) { + public FurnaceEngineTileEntity(BlockEntityType type) { super(type); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillingRecipe.java index 123fc1133..849154b04 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillingRecipe.java @@ -6,7 +6,7 @@ import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.content.contraptions.components.crusher.AbstractCrushingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraftforge.items.wrapper.RecipeWrapper; @ParametersAreNonnullByDefault @@ -17,7 +17,7 @@ public class MillingRecipe extends AbstractCrushingRecipe { } @Override - public boolean matches(RecipeWrapper inv, World worldIn) { + public boolean matches(RecipeWrapper inv, Level worldIn) { if (inv.isEmpty()) return false; return ingredients.get(0) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneBlock.java index e880796ce..303c17bcb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneBlock.java @@ -8,30 +8,32 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemStackHandler; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class MillstoneBlock extends KineticBlock implements ITE, ICogWheel { public MillstoneBlock(Properties properties) { @@ -39,27 +41,27 @@ public class MillstoneBlock extends KineticBlock implements ITE { boolean emptyOutput = true; @@ -84,11 +86,11 @@ public class MillstoneBlock extends KineticBlock implements ITE { ItemHelper.dropContents(worldIn, pos, te.inputInv); @@ -141,7 +143,7 @@ public class MillstoneBlock extends KineticBlock implements ITE type) { + public MillstoneTileEntity(BlockEntityType type) { super(type); inputInv = new ItemStackHandler(1); outputInv = new ItemStackHandler(9); @@ -63,7 +63,7 @@ public class MillstoneTileEntity extends KineticTileEntity { .isEmpty()) return; - float pitch = MathHelper.clamp((Math.abs(getSpeed()) / 256f) + .45f, .85f, 1f); + float pitch = Mth.clamp((Math.abs(getSpeed()) / 256f) + .45f, .85f, 1f); SoundScapes.play(AmbienceGroup.MILLING, worldPosition, pitch); } @@ -142,19 +142,19 @@ public class MillstoneTileEntity extends KineticTileEntity { if (stackInSlot.isEmpty()) return; - ItemParticleData data = new ItemParticleData(ParticleTypes.ITEM, stackInSlot); + ItemParticleOption data = new ItemParticleOption(ParticleTypes.ITEM, stackInSlot); float angle = level.random.nextFloat() * 360; - Vector3d offset = new Vector3d(0, 0, 0.5f); + Vec3 offset = new Vec3(0, 0, 0.5f); offset = VecHelper.rotate(offset, angle, Axis.Y); - Vector3d target = VecHelper.rotate(offset, getSpeed() > 0 ? 25 : -25, Axis.Y); + Vec3 target = VecHelper.rotate(offset, getSpeed() > 0 ? 25 : -25, Axis.Y); - Vector3d center = offset.add(VecHelper.getCenterOf(worldPosition)); + Vec3 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 - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("Timer", timer); compound.put("InputInventory", inputInv.serializeNBT()); compound.put("OutputInventory", outputInv.serializeNBT()); @@ -162,7 +162,7 @@ public class MillstoneTileEntity extends KineticTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { timer = compound.getInt("Timer"); inputInv.deserializeNBT(compound.getCompound("InputInventory")); outputInv.deserializeNBT(compound.getCompound("OutputInventory")); @@ -170,7 +170,7 @@ public class MillstoneTileEntity extends KineticTileEntity { } public int getProcessingSpeed() { - return MathHelper.clamp((int) Math.abs(getSpeed() / 16f), 1, 512); + return Mth.clamp((int) Math.abs(getSpeed() / 16f), 1, 512); } @Override 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 5e618fef9..b937f78f6 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 @@ -7,17 +7,20 @@ import com.simibubi.create.content.contraptions.base.KineticBlock; import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; + +import com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class MechanicalMixerBlock extends KineticBlock implements ITE, ICogWheel { @@ -26,18 +29,18 @@ public class MechanicalMixerBlock extends KineticBlock implements ITE type) { + public MechanicalMixerTileEntity(BlockEntityType type) { super(type); } @@ -60,14 +60,14 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { if (runningTicks < 20) { localTick = runningTicks; float num = (localTick + partialTicks) / 20f; - num = ((2 - MathHelper.cos((float) (num * Math.PI))) / 2); + num = ((2 - Mth.cos((float) (num * Math.PI))) / 2); offset = num - .5f; } else if (runningTicks <= 20) { offset = 1; } else { localTick = 40 - runningTicks; float num = (localTick - partialTicks) / 20f; - num = ((2 - MathHelper.cos((float) (num * Math.PI))) / 2); + num = ((2 - Mth.cos((float) (num * Math.PI))) / 2); offset = num - .5f; } } @@ -89,12 +89,12 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { } @Override - public AxisAlignedBB makeRenderBoundingBox() { - return new AxisAlignedBB(worldPosition).expandTowards(0, -1.5, 0); + public AABB makeRenderBoundingBox() { + return new AABB(worldPosition).expandTowards(0, -1.5, 0); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { running = compound.getBoolean("Running"); runningTicks = compound.getInt("Ticks"); super.fromTag(state, compound, clientPacket); @@ -104,7 +104,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("Running", running); compound.putInt("Ticks", runningTicks); super.write(compound, clientPacket); @@ -128,7 +128,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { if ((!level.isClientSide || isVirtual()) && runningTicks == 20) { if (processingTicks < 0) { - processingTicks = MathHelper.clamp((MathHelper.log2((int) (512 / speed))) * 15 + 1, 1, 512); + processingTicks = Mth.clamp((Mth.log2((int) (512 / speed))) * 15 + 1, 1, 512); Optional basin = getBasin(); if (basin.isPresent()) { @@ -139,7 +139,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { || !tanks.getSecond() .isEmpty()) level.playSound(null, worldPosition, SoundEvents.BUBBLE_COLUMN_WHIRLPOOL_AMBIENT, - SoundCategory.BLOCKS, .75f, speed < 65 ? .75f : 1.5f); + SoundSource.BLOCKS, .75f, speed < 65 ? .75f : 1.5f); } } else { @@ -169,7 +169,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { ItemStack stackInSlot = inv.getItem(slot); if (stackInSlot.isEmpty()) continue; - ItemParticleData data = new ItemParticleData(ParticleTypes.ITEM, stackInSlot); + ItemParticleOption data = new ItemParticleOption(ParticleTypes.ITEM, stackInSlot); spillParticle(data); } } @@ -186,20 +186,20 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { } } - protected void spillParticle(IParticleData data) { + protected void spillParticle(ParticleOptions data) { float angle = level.random.nextFloat() * 360; - Vector3d offset = new Vector3d(0, 0, 0.25f); + Vec3 offset = new Vec3(0, 0, 0.25f); offset = VecHelper.rotate(offset, angle, Axis.Y); - Vector3d target = VecHelper.rotate(offset, getSpeed() > 0 ? 25 : -25, Axis.Y) + Vec3 target = VecHelper.rotate(offset, getSpeed() > 0 ? 25 : -25, Axis.Y) .add(0, .25f, 0); - Vector3d center = offset.add(VecHelper.getCenterOf(worldPosition)); + Vec3 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 - protected List> getMatchingRecipes() { - List> matchingRecipes = super.getMatchingRecipes(); + protected List> getMatchingRecipes() { + List> matchingRecipes = super.getMatchingRecipes(); Optional basin = getBasin(); if (!basin.isPresent()) @@ -227,8 +227,8 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { } @Override - protected boolean matchStaticFilters(IRecipe r) { - return ((r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE + protected boolean matchStaticFilters(Recipe r) { + return ((r.getSerializer() == RecipeSerializer.SHAPELESS_RECIPE && AllConfigs.SERVER.recipes.allowShapelessInMixer.get() && r.getIngredients() .size() > 1 && !MechanicalPressTileEntity.canCompress(r)) || r.getType() == AllRecipeTypes.MIXING.getType()); 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 1c79b042e..78afc6087 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 @@ -10,6 +10,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.Direction; +import OrientedData; + public class MixerInstance extends ShaftlessCogInstance implements IDynamicInstance { private final RotatingData mixerHead; 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 0d137fe2e..f034ffe64 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 @@ -4,17 +4,19 @@ import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class CreativeMotorBlock extends DirectionalKineticBlock { @@ -23,17 +25,17 @@ public class CreativeMotorBlock extends DirectionalKineticBlock { } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.MOTOR_BLOCK.get(state.getValue(FACING)); } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.MOTOR.create(); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Direction preferred = getPreferredFacing(context); if ((context.getPlayer() != null && context.getPlayer() .isShiftKeyDown()) || preferred == null) @@ -44,7 +46,7 @@ public class CreativeMotorBlock extends DirectionalKineticBlock { // IRotate: @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face == state.getValue(FACING); } @@ -60,7 +62,7 @@ public class CreativeMotorBlock extends DirectionalKineticBlock { } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 032783bb6..5cda67a94 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 @@ -5,9 +5,9 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; import net.minecraftforge.client.model.generators.ModelFile; public class CreativeMotorGenerator extends SpecialBlockStateGen { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java index 513e0f200..952dd147d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java @@ -6,11 +6,11 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; public class CreativeMotorRenderer extends KineticTileEntityRenderer { - public CreativeMotorRenderer(TileEntityRendererDispatcher dispatcher) { + public CreativeMotorRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } 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 4509f6ff8..947abccb7 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 @@ -11,14 +11,14 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.entity.BlockEntityType; public class CreativeMotorTileEntity extends GeneratingKineticTileEntity { public static final int DEFAULT_SPEED = 16; protected ScrollValueBehaviour generatedSpeed; - public CreativeMotorTileEntity(TileEntityType type) { + public CreativeMotorTileEntity(BlockEntityType type) { super(type); } 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 e05d44501..e15ab9f57 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 @@ -6,18 +6,20 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE { @@ -26,24 +28,24 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE< } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - if (context.getEntity() instanceof PlayerEntity) + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { + if (context.getEntity() instanceof Player) return AllShapes.CASING_14PX.get(Direction.DOWN); return AllShapes.MECHANICAL_PROCESSOR_SHAPE; } @Override - public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) { return !AllBlocks.BASIN.has(worldIn.getBlockState(pos.below())); } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.MECHANICAL_PRESS.create(); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Direction prefferedSide = getPreferredHorizontalFacing(context); if (prefferedSide != null) return defaultBlockState().setValue(HORIZONTAL_FACING, prefferedSide); @@ -57,7 +59,7 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE< } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.getValue(HORIZONTAL_FACING) .getAxis(); } @@ -68,7 +70,7 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE< } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 a310c7c1d..cf633a78c 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 @@ -2,8 +2,19 @@ package com.simibubi.create.content.contraptions.components.press; import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; -import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.net.minimport com.jozufozu.flywheel.backend.Backend; +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; +import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; +import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.SuperByteBuffer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.level.block.state.BlockState; + +ecraft.world.level.block.state.properties.BlockStatePropertiesng.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -17,7 +28,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; public class MechanicalPressRenderer extends KineticTileEntityRenderer { - public MechanicalPressRenderer(TileEntityRendererDispatcher dispatcher) { + public MechanicalPressRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @@ -27,7 +38,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer { } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); 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 059067cfd..88820f563 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java @@ -24,25 +24,25 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.SoundType; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.ICraftingRecipe; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ItemParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.AABB; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; @@ -64,7 +64,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { public Mode mode; public boolean finished; - public MechanicalPressTileEntity(TileEntityType type) { + public MechanicalPressTileEntity(BlockEntityType type) { super(type); mode = Mode.WORLD; entityScanCooldown = ENTITY_SCAN; @@ -80,7 +80,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { running = compound.getBoolean("Running"); mode = Mode.values()[compound.getInt("Mode")]; finished = compound.getBoolean("Finished"); @@ -95,7 +95,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("Running", running); compound.putInt("Mode", mode.ordinal()); compound.putBoolean("Finished", finished); @@ -109,8 +109,8 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { } @Override - public AxisAlignedBB makeRenderBoundingBox() { - return new AxisAlignedBB(worldPosition).expandTowards(0, -1.5, 0) + public AABB makeRenderBoundingBox() { + return new AABB(worldPosition).expandTowards(0, -1.5, 0) .expandTowards(0, 1, 0); } @@ -118,10 +118,10 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { if (!running) return 0; int runningTicks = Math.abs(this.runningTicks); - float ticks = MathHelper.lerp(partialTicks, prevRunningTicks, runningTicks); + float ticks = Mth.lerp(partialTicks, prevRunningTicks, runningTicks); if (runningTicks < (CYCLE * 2) / 3) - return (float) MathHelper.clamp(Math.pow(ticks / CYCLE * 2, 3), 0, 1) * mode.headOffset; - return MathHelper.clamp((CYCLE - ticks) / CYCLE * 3, 0, 1) * mode.headOffset; + return (float) Mth.clamp(Math.pow(ticks / CYCLE * 2, 3), 0, 1) * mode.headOffset; + return Mth.clamp((CYCLE - ticks) / CYCLE * 3, 0, 1) * mode.headOffset; } public void start(Mode mode) { @@ -160,7 +160,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { return; for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, - new AxisAlignedBB(worldPosition.below()).deflate(.125f))) { + new AABB(worldPosition.below()).deflate(.125f))) { if (!itemEntity.isAlive() || !itemEntity.isOnGround()) continue; ItemStack stack = itemEntity.getItem(); @@ -242,7 +242,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { } protected void applyPressingInWorld() { - AxisAlignedBB bb = new AxisAlignedBB(worldPosition.below(1)); + AABB bb = new AABB(worldPosition.below(1)); boolean bulk = canProcessInBulk(); pressedItems.clear(); if (level.isClientSide) @@ -268,7 +268,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { ItemEntity created = new ItemEntity(level, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), result); created.setDefaultPickUpDelay(); - created.setDeltaMovement(VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .05f)); + created.setDeltaMovement(VecHelper.offsetRandomly(Vec3.ZERO, Create.RANDOM, .05f)); level.addFreshEntity(created); } item.shrink(1); @@ -289,7 +289,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { public int getRunningTickSpeed() { if (getSpeed() == 0) return 0; - return (int) MathHelper.lerp(MathHelper.clamp(Math.abs(getSpeed()) / 512f, 0, 1), 1, 60); + return (int) Mth.lerp(Mth.clamp(Math.abs(getSpeed()) / 512f, 0, 1), 1, 60); } protected void spawnParticles() { @@ -308,24 +308,24 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { pressedItems.clear(); } - public void makePressingParticleEffect(Vector3d pos, ItemStack stack) { + public void makePressingParticleEffect(Vec3 pos, ItemStack stack) { if (level == null || !level.isClientSide) return; for (int i = 0; i < 20; i++) { - Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, level.random, .125f) + Vec3 motion = VecHelper.offsetRandomly(Vec3.ZERO, level.random, .125f) .multiply(1, 0, 1); - level.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), pos.x, pos.y - .25f, pos.z, motion.x, + level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), pos.x, pos.y - .25f, pos.z, motion.x, motion.y + .125f, motion.z); } } - public void makeCompactingParticleEffect(Vector3d pos, ItemStack stack) { + public void makeCompactingParticleEffect(Vec3 pos, ItemStack stack) { if (level == null || !level.isClientSide) return; for (int i = 0; i < 20; i++) { - Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, level.random, .175f) + Vec3 motion = VecHelper.offsetRandomly(Vec3.ZERO, level.random, .175f) .multiply(1, 0, 1); - level.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), pos.x, pos.y, pos.z, motion.x, + level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), pos.x, pos.y, pos.z, motion.x, motion.y + .25f, motion.z); } } @@ -345,12 +345,12 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { private static final List RECIPE_DENY_LIST = ImmutableList.of(new ResourceLocation("occultism", "spirit_trade")); - public static boolean canCompress(IRecipe recipe) { + public static boolean canCompress(Recipe recipe) { NonNullList ingredients = recipe.getIngredients(); - if (!(recipe instanceof ICraftingRecipe)) + if (!(recipe instanceof CraftingRecipe)) return false; - IRecipeSerializer serializer = recipe.getSerializer(); + RecipeSerializer serializer = recipe.getSerializer(); for (ResourceLocation denied : RECIPE_DENY_LIST) if (serializer != null && denied.equals(serializer.getRegistryName())) return false; @@ -361,8 +361,8 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { } @Override - protected boolean matchStaticFilters(IRecipe recipe) { - return (recipe instanceof ICraftingRecipe && canCompress(recipe)) + protected boolean matchStaticFilters(Recipe recipe) { + return (recipe instanceof CraftingRecipe && canCompress(recipe)) || recipe.getType() == AllRecipeTypes.COMPACTING.getType(); } 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 95fb9058a..b48ebc85a 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 @@ -9,8 +9,10 @@ import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3f; +import com.mojang.math.Quaternion; +import com.mojang.math.Vector3f; + +import OrientedData; public class PressInstance extends ShaftInstance implements IDynamicInstance { 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 f68c4abeb..398189016 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 @@ -14,10 +14,10 @@ import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.ItemLike; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.wrapper.RecipeWrapper; @@ -30,7 +30,7 @@ public class PressingRecipe extends ProcessingRecipe implements I } @Override - public boolean matches(RecipeWrapper inv, World worldIn) { + public boolean matches(RecipeWrapper inv, Level worldIn) { if (inv.isEmpty()) return false; return ingredients.get(0) @@ -52,12 +52,12 @@ public class PressingRecipe extends ProcessingRecipe implements I @Override @OnlyIn(Dist.CLIENT) - public ITextComponent getDescriptionForAssembly() { + public Component getDescriptionForAssembly() { return Lang.translate("recipe.assembly.pressing"); } @Override - public void addRequiredMachines(Set list) { + public void addRequiredMachines(Set list) { list.add(AllBlocks.MECHANICAL_PRESS.get()); } 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 0933bec29..18e244d66 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 @@ -14,10 +14,10 @@ import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.ItemLike; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.wrapper.RecipeWrapper; @@ -30,7 +30,7 @@ public class CuttingRecipe extends ProcessingRecipe implements IA } @Override - public boolean matches(RecipeWrapper inv, World worldIn) { + public boolean matches(RecipeWrapper inv, Level worldIn) { if (inv.isEmpty()) return false; return ingredients.get(0) @@ -52,12 +52,12 @@ public class CuttingRecipe extends ProcessingRecipe implements IA @Override @OnlyIn(Dist.CLIENT) - public ITextComponent getDescriptionForAssembly() { + public Component getDescriptionForAssembly() { return Lang.translate("recipe.assembly.cutting"); } @Override - public void addRequiredMachines(Set list) { + public void addRequiredMachines(Set list) { list.add(AllBlocks.MECHANICAL_SAW.get()); } 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 cebba49a6..31ff45705 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 @@ -12,23 +12,25 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -40,7 +42,7 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE { if (te.getSpeed() == 0) @@ -72,7 +74,7 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE { - public SawRenderer(TileEntityRendererDispatcher dispatcher) { + public SawRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(SawTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, + protected void renderSafe(SawTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { renderBlade(te, ms, buffer, light); renderItems(te, partialTicks, ms, buffer, light, overlay); @@ -56,7 +88,7 @@ public class SawRenderer extends SafeTileEntityRenderer { renderShaft(te, ms, buffer, light, overlay); } - protected void renderBlade(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light) { + protected void renderBlade(SawTileEntity te, PoseStack ms, MultiBufferSource buffer, int light) { BlockState blockState = te.getBlockState(); PartialModel partial; float speed = te.getSpeed(); @@ -92,12 +124,12 @@ public class SawRenderer extends SafeTileEntityRenderer { .renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped())); } - protected void renderShaft(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + protected void renderShaft(SawTileEntity te, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { KineticTileEntityRenderer.renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(RenderType.solid()), light); } - protected void renderItems(SawTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderItems(SawTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { boolean processingMode = te.getBlockState() .getValue(SawBlock.FACING) == Direction.UP; @@ -108,9 +140,9 @@ public class SawRenderer extends SafeTileEntityRenderer { boolean moving = te.inventory.recipeDuration != 0; float offset = moving ? (float) (te.inventory.remainingTime) / te.inventory.recipeDuration : 0; - float processingSpeed = MathHelper.clamp(Math.abs(te.getSpeed()) / 32, 1, 128); + float processingSpeed = Mth.clamp(Math.abs(te.getSpeed()) / 32, 1, 128); if (moving) { - offset = MathHelper + offset = Mth .clamp(offset + ((-partialTicks + .5f) * processingSpeed) / te.inventory.recipeDuration, 0.125f, 1f); if (!te.inventory.appliedRecipe) offset += 1; @@ -129,7 +161,7 @@ public class SawRenderer extends SafeTileEntityRenderer { ItemRenderer itemRenderer = Minecraft.getInstance() .getItemRenderer(); - IBakedModel modelWithOverrides = itemRenderer.getModel(stack, te.getLevel(), null); + BakedModel modelWithOverrides = itemRenderer.getModel(stack, te.getLevel(), null); boolean blockItem = modelWithOverrides.isGui3d(); ms.translate(alongZ ? offset : .5, blockItem ? .925f : 13f / 16f, alongZ ? .5 : offset); @@ -138,7 +170,7 @@ public class SawRenderer extends SafeTileEntityRenderer { if (alongZ) ms.mulPose(Vector3f.YP.rotationDegrees(90)); ms.mulPose(Vector3f.XP.rotationDegrees(90)); - itemRenderer.renderStatic(stack, ItemCameraTransforms.TransformType.FIXED, light, overlay, ms, buffer); + itemRenderer.renderStatic(stack, ItemTransforms.TransformType.FIXED, light, overlay, ms, buffer); break; } @@ -162,11 +194,11 @@ public class SawRenderer extends SafeTileEntityRenderer { } public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - ContraptionMatrices matrices, IRenderTypeBuffer buffer) { + ContraptionMatrices matrices, MultiBufferSource buffer) { BlockState state = context.state; Direction facing = state.getValue(SawBlock.FACING); - Vector3d facingVec = Vector3d.atLowerCornerOf(context.state.getValue(SawBlock.FACING) + Vec3 facingVec = Vec3.atLowerCornerOf(context.state.getValue(SawBlock.FACING) .getNormal()); facingVec = context.rotation.apply(facingVec); @@ -192,7 +224,7 @@ public class SawRenderer extends SafeTileEntityRenderer { superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state); } - MatrixStack m = matrices.getModel(); + PoseStack m = matrices.getModel(); m.pushPose(); MatrixTransformStack.of(m) .centre() 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 768f795e3..c7268580b 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 @@ -29,38 +29,38 @@ import com.simibubi.create.foundation.utility.recipe.RecipeConditions; import com.simibubi.create.foundation.utility.recipe.RecipeFinder; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BambooBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CactusBlock; -import net.minecraft.block.ChorusPlantBlock; -import net.minecraft.block.KelpBlock; -import net.minecraft.block.KelpTopBlock; -import net.minecraft.block.SoundType; -import net.minecraft.block.StemGrownBlock; -import net.minecraft.block.SugarCaneBlock; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.item.crafting.StonecuttingRecipe; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.BlockParticleData; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ItemParticleData; -import net.minecraft.particles.ParticleTypes; +import net.minecraft.world.level.block.BambooBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.CactusBlock; +import net.minecraft.world.level.block.ChorusPlantBlock; +import net.minecraft.world.level.block.KelpPlantBlock; +import net.minecraft.world.level.block.KelpBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.StemGrownBlock; +import net.minecraft.world.level.block.SugarCaneBlock; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.StonecutterRecipe; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.tags.BlockTags; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.LazyValue; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.util.LazyLoadedValue; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Registry; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.Capability; @@ -72,11 +72,11 @@ import net.minecraftforge.items.IItemHandler; @MethodsReturnNonnullByDefault public class SawTileEntity extends BlockBreakingKineticTileEntity { - private static final AxisAlignedBB RENDER_BOX = new AxisAlignedBB(0, 0, 0, 1, 1, 1); + private static final AABB RENDER_BOX = new AABB(0, 0, 0, 1, 1, 1); private static final Object cuttingRecipesKey = new Object(); - public static final LazyValue> woodcuttingRecipeType = - new LazyValue<>(() -> Registry.RECIPE_TYPE.get(new ResourceLocation("druidcraft", "woodcutting"))); + public static final LazyLoadedValue> woodcuttingRecipeType = + new LazyLoadedValue<>(() -> Registry.RECIPE_TYPE.get(new ResourceLocation("druidcraft", "woodcutting"))); public ProcessingInventory inventory; private int recipeIndex; @@ -85,7 +85,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { private ItemStack playEvent; - public SawTileEntity(TileEntityType type) { + public SawTileEntity(BlockEntityType type) { super(type); inventory = new ProcessingInventory(this::start).withSlotLimit(!AllConfigs.SERVER.recipes.bulkCutting.get()); inventory.remainingTime = -1; @@ -103,7 +103,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.put("Inventory", inventory.serializeNBT()); compound.putInt("RecipeIndex", recipeIndex); super.write(compound, clientPacket); @@ -115,7 +115,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); inventory.deserializeNBT(compound.getCompound("Inventory")); recipeIndex = compound.getInt("RecipeIndex"); @@ -124,7 +124,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } @Override - protected AxisAlignedBB makeRenderBoundingBox() { + protected AABB makeRenderBoundingBox() { return RENDER_BOX.inflate(.125f) .move(worldPosition); } @@ -169,7 +169,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { return; } - float processingSpeed = MathHelper.clamp(Math.abs(getSpeed()) / 24, 1, 128); + float processingSpeed = Mth.clamp(Math.abs(getSpeed()) / 24, 1, 128); inventory.remainingTime -= processingSpeed; if (inventory.remainingTime > 0) @@ -187,7 +187,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { return; } - Vector3d itemMovement = getItemMovementVec(); + Vec3 itemMovement = getItemMovementVec(); Direction itemMovementFacing = Direction.getNearest(itemMovement.x, itemMovement.y, itemMovement.z); if (inventory.remainingTime > 0) return; @@ -236,10 +236,10 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } // Eject Items - Vector3d outPos = VecHelper.getCenterOf(worldPosition) + Vec3 outPos = VecHelper.getCenterOf(worldPosition) .add(itemMovement.scale(.5f) .add(0, .5, 0)); - Vector3d outMotion = itemMovement.scale(.0625) + Vec3 outMotion = itemMovement.scale(.0625) .add(0, .125, 0); for (int slot = 0; slot < inventory.getSlots(); slot++) { ItemStack stack = inventory.getStackInSlot(slot); @@ -272,18 +272,18 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { if (stack == null || stack.isEmpty()) return; - IParticleData particleData = null; + ParticleOptions particleData = null; if (stack.getItem() instanceof BlockItem) - particleData = new BlockParticleData(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock() + particleData = new BlockParticleOption(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock() .defaultBlockState()); else - particleData = new ItemParticleData(ParticleTypes.ITEM, stack); + particleData = new ItemParticleOption(ParticleTypes.ITEM, stack); Random r = level.random; - Vector3d v = VecHelper.getCenterOf(this.worldPosition) + Vec3 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); + Vec3 m = VecHelper.offsetRandomly(new Vec3(0, 0.25f, 0), r, .125f); level.addParticle(particleData, v.x, v.y, v.z, m.x, m.y, m.y); } } @@ -292,19 +292,19 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { if (stack == null || stack.isEmpty()) return; - IParticleData particleData = null; + ParticleOptions particleData = null; float speed = 1; if (stack.getItem() instanceof BlockItem) - particleData = new BlockParticleData(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock() + particleData = new BlockParticleOption(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock() .defaultBlockState()); else { - particleData = new ItemParticleData(ParticleTypes.ITEM, stack); + particleData = new ItemParticleOption(ParticleTypes.ITEM, stack); speed = .125f; } Random r = level.random; - Vector3d vec = getItemMovementVec(); - Vector3d pos = VecHelper.getCenterOf(this.worldPosition); + Vec3 vec = getItemMovementVec(); + Vec3 pos = VecHelper.getCenterOf(this.worldPosition); float offset = inventory.recipeDuration != 0 ? (float) (inventory.remainingTime) / inventory.recipeDuration : 0; offset /= 2; if (inventory.appliedRecipe) @@ -313,20 +313,20 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { -vec.x * speed, r.nextFloat() * speed, -vec.z * speed); } - public Vector3d getItemMovementVec() { + public Vec3 getItemMovementVec() { 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)); + return new Vec3(offset * (alongX ? 1 : 0), 0, offset * (alongX ? 0 : -1)); } private void applyRecipe() { - List> recipes = getRecipes(); + List> recipes = getRecipes(); if (recipes.isEmpty()) return; if (recipeIndex >= recipes.size()) recipeIndex = 0; - IRecipe recipe = recipes.get(recipeIndex); + Recipe recipe = recipes.get(recipeIndex); int rolls = inventory.getStackInSlot(0) .getCount(); @@ -337,7 +337,7 @@ 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.get()) + else if (recipe instanceof StonecutterRecipe || recipe.getType() == woodcuttingRecipeType.get()) results.add(recipe.getResultItem() .copy()); @@ -352,18 +352,18 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { } - private List> getRecipes() { + private List> getRecipes() { Optional assemblyRecipe = SequencedAssemblyRecipe.getRecipe(level, inventory.getStackInSlot(0), AllRecipeTypes.CUTTING.getType(), CuttingRecipe.class); if (assemblyRecipe.isPresent() && filtering.test(assemblyRecipe.get() .getResultItem())) return ImmutableList.of(assemblyRecipe.get()); - Predicate> types = RecipeConditions.isOfType(AllRecipeTypes.CUTTING.getType(), - AllConfigs.SERVER.recipes.allowStonecuttingOnSaw.get() ? IRecipeType.STONECUTTING : null, + Predicate> types = RecipeConditions.isOfType(AllRecipeTypes.CUTTING.getType(), + AllConfigs.SERVER.recipes.allowStonecuttingOnSaw.get() ? RecipeType.STONECUTTING : null, AllConfigs.SERVER.recipes.allowWoodcuttingOnSaw.get() ? woodcuttingRecipeType.get() : null); - List> startedSearch = RecipeFinder.get(cuttingRecipesKey, level, types); + List> startedSearch = RecipeFinder.get(cuttingRecipesKey, level, types); return startedSearch.stream() .filter(RecipeConditions.outputMatchesFilter(filtering)) .filter(RecipeConditions.firstIngredientMatches(inventory.getStackInSlot(0))) @@ -397,7 +397,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { if (level.isClientSide && !isVirtual()) return; - List> recipes = getRecipes(); + List> recipes = getRecipes(); boolean valid = !recipes.isEmpty(); int time = 50; @@ -414,7 +414,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { recipeIndex = 0; } - IRecipe recipe = recipes.get(recipeIndex); + Recipe recipe = recipes.get(recipeIndex); if (recipe instanceof CuttingRecipe) { time = ((CuttingRecipe) recipe).getProcessingDuration(); } @@ -458,9 +458,9 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { public void dropItemFromCutTree(BlockPos pos, ItemStack stack) { float distance = (float) Math.sqrt(pos.distSqr(breakingPos)); - Vector3d dropPos = VecHelper.getCenterOf(pos); + Vec3 dropPos = VecHelper.getCenterOf(pos); ItemEntity entity = new ItemEntity(level, dropPos.x, dropPos.y, dropPos.z, stack); - entity.setDeltaMovement(Vector3d.atLowerCornerOf(breakingPos.subtract(this.worldPosition)) + entity.setDeltaMovement(Vec3.atLowerCornerOf(breakingPos.subtract(this.worldPosition)) .scale(distance / 20f)); level.addFreshEntity(entity); } @@ -484,9 +484,9 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { return true; if (block instanceof SugarCaneBlock) return true; - if (block instanceof KelpBlock) + if (block instanceof KelpPlantBlock) return true; - if (block instanceof KelpTopBlock) + if (block instanceof KelpBlock) return true; if (block instanceof ChorusPlantBlock) return true; 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 4dcd0080e..21cbd05f6 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 @@ -13,7 +13,7 @@ import org.apache.commons.lang3.tuple.MutablePair; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.Create; @@ -26,39 +26,41 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.material.PushReaction; +import net.minecraft.world.level.material.PushReaction; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.item.HangingEntity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.network.IPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.datasync.DataParameter; -import net.minecraft.network.datasync.DataSerializers; -import net.minecraft.network.datasync.EntityDataManager; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.decoration.HangingEntity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtIo; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.PacketDistributor; +import net.minecraft.world.entity.Entity.MoveFunction; + public abstract class AbstractContraptionEntity extends Entity implements IEntityAdditionalSpawnData { - private static final DataParameter STALLED = - EntityDataManager.defineId(AbstractContraptionEntity.class, DataSerializers.BOOLEAN); + private static final EntityDataAccessor STALLED = + SynchedEntityData.defineId(AbstractContraptionEntity.class, EntityDataSerializers.BOOLEAN); public final Map collidingEntities; @@ -67,7 +69,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit protected boolean prevPosInvalid; private boolean ticking; - public AbstractContraptionEntity(EntityType entityTypeIn, World worldIn) { + public AbstractContraptionEntity(EntityType entityTypeIn, Level worldIn) { super(entityTypeIn, worldIn); prevPosInvalid = true; collidingEntities = new IdentityHashMap<>(); @@ -107,7 +109,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit @Override protected void removePassenger(Entity passenger) { - Vector3d transformedVector = getPassengerPosition(passenger, 1); + Vec3 transformedVector = getPassengerPosition(passenger, 1); super.removePassenger(passenger); if (level.isClientSide) return; @@ -121,16 +123,16 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } @Override - public void positionRider(Entity passenger, IMoveCallback callback) { + public void positionRider(Entity passenger, MoveFunction callback) { if (!hasPassenger(passenger)) return; - Vector3d transformedVector = getPassengerPosition(passenger, 1); + Vec3 transformedVector = getPassengerPosition(passenger, 1); if (transformedVector == null) return; callback.accept(passenger, transformedVector.x, transformedVector.y, transformedVector.z); } - protected Vector3d getPassengerPosition(Entity passenger, float partialTicks) { + protected Vec3 getPassengerPosition(Entity passenger, float partialTicks) { UUID id = passenger.getUUID(); if (passenger instanceof OrientedContraptionEntity) { BlockPos localPos = contraption.getBearingPosOf(id); @@ -140,12 +142,12 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit .subtract(.5f, 1, .5f); } - AxisAlignedBB bb = passenger.getBoundingBox(); + AABB bb = passenger.getBoundingBox(); double ySize = bb.getYsize(); BlockPos seat = contraption.getSeatOf(id); if (seat == null) return null; - Vector3d transformedVector = toGlobalVector(Vector3d.atLowerCornerOf(seat) + Vec3 transformedVector = toGlobalVector(Vec3.atLowerCornerOf(seat) .add(.5, passenger.getMyRidingOffset() + ySize - .15f, .5), partialTicks).add(VecHelper.getCenterOf(BlockPos.ZERO)) .subtract(0.5, ySize, 0.5); return transformedVector; @@ -160,8 +162,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit .size(); } - public boolean handlePlayerInteraction(PlayerEntity player, BlockPos localPos, Direction side, - Hand interactionHand) { + public boolean handlePlayerInteraction(Player player, BlockPos localPos, Direction side, + InteractionHand interactionHand) { int indexOfSeat = contraption.getSeats() .indexOf(localPos); if (indexOfSeat == -1) @@ -178,14 +180,14 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit if (!entry.getKey() .equals(entity.getUUID())) continue; - if (entity instanceof PlayerEntity) + if (entity instanceof Player) return false; toDismount = entity; } } if (toDismount != null && !level.isClientSide) { - Vector3d transformedVector = getPassengerPosition(toDismount, 1); + Vec3 transformedVector = getPassengerPosition(toDismount, 1); toDismount.stopRiding(); if (transformedVector != null) toDismount.teleportTo(transformedVector.x, transformedVector.y, transformedVector.z); @@ -197,8 +199,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit return true; } - public Vector3d toGlobalVector(Vector3d localVec, float partialTicks) { - Vector3d rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO); + public Vec3 toGlobalVector(Vec3 localVec, float partialTicks) { + Vec3 rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO); localVec = localVec.subtract(rotationOffset); localVec = applyRotation(localVec, partialTicks); localVec = localVec.add(rotationOffset) @@ -206,8 +208,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit return localVec; } - public Vector3d toLocalVector(Vector3d globalVec, float partialTicks) { - Vector3d rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO); + public Vec3 toLocalVector(Vec3 globalVec, float partialTicks) { + Vec3 rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO); globalVec = globalVec.subtract(getAnchorVec()) .subtract(rotationOffset); globalVec = reverseRotation(globalVec, partialTicks); @@ -243,9 +245,9 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit protected abstract void tickContraption(); - public abstract Vector3d applyRotation(Vector3d localPos, float partialTicks); + public abstract Vec3 applyRotation(Vec3 localPos, float partialTicks); - public abstract Vector3d reverseRotation(Vector3d localPos, float partialTicks); + public abstract Vec3 reverseRotation(Vec3 localPos, float partialTicks); public void tickActors() { boolean stalledPreviously = contraption.stalled; @@ -254,13 +256,13 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit contraption.stalled = false; ticking = true; - for (MutablePair pair : contraption.getActors()) { + for (MutablePair pair : contraption.getActors()) { MovementContext context = pair.right; - BlockInfo blockInfo = pair.left; + StructureBlockInfo blockInfo = pair.left; MovementBehaviour actor = AllMovementBehaviours.of(blockInfo.state); - Vector3d oldMotion = context.motion; - Vector3d actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos) + Vec3 oldMotion = context.motion; + Vec3 actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos) .add(actor.getActiveAreaOffset(context)), 1); BlockPos gridPosition = new BlockPos(actorPosition); boolean newPosVisited = @@ -319,14 +321,14 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit new ContraptionStallPacket(getId(), getX(), getY(), getZ(), getStalledAngle())); } - protected boolean shouldActorTrigger(MovementContext context, BlockInfo blockInfo, MovementBehaviour actor, - Vector3d actorPosition, BlockPos gridPosition) { - Vector3d previousPosition = context.position; + protected boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor, + Vec3 actorPosition, BlockPos gridPosition) { + Vec3 previousPosition = context.position; if (previousPosition == null) return false; context.motion = actorPosition.subtract(previousPosition); - Vector3d relativeMotion = context.motion; + Vec3 relativeMotion = context.motion; relativeMotion = reverseRotation(relativeMotion, 1); context.relativeMotion = relativeMotion; return !new BlockPos(previousPosition).equals(gridPosition) @@ -337,7 +339,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit setPos(getX() + x, getY() + y, getZ() + z); } - public Vector3d getAnchorVec() { + public Vec3 getAnchorVec() { return position(); } @@ -350,18 +352,18 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit super.setPos(x, y, z); if (contraption == null) return; - AxisAlignedBB cbox = contraption.bounds; + AABB cbox = contraption.bounds; if (cbox == null) return; - Vector3d actualVec = getAnchorVec(); + Vec3 actualVec = getAnchorVec(); setBoundingBox(cbox.move(actualVec)); } - public static float yawFromVector(Vector3d vec) { + public static float yawFromVector(Vec3 vec) { return (float) ((3 * Math.PI / 2 + Math.atan2(vec.z, vec.x)) / Math.PI * 180); } - public static float pitchFromVector(Vector3d vec) { + public static float pitchFromVector(Vec3 vec) { return (float) ((Math.acos(vec.y)) / Math.PI * 180); } @@ -378,30 +380,30 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } @Override - public IPacket getAddEntityPacket() { + public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override - public void writeSpawnData(PacketBuffer buffer) { - CompoundNBT compound = new CompoundNBT(); + public void writeSpawnData(FriendlyByteBuf buffer) { + CompoundTag compound = new CompoundTag(); writeAdditional(compound, true); try { ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(); - CompressedStreamTools.write(compound, dataOutput); + NbtIo.write(compound, dataOutput); byte[] byteArray = dataOutput.toByteArray(); int estimatedPacketSize = byteArray.length; if (estimatedPacketSize > 2_000_000) { Create.LOGGER.warn("Could not send Contraption Spawn Data (Packet too big): " + getContraption().getType().id + " @" + position() + " (" + getUUID().toString() + ")"); - buffer.writeNbt(new CompoundNBT()); + buffer.writeNbt(new CompoundTag()); return; } } catch (IOException e) { e.printStackTrace(); - buffer.writeNbt(new CompoundNBT()); + buffer.writeNbt(new CompoundTag()); return; } @@ -409,11 +411,11 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } @Override - protected final void addAdditionalSaveData(CompoundNBT compound) { + protected final void addAdditionalSaveData(CompoundTag compound) { writeAdditional(compound, false); } - protected void writeAdditional(CompoundNBT compound, boolean spawnPacket) { + protected void writeAdditional(CompoundTag compound, boolean spawnPacket) { if (contraption != null) compound.put("Contraption", contraption.writeNBT(spawnPacket)); compound.putBoolean("Stalled", isStalled()); @@ -421,16 +423,16 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } @Override - public void readSpawnData(PacketBuffer additionalData) { + public void readSpawnData(FriendlyByteBuf additionalData) { readAdditional(additionalData.readNbt(), true); } @Override - protected final void readAdditionalSaveData(CompoundNBT compound) { + protected final void readAdditionalSaveData(CompoundTag compound) { readAdditional(compound, false); } - protected void readAdditional(CompoundNBT compound, boolean spawnData) { + protected void readAdditional(CompoundTag compound, boolean spawnData) { if (compound.isEmpty()) return; @@ -474,8 +476,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit private void moveCollidedEntitiesOnDisassembly(StructureTransform transform) { for (Entity entity : collidingEntities.keySet()) { - Vector3d localVec = toLocalVector(entity.position(), 0); - Vector3d transformed = transform.apply(localVec); + Vec3 localVec = toLocalVector(entity.position(), 0); + Vec3 transformed = transform.apply(localVec); if (level.isClientSide) entity.setPos(transformed.x, transformed.y + 1 / 16f, transformed.z); else @@ -552,8 +554,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit @Override @SuppressWarnings("deprecation") - public CompoundNBT saveWithoutId(CompoundNBT nbt) { - Vector3d vec = position(); + public CompoundTag saveWithoutId(CompoundTag nbt) { + Vec3 vec = position(); List passengers = getPassengers(); for (Entity entity : passengers) { @@ -561,7 +563,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit entity.removed = true; // Gather passengers into same chunk when saving - Vector3d prevVec = entity.position(); + Vec3 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 @@ -569,20 +571,20 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit entity.removed = false; } - CompoundNBT tag = super.saveWithoutId(nbt); + CompoundTag tag = super.saveWithoutId(nbt); return tag; } @Override // Make sure nothing can move contraptions out of the way - public void setDeltaMovement(Vector3d motionIn) {} + public void setDeltaMovement(Vec3 motionIn) {} @Override public PushReaction getPistonPushReaction() { return PushReaction.IGNORE; } - public void setContraptionMotion(Vector3d vec) { + public void setContraptionMotion(Vec3 vec) { super.setDeltaMovement(vec); } @@ -596,34 +598,34 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit return false; } - public Vector3d getPrevPositionVec() { - return prevPosInvalid ? position() : new Vector3d(xo, yo, zo); + public Vec3 getPrevPositionVec() { + return prevPosInvalid ? position() : new Vec3(xo, yo, zo); } public abstract ContraptionRotationState getRotationState(); - public Vector3d getContactPointMotion(Vector3d globalContactPoint) { + public Vec3 getContactPointMotion(Vec3 globalContactPoint) { if (prevPosInvalid) - return Vector3d.ZERO; - Vector3d contactPoint = toGlobalVector(toLocalVector(globalContactPoint, 0), 1); + return Vec3.ZERO; + Vec3 contactPoint = toGlobalVector(toLocalVector(globalContactPoint, 0), 1); return contactPoint.subtract(globalContactPoint) .add(position().subtract(getPrevPositionVec())); } public boolean canCollideWith(Entity e) { - if (e instanceof PlayerEntity && e.isSpectator()) + if (e instanceof Player && e.isSpectator()) return false; if (e.noPhysics) return false; if (e instanceof HangingEntity) return false; - if (e instanceof AbstractMinecartEntity) + if (e instanceof AbstractMinecart) return !(contraption instanceof MountedContraption); if (e instanceof SuperGlueEntity) return false; if (e instanceof SeatEntity) return false; - if (e instanceof ProjectileEntity) + if (e instanceof Projectile) return false; if (e.getVehicle() != null) return false; @@ -644,7 +646,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } @OnlyIn(Dist.CLIENT) - public abstract void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks); + public abstract void doLocalTransforms(float partialTicks, PoseStack[] matrixStacks); public static class ContraptionRotationState { public static final ContraptionRotationState NONE = new ContraptionRotationState(); 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 0f1972ad4..7ac6528c1 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 @@ -2,24 +2,24 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import com.simibubi.create.foundation.config.AllConfigs; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; public class AssemblyException extends Exception { private static final long serialVersionUID = 1L; - public final ITextComponent component; + public final Component component; private BlockPos position = null; - public static void write(CompoundNBT compound, AssemblyException exception) { + public static void write(CompoundTag compound, AssemblyException exception) { if (exception == null) return; - CompoundNBT nbt = new CompoundNBT(); - nbt.putString("Component", ITextComponent.Serializer.toJson(exception.component)); + CompoundTag nbt = new CompoundTag(); + nbt.putString("Component", Component.Serializer.toJson(exception.component)); if (exception.hasPosition()) nbt.putLong("Position", exception.getPosition() .asLong()); @@ -27,30 +27,30 @@ public class AssemblyException extends Exception { compound.put("LastException", nbt); } - public static AssemblyException read(CompoundNBT compound) { + public static AssemblyException read(CompoundTag compound) { if (!compound.contains("LastException")) return null; - CompoundNBT nbt = compound.getCompound("LastException"); + CompoundTag nbt = compound.getCompound("LastException"); String string = nbt.getString("Component"); - AssemblyException exception = new AssemblyException(ITextComponent.Serializer.fromJson(string)); + AssemblyException exception = new AssemblyException(Component.Serializer.fromJson(string)); if (nbt.contains("Position")) exception.position = BlockPos.of(nbt.getLong("Position")); return exception; } - public AssemblyException(ITextComponent component) { + public AssemblyException(Component component) { this.component = component; } public AssemblyException(String langKey, Object... objects) { - this(new TranslationTextComponent("create.gui.assembly.exception." + langKey, objects)); + this(new TranslatableComponent("create.gui.assembly.exception." + langKey, objects)); } public static AssemblyException unmovableBlock(BlockPos pos, BlockState state) { AssemblyException e = new AssemblyException("unmovableBlock", pos.getX(), pos.getY(), pos.getZ(), - new TranslationTextComponent(state.getBlock() + new TranslatableComponent(state.getBlock() .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 ba3966261..81aac2f38 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 @@ -32,39 +32,39 @@ import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkBlock; import com.simibubi.create.foundation.config.ContraptionMovementSetting; -import net.minecraft.block.AbstractPressurePlateBlock; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.AbstractSignBlock; -import net.minecraft.block.BedBlock; -import net.minecraft.block.BellBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CarpetBlock; -import net.minecraft.block.DoorBlock; -import net.minecraft.block.FenceGateBlock; -import net.minecraft.block.FlowerPotBlock; -import net.minecraft.block.GrindstoneBlock; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.block.HorizontalFaceBlock; -import net.minecraft.block.LadderBlock; -import net.minecraft.block.RedstoneDiodeBlock; -import net.minecraft.block.RedstoneWallTorchBlock; -import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.block.StandingSignBlock; -import net.minecraft.block.TorchBlock; -import net.minecraft.block.WallSignBlock; -import net.minecraft.block.WallTorchBlock; -import net.minecraft.block.material.PushReaction; -import net.minecraft.state.properties.AttachFace; -import net.minecraft.state.properties.BedPart; -import net.minecraft.state.properties.BellAttachment; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.BasePressurePlateBlock; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.SignBlock; +import net.minecraft.world.level.block.BedBlock; +import net.minecraft.world.level.block.BellBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.WoolCarpetBlock; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.FenceGateBlock; +import net.minecraft.world.level.block.FlowerPotBlock; +import net.minecraft.world.level.block.GrindstoneBlock; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock; +import net.minecraft.world.level.block.LadderBlock; +import net.minecraft.world.level.block.DiodeBlock; +import net.minecraft.world.level.block.RedstoneWallTorchBlock; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.world.level.block.StandingSignBlock; +import net.minecraft.world.level.block.TorchBlock; +import net.minecraft.world.level.block.WallSignBlock; +import net.minecraft.world.level.block.WallTorchBlock; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.level.block.state.properties.BedPart; +import net.minecraft.world.level.block.state.properties.BellAttachType; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class BlockMovementChecks { @@ -108,7 +108,7 @@ public class BlockMovementChecks { // Actual check methods - public static boolean isMovementNecessary(BlockState state, World world, BlockPos pos) { + public static boolean isMovementNecessary(BlockState state, Level world, BlockPos pos) { for (MovementNecessaryCheck check : MOVEMENT_NECESSARY_CHECKS) { CheckResult result = check.isMovementNecessary(state, world, pos); if (result != CheckResult.PASS) { @@ -118,7 +118,7 @@ public class BlockMovementChecks { return isMovementNecessaryFallback(state, world, pos); } - public static boolean isMovementAllowed(BlockState state, World world, BlockPos pos) { + public static boolean isMovementAllowed(BlockState state, Level world, BlockPos pos) { for (MovementAllowedCheck check : MOVEMENT_ALLOWED_CHECKS) { CheckResult result = check.isMovementAllowed(state, world, pos); if (result != CheckResult.PASS) { @@ -145,7 +145,7 @@ public class BlockMovementChecks { /** * Attached blocks will move if blocks they are attached to are moved */ - public static boolean isBlockAttachedTowards(BlockState state, World world, BlockPos pos, + public static boolean isBlockAttachedTowards(BlockState state, Level world, BlockPos pos, Direction direction) { for (AttachedCheck check : ATTACHED_CHECKS) { CheckResult result = check.isBlockAttachedTowards(state, world, pos, direction); @@ -172,7 +172,7 @@ public class BlockMovementChecks { // Fallback checks - private static boolean isMovementNecessaryFallback(BlockState state, World world, BlockPos pos) { + private static boolean isMovementNecessaryFallback(BlockState state, Level world, BlockPos pos) { if (isBrittle(state)) return true; if (state.getBlock() instanceof FenceGateBlock) @@ -186,7 +186,7 @@ public class BlockMovementChecks { return true; } - private static boolean isMovementAllowedFallback(BlockState state, World world, BlockPos pos) { + private static boolean isMovementAllowedFallback(BlockState state, Level world, BlockPos pos) { Block block = state.getBlock(); if (block instanceof AbstractChassisBlock) return true; @@ -201,22 +201,22 @@ public class BlockMovementChecks { if (block instanceof MechanicalPistonBlock && state.getValue(MechanicalPistonBlock.STATE) != PistonState.MOVING) return true; if (block instanceof MechanicalBearingBlock) { - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (te instanceof MechanicalBearingTileEntity) return !((MechanicalBearingTileEntity) te).isRunning(); } if (block instanceof WindmillBearingBlock) { - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (te instanceof WindmillBearingTileEntity) return !((WindmillBearingTileEntity) te).isRunning(); } if (block instanceof ClockworkBearingBlock) { - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (te instanceof ClockworkBearingTileEntity) return !((ClockworkBearingTileEntity) te).isRunning(); } if (block instanceof PulleyBlock) { - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (te instanceof PulleyTileEntity) return !((PulleyTileEntity) te).running; } @@ -237,26 +237,26 @@ public class BlockMovementChecks { return true; if (block instanceof TorchBlock) return true; - if (block instanceof AbstractSignBlock) + if (block instanceof SignBlock) return true; - if (block instanceof AbstractPressurePlateBlock) + if (block instanceof BasePressurePlateBlock) return true; - if (block instanceof HorizontalFaceBlock && !(block instanceof GrindstoneBlock)) + if (block instanceof FaceAttachedHorizontalDirectionalBlock && !(block instanceof GrindstoneBlock)) return true; if (block instanceof CartAssemblerBlock) return false; - if (block instanceof AbstractRailBlock) + if (block instanceof BaseRailBlock) return true; - if (block instanceof RedstoneDiodeBlock) + if (block instanceof DiodeBlock) return true; - if (block instanceof RedstoneWireBlock) + if (block instanceof RedStoneWireBlock) return true; - if (block instanceof CarpetBlock) + if (block instanceof WoolCarpetBlock) return true; return AllBlockTags.BRITTLE.tag.contains(block); } - private static boolean isBlockAttachedTowardsFallback(BlockState state, World world, BlockPos pos, + private static boolean isBlockAttachedTowardsFallback(BlockState state, Level world, BlockPos pos, Direction direction) { Block block = state.getBlock(); if (block instanceof LadderBlock) @@ -267,7 +267,7 @@ public class BlockMovementChecks { return state.getValue(WallSignBlock.FACING) == direction.getOpposite(); if (block instanceof StandingSignBlock) return direction == Direction.DOWN; - if (block instanceof AbstractPressurePlateBlock) + if (block instanceof BasePressurePlateBlock) return direction == Direction.DOWN; if (block instanceof DoorBlock) { if (state.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER && direction == Direction.UP) @@ -284,28 +284,28 @@ public class BlockMovementChecks { return direction.getOpposite() == state.getValue(RedstoneLinkBlock.FACING); if (block instanceof FlowerPotBlock) return direction == Direction.DOWN; - if (block instanceof RedstoneDiodeBlock) + if (block instanceof DiodeBlock) return direction == Direction.DOWN; - if (block instanceof RedstoneWireBlock) + if (block instanceof RedStoneWireBlock) return direction == Direction.DOWN; - if (block instanceof CarpetBlock) + if (block instanceof WoolCarpetBlock) return direction == Direction.DOWN; if (block instanceof RedstoneWallTorchBlock) return state.getValue(RedstoneWallTorchBlock.FACING) == direction.getOpposite(); if (block instanceof TorchBlock) return direction == Direction.DOWN; - if (block instanceof HorizontalFaceBlock) { - AttachFace attachFace = state.getValue(HorizontalFaceBlock.FACE); + if (block instanceof FaceAttachedHorizontalDirectionalBlock) { + AttachFace attachFace = state.getValue(FaceAttachedHorizontalDirectionalBlock.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.getValue(HorizontalFaceBlock.FACING); + return direction.getOpposite() == state.getValue(FaceAttachedHorizontalDirectionalBlock.FACING); } if (state.hasProperty(BlockStateProperties.HANGING)) return direction == (state.getValue(BlockStateProperties.HANGING) ? Direction.UP : Direction.DOWN); - if (block instanceof AbstractRailBlock) + if (block instanceof BaseRailBlock) return direction == Direction.DOWN; if (block instanceof AttachedActorBlock) return direction == state.getValue(HarvesterBlock.FACING) @@ -320,12 +320,12 @@ public class BlockMovementChecks { return direction == state.getValue(EngineBlock.FACING) .getOpposite(); if (block instanceof BellBlock) { - BellAttachment attachment = state.getValue(BlockStateProperties.BELL_ATTACHMENT); - if (attachment == BellAttachment.FLOOR) + BellAttachType attachment = state.getValue(BlockStateProperties.BELL_ATTACHMENT); + if (attachment == BellAttachType.FLOOR) return direction == Direction.DOWN; - if (attachment == BellAttachment.CEILING) + if (attachment == BellAttachType.CEILING) return direction == Direction.UP; - return direction == state.getValue(HorizontalBlock.FACING); + return direction == state.getValue(HorizontalDirectionalBlock.FACING); } if (state.getBlock() instanceof SailBlock) return direction.getAxis() != state.getValue(SailBlock.FACING) @@ -354,7 +354,7 @@ public class BlockMovementChecks { return state.getValue(BlockStateProperties.HORIZONTAL_FACING) == facing; if (AllBlocks.ROPE_PULLEY.has(state)) return facing == Direction.DOWN; - if (state.getBlock() instanceof CarpetBlock) + if (state.getBlock() instanceof WoolCarpetBlock) return facing == Direction.UP; if (state.getBlock() instanceof SailBlock) return facing.getAxis() == state.getValue(SailBlock.FACING) @@ -373,11 +373,11 @@ public class BlockMovementChecks { // Check classes public static interface MovementNecessaryCheck { - public CheckResult isMovementNecessary(BlockState state, World world, BlockPos pos); + public CheckResult isMovementNecessary(BlockState state, Level world, BlockPos pos); } public static interface MovementAllowedCheck { - public CheckResult isMovementAllowed(BlockState state, World world, BlockPos pos); + public CheckResult isMovementAllowed(BlockState state, Level world, BlockPos pos); } public static interface BrittleCheck { @@ -392,7 +392,7 @@ public class BlockMovementChecks { /** * Attached blocks will move if blocks they are attached to are moved */ - public CheckResult isBlockAttachedTowards(BlockState state, World world, BlockPos pos, Direction direction); + public CheckResult isBlockAttachedTowards(BlockState state, Level world, BlockPos pos, Direction direction); } public static interface NotSupportiveCheck { 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 44084fe7e..75e4f5a0b 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 @@ -71,42 +71,42 @@ import com.simibubi.create.foundation.utility.NBTProcessors; import com.simibubi.create.foundation.utility.UniqueLinkedList; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.AbstractButtonBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.block.PressurePlateBlock; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.Entity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.network.DebugPacketSender; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.ChestType; -import net.minecraft.state.properties.PistonType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.ButtonBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ChestBlock; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.block.PressurePlateBlock; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.protocol.game.DebugPackets; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.ChestType; +import net.minecraft.world.level.block.state.properties.PistonType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.shapes.IBooleanFunction; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.palette.HashMapPalette; -import net.minecraft.village.PointOfInterestType; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.chunk.HashMapPalette; +import net.minecraft.world.entity.ai.village.poi.PoiType; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.Constants.BlockFlags; @@ -122,19 +122,19 @@ import net.minecraftforge.registries.GameData; public abstract class Contraption { - public Optional> simplifiedEntityColliders; + public Optional> simplifiedEntityColliders; public AbstractContraptionEntity entity; public ContraptionInvWrapper inventory; public CombinedTankWrapper fluidInventory; - public AxisAlignedBB bounds; + public AABB bounds; public BlockPos anchor; public boolean stalled; public boolean hasUniversalCreativeCrate; - protected Map blocks; + protected Map blocks; protected Map storage; protected Map fluidStorage; - protected List> actors; + protected List> actors; protected Map interactors; protected Set> superglue; protected List seats; @@ -148,9 +148,9 @@ public abstract class Contraption { private CompletableFuture simplifiedEntityColliderProvider; // Client - public Map presentTileEntities; - public List maybeInstancedTileEntities; - public List specialRenderedTileEntities; + public Map presentTileEntities; + public List maybeInstancedTileEntities; + public List specialRenderedTileEntities; protected ContraptionWorld world; @@ -179,26 +179,26 @@ public abstract class Contraption { return world; } - public abstract boolean assemble(World world, BlockPos pos) throws AssemblyException; + public abstract boolean assemble(Level world, BlockPos pos) throws AssemblyException; public abstract boolean canBeStabilized(Direction facing, BlockPos localPos); protected abstract ContraptionType getType(); - protected boolean customBlockPlacement(IWorld world, BlockPos pos, BlockState state) { + protected boolean customBlockPlacement(LevelAccessor world, BlockPos pos, BlockState state) { return false; } - protected boolean customBlockRemoval(IWorld world, BlockPos pos, BlockState state) { + protected boolean customBlockRemoval(LevelAccessor world, BlockPos pos, BlockState state) { return false; } - protected boolean addToInitialFrontier(World world, BlockPos pos, Direction forcedDirection, + protected boolean addToInitialFrontier(Level world, BlockPos pos, Direction forcedDirection, Queue frontier) throws AssemblyException { return true; } - public static Contraption fromNBT(World world, CompoundNBT nbt, boolean spawnData) { + public static Contraption fromNBT(Level world, CompoundTag nbt, boolean spawnData) { String type = nbt.getString("Type"); Contraption contraption = ContraptionType.fromType(type); contraption.readNBT(world, nbt, spawnData); @@ -207,7 +207,7 @@ public abstract class Contraption { return contraption; } - public boolean searchMovedStructure(World world, BlockPos pos, @Nullable Direction forcedDirection) + public boolean searchMovedStructure(Level world, BlockPos pos, @Nullable Direction forcedDirection) throws AssemblyException { initialPassengers.clear(); Queue frontier = new UniqueLinkedList<>(); @@ -215,7 +215,7 @@ public abstract class Contraption { anchor = pos; if (bounds == null) - bounds = new AxisAlignedBB(BlockPos.ZERO); + bounds = new AABB(BlockPos.ZERO); if (!BlockMovementChecks.isBrittle(world.getBlockState(pos))) frontier.add(pos); @@ -237,7 +237,7 @@ public abstract class Contraption { for (BlockFace blockFace : pendingSubContraptions) { Direction face = blockFace.getFace(); StabilizedContraption subContraption = new StabilizedContraption(face); - World world = entity.level; + Level world = entity.level; BlockPos pos = blockFace.getPos(); try { if (!subContraption.assemble(world, pos)) @@ -277,7 +277,7 @@ public abstract class Contraption { } } - public void onEntityInitialize(World world, AbstractContraptionEntity contraptionEntity) { + public void onEntityInitialize(Level world, AbstractContraptionEntity contraptionEntity) { if (world.isClientSide) return; @@ -298,19 +298,19 @@ public abstract class Contraption { } } - public void onEntityTick(World world) { + public void onEntityTick(Level world) { fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, world.isClientSide)); } /** move the first block in frontier queue */ - protected boolean moveBlock(World world, @Nullable Direction forcedDirection, Queue frontier, + protected boolean moveBlock(Level world, @Nullable Direction forcedDirection, Queue frontier, Set visited) throws AssemblyException { BlockPos pos = frontier.poll(); if (pos == null) return false; visited.add(pos); - if (World.isOutsideBuildHeight(pos)) + if (Level.isOutsideBuildHeight(pos)) return true; if (!world.isLoaded(pos)) throw AssemblyException.unloadedChunk(pos); @@ -423,7 +423,7 @@ public abstract class Contraption { throw AssemblyException.structureTooLarge(); } - protected void movePistonHead(World world, BlockPos pos, Queue frontier, Set visited, + protected void movePistonHead(Level world, BlockPos pos, Queue frontier, Set visited, BlockState state) { Direction direction = state.getValue(MechanicalPistonHeadBlock.FACING); BlockPos offset = pos.relative(direction.getOpposite()); @@ -446,7 +446,7 @@ public abstract class Contraption { } } - protected void movePistonPole(World world, BlockPos pos, Queue frontier, Set visited, + protected void movePistonPole(Level world, BlockPos pos, Queue frontier, Set visited, BlockState state) { for (Direction d : Iterate.directionsInAxis(state.getValue(PistonExtensionPoleBlock.FACING) .getAxis())) { @@ -469,7 +469,7 @@ public abstract class Contraption { } } - protected void moveGantryPinion(World world, BlockPos pos, Queue frontier, Set visited, + protected void moveGantryPinion(Level world, BlockPos pos, Queue frontier, Set visited, BlockState state) { BlockPos offset = pos.relative(state.getValue(GantryCarriageBlock.FACING)); if (!visited.contains(offset)) @@ -485,7 +485,7 @@ public abstract class Contraption { } } - protected void moveGantryShaft(World world, BlockPos pos, Queue frontier, Set visited, + protected void moveGantryShaft(Level world, BlockPos pos, Queue frontier, Set visited, BlockState state) { for (Direction d : Iterate.directions) { BlockPos offset = pos.relative(d); @@ -529,10 +529,10 @@ public abstract class Contraption { frontier.add(prevPos); } - private void moveSeat(World world, BlockPos pos) { + private void moveSeat(Level world, BlockPos pos) { BlockPos local = toLocalPos(pos); getSeats().add(local); - List seatsEntities = world.getEntitiesOfClass(SeatEntity.class, new AxisAlignedBB(pos)); + List seatsEntities = world.getEntitiesOfClass(SeatEntity.class, new AABB(pos)); if (!seatsEntities.isEmpty()) { SeatEntity seat = seatsEntities.get(0); List passengers = seat.getPassengers(); @@ -541,7 +541,7 @@ public abstract class Contraption { } } - private void movePulley(World world, BlockPos pos, Queue frontier, Set visited) { + private void movePulley(Level world, BlockPos pos, Queue frontier, Set visited) { int limit = AllConfigs.SERVER.kinetics.maxRopeLength.get(); BlockPos ropePos = pos; while (limit-- >= 0) { @@ -559,7 +559,7 @@ public abstract class Contraption { } } - private boolean moveMechanicalPiston(World world, BlockPos pos, Queue frontier, Set visited, + private boolean moveMechanicalPiston(Level world, BlockPos pos, Queue frontier, Set visited, BlockState state) throws AssemblyException { Direction direction = state.getValue(MechanicalPistonBlock.FACING); PistonState pistonState = state.getValue(MechanicalPistonBlock.STATE); @@ -583,9 +583,9 @@ public abstract class Contraption { return true; } - private boolean moveChassis(World world, BlockPos pos, Direction movementDirection, Queue frontier, + private boolean moveChassis(Level world, BlockPos pos, Direction movementDirection, Queue frontier, Set visited) { - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (!(te instanceof ChassisTileEntity)) return false; ChassisTileEntity chassis = (ChassisTileEntity) te; @@ -599,7 +599,7 @@ public abstract class Contraption { return true; } - protected Pair capture(World world, BlockPos pos) { + protected Pair capture(Level world, BlockPos pos) { BlockState blockstate = world.getBlockState(pos); if (blockstate.getBlock() instanceof ChestBlock) blockstate = blockstate.setValue(ChestBlock.TYPE, ChestType.SINGLE); @@ -607,8 +607,8 @@ public abstract class Contraption { blockstate = blockstate.setValue(AdjustableCrateBlock.DOUBLE, false); if (AllBlocks.REDSTONE_CONTACT.has(blockstate)) blockstate = blockstate.setValue(RedstoneContactBlock.POWERED, true); - if (blockstate.getBlock() instanceof AbstractButtonBlock) { - blockstate = blockstate.setValue(AbstractButtonBlock.POWERED, false); + if (blockstate.getBlock() instanceof ButtonBlock) { + blockstate = blockstate.setValue(ButtonBlock.POWERED, false); world.getBlockTicks() .scheduleTick(pos, blockstate.getBlock(), -1); } @@ -617,21 +617,21 @@ public abstract class Contraption { world.getBlockTicks() .scheduleTick(pos, blockstate.getBlock(), -1); } - CompoundNBT compoundnbt = getTileEntityNBT(world, pos); - TileEntity tileentity = world.getBlockEntity(pos); - return Pair.of(new BlockInfo(pos, blockstate, compoundnbt), tileentity); + CompoundTag compoundnbt = getTileEntityNBT(world, pos); + BlockEntity tileentity = world.getBlockEntity(pos); + return Pair.of(new StructureBlockInfo(pos, blockstate, compoundnbt), tileentity); } - protected void addBlock(BlockPos pos, Pair pair) { - BlockInfo captured = pair.getKey(); + protected void addBlock(BlockPos pos, Pair pair) { + StructureBlockInfo captured = pair.getKey(); BlockPos localPos = pos.subtract(anchor); - BlockInfo blockInfo = new BlockInfo(localPos, captured.state, captured.nbt); + StructureBlockInfo blockInfo = new StructureBlockInfo(localPos, captured.state, captured.nbt); if (blocks.put(localPos, blockInfo) != null) return; - bounds = bounds.minmax(new AxisAlignedBB(localPos)); + bounds = bounds.minmax(new AABB(localPos)); - TileEntity te = pair.getValue(); + BlockEntity te = pair.getValue(); if (te != null && MountedStorage.canUseAsStorage(te)) storage.put(localPos, new MountedStorage(te)); if (te != null && MountedFluidStorage.canUseAsStorage(te)) @@ -648,18 +648,18 @@ public abstract class Contraption { } @Nullable - protected CompoundNBT getTileEntityNBT(World world, BlockPos pos) { - TileEntity tileentity = world.getBlockEntity(pos); + protected CompoundTag getTileEntityNBT(Level world, BlockPos pos) { + BlockEntity tileentity = world.getBlockEntity(pos); if (tileentity == null) return null; - CompoundNBT nbt = tileentity.save(new CompoundNBT()); + CompoundTag nbt = tileentity.save(new CompoundTag()); nbt.remove("x"); nbt.remove("y"); nbt.remove("z"); if (tileentity instanceof FluidTankTileEntity && nbt.contains("Controller")) nbt.put("Controller", - NBTUtil.writeBlockPos(toLocalPos(NBTUtil.readBlockPos(nbt.getCompound("Controller"))))); + NbtUtils.writeBlockPos(toLocalPos(NbtUtils.readBlockPos(nbt.getCompound("Controller"))))); return nbt; } @@ -675,7 +675,7 @@ public abstract class Contraption { return globalPos.subtract(anchor); } - protected boolean movementAllowed(BlockState state, World world, BlockPos pos) { + protected boolean movementAllowed(BlockState state, Level world, BlockPos pos) { return BlockMovementChecks.isMovementAllowed(state, world, pos); } @@ -683,36 +683,36 @@ public abstract class Contraption { return pos.equals(anchor); } - public void readNBT(World world, CompoundNBT nbt, boolean spawnData) { + public void readNBT(Level world, CompoundTag nbt, boolean spawnData) { blocks.clear(); presentTileEntities.clear(); specialRenderedTileEntities.clear(); - INBT blocks = nbt.get("Blocks"); + Tag blocks = nbt.get("Blocks"); // used to differentiate between the 'old' and the paletted serialization boolean usePalettedDeserialization = - blocks != null && blocks.getId() == 10 && ((CompoundNBT) blocks).contains("Palette"); + blocks != null && blocks.getId() == 10 && ((CompoundTag) blocks).contains("Palette"); readBlocksCompound(blocks, world, usePalettedDeserialization); actors.clear(); nbt.getList("Actors", 10) .forEach(c -> { - CompoundNBT comp = (CompoundNBT) c; - BlockInfo info = this.blocks.get(NBTUtil.readBlockPos(comp.getCompound("Pos"))); + CompoundTag comp = (CompoundTag) c; + StructureBlockInfo info = this.blocks.get(NbtUtils.readBlockPos(comp.getCompound("Pos"))); MovementContext context = MovementContext.readNBT(world, info, comp, this); getActors().add(MutablePair.of(info, context)); }); superglue.clear(); NBTHelper.iterateCompoundList(nbt.getList("Superglue", NBT.TAG_COMPOUND), c -> superglue.add( - Pair.of(NBTUtil.readBlockPos(c.getCompound("Pos")), Direction.from3DDataValue(c.getByte("Direction"))))); + Pair.of(NbtUtils.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))); + NBTHelper.iterateCompoundList(nbt.getList("Seats", NBT.TAG_COMPOUND), c -> seats.add(NbtUtils.readBlockPos(c))); seatMapping.clear(); NBTHelper.iterateCompoundList(nbt.getList("Passengers", NBT.TAG_COMPOUND), - c -> seatMapping.put(NBTUtil.loadUUID(NBTHelper.getINBT(c, "Id")), c.getInt("Seat"))); + c -> seatMapping.put(NbtUtils.loadUUID(NBTHelper.getINBT(c, "Id")), c.getInt("Seat"))); stabilizedSubContraptions.clear(); NBTHelper.iterateCompoundList(nbt.getList("SubContraptions", NBT.TAG_COMPOUND), @@ -720,15 +720,15 @@ public abstract class Contraption { storage.clear(); NBTHelper.iterateCompoundList(nbt.getList("Storage", NBT.TAG_COMPOUND), c -> storage - .put(NBTUtil.readBlockPos(c.getCompound("Pos")), MountedStorage.deserialize(c.getCompound("Data")))); + .put(NbtUtils.readBlockPos(c.getCompound("Pos")), MountedStorage.deserialize(c.getCompound("Data")))); fluidStorage.clear(); NBTHelper.iterateCompoundList(nbt.getList("FluidStorage", NBT.TAG_COMPOUND), c -> fluidStorage - .put(NBTUtil.readBlockPos(c.getCompound("Pos")), MountedFluidStorage.deserialize(c.getCompound("Data")))); + .put(NbtUtils.readBlockPos(c.getCompound("Pos")), MountedFluidStorage.deserialize(c.getCompound("Data")))); interactors.clear(); NBTHelper.iterateCompoundList(nbt.getList("Interactors", NBT.TAG_COMPOUND), c -> { - BlockPos pos = NBTUtil.readBlockPos(c.getCompound("Pos")); + BlockPos pos = NbtUtils.readBlockPos(c.getCompound("Pos")); MovingInteractionBehaviour behaviour = AllInteractionBehaviours.of(getBlocks().get(pos).state.getBlock()); if (behaviour != null) interactors.put(pos, behaviour); @@ -736,7 +736,7 @@ public abstract class Contraption { if (spawnData) fluidStorage.forEach((pos, mfs) -> { - TileEntity tileEntity = presentTileEntities.get(pos); + BlockEntity tileEntity = presentTileEntities.get(pos); if (!(tileEntity instanceof FluidTankTileEntity)) return; FluidTankTileEntity tank = (FluidTankTileEntity) tileEntity; @@ -766,75 +766,75 @@ public abstract class Contraption { stalled = nbt.getBoolean("Stalled"); hasUniversalCreativeCrate = nbt.getBoolean("BottomlessSupply"); - anchor = NBTUtil.readBlockPos(nbt.getCompound("Anchor")); + anchor = NbtUtils.readBlockPos(nbt.getCompound("Anchor")); } - public CompoundNBT writeNBT(boolean spawnPacket) { - CompoundNBT nbt = new CompoundNBT(); + public CompoundTag writeNBT(boolean spawnPacket) { + CompoundTag nbt = new CompoundTag(); nbt.putString("Type", getType().id); - CompoundNBT blocksNBT = writeBlocksCompound(); + CompoundTag blocksNBT = writeBlocksCompound(); - ListNBT actorsNBT = new ListNBT(); - for (MutablePair actor : getActors()) { - CompoundNBT compound = new CompoundNBT(); - compound.put("Pos", NBTUtil.writeBlockPos(actor.left.pos)); + ListTag actorsNBT = new ListTag(); + for (MutablePair actor : getActors()) { + CompoundTag compound = new CompoundTag(); + compound.put("Pos", NbtUtils.writeBlockPos(actor.left.pos)); AllMovementBehaviours.of(actor.left.state) .writeExtraData(actor.right); actor.right.writeToNBT(compound); actorsNBT.add(compound); } - ListNBT superglueNBT = new ListNBT(); - ListNBT storageNBT = new ListNBT(); + ListTag superglueNBT = new ListTag(); + ListTag storageNBT = new ListTag(); if (!spawnPacket) { for (Pair glueEntry : superglue) { - CompoundNBT c = new CompoundNBT(); - c.put("Pos", NBTUtil.writeBlockPos(glueEntry.getKey())); + CompoundTag c = new CompoundTag(); + c.put("Pos", NbtUtils.writeBlockPos(glueEntry.getKey())); c.putByte("Direction", (byte) glueEntry.getValue() .get3DDataValue()); superglueNBT.add(c); } for (BlockPos pos : storage.keySet()) { - CompoundNBT c = new CompoundNBT(); + CompoundTag c = new CompoundTag(); MountedStorage mountedStorage = storage.get(pos); if (!mountedStorage.isValid()) continue; - c.put("Pos", NBTUtil.writeBlockPos(pos)); + c.put("Pos", NbtUtils.writeBlockPos(pos)); c.put("Data", mountedStorage.serialize()); storageNBT.add(c); } } - ListNBT fluidStorageNBT = new ListNBT(); + ListTag fluidStorageNBT = new ListTag(); for (BlockPos pos : fluidStorage.keySet()) { - CompoundNBT c = new CompoundNBT(); + CompoundTag c = new CompoundTag(); MountedFluidStorage mountedStorage = fluidStorage.get(pos); if (!mountedStorage.isValid()) continue; - c.put("Pos", NBTUtil.writeBlockPos(pos)); + c.put("Pos", NbtUtils.writeBlockPos(pos)); c.put("Data", mountedStorage.serialize()); fluidStorageNBT.add(c); } - ListNBT interactorNBT = new ListNBT(); + ListTag interactorNBT = new ListTag(); for (BlockPos pos : interactors.keySet()) { - CompoundNBT c = new CompoundNBT(); - c.put("Pos", NBTUtil.writeBlockPos(pos)); + CompoundTag c = new CompoundTag(); + c.put("Pos", NbtUtils.writeBlockPos(pos)); interactorNBT.add(c); } - nbt.put("Seats", NBTHelper.writeCompoundList(getSeats(), NBTUtil::writeBlockPos)); + nbt.put("Seats", NBTHelper.writeCompoundList(getSeats(), NbtUtils::writeBlockPos)); nbt.put("Passengers", NBTHelper.writeCompoundList(getSeatMapping().entrySet(), e -> { - CompoundNBT tag = new CompoundNBT(); - tag.put("Id", NBTUtil.createUUID(e.getKey())); + CompoundTag tag = new CompoundTag(); + tag.put("Id", NbtUtils.createUUID(e.getKey())); tag.putInt("Seat", e.getValue()); return tag; })); nbt.put("SubContraptions", NBTHelper.writeCompoundList(stabilizedSubContraptions.entrySet(), e -> { - CompoundNBT tag = new CompoundNBT(); + CompoundTag tag = new CompoundTag(); tag.putUUID("Id", e.getKey()); tag.put("Location", e.getValue() .serializeNBT()); @@ -847,28 +847,28 @@ public abstract class Contraption { nbt.put("Superglue", superglueNBT); nbt.put("Storage", storageNBT); nbt.put("FluidStorage", fluidStorageNBT); - nbt.put("Anchor", NBTUtil.writeBlockPos(anchor)); + nbt.put("Anchor", NbtUtils.writeBlockPos(anchor)); nbt.putBoolean("Stalled", stalled); nbt.putBoolean("BottomlessSupply", hasUniversalCreativeCrate); if (bounds != null) { - ListNBT bb = NBTHelper.writeAABB(bounds); + ListTag bb = NBTHelper.writeAABB(bounds); nbt.put("BoundsFront", bb); } return nbt; } - private CompoundNBT writeBlocksCompound() { - CompoundNBT compound = new CompoundNBT(); + private CompoundTag writeBlocksCompound() { + CompoundTag compound = new CompoundTag(); HashMapPalette palette = new HashMapPalette<>(GameData.getBlockStateIDMap(), 16, (i, s) -> { throw new IllegalStateException("Palette Map index exceeded maximum"); - }, NBTUtil::readBlockState, NBTUtil::writeBlockState); - ListNBT blockList = new ListNBT(); + }, NbtUtils::readBlockState, NbtUtils::writeBlockState); + ListTag blockList = new ListTag(); - for (BlockInfo block : this.blocks.values()) { + for (StructureBlockInfo block : this.blocks.values()) { int id = palette.idFor(block.state); - CompoundNBT c = new CompoundNBT(); + CompoundTag c = new CompoundTag(); c.putLong("Pos", block.pos.asLong()); c.putInt("State", id); if (block.nbt != null) @@ -876,7 +876,7 @@ public abstract class Contraption { blockList.add(c); } - ListNBT paletteNBT = new ListNBT(); + ListTag paletteNBT = new ListTag(); palette.write(paletteNBT); compound.put("Palette", paletteNBT); compound.put("BlockList", blockList); @@ -884,32 +884,32 @@ public abstract class Contraption { return compound; } - private void readBlocksCompound(INBT compound, World world, boolean usePalettedDeserialization) { + private void readBlocksCompound(Tag compound, Level world, boolean usePalettedDeserialization) { HashMapPalette palette = null; - ListNBT blockList; + ListTag blockList; if (usePalettedDeserialization) { - CompoundNBT c = ((CompoundNBT) compound); + CompoundTag c = ((CompoundTag) compound); palette = new HashMapPalette<>(GameData.getBlockStateIDMap(), 16, (i, s) -> { throw new IllegalStateException("Palette Map index exceeded maximum"); - }, NBTUtil::readBlockState, NBTUtil::writeBlockState); + }, NbtUtils::readBlockState, NbtUtils::writeBlockState); palette.read(c.getList("Palette", 10)); blockList = c.getList("BlockList", 10); } else { - blockList = (ListNBT) compound; + blockList = (ListTag) compound; } HashMapPalette finalPalette = palette; blockList.forEach(e -> { - CompoundNBT c = (CompoundNBT) e; + CompoundTag c = (CompoundTag) e; - BlockInfo info = usePalettedDeserialization ? readBlockInfo(c, finalPalette) : legacyReadBlockInfo(c); + StructureBlockInfo info = usePalettedDeserialization ? readBlockInfo(c, finalPalette) : legacyReadBlockInfo(c); this.blocks.put(info.pos, info); if (world.isClientSide) { Block block = info.state.getBlock(); - CompoundNBT tag = info.nbt; + CompoundTag tag = info.nbt; MovementBehaviour movementBehaviour = AllMovementBehaviours.of(block); if (tag == null) return; @@ -918,7 +918,7 @@ public abstract class Contraption { tag.putInt("y", info.pos.getY()); tag.putInt("z", info.pos.getZ()); - TileEntity te = TileEntity.loadStatic(info.state, tag); + BlockEntity te = BlockEntity.loadStatic(info.state, tag); if (te == null) return; te.setLevelAndPosition(new ContraptionTileWorld(world, te, info), te.getBlockPos()); @@ -939,19 +939,19 @@ public abstract class Contraption { }); } - private static BlockInfo readBlockInfo(CompoundNBT blockListEntry, HashMapPalette palette) { - return new BlockInfo(BlockPos.of(blockListEntry.getLong("Pos")), + private static StructureBlockInfo readBlockInfo(CompoundTag blockListEntry, HashMapPalette palette) { + return new StructureBlockInfo(BlockPos.of(blockListEntry.getLong("Pos")), Objects.requireNonNull(palette.valueFor(blockListEntry.getInt("State"))), blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null); } - private static BlockInfo legacyReadBlockInfo(CompoundNBT blockListEntry) { - return new BlockInfo(NBTUtil.readBlockPos(blockListEntry.getCompound("Pos")), - NBTUtil.readBlockState(blockListEntry.getCompound("Block")), + private static StructureBlockInfo legacyReadBlockInfo(CompoundTag blockListEntry) { + return new StructureBlockInfo(NbtUtils.readBlockPos(blockListEntry.getCompound("Pos")), + NbtUtils.readBlockState(blockListEntry.getCompound("Block")), blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null); } - public void removeBlocksFromWorld(World world, BlockPos offset) { + public void removeBlocksFromWorld(Level world, BlockPos offset) { storage.values() .forEach(MountedStorage::removeStorageFromWorld); fluidStorage.values() @@ -959,9 +959,9 @@ public abstract class Contraption { glueToRemove.forEach(SuperGlueEntity::remove); for (boolean brittles : Iterate.trueAndFalse) { - for (Iterator iterator = blocks.values() + for (Iterator iterator = blocks.values() .iterator(); iterator.hasNext();) { - BlockInfo block = iterator.next(); + StructureBlockInfo block = iterator.next(); if (brittles != BlockMovementChecks.isBrittle(block.state)) continue; @@ -976,7 +976,7 @@ public abstract class Contraption { 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.hasProperty(BlockStateProperties.WATERLOGGED) + if (blockIn instanceof SimpleWaterloggedBlock && oldState.hasProperty(BlockStateProperties.WATERLOGGED) && oldState.getValue(BlockStateProperties.WATERLOGGED)) { world.setBlock(add, Blocks.WATER.defaultBlockState(), flags); continue; @@ -984,7 +984,7 @@ public abstract class Contraption { world.setBlock(add, Blocks.AIR.defaultBlockState(), flags); } } - for (BlockInfo block : blocks.values()) { + for (StructureBlockInfo block : blocks.values()) { BlockPos add = block.pos.offset(anchor) .offset(offset); // if (!shouldUpdateAfterMovement(block)) @@ -996,14 +996,14 @@ public abstract class Contraption { // 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 // (code copied from ServerWorld.onBlockStateChange) - ServerWorld serverWorld = (ServerWorld) world; - PointOfInterestType.forState(block.state) + ServerLevel serverWorld = (ServerLevel) world; + PoiType.forState(block.state) .ifPresent(poiType -> { world.getServer() .execute(() -> { serverWorld.getPoiManager() .add(add, poiType); - DebugPacketSender.sendPoiAddedPacket(serverWorld, add); + DebugPackets.sendPoiAddedPacket(serverWorld, add); }); }); @@ -1013,9 +1013,9 @@ public abstract class Contraption { } } - public void addBlocksToWorld(World world, StructureTransform transform) { + public void addBlocksToWorld(Level world, StructureTransform transform) { for (boolean nonBrittles : Iterate.trueAndFalse) { - for (BlockInfo block : blocks.values()) { + for (StructureBlockInfo block : blocks.values()) { if (nonBrittles == BlockMovementChecks.isBrittle(block.state)) continue; @@ -1041,7 +1041,7 @@ public abstract class Contraption { Block.dropResources(state, world, targetPos, null); continue; } - if (state.getBlock() instanceof IWaterLoggable && state.hasProperty(BlockStateProperties.WATERLOGGED)) { + if (state.getBlock() instanceof SimpleWaterloggedBlock && state.hasProperty(BlockStateProperties.WATERLOGGED)) { FluidState FluidState = world.getFluidState(targetPos); state = state.setValue(BlockStateProperties.WATERLOGGED, FluidState.getType() == Fluids.WATER); } @@ -1056,8 +1056,8 @@ public abstract class Contraption { world.destroyBlock(targetPos, true); } - TileEntity tileEntity = world.getBlockEntity(targetPos); - CompoundNBT tag = block.nbt; + BlockEntity tileEntity = world.getBlockEntity(targetPos); + CompoundTag tag = block.nbt; if (tileEntity != null) tag = NBTProcessors.process(tileEntity, tag, false); if (tileEntity != null && tag != null) { @@ -1071,7 +1071,7 @@ public abstract class Contraption { } if (tileEntity instanceof FluidTankTileEntity && tag.contains("LastKnownPos")) - tag.put("LastKnownPos", NBTUtil.writeBlockPos(BlockPos.ZERO.below())); + tag.put("LastKnownPos", NbtUtils.writeBlockPos(BlockPos.ZERO.below())); tileEntity.load(block.state, tag); @@ -1091,7 +1091,7 @@ public abstract class Contraption { transform.apply(tileEntity); } } - for (BlockInfo block : blocks.values()) { + for (StructureBlockInfo block : blocks.values()) { if (!shouldUpdateAfterMovement(block)) continue; BlockPos targetPos = transform.apply(block.pos); @@ -1118,7 +1118,7 @@ public abstract class Contraption { } } - public void addPassengersToWorld(World world, StructureTransform transform, List seatedEntities) { + public void addPassengersToWorld(Level world, StructureTransform transform, List seatedEntities) { for (Entity seatedEntity : seatedEntities) { if (getSeatMapping().isEmpty()) continue; @@ -1134,8 +1134,8 @@ public abstract class Contraption { } } - public void startMoving(World world) { - for (MutablePair pair : actors) { + public void startMoving(Level world) { + for (MutablePair pair : actors) { MovementContext context = new MovementContext(world, pair.left, this); AllMovementBehaviours.of(pair.left.state) .startMoving(context); @@ -1143,23 +1143,23 @@ public abstract class Contraption { } } - public void stop(World world) { + public void stop(Level world) { foreachActor(world, (behaviour, ctx) -> { behaviour.stopMoving(ctx); ctx.position = null; - ctx.motion = Vector3d.ZERO; - ctx.relativeMotion = Vector3d.ZERO; + ctx.motion = Vec3.ZERO; + ctx.relativeMotion = Vec3.ZERO; ctx.rotation = v -> v; }); } - public void foreachActor(World world, BiConsumer callBack) { - for (MutablePair pair : actors) + public void foreachActor(Level world, BiConsumer callBack) { + for (MutablePair pair : actors) callBack.accept(AllMovementBehaviours.of(pair.getLeft().state), pair.getRight()); } - protected boolean shouldUpdateAfterMovement(BlockInfo info) { - if (PointOfInterestType.forState(info.state) + protected boolean shouldUpdateAfterMovement(StructureBlockInfo info) { + if (PoiType.forState(info.state) .isPresent()) return false; return true; 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 f07a194b1..872cd4e9c 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.getHorizontalDistanceSqr; +import staticnet.minecraft.world.entity.Entityy.getHorizontalDistanceSqr; import java.util.ArrayList; import java.util.List; @@ -26,29 +26,29 @@ import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.CocoaBlock; -import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.CocoaBlock; +import net.minecraft.client.player.LocalPlayer; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.ReuseableStream; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.IBooleanFunction; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.util.RewindableStream; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; @@ -60,18 +60,18 @@ public class ContraptionCollider { } static void collideEntities(AbstractContraptionEntity contraptionEntity) { - World world = contraptionEntity.getCommandSenderWorld(); + Level world = contraptionEntity.getCommandSenderWorld(); Contraption contraption = contraptionEntity.getContraption(); - AxisAlignedBB bounds = contraptionEntity.getBoundingBox(); + AABB bounds = contraptionEntity.getBoundingBox(); if (contraption == null) return; if (bounds == null) return; - Vector3d contraptionPosition = contraptionEntity.position(); - Vector3d contraptionMotion = contraptionPosition.subtract(contraptionEntity.getPrevPositionVec()); - Vector3d anchorVec = contraptionEntity.getAnchorVec(); + Vec3 contraptionPosition = contraptionEntity.position(); + Vec3 contraptionMotion = contraptionPosition.subtract(contraptionEntity.getPrevPositionVec()); + Vec3 anchorVec = contraptionEntity.getAnchorVec(); ContraptionRotationState rotation = null; // After death, multiple refs to the client player may show up in the area @@ -85,8 +85,8 @@ public class ContraptionCollider { if (playerType == PlayerType.REMOTE) continue; - if (playerType == PlayerType.SERVER && entity instanceof ServerPlayerEntity) { - ((ServerPlayerEntity) entity).connection.aboveGroundTickCount = 0; + if (playerType == PlayerType.SERVER && entity instanceof ServerPlayer) { + ((ServerPlayer) entity).connection.aboveGroundTickCount = 0; continue; } @@ -102,14 +102,14 @@ public class ContraptionCollider { Matrix3d rotationMatrix = rotation.asMatrix(); // Transform entity position and motion to local space - Vector3d entityPosition = entity.position(); - AxisAlignedBB entityBounds = entity.getBoundingBox(); - Vector3d motion = entity.getDeltaMovement(); + Vec3 entityPosition = entity.position(); + AABB entityBounds = entity.getBoundingBox(); + Vec3 motion = entity.getDeltaMovement(); float yawOffset = rotation.getYawOffset(); - Vector3d position = getWorldToLocalTranslation(entity, anchorVec, rotationMatrix, yawOffset); + Vec3 position = getWorldToLocalTranslation(entity, anchorVec, rotationMatrix, yawOffset); // Prepare entity bounds - AxisAlignedBB localBB = entityBounds.move(position) + AABB localBB = entityBounds.move(position) .inflate(1.0E-7D); OrientedBB obb = new OrientedBB(localBB); obb.setRotation(rotationMatrix); @@ -117,12 +117,12 @@ public class ContraptionCollider { motion = rotationMatrix.transform(motion); // Use simplified bbs when present - final Vector3d motionCopy = motion; - List collidableBBs = contraption.simplifiedEntityColliders.orElseGet(() -> { + final Vec3 motionCopy = motion; + List collidableBBs = contraption.simplifiedEntityColliders.orElseGet(() -> { // Else find 'nearby' individual block shapes to collide with - List bbs = new ArrayList<>(); - ReuseableStream potentialHits = + List bbs = new ArrayList<>(); + RewindableStream potentialHits = getPotentiallyCollidedShapes(world, contraption, localBB.expandTowards(motionCopy)); potentialHits.getStream() .forEach(shape -> shape.toAabbs() @@ -131,21 +131,21 @@ public class ContraptionCollider { }); - MutableObject collisionResponse = new MutableObject<>(Vector3d.ZERO); - MutableObject normal = new MutableObject<>(Vector3d.ZERO); - MutableObject location = new MutableObject<>(Vector3d.ZERO); + MutableObject collisionResponse = new MutableObject<>(Vec3.ZERO); + MutableObject normal = new MutableObject<>(Vec3.ZERO); + MutableObject location = new MutableObject<>(Vec3.ZERO); MutableBoolean surfaceCollision = new MutableBoolean(false); MutableFloat temporalResponse = new MutableFloat(1); - Vector3d obbCenter = obb.getCenter(); + Vec3 obbCenter = obb.getCenter(); // Apply separation maths boolean doHorizontalPass = !rotation.hasVerticalRotation(); for (boolean horizontalPass : Iterate.trueAndFalse) { boolean verticalPass = !horizontalPass || !doHorizontalPass; - for (AxisAlignedBB bb : collidableBBs) { - Vector3d currentResponse = collisionResponse.getValue(); - Vector3d currentCenter = obbCenter.add(currentResponse); + for (AABB bb : collidableBBs) { + Vec3 currentResponse = collisionResponse.getValue(); + Vec3 currentCenter = obbCenter.add(currentResponse); if (Math.abs(currentCenter.x - bb.getCenter().x) - entityBounds.getXsize() - 1 > bb.getXsize() / 2) continue; @@ -165,12 +165,12 @@ public class ContraptionCollider { double timeOfImpact = intersect.getTimeOfImpact(); boolean isTemporal = timeOfImpact > 0 && timeOfImpact < 1; - Vector3d collidingNormal = intersect.getCollisionNormal(); - Vector3d collisionPosition = intersect.getCollisionPosition(); + Vec3 collidingNormal = intersect.getCollisionNormal(); + Vec3 collisionPosition = intersect.getCollisionPosition(); if (!isTemporal) { - Vector3d separation = intersect.asSeparationVec(entity.maxUpStep); - if (separation != null && !separation.equals(Vector3d.ZERO)) { + Vec3 separation = intersect.asSeparationVec(entity.maxUpStep); + if (separation != null && !separation.equals(Vec3.ZERO)) { collisionResponse.setValue(currentResponse.add(separation)); timeOfImpact = 0; } @@ -203,14 +203,14 @@ public class ContraptionCollider { } // Resolve collision - Vector3d entityMotion = entity.getDeltaMovement(); - Vector3d entityMotionNoTemporal = entityMotion; - Vector3d collisionNormal = normal.getValue(); - Vector3d collisionLocation = location.getValue(); - Vector3d totalResponse = collisionResponse.getValue(); - boolean hardCollision = !totalResponse.equals(Vector3d.ZERO); + Vec3 entityMotion = entity.getDeltaMovement(); + Vec3 entityMotionNoTemporal = entityMotion; + Vec3 collisionNormal = normal.getValue(); + Vec3 collisionLocation = location.getValue(); + Vec3 totalResponse = collisionResponse.getValue(); + boolean hardCollision = !totalResponse.equals(Vec3.ZERO); boolean temporalCollision = temporalResponse.getValue() != 1; - Vector3d motionResponse = !temporalCollision ? motion + Vec3 motionResponse = !temporalCollision ? motion : motion.normalize() .scale(motion.length() * temporalResponse.getValue()); @@ -229,7 +229,7 @@ public class ContraptionCollider { double bounce = 0; double slide = 0; - if (!collisionLocation.equals(Vector3d.ZERO)) { + if (!collisionLocation.equals(Vec3.ZERO)) { collisionLocation = collisionLocation.add(entity.position() .add(entity.getBoundingBox() .getCenter()) @@ -246,13 +246,13 @@ public class ContraptionCollider { } } - boolean hasNormal = !collisionNormal.equals(Vector3d.ZERO); + boolean hasNormal = !collisionNormal.equals(Vec3.ZERO); boolean anyCollision = hardCollision || temporalCollision; if (bounce > 0 && hasNormal && anyCollision && bounceEntity(entity, collisionNormal, contraptionEntity, bounce)) { - entity.level.playSound(playerType == PlayerType.CLIENT ? (PlayerEntity) entity : null, + entity.level.playSound(playerType == PlayerType.CLIENT ? (Player) entity : null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.SLIME_BLOCK_FALL, - SoundCategory.BLOCKS, .5f, 1); + SoundSource.BLOCKS, .5f, 1); continue; } @@ -286,11 +286,11 @@ public class ContraptionCollider { if (bounce == 0 && slide > 0 && hasNormal && anyCollision && rotation.hasVerticalRotation()) { double slideFactor = collisionNormal.multiply(1, 0, 1) .length() * 1.25f; - Vector3d motionIn = entityMotionNoTemporal.multiply(0, .9, 0) + Vec3 motionIn = entityMotionNoTemporal.multiply(0, .9, 0) .add(0, -.01f, 0); - Vector3d slideNormal = collisionNormal.cross(motionIn.cross(collisionNormal)) + Vec3 slideNormal = collisionNormal.cross(motionIn.cross(collisionNormal)) .normalize(); - Vector3d newMotion = entityMotion.multiply(.85, 0, .85) + Vec3 newMotion = entityMotion.multiply(.85, 0, .85) .add(slideNormal.scale((.2f + slide) * motionIn.length() * slideFactor) .add(0, -.1f - collisionNormal.y * .125f, 0)); entity.setDeltaMovement(newMotion); @@ -300,13 +300,13 @@ public class ContraptionCollider { if (!hardCollision && surfaceCollision.isFalse()) continue; - Vector3d allowedMovement = getAllowedMovement(totalResponse, entity); + Vec3 allowedMovement = getAllowedMovement(totalResponse, entity); entity.setPos(entityPosition.x + allowedMovement.x, entityPosition.y + allowedMovement.y, entityPosition.z + allowedMovement.z); entityPosition = entity.position(); entity.hurtMarked = true; - Vector3d contactPointMotion = Vector3d.ZERO; + Vec3 contactPointMotion = Vec3.ZERO; if (surfaceCollision.isTrue()) { entity.fallDistance = 0; @@ -331,7 +331,7 @@ public class ContraptionCollider { 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; + float limbSwing = Mth.sqrt(d0 * d0 + d1 * d1) * 4.0F; if (limbSwing > 1.0F) limbSwing = 1.0F; AllPackets.channel.sendToServer(new ClientMotionPacket(entityMotion, true, limbSwing)); @@ -339,33 +339,33 @@ public class ContraptionCollider { } - static boolean bounceEntity(Entity entity, Vector3d normal, AbstractContraptionEntity contraption, double factor) { + static boolean bounceEntity(Entity entity, Vec3 normal, AbstractContraptionEntity contraption, double factor) { if (factor == 0) return false; if (entity.isSuppressingBounce()) return false; - Vector3d contactPointMotion = contraption.getContactPointMotion(entity.position()); - Vector3d motion = entity.getDeltaMovement().subtract(contactPointMotion); - Vector3d deltav = normal.scale(factor*2*motion.dot(normal)); + Vec3 contactPointMotion = contraption.getContactPointMotion(entity.position()); + Vec3 motion = entity.getDeltaMovement().subtract(contactPointMotion); + Vec3 deltav = normal.scale(factor*2*motion.dot(normal)); if (deltav.dot(deltav) < 0.1f) return false; entity.setDeltaMovement(entity.getDeltaMovement().subtract(deltav)); return true; } - public static Vector3d getWorldToLocalTranslation(Entity entity, AbstractContraptionEntity contraptionEntity) { + public static Vec3 getWorldToLocalTranslation(Entity entity, AbstractContraptionEntity contraptionEntity) { return getWorldToLocalTranslation(entity, contraptionEntity.getAnchorVec(), contraptionEntity.getRotationState()); } - public static Vector3d getWorldToLocalTranslation(Entity entity, Vector3d anchorVec, ContraptionRotationState rotation) { + public static Vec3 getWorldToLocalTranslation(Entity entity, Vec3 anchorVec, ContraptionRotationState rotation) { return getWorldToLocalTranslation(entity, anchorVec, rotation.asMatrix(), rotation.getYawOffset()); } - public static Vector3d getWorldToLocalTranslation(Entity entity, Vector3d anchorVec, Matrix3d rotationMatrix, float yawOffset) { - Vector3d entityPosition = entity.position(); - Vector3d centerY = new Vector3d(0, entity.getBoundingBox().getYsize() / 2, 0); - Vector3d position = entityPosition; + public static Vec3 getWorldToLocalTranslation(Entity entity, Vec3 anchorVec, Matrix3d rotationMatrix, float yawOffset) { + Vec3 entityPosition = entity.position(); + Vec3 centerY = new Vec3(0, entity.getBoundingBox().getYsize() / 2, 0); + Vec3 position = entityPosition; position = position.add(centerY); position = position.subtract(VecHelper.CENTER_OF_ORIGIN); position = position.subtract(anchorVec); @@ -377,16 +377,16 @@ public class ContraptionCollider { return position; } - public static Vector3d getWorldToLocalTranslation(Vector3d entity, AbstractContraptionEntity contraptionEntity) { + public static Vec3 getWorldToLocalTranslation(Vec3 entity, AbstractContraptionEntity contraptionEntity) { return getWorldToLocalTranslation(entity, contraptionEntity.getAnchorVec(), contraptionEntity.getRotationState()); } - public static Vector3d getWorldToLocalTranslation(Vector3d inPos, Vector3d anchorVec, ContraptionRotationState rotation) { + public static Vec3 getWorldToLocalTranslation(Vec3 inPos, Vec3 anchorVec, ContraptionRotationState rotation) { return getWorldToLocalTranslation(inPos, anchorVec, rotation.asMatrix(), rotation.getYawOffset()); } - public static Vector3d getWorldToLocalTranslation(Vector3d inPos, Vector3d anchorVec, Matrix3d rotationMatrix, float yawOffset) { - Vector3d position = inPos; + public static Vec3 getWorldToLocalTranslation(Vec3 inPos, Vec3 anchorVec, Matrix3d rotationMatrix, float yawOffset) { + Vec3 position = inPos; position = position.subtract(VecHelper.CENTER_OF_ORIGIN); position = position.subtract(anchorVec); position = VecHelper.rotate(position, -yawOffset, Axis.Y); @@ -397,31 +397,31 @@ public class ContraptionCollider { } /** From Entity#getAllowedMovement **/ - static Vector3d getAllowedMovement(Vector3d movement, Entity e) { - AxisAlignedBB bb = e.getBoundingBox(); - ISelectionContext ctx = ISelectionContext.of(e); - World world = e.level; + static Vec3 getAllowedMovement(Vec3 movement, Entity e) { + AABB bb = e.getBoundingBox(); + CollisionContext ctx = CollisionContext.of(e); + Level world = e.level; VoxelShape voxelshape = world.getWorldBorder() .getCollisionShape(); Stream stream = - VoxelShapes.joinIsNotEmpty(voxelshape, VoxelShapes.create(bb.deflate(1.0E-7D)), IBooleanFunction.AND) + Shapes.joinIsNotEmpty(voxelshape, Shapes.create(bb.deflate(1.0E-7D)), BooleanOp.AND) ? Stream.empty() : Stream.of(voxelshape); 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.lengthSqr() == 0.0D ? movement + RewindableStream reuseablestream = new RewindableStream<>(Stream.concat(stream1, stream)); + Vec3 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.maxUpStep > 0.0F && notMovingUp && (xDifferent || zDifferent)) { - Vector3d allowedStep = collideBoundingBoxHeuristically(e, new Vector3d(movement.x, (double) e.maxUpStep, movement.z), + Vec3 allowedStep = collideBoundingBoxHeuristically(e, new Vec3(movement.x, (double) e.maxUpStep, movement.z), bb, world, ctx, reuseablestream); - Vector3d allowedStepGivenMovement = collideBoundingBoxHeuristically(e, new Vector3d(0.0D, (double) e.maxUpStep, 0.0D), + Vec3 allowedStepGivenMovement = collideBoundingBoxHeuristically(e, new Vec3(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), + Vec3 vec3 = collideBoundingBoxHeuristically(e, new Vec3(movement.x, 0.0D, movement.z), bb.move(allowedStepGivenMovement), world, ctx, reuseablestream).add(allowedStepGivenMovement); if (getHorizontalDistanceSqr(vec3) > getHorizontalDistanceSqr(allowedStep)) { allowedStep = vec3; @@ -429,7 +429,7 @@ public class ContraptionCollider { } if (getHorizontalDistanceSqr(allowedStep) > getHorizontalDistanceSqr(allowedMovement)) { - return allowedStep.add(collideBoundingBoxHeuristically(e, new Vector3d(0.0D, -allowedStep.y + movement.y, 0.0D), + return allowedStep.add(collideBoundingBoxHeuristically(e, new Vec3(0.0D, -allowedStep.y + movement.y, 0.0D), bb.move(allowedStep), world, ctx, reuseablestream)); } } @@ -438,7 +438,7 @@ public class ContraptionCollider { } private static PlayerType getPlayerType(Entity entity) { - if (!(entity instanceof PlayerEntity)) + if (!(entity instanceof Player)) return PlayerType.NONE; if (!entity.level.isClientSide) return PlayerType.SERVER; @@ -449,23 +449,23 @@ public class ContraptionCollider { @OnlyIn(Dist.CLIENT) private static boolean isClientPlayerEntity(Entity entity) { - return entity instanceof ClientPlayerEntity; + return entity instanceof LocalPlayer; } - private static ReuseableStream getPotentiallyCollidedShapes(World world, Contraption contraption, - AxisAlignedBB localBB) { + private static RewindableStream getPotentiallyCollidedShapes(Level world, Contraption contraption, + AABB localBB) { 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.inflate(0.5f); + AABB 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.betweenClosedStream(min, max) + RewindableStream potentialHits = new RewindableStream<>(BlockPos.betweenClosedStream(min, max) .filter(contraption.getBlocks()::containsKey) .map(p -> { BlockState blockState = contraption.getBlocks() @@ -484,18 +484,18 @@ public class ContraptionCollider { if (!contraptionEntity.supportsTerrainCollision()) return false; - World world = contraptionEntity.getCommandSenderWorld(); - Vector3d motion = contraptionEntity.getDeltaMovement(); + Level world = contraptionEntity.getCommandSenderWorld(); + Vec3 motion = contraptionEntity.getDeltaMovement(); TranslatingContraption contraption = (TranslatingContraption) contraptionEntity.getContraption(); - AxisAlignedBB bounds = contraptionEntity.getBoundingBox(); - Vector3d position = contraptionEntity.position(); + AABB bounds = contraptionEntity.getBoundingBox(); + Vec3 position = contraptionEntity.position(); BlockPos gridPos = new BlockPos(position); if (contraption == null) return false; if (bounds == null) return false; - if (motion.equals(Vector3d.ZERO)) + if (motion.equals(Vec3.ZERO)) return false; Direction movementDirection = Direction.getNearest(motion.x, motion.y, motion.z); @@ -513,10 +513,10 @@ public class ContraptionCollider { if (!otherContraptionEntity.supportsTerrainCollision()) continue; - Vector3d otherMotion = otherContraptionEntity.getDeltaMovement(); + Vec3 otherMotion = otherContraptionEntity.getDeltaMovement(); TranslatingContraption otherContraption = (TranslatingContraption) otherContraptionEntity.getContraption(); - AxisAlignedBB otherBounds = otherContraptionEntity.getBoundingBox(); - Vector3d otherPosition = otherContraptionEntity.position(); + AABB otherBounds = otherContraptionEntity.getBoundingBox(); + Vec3 otherPosition = otherContraptionEntity.position(); if (otherContraption == null) return false; @@ -540,7 +540,7 @@ public class ContraptionCollider { return false; } - public static boolean isCollidingWithWorld(World world, TranslatingContraption contraption, BlockPos anchor, + public static boolean isCollidingWithWorld(Level world, TranslatingContraption contraption, BlockPos anchor, Direction movementDirection) { for (BlockPos pos : contraption.getColliders(world, movementDirection)) { BlockPos colliderPos = pos.offset(anchor); @@ -549,7 +549,7 @@ public class ContraptionCollider { return true; BlockState collidedState = world.getBlockState(colliderPos); - BlockInfo blockInfo = contraption.getBlocks() + StructureBlockInfo blockInfo = contraption.getBlocks() .get(pos); if (AllMovementBehaviours.contains(blockInfo.state.getBlock())) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionDisassemblyPacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionDisassemblyPacket.java index 50b27b6ff..f50be063a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionDisassemblyPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionDisassemblyPacket.java @@ -4,7 +4,7 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.network.PacketBuffer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.NetworkEvent.Context; @@ -19,13 +19,13 @@ public class ContraptionDisassemblyPacket extends SimplePacketBase { this.transform = transform; } - public ContraptionDisassemblyPacket(PacketBuffer buffer) { + public ContraptionDisassemblyPacket(FriendlyByteBuf buffer) { entityID = buffer.readInt(); transform = StructureTransform.fromBuffer(buffer); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(entityID); transform.writeToBuffer(buffer); } 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 8be7f7b41..2f6db20f3 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 @@ -1,17 +1,17 @@ package com.simibubi.create.content.contraptions.components.structureMovement; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.culling.ClippingHelper; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.resources.ResourceLocation; public class ContraptionEntityRenderer extends EntityRenderer { - public ContraptionEntityRenderer(EntityRendererManager manager) { + public ContraptionEntityRenderer(EntityRenderDispatcher manager) { super(manager); } @@ -21,7 +21,7 @@ public class ContraptionEntityRenderer exte } @Override - public boolean shouldRender(C entity, ClippingHelper clippingHelper, double cameraX, double cameraY, + public boolean shouldRender(C entity, Frustum clippingHelper, double cameraX, double cameraY, double cameraZ) { if (entity.getContraption() == null) return false; @@ -32,7 +32,7 @@ public class ContraptionEntityRenderer exte } @Override - public void render(C entity, float yaw, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, + public void render(C entity, float yaw, float partialTicks, PoseStack ms, MultiBufferSource buffers, int overlay) { super.render(entity, yaw, partialTicks, ms, buffers, overlay); 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 ef0a9dedd..788dbf713 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 @@ -12,11 +12,11 @@ import com.simibubi.create.foundation.utility.WorldAttached; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectLists; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.Constants.NBT; public class ContraptionHandler { @@ -31,7 +31,7 @@ public class ContraptionHandler { queuedAdditions = new WorldAttached<>($ -> ObjectLists.synchronize(new ObjectArrayList<>())); } - public static void tick(World world) { + public static void tick(Level world) { Map> map = loadedContraptions.get(world); List queued = queuedAdditions.get(world); @@ -51,19 +51,19 @@ public class ContraptionHandler { } } - public static void addSpawnedContraptionsToCollisionList(Entity entity, World world) { + public static void addSpawnedContraptionsToCollisionList(Entity entity, Level world) { if (entity instanceof AbstractContraptionEntity) queuedAdditions.get(world) .add((AbstractContraptionEntity) entity); } - public static void entitiesWhoJustDismountedGetSentToTheRightLocation(LivingEntity entityLiving, World world) { + public static void entitiesWhoJustDismountedGetSentToTheRightLocation(LivingEntity entityLiving, Level world) { if (world.isClientSide) return; - CompoundNBT data = entityLiving.getPersistentData(); + CompoundTag data = entityLiving.getPersistentData(); if (!data.contains("ContraptionDismountLocation")) return; - Vector3d position = VecHelper.readNBT(data.getList("ContraptionDismountLocation", NBT.TAG_DOUBLE)); + Vec3 position = VecHelper.readNBT(data.getList("ContraptionDismountLocation", NBT.TAG_DOUBLE)); 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 deb7ec47c..5c2e46cc5 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 @@ -7,19 +7,19 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.RaycastHelper; import com.simibubi.create.foundation.utility.RaycastHelper.PredicateTraceResult; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.entity.player.RemoteClientPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.player.RemotePlayer; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.InputEvent.ClickInputEvent; @@ -36,10 +36,10 @@ public class ContraptionHandlerClient { public static void preventRemotePlayersWalkingAnimations(PlayerTickEvent event) { if (event.phase == Phase.START) return; - if (!(event.player instanceof RemoteClientPlayerEntity)) + if (!(event.player instanceof RemotePlayer)) return; - RemoteClientPlayerEntity remotePlayer = (RemoteClientPlayerEntity) event.player; - CompoundNBT data = remotePlayer.getPersistentData(); + RemotePlayer remotePlayer = (RemotePlayer) event.player; + CompoundTag data = remotePlayer.getPersistentData(); if (!data.contains("LastOverrideLimbSwingUpdate")) return; @@ -60,7 +60,7 @@ public class ContraptionHandlerClient { @OnlyIn(Dist.CLIENT) public static void rightClickingOnContraptionsGetsHandledLocally(ClickInputEvent event) { Minecraft mc = Minecraft.getInstance(); - ClientPlayerEntity player = mc.player; + LocalPlayer player = mc.player; if (player == null) return; if (player.isPassenger()) @@ -69,24 +69,24 @@ public class ContraptionHandlerClient { return; if (!event.isUseItem()) return; - Vector3d origin = RaycastHelper.getTraceOrigin(player); + Vec3 origin = RaycastHelper.getTraceOrigin(player); 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); + Vec3 target = RaycastHelper.getTraceTarget(player, reach, origin); for (AbstractContraptionEntity contraptionEntity : mc.level - .getEntitiesOfClass(AbstractContraptionEntity.class, new AxisAlignedBB(origin, target))) { + .getEntitiesOfClass(AbstractContraptionEntity.class, new AABB(origin, target))) { - Vector3d localOrigin = contraptionEntity.toLocalVector(origin, 1); - Vector3d localTarget = contraptionEntity.toLocalVector(target, 1); + Vec3 localOrigin = contraptionEntity.toLocalVector(origin, 1); + Vec3 localTarget = contraptionEntity.toLocalVector(target, 1); Contraption contraption = contraptionEntity.getContraption(); - MutableObject mutableResult = new MutableObject<>(); + MutableObject mutableResult = new MutableObject<>(); PredicateTraceResult predicateResult = RaycastHelper.rayTraceUntil(localOrigin, localTarget, p -> { - BlockInfo blockInfo = contraption.getBlocks() + StructureBlockInfo blockInfo = contraption.getBlocks() .get(p); if (blockInfo == null) return false; @@ -94,7 +94,7 @@ public class ContraptionHandlerClient { VoxelShape raytraceShape = state.getShape(Minecraft.getInstance().level, BlockPos.ZERO.below()); if (raytraceShape.isEmpty()) return false; - BlockRayTraceResult rayTrace = raytraceShape.clip(localOrigin, localTarget, p); + BlockHitResult rayTrace = raytraceShape.clip(localOrigin, localTarget, p); if (rayTrace != null) { mutableResult.setValue(rayTrace); return true; @@ -105,8 +105,8 @@ public class ContraptionHandlerClient { if (predicateResult == null || predicateResult.missed()) return; - BlockRayTraceResult rayTraceResult = mutableResult.getValue(); - Hand hand = event.getHand(); + BlockHitResult rayTraceResult = mutableResult.getValue(); + InteractionHand hand = event.getHand(); Direction face = rayTraceResult.getDirection(); BlockPos pos = rayTraceResult.getBlockPos(); 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 13288eed6..caca45b21 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 @@ -4,6 +4,8 @@ import com.jozufozu.flywheel.light.*; import net.minecraft.world.LightType; +import GPULightVolume; + public abstract class ContraptionLighter implements ILightUpdateListener { protected final C contraption; public final GPULightVolume lightVolume; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionStallPacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionStallPacket.java index 9c9aac76f..79787288f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionStallPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionStallPacket.java @@ -4,7 +4,7 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.network.PacketBuffer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.NetworkEvent.Context; @@ -25,7 +25,7 @@ public class ContraptionStallPacket extends SimplePacketBase { this.angle = angle; } - public ContraptionStallPacket(PacketBuffer buffer) { + public ContraptionStallPacket(FriendlyByteBuf buffer) { entityID = buffer.readInt(); x = buffer.readFloat(); y = buffer.readFloat(); @@ -34,7 +34,7 @@ public class ContraptionStallPacket extends SimplePacketBase { } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(entityID); writeAll(buffer, x, y, z, angle); } @@ -46,7 +46,7 @@ public class ContraptionStallPacket extends SimplePacketBase { context.get().setPacketHandled(true); } - private void writeAll(PacketBuffer buffer, float... floats) { + private void writeAll(FriendlyByteBuf buffer, float... floats) { for (float f : floats) buffer.writeFloat(f); } 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 28d9dc99b..4169b6c6f 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 @@ -2,20 +2,20 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.player.Player; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class ContraptionWorld extends WrappedWorld { final Contraption contraption; - public ContraptionWorld(World world, Contraption contraption) { + public ContraptionWorld(Level world, Contraption contraption) { super(world); this.contraption = contraption; @@ -24,7 +24,7 @@ public class ContraptionWorld extends WrappedWorld { @Override public BlockState getBlockState(BlockPos pos) { - Template.BlockInfo blockInfo = contraption.getBlocks().get(pos); + StructureTemplate.StructureBlockInfo blockInfo = contraption.getBlocks().get(pos); if (blockInfo != null) return blockInfo.state; @@ -33,9 +33,9 @@ public class ContraptionWorld extends WrappedWorld { } @Override - public void playSound(PlayerEntity player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch) { + public void playSound(Player player, double x, double y, double z, SoundEvent soundIn, SoundSource category, float volume, float pitch) { - Vector3d worldPos = ContraptionCollider.getWorldToLocalTranslation(new Vector3d(x, y, z), this.contraption.entity); + Vec3 worldPos = ContraptionCollider.getWorldToLocalTranslation(new Vec3(x, y, z), this.contraption.entity); worldPos = worldPos.add(x, y, z); @@ -43,7 +43,7 @@ public class ContraptionWorld extends WrappedWorld { } @Override - 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_) { + public void playLocalSound(double x, double y, double z, SoundEvent p_184134_7_, SoundSource 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 c27d87133..c698b6e61 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 @@ -3,22 +3,22 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import static com.simibubi.create.foundation.utility.AngleHelper.angleLerp; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllEntityTypes; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingContraption; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.entity.EntityType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.world.entity.EntityType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -36,11 +36,11 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { protected float angle; protected float angleDelta; - public ControlledContraptionEntity(EntityType type, World world) { + public ControlledContraptionEntity(EntityType type, Level world) { super(type, world); } - public static ControlledContraptionEntity create(World world, IControlContraption controller, + public static ControlledContraptionEntity create(Level world, IControlContraption controller, Contraption contraption) { ControlledContraptionEntity entity = new ControlledContraptionEntity(AllEntityTypes.CONTROLLED_CONTRAPTION.get(), world); @@ -50,7 +50,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { } @Override - public Vector3d getContactPointMotion(Vector3d globalContactPoint) { + public Vec3 getContactPointMotion(Vec3 globalContactPoint) { if (contraption instanceof TranslatingContraption) return getDeltaMovement(); return super.getContactPointMotion(globalContactPoint); @@ -66,18 +66,18 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { } @Override - protected void readAdditional(CompoundNBT compound, boolean spawnPacket) { + protected void readAdditional(CompoundTag compound, boolean spawnPacket) { super.readAdditional(compound, spawnPacket); - controllerPos = NBTUtil.readBlockPos(compound.getCompound("Controller")); + controllerPos = NbtUtils.readBlockPos(compound.getCompound("Controller")); if (compound.contains("Axis")) rotationAxis = NBTHelper.readEnum(compound, "Axis", Axis.class); angle = compound.getFloat("Angle"); } @Override - protected void writeAdditional(CompoundNBT compound, boolean spawnPacket) { + protected void writeAdditional(CompoundTag compound, boolean spawnPacket) { super.writeAdditional(compound, spawnPacket); - compound.put("Controller", NBTUtil.writeBlockPos(controllerPos)); + compound.put("Controller", NbtUtils.writeBlockPos(controllerPos)); if (rotationAxis != null) NBTHelper.writeEnum(compound, "Axis", rotationAxis); compound.putFloat("Angle", angle); @@ -96,13 +96,13 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { } @Override - public Vector3d applyRotation(Vector3d localPos, float partialTicks) { + public Vec3 applyRotation(Vec3 localPos, float partialTicks) { localPos = VecHelper.rotate(localPos, getAngle(partialTicks), rotationAxis); return localPos; } @Override - public Vector3d reverseRotation(Vector3d localPos, float partialTicks) { + public Vec3 reverseRotation(Vec3 localPos, float partialTicks) { localPos = VecHelper.rotate(localPos, -getAngle(partialTicks), rotationAxis); return localPos; } @@ -150,15 +150,15 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { setPos(getX(), getY(), getZ()); } - Vector3d motion = getDeltaMovement(); + Vec3 motion = getDeltaMovement(); move(motion.x, motion.y, motion.z); if (ContraptionCollider.collideBlocks(this)) getController().collided(); } @Override - protected boolean shouldActorTrigger(MovementContext context, BlockInfo blockInfo, MovementBehaviour actor, - Vector3d actorPosition, BlockPos gridPosition) { + protected boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor, + Vec3 actorPosition, BlockPos gridPosition) { if (super.shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition)) return true; @@ -167,13 +167,13 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { return false; BearingContraption bc = (BearingContraption) contraption; Direction facing = bc.getFacing(); - Vector3d activeAreaOffset = actor.getActiveAreaOffset(context); - if (!activeAreaOffset.multiply(VecHelper.axisAlingedPlaneOf(Vector3d.atLowerCornerOf(facing.getNormal()))) - .equals(Vector3d.ZERO)) + Vec3 activeAreaOffset = actor.getActiveAreaOffset(context); + if (!activeAreaOffset.multiply(VecHelper.axisAlingedPlaneOf(Vec3.atLowerCornerOf(facing.getNormal()))) + .equals(Vec3.ZERO)) return false; if (!VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis())) return false; - context.motion = Vector3d.atLowerCornerOf(facing.getNormal()).scale(angleDelta / 360.0); + context.motion = Vec3.atLowerCornerOf(facing.getNormal()).scale(angleDelta / 360.0); context.relativeMotion = context.motion; int timer = context.data.getInt("StationaryTimer"); if (timer > 0) { @@ -190,7 +190,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { return null; if (!level.isLoaded(controllerPos)) return null; - TileEntity te = level.getBlockEntity(controllerPos); + BlockEntity te = level.getBlockEntity(controllerPos); if (!(te instanceof IControlContraption)) return null; return (IControlContraption) te; @@ -226,11 +226,11 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { @Override @OnlyIn(Dist.CLIENT) - public void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks) { + public void doLocalTransforms(float partialTicks, PoseStack[] matrixStacks) { float angle = getAngle(partialTicks); Axis axis = getRotationAxis(); - for (MatrixStack stack : matrixStacks) + for (PoseStack stack : matrixStacks) MatrixTransformStack.of(stack) .nudge(getId()) .centre() 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 02d7e94cc..9ff77579e 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 @@ -3,14 +3,14 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import java.util.function.BiPredicate; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.Vec3; public class DirectionalExtenderScrollOptionSlot extends CenteredSideValueBoxTransform { @@ -19,13 +19,13 @@ public class DirectionalExtenderScrollOptionSlot extends CenteredSideValueBoxTra } @Override - protected Vector3d getLocalOffset(BlockState state) { + protected Vec3 getLocalOffset(BlockState state) { return super.getLocalOffset(state) - .add(Vector3d.atLowerCornerOf(state.getValue(BlockStateProperties.FACING).getNormal()).scale(-2 / 16f)); + .add(Vec3.atLowerCornerOf(state.getValue(BlockStateProperties.FACING).getNormal()).scale(-2 / 16f)); } @Override - protected void rotate(BlockState state, MatrixStack ms) { + protected void rotate(BlockState state, PoseStack ms) { if (!getSide().getAxis().isHorizontal()) MatrixTransformStack.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/IControlContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/IControlContraption.java index e5d8c1c9f..5e377ad0d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/IControlContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/IControlContraption.java @@ -4,7 +4,7 @@ import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; public interface IControlContraption { 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 80c154e7e..37cf98bd4 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 @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import static net.minecraft.util.text.TextFormatting.GRAY; -import static net.minecraft.util.text.TextFormatting.WHITE; +import staticnet.minecraft.ChatFormattingg.WHITE; import java.util.Arrays; import java.util.List; @@ -10,21 +10,21 @@ import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraft.util.text.TextFormatting; public interface IDisplayAssemblyExceptions { - default boolean addExceptionToTooltip(List tooltip) { + default boolean addExceptionToTooltip(List tooltip) { AssemblyException e = getLastAssemblyException(); if (e == null) return false; if (!tooltip.isEmpty()) - tooltip.add(StringTextComponent.EMPTY); + tooltip.add(TextComponent.EMPTY); - tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy().append(Lang.translate("gui.assembly.exception").withStyle(TextFormatting.GOLD))); + tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy().append(Lang.translate("gui.assembly.exception").withStyle(ChatFormatting.GOLD))); String text = e.component.getString(); Arrays.stream(text.split("\n")) 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 8ef8f2a3a..72dee667c 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 @@ -9,10 +9,10 @@ import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; @@ -24,27 +24,27 @@ public class MountedFluidStorage { SmartFluidTank tank; private boolean valid; - private TileEntity te; + private BlockEntity te; private int packetCooldown = 0; private boolean sendPacket = false; - public static boolean canUseAsStorage(TileEntity te) { + public static boolean canUseAsStorage(BlockEntity te) { if (te instanceof FluidTankTileEntity) return ((FluidTankTileEntity) te).isController(); return false; } - public MountedFluidStorage(TileEntity te) { + public MountedFluidStorage(BlockEntity te) { assignTileEntity(te); } - public void assignTileEntity(TileEntity te) { + public void assignTileEntity(BlockEntity te) { this.te = te; tank = createMountedTank(te); } - private SmartFluidTank createMountedTank(TileEntity te) { + private SmartFluidTank createMountedTank(BlockEntity te) { if (te instanceof CreativeFluidTankTileEntity) return new CreativeSmartFluidTank( ((FluidTankTileEntity) te).getTotalTankSize() * FluidTankTileEntity.getCapacityMultiplier(), $ -> { @@ -110,7 +110,7 @@ public class MountedFluidStorage { sendPacket = true; } - public void addStorageToWorld(TileEntity te) { + public void addStorageToWorld(BlockEntity te) { if (tank instanceof CreativeSmartFluidTank) return; @@ -127,21 +127,21 @@ public class MountedFluidStorage { return tank; } - public CompoundNBT serialize() { + public CompoundTag serialize() { if (!valid) return null; - CompoundNBT tag = tank.writeToNBT(new CompoundNBT()); + CompoundTag tag = tank.writeToNBT(new CompoundTag()); tag.putInt("Capacity", tank.getCapacity()); if (tank instanceof CreativeSmartFluidTank) { NBTHelper.putMarker(tag, "Bottomless"); tag.put("ProvidedStack", tank.getFluid() - .writeToNBT(new CompoundNBT())); + .writeToNBT(new CompoundTag())); } return tag; } - public static MountedFluidStorage deserialize(CompoundNBT nbt) { + public static MountedFluidStorage deserialize(CompoundTag nbt) { MountedFluidStorage storage = new MountedFluidStorage(null); if (nbt == null) return storage; 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 cc9769c8a..3441990cb 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 @@ -6,15 +6,15 @@ import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateBl import com.simibubi.create.content.logistics.block.inventories.BottomlessItemHandler; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.block.ChestBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.state.properties.ChestType; -import net.minecraft.tileentity.BarrelTileEntity; -import net.minecraft.tileentity.ChestTileEntity; -import net.minecraft.tileentity.ShulkerBoxTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.ChestBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.properties.ChestType; +import net.minecraft.world.level.block.entity.BarrelBlockEntity; +import net.minecraft.world.level.block.entity.ChestBlockEntity; +import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; @@ -27,9 +27,9 @@ public class MountedStorage { ItemStackHandler handler; boolean valid; - private TileEntity te; + private BlockEntity te; - public static boolean canUseAsStorage(TileEntity te) { + public static boolean canUseAsStorage(BlockEntity te) { if (te == null) return false; @@ -37,11 +37,11 @@ public class MountedStorage { return true; if (AllTileEntities.CREATIVE_CRATE.is(te)) return true; - if (te instanceof ShulkerBoxTileEntity) + if (te instanceof ShulkerBoxBlockEntity) return true; - if (te instanceof ChestTileEntity) + if (te instanceof ChestBlockEntity) return true; - if (te instanceof BarrelTileEntity) + if (te instanceof BarrelBlockEntity) return true; LazyOptional capability = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); @@ -49,7 +49,7 @@ public class MountedStorage { return handler instanceof ItemStackHandler && !(handler instanceof ProcessingInventory); } - public MountedStorage(TileEntity te) { + public MountedStorage(BlockEntity te) { this.te = te; handler = dummyHandler; } @@ -60,7 +60,7 @@ public class MountedStorage { return; // Split double chests - if (te.getType() == TileEntityType.CHEST || te.getType() == TileEntityType.TRAPPED_CHEST) { + if (te.getType() == BlockEntityType.CHEST || te.getType() == BlockEntityType.TRAPPED_CHEST) { if (te.getBlockState() .getValue(ChestBlock.TYPE) != ChestType.SINGLE) te.getLevel() @@ -105,7 +105,7 @@ public class MountedStorage { } - public void addStorageToWorld(TileEntity te) { + public void addStorageToWorld(BlockEntity te) { // FIXME: More dynamic mounted storage in .4 if (handler instanceof BottomlessItemHandler) return; @@ -124,10 +124,10 @@ public class MountedStorage { return handler; } - public CompoundNBT serialize() { + public CompoundTag serialize() { if (!valid) return null; - CompoundNBT tag = handler.serializeNBT(); + CompoundTag tag = handler.serializeNBT(); if (handler instanceof BottomlessItemHandler) { NBTHelper.putMarker(tag, "Bottomless"); @@ -138,7 +138,7 @@ public class MountedStorage { return tag; } - public static MountedStorage deserialize(CompoundNBT nbt) { + public static MountedStorage deserialize(CompoundTag nbt) { MountedStorage storage = new MountedStorage(null); storage.handler = new ItemStackHandler(); if (nbt == null) 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 6ac3bed21..e9ef10f86 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 @@ -8,11 +8,11 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.ItemHandlerHelper; @@ -29,8 +29,8 @@ public abstract class MovementBehaviour { public void visitNewPosition(MovementContext context, BlockPos pos) {} - public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.ZERO; + public Vec3 getActiveAreaOffset(MovementContext context) { + return Vec3.ZERO; } public void dropItem(MovementContext context, ItemStack stack) { @@ -42,7 +42,7 @@ public abstract class MovementBehaviour { if (remainder.isEmpty()) return; - Vector3d vec = context.position; + Vec3 vec = context.position; ItemEntity itemEntity = new ItemEntity(context.world, vec.x, vec.y, vec.z, remainder); itemEntity.setDeltaMovement(context.motion.add(0, 0.5f, 0) .scale(context.world.random.nextFloat() * .3f)); @@ -67,7 +67,7 @@ public abstract class MovementBehaviour { @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - ContraptionMatrices matrices, IRenderTypeBuffer buffer) {} + ContraptionMatrices matrices, MultiBufferSource buffer) {} @OnlyIn(Dist.CLIENT) @Nullable @@ -75,6 +75,6 @@ public abstract class MovementBehaviour { return null; } - public void onSpeedChanged(MovementContext context, Vector3d oldMotion, Vector3d motion) { + public void onSpeedChanged(MovementContext context, Vec3 oldMotion, Vec3 motion) { } } 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 bfad9ad5a..0d92e9395 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 @@ -4,33 +4,33 @@ import java.util.function.UnaryOperator; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraftforge.common.util.Constants.NBT; public class MovementContext { - public Vector3d position; - public Vector3d motion; - public Vector3d relativeMotion; - public UnaryOperator rotation; + public Vec3 position; + public Vec3 motion; + public Vec3 relativeMotion; + public UnaryOperator rotation; - public World world; + public Level world; public BlockState state; public BlockPos localPos; - public CompoundNBT tileData; + public CompoundTag tileData; public boolean stall; public boolean firstMovement; - public CompoundNBT data; + public CompoundTag data; public Contraption contraption; public Object temporaryData; - public MovementContext(World world, BlockInfo info, Contraption contraption) { + public MovementContext(Level world, StructureBlockInfo info, Contraption contraption) { this.world = world; this.state = info.state; this.tileData = info.nbt; @@ -38,11 +38,11 @@ public class MovementContext { localPos = info.pos; firstMovement = true; - motion = Vector3d.ZERO; - relativeMotion = Vector3d.ZERO; + motion = Vec3.ZERO; + relativeMotion = Vec3.ZERO; rotation = v -> v; position = null; - data = new CompoundNBT(); + data = new CompoundTag(); stall = false; } @@ -56,7 +56,7 @@ public class MovementContext { return (((int) (length * modifier + 100 * Math.signum(length))) / 100) * 100; } - public static MovementContext readNBT(World world, BlockInfo info, CompoundNBT nbt, Contraption contraption) { + public static MovementContext readNBT(Level world, StructureBlockInfo info, CompoundTag nbt, Contraption contraption) { MovementContext context = new MovementContext(world, info, contraption); context.motion = VecHelper.readNBT(nbt.getList("Motion", NBT.TAG_DOUBLE)); context.relativeMotion = VecHelper.readNBT(nbt.getList("RelativeMotion", NBT.TAG_DOUBLE)); @@ -68,7 +68,7 @@ public class MovementContext { return context; } - public CompoundNBT writeToNBT(CompoundNBT nbt) { + public CompoundTag writeToNBT(CompoundTag nbt) { nbt.put("Motion", VecHelper.writeNBT(motion)); nbt.put("RelativeMotion", VecHelper.writeNBT(relativeMotion)); if (position != null) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovingInteractionBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovingInteractionBehaviour.java index 8165150b7..2e30d3a6c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovingInteractionBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovingInteractionBehaviour.java @@ -4,10 +4,10 @@ import org.apache.commons.lang3.tuple.MutablePair; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; @@ -16,7 +16,7 @@ public abstract class MovingInteractionBehaviour { public MovingInteractionBehaviour() {} - protected void setContraptionActorData(AbstractContraptionEntity contraptionEntity, int index, BlockInfo info, + protected void setContraptionActorData(AbstractContraptionEntity contraptionEntity, int index, StructureBlockInfo info, MovementContext ctx) { contraptionEntity.contraption.actors.remove(index); contraptionEntity.contraption.actors.add(index, MutablePair.of(info, ctx)); @@ -24,7 +24,7 @@ public abstract class MovingInteractionBehaviour { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> invalidate(contraptionEntity.contraption)); } - protected void setContraptionBlockData(AbstractContraptionEntity contraptionEntity, BlockPos pos, BlockInfo info) { + protected void setContraptionBlockData(AbstractContraptionEntity contraptionEntity, BlockPos pos, StructureBlockInfo info) { contraptionEntity.contraption.blocks.put(pos, info); if (contraptionEntity.level.isClientSide) DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> invalidate(contraptionEntity.contraption)); @@ -35,7 +35,7 @@ public abstract class MovingInteractionBehaviour { ContraptionRenderDispatcher.invalidate(contraption); } - public boolean handlePlayerInteraction(PlayerEntity player, Hand activeHand, BlockPos localPos, + public boolean handlePlayerInteraction(Player player, InteractionHand activeHand, BlockPos localPos, AbstractContraptionEntity contraptionEntity) { return true; } 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 47c10d668..20cc5131c 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 @@ -8,7 +8,7 @@ import java.util.UUID; import javax.annotation.Nullable; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllEntityTypes; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.StabilizedContraption; import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity.CartMovementMode; @@ -22,28 +22,28 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.item.minecart.FurnaceMinecartEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.network.datasync.DataParameter; -import net.minecraft.network.datasync.DataSerializers; -import net.minecraft.network.datasync.EntityDataManager; -import net.minecraft.state.properties.RailShape; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.MinecartFurnace; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.block.state.properties.RailShape; import net.minecraft.tags.BlockTags; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; @@ -57,12 +57,12 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { private static final Ingredient FUEL_ITEMS = Ingredient.of(Items.COAL, Items.CHARCOAL); - private static final DataParameter> COUPLING = - EntityDataManager.defineId(OrientedContraptionEntity.class, DataSerializers.OPTIONAL_UUID); - private static final DataParameter INITIAL_ORIENTATION = - EntityDataManager.defineId(OrientedContraptionEntity.class, DataSerializers.DIRECTION); + private static final EntityDataAccessor> COUPLING = + SynchedEntityData.defineId(OrientedContraptionEntity.class, EntityDataSerializers.OPTIONAL_UUID); + private static final EntityDataAccessor INITIAL_ORIENTATION = + SynchedEntityData.defineId(OrientedContraptionEntity.class, EntityDataSerializers.DIRECTION); - protected Vector3d motionBeforeStall; + protected Vec3 motionBeforeStall; protected boolean forceAngle; private boolean isSerializingFurnaceCart; private boolean attachedExtraInventories; @@ -79,15 +79,15 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { // When placed using a contraption item private float initialYawOffset; - public OrientedContraptionEntity(EntityType type, World world) { + public OrientedContraptionEntity(EntityType type, Level world) { super(type, world); - motionBeforeStall = Vector3d.ZERO; + motionBeforeStall = Vec3.ZERO; attachedExtraInventories = false; isSerializingFurnaceCart = false; initialYawOffset = -1; } - public static OrientedContraptionEntity create(World world, Contraption contraption, Direction initialOrientation) { + public static OrientedContraptionEntity create(Level world, Contraption contraption, Direction initialOrientation) { OrientedContraptionEntity entity = new OrientedContraptionEntity(AllEntityTypes.ORIENTED_CONTRAPTION.get(), world); entity.setContraption(contraption); @@ -96,7 +96,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { return entity; } - public static OrientedContraptionEntity createAtYaw(World world, Contraption contraption, + public static OrientedContraptionEntity createAtYaw(Level world, Contraption contraption, Direction initialOrientation, float initialYaw) { OrientedContraptionEntity entity = create(world, contraption, initialOrientation); entity.startAtYaw(initialYaw); @@ -158,7 +158,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } @Override - protected void readAdditional(CompoundNBT compound, boolean spawnPacket) { + protected void readAdditional(CompoundTag compound, boolean spawnPacket) { super.readAdditional(compound, spawnPacket); if (compound.contains("InitialOrientation")) @@ -171,19 +171,19 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { if (compound.contains("ForceYaw")) startAtYaw(compound.getFloat("ForceYaw")); - ListNBT vecNBT = compound.getList("CachedMotion", 6); + ListTag vecNBT = compound.getList("CachedMotion", 6); if (!vecNBT.isEmpty()) { - motionBeforeStall = new Vector3d(vecNBT.getDouble(0), vecNBT.getDouble(1), vecNBT.getDouble(2)); - if (!motionBeforeStall.equals(Vector3d.ZERO)) + motionBeforeStall = new Vec3(vecNBT.getDouble(0), vecNBT.getDouble(1), vecNBT.getDouble(2)); + if (!motionBeforeStall.equals(Vec3.ZERO)) targetYaw = prevYaw = yaw += yawFromVector(motionBeforeStall); - setDeltaMovement(Vector3d.ZERO); + setDeltaMovement(Vec3.ZERO); } setCouplingId(compound.contains("OnCoupling") ? compound.getUUID("OnCoupling") : null); } @Override - protected void writeAdditional(CompoundNBT compound, boolean spawnPacket) { + protected void writeAdditional(CompoundTag compound, boolean spawnPacket) { super.writeAdditional(compound, spawnPacket); if (motionBeforeStall != null) @@ -208,7 +208,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } @Override - public void onSyncedDataUpdated(DataParameter key) { + public void onSyncedDataUpdated(EntityDataAccessor key) { super.onSyncedDataUpdated(key); if (key == INITIAL_ORIENTATION && isInitialOrientationPresent() && !manuallyPlaced) startAtInitialYaw(); @@ -230,7 +230,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } @Override - public Vector3d applyRotation(Vector3d localPos, float partialTicks) { + public Vec3 applyRotation(Vec3 localPos, float partialTicks) { localPos = VecHelper.rotate(localPos, getInitialYaw(), Axis.Y); localPos = VecHelper.rotate(localPos, getViewXRot(partialTicks), Axis.Z); localPos = VecHelper.rotate(localPos, getViewYRot(partialTicks), Axis.Y); @@ -238,7 +238,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } @Override - public Vector3d reverseRotation(Vector3d localPos, float partialTicks) { + public Vec3 reverseRotation(Vec3 localPos, float partialTicks) { localPos = VecHelper.rotate(localPos, -getViewYRot(partialTicks), Axis.Y); localPos = VecHelper.rotate(localPos, -getViewXRot(partialTicks), Axis.Z); localPos = VecHelper.rotate(localPos, -getInitialYaw(), Axis.Y); @@ -274,7 +274,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { boolean isOnCoupling = false; UUID couplingId = getCouplingId(); - isOnCoupling = couplingId != null && riding instanceof AbstractMinecartEntity; + isOnCoupling = couplingId != null && riding instanceof AbstractMinecart; if (!attachedExtraInventories) { attachInventoriesFromRidingCarts(riding, isOnCoupling, couplingId); @@ -300,7 +300,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } if (wasStalled && !isStalled) { riding.setDeltaMovement(motionBeforeStall); - motionBeforeStall = Vector3d.ZERO; + motionBeforeStall = Vec3.ZERO; } } @@ -326,10 +326,10 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { if (coupledCarts == null) return false; - Vector3d positionVec = coupledCarts.getFirst() + Vec3 positionVec = coupledCarts.getFirst() .cart() .position(); - Vector3d coupledVec = coupledCarts.getSecond() + Vec3 coupledVec = coupledCarts.getSecond() .cart() .position(); @@ -339,7 +339,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { prevYaw = yaw; prevPitch = pitch; - yaw = (float) (MathHelper.atan2(diffZ, diffX) * 180 / Math.PI); + yaw = (float) (Mth.atan2(diffZ, diffX) * 180 / Math.PI); pitch = (float) (Math.atan2(diffY, Math.sqrt(diffX * diffX + diffZ * diffZ)) * 180 / Math.PI); if (getCouplingId().equals(riding.getUUID())) { @@ -368,20 +368,20 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { return false; boolean rotating = false; - Vector3d movementVector = riding.getDeltaMovement(); - Vector3d locationDiff = riding.position() + Vec3 movementVector = riding.getDeltaMovement(); + Vec3 locationDiff = riding.position() .subtract(riding.xo, riding.yo, riding.zo); - if (!(riding instanceof AbstractMinecartEntity)) + if (!(riding instanceof AbstractMinecart)) movementVector = locationDiff; - Vector3d motion = movementVector.normalize(); + Vec3 motion = movementVector.normalize(); if (!rotationLock) { - if (riding instanceof AbstractMinecartEntity) { - AbstractMinecartEntity minecartEntity = (AbstractMinecartEntity) riding; + if (riding instanceof AbstractMinecart) { + AbstractMinecart minecartEntity = (AbstractMinecart) riding; BlockPos railPosition = minecartEntity.getCurrentRailPosition(); BlockState blockState = level.getBlockState(railPosition); - if (blockState.getBlock() instanceof AbstractRailBlock) { - AbstractRailBlock abstractRailBlock = (AbstractRailBlock) blockState.getBlock(); + if (blockState.getBlock() instanceof BaseRailBlock) { + BaseRailBlock abstractRailBlock = (BaseRailBlock) blockState.getBlock(); RailShape railDirection = abstractRailBlock.getRailDirection(blockState, level, railPosition, minecartEntity); motion = VecHelper.project(motion, MinecartSim2020.getRailVec(railDirection)); @@ -399,7 +399,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { prevYaw = yaw; float maxApproachSpeed = (float) (motion.length() * 12f / (Math.max(1, getBoundingBox().getXsize() / 6f))); float approach = AngleHelper.getShortestAngleDiff(yaw, targetYaw); - approach = MathHelper.clamp(approach, -maxApproachSpeed, maxApproachSpeed); + approach = Mth.clamp(approach, -maxApproachSpeed, maxApproachSpeed); yaw += approach; if (Math.abs(AngleHelper.getShortestAngleDiff(yaw, targetYaw)) < 1f) yaw = targetYaw; @@ -410,13 +410,13 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } protected void powerFurnaceCartWithFuelFromStorage(Entity riding) { - if (!(riding instanceof FurnaceMinecartEntity)) + if (!(riding instanceof MinecartFurnace)) return; - FurnaceMinecartEntity furnaceCart = (FurnaceMinecartEntity) riding; + MinecartFurnace furnaceCart = (MinecartFurnace) riding; // Notify to not trigger serialization side-effects isSerializingFurnaceCart = true; - CompoundNBT nbt = furnaceCart.serializeNBT(); + CompoundTag nbt = furnaceCart.serializeNBT(); isSerializingFurnaceCart = false; int fuel = nbt.getInt("Fuel"); @@ -424,9 +424,9 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { double pushX = nbt.getDouble("PushX"); double pushZ = nbt.getDouble("PushZ"); - int i = MathHelper.floor(furnaceCart.getX()); - int j = MathHelper.floor(furnaceCart.getY()); - int k = MathHelper.floor(furnaceCart.getZ()); + int i = Mth.floor(furnaceCart.getX()); + int j = Mth.floor(furnaceCart.getY()); + int k = Mth.floor(furnaceCart.getZ()); if (furnaceCart.level.getBlockState(new BlockPos(i, j - 1, k)) .is(BlockTags.RAILS)) --j; @@ -480,7 +480,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } @Override - public CompoundNBT saveWithoutId(CompoundNBT nbt) { + public CompoundTag saveWithoutId(CompoundTag nbt) { return isSerializingFurnaceCart ? nbt : super.saveWithoutId(nbt); } @@ -495,8 +495,8 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } @Override - public Vector3d getAnchorVec() { - return new Vector3d(getX() - .5, getY(), getZ() - .5); + public Vec3 getAnchorVec() { + return new Vec3(getX() - .5, getY(), getZ() - .5); } @Override @@ -517,25 +517,25 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { @Override @OnlyIn(Dist.CLIENT) - public void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks) { + public void doLocalTransforms(float partialTicks, PoseStack[] matrixStacks) { float angleInitialYaw = getInitialYaw(); float angleYaw = getViewYRot(partialTicks); float anglePitch = getViewXRot(partialTicks); - for (MatrixStack stack : matrixStacks) + for (PoseStack stack : matrixStacks) stack.translate(-.5f, 0, -.5f); Entity ridingEntity = getVehicle(); - if (ridingEntity instanceof AbstractMinecartEntity) + if (ridingEntity instanceof AbstractMinecart) repositionOnCart(partialTicks, matrixStacks, ridingEntity); else if (ridingEntity instanceof AbstractContraptionEntity) { - if (ridingEntity.getVehicle() instanceof AbstractMinecartEntity) + if (ridingEntity.getVehicle() instanceof AbstractMinecart) repositionOnCart(partialTicks, matrixStacks, ridingEntity.getVehicle()); else repositionOnContraption(partialTicks, matrixStacks, ridingEntity); } - for (MatrixStack stack : matrixStacks) + for (PoseStack stack : matrixStacks) MatrixTransformStack.of(stack) .nudge(getId()) .centre() @@ -546,47 +546,47 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } @OnlyIn(Dist.CLIENT) - private void repositionOnContraption(float partialTicks, MatrixStack[] matrixStacks, Entity ridingEntity) { - Vector3d pos = getContraptionOffset(partialTicks, ridingEntity); - for (MatrixStack stack : matrixStacks) + private void repositionOnContraption(float partialTicks, PoseStack[] matrixStacks, Entity ridingEntity) { + Vec3 pos = getContraptionOffset(partialTicks, ridingEntity); + for (PoseStack stack : matrixStacks) stack.translate(pos.x, pos.y, pos.z); } // Minecarts do not always render at their exact location, so the contraption // has to adjust aswell @OnlyIn(Dist.CLIENT) - private void repositionOnCart(float partialTicks, MatrixStack[] matrixStacks, Entity ridingEntity) { - Vector3d cartPos = getCartOffset(partialTicks, ridingEntity); + private void repositionOnCart(float partialTicks, PoseStack[] matrixStacks, Entity ridingEntity) { + Vec3 cartPos = getCartOffset(partialTicks, ridingEntity); - if (cartPos == Vector3d.ZERO) + if (cartPos == Vec3.ZERO) return; - for (MatrixStack stack : matrixStacks) + for (PoseStack stack : matrixStacks) stack.translate(cartPos.x, cartPos.y, cartPos.z); } @OnlyIn(Dist.CLIENT) - private Vector3d getContraptionOffset(float partialTicks, Entity ridingEntity) { + private Vec3 getContraptionOffset(float partialTicks, Entity ridingEntity) { AbstractContraptionEntity parent = (AbstractContraptionEntity) ridingEntity; - Vector3d passengerPosition = parent.getPassengerPosition(this, partialTicks); - 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()); + Vec3 passengerPosition = parent.getPassengerPosition(this, partialTicks); + double x = passengerPosition.x - Mth.lerp(partialTicks, this.xOld, this.getX()); + double y = passengerPosition.y - Mth.lerp(partialTicks, this.yOld, this.getY()); + double z = passengerPosition.z - Mth.lerp(partialTicks, this.zOld, this.getZ()); - return new Vector3d(x, y, z); + return new Vec3(x, y, z); } @OnlyIn(Dist.CLIENT) - private Vector3d getCartOffset(float partialTicks, Entity ridingEntity) { - AbstractMinecartEntity cart = (AbstractMinecartEntity) ridingEntity; - 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); + private Vec3 getCartOffset(float partialTicks, Entity ridingEntity) { + AbstractMinecart cart = (AbstractMinecart) ridingEntity; + double cartX = Mth.lerp(partialTicks, cart.xOld, cart.getX()); + double cartY = Mth.lerp(partialTicks, cart.yOld, cart.getY()); + double cartZ = Mth.lerp(partialTicks, cart.zOld, cart.getZ()); + Vec3 cartPos = cart.getPos(cartX, cartY, cartZ); if (cartPos != null) { - Vector3d cartPosFront = cart.getPosOffs(cartX, cartY, cartZ, (double) 0.3F); - Vector3d cartPosBack = cart.getPosOffs(cartX, cartY, cartZ, (double) -0.3F); + Vec3 cartPosFront = cart.getPosOffs(cartX, cartY, cartZ, (double) 0.3F); + Vec3 cartPosBack = cart.getPosOffs(cartX, cartY, cartZ, (double) -0.3F); if (cartPosFront == null) cartPosFront = cartPos; if (cartPosBack == null) @@ -596,9 +596,9 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { cartY = (cartPosFront.y + cartPosBack.y) / 2.0D - cartY; cartZ = cartPos.z - cartZ; - return new Vector3d(cartX, cartY, cartZ); + return new Vec3(cartX, cartY, cartZ); } - return Vector3d.ZERO; + return Vec3.ZERO; } } 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 a2fa2b4ab..28a67c3fc 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 @@ -1,16 +1,16 @@ package com.simibubi.create.content.contraptions.components.structureMovement; -import net.minecraft.client.renderer.culling.ClippingHelper; -import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; public class OrientedContraptionEntityRenderer extends ContraptionEntityRenderer { - public OrientedContraptionEntityRenderer(EntityRendererManager p_i46179_1_) { + public OrientedContraptionEntityRenderer(EntityRenderDispatcher p_i46179_1_) { super(p_i46179_1_); } @Override - public boolean shouldRender(OrientedContraptionEntity entity, ClippingHelper p_225626_2_, double p_225626_3_, + public boolean shouldRender(OrientedContraptionEntity entity, Frustum p_225626_2_, double p_225626_3_, double p_225626_5_, double p_225626_7_) { if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_)) return false; 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 67aab845a..a983fcf7a 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 @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import static net.minecraft.block.HorizontalFaceBlock.FACE; -import static net.minecraft.state.properties.BlockStateProperties.AXIS; +import staticnet.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlockateProperties.AXIS; import static net.minecraft.state.properties.BlockStateProperties.FACING; -import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; +import staticnet.minecraft.world.level.block.state.properties.BlockStatePropertiess.HORIZONTAL_FACING; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock; @@ -14,27 +14,27 @@ import com.simibubi.create.foundation.utility.DirectionHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BellBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.BellBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.block.HorizontalFaceBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.StairsBlock; -import net.minecraft.network.PacketBuffer; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.properties.AttachFace; -import net.minecraft.state.properties.BellAttachment; +import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.level.block.StairBlock; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.level.block.state.properties.BellAttachType; import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.Half; -import net.minecraft.state.properties.SlabType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.properties.Half; +import net.minecraft.world.level.block.state.properties.SlabType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class StructureTransform { @@ -87,8 +87,8 @@ public class StructureTransform { mirror = Mirror.NONE; } - public Vector3d applyWithoutOffset(Vector3d localVec) { - Vector3d vec = localVec; + public Vec3 applyWithoutOffset(Vec3 localVec) { + Vec3 vec = localVec; if (mirror != null) vec = VecHelper.mirrorCentered(vec, mirror); if (rotationAxis != null) @@ -96,8 +96,8 @@ public class StructureTransform { return vec; } - public Vector3d apply(Vector3d localVec) { - return applyWithoutOffset(localVec).add(Vector3d.atLowerCornerOf(offset)); + public Vec3 apply(Vec3 localVec) { + return applyWithoutOffset(localVec).add(Vec3.atLowerCornerOf(offset)); } public BlockPos applyWithoutOffset(BlockPos localPos) { @@ -108,7 +108,7 @@ public class StructureTransform { return applyWithoutOffset(localPos).offset(offset); } - public void apply(TileEntity te) { + public void apply(BlockEntity te) { if (te instanceof ITransformableTE) ((ITransformableTE) te).transform(this); } @@ -126,11 +126,11 @@ public class StructureTransform { if (rotationAxis == Axis.Y) { if (block instanceof BellBlock) { - if (state.getValue(BlockStateProperties.BELL_ATTACHMENT) == BellAttachment.DOUBLE_WALL) { - state = state.setValue(BlockStateProperties.BELL_ATTACHMENT, BellAttachment.SINGLE_WALL); + if (state.getValue(BlockStateProperties.BELL_ATTACHMENT) == BellAttachType.DOUBLE_WALL) { + state = state.setValue(BlockStateProperties.BELL_ATTACHMENT, BellAttachType.SINGLE_WALL); } - return state.setValue(HorizontalFaceBlock.FACING, - rotation.rotate(state.getValue(HorizontalFaceBlock.FACING))); + return state.setValue(FaceAttachedHorizontalDirectionalBlock.FACING, + rotation.rotate(state.getValue(FaceAttachedHorizontalDirectionalBlock.FACING))); } return state.rotate(rotation); } @@ -138,8 +138,8 @@ public class StructureTransform { if (block instanceof AbstractChassisBlock) return rotateChassis(state); - if (block instanceof HorizontalFaceBlock) { - Direction stateFacing = state.getValue(HorizontalFaceBlock.FACING); + if (block instanceof FaceAttachedHorizontalDirectionalBlock) { + Direction stateFacing = state.getValue(FaceAttachedHorizontalDirectionalBlock.FACING); AttachFace stateFace = state.getValue(FACE); Direction forcedAxis = rotationAxis == Axis.Z ? Direction.EAST : Direction.SOUTH; @@ -148,7 +148,7 @@ public class StructureTransform { for (int i = 0; i < rotation.ordinal(); i++) { stateFace = state.getValue(FACE); - stateFacing = state.getValue(HorizontalFaceBlock.FACING); + stateFacing = state.getValue(FaceAttachedHorizontalDirectionalBlock.FACING); boolean b = state.getValue(FACE) == AttachFace.CEILING; state = state.setValue(HORIZONTAL_FACING, b ? forcedAxis : forcedAxis.getOpposite()); @@ -169,7 +169,7 @@ public class StructureTransform { } boolean halfTurn = rotation == Rotation.CLOCKWISE_180; - if (block instanceof StairsBlock) { + if (block instanceof StairBlock) { state = transformStairs(state, halfTurn); return state; } @@ -214,20 +214,20 @@ public class StructureTransform { } protected BlockState transformStairs(BlockState state, boolean halfTurn) { - if (state.getValue(StairsBlock.FACING) + if (state.getValue(StairBlock.FACING) .getAxis() != rotationAxis) { for (int i = 0; i < rotation.ordinal(); i++) { - Direction direction = state.getValue(StairsBlock.FACING); - Half half = state.getValue(StairsBlock.HALF); + Direction direction = state.getValue(StairBlock.FACING); + Half half = state.getValue(StairBlock.HALF); if (direction.getAxisDirection() == AxisDirection.POSITIVE ^ half == Half.BOTTOM ^ direction.getAxis() == Axis.Z) - state = state.cycle(StairsBlock.HALF); + state = state.cycle(StairBlock.HALF); else - state = state.setValue(StairsBlock.FACING, direction.getOpposite()); + state = state.setValue(StairBlock.FACING, direction.getOpposite()); } } else { if (halfTurn) { - state = state.cycle(StairsBlock.HALF); + state = state.cycle(StairBlock.HALF); } } return state; @@ -354,7 +354,7 @@ public class StructureTransform { return rotated; } - public static StructureTransform fromBuffer(PacketBuffer buffer) { + public static StructureTransform fromBuffer(FriendlyByteBuf buffer) { BlockPos readBlockPos = buffer.readBlockPos(); int readAngle = buffer.readInt(); int axisIndex = buffer.readVarInt(); @@ -365,7 +365,7 @@ public class StructureTransform { mirrorIndex == -1 ? null : Mirror.values()[mirrorIndex]); } - public void writeToBuffer(PacketBuffer buffer) { + public void writeToBuffer(FriendlyByteBuf buffer) { buffer.writeBlockPos(offset); buffer.writeInt(angle); buffer.writeVarInt(rotationAxis == null ? -1 : rotationAxis.ordinal()); 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 a28788f0e..5342576e3 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 @@ -4,24 +4,24 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; public abstract class TranslatingContraption extends Contraption { protected Set cachedColliders; protected Direction cachedColliderDirection; - public Set getColliders(World world, Direction movementDirection) { + public Set getColliders(Level world, Direction movementDirection) { if (getBlocks() == null) return Collections.emptySet(); if (cachedColliders == null || cachedColliderDirection != movementDirection) { cachedColliders = new HashSet<>(); cachedColliderDirection = movementDirection; - for (BlockInfo info : getBlocks().values()) { + for (StructureBlockInfo info : getBlocks().values()) { BlockPos offsetPos = info.pos.relative(movementDirection); if (info.state.getCollisionShape(world, offsetPos) .isEmpty()) @@ -38,7 +38,7 @@ public abstract class TranslatingContraption extends Contraption { } @Override - public void removeBlocksFromWorld(World world, BlockPos offset) { + public void removeBlocksFromWorld(Level world, BlockPos offset) { int count = blocks.size(); super.removeBlocksFromWorld(world, offset); if (count != blocks.size()) { 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 daa19daa7..7b2406657 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 @@ -2,14 +2,16 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelReader; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public abstract class BearingBlock extends DirectionalKineticBlock { @@ -18,7 +20,7 @@ public abstract class BearingBlock extends DirectionalKineticBlock { } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face == state.getValue(FACING).getOpposite(); } @@ -33,10 +35,10 @@ public abstract class BearingBlock extends DirectionalKineticBlock { } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - ActionResultType resultType = super.onWrenched(state, context); + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + InteractionResult resultType = super.onWrenched(state, context); if (!context.getLevel().isClientSide && resultType.consumesAction()) { - TileEntity te = context.getLevel().getBlockEntity(context.getClickedPos()); + BlockEntity 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 871ce7a0f..a82528bd9 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 @@ -9,12 +9,12 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType; import com.simibubi.create.foundation.config.AllConfigs; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -33,7 +33,7 @@ public class BearingContraption extends Contraption { } @Override - public boolean assemble(World world, BlockPos pos) throws AssemblyException { + public boolean assemble(Level world, BlockPos pos) throws AssemblyException { BlockPos offset = pos.relative(facing); if (!searchMovedStructure(world, offset, null)) return false; @@ -57,7 +57,7 @@ public class BearingContraption extends Contraption { } @Override - public void addBlock(BlockPos pos, Pair capture) { + public void addBlock(BlockPos pos, Pair capture) { BlockPos localPos = pos.subtract(anchor); if (!getBlocks().containsKey(localPos) && AllBlockTags.WINDMILL_SAILS.matches(capture.getKey().state)) sailBlocks++; @@ -65,15 +65,15 @@ public class BearingContraption extends Contraption { } @Override - public CompoundNBT writeNBT(boolean spawnPacket) { - CompoundNBT tag = super.writeNBT(spawnPacket); + public CompoundTag writeNBT(boolean spawnPacket) { + CompoundTag tag = super.writeNBT(spawnPacket); tag.putInt("Sails", sailBlocks); tag.putInt("Facing", facing.get3DDataValue()); return tag; } @Override - public void readNBT(World world, CompoundNBT tag, boolean spawnData) { + public void readNBT(Level world, CompoundTag tag, boolean spawnData) { sailBlocks = tag.getInt("Sails"); 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 547371ae4..84664ea9a 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 @@ -10,10 +10,12 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import com.mojang.math.Quaternion; +import com.mojang.math.Vector3f; + +import OrientedData; public class BearingInstance extends BackHalfShaftInstance implements IDynamicInstance { final B bearing; 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 e8521f53b..7492ad710 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 @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -10,20 +10,20 @@ import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; public class BearingRenderer extends KineticTileEntityRenderer { - public BearingRenderer(TileEntityRendererDispatcher dispatcher) { + public BearingRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; 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 240e1a23f..16c7d47b8 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 @@ -3,16 +3,18 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class ClockworkBearingBlock extends BearingBlock implements ITE { @@ -21,17 +23,17 @@ public class ClockworkBearingBlock extends BearingBlock implements ITE { @@ -42,9 +44,9 @@ public class ClockworkBearingBlock extends BearingBlock implements ITE type) { + public ClockworkBearingTileEntity(BlockEntityType type) { super(type); setLazyTickRate(3); } @@ -301,7 +301,7 @@ public class ClockworkBearingTileEntity extends KineticTileEntity } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("Running", running); compound.putFloat("HourAngle", hourAngle); compound.putFloat("MinuteAngle", minuteAngle); @@ -310,7 +310,7 @@ public class ClockworkBearingTileEntity extends KineticTileEntity } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { float hourAngleBefore = hourAngle; float minuteAngleBefore = minuteAngle; @@ -348,10 +348,10 @@ public class ClockworkBearingTileEntity extends KineticTileEntity @Override public float getInterpolatedAngle(float partialTicks) { if (isVirtual()) - return MathHelper.lerp(partialTicks, prevForcedAngle, hourAngle); + return Mth.lerp(partialTicks, prevForcedAngle, hourAngle); if (hourHand == null || hourHand.isStalled()) partialTicks = 0; - return MathHelper.lerp(partialTicks, hourAngle, hourAngle + getHourArmSpeed()); + return Mth.lerp(partialTicks, hourAngle, hourAngle + getHourArmSpeed()); } @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 7c0af2c70..09269d83a 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 @@ -12,10 +12,10 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class ClockworkContraption extends Contraption { @@ -39,7 +39,7 @@ public class ClockworkContraption extends Contraption { return pos.equals(anchor.relative(facing.getOpposite(), offset + 1)); } - public static Pair assembleClockworkAt(World world, BlockPos pos, + public static Pair assembleClockworkAt(Level world, BlockPos pos, Direction direction) throws AssemblyException { int hourArmBlocks = 0; @@ -83,17 +83,17 @@ public class ClockworkContraption extends Contraption { } @Override - public boolean assemble(World world, BlockPos pos) throws AssemblyException { + public boolean assemble(Level world, BlockPos pos) throws AssemblyException { return searchMovedStructure(world, pos, facing); } @Override - public boolean searchMovedStructure(World world, BlockPos pos, Direction direction) throws AssemblyException { + public boolean searchMovedStructure(Level world, BlockPos pos, Direction direction) throws AssemblyException { return super.searchMovedStructure(world, pos.relative(direction, offset + 1), null); } @Override - protected boolean moveBlock(World world, Direction direction, Queue frontier, + protected boolean moveBlock(Level world, Direction direction, Queue frontier, Set visited) throws AssemblyException { if (ignoreBlocks.contains(frontier.peek())) { frontier.poll(); @@ -103,8 +103,8 @@ public class ClockworkContraption extends Contraption { } @Override - public CompoundNBT writeNBT(boolean spawnPacket) { - CompoundNBT tag = super.writeNBT(spawnPacket); + public CompoundTag writeNBT(boolean spawnPacket) { + CompoundTag tag = super.writeNBT(spawnPacket); tag.putInt("facing", facing.get3DDataValue()); tag.putInt("offset", offset); NBTHelper.writeEnum(tag, "HandType", handType); @@ -112,7 +112,7 @@ public class ClockworkContraption extends Contraption { } @Override - public void readNBT(World world, CompoundNBT tag, boolean spawnData) { + public void readNBT(Level world, CompoundTag tag, boolean spawnData) { facing = Direction.from3DDataValue(tag.getInt("facing")); handType = NBTHelper.readEnum(tag, "HandType", HandType.class); offset = tag.getInt("offset"); 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 af8a52b22..8d7b04e16 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 @@ -4,7 +4,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Dir import com.simibubi.create.content.contraptions.components.structureMovement.IControlContraption; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; -import net.minecraft.util.Direction.Axis; +import net.minecraft.core.Direction.Axis; public interface IBearingTileEntity extends IControlContraption { 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 005f57692..25e8a2afb 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 @@ -3,15 +3,17 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class MechanicalBearingBlock extends BearingBlock implements ITE { @@ -20,21 +22,21 @@ public class MechanicalBearingBlock extends BearingBlock implements ITE { if (te.running) { te.disassemble(); @@ -42,9 +44,9 @@ public class MechanicalBearingBlock extends BearingBlock implements ITE type) { + public MechanicalBearingTileEntity(BlockEntityType type) { super(type); setLazyTickRate(3); } @@ -67,7 +88,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("Running", running); compound.putFloat("Angle", angle); AssemblyException.write(compound, lastException); @@ -75,7 +96,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { if (wasMoved) { super.fromTag(state, compound, clientPacket); return; @@ -98,10 +119,10 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity @Override public float getInterpolatedAngle(float partialTicks) { if (isVirtual()) - return MathHelper.lerp(partialTicks + .5f, prevAngle, angle); + return Mth.lerp(partialTicks + .5f, prevAngle, angle); if (movedContraption == null || movedContraption.isStalled() || !running) partialTicks = 0; - return MathHelper.lerp(partialTicks, angle, angle + getAngularSpeed()); + return Mth.lerp(partialTicks, angle, angle + getAngularSpeed()); } @Override @@ -300,7 +321,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity } @Override - public boolean addToTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToTooltip(List tooltip, boolean isPlayerSneaking) { if (super.addToTooltip(tooltip, isPlayerSneaking)) return true; if (isPlayerSneaking) 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 458ff0d2c..60ff96cc1 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 @@ -18,28 +18,30 @@ import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.placement.PlacementOffset; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ShearsItem; -import net.minecraft.pathfinding.PathType; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ShearsItem; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class SailBlock extends WrenchableDirectionalBlock { @@ -63,13 +65,13 @@ public class SailBlock extends WrenchableDirectionalBlock { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockState state = super.getStateForPlacement(context); return state.setValue(FACING, state.getValue(FACING).getOpposite()); } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) { ItemStack heldItem = player.getItemInHand(hand); IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId); @@ -79,23 +81,23 @@ public class SailBlock extends WrenchableDirectionalBlock { if (heldItem.getItem() instanceof ShearsItem) { if (!world.isClientSide) applyDye(state, world, pos, null); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (frame) - return ActionResultType.PASS; + return InteractionResult.PASS; DyeColor color = DyeColor.getColor(heldItem); if (color != null && color != this.color) { if (!world.isClientSide) applyDye(state, world, pos, color); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } - protected void applyDye(BlockState state, World world, BlockPos pos, @Nullable DyeColor color) { + protected void applyDye(BlockState state, Level world, BlockPos pos, @Nullable DyeColor color) { BlockState newState = (color == null ? AllBlocks.SAIL_FRAME : AllBlocks.DYED_SAILS.get(color)).getDefaultState(); newState = BlockHelper.copyProperties(state, newState); @@ -154,19 +156,19 @@ public class SailBlock extends WrenchableDirectionalBlock { } @Override - public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, CollisionContext p_220053_4_) { 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_) { + public VoxelShape getCollisionShape(BlockState state, BlockGetter p_220071_2_, BlockPos p_220071_3_, CollisionContext p_220071_4_) { if (frame) return AllShapes.SAIL_FRAME_COLLISION.get(state.getValue(FACING)); return getShape(state, p_220071_2_, p_220071_3_, p_220071_4_); } @Override - public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) { + public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) { ItemStack pickBlock = super.getPickBlock(state, target, world, pos, player); if (pickBlock.isEmpty()) return AllBlocks.SAIL.get() @@ -174,13 +176,13 @@ public class SailBlock extends WrenchableDirectionalBlock { return pickBlock; } - public void fallOn(World p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { + public void fallOn(Level p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { if (frame) 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 updateEntityAfterFallOn(IBlockReader p_176216_1_, Entity p_176216_2_) { + public void updateEntityAfterFallOn(BlockGetter p_176216_1_, Entity p_176216_2_) { if (frame || p_176216_2_.isSuppressingBounce()) { super.updateEntityAfterFallOn(p_176216_1_, p_176216_2_); } else { @@ -189,7 +191,7 @@ public class SailBlock extends WrenchableDirectionalBlock { } private void bounce(Entity p_226860_1_) { - Vector3d Vector3d = p_226860_1_.getDeltaMovement(); + Vec3 Vector3d = p_226860_1_.getDeltaMovement(); if (Vector3d.y < 0.0D) { double d0 = p_226860_1_ instanceof LivingEntity ? 1.0D : 0.8D; p_226860_1_.setDeltaMovement(Vector3d.x, -Vector3d.y * (double) 0.26F * d0, Vector3d.z); @@ -198,7 +200,7 @@ public class SailBlock extends WrenchableDirectionalBlock { } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } @@ -223,7 +225,7 @@ public class SailBlock extends WrenchableDirectionalBlock { } @Override - public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { + public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) { List directions = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), state.getValue(SailBlock.FACING).getAxis(), dir -> world.getBlockState(pos.relative(dir)).getMaterial().isReplaceable()); if (directions.isEmpty()) 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 53490eedd..9be6ccdc8 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 @@ -9,11 +9,13 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import com.mojang.math.Quaternion; +import com.mojang.math.Vector3f; + +import OrientedData; public class StabilizedBearingInstance extends ActorInstance { 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 4f23b4b3e..fb97c5b44 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 @@ -19,12 +19,12 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Quaternion; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import com.mojang.math.Quaternion; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -33,7 +33,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { @Override @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - ContraptionMatrices matrices, IRenderTypeBuffer buffer) { + ContraptionMatrices matrices, MultiBufferSource buffer) { if (Backend.getInstance().canUseInstancing()) return; Direction facing = context.state.getValue(BlockStateProperties.FACING); 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 e3f96872d..f43c0a1bd 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 @@ -6,10 +6,10 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType; import com.simibubi.create.content.contraptions.components.structureMovement.NonStationaryLighter; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class StabilizedContraption extends Contraption { @@ -22,7 +22,7 @@ public class StabilizedContraption extends Contraption { } @Override - public boolean assemble(World world, BlockPos pos) throws AssemblyException { + public boolean assemble(Level world, BlockPos pos) throws AssemblyException { BlockPos offset = pos.relative(facing); if (!searchMovedStructure(world, offset, null)) return false; @@ -43,14 +43,14 @@ public class StabilizedContraption extends Contraption { } @Override - public CompoundNBT writeNBT(boolean spawnPacket) { - CompoundNBT tag = super.writeNBT(spawnPacket); + public CompoundTag writeNBT(boolean spawnPacket) { + CompoundTag tag = super.writeNBT(spawnPacket); tag.putInt("Facing", facing.get3DDataValue()); return tag; } @Override - public void readNBT(World world, CompoundNBT tag, boolean spawnData) { + public void readNBT(Level world, CompoundTag tag, boolean spawnData) { 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 0c6e037f9..563dfe27c 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 @@ -3,15 +3,17 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class WindmillBearingBlock extends BearingBlock implements ITE { @@ -20,21 +22,21 @@ public class WindmillBearingBlock extends BearingBlock implements ITE { if (te.running) { te.disassemble(); @@ -42,9 +44,9 @@ public class WindmillBearingBlock extends BearingBlock implements ITE movementDirection; protected float lastGeneratedSpeed; - public WindmillBearingTileEntity(TileEntityType type) { + public WindmillBearingTileEntity(BlockEntityType type) { super(type); } @@ -44,7 +44,7 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity { return lastGeneratedSpeed; int sails = ((BearingContraption) movedContraption.getContraption()).getSailBlocks() / AllConfigs.SERVER.kinetics.windmillSailsPerRPM.get(); - return MathHelper.clamp(sails, 1, 16) * getAngleSpeedDirection(); + return Mth.clamp(sails, 1, 16) * getAngleSpeedDirection(); } @Override @@ -58,13 +58,13 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putFloat("LastGenerated", lastGeneratedSpeed); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { if (!wasMoved) lastGeneratedSpeed = compound.getFloat("LastGenerated"); super.fromTag(state, compound, clientPacket); 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 7ba1ceba3..6967624fc 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 @@ -6,25 +6,27 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.block.RotatedPillarBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.state.BooleanProperty; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.common.Tags; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public abstract class AbstractChassisBlock extends RotatedPillarBlock implements IWrenchable { public AbstractChassisBlock(Properties properties) { @@ -37,15 +39,15 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.CHASSIS.create(); } @Override - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { if (!player.mayBuild()) - return ActionResultType.PASS; + return InteractionResult.PASS; ItemStack heldItem = player.getItemInHand(handIn); boolean isSlimeBall = heldItem.getItem() @@ -53,16 +55,16 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements BooleanProperty affectedSide = getGlueableSide(state, hit.getDirection()); if (affectedSide == null) - return ActionResultType.PASS; + return InteractionResult.PASS; if (isSlimeBall && state.getValue(affectedSide)) { for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(state, face); if (glueableSide != null && !state.getValue(glueableSide) && glueAllowedOnSide(worldIn, pos, state, face)) { if (worldIn.isClientSide) { - Vector3d vec = hit.getLocation(); + Vec3 vec = hit.getLocation(); worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } AllSoundEvents.SLIME_ADDED.playOnServer(worldIn, pos, .5f, 1); state = state.setValue(glueableSide, true); @@ -70,24 +72,24 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements } if (!worldIn.isClientSide) worldIn.setBlockAndUpdate(pos, state); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if ((!heldItem.isEmpty() || !player.isShiftKeyDown()) && !isSlimeBall) - return ActionResultType.PASS; + return InteractionResult.PASS; if (state.getValue(affectedSide) == isSlimeBall) - return ActionResultType.PASS; + return InteractionResult.PASS; if (!glueAllowedOnSide(worldIn, pos, state, hit.getDirection())) - return ActionResultType.PASS; + return InteractionResult.PASS; if (worldIn.isClientSide) { - Vector3d vec = hit.getLocation(); + Vec3 vec = hit.getLocation(); worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } AllSoundEvents.SLIME_ADDED.playOnServer(worldIn, pos, .5f, 1); worldIn.setBlockAndUpdate(pos, state.setValue(affectedSide, isSlimeBall)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override @@ -143,7 +145,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements public abstract BooleanProperty getGlueableSide(BlockState state, Direction face); - protected boolean glueAllowedOnSide(IBlockReader world, BlockPos pos, BlockState state, Direction side) { + protected boolean glueAllowedOnSide(BlockGetter world, BlockPos pos, BlockState state, Direction side) { return true; } 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 5477f449e..0bb11e1a5 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 @@ -16,12 +16,12 @@ import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.CreateClient; import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.level.Level; public class ChassisRangeDisplay { @@ -87,8 +87,8 @@ public class ChassisRangeDisplay { static List groupEntries = new ArrayList<>(); public static void tick() { - PlayerEntity player = Minecraft.getInstance().player; - World world = Minecraft.getInstance().level; + Player player = Minecraft.getInstance().player; + Level world = Minecraft.getInstance().level; boolean hasWrench = AllItems.WRENCH.isIn(player.getMainHandItem()); for (Iterator iterator = entries.keySet() @@ -113,12 +113,12 @@ public class ChassisRangeDisplay { if (!hasWrench) return; - RayTraceResult over = Minecraft.getInstance().hitResult; - if (!(over instanceof BlockRayTraceResult)) + HitResult over = Minecraft.getInstance().hitResult; + if (!(over instanceof BlockHitResult)) return; - BlockRayTraceResult ray = (BlockRayTraceResult) over; + BlockHitResult ray = (BlockHitResult) over; BlockPos pos = ray.getBlockPos(); - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity tileEntity = world.getBlockEntity(pos); if (tileEntity == null || tileEntity.isRemoved()) return; if (!(tileEntity instanceof ChassisTileEntity)) @@ -147,8 +147,8 @@ public class ChassisRangeDisplay { private static boolean tickEntry(Entry entry, boolean hasWrench) { ChassisTileEntity chassisTileEntity = entry.te; - World teWorld = chassisTileEntity.getLevel(); - World world = Minecraft.getInstance().level; + Level teWorld = chassisTileEntity.getLevel(); + Level world = Minecraft.getInstance().level; if (chassisTileEntity.isRemoved() || teWorld == null || teWorld != world || !world.isLoaded(chassisTileEntity.getBlockPos())) { 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 a5590caf6..1aa894726 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 @@ -2,6 +2,16 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch import static net.minecraft.state.properties.BlockStateProperties.AXIS; +import javanet.minimport com.simibubi.create.AllBlocks; +import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; +import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.tileEntity.SmartTileEntity; +import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform; +import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.BulkScrollValueBehaviour; +import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; +import com.simibubi.create.foundation.utility.Iterate; +import com.simibubi.create.foundation.utility.Lang; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -9,6 +19,21 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; import java.util.Set; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.DistExecutor; + +ecraft.world.level.block.state.properties.BlockStatePropertiesport java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import java.util.Set; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; @@ -36,7 +61,7 @@ public class ChassisTileEntity extends SmartTileEntity { ScrollValueBehaviour range; - public ChassisTileEntity(TileEntityType type) { + public ChassisTileEntity(BlockEntityType type) { super(type); } @@ -86,7 +111,7 @@ public class ChassisTileEntity extends SmartTileEntity { if (visited.contains(current)) continue; visited.add(current); - TileEntity tileEntity = level.getBlockEntity(current); + BlockEntity tileEntity = level.getBlockEntity(current); if (tileEntity instanceof ChassisTileEntity) { ChassisTileEntity chassis = (ChassisTileEntity) tileEntity; collected.add(chassis); 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 3c35b4573..1f6338559 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 @@ -5,18 +5,20 @@ import com.simibubi.create.AllSpriteShifts; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class LinearChassisBlock extends AbstractChassisBlock { @@ -36,7 +38,7 @@ public class LinearChassisBlock extends AbstractChassisBlock { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockPos placedOnPos = context.getClickedPos() .relative(context.getClickedFace() .getOpposite()); @@ -54,7 +56,7 @@ public class LinearChassisBlock extends AbstractChassisBlock { } @Override - public BlockState updateShape(BlockState state, Direction side, BlockState other, IWorld p_196271_4_, + public BlockState updateShape(BlockState state, Direction side, BlockState other, LevelAccessor p_196271_4_, BlockPos p_196271_5_, BlockPos p_196271_6_) { BooleanProperty property = getGlueableSide(state, side); if (property == null || !sameKind(state, other) || state.getValue(AXIS) != other.getValue(AXIS)) @@ -70,7 +72,7 @@ public class LinearChassisBlock extends AbstractChassisBlock { } @Override - protected boolean glueAllowedOnSide(IBlockReader world, BlockPos pos, BlockState state, Direction side) { + protected boolean glueAllowedOnSide(BlockGetter world, BlockPos pos, BlockState state, Direction side) { BlockState other = world.getBlockState(pos.relative(side)); return !sameKind(other, state) || state.getValue(AXIS) != other.getValue(AXIS); } @@ -96,7 +98,7 @@ public class LinearChassisBlock extends AbstractChassisBlock { } @Override - protected Direction getUpDirection(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face) { + protected Direction getUpDirection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) { Axis axis = state.getValue(AXIS); if (face.getAxis() == axis) return super.getUpDirection(reader, pos, state, face); @@ -104,7 +106,7 @@ public class LinearChassisBlock extends AbstractChassisBlock { } @Override - protected Direction getRightDirection(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face) { + protected Direction getRightDirection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) { Axis axis = state.getValue(AXIS); return axis != face.getAxis() && axis.isHorizontal() ? (face.getAxis() .isHorizontal() ? Direction.DOWN : (axis == Axis.X ? Direction.NORTH : Direction.EAST)) @@ -138,7 +140,7 @@ public class LinearChassisBlock extends AbstractChassisBlock { } @Override - public boolean connectsTo(BlockState state, BlockState other, IBlockDisplayReader reader, BlockPos pos, + public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, Direction face) { Axis axis = state.getValue(AXIS); boolean superConnect = face.getAxis() == axis ? super.connectsTo(state, other, reader, pos, otherPos, face) 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 a54bc4c65..4432d9d1c 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 @@ -1,11 +1,13 @@ package com.simibubi.create.content.contraptions.components.structureMovement.chassis; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class RadialChassisBlock extends AbstractChassisBlock { 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 fab3a2e05..4dfe2cb4c 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 @@ -5,25 +5,27 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.particles.BlockParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class StickerBlock extends WrenchableDirectionalBlock implements ITE { @@ -37,7 +39,7 @@ public class StickerBlock extends WrenchableDirectionalBlock implements ITE implements IDynamicInstance { @@ -42,7 +44,7 @@ public class StickerInstance extends TileEntityInstance imple if (fakeWorld) offset = this.offset; - if (MathHelper.equal(offset, lastOffset)) + if (Mth.equal(offset, lastOffset)) return; animateHead(offset); @@ -51,7 +53,7 @@ public class StickerInstance extends TileEntityInstance imple } private void animateHead(float offset) { - MatrixStack stack = new MatrixStack(); + PoseStack stack = new PoseStack(); MatrixTransformStack.of(stack) .translate(getInstancePosition()) .nudge(tile.hashCode()) 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 91ef67f06..e8ef1b09c 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 @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.chassis; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -9,21 +9,21 @@ import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; public class StickerRenderer extends SafeTileEntityRenderer { - public StickerRenderer(TileEntityRendererDispatcher dispatcher) { + public StickerRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(StickerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(StickerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; 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 6e85209da..a69c8e492 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 @@ -13,11 +13,11 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; @@ -27,7 +27,7 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende LerpedFloat piston; boolean update; - public StickerTileEntity(TileEntityType tileEntityTypeIn) { + public StickerTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); piston = LerpedFloat.linear(); update = false; @@ -82,7 +82,7 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); if (clientPacket) update = true; 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 1c818a8ca..9e3f7c8ed 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 @@ -8,21 +8,23 @@ import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftBlock import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements ITE { @@ -31,7 +33,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements } @Override - public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader 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) @@ -39,40 +41,40 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements } @Override - public void updateIndirectNeighbourShapes(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) { + public void updateIndirectNeighbourShapes(BlockState stateIn, LevelAccessor worldIn, BlockPos pos, int flags, int count) { super.updateIndirectNeighbourShapes(stateIn, worldIn, pos, flags, count); withTileEntityDo(worldIn, pos, GantryCarriageTileEntity::checkValidGantryShaft); } @Override - public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { super.onPlace(state, worldIn, pos, oldState, isMoving); } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.GANTRY_PINION.create(); } @Override - protected Direction getFacingForPlacement(BlockItemUseContext context) { + protected Direction getFacingForPlacement(BlockPlaceContext context) { return context.getClickedFace(); } - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { if (!player.mayBuild() || player.isShiftKeyDown()) - return ActionResultType.PASS; + return InteractionResult.PASS; if (player.getItemInHand(handIn) .isEmpty()) { withTileEntityDo(worldIn, pos, te -> te.checkValidGantryShaft()); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockState stateForPlacement = super.getStateForPlacement(context); Direction opposite = stateForPlacement.getValue(FACING) .getOpposite(); @@ -82,7 +84,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, BlockPos updatePos, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos updatePos, boolean p_220069_6_) { if (updatePos.equals(pos.relative(state.getValue(FACING) .getOpposite())) && !canSurvive(state, world, pos)) @@ -90,7 +92,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState otherState, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState otherState, LevelAccessor world, BlockPos pos, BlockPos p_196271_6_) { if (state.getValue(FACING) != direction.getOpposite()) return state; 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 b2efd087a..d63247b47 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 @@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -12,10 +12,12 @@ import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import com.mojang.math.Vector3f; + +import ModelData; public class GantryCarriageInstance extends ShaftInstance implements IDynamicInstance { @@ -53,7 +55,7 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns public void beginFrame() { float cogAngle = getCogAngle(); - if (MathHelper.equal(cogAngle, lastAngle)) return; + if (Mth.equal(cogAngle, lastAngle)) return; animateCogs(cogAngle); } @@ -63,7 +65,7 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns } private void animateCogs(float cogAngle) { - MatrixStack ms = new MatrixStack(); + PoseStack ms = new PoseStack(); MatrixTransformStack.of(ms) .translate(getInstancePosition()) .centre() 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 63efd4fc7..cc17842b1 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 @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.gantry; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -11,24 +11,24 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import com.mojang.math.Vector3f; public class GantryCarriageRenderer extends KineticTileEntityRenderer { - public GantryCarriageRenderer(TileEntityRendererDispatcher dispatcher) { + public GantryCarriageRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); 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 7e516d2dc..902c06b40 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 @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ga import static net.minecraft.state.properties.BlockStateProperties.FACING; -import com.simibubi.create.AllBlocks; +import com.net.minimport com.simibubi.create.AllBlocks; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; @@ -10,6 +10,21 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import com.simibubi.create.content.contraptions.components.structureMovement.IDisplayAssemblyExceptions; import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftBlock; import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; + +ecraft.world.level.block.state.properties.BlockStatePropertiesate.AllSoundEvents; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; +import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; +import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionCollider; +import com.simibubi.create.content.contraptions.components.structureMovement.IDisplayAssemblyExceptions; +import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftBlock; +import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileEntity; import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundNBT; @@ -24,7 +39,7 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp boolean assembleNextTick; protected AssemblyException lastException; - public GantryCarriageTileEntity(TileEntityType typeIn) { + public GantryCarriageTileEntity(BlockEntityType typeIn) { super(typeIn); } @@ -75,7 +90,7 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp Direction direction = blockState.getValue(FACING); GantryContraption contraption = new GantryContraption(direction); - TileEntity shaftTe = level.getBlockEntity(worldPosition.relative(direction.getOpposite())); + BlockEntity shaftTe = level.getBlockEntity(worldPosition.relative(direction.getOpposite())); if (!(shaftTe instanceof GantryShaftTileEntity)) return; BlockState shaftState = shaftTe.getBlockState(); @@ -113,13 +128,13 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { AssemblyException.write(compound, lastException); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { lastException = AssemblyException.read(compound); super.fromTag(state, compound, clientPacket); } @@ -170,7 +185,7 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp return false; if (shaftState.getValue(GantryShaftBlock.POWERED)) return false; - TileEntity te = level.getBlockEntity(worldPosition.relative(facing)); + BlockEntity 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 260da29e1..24d76929f 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 @@ -7,11 +7,11 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import com.simibubi.create.content.contraptions.components.structureMovement.NonStationaryLighter; import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; public class GantryContraption extends TranslatingContraption { @@ -24,7 +24,7 @@ public class GantryContraption extends TranslatingContraption { } @Override - public boolean assemble(World world, BlockPos pos) throws AssemblyException { + public boolean assemble(Level world, BlockPos pos) throws AssemblyException { if (!searchMovedStructure(world, pos, null)) return false; startMoving(world); @@ -32,14 +32,14 @@ public class GantryContraption extends TranslatingContraption { } @Override - public CompoundNBT writeNBT(boolean spawnPacket) { - CompoundNBT tag = super.writeNBT(spawnPacket); + public CompoundTag writeNBT(boolean spawnPacket) { + CompoundTag tag = super.writeNBT(spawnPacket); tag.putInt("Facing", facing.get3DDataValue()); return tag; } @Override - public void readNBT(World world, CompoundNBT tag, boolean spawnData) { + public void readNBT(Level world, CompoundTag tag, boolean spawnData) { facing = Direction.from3DDataValue(tag.getInt("Facing")); super.readNBT(world, tag, spawnData); } @@ -59,7 +59,7 @@ public class GantryContraption extends TranslatingContraption { } @Override - protected boolean shouldUpdateAfterMovement(BlockInfo info) { + protected boolean shouldUpdateAfterMovement(StructureBlockInfo info) { return super.shouldUpdateAfterMovement(info) && !AllBlocks.GANTRY_CARRIAGE.has(info.state); } 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 c49b3bbe1..040c7eb18 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 @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.gantry; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllEntityTypes; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; @@ -13,32 +13,34 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.ServerSpeedProvider; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; 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; double clientOffsetDiff; double axisMotion; - public GantryContraptionEntity(EntityType entityTypeIn, World worldIn) { + public GantryContraptionEntity(EntityType entityTypeIn, Level worldIn) { super(entityTypeIn, worldIn); } - public static GantryContraptionEntity create(World world, Contraption contraption, Direction movementAxis) { + public static GantryContraptionEntity create(Level world, Contraption contraption, Direction movementAxis) { GantryContraptionEntity entity = new GantryContraptionEntity(AllEntityTypes.GANTRY_CONTRAPTION.get(), world); entity.setContraption(contraption); entity.movementAxis = movementAxis; @@ -58,7 +60,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { checkPinionShaft(); tickActors(); - Vector3d movementVec = getDeltaMovement(); + Vec3 movementVec = getDeltaMovement(); if (ContraptionCollider.collideBlocks(this)) { if (!level.isClientSide) @@ -76,15 +78,15 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { } protected void checkPinionShaft() { - Vector3d movementVec; + Vec3 movementVec; Direction facing = ((GantryContraption) contraption).getFacing(); - Vector3d currentPosition = getAnchorVec().add(.5, .5, .5); + Vec3 currentPosition = getAnchorVec().add(.5, .5, .5); BlockPos gantryShaftPos = new BlockPos(currentPosition).relative(facing.getOpposite()); - TileEntity te = level.getBlockEntity(gantryShaftPos); + BlockEntity te = level.getBlockEntity(gantryShaftPos); if (!(te instanceof GantryShaftTileEntity) || !AllBlocks.GANTRY_SHAFT.has(te.getBlockState())) { if (!level.isClientSide) { - setContraptionMotion(Vector3d.ZERO); + setContraptionMotion(Vec3.ZERO); disassemble(); } return; @@ -95,25 +97,25 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { GantryShaftTileEntity gantryShaftTileEntity = (GantryShaftTileEntity) te; float pinionMovementSpeed = gantryShaftTileEntity.getPinionMovementSpeed(); - movementVec = Vector3d.atLowerCornerOf(direction.getNormal()).scale(pinionMovementSpeed); + movementVec = Vec3.atLowerCornerOf(direction.getNormal()).scale(pinionMovementSpeed); if (blockState.getValue(GantryShaftBlock.POWERED) || pinionMovementSpeed == 0) { - setContraptionMotion(Vector3d.ZERO); + setContraptionMotion(Vec3.ZERO); if (!level.isClientSide) disassemble(); return; } - Vector3d nextPosition = currentPosition.add(movementVec); + Vec3 nextPosition = currentPosition.add(movementVec); double currentCoord = direction.getAxis() .choose(currentPosition.x, currentPosition.y, currentPosition.z); double nextCoord = direction.getAxis() .choose(nextPosition.x, nextPosition.y, nextPosition.z); - if ((MathHelper.floor(currentCoord) + .5f < nextCoord != (pinionMovementSpeed * direction.getAxisDirection() + if ((Mth.floor(currentCoord) + .5f < nextCoord != (pinionMovementSpeed * direction.getAxisDirection() .getStep() < 0))) if (!gantryShaftTileEntity.canAssembleOn()) { - setContraptionMotion(Vector3d.ZERO); + setContraptionMotion(Vec3.ZERO); if (!level.isClientSide) disassemble(); return; @@ -127,23 +129,23 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { } @Override - protected void writeAdditional(CompoundNBT compound, boolean spawnPacket) { + protected void writeAdditional(CompoundTag compound, boolean spawnPacket) { NBTHelper.writeEnum(compound, "GantryAxis", movementAxis); super.writeAdditional(compound, spawnPacket); } - protected void readAdditional(CompoundNBT compound, boolean spawnData) { + protected void readAdditional(CompoundTag compound, boolean spawnData) { movementAxis = NBTHelper.readEnum(compound, "GantryAxis", Direction.class); super.readAdditional(compound, spawnData); } @Override - public Vector3d applyRotation(Vector3d localPos, float partialTicks) { + public Vec3 applyRotation(Vec3 localPos, float partialTicks) { return localPos; } @Override - public Vector3d reverseRotation(Vector3d localPos, float partialTicks) { + public Vec3 reverseRotation(Vec3 localPos, float partialTicks) { return localPos; } @@ -176,17 +178,17 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { } @Override - public void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks) { } + public void doLocalTransforms(float partialTicks, PoseStack[] matrixStacks) { } public void updateClientMotion() { float modifier = movementAxis.getAxisDirection() .getStep(); - setContraptionMotion(Vector3d.atLowerCornerOf(movementAxis.getNormal()) + setContraptionMotion(Vec3.atLowerCornerOf(movementAxis.getNormal()) .scale((axisMotion + clientOffsetDiff * modifier / 2f) * ServerSpeedProvider.get())); } public double getAxisCoord() { - Vector3d anchorVec = getAnchorVec(); + Vec3 anchorVec = getAnchorVec(); return movementAxis.getAxis() .choose(anchorVec.x, anchorVec.y, anchorVec.z); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionUpdatePacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionUpdatePacket.java index 54463c051..25e4bdb89 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionUpdatePacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionUpdatePacket.java @@ -4,7 +4,7 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.network.PacketBuffer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.NetworkEvent.Context; @@ -21,14 +21,14 @@ public class GantryContraptionUpdatePacket extends SimplePacketBase { this.motion = motion; } - public GantryContraptionUpdatePacket(PacketBuffer buffer) { + public GantryContraptionUpdatePacket(FriendlyByteBuf buffer) { entityID = buffer.readInt(); coord = buffer.readFloat(); motion = buffer.readFloat(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(entityID); buffer.writeFloat((float) coord); buffer.writeFloat((float) motion); 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 8811e0208..ea2214c97 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 @@ -5,9 +5,9 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; @@ -25,13 +25,13 @@ public class GlueEffectPacket extends SimplePacketBase { this.fullBlock = fullBlock; } - public GlueEffectPacket(PacketBuffer buffer) { + public GlueEffectPacket(FriendlyByteBuf buffer) { pos = buffer.readBlockPos(); direction = Direction.from3DDataValue(buffer.readByte()); fullBlock = buffer.readBoolean(); } - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBlockPos(pos); buffer.writeByte(direction.get3DDataValue()); buffer.writeBoolean(fullBlock); 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 fd9b4b801..4b1051588 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 @@ -23,9 +23,9 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Quaternion; +import com.mojang.math.Quaternion; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.LightType; 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 c6e6ff037..676415614 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 @@ -21,44 +21,44 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.DirectionalBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DirectionalBlock; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntitySize; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.MoverType; -import net.minecraft.entity.Pose; -import net.minecraft.entity.effect.LightningBoltEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.IPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.state.BooleanProperty; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.GameRules; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.entity.LightningBolt; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.FakePlayer; @@ -73,11 +73,11 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat protected BlockPos hangingPosition; protected Direction facingDirection = Direction.SOUTH; - public SuperGlueEntity(EntityType type, World world) { + public SuperGlueEntity(EntityType type, Level world) { super(type, world); } - public SuperGlueEntity(World world, BlockPos pos, Direction direction) { + public SuperGlueEntity(Level world, BlockPos pos, Direction direction) { this(AllEntityTypes.SUPER_GLUE.get(), world); hangingPosition = pos; facingDirection = direction; @@ -153,7 +153,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat w = w / 32.0D; h = h / 32.0D; l = l / 32.0D; - this.setBoundingBox(new AxisAlignedBB(x - w, y - h, z - l, x + w, y + h, z + l)); + this.setBoundingBox(new AABB(x - w, y - h, z - l, x + w, y + h, z + l)); } } @@ -198,7 +198,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat .isEmpty(); } - public static boolean isValidFace(World world, BlockPos pos, Direction direction) { + public static boolean isValidFace(Level world, BlockPos pos, Direction direction) { BlockState state = world.getBlockState(pos); if (BlockMovementChecks.isBlockAttachedTowards(state, world, pos, direction)) return true; @@ -209,7 +209,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat return true; } - public static boolean isSideSticky(World world, BlockPos pos, Direction direction) { + public static boolean isSideSticky(Level world, BlockPos pos, Direction direction) { BlockState state = world.getBlockState(pos); if (AllBlocks.STICKY_MECHANICAL_PISTON.has(state)) return state.getValue(DirectionalKineticBlock.FACING) == direction; @@ -249,8 +249,8 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat @Override public boolean skipAttackInteraction(Entity entity) { - return entity instanceof PlayerEntity - ? hurt(DamageSource.playerAttack((PlayerEntity) entity), 0) + return entity instanceof Player + ? hurt(DamageSource.playerAttack((Player) entity), 0) : false; } @@ -266,12 +266,12 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat boolean mobGriefing = level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); Entity trueSource = source.getEntity(); - if (!mobGriefing && trueSource instanceof MobEntity) + if (!mobGriefing && trueSource instanceof Mob) return false; Entity immediateSource = source.getDirectEntity(); - if (!isVisible() && immediateSource instanceof PlayerEntity) { - if (!AllItems.SUPER_GLUE.isIn(((PlayerEntity) immediateSource).getMainHandItem())) + if (!isVisible() && immediateSource instanceof Player) { + if (!AllItems.SUPER_GLUE.isIn(((Player) immediateSource).getMainHandItem())) return true; } @@ -285,7 +285,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public void move(MoverType typeIn, Vector3d pos) { + public void move(MoverType typeIn, Vec3 pos) { if (!level.isClientSide && isAlive() && pos.lengthSqr() > 0.0D) { remove(); onBroken(null); @@ -301,12 +301,12 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - protected float getEyeHeight(Pose poseIn, EntitySize sizeIn) { + protected float getEyeHeight(Pose poseIn, EntityDimensions sizeIn) { return 0.0F; } @Override - public ItemStack getPickedResult(RayTraceResult target) { + public ItemStack getPickedResult(HitResult target) { return AllItems.SUPER_GLUE.asStack(); } @@ -316,43 +316,43 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public ActionResultType interact(PlayerEntity player, Hand hand) { + public InteractionResult interact(Player player, InteractionHand hand) { if (player instanceof FakePlayer) - return ActionResultType.PASS; + return InteractionResult.PASS; DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { triggerPlaceBlock(player, hand); }); - return ActionResultType.CONSUME; + return InteractionResult.CONSUME; } @OnlyIn(Dist.CLIENT) - private void triggerPlaceBlock(PlayerEntity player, Hand hand) { - if (!(player instanceof ClientPlayerEntity)) + private void triggerPlaceBlock(Player player, InteractionHand hand) { + if (!(player instanceof LocalPlayer)) return; - if (!(player.level instanceof ClientWorld)) + if (!(player.level instanceof ClientLevel)) return; - ClientPlayerEntity cPlayer = (ClientPlayerEntity) player; + LocalPlayer cPlayer = (LocalPlayer) player; Minecraft mc = Minecraft.getInstance(); - RayTraceResult ray = + HitResult ray = cPlayer.pick(mc.gameMode.getPickRange(), AnimationTickHolder.getPartialTicks(), false); - if (!(ray instanceof BlockRayTraceResult)) + if (!(ray instanceof BlockHitResult)) return; if (ray.getType() == Type.MISS) return; - BlockRayTraceResult blockRay = (BlockRayTraceResult) ray; + BlockHitResult blockRay = (BlockHitResult) ray; 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()) { + for (InteractionHand handIn : InteractionHand.values()) { ItemStack itemstack = cPlayer.getItemInHand(handIn); int countBefore = itemstack.getCount(); - ActionResultType actionResultType = - mc.gameMode.useItemOn(cPlayer, (ClientWorld) cPlayer.level, handIn, blockRay); - if (actionResultType != ActionResultType.SUCCESS) + InteractionResult actionResultType = + mc.gameMode.useItemOn(cPlayer, (ClientLevel) cPlayer.level, handIn, blockRay); + if (actionResultType != InteractionResult.SUCCESS) return; cPlayer.swing(handIn); @@ -363,7 +363,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public void addAdditionalSaveData(CompoundNBT compound) { + public void addAdditionalSaveData(CompoundTag compound) { compound.putByte("Facing", (byte) this.getFacingDirection() .get3DDataValue()); BlockPos blockpos = this.getHangingPosition(); @@ -373,7 +373,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public void readAdditionalSaveData(CompoundNBT compound) { + public void readAdditionalSaveData(CompoundTag compound) { this.hangingPosition = new BlockPos(compound.getInt("TileX"), compound.getInt("TileY"), compound.getInt("TileZ")); this.facingDirection = Direction.from3DDataValue(compound.getByte("Facing")); @@ -423,7 +423,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } } - float f = MathHelper.wrapDegrees(this.yRot); + float f = Mth.wrapDegrees(this.yRot); switch (transformRotation) { case CLOCKWISE_180: return f + 180.0F; @@ -450,7 +450,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public void thunderHit(ServerWorld world, LightningBoltEntity lightningBolt) {} + public void thunderHit(ServerLevel world, LightningBolt lightningBolt) {} @Override public void refreshDimensions() {} @@ -462,19 +462,19 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public IPacket getAddEntityPacket() { + public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override - public void writeSpawnData(PacketBuffer buffer) { - CompoundNBT compound = new CompoundNBT(); + public void writeSpawnData(FriendlyByteBuf buffer) { + CompoundTag compound = new CompoundTag(); addAdditionalSaveData(compound); buffer.writeNbt(compound); } @Override - public void readSpawnData(PacketBuffer additionalData) { + public void readSpawnData(FriendlyByteBuf additionalData) { readAdditionalSaveData(additionalData.readNbt()); } @@ -493,7 +493,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } @Override - public World getWorld() { + public Level getWorld() { 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 f1778657f..a3fbe81b8 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 @@ -9,22 +9,22 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.placement.IPlacementHelper; import com.simibubi.create.foundation.utility.worldWrappers.RayTraceWorld; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.event.world.BlockEvent.EntityPlaceEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -34,8 +34,8 @@ import net.minecraftforge.fml.network.PacketDistributor; @EventBusSubscriber public class SuperGlueHandler { - public static Map gatherGlue(IWorld world, BlockPos pos) { - List entities = world.getEntitiesOfClass(SuperGlueEntity.class, new AxisAlignedBB(pos)); + public static Map gatherGlue(LevelAccessor world, BlockPos pos) { + List entities = world.getEntitiesOfClass(SuperGlueEntity.class, new AABB(pos)); Map map = new HashMap<>(); for (SuperGlueEntity entity : entities) map.put(entity.getAttachedDirection(pos), entity); @@ -44,7 +44,7 @@ public class SuperGlueHandler { @SubscribeEvent public static void glueListensForBlockPlacement(EntityPlaceEvent event) { - IWorld world = event.getWorld(); + LevelAccessor world = event.getWorld(); Entity entity = event.getEntity(); BlockPos pos = event.getPos(); @@ -58,13 +58,13 @@ public class SuperGlueHandler { AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> entity), new GlueEffectPacket(pos, direction, true)); - if (entity instanceof PlayerEntity) - glueInOffHandAppliesOnBlockPlace(event, pos, (PlayerEntity) entity); + if (entity instanceof Player) + glueInOffHandAppliesOnBlockPlace(event, pos, (Player) entity); } - public static void glueInOffHandAppliesOnBlockPlace(EntityPlaceEvent event, BlockPos pos, PlayerEntity placer) { + public static void glueInOffHandAppliesOnBlockPlace(EntityPlaceEvent event, BlockPos pos, Player placer) { ItemStack itemstack = placer.getOffhandItem(); - ModifiableAttributeInstance reachAttribute = placer.getAttribute(ForgeMod.REACH_DISTANCE.get()); + AttributeInstance reachAttribute = placer.getAttribute(ForgeMod.REACH_DISTANCE.get()); if (!AllItems.SUPER_GLUE.isIn(itemstack) || reachAttribute == null) return; if (AllItems.WRENCH.isIn(placer.getMainHandItem())) @@ -73,15 +73,15 @@ public class SuperGlueHandler { return; double distance = reachAttribute.getValue(); - Vector3d start = placer.getEyePosition(1); - Vector3d look = placer.getViewVector(1); - Vector3d end = start.add(look.x * distance, look.y * distance, look.z * distance); - World world = placer.level; + Vec3 start = placer.getEyePosition(1); + Vec3 look = placer.getViewVector(1); + Vec3 end = start.add(look.x * distance, look.y * distance, look.z * distance); + Level world = placer.level; RayTraceWorld rayTraceWorld = 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)); + BlockHitResult ray = rayTraceWorld.clip( + new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, placer)); Direction face = ray.getDirection(); if (face == null || ray.getType() == Type.MISS) @@ -95,7 +95,7 @@ public class SuperGlueHandler { } SuperGlueEntity entity = new SuperGlueEntity(world, ray.getBlockPos(), face.getOpposite()); - CompoundNBT compoundnbt = itemstack.getTag(); + CompoundTag compoundnbt = itemstack.getTag(); if (compoundnbt != null) EntityType.updateCustomEntityTag(world, placer, entity, compoundnbt); 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 99811ca53..3655aa124 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 @@ -2,24 +2,26 @@ package com.simibubi.create.content.contraptions.components.structureMovement.gl import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ItemParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.item.Item.Properties; + public class SuperGlueItem extends Item { public SuperGlueItem(Properties properties) { @@ -42,24 +44,24 @@ public class SuperGlueItem extends Item { } @Override - public ActionResultType useOn(ItemUseContext context) { + public InteractionResult useOn(UseOnContext context) { BlockPos blockpos = context.getClickedPos(); Direction direction = context.getClickedFace(); BlockPos blockpos1 = blockpos.relative(direction); - PlayerEntity playerentity = context.getPlayer(); + Player playerentity = context.getPlayer(); ItemStack itemstack = context.getItemInHand(); if (playerentity == null || !this.canPlace(playerentity, direction, itemstack, blockpos1)) - return ActionResultType.FAIL; + return InteractionResult.FAIL; - World world = context.getLevel(); + Level world = context.getLevel(); SuperGlueEntity entity = new SuperGlueEntity(world, blockpos1, direction); - CompoundNBT compoundnbt = itemstack.getTag(); + CompoundTag compoundnbt = itemstack.getTag(); if (compoundnbt != null) EntityType.updateCustomEntityTag(world, playerentity, entity, compoundnbt); if (!entity.onValidSurface()) - return ActionResultType.FAIL; + return InteractionResult.FAIL; if (!world.isClientSide) { entity.playPlaceSound(); @@ -67,22 +69,22 @@ public class SuperGlueItem extends Item { } itemstack.hurtAndBreak(1, playerentity, SuperGlueItem::onBroken); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - public static void onBroken(PlayerEntity player) { + public static void onBroken(Player player) { } - protected boolean canPlace(PlayerEntity entity, Direction facing, ItemStack stack, BlockPos pos) { - return !World.isOutsideBuildHeight(pos) && entity.mayUseItemAt(pos, facing, stack); + protected boolean canPlace(Player entity, Direction facing, ItemStack stack, BlockPos pos) { + return !Level.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.atLowerCornerOf(direction.getNormal()); - Vector3d plane = VecHelper.axisAlingedPlaneOf(vec); - Vector3d facePos = VecHelper.getCenterOf(pos) + public static void spawnParticles(Level world, BlockPos pos, Direction direction, boolean fullBlock) { + Vec3 vec = Vec3.atLowerCornerOf(direction.getNormal()); + Vec3 plane = VecHelper.axisAlingedPlaneOf(vec); + Vec3 facePos = VecHelper.getCenterOf(pos) .add(vec.scale(.5f)); float distance = fullBlock ? 1f : .25f + .25f * (world.random.nextFloat() - .5f); @@ -90,14 +92,14 @@ public class SuperGlueItem extends Item { ItemStack stack = new ItemStack(Items.SLIME_BALL); for (int i = fullBlock ? 40 : 15; i > 0; i--) { - Vector3d offset = VecHelper.rotate(plane, 360 * world.random.nextFloat(), direction.getAxis()); - Vector3d motion = offset.normalize() + Vec3 offset = VecHelper.rotate(plane, 360 * world.random.nextFloat(), direction.getAxis()); + Vec3 motion = offset.normalize() .scale(1 / 16f); if (fullBlock) - offset = new Vector3d(MathHelper.clamp(offset.x, -.5, .5), MathHelper.clamp(offset.y, -.5, .5), - MathHelper.clamp(offset.z, -.5, .5)); - Vector3d particlePos = facePos.add(offset); - world.addParticle(new ItemParticleData(ParticleTypes.ITEM, stack), particlePos.x, particlePos.y, + offset = new Vec3(Mth.clamp(offset.x, -.5, .5), Mth.clamp(offset.y, -.5, .5), + Mth.clamp(offset.z, -.5, .5)); + Vec3 particlePos = facePos.add(offset); + world.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), particlePos.x, particlePos.y, particlePos.z, motion.x, motion.y, motion.z); } 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 9c2ad5ef3..e76998bb2 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 @@ -1,29 +1,29 @@ package com.simibubi.create.content.contraptions.components.structureMovement.glue; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.matrix.MatrixStack.Entry; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.PoseStack.Pose; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllItems; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.culling.ClippingHelper; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -35,7 +35,7 @@ public class SuperGlueRenderer extends EntityRenderer { private float[] insideQuad; private float[] outsideQuad; - public SuperGlueRenderer(EntityRendererManager renderManager) { + public SuperGlueRenderer(EntityRenderDispatcher renderManager) { super(renderManager); initQuads(); } @@ -46,9 +46,9 @@ public class SuperGlueRenderer extends EntityRenderer { } @Override - public boolean shouldRender(SuperGlueEntity entity, ClippingHelper frustum, double x, double y, double z) { + public boolean shouldRender(SuperGlueEntity entity, Frustum frustum, double x, double y, double z) { if (super.shouldRender(entity, frustum, x, y, z)) { - PlayerEntity player = Minecraft.getInstance().player; + Player player = Minecraft.getInstance().player; boolean visible = entity.isVisible(); boolean holdingGlue = AllItems.SUPER_GLUE.isIn(player.getMainHandItem()) || AllItems.SUPER_GLUE.isIn(player.getOffhandItem()); @@ -60,11 +60,11 @@ public class SuperGlueRenderer extends EntityRenderer { } @Override - public void render(SuperGlueEntity entity, float yaw, float partialTicks, MatrixStack ms, - IRenderTypeBuffer buffer, int light) { + public void render(SuperGlueEntity entity, float yaw, float partialTicks, PoseStack ms, + MultiBufferSource buffer, int light) { super.render(entity, yaw, partialTicks, ms, buffer, light); - IVertexBuilder builder = buffer.getBuffer(RenderType.entityCutout(getTextureLocation(entity))); + VertexConsumer builder = buffer.getBuffer(RenderType.entityCutout(getTextureLocation(entity))); light = getBrightnessForRender(entity); Direction face = entity.getFacingDirection(); @@ -72,7 +72,7 @@ public class SuperGlueRenderer extends EntityRenderer { MatrixTransformStack.of(ms) .rotateY(AngleHelper.horizontalAngleNew(face)) .rotateX(AngleHelper.verticalAngle(face)); - Entry peek = ms.last(); + Pose peek = ms.last(); renderQuad(builder, peek, insideQuad, light, -1); renderQuad(builder, peek, outsideQuad, light, 1); @@ -81,29 +81,29 @@ public class SuperGlueRenderer extends EntityRenderer { } private void initQuads() { - Vector3d diff = Vector3d.atLowerCornerOf(Direction.SOUTH.getNormal()); - Vector3d extension = diff.normalize() + Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal()); + Vec3 extension = diff.normalize() .scale(1 / 32f - 1 / 128f); - Vector3d plane = VecHelper.axisAlingedPlaneOf(diff); + Vec3 plane = VecHelper.axisAlingedPlaneOf(diff); Axis axis = Direction.getNearest(diff.x, diff.y, diff.z) .getAxis(); - Vector3d start = Vector3d.ZERO.subtract(extension); - Vector3d end = Vector3d.ZERO.add(extension); + Vec3 start = Vec3.ZERO.subtract(extension); + Vec3 end = Vec3.ZERO.add(extension); plane = plane.scale(1 / 2f); - Vector3d a1 = plane.add(start); - Vector3d b1 = plane.add(end); + Vec3 a1 = plane.add(start); + Vec3 b1 = plane.add(end); plane = VecHelper.rotate(plane, -90, axis); - Vector3d a2 = plane.add(start); - Vector3d b2 = plane.add(end); + Vec3 a2 = plane.add(start); + Vec3 b2 = plane.add(end); plane = VecHelper.rotate(plane, -90, axis); - Vector3d a3 = plane.add(start); - Vector3d b3 = plane.add(end); + Vec3 a3 = plane.add(start); + Vec3 b3 = plane.add(end); plane = VecHelper.rotate(plane, -90, axis); - Vector3d a4 = plane.add(start); - Vector3d b4 = plane.add(end); + Vec3 a4 = plane.add(start); + Vec3 b4 = plane.add(end); insideQuad = new float[] { (float) a1.x, (float) a1.y, (float) a1.z, 1, 0, @@ -124,14 +124,14 @@ public class SuperGlueRenderer extends EntityRenderer { BlockPos blockpos2 = blockpos.relative(entity.getFacingDirection() .getOpposite()); - World world = entity.getCommandSenderWorld(); - int light = world.isLoaded(blockpos) ? WorldRenderer.getLightColor(world, blockpos) : 15; - int light2 = world.isLoaded(blockpos2) ? WorldRenderer.getLightColor(world, blockpos2) : 15; + Level world = entity.getCommandSenderWorld(); + int light = world.isLoaded(blockpos) ? LevelRenderer.getLightColor(world, blockpos) : 15; + int light2 = world.isLoaded(blockpos2) ? LevelRenderer.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) { + private void renderQuad(VertexConsumer builder, Pose matrix, float[] data, int light, float normalZ) { for (int i = 0; i < 4; i++) { builder.vertex(matrix.pose(), data[5 * i], data[5 * i + 1], data[5 * i + 2]) .color(255, 255, 255, 255) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/DoorMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/DoorMovingInteraction.java index 4f270588c..5a390fbba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/DoorMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/DoorMovingInteraction.java @@ -2,28 +2,28 @@ package com.simibubi.create.content.contraptions.components.structureMovement.in import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; -import net.minecraft.block.BlockState; -import net.minecraft.block.DoorBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; public class DoorMovingInteraction extends SimpleBlockMovingInteraction { @Override - protected BlockState handle(PlayerEntity player, Contraption contraption, BlockPos pos, BlockState currentState) { + protected BlockState handle(Player player, Contraption contraption, BlockPos pos, BlockState currentState) { SoundEvent sound = currentState.getValue(DoorBlock.OPEN) ? SoundEvents.WOODEN_DOOR_CLOSE : SoundEvents.WOODEN_DOOR_OPEN; BlockPos otherPos = currentState.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? pos.above() : pos.below(); - BlockInfo info = contraption.getBlocks() + StructureBlockInfo info = contraption.getBlocks() .get(otherPos); if (info.state.hasProperty(DoorBlock.OPEN)) setContraptionBlockData(contraption.entity, otherPos, - new BlockInfo(info.pos, info.state.cycle(DoorBlock.OPEN), info.nbt)); + new StructureBlockInfo(info.pos, info.state.cycle(DoorBlock.OPEN), info.nbt)); float pitch = player.level.random.nextFloat() * 0.1F + 0.9F; playSound(player, sound, pitch); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/LeverMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/LeverMovingInteraction.java index 5101374b3..644d98737 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/LeverMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/LeverMovingInteraction.java @@ -2,16 +2,16 @@ package com.simibubi.create.content.contraptions.components.structureMovement.in import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeverBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LeverBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; public class LeverMovingInteraction extends SimpleBlockMovingInteraction { @Override - protected BlockState handle(PlayerEntity player, Contraption contraption, BlockPos pos, BlockState currentState) { + protected BlockState handle(Player player, Contraption contraption, BlockPos pos, BlockState currentState) { playSound(player, SoundEvents.LEVER_CLICK, currentState.getValue(LeverBlock.POWERED) ? 0.5f : 0.6f); return currentState.cycle(LeverBlock.POWERED); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/SimpleBlockMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/SimpleBlockMovingInteraction.java index 05decf2a8..63e0b09cc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/SimpleBlockMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/SimpleBlockMovingInteraction.java @@ -4,28 +4,28 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Abs import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.MovingInteractionBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; public abstract class SimpleBlockMovingInteraction extends MovingInteractionBehaviour { @Override - public boolean handlePlayerInteraction(PlayerEntity player, Hand activeHand, BlockPos localPos, + public boolean handlePlayerInteraction(Player player, InteractionHand activeHand, BlockPos localPos, AbstractContraptionEntity contraptionEntity) { Contraption contraption = contraptionEntity.getContraption(); - BlockInfo info = contraption.getBlocks() + StructureBlockInfo info = contraption.getBlocks() .get(localPos); BlockState newState = handle(player, contraption, localPos, info.state); if (info.state == newState) return false; - setContraptionBlockData(contraptionEntity, localPos, new BlockInfo(info.pos, newState, info.nbt)); + setContraptionBlockData(contraptionEntity, localPos, new StructureBlockInfo(info.pos, newState, info.nbt)); if (updateColliders()) contraption.invalidateColliders(); return true; @@ -35,11 +35,11 @@ public abstract class SimpleBlockMovingInteraction extends MovingInteractionBeha return false; } - protected void playSound(PlayerEntity player, SoundEvent sound, float pitch) { - player.level.playSound(player, player.blockPosition(), sound, SoundCategory.BLOCKS, 0.3f, pitch); + protected void playSound(Player player, SoundEvent sound, float pitch) { + player.level.playSound(player, player.blockPosition(), sound, SoundSource.BLOCKS, 0.3f, pitch); } - protected abstract BlockState handle(PlayerEntity player, Contraption contraption, BlockPos pos, + protected abstract BlockState handle(Player player, Contraption contraption, BlockPos pos, BlockState currentState); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/TrapdoorMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/TrapdoorMovingInteraction.java index 752c96974..3e0cd46e4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/TrapdoorMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/TrapdoorMovingInteraction.java @@ -2,17 +2,17 @@ package com.simibubi.create.content.contraptions.components.structureMovement.in import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; -import net.minecraft.block.BlockState; -import net.minecraft.block.TrapDoorBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; public class TrapdoorMovingInteraction extends SimpleBlockMovingInteraction { @Override - protected BlockState handle(PlayerEntity player, Contraption contraption, BlockPos pos, BlockState currentState) { + protected BlockState handle(Player player, Contraption contraption, BlockPos pos, BlockState currentState) { SoundEvent sound = currentState.getValue(TrapDoorBlock.OPEN) ? SoundEvents.WOODEN_TRAPDOOR_CLOSE : SoundEvents.WOODEN_TRAPDOOR_OPEN; float pitch = player.level.random.nextFloat() * 0.1F + 0.9F; 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 20dd43e65..b08792092 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 @@ -6,13 +6,13 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.utility.Lang; import com.tterrag.registrate.util.entry.BlockEntry; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.Item; -import net.minecraft.util.IStringSerializable; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.Item; +import net.minecraft.util.StringRepresentable; -public enum CartAssembleRailType implements IStringSerializable { +public enum CartAssembleRailType implements StringRepresentable { REGULAR(Blocks.RAIL), POWERED_RAIL(Blocks.POWERED_RAIL), 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 230c858a2..13ce664c3 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 @@ -16,48 +16,50 @@ import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.item.minecart.ChestMinecartEntity; -import net.minecraft.entity.item.minecart.FurnaceMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.loot.LootContext; -import net.minecraft.loot.LootParameters; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.Property; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.RailShape; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.MinecartChest; +import net.minecraft.world.entity.vehicle.MinecartFurnace; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; -public class CartAssemblerBlock extends AbstractRailBlock +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class CartAssemblerBlock extends BaseRailBlock implements ITE, IWrenchable, ISpecialBlockItemRequirement { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; @@ -86,7 +88,7 @@ public class CartAssemblerBlock extends AbstractRailBlock } public static BlockState getRailBlock(BlockState state) { - AbstractRailBlock railBlock = (AbstractRailBlock) state.getValue(RAIL_TYPE) + BaseRailBlock railBlock = (BaseRailBlock) state.getValue(RAIL_TYPE) .getBlock(); BlockState railState = railBlock.defaultBlockState() .setValue(railBlock.getShapeProperty(), state.getValue(RAIL_SHAPE)); @@ -107,18 +109,18 @@ public class CartAssemblerBlock extends AbstractRailBlock } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.CART_ASSEMBLER.create(); } @Override - public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos) { + public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull BlockGetter world, @Nonnull BlockPos pos) { return false; } @Override - public void onMinecartPass(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, - AbstractMinecartEntity cart) { + public void onMinecartPass(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, + AbstractMinecart cart) { if (!canAssembleTo(cart)) return; if (world.isClientSide) @@ -139,7 +141,7 @@ public class CartAssemblerBlock extends AbstractRailBlock } } - public static CartAssemblerAction getActionForCart(BlockState state, AbstractMinecartEntity cart) { + public static CartAssemblerAction getActionForCart(BlockState state, AbstractMinecart cart) { CartAssembleRailType type = state.getValue(RAIL_TYPE); boolean powered = state.getValue(POWERED); switch (type) { @@ -160,14 +162,14 @@ public class CartAssemblerBlock extends AbstractRailBlock } } - public static boolean canAssembleTo(AbstractMinecartEntity cart) { - return cart.canBeRidden() || cart instanceof FurnaceMinecartEntity || cart instanceof ChestMinecartEntity; + public static boolean canAssembleTo(AbstractMinecart cart) { + return cart.canBeRidden() || cart instanceof MinecartFurnace || cart instanceof MinecartChest; } @Override @Nonnull - public ActionResultType use(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, - PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult blockRayTraceResult) { + public InteractionResult use(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, + Player player, @Nonnull InteractionHand hand, @Nonnull BlockHitResult blockRayTraceResult) { ItemStack itemStack = player.getItemInHand(hand); Item previousItem = getRailItem(state); @@ -179,22 +181,22 @@ public class CartAssemblerBlock extends AbstractRailBlock if (heldItem == type.getItem()) newType = type; if (newType == null) - return ActionResultType.PASS; - world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, 1, 1); + return InteractionResult.PASS; + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, 1, 1); world.setBlockAndUpdate(pos, state.setValue(RAIL_TYPE, newType)); if (!player.isCreative()) { itemStack.shrink(1); player.inventory.placeItemBackInInventory(world, new ItemStack(previousItem)); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public void neighborChanged(@Nonnull BlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos, + public void neighborChanged(@Nonnull BlockState state, @Nonnull Level worldIn, @Nonnull BlockPos pos, @Nonnull Block blockIn, @Nonnull BlockPos fromPos, boolean isMoving) { if (worldIn.isClientSide) return; @@ -212,8 +214,8 @@ public class CartAssemblerBlock extends AbstractRailBlock @Override @Nonnull - public VoxelShape getShape(BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos, - @Nonnull ISelectionContext context) { + public VoxelShape getShape(BlockState state, @Nonnull BlockGetter worldIn, @Nonnull BlockPos pos, + @Nonnull CollisionContext context) { return AllShapes.CART_ASSEMBLER.get(getRailAxis(state)); } @@ -223,14 +225,14 @@ public class CartAssemblerBlock extends AbstractRailBlock @Override @Nonnull - public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos, - ISelectionContext context) { + public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull BlockGetter worldIn, @Nonnull BlockPos pos, + CollisionContext context) { Entity entity = context.getEntity(); - if (entity instanceof AbstractMinecartEntity) - return VoxelShapes.empty(); - if (entity instanceof PlayerEntity) + if (entity instanceof AbstractMinecart) + return Shapes.empty(); + if (entity instanceof Player) return AllShapes.CART_ASSEMBLER_PLAYER_COLLISION.get(getRailAxis(state)); - return VoxelShapes.block(); + return Shapes.block(); } @Override @@ -245,12 +247,12 @@ public class CartAssemblerBlock extends AbstractRailBlock } @Override - public boolean canSurvive(@Nonnull BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos) { + public boolean canSurvive(@Nonnull BlockState state, @Nonnull LevelReader world, @Nonnull BlockPos pos) { return false; } @Override - public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) { ArrayList reuiredItems = new ArrayList<>(); reuiredItems.add(new ItemStack(getRailItem(state))); reuiredItems.add(new ItemStack(asItem())); @@ -261,36 +263,36 @@ public class CartAssemblerBlock extends AbstractRailBlock @SuppressWarnings("deprecation") @Nonnull public List getDrops(@Nonnull BlockState state, - @Nonnull net.minecraft.loot.LootContext.Builder builder) { + @Nonnull net.minecraft.world.level.storage.loot.LootContext.Builder builder) { List drops = super.getDrops(state, builder); drops.addAll(getRailBlock(state).getDrops(builder)); return drops; } @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_) { + public List getDropsNoRail(BlockState state, ServerLevel world, BlockPos pos, + @Nullable BlockEntity p_220077_3_, @Nullable Entity p_220077_4_, ItemStack p_220077_5_) { return super.getDrops(state, (new LootContext.Builder(world)).withRandom(world.random) - .withParameter(LootParameters.ORIGIN, Vector3d.atLowerCornerOf(pos)) - .withParameter(LootParameters.TOOL, p_220077_5_) - .withOptionalParameter(LootParameters.THIS_ENTITY, p_220077_4_) - .withOptionalParameter(LootParameters.BLOCK_ENTITY, p_220077_3_)); + .withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(pos)) + .withParameter(LootContextParams.TOOL, p_220077_5_) + .withOptionalParameter(LootContextParams.THIS_ENTITY, p_220077_4_) + .withOptionalParameter(LootContextParams.BLOCK_ENTITY, p_220077_3_)); } @Override - public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) { - World world = context.getLevel(); + public InteractionResult onSneakWrenched(BlockState state, UseOnContext context) { + Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); - PlayerEntity player = context.getPlayer(); + Player player = context.getPlayer(); if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; if (player != null && !player.isCreative()) - getDropsNoRail(state, (ServerWorld) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) + getDropsNoRail(state, (ServerLevel) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) .forEach(itemStack -> player.inventory.placeItemBackInInventory(world, itemStack)); - if (world instanceof ServerWorld) - state.spawnAfterBreak((ServerWorld) world, pos, ItemStack.EMPTY); + if (world instanceof ServerLevel) + state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY); world.setBlockAndUpdate(pos, getRailBlock(state)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } public static class MinecartAnchorBlock extends Block { @@ -307,26 +309,26 @@ public class CartAssemblerBlock extends AbstractRailBlock @Override @Nonnull - public VoxelShape getShape(@Nonnull BlockState p_220053_1_, @Nonnull IBlockReader p_220053_2_, - @Nonnull BlockPos p_220053_3_, @Nonnull ISelectionContext p_220053_4_) { - return VoxelShapes.empty(); + public VoxelShape getShape(@Nonnull BlockState p_220053_1_, @Nonnull BlockGetter p_220053_2_, + @Nonnull BlockPos p_220053_3_, @Nonnull CollisionContext p_220053_4_) { + return Shapes.empty(); } } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getLevel(); + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + Level world = context.getLevel(); if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; BlockPos pos = context.getClickedPos(); world.setBlock(pos, rotate(state, Rotation.CLOCKWISE_90), 3); world.updateNeighborsAt(pos.below(), this); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override 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 e8678801f..64d735c8d 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 @@ -6,20 +6,22 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.tracks.ControllerRailBlock; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.properties.RailShape; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; + +import net.minecraft.world.item.Item.Properties; public class CartAssemblerBlockItem extends BlockItem { @@ -29,30 +31,30 @@ public class CartAssemblerBlockItem extends BlockItem { @Override @Nonnull - public ActionResultType useOn(ItemUseContext context) { + public InteractionResult useOn(UseOnContext context) { if (tryPlaceAssembler(context)) { context.getLevel() - .playSound(null, context.getClickedPos(), SoundEvents.STONE_PLACE, SoundCategory.BLOCKS, 1, 1); - return ActionResultType.SUCCESS; + .playSound(null, context.getClickedPos(), SoundEvents.STONE_PLACE, SoundSource.BLOCKS, 1, 1); + return InteractionResult.SUCCESS; } return super.useOn(context); } - public boolean tryPlaceAssembler(ItemUseContext context) { + public boolean tryPlaceAssembler(UseOnContext context) { BlockPos pos = context.getClickedPos(); - World world = context.getLevel(); + Level world = context.getLevel(); BlockState state = world.getBlockState(pos); Block block = state.getBlock(); - PlayerEntity player = context.getPlayer(); + Player player = context.getPlayer(); if (player == null) return false; - if (!(block instanceof AbstractRailBlock)) { + if (!(block instanceof BaseRailBlock)) { Lang.sendStatus(player, "block.cart_assembler.invalid"); return false; } - RailShape shape = state.getValue(((AbstractRailBlock) block).getShapeProperty()); + RailShape shape = state.getValue(((BaseRailBlock) block).getShapeProperty()); if (shape != RailShape.EAST_WEST && shape != RailShape.NORTH_SOUTH) return false; 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 80393ed1e..5e949e87e 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 @@ -23,20 +23,20 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.item.minecart.FurnaceMinecartEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.state.properties.RailShape; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.MinecartFurnace; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -47,9 +47,9 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay protected ScrollOptionBehaviour movementMode; private int ticksSinceMinecartUpdate; protected AssemblyException lastException; - protected AbstractMinecartEntity cartToAssemble; + protected AbstractMinecart cartToAssemble; - public CartAssemblerTileEntity(TileEntityType type) { + public CartAssemblerTileEntity(BlockEntityType type) { super(type); ticksSinceMinecartUpdate = assemblyCooldown; } @@ -65,7 +65,7 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay cartToAssemble = null; } - public void tryAssemble(AbstractMinecartEntity cart) { + public void tryAssemble(AbstractMinecart cart) { if (cart == null) return; @@ -98,22 +98,22 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay } } if (action == CartAssemblerBlock.CartAssemblerAction.ASSEMBLE_ACCELERATE_DIRECTIONAL) { - Vector3i accelerationVector = + Vec3i accelerationVector = ControllerRailBlock.getAccelerationVector(AllBlocks.CONTROLLER_RAIL.getDefaultState() .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) + cart.setDeltaMovement(Vec3.atLowerCornerOf(accelerationVector) .scale(speed)); } if (action == CartAssemblerBlock.CartAssemblerAction.DISASSEMBLE_BRAKE) { - Vector3d diff = VecHelper.getCenterOf(worldPosition) + Vec3 diff = VecHelper.getCenterOf(worldPosition) .subtract(cart.position()); cart.setDeltaMovement(diff.x / 16f, 0, diff.z / 16f); } } - protected void assemble(World world, BlockPos pos, AbstractMinecartEntity cart) { + protected void assemble(Level world, BlockPos pos, AbstractMinecart cart) { if (!cart.getPassengers() .isEmpty()) return; @@ -154,9 +154,9 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay contraption.expandBoundsAroundAxis(Axis.Y); if (couplingFound) { - Vector3d diff = contraption.connectedCart.position() + Vec3 diff = contraption.connectedCart.position() .subtract(cart.position()); - initialOrientation = Direction.fromYRot(MathHelper.atan2(diff.z, diff.x) * 180 / Math.PI); + initialOrientation = Direction.fromYRot(Mth.atan2(diff.z, diff.x) * 180 / Math.PI); } OrientedContraptionEntity entity = OrientedContraptionEntity.create(world, contraption, initialOrientation); @@ -166,15 +166,15 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay world.addFreshEntity(entity); entity.startRiding(cart); - if (cart instanceof FurnaceMinecartEntity) { - CompoundNBT nbt = cart.serializeNBT(); + if (cart instanceof MinecartFurnace) { + CompoundTag nbt = cart.serializeNBT(); nbt.putDouble("PushZ", 0); nbt.putDouble("PushX", 0); cart.deserializeNBT(nbt); } } - protected void disassemble(World world, BlockPos pos, AbstractMinecartEntity cart) { + protected void disassemble(Level world, BlockPos pos, AbstractMinecart cart) { if (cart.getPassengers() .isEmpty()) return; @@ -217,10 +217,10 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay disassembleCart(cart); } - protected void disassembleCart(AbstractMinecartEntity cart) { + protected void disassembleCart(AbstractMinecart cart) { cart.ejectPassengers(); - if (cart instanceof FurnaceMinecartEntity) { - CompoundNBT nbt = cart.serializeNBT(); + if (cart instanceof MinecartFurnace) { + CompoundTag nbt = cart.serializeNBT(); nbt.putDouble("PushZ", cart.getDeltaMovement().x); nbt.putDouble("PushX", cart.getDeltaMovement().z); cart.deserializeNBT(nbt); @@ -236,13 +236,13 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { AssemblyException.write(compound, lastException); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { lastException = AssemblyException.read(compound); super.fromTag(state, compound, clientPacket); } @@ -271,7 +271,7 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay } @Override - protected Vector3d getSouthLocation() { + protected Vec3 getSouthLocation() { return VecHelper.voxelSpace(8, 8, 18); } @@ -308,7 +308,7 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay ticksSinceMinecartUpdate = 0; } - public void assembleNextTick(AbstractMinecartEntity cart) { + public void assembleNextTick(AbstractMinecart cart) { if (cartToAssemble == null) cartToAssemble = cart; } 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 669bff17e..1c8ff0e0f 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 @@ -4,8 +4,8 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; @@ -13,9 +13,9 @@ import net.minecraftforge.items.ItemHandlerHelper; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class ItemHandlerModifiableFromIInventory implements IItemHandlerModifiable { - private final IInventory inventory; + private final Container inventory; - public ItemHandlerModifiableFromIInventory(IInventory inventory) { + public ItemHandlerModifiableFromIInventory(Container inventory) { this.inventory = inventory; } 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 0650302bf..ae9ff6499 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 @@ -15,39 +15,41 @@ import com.simibubi.create.foundation.config.ContraptionMovementSetting; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.DispenserBlock; -import net.minecraft.block.material.Material; -import net.minecraft.dispenser.DefaultDispenseItemBehavior; -import net.minecraft.dispenser.IBlockSource; -import net.minecraft.dispenser.IDispenseItemBehavior; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity.Type; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.state.properties.RailShape; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.DispenserBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; +import net.minecraft.core.BlockSource; +import net.minecraft.core.dispenser.DispenseItemBehavior; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.AbstractMinecart.Type; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtIo; +import net.minecraft.world.level.block.state.properties.RailShape; import net.minecraft.tags.BlockTags; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.NonNullList; +import net.minecraft.core.BlockPos; +import net.minecraft.ChatFormatting; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.world.item.Item.Properties; + @EventBusSubscriber public class MinecartContraptionItem extends Item { - private final AbstractMinecartEntity.Type minecartType; + private final AbstractMinecart.Type minecartType; public static MinecartContraptionItem rideable(Properties builder) { return new MinecartContraptionItem(Type.RIDEABLE, builder); @@ -68,22 +70,22 @@ public class MinecartContraptionItem extends Item { } // Taken and adjusted from MinecartItem - private static final IDispenseItemBehavior DISPENSER_BEHAVIOR = new DefaultDispenseItemBehavior() { + private static final DispenseItemBehavior DISPENSER_BEHAVIOR = new DefaultDispenseItemBehavior() { private final DefaultDispenseItemBehavior behaviourDefaultDispenseItem = new DefaultDispenseItemBehavior(); @Override - public ItemStack execute(IBlockSource source, ItemStack stack) { + public ItemStack execute(BlockSource source, ItemStack stack) { Direction direction = source.getBlockState() .getValue(DispenserBlock.FACING); - World world = source.getLevel(); + Level 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 railshape = blockstate.getBlock() instanceof BaseRailBlock + ? ((BaseRailBlock) blockstate.getBlock()).getRailDirection(blockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; double d3; if (blockstate.is(BlockTags.RAILS)) { @@ -99,8 +101,8 @@ public class MinecartContraptionItem extends Item { } BlockState blockstate1 = world.getBlockState(blockpos.below()); - RailShape railshape1 = blockstate1.getBlock() instanceof AbstractRailBlock - ? ((AbstractRailBlock) blockstate1.getBlock()).getRailDirection(blockstate1, world, blockpos.below(), + RailShape railshape1 = blockstate1.getBlock() instanceof BaseRailBlock + ? ((BaseRailBlock) blockstate1.getBlock()).getRailDirection(blockstate1, world, blockpos.below(), null) : RailShape.NORTH_SOUTH; if (direction != Direction.DOWN && railshape1.isAscending()) { @@ -110,7 +112,7 @@ public class MinecartContraptionItem extends Item { } } - AbstractMinecartEntity abstractminecartentity = AbstractMinecartEntity.createMinecart(world, d0, d1 + d3, d2, + AbstractMinecart abstractminecartentity = AbstractMinecart.createMinecart(world, d0, d1 + d3, d2, ((MinecartContraptionItem) stack.getItem()).minecartType); if (stack.hasCustomHoverName()) abstractminecartentity.setCustomName(stack.getHoverName()); @@ -122,7 +124,7 @@ public class MinecartContraptionItem extends Item { } @Override - protected void playSound(IBlockSource source) { + protected void playSound(BlockSource source) { source.getLevel() .levelEvent(1000, source.getPos(), 0); } @@ -130,44 +132,44 @@ public class MinecartContraptionItem extends Item { // Taken and adjusted from MinecartItem @Override - public ActionResultType useOn(ItemUseContext context) { - World world = context.getLevel(); + public InteractionResult useOn(UseOnContext context) { + Level world = context.getLevel(); BlockPos blockpos = context.getClickedPos(); BlockState blockstate = world.getBlockState(blockpos); if (!blockstate.is(BlockTags.RAILS)) { - return ActionResultType.FAIL; + return InteractionResult.FAIL; } else { ItemStack itemstack = context.getItemInHand(); if (!world.isClientSide) { - RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock - ? ((AbstractRailBlock) blockstate.getBlock()).getRailDirection(blockstate, world, blockpos, null) + RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock + ? ((BaseRailBlock) blockstate.getBlock()).getRailDirection(blockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; double d0 = 0.0D; if (railshape.isAscending()) { d0 = 0.5D; } - AbstractMinecartEntity abstractminecartentity = - AbstractMinecartEntity.createMinecart(world, (double) blockpos.getX() + 0.5D, + AbstractMinecart abstractminecartentity = + AbstractMinecart.createMinecart(world, (double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 0.0625D + d0, (double) blockpos.getZ() + 0.5D, this.minecartType); if (itemstack.hasCustomHoverName()) abstractminecartentity.setCustomName(itemstack.getHoverName()); - PlayerEntity player = context.getPlayer(); + Player player = context.getPlayer(); world.addFreshEntity(abstractminecartentity); addContraptionToMinecart(world, itemstack, abstractminecartentity, player == null ? null : player.getDirection()); } itemstack.shrink(1); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } } - public static void addContraptionToMinecart(World world, ItemStack itemstack, AbstractMinecartEntity cart, + public static void addContraptionToMinecart(Level world, ItemStack itemstack, AbstractMinecart cart, @Nullable Direction newFacing) { - CompoundNBT tag = itemstack.getOrCreateTag(); + CompoundTag tag = itemstack.getOrCreateTag(); if (tag.contains("Contraption")) { - CompoundNBT contraptionTag = tag.getCompound("Contraption"); + CompoundTag contraptionTag = tag.getCompound("Contraption"); Direction intialOrientation = NBTHelper.readEnum(contraptionTag, "InitialOrientation", Direction.class); @@ -189,12 +191,12 @@ public class MinecartContraptionItem extends Item { } @Override - public void fillItemCategory(ItemGroup group, NonNullList items) {} + public void fillItemCategory(CreativeModeTab group, NonNullList items) {} @SubscribeEvent public static void wrenchCanBeUsedToPickUpMinecartContraptions(PlayerInteractEvent.EntityInteract event) { Entity entity = event.getTarget(); - PlayerEntity player = event.getPlayer(); + Player player = event.getPlayer(); if (player == null || entity == null) return; @@ -203,11 +205,11 @@ public class MinecartContraptionItem extends Item { return; if (entity instanceof AbstractContraptionEntity) entity = entity.getVehicle(); - if (!(entity instanceof AbstractMinecartEntity)) + if (!(entity instanceof AbstractMinecart)) return; if (!entity.isAlive()) return; - AbstractMinecartEntity cart = (AbstractMinecartEntity) entity; + AbstractMinecart cart = (AbstractMinecart) entity; Type type = cart.getMinecartType(); if (type != Type.RIDEABLE && type != Type.FURNACE && type != Type.CHEST) return; @@ -218,12 +220,12 @@ public class MinecartContraptionItem extends Item { if(ContraptionMovementSetting.isNoPickup(contraption.getContraption().getBlocks().values())) { player.displayClientMessage(Lang.translate("contraption.minecart_contraption_illegal_pickup") - .withStyle(TextFormatting.RED), true); + .withStyle(ChatFormatting.RED), true); return; } if (event.getWorld().isClientSide) { - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); event.setCanceled(true); return; } @@ -232,11 +234,11 @@ public class MinecartContraptionItem extends Item { try { ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(); - CompressedStreamTools.write(generatedStack.serializeNBT(), dataOutput); + NbtIo.write(generatedStack.serializeNBT(), dataOutput); int estimatedPacketSize = dataOutput.toByteArray().length; if (estimatedPacketSize > 2_000_000) { player.displayClientMessage(Lang.translate("contraption.minecart_contraption_too_big") - .withStyle(TextFormatting.RED), true); + .withStyle(ChatFormatting.RED), true); return; } @@ -248,7 +250,7 @@ public class MinecartContraptionItem extends Item { player.inventory.placeItemBackInInventory(event.getWorld(), generatedStack); contraption.remove(); entity.remove(); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); event.setCanceled(true); } @@ -272,7 +274,7 @@ public class MinecartContraptionItem extends Item { if (stack.isEmpty()) return stack; - CompoundNBT tag = entity.getContraption() + CompoundTag tag = entity.getContraption() .writeNBT(false); tag.remove("UUID"); tag.remove("Pos"); 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 faec44b37..61b9e3690 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 @@ -17,28 +17,30 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.inventory.IInventory; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.RailShape; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.Container; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; 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; - public AbstractMinecartEntity connectedCart; + public AbstractMinecart connectedCart; public MountedContraption() { this(CartMovementMode.ROTATE); @@ -54,7 +56,7 @@ public class MountedContraption extends Contraption { } @Override - public boolean assemble(World world, BlockPos pos) throws AssemblyException { + public boolean assemble(Level world, BlockPos pos) throws AssemblyException { BlockState state = world.getBlockState(pos); if (!state.hasProperty(RAIL_SHAPE)) return false; @@ -62,7 +64,7 @@ public class MountedContraption extends Contraption { return false; Axis axis = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.X : Axis.Z; - addBlock(pos, Pair.of(new BlockInfo(pos, AllBlocks.MINECART_ANCHOR.getDefaultState() + addBlock(pos, Pair.of(new StructureBlockInfo(pos, AllBlocks.MINECART_ANCHOR.getDefaultState() .setValue(BlockStateProperties.HORIZONTAL_AXIS, axis), null), null)); if (blocks.size() == 1) @@ -72,29 +74,29 @@ public class MountedContraption extends Contraption { } @Override - protected boolean addToInitialFrontier(World world, BlockPos pos, Direction direction, Queue frontier) { + protected boolean addToInitialFrontier(Level world, BlockPos pos, Direction direction, Queue frontier) { frontier.clear(); frontier.add(pos.above()); return true; } @Override - protected Pair capture(World world, BlockPos pos) { - Pair pair = super.capture(world, pos); - BlockInfo capture = pair.getKey(); + protected Pair capture(Level world, BlockPos pos) { + Pair pair = super.capture(world, pos); + StructureBlockInfo capture = pair.getKey(); if (!AllBlocks.CART_ASSEMBLER.has(capture.state)) return pair; - Pair anchorSwap = - Pair.of(new BlockInfo(pos, CartAssemblerBlock.createAnchor(capture.state), null), pair.getValue()); + Pair anchorSwap = + Pair.of(new StructureBlockInfo(pos, CartAssemblerBlock.createAnchor(capture.state), null), pair.getValue()); if (pos.equals(anchor) || connectedCart != null) return anchorSwap; for (Axis axis : Iterate.axes) { if (axis.isVertical() || !VecHelper.onSameAxis(anchor, pos, axis)) continue; - for (AbstractMinecartEntity abstractMinecartEntity : world - .getEntitiesOfClass(AbstractMinecartEntity.class, new AxisAlignedBB(pos))) { + for (AbstractMinecart abstractMinecartEntity : world + .getEntitiesOfClass(AbstractMinecart.class, new AABB(pos))) { if (!CartAssemblerBlock.canAssembleTo(abstractMinecartEntity)) break; connectedCart = abstractMinecartEntity; @@ -106,18 +108,18 @@ public class MountedContraption extends Contraption { } @Override - protected boolean movementAllowed(BlockState state, World world, BlockPos pos) { + protected boolean movementAllowed(BlockState state, Level world, BlockPos pos) { if (!pos.equals(anchor) && AllBlocks.CART_ASSEMBLER.has(state)) return testSecondaryCartAssembler(world, state, pos); return super.movementAllowed(state, world, pos); } - protected boolean testSecondaryCartAssembler(World world, BlockState state, BlockPos pos) { + protected boolean testSecondaryCartAssembler(Level world, BlockState state, BlockPos pos) { for (Axis axis : Iterate.axes) { if (axis.isVertical() || !VecHelper.onSameAxis(anchor, pos, axis)) continue; - for (AbstractMinecartEntity abstractMinecartEntity : world - .getEntitiesOfClass(AbstractMinecartEntity.class, new AxisAlignedBB(pos))) { + for (AbstractMinecart abstractMinecartEntity : world + .getEntitiesOfClass(AbstractMinecart.class, new AABB(pos))) { if (!CartAssemblerBlock.canAssembleTo(abstractMinecartEntity)) break; return true; @@ -127,25 +129,25 @@ public class MountedContraption extends Contraption { } @Override - public CompoundNBT writeNBT(boolean spawnPacket) { - CompoundNBT tag = super.writeNBT(spawnPacket); + public CompoundTag writeNBT(boolean spawnPacket) { + CompoundTag tag = super.writeNBT(spawnPacket); NBTHelper.writeEnum(tag, "RotationMode", rotationMode); return tag; } @Override - public void readNBT(World world, CompoundNBT nbt, boolean spawnData) { + public void readNBT(Level world, CompoundTag nbt, boolean spawnData) { rotationMode = NBTHelper.readEnum(nbt, "RotationMode", CartMovementMode.class); super.readNBT(world, nbt, spawnData); } @Override - protected boolean customBlockPlacement(IWorld world, BlockPos pos, BlockState state) { + protected boolean customBlockPlacement(LevelAccessor world, BlockPos pos, BlockState state) { return AllBlocks.MINECART_ANCHOR.has(state); } @Override - protected boolean customBlockRemoval(IWorld world, BlockPos pos, BlockState state) { + protected boolean customBlockRemoval(LevelAccessor world, BlockPos pos, BlockState state) { return AllBlocks.MINECART_ANCHOR.has(state); } @@ -156,9 +158,9 @@ public class MountedContraption extends Contraption { @Override public void addExtraInventories(Entity cart) { - if (!(cart instanceof IInventory)) + if (!(cart instanceof Container)) return; - IItemHandlerModifiable handlerFromInv = new ContraptionInvWrapper(true, new InvWrapper((IInventory) cart)); + IItemHandlerModifiable handlerFromInv = new ContraptionInvWrapper(true, new InvWrapper((Container) cart)); inventory = new ContraptionInvWrapper(handlerFromInv, inventory); } 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 a4f3b1671..b6a667261 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 @@ -14,12 +14,14 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOpt import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.ServerSpeedProvider; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; + +import com.simibubi.create.content.contraptions.components.structureMovement.IControlContraption.MovementMode; public abstract class LinearActuatorTileEntity extends KineticTileEntity implements IControlContraption, IDisplayAssemblyExceptions { @@ -36,7 +38,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity // Custom position sync protected float clientOffsetDiff; - public LinearActuatorTileEntity(TileEntityType typeIn) { + public LinearActuatorTileEntity(BlockEntityType typeIn) { super(typeIn); setLazyTickRate(3); forceMove = true; @@ -71,7 +73,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity movedContraption.setContraptionMotion(toMotionVector(syncSpeed)); return; } - movedContraption.setContraptionMotion(Vector3d.ZERO); + movedContraption.setContraptionMotion(Vec3.ZERO); return; } @@ -135,12 +137,12 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity } protected int getGridOffset(float offset) { - return MathHelper.clamp((int) (offset + .5f), 0, getExtensionRange()); + return Mth.clamp((int) (offset + .5f), 0, getExtensionRange()); } public float getInterpolatedOffset(float partialTicks) { float interpolatedOffset = - MathHelper.clamp(offset + (partialTicks - .5f) * getMovementSpeed(), 0, getExtensionRange()); + Mth.clamp(offset + (partialTicks - .5f) * getMovementSpeed(), 0, getExtensionRange()); return interpolatedOffset; } @@ -165,7 +167,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("Running", running); compound.putBoolean("Waiting", waitingForSpeedChange); compound.putFloat("Offset", offset); @@ -179,7 +181,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { boolean forceMovement = compound.contains("ForceMovement"); float offsetBefore = offset; @@ -216,9 +218,9 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity protected abstract ValueBoxTransform getMovementModeSlot(); - protected abstract Vector3d toMotionVector(float speed); + protected abstract Vec3 toMotionVector(float speed); - protected abstract Vector3d toPosition(float offset); + protected abstract Vec3 toPosition(float offset); protected void visitNewPosition() {} @@ -254,7 +256,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity if (movedContraption == null) return; if (movedContraption.isStalled()) { - movedContraption.setContraptionMotion(Vector3d.ZERO); + movedContraption.setContraptionMotion(Vec3.ZERO); return; } movedContraption.setContraptionMotion(getMotionVector()); @@ -263,20 +265,20 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity protected void applyContraptionPosition() { if (movedContraption == null) return; - Vector3d vec = toPosition(offset); + Vec3 vec = toPosition(offset); movedContraption.setPos(vec.x, vec.y, vec.z); if (getSpeed() == 0 || waitingForSpeedChange) - movedContraption.setContraptionMotion(Vector3d.ZERO); + movedContraption.setContraptionMotion(Vec3.ZERO); } public float getMovementSpeed() { - float movementSpeed = MathHelper.clamp(convertToLinear(getSpeed()), -.49f, .49f) + clientOffsetDiff / 2f; + float movementSpeed = Mth.clamp(convertToLinear(getSpeed()), -.49f, .49f) + clientOffsetDiff / 2f; if (level.isClientSide) movementSpeed *= ServerSpeedProvider.get(); return movementSpeed; } - public Vector3d getMotionVector() { + public Vec3 getMotionVector() { return toMotionVector(getMovementSpeed()); } 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 b936f8814..917ee8896 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 @@ -11,30 +11,32 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemUseContext; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.util.StringRepresentable; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.Tags; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implements ITE { public static final EnumProperty STATE = EnumProperty.create("state", PistonState.class); @@ -62,33 +64,33 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement } @Override - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { if (!player.mayBuild()) - return ActionResultType.PASS; + return InteractionResult.PASS; if (player.isShiftKeyDown()) - return ActionResultType.PASS; + return InteractionResult.PASS; if (!player.getItemInHand(handIn) .getItem() .is(Tags.Items.SLIMEBALLS)) { if (player.getItemInHand(handIn) .isEmpty()) { withTileEntityDo(worldIn, pos, te -> te.assembleNextTick = true); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } if (state.getValue(STATE) != PistonState.RETRACTED) - return ActionResultType.PASS; + return InteractionResult.PASS; Direction direction = state.getValue(FACING); if (hit.getDirection() != direction) - return ActionResultType.PASS; + return InteractionResult.PASS; if (((MechanicalPistonBlock) state.getBlock()).isSticky) - return ActionResultType.PASS; + return InteractionResult.PASS; if (worldIn.isClientSide) { - Vector3d vec = hit.getLocation(); + Vec3 vec = hit.getLocation(); worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } AllSoundEvents.SLIME_ADDED.playOnServer(worldIn, pos, .5f, 1); if (!player.isCreative()) @@ -97,11 +99,11 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement 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; + return InteractionResult.SUCCESS; } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, BlockPos fromPos, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos fromPos, boolean p_220069_6_) { Direction direction = state.getValue(FACING); if (!fromPos.equals(pos.relative(direction.getOpposite()))) @@ -113,7 +115,7 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel 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)) @@ -130,18 +132,18 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.MECHANICAL_PISTON.create(); } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onWrenched(BlockState state, UseOnContext context) { if (state.getValue(STATE) != PistonState.RETRACTED) - return ActionResultType.PASS; + return InteractionResult.PASS; return super.onWrenched(state, context); } - public enum PistonState implements IStringSerializable { + public enum PistonState implements StringRepresentable { RETRACTED, MOVING, EXTENDED; @Override @@ -151,7 +153,7 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement } @Override - public void playerWillDestroy(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { + public void playerWillDestroy(Level worldIn, BlockPos pos, BlockState state, Player player) { Direction direction = state.getValue(FACING); BlockPos pistonHead = null; BlockPos pistonBase = pos; @@ -200,7 +202,7 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { if (state.getValue(STATE) == PistonState.EXTENDED) return AllShapes.MECHANICAL_PISTON_EXTENDED.get(state.getValue(FACING)); @@ -208,7 +210,7 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement if (state.getValue(STATE) == PistonState.MOVING) return AllShapes.MECHANICAL_PISTON.get(state.getValue(FACING)); - return VoxelShapes.block(); + return Shapes.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 4b3363bcf..e6cdee48c 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 @@ -5,12 +5,12 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.PistonBlock; -import net.minecraft.state.properties.PistonType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.piston.PistonBaseBlock; +import net.minecraft.world.level.block.state.properties.PistonType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; import net.minecraftforge.client.model.generators.ModelFile; public class MechanicalPistonGenerator extends SpecialBlockStateGen { @@ -38,7 +38,7 @@ public class MechanicalPistonGenerator extends SpecialBlockStateGen { @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - Direction facing = state.getValue(PistonBlock.FACING); + Direction facing = state.getValue(PistonBaseBlock.FACING); boolean axisAlongFirst = state.getValue(MechanicalPistonBlock.AXIS_ALONG_FIRST_COORDINATE); PistonState pistonState = state.getValue(MechanicalPistonBlock.STATE); 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 09678c268..37589a580 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 @@ -7,30 +7,32 @@ import com.simibubi.create.AllShapes; import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.PistonType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.PistonType; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; -public class MechanicalPistonHeadBlock extends WrenchableDirectionalBlock implements IWaterLoggable { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class MechanicalPistonHeadBlock extends WrenchableDirectionalBlock implements SimpleWaterloggedBlock { public static final EnumProperty TYPE = BlockStateProperties.PISTON_TYPE; @@ -51,13 +53,13 @@ public class MechanicalPistonHeadBlock extends WrenchableDirectionalBlock implem } @Override - public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, - PlayerEntity player) { + public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, + Player player) { return AllBlocks.PISTON_EXTENSION_POLE.asStack(); } @Override - public void playerWillDestroy(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { + public void playerWillDestroy(Level worldIn, BlockPos pos, BlockState state, Player player) { Direction direction = state.getValue(FACING); BlockPos pistonHead = pos; BlockPos pistonBase = null; @@ -89,7 +91,7 @@ public class MechanicalPistonHeadBlock extends WrenchableDirectionalBlock implem } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.MECHANICAL_PISTON_HEAD.get(state.getValue(FACING)); } @@ -100,7 +102,7 @@ public class MechanicalPistonHeadBlock extends WrenchableDirectionalBlock implem @Override public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, - IWorld world, BlockPos pos, BlockPos neighbourPos) { + LevelAccessor world, BlockPos pos, BlockPos neighbourPos) { if (state.getValue(BlockStateProperties.WATERLOGGED)) { world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } @@ -108,13 +110,13 @@ public class MechanicalPistonHeadBlock extends WrenchableDirectionalBlock implem } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { FluidState FluidState = context.getLevel().getFluidState(context.getClickedPos()); return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER)); } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonRenderer.java index ae6114f31..1ca60d15f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonRenderer.java @@ -3,12 +3,12 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pi import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; public class MechanicalPistonRenderer extends KineticTileEntityRenderer { - public MechanicalPistonRenderer(TileEntityRendererDispatcher dispatcher) { + public MechanicalPistonRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } 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 5ca97b096..122ba6368 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 @@ -11,34 +11,34 @@ import com.simibubi.create.content.contraptions.components.structureMovement.pis import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.ServerSpeedProvider; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class MechanicalPistonTileEntity extends LinearActuatorTileEntity { protected boolean hadCollisionWithOtherPiston; protected int extensionLength; - public MechanicalPistonTileEntity(TileEntityType type) { + public MechanicalPistonTileEntity(BlockEntityType type) { super(type); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { extensionLength = compound.getInt("ExtensionLength"); super.fromTag(state, compound, clientPacket); } @Override - protected void write(CompoundNBT tag, boolean clientPacket) { + protected void write(CompoundTag tag, boolean clientPacket) { tag.putInt("ExtensionLength", extensionLength); super.write(tag, clientPacket); } @@ -118,7 +118,7 @@ public class MechanicalPistonTileEntity extends LinearActuatorTileEntity { @Override public float getMovementSpeed() { - float movementSpeed = MathHelper.clamp(convertToLinear(getSpeed()), -.49f, .49f); + float movementSpeed = Mth.clamp(convertToLinear(getSpeed()), -.49f, .49f); if (level.isClientSide) movementSpeed *= ServerSpeedProvider.get(); Direction pistonDirection = getBlockState().getValue(BlockStateProperties.FACING); @@ -127,7 +127,7 @@ public class MechanicalPistonTileEntity extends LinearActuatorTileEntity { movementSpeed = movementSpeed * -movementModifier + clientOffsetDiff / 2f; int extensionRange = getExtensionRange(); - movementSpeed = MathHelper.clamp(movementSpeed, 0 - offset, extensionRange - offset); + movementSpeed = Mth.clamp(movementSpeed, 0 - offset, extensionRange - offset); return movementSpeed; } @@ -140,18 +140,18 @@ public class MechanicalPistonTileEntity extends LinearActuatorTileEntity { protected void visitNewPosition() {} @Override - protected Vector3d toMotionVector(float speed) { + protected Vec3 toMotionVector(float speed) { Direction pistonDirection = getBlockState().getValue(BlockStateProperties.FACING); - return Vector3d.atLowerCornerOf(pistonDirection.getNormal()) + return Vec3.atLowerCornerOf(pistonDirection.getNormal()) .scale(speed); } @Override - protected Vector3d toPosition(float offset) { - Vector3d position = Vector3d.atLowerCornerOf(getBlockState().getValue(BlockStateProperties.FACING) + protected Vec3 toPosition(float offset) { + Vec3 position = Vec3.atLowerCornerOf(getBlockState().getValue(BlockStateProperties.FACING) .getNormal()) .scale(offset); - return position.add(Vector3d.atLowerCornerOf(movedContraption.getContraption().anchor)); + return position.add(Vec3.atLowerCornerOf(movedContraption.getContraption().anchor)); } @Override 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 5c79bd6fb..2f015d62d 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 @@ -8,9 +8,33 @@ import static com.simibubi.create.content.contraptions.components.structureMovem import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isStickyPiston; import static net.minecraft.state.properties.BlockStateProperties.FACING; +import javanet.minimport com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; +import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; +import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; +import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType; +import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption; +import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.utility.VecHelper; import java.util.ArrayList; import java.util.List; import java.util.Queue; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.WoolCarpetBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.PistonType; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.phys.AABB; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import org.apache.commons.lang3.tuple.Pair; + +ecraft.world.level.block.state.properties.BlockStatePropertiesva.util.Queue; import org.apache.commons.lang3.tuple.Pair; @@ -45,7 +69,7 @@ public class PistonContraption extends TranslatingContraption { protected int initialExtensionProgress; protected Direction orientation; - private AxisAlignedBB pistonExtensionCollisionBox; + private AABB pistonExtensionCollisionBox; private boolean retract; @Override @@ -61,7 +85,7 @@ public class PistonContraption extends TranslatingContraption { } @Override - public boolean assemble(World world, BlockPos pos) throws AssemblyException { + public boolean assemble(Level world, BlockPos pos) throws AssemblyException { if (!collectExtensions(world, pos, orientation)) return false; int count = blocks.size(); @@ -76,8 +100,8 @@ public class PistonContraption extends TranslatingContraption { return true; } - private boolean collectExtensions(World world, BlockPos pos, Direction direction) throws AssemblyException { - List poles = new ArrayList<>(); + private boolean collectExtensions(Level world, BlockPos pos, Direction direction) throws AssemblyException { + List poles = new ArrayList<>(); BlockPos actualStart = pos; BlockState nextBlock = world.getBlockState(actualStart.relative(direction)); int extensionsInFront = 0; @@ -91,7 +115,7 @@ public class PistonContraption extends TranslatingContraption { while (PistonExtensionPoleBlock.PlacementHelper.get().matchesAxis(nextBlock, direction.getAxis()) || isPistonHead(nextBlock) && nextBlock.getValue(FACING) == direction) { actualStart = actualStart.relative(direction); - poles.add(new BlockInfo(actualStart, nextBlock.setValue(FACING, direction), null)); + poles.add(new StructureBlockInfo(actualStart, nextBlock.setValue(FACING, direction), null)); extensionsInFront++; if (isPistonHead(nextBlock)) @@ -104,11 +128,11 @@ public class PistonContraption extends TranslatingContraption { } if (extensionsInFront == 0) - poles.add(new BlockInfo(pos, MECHANICAL_PISTON_HEAD.getDefaultState() + poles.add(new StructureBlockInfo(pos, MECHANICAL_PISTON_HEAD.getDefaultState() .setValue(FACING, direction) .setValue(BlockStateProperties.PISTON_TYPE, sticky ? PistonType.STICKY : PistonType.DEFAULT), null)); else - poles.add(new BlockInfo(pos, PISTON_EXTENSION_POLE.getDefaultState() + poles.add(new StructureBlockInfo(pos, PISTON_EXTENSION_POLE.getDefaultState() .setValue(FACING, direction), null)); BlockPos end = pos; @@ -117,7 +141,7 @@ public class PistonContraption extends TranslatingContraption { while (PistonExtensionPoleBlock.PlacementHelper.get().matchesAxis(nextBlock, direction.getAxis())) { end = end.relative(direction.getOpposite()); - poles.add(new BlockInfo(end, nextBlock.setValue(FACING, direction), null)); + poles.add(new StructureBlockInfo(end, nextBlock.setValue(FACING, direction), null)); extensionsInBack++; nextBlock = world.getBlockState(end.relative(direction.getOpposite())); @@ -128,7 +152,7 @@ public class PistonContraption extends TranslatingContraption { anchor = pos.relative(direction, initialExtensionProgress + 1); extensionLength = extensionsInBack + extensionsInFront; initialExtensionProgress = extensionsInFront; - pistonExtensionCollisionBox = new AxisAlignedBB( + pistonExtensionCollisionBox = new AABB( BlockPos.ZERO.relative(direction, -1), BlockPos.ZERO.relative(direction, -extensionLength - 1)).expandTowards(1, 1, 1); @@ -136,12 +160,12 @@ public class PistonContraption extends TranslatingContraption { if (extensionLength == 0) throw AssemblyException.noPistonPoles(); - bounds = new AxisAlignedBB(0, 0, 0, 0, 0, 0); + bounds = new AABB(0, 0, 0, 0, 0, 0); - for (BlockInfo pole : poles) { + for (StructureBlockInfo pole : poles) { BlockPos relPos = pole.pos.relative(direction, -extensionsInFront); BlockPos localPos = relPos.subtract(anchor); - getBlocks().put(localPos, new BlockInfo(localPos, pole.state, null)); + getBlocks().put(localPos, new StructureBlockInfo(localPos, pole.state, null)); //pistonExtensionCollisionBox = pistonExtensionCollisionBox.union(new AxisAlignedBB(localPos)); } @@ -154,7 +178,7 @@ public class PistonContraption extends TranslatingContraption { } @Override - protected boolean addToInitialFrontier(World world, BlockPos pos, Direction direction, Queue frontier) throws AssemblyException { + protected boolean addToInitialFrontier(Level world, BlockPos pos, Direction direction, Queue frontier) throws AssemblyException { frontier.clear(); boolean sticky = isStickyPiston(world.getBlockState(pos.relative(orientation, -1))); boolean retracting = direction != orientation; @@ -164,14 +188,14 @@ public class PistonContraption extends TranslatingContraption { if (offset == 1 && retracting) return true; BlockPos currentPos = pos.relative(orientation, offset + initialExtensionProgress); - if (retracting && World.isOutsideBuildHeight(currentPos)) + if (retracting && Level.isOutsideBuildHeight(currentPos)) return true; 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)) + if (BlockMovementChecks.isBrittle(state) && !(state.getBlock() instanceof WoolCarpetBlock)) return true; if (isPistonHead(state) && state.getValue(FACING) == direction.getOpposite()) return true; @@ -190,7 +214,7 @@ public class PistonContraption extends TranslatingContraption { } @Override - public void addBlock(BlockPos pos, Pair capture) { + public void addBlock(BlockPos pos, Pair capture) { super.addBlock(pos.relative(orientation, -initialExtensionProgress), capture); } @@ -201,10 +225,10 @@ public class PistonContraption extends TranslatingContraption { } @Override - protected boolean customBlockPlacement(IWorld world, BlockPos pos, BlockState state) { + protected boolean customBlockPlacement(LevelAccessor world, BlockPos pos, BlockState state) { BlockPos pistonPos = anchor.relative(orientation, -1); BlockState pistonState = world.getBlockState(pistonPos); - TileEntity te = world.getBlockEntity(pistonPos); + BlockEntity te = world.getBlockEntity(pistonPos); if (pos.equals(pistonPos)) { if (te == null || te.isRemoved()) return true; @@ -217,7 +241,7 @@ public class PistonContraption extends TranslatingContraption { } @Override - protected boolean customBlockRemoval(IWorld world, BlockPos pos, BlockState state) { + protected boolean customBlockRemoval(LevelAccessor world, BlockPos pos, BlockState state) { BlockPos pistonPos = anchor.relative(orientation, -1); BlockState blockState = world.getBlockState(pos); if (pos.equals(pistonPos) && isPiston(blockState)) { @@ -228,7 +252,7 @@ public class PistonContraption extends TranslatingContraption { } @Override - public void readNBT(World world, CompoundNBT nbt, boolean spawnData) { + public void readNBT(Level world, CompoundTag nbt, boolean spawnData) { super.readNBT(world, nbt, spawnData); initialExtensionProgress = nbt.getInt("InitialLength"); extensionLength = nbt.getInt("ExtensionLength"); @@ -236,8 +260,8 @@ public class PistonContraption extends TranslatingContraption { } @Override - public CompoundNBT writeNBT(boolean spawnPacket) { - CompoundNBT tag = super.writeNBT(spawnPacket); + public CompoundTag writeNBT(boolean spawnPacket) { + CompoundTag tag = super.writeNBT(spawnPacket); tag.putInt("InitialLength", initialExtensionProgress); tag.putInt("ExtensionLength", extensionLength); tag.putInt("Orientation", orientation.get3DDataValue()); 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 c944cb4ec..1027b8a2b 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 @@ -16,35 +16,37 @@ import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.placement.util.PoleHelper; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ToolType; -public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock implements IWrenchable, IWaterLoggable { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock implements IWrenchable, SimpleWaterloggedBlock { private static final int placementHelperId = PlacementHelpers.register(PlacementHelper.get()); @@ -59,7 +61,7 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme } @Override - public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) { + public boolean canHarvestBlock(BlockState state, BlockGetter world, BlockPos pos, Player player) { for (ToolType toolType : player.getMainHandItem() .getToolTypes()) { if (isToolEffective(state, toolType)) @@ -79,7 +81,7 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme } @Override - public void playerWillDestroy(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { + public void playerWillDestroy(Level worldIn, BlockPos pos, BlockState state, Player player) { Axis axis = state.getValue(FACING) .getAxis(); Direction direction = Direction.get(AxisDirection.POSITIVE, axis); @@ -119,7 +121,7 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme worldIn.setBlockAndUpdate(basePos, worldIn.getBlockState(basePos) .setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED)); - TileEntity te = worldIn.getBlockEntity(basePos); + BlockEntity te = worldIn.getBlockEntity(basePos); if (te instanceof MechanicalPistonTileEntity) { MechanicalPistonTileEntity baseTE = (MechanicalPistonTileEntity) te; baseTE.offset = 0; @@ -131,13 +133,13 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.FOUR_VOXEL_POLE.get(state.getValue(FACING) .getAxis()); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { FluidState FluidState = context.getLevel() .getFluidState(context.getClickedPos()); return defaultBlockState().setValue(FACING, context.getClickedFace() @@ -146,15 +148,15 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult ray) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult ray) { ItemStack heldItem = player.getItemInHand(hand); IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId); 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; + return InteractionResult.PASS; } @Override @@ -170,7 +172,7 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, BlockPos pos, BlockPos neighbourPos) { + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) { if (state.getValue(BlockStateProperties.WATERLOGGED)) { world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } @@ -178,7 +180,7 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } 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 1c05d8b77..2072a657f 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pi import com.jozufozu.flywheel.light.GridAlignedBB; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; -import net.minecraft.util.math.vector.Vector3i; +import net.minecraft.core.Vec3i; public class PistonLighter extends ContraptionLighter { public PistonLighter(PistonContraption contraption) { @@ -16,7 +16,7 @@ public class PistonLighter extends ContraptionLighter { bounds.translate(contraption.anchor); int length = contraption.extensionLength; - Vector3i direction = contraption.orientation.getNormal(); + Vec3i 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/AbstractPulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java index 5599b93a4..e52a08b7d 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 @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -11,24 +11,24 @@ import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { private PartialModel halfRope; private PartialModel halfMagnet; - public AbstractPulleyRenderer(TileEntityRendererDispatcher dispatcher, PartialModel halfRope, + public AbstractPulleyRenderer(BlockEntityRenderDispatcher dispatcher, PartialModel halfRope, PartialModel halfMagnet) { super(dispatcher); this.halfRope = halfRope; @@ -41,7 +41,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; @@ -55,7 +55,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { kineticRotationTransform(getRotatedCoil(te), te, rotationAxis, AngleHelper.rad(offset * 180), light) .renderInto(ms, buffer.getBuffer(RenderType.solid())); - World world = te.getLevel(); + Level world = te.getLevel(); BlockState blockState = te.getBlockState(); BlockPos pos = te.getBlockPos(); @@ -64,7 +64,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { SuperByteBuffer magnet = renderMagnet(te); SuperByteBuffer rope = renderRope(te); - IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); if (running || offset == 0) renderAt(world, offset > .25f ? magnet : halfMagnet, offset, pos, ms, vb); @@ -79,10 +79,10 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { renderAt(world, rope, offset - i - 1, pos, ms, vb); } - private void renderAt(IWorld world, SuperByteBuffer partial, float offset, BlockPos pulleyPos, MatrixStack ms, - IVertexBuilder buffer) { + private void renderAt(LevelAccessor world, SuperByteBuffer partial, float offset, BlockPos pulleyPos, PoseStack ms, + VertexConsumer buffer) { BlockPos actualPos = pulleyPos.below((int) offset); - int light = WorldRenderer.getLightColor(world, world.getBlockState(actualPos), actualPos); + int light = LevelRenderer.getLightColor(world, world.getBlockState(actualPos), actualPos); partial.translate(0, -offset, 0) .light(light) .renderInto(ms, buffer); 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 c482ac605..3d9f0dca2 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 @@ -6,32 +6,34 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.HorizontalAxisKineticBlock; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE { @@ -41,8 +43,8 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE te.assembleNextTick = true); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.PULLEY.get(state.getValue(HORIZONTAL_AXIS)); } @@ -92,7 +94,7 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE { public PulleyLighter(PulleyContraption contraption) { @@ -17,9 +17,9 @@ public class PulleyLighter extends ContraptionLighter { GridAlignedBB bounds = GridAlignedBB.from(contraption.bounds); - World world = contraption.entity.level; + Level world = contraption.entity.level; - BlockPos.Mutable pos = contraption.anchor.mutable(); + BlockPos.MutableBlockPos 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 233dbe8d5..d7ae73220 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 @@ -8,13 +8,13 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.foundation.render.SuperByteBuffer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction.Axis; +import net.minecraft.util.Mth; public class PulleyRenderer extends AbstractPulleyRenderer { - public PulleyRenderer(TileEntityRendererDispatcher dispatcher) { + public PulleyRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher, AllBlockPartials.ROPE_HALF, AllBlockPartials.ROPE_HALF_MAGNET); } @@ -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.yOld, e.getY()); + double entityPos = Mth.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 5af548f7c..6788ba334 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 @@ -10,31 +10,31 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.state.properties.BlockStateProperties; -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.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class PulleyTileEntity extends LinearActuatorTileEntity { protected int initialOffset; private float prevAnimatedOffset; - public PulleyTileEntity(TileEntityType type) { + public PulleyTileEntity(BlockEntityType type) { super(type); } @Override - public AxisAlignedBB makeRenderBoundingBox() { + public AABB makeRenderBoundingBox() { return super.makeRenderBoundingBox().expandTowards(0, -offset, 0); } @@ -75,8 +75,8 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { // Collect Construct if (!level.isClientSide) { - BlockPos anchor = worldPosition.below(MathHelper.floor(offset + 1)); - initialOffset = MathHelper.floor(offset); + BlockPos anchor = worldPosition.below(Mth.floor(offset + 1)); + initialOffset = Mth.floor(offset); PulleyContraption contraption = new PulleyContraption(initialOffset); boolean canAssembleStructure = contraption.assemble(level, anchor); @@ -93,7 +93,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { for (i = ((int) offset); i > 0; i--) { BlockPos offset = worldPosition.below(i); BlockState oldState = level.getBlockState(offset); - if (oldState.getBlock() instanceof IWaterLoggable && oldState.hasProperty(BlockStateProperties.WATERLOGGED) + if (oldState.getBlock() instanceof SimpleWaterloggedBlock && oldState.hasProperty(BlockStateProperties.WATERLOGGED) && oldState.getValue(BlockStateProperties.WATERLOGGED)) { level.setBlock(offset, Blocks.WATER.defaultBlockState(), 66); continue; @@ -165,13 +165,13 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { } @Override - protected Vector3d toPosition(float offset) { + protected Vec3 toPosition(float offset) { if (movedContraption.getContraption() instanceof PulleyContraption) { PulleyContraption contraption = (PulleyContraption) movedContraption.getContraption(); - return Vector3d.atLowerCornerOf(contraption.anchor).add(0, contraption.initialOffset - offset, 0); + return Vec3.atLowerCornerOf(contraption.anchor).add(0, contraption.initialOffset - offset, 0); } - return Vector3d.ZERO; + return Vec3.ZERO; } @Override @@ -196,13 +196,13 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { initialOffset = compound.getInt("InitialOffset"); super.fromTag(state, compound, clientPacket); } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("InitialOffset", initialOffset); super.write(compound, clientPacket); } @@ -218,8 +218,8 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { } @Override - protected Vector3d toMotionVector(float speed) { - return new Vector3d(0, -speed, 0); + protected Vec3 toMotionVector(float speed) { + return new Vec3(0, -speed, 0); } @Override @@ -230,7 +230,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { @Override public float getInterpolatedOffset(float partialTicks) { if (isVirtual()) - return MathHelper.lerp(partialTicks, prevAnimatedOffset, offset); + return Mth.lerp(partialTicks, prevAnimatedOffset, offset); boolean moving = running && (movedContraption == null || !movedContraption.isStalled()); return super.getInterpolatedOffset(moving ? partialTicks : 0.5f); } 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 7464bbbd7..7aeb82184 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 @@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.world.LightType; +import net.minecraft.world.level.LightLayer; public abstract class ActorInstance { protected final MaterialManager materialManager; @@ -22,6 +22,6 @@ public abstract class ActorInstance { public void beginFrame() { } protected int localBlockLight() { - return simulationWorld.getBrightness(LightType.BLOCK, context.localPos); + return simulationWorld.getBrightness(LightLayer.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 733ff004d..f20760cf2 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 @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.world.entity.Entity; +import net.minecraft.util.Mth; +import com.mojang.math.Matrix4f; /** *

@@ -15,9 +15,9 @@ import net.minecraft.util.math.vector.Matrix4f; */ public class ContraptionMatrices { - private final MatrixStack modelViewProjection = new MatrixStack(); - private final MatrixStack viewProjection = new MatrixStack(); - private final MatrixStack model = new MatrixStack(); + private final PoseStack modelViewProjection = new PoseStack(); + private final PoseStack viewProjection = new PoseStack(); + private final PoseStack model = new PoseStack(); private final Matrix4f world = new Matrix4f(); private final Matrix4f light = new Matrix4f(); @@ -28,13 +28,13 @@ public class ContraptionMatrices { light.setIdentity(); } - public void setup(MatrixStack viewProjection, AbstractContraptionEntity entity) { + public void setup(PoseStack viewProjection, AbstractContraptionEntity entity) { float partialTicks = AnimationTickHolder.getPartialTicks(); this.viewProjection.pushPose(); transform(this.viewProjection, viewProjection); model.pushPose(); - entity.doLocalTransforms(partialTicks, new MatrixStack[] { model }); + entity.doLocalTransforms(partialTicks, new PoseStack[] { model }); modelViewProjection.pushPose(); transform(modelViewProjection, viewProjection); @@ -58,15 +58,15 @@ public class ContraptionMatrices { ready = false; } - public MatrixStack getModelViewProjection() { + public PoseStack getModelViewProjection() { return modelViewProjection; } - public MatrixStack getViewProjection() { + public PoseStack getViewProjection() { return viewProjection; } - public MatrixStack getModel() { + public PoseStack getModel() { return model; } @@ -82,7 +82,7 @@ public class ContraptionMatrices { return ready; } - public static void transform(MatrixStack ms, MatrixStack transform) { + public static void transform(PoseStack ms, PoseStack transform) { ms.last().pose() .multiply(transform.last() .pose()); @@ -92,13 +92,13 @@ public class ContraptionMatrices { } public static void translateToEntity(Matrix4f matrix, Entity entity, float partialTicks) { - 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()); + double x = Mth.lerp(partialTicks, entity.xOld, entity.getX()); + double y = Mth.lerp(partialTicks, entity.yOld, entity.getY()); + double z = Mth.lerp(partialTicks, entity.zOld, entity.getZ()); matrix.setTranslation((float) x, (float) y, (float) z); } - public static void clearStack(MatrixStack ms) { + public static void clearStack(PoseStack ms) { while (!ms.clear()) { ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java index 897d132bc..784e92ea2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java @@ -7,9 +7,9 @@ import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.core.shader.WorldProgram; import com.jozufozu.flywheel.core.shader.extension.IProgramExtension; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.AABB; +import com.mojang.math.Matrix4f; public class ContraptionProgram extends WorldProgram { protected final int uLightBoxSize; @@ -31,7 +31,7 @@ public class ContraptionProgram extends WorldProgram { uLightVolume = setSamplerBinding("uLightVolume", 4); } - public void bind(Matrix4f model, AxisAlignedBB lightVolume) { + public void bind(Matrix4f model, AABB lightVolume) { double sizeX = lightVolume.maxX - lightVolume.minX; double sizeY = lightVolume.maxY - lightVolume.minY; double sizeZ = lightVolume.maxZ - lightVolume.minZ; 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 bb906a32f..f241a7ede 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 @@ -12,7 +12,7 @@ import com.jozufozu.flywheel.event.ReloadRenderersEvent; import com.jozufozu.flywheel.event.RenderLayerEvent; import com.jozufozu.flywheel.util.WorldAttached; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; @@ -23,15 +23,15 @@ import com.simibubi.create.foundation.render.TileEntityRenderHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import com.mojang.blaze3d.vertex.BufferBuilder; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.LightType; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -49,12 +49,12 @@ public class ContraptionRenderDispatcher { * @return true if there was a renderer associated with the given contraption. */ public static boolean invalidate(Contraption contraption) { - World level = contraption.entity.level; + Level level = contraption.entity.level; return WORLDS.get(level).invalidate(contraption); } - public static void tick(World world) { + public static void tick(Level world) { if (Minecraft.getInstance().isPaused()) return; WORLDS.get(world).tick(); @@ -79,8 +79,8 @@ public class ContraptionRenderDispatcher { reset(); } - public static void renderFromEntity(AbstractContraptionEntity entity, Contraption contraption, IRenderTypeBuffer buffers) { - World world = entity.level; + public static void renderFromEntity(AbstractContraptionEntity entity, Contraption contraption, MultiBufferSource buffers) { + Level world = entity.level; ContraptionRenderInfo renderInfo = WORLDS.get(world) .getRenderInfo(contraption); @@ -93,18 +93,18 @@ public class ContraptionRenderDispatcher { renderTileEntities(world, renderWorld, contraption, matrices, buffers); - if (buffers instanceof IRenderTypeBuffer.Impl) - ((IRenderTypeBuffer.Impl) buffers).endBatch(); + if (buffers instanceof MultiBufferSource.BufferSource) + ((MultiBufferSource.BufferSource) buffers).endBatch(); renderActors(world, renderWorld, contraption, matrices, buffers); } - public static PlacementSimulationWorld setupRenderWorld(World world, Contraption c) { + public static PlacementSimulationWorld setupRenderWorld(Level world, Contraption c) { PlacementSimulationWorld renderWorld = new PlacementSimulationWorld(world); renderWorld.setTileEntities(c.presentTileEntities.values()); - for (Template.BlockInfo info : c.getBlocks() + for (StructureTemplate.StructureBlockInfo info : c.getBlocks() .values()) // Skip individual lighting updates to prevent lag with large contraptions renderWorld.setBlock(info.pos, info.state, 128); @@ -115,23 +115,23 @@ public class ContraptionRenderDispatcher { return renderWorld; } - public static void renderTileEntities(World world, PlacementSimulationWorld renderWorld, Contraption c, - ContraptionMatrices matrices, IRenderTypeBuffer buffer) { + public static void renderTileEntities(Level world, PlacementSimulationWorld renderWorld, Contraption c, + ContraptionMatrices matrices, MultiBufferSource buffer) { TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities, matrices.getModelViewProjection(), matrices.getLight(), buffer); } - protected static void renderActors(World world, PlacementSimulationWorld renderWorld, Contraption c, - ContraptionMatrices matrices, IRenderTypeBuffer buffer) { - for (Pair actor : c.getActors()) { + protected static void renderActors(Level world, PlacementSimulationWorld renderWorld, Contraption c, + ContraptionMatrices matrices, MultiBufferSource buffer) { + for (Pair actor : c.getActors()) { MovementContext context = actor.getRight(); if (context == null) continue; if (context.world == null) context.world = world; - Template.BlockInfo blockInfo = actor.getLeft(); + StructureTemplate.StructureBlockInfo blockInfo = actor.getLeft(); - MatrixStack m = matrices.getModel(); + PoseStack m = matrices.getModel(); m.pushPose(); MatrixTransformStack.of(m) .translate(blockInfo.pos); @@ -145,14 +145,14 @@ public class ContraptionRenderDispatcher { } public static SuperByteBuffer buildStructureBuffer(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { - Collection values = c.getBlocks() + Collection values = c.getBlocks() .values(); BufferBuilder builder = ModelUtil.getBufferBuilderFromTemplate(renderWorld, layer, values); return new SuperByteBuffer(builder); } - public static int getLight(World world, float lx, float ly, float lz) { - BlockPos.Mutable pos = new BlockPos.Mutable(); + public static int getLight(Level world, float lx, float ly, float lz) { + BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); float block = 0, sky = 0; float offset = 1 / 8f; @@ -160,15 +160,15 @@ public class ContraptionRenderDispatcher { for (float yOffset = offset; yOffset >= -offset; yOffset -= 2 * offset) for (float xOffset = offset; xOffset >= -offset; xOffset -= 2 * offset) { pos.set(lx + xOffset, ly + yOffset, lz + zOffset); - block += world.getBrightness(LightType.BLOCK, pos) / 8f; - sky += world.getBrightness(LightType.SKY, pos) / 8f; + block += world.getBrightness(LightLayer.BLOCK, pos) / 8f; + sky += world.getBrightness(LightLayer.SKY, pos) / 8f; } return LightTexture.pack((int) block, (int) sky); } public static int getContraptionWorldLight(MovementContext context, PlacementSimulationWorld renderWorld) { - return WorldRenderer.getLightColor(renderWorld, context.localPos); + return LevelRenderer.getLightColor(renderWorld, context.localPos); } public static void reset() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java index 861db5c41..648311387 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java @@ -1,13 +1,13 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; import com.jozufozu.flywheel.event.BeginFrameEvent; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; public class ContraptionRenderInfo { public final Contraption contraption; @@ -44,15 +44,15 @@ public class ContraptionRenderInfo { /** * Need to call this during RenderLayerEvent. */ - public void setupMatrices(MatrixStack viewProjection, double camX, double camY, double camZ) { + public void setupMatrices(PoseStack viewProjection, double camX, double camY, double camZ) { if (!matrices.isReady()) { AbstractContraptionEntity entity = contraption.entity; viewProjection.pushPose(); - double x = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), entity.xOld, entity.getX()) - camX; - double y = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), entity.yOld, entity.getY()) - camY; - double z = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), entity.zOld, entity.getZ()) - camZ; + double x = Mth.lerp(AnimationTickHolder.getPartialTicks(), entity.xOld, entity.getX()) - camX; + double y = Mth.lerp(AnimationTickHolder.getPartialTicks(), entity.yOld, entity.getY()) - camY; + double z = Mth.lerp(AnimationTickHolder.getPartialTicks(), entity.zOld, entity.getZ()) - camZ; viewProjection.translate(x, y, z); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java index 5bc3abed3..859c1c4a0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java @@ -14,19 +14,19 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; public abstract class ContraptionRenderManager { - protected final World world; + protected final Level world; private int removalTimer; protected final Int2ObjectMap renderInfos = new Int2ObjectOpenHashMap<>(); protected final List visible = new ObjectArrayList<>(); - public ContraptionRenderManager(IWorld world) { - this.world = (World) world; + public ContraptionRenderManager(LevelAccessor world) { + this.world = (Level) world; } public boolean invalidate(Contraption contraption) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java index d5ddbe7f7..5ac3c64d7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java @@ -15,11 +15,11 @@ import com.simibubi.create.foundation.render.CreateContexts; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.client.renderer.RenderType; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.LevelAccessor; public class FlwContraptionManager extends ContraptionRenderManager { - public FlwContraptionManager(IWorld world) { + public FlwContraptionManager(LevelAccessor world) { super(world); } 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 47756d24a..b1ae9d93e 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 @@ -24,13 +24,15 @@ import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationW import net.minecraft.client.renderer.RenderType; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.world.phys.AABB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix4f; +import com.mojang.math.Matrix4f; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; +import MaterialManagerImpl; + public class RenderedContraption extends ContraptionRenderInfo { private final ContraptionLighter lighter; @@ -42,7 +44,7 @@ public class RenderedContraption extends ContraptionRenderInfo { private final Matrix4f modelViewPartial = new Matrix4f(); private boolean modelViewPartialReady; - private AxisAlignedBB lightBox; + private AABB lightBox; public RenderedContraption(Contraption contraption, PlacementSimulationWorld renderWorld) { super(contraption, renderWorld); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/SBBContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/SBBContraptionManager.java index 0fb8e5536..ab5961028 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/SBBContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/SBBContraptionManager.java @@ -11,12 +11,12 @@ import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.client.renderer.RenderType; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.LevelAccessor; public class SBBContraptionManager extends ContraptionRenderManager { public static final Compartment> CONTRAPTION = new Compartment<>(); - public SBBContraptionManager(IWorld world) { + public SBBContraptionManager(LevelAccessor world) { super(world); } 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 9e2487763..7350ab911 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 @@ -5,32 +5,32 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fml.network.NetworkEvent.Context; import net.minecraftforge.fml.network.PacketDistributor; public class ClientMotionPacket extends SimplePacketBase { - private Vector3d motion; + private Vec3 motion; private boolean onGround; private float limbSwing; - public ClientMotionPacket(Vector3d motion, boolean onGround, float limbSwing) { + public ClientMotionPacket(Vec3 motion, boolean onGround, float limbSwing) { this.motion = motion; this.onGround = onGround; this.limbSwing = limbSwing; } - public ClientMotionPacket(PacketBuffer buffer) { - motion = new Vector3d(buffer.readFloat(), buffer.readFloat(), buffer.readFloat()); + public ClientMotionPacket(FriendlyByteBuf buffer) { + motion = new Vec3(buffer.readFloat(), buffer.readFloat(), buffer.readFloat()); onGround = buffer.readBoolean(); limbSwing = buffer.readFloat(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeFloat((float) motion.x); buffer.writeFloat((float) motion.y); buffer.writeFloat((float) motion.z); @@ -42,7 +42,7 @@ public class ClientMotionPacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity sender = context.get() + ServerPlayer sender = context.get() .getSender(); if (sender == null) return; 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 fd648bb5d..1ffcaf4b9 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 @@ -6,9 +6,9 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Abs import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.network.NetworkEvent.Context; @@ -24,14 +24,14 @@ public class ContraptionFluidPacket extends SimplePacketBase { this.containedFluid = containedFluid; } - public ContraptionFluidPacket(PacketBuffer buffer) { + public ContraptionFluidPacket(FriendlyByteBuf buffer) { entityId = buffer.readInt(); localPos = buffer.readBlockPos(); containedFluid = FluidStack.readFromPacket(buffer); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(entityId); buffer.writeBlockPos(localPos); containedFluid.writeToPacket(buffer); 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 9d731d735..1a0aafe3f 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 @@ -5,39 +5,39 @@ import java.util.function.Supplier; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.fml.network.NetworkEvent.Context; public class ContraptionInteractionPacket extends SimplePacketBase { - private Hand interactionHand; + private InteractionHand interactionHand; private int target; private BlockPos localPos; private Direction face; - public ContraptionInteractionPacket(AbstractContraptionEntity target, Hand hand, BlockPos localPos, Direction side) { + public ContraptionInteractionPacket(AbstractContraptionEntity target, InteractionHand hand, BlockPos localPos, Direction side) { this.interactionHand = hand; this.localPos = localPos; this.target = target.getId(); this.face = side; } - public ContraptionInteractionPacket(PacketBuffer buffer) { + public ContraptionInteractionPacket(FriendlyByteBuf buffer) { target = buffer.readInt(); int handId = buffer.readInt(); - interactionHand = handId == -1 ? null : Hand.values()[handId]; + interactionHand = handId == -1 ? null : InteractionHand.values()[handId]; localPos = buffer.readBlockPos(); face = Direction.from3DDataValue(buffer.readShort()); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(target); buffer.writeInt(interactionHand == null ? -1 : interactionHand.ordinal()); buffer.writeBlockPos(localPos); @@ -47,7 +47,7 @@ public class ContraptionInteractionPacket extends SimplePacketBase { @Override public void handle(Supplier context) { context.get().enqueueWork(() -> { - ServerPlayerEntity sender = context.get().getSender(); + ServerPlayer sender = context.get().getSender(); if (sender == null) return; Entity entityByID = sender.getLevel().getEntity(target); 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 b05df0f01..23d4c49e9 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 @@ -9,8 +9,8 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Abs import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.entity.Entity; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.network.NetworkEvent.Context; public class ContraptionSeatMappingPacket extends SimplePacketBase { @@ -23,7 +23,7 @@ public class ContraptionSeatMappingPacket extends SimplePacketBase { this.mapping = mapping; } - public ContraptionSeatMappingPacket(PacketBuffer buffer) { + public ContraptionSeatMappingPacket(FriendlyByteBuf buffer) { entityID = buffer.readInt(); mapping = new HashMap<>(); short size = buffer.readShort(); @@ -32,7 +32,7 @@ public class ContraptionSeatMappingPacket extends SimplePacketBase { } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(entityID); buffer.writeShort(mapping.size()); mapping.forEach((k, v) -> { 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 454ef81d4..a2bb0d2cb 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 @@ -5,33 +5,33 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fml.network.NetworkEvent.Context; public class LimbSwingUpdatePacket extends SimplePacketBase { private int entityId; - private Vector3d position; + private Vec3 position; private float limbSwing; - public LimbSwingUpdatePacket(int entityId, Vector3d position, float limbSwing) { + public LimbSwingUpdatePacket(int entityId, Vec3 position, float limbSwing) { this.entityId = entityId; this.position = position; this.limbSwing = limbSwing; } - public LimbSwingUpdatePacket(PacketBuffer buffer) { + public LimbSwingUpdatePacket(FriendlyByteBuf buffer) { entityId = buffer.readInt(); - position = new Vector3d(buffer.readFloat(), buffer.readFloat(), buffer.readFloat()); + position = new Vec3(buffer.readFloat(), buffer.readFloat(), buffer.readFloat()); limbSwing = buffer.readFloat(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(entityId); buffer.writeFloat((float) position.x); buffer.writeFloat((float) position.y); @@ -43,13 +43,13 @@ public class LimbSwingUpdatePacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ClientWorld world = Minecraft.getInstance().level; + ClientLevel world = Minecraft.getInstance().level; if (world == null) return; Entity entity = world.getEntity(entityId); if (entity == null) return; - CompoundNBT data = entity.getPersistentData(); + CompoundTag data = entity.getPersistentData(); data.putInt("LastOverrideLimbSwingUpdate", 0); data.putFloat("OverrideLimbSwing", limbSwing); entity.lerpTo(position.x, position.y, position.z, entity.yRot, 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 c042219d1..dc541a318 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 @@ -4,27 +4,27 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.network.NetworkEvent.Context; public class CouplingCreationPacket extends SimplePacketBase { int id1, id2; - public CouplingCreationPacket(AbstractMinecartEntity cart1, AbstractMinecartEntity cart2) { + public CouplingCreationPacket(AbstractMinecart cart1, AbstractMinecart cart2) { id1 = cart1.getId(); id2 = cart2.getId(); } - public CouplingCreationPacket(PacketBuffer buffer) { + public CouplingCreationPacket(FriendlyByteBuf buffer) { id1 = buffer.readInt(); id2 = buffer.readInt(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(id1); buffer.writeInt(id2); } @@ -33,7 +33,7 @@ public class CouplingCreationPacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity sender = context.get() + ServerPlayer sender = context.get() .getSender(); if (sender != null) CouplingHandler.tryToCoupleCarts(sender, sender.level, id1, id2); 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 924bd4d11..6b1c84a87 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 @@ -16,12 +16,12 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.world.World; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.entity.EntityMountEvent; import net.minecraftforge.eventbus.api.Event.Result; @@ -46,7 +46,7 @@ public class CouplingHandler { } } - public static void forEachLoadedCoupling(World world, Consumer> consumer) { + public static void forEachLoadedCoupling(Level world, Consumer> consumer) { if (world == null) return; Set cartsWithCoupling = CapabilityMinecartController.loadedMinecartsWithCoupling.get(world); @@ -66,13 +66,13 @@ public class CouplingHandler { }); } - public static boolean tryToCoupleCarts(@Nullable PlayerEntity player, World world, int cartId1, int cartId2) { + public static boolean tryToCoupleCarts(@Nullable Player player, Level world, int cartId1, int cartId2) { Entity entity1 = world.getEntity(cartId1); Entity entity2 = world.getEntity(cartId2); - if (!(entity1 instanceof AbstractMinecartEntity)) + if (!(entity1 instanceof AbstractMinecart)) return false; - if (!(entity2 instanceof AbstractMinecartEntity)) + if (!(entity2 instanceof AbstractMinecart)) return false; String tooMany = "two_couplings_max"; @@ -95,8 +95,8 @@ public class CouplingHandler { return false; } - AbstractMinecartEntity cart1 = (AbstractMinecartEntity) entity1; - AbstractMinecartEntity cart2 = (AbstractMinecartEntity) entity2; + AbstractMinecart cart1 = (AbstractMinecart) entity1; + AbstractMinecart cart2 = (AbstractMinecart) entity2; UUID mainID = cart1.getUUID(); UUID connectedID = cart2.getUUID(); MinecartController mainController = CapabilityMinecartController.getIfPresent(world, mainID); @@ -143,7 +143,7 @@ public class CouplingHandler { } if (!contraptionCoupling) { - for (Hand hand : Hand.values()) { + for (InteractionHand hand : InteractionHand.values()) { if (player.isCreative()) break; ItemStack heldItem = player.getItemInHand(hand); @@ -166,7 +166,7 @@ public class CouplingHandler { /** * MinecartController.EMPTY if none connected, null if not yet loaded */ - public static MinecartController getNextInCouplingChain(World world, MinecartController controller, + public static MinecartController getNextInCouplingChain(Level world, MinecartController controller, boolean forward) { UUID coupledCart = controller.getCoupledCart(forward); if (coupledCart == null) @@ -174,7 +174,7 @@ public class CouplingHandler { return CapabilityMinecartController.getIfPresent(world, coupledCart); } - public static void status(PlayerEntity player, String key) { + public static void status(Player player, String key) { if (player == null) return; 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 d4b34b7c0..fa201e5c5 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 @@ -7,27 +7,27 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.particles.RedstoneParticleData; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; public class CouplingHandlerClient { - static AbstractMinecartEntity selectedCart; + static AbstractMinecart selectedCart; static Random r = new Random(); public static void tick() { if (selectedCart == null) return; spawnSelectionParticles(selectedCart.getBoundingBox(), false); - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; ItemStack heldItemMainhand = player.getMainHandItem(); ItemStack heldItemOffhand = player.getOffhandItem(); if (AllItems.MINECART_COUPLING.isIn(heldItemMainhand) || AllItems.MINECART_COUPLING.isIn(heldItemOffhand)) @@ -35,7 +35,7 @@ public class CouplingHandlerClient { selectedCart = null; } - static void onCartClicked(PlayerEntity player, AbstractMinecartEntity entity) { + static void onCartClicked(Player player, AbstractMinecart entity) { if (Minecraft.getInstance().player != player) return; if (selectedCart == null || selectedCart == entity) { @@ -52,13 +52,13 @@ public class CouplingHandlerClient { selectedCart = null; } - private static void spawnSelectionParticles(AxisAlignedBB axisAlignedBB, boolean highlight) { - ClientWorld world = Minecraft.getInstance().level; - Vector3d center = axisAlignedBB.getCenter(); + private static void spawnSelectionParticles(AABB axisAlignedBB, boolean highlight) { + ClientLevel world = Minecraft.getInstance().level; + Vec3 center = axisAlignedBB.getCenter(); int amount = highlight ? 100 : 2; - IParticleData particleData = highlight ? ParticleTypes.END_ROD : new RedstoneParticleData(1, 1, 1, 1); + ParticleOptions particleData = highlight ? ParticleTypes.END_ROD : new DustParticleOptions(1, 1, 1, 1); for (int i = 0; i < amount; i++) { - Vector3d v = VecHelper.offsetRandomly(Vector3d.ZERO, r, 1); + Vec3 v = VecHelper.offsetRandomly(Vec3.ZERO, r, 1); double yOffset = v.y; v = v.multiply(1, 0, 1) .normalize() 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 24c97dc04..90cd41297 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 @@ -5,26 +5,26 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.MoverType; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.state.properties.RailShape; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.level.block.state.properties.RailShape; import net.minecraft.tags.BlockTags; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; public class CouplingPhysics { - public static void tick(World world) { + public static void tick(Level world) { CouplingHandler.forEachLoadedCoupling(world, c -> tickCoupling(world, c)); } - public static void tickCoupling(World world, Couple c) { - Couple carts = c.map(MinecartController::cart); + public static void tickCoupling(Level world, Couple c) { + Couple carts = c.map(MinecartController::cart); float couplingLength = c.getFirst() .getCouplingLength(true); softCollisionStep(world, carts, couplingLength); @@ -33,16 +33,16 @@ public class CouplingPhysics { hardCollisionStep(world, carts, couplingLength); } - public static void hardCollisionStep(World world, Couple carts, double couplingLength) { + public static void hardCollisionStep(Level world, Couple carts, double couplingLength) { if (!MinecartSim2020.canAddMotion(carts.get(false)) && MinecartSim2020.canAddMotion(carts.get(true))) carts = carts.swap(); - Couple corrections = Couple.create(null, null); - Couple maxSpeed = carts.map(AbstractMinecartEntity::getMaxCartSpeedOnRail); + Couple corrections = Couple.create(null, null); + Couple maxSpeed = carts.map(AbstractMinecart::getMaxCartSpeedOnRail); boolean firstLoop = true; for (boolean current : new boolean[] { true, false, true }) { - AbstractMinecartEntity cart = carts.get(current); - AbstractMinecartEntity otherCart = carts.get(!current); + AbstractMinecart cart = carts.get(current); + AbstractMinecart otherCart = carts.get(!current); float stress = (float) (couplingLength - cart.position() .distanceTo(otherCart.position())); @@ -54,14 +54,14 @@ public class CouplingPhysics { BlockPos railPosition = cart.getCurrentRailPosition(); BlockState railState = world.getBlockState(railPosition.above()); - if (railState.getBlock() instanceof AbstractRailBlock) { - AbstractRailBlock block = (AbstractRailBlock) railState.getBlock(); + if (railState.getBlock() instanceof BaseRailBlock) { + BaseRailBlock block = (BaseRailBlock) railState.getBlock(); shape = block.getRailDirection(railState, world, railPosition, cart); } - Vector3d correction = Vector3d.ZERO; - Vector3d pos = cart.position(); - Vector3d link = otherCart.position() + Vec3 correction = Vec3.ZERO; + Vec3 pos = cart.position(); + Vec3 link = otherCart.position() .subtract(pos); float correctionMagnitude = firstLoop ? -stress / 2f : -stress; @@ -90,40 +90,40 @@ public class CouplingPhysics { } } - public static void softCollisionStep(World world, Couple carts, double couplingLength) { - Couple maxSpeed = carts.map(AbstractMinecartEntity::getMaxCartSpeedOnRail); + public static void softCollisionStep(Level world, Couple carts, double couplingLength) { + Couple maxSpeed = carts.map(AbstractMinecart::getMaxCartSpeedOnRail); Couple canAddmotion = carts.map(MinecartSim2020::canAddMotion); // Assuming Minecarts will never move faster than 1 block/tick - Couple motions = carts.map(Entity::getDeltaMovement); + Couple motions = carts.map(Entity::getDeltaMovement); motions.replaceWithParams(VecHelper::clamp, Couple.create(1f, 1f)); - Couple nextPositions = carts.map(MinecartSim2020::predictNextPositionOf); + 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.x()); - int y = MathHelper.floor(vec.y()); - int z = MathHelper.floor(vec.z()); + AbstractMinecart minecart = cart.getMinecart(); + Vec3 vec = nextPositions.get(current); + int x = Mth.floor(vec.x()); + int y = Mth.floor(vec.y()); + int z = Mth.floor(vec.z()); BlockPos pos = new BlockPos(x, y - 1, z); if (minecart.level.getBlockState(pos).is(BlockTags.RAILS)) pos = pos.below(); BlockPos railPosition = pos; BlockState railState = world.getBlockState(railPosition.above()); - if (!(railState.getBlock() instanceof AbstractRailBlock)) + if (!(railState.getBlock() instanceof BaseRailBlock)) return null; - AbstractRailBlock block = (AbstractRailBlock) railState.getBlock(); + BaseRailBlock block = (BaseRailBlock) railState.getBlock(); return block.getRailDirection(railState, world, railPosition, cart); }); float futureStress = (float) (couplingLength - nextPositions.getFirst() .distanceTo(nextPositions.getSecond())); - if (MathHelper.equal(futureStress, 0D)) + if (Mth.equal(futureStress, 0D)) return; for (boolean current : Iterate.trueAndFalse) { - Vector3d correction = Vector3d.ZERO; - Vector3d pos = nextPositions.get(current); - Vector3d link = nextPositions.get(!current) + Vec3 correction = Vec3.ZERO; + Vec3 pos = nextPositions.get(current); + Vec3 link = nextPositions.get(!current) .subtract(pos); float correctionMagnitude = -futureStress / 2f; @@ -134,7 +134,7 @@ public class CouplingPhysics { RailShape shape = shapes.get(current); if (shape != null) { - Vector3d railVec = MinecartSim2020.getRailVec(shape); + Vec3 railVec = MinecartSim2020.getRailVec(shape); correction = followLinkOnRail(link, pos, correctionMagnitude, railVec).subtract(pos); } else correction = link.normalize() @@ -150,15 +150,15 @@ public class CouplingPhysics { carts.forEachWithParams(Entity::setDeltaMovement, motions); } - public static Vector3d followLinkOnRail(Vector3d link, Vector3d cart, float diffToReduce, Vector3d railAxis) { + public static Vec3 followLinkOnRail(Vec3 link, Vec3 cart, float diffToReduce, Vec3 railAxis) { double dotProduct = railAxis.dot(link); if (Double.isNaN(dotProduct) || dotProduct == 0 || diffToReduce == 0) return cart; - Vector3d axis = railAxis.scale(-Math.signum(dotProduct)); - Vector3d center = cart.add(link); + Vec3 axis = railAxis.scale(-Math.signum(dotProduct)); + Vec3 center = cart.add(link); double radius = link.length() - diffToReduce; - Vector3d intersectSphere = VecHelper.intersectSphere(cart, axis, center, radius); + Vec3 intersectSphere = VecHelper.intersectSphere(cart, axis, center, radius); // Cannot satisfy on current rail vector if (intersectSphere == null) 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 1b8cef08a..d34da8034 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 @@ -1,8 +1,34 @@ package com.simibubi.create.content.contraptions.components.structureMovement.train; -import static net.minecraft.util.math.MathHelper.lerp; +import static net.minecraft.util.math.MathHelpimport com.jozufozu.flywheel.util.transform.MatrixTransformStack; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Vector3f; +import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.CreateClient; +import com.simibubi.create.content.contraptions.KineticDebugger; +import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; +import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.utility.Color; +import com.simibubi.create.foundation.utility.Couple; +import com.simibubi.create.foundation.utility.VecHelper; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; -import com.jozufozu.flywheel.util.transform.MatrixTransformStack; +er.lerp; + +import com.net.minecraft.util.MthatrixTransformStack; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -32,7 +58,7 @@ import net.minecraft.util.math.vector.Vector3f; public class CouplingRenderer { - public static void renderAll(MatrixStack ms, IRenderTypeBuffer buffer) { + public static void renderAll(PoseStack ms, MultiBufferSource buffer) { CouplingHandler.forEachLoadedCoupling(Minecraft.getInstance().level, c -> { if (c.getFirst().hasContraptionCoupling(true)) @@ -46,17 +72,17 @@ public class CouplingRenderer { CouplingHandler.forEachLoadedCoupling(Minecraft.getInstance().level, CouplingRenderer::doDebugRender); } - public static void renderCoupling(MatrixStack ms, IRenderTypeBuffer buffer, Couple carts) { - ClientWorld world = Minecraft.getInstance().level; + public static void renderCoupling(PoseStack ms, MultiBufferSource buffer, Couple carts) { + ClientLevel world = Minecraft.getInstance().level; if (carts.getFirst() == null || carts.getSecond() == null) return; Couple lightValues = - carts.map(c -> WorldRenderer.getLightColor(world, new BlockPos(c.getBoundingBox() + carts.map(c -> LevelRenderer.getLightColor(world, new BlockPos(c.getBoundingBox() .getCenter()))); - Vector3d center = carts.getFirst() + Vec3 center = carts.getFirst() .position() .add(carts.getSecond() .position()) @@ -65,17 +91,17 @@ public class CouplingRenderer { Couple transforms = carts.map(c -> getSuitableCartEndpoint(c, center)); BlockState renderState = Blocks.AIR.defaultBlockState(); - IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); + VertexConsumer 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); - Vector3d zero = Vector3d.ZERO; - Vector3d firstEndpoint = transforms.getFirst() + Vec3 zero = Vec3.ZERO; + Vec3 firstEndpoint = transforms.getFirst() .apply(zero); - Vector3d secondEndpoint = transforms.getSecond() + Vec3 secondEndpoint = transforms.getSecond() .apply(zero); - Vector3d endPointDiff = secondEndpoint.subtract(firstEndpoint); + Vec3 endPointDiff = secondEndpoint.subtract(firstEndpoint); double connectorYaw = -Math.atan2(endPointDiff.z, endPointDiff.x) * 180.0D / Math.PI; double connectorPitch = Math.atan2(endPointDiff.y, endPointDiff.multiply(1, 0, 1) .length()) * 180 / Math.PI; @@ -110,7 +136,7 @@ public class CouplingRenderer { ms.popPose(); } - private static CartEndpoint getSuitableCartEndpoint(AbstractMinecartEntity cart, Vector3d centerOfCoupling) { + private static CartEndpoint getSuitableCartEndpoint(AbstractMinecart cart, Vec3 centerOfCoupling) { 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; @@ -130,13 +156,13 @@ public class CouplingRenderer { float rollAmplifier = cart.getDamage() - pt; if (rollAmplifier < 0.0F) rollAmplifier = 0.0F; - roll = roll > 0 ? MathHelper.sin(roll) * roll * rollAmplifier / 10.0F * cart.getHurtDir() : 0; + roll = roll > 0 ? Mth.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)); - Vector3d backVec = positionVec.add(VecHelper.rotate(new Vector3d(-.5, 0, 0), 180 - yaw, Axis.Y)); + Vec3 positionVec = new Vec3(xIn, yIn, zIn); + Vec3 frontVec = positionVec.add(VecHelper.rotate(new Vec3(.5, 0, 0), 180 - yaw, Axis.Y)); + Vec3 backVec = positionVec.add(VecHelper.rotate(new Vec3(-.5, 0, 0), 180 - yaw, Axis.Y)); - Vector3d railVecOfPos = cart.getPos(xIn, yIn, zIn); + Vec3 railVecOfPos = cart.getPos(xIn, yIn, zIn); boolean flip = false; if (railVecOfPos != null) { @@ -151,7 +177,7 @@ public class CouplingRenderer { y += (frontVec.y + backVec.y) / 2; z += railVecOfPos.z; - Vector3d endPointDiff = backVec.add(-frontVec.x, -frontVec.y, -frontVec.z); + Vec3 endPointDiff = backVec.add(-frontVec.x, -frontVec.y, -frontVec.z); if (endPointDiff.length() != 0.0D) { endPointDiff = endPointDiff.normalize(); yaw = (float) (Math.atan2(endPointDiff.z, endPointDiff.x) * 180.0D / Math.PI); @@ -194,7 +220,7 @@ public class CouplingRenderer { this.flip = flip; } - public Vector3d apply(Vector3d vec) { + public Vec3 apply(Vec3 vec) { vec = vec.add(offset, 0, 0); vec = VecHelper.rotate(vec, roll, Axis.X); vec = VecHelper.rotate(vec, pitch, Axis.Z); @@ -202,7 +228,7 @@ public class CouplingRenderer { return vec.add(x, y, z); } - public void apply(MatrixStack ms) { + public void apply(PoseStack ms) { ms.translate(x, y, z); ms.mulPose(Vector3f.YP.rotationDegrees(yaw)); ms.mulPose(Vector3f.ZP.rotationDegrees(pitch)); @@ -217,22 +243,22 @@ public class CouplingRenderer { public static void doDebugRender(Couple c) { int yOffset = 1; MinecartController first = c.getFirst(); - AbstractMinecartEntity mainCart = first.cart(); - Vector3d mainCenter = mainCart.position() + AbstractMinecart mainCart = first.cart(); + Vec3 mainCenter = mainCart.position() .add(0, yOffset, 0); - Vector3d connectedCenter = c.getSecond() + Vec3 connectedCenter = c.getSecond() .cart() .position() .add(0, yOffset, 0); - int color = Color.mixColors(0xabf0e9, 0xee8572, (float) MathHelper + int color = Color.mixColors(0xabf0e9, 0xee8572, (float) Mth .clamp(Math.abs(first.getCouplingLength(true) - connectedCenter.distanceTo(mainCenter)) * 8, 0, 1)); CreateClient.OUTLINER.showLine(mainCart.getId() + "", mainCenter, connectedCenter) .colored(color) .lineWidth(1 / 8f); - Vector3d point = mainCart.position() + Vec3 point = mainCart.position() .add(0, yOffset, 0); CreateClient.OUTLINER.showLine(mainCart.getId() + "_dot", point, point.add(0, 1 / 128f, 0)) .colored(0xffffff) 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 737f4a828..c5389933e 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 @@ -5,13 +5,13 @@ import com.simibubi.create.content.contraptions.components.structureMovement.tra import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResultType; -import net.minecraft.world.World; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; @@ -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.world.item.Item.Properties; + @EventBusSubscriber public class MinecartCouplingItem extends Item { @@ -32,10 +34,10 @@ public class MinecartCouplingItem extends Item { @SubscribeEvent(priority = EventPriority.HIGH) public static void handleInteractionWithMinecart(PlayerInteractEvent.EntityInteract event) { Entity interacted = event.getTarget(); - if (!(interacted instanceof AbstractMinecartEntity)) + if (!(interacted instanceof AbstractMinecart)) return; - AbstractMinecartEntity minecart = (AbstractMinecartEntity) interacted; - PlayerEntity player = event.getPlayer(); + AbstractMinecart minecart = (AbstractMinecart) interacted; + Player player = event.getPlayer(); if (player == null) return; LazyOptional capability = @@ -55,12 +57,12 @@ public class MinecartCouplingItem extends Item { return; event.setCanceled(true); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); } protected static boolean onCouplingInteractOnMinecart(PlayerInteractEvent.EntityInteract event, - AbstractMinecartEntity minecart, PlayerEntity player, MinecartController controller) { - World world = event.getWorld(); + AbstractMinecart minecart, Player player, MinecartController controller) { + Level world = event.getWorld(); if (controller.isFullyCoupled()) { if (!world.isClientSide) CouplingHandler.status(player, "two_couplings_max"); @@ -71,8 +73,8 @@ public class MinecartCouplingItem extends Item { return true; } - private static boolean onWrenchInteractOnMinecart(EntityInteract event, AbstractMinecartEntity minecart, - PlayerEntity player, MinecartController controller) { + private static boolean onWrenchInteractOnMinecart(EntityInteract event, AbstractMinecart minecart, + Player player, MinecartController controller) { int couplings = (controller.isConnectedToCoupling() ? 1 : 0) + (controller.isLeadingCoupling() ? 1 : 0); if (couplings == 0) return false; @@ -93,8 +95,8 @@ public class MinecartCouplingItem extends Item { } @OnlyIn(Dist.CLIENT) - private static void cartClicked(PlayerEntity player, AbstractMinecartEntity interacted) { - CouplingHandlerClient.onCartClicked(player, (AbstractMinecartEntity) interacted); + private static void cartClicked(Player player, AbstractMinecart interacted) { + CouplingHandlerClient.onCartClicked(player, (AbstractMinecart) interacted); } } 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 0c0f3689b..1fd03b47a 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 @@ -2,9 +2,26 @@ package com.simibubi.create.content.contraptions.components.structureMovement.tr import static net.minecraft.entity.Entity.getHorizontalDistanceSqr; +importimport com.google.common.collect.Maps; +import com.mojang.datafixers.util.Pair; +import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; +import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; +import com.simibubi.create.foundation.utility.VecHelper; import java.util.Map; +import net.minecraft.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.MinecartFurnace; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.common.util.LazyOptional; -import com.google.common.collect.Maps; + javanet.minecraft.world.entity.Entityogle.common.collect.Maps; import com.mojang.datafixers.util.Pair; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; @@ -28,12 +45,12 @@ import net.minecraftforge.common.util.LazyOptional; * */ public class MinecartSim2020 { - private static final Map> MATRIX = + private static final Map> MATRIX = Util.make(Maps.newEnumMap(RailShape.class), (map) -> { - Vector3i west = Direction.WEST.getNormal(); - Vector3i east = Direction.EAST.getNormal(); - Vector3i north = Direction.NORTH.getNormal(); - Vector3i south = Direction.SOUTH.getNormal(); + Vec3i west = Direction.WEST.getNormal(); + Vec3i east = Direction.EAST.getNormal(); + Vec3i north = Direction.NORTH.getNormal(); + Vec3i 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.below(), east)); @@ -46,16 +63,16 @@ public class MinecartSim2020 { map.put(RailShape.NORTH_EAST, Pair.of(north, east)); }); - public static Vector3d predictNextPositionOf(AbstractMinecartEntity cart) { - Vector3d position = cart.position(); - Vector3d motion = VecHelper.clamp(cart.getDeltaMovement(), 1f); + public static Vec3 predictNextPositionOf(AbstractMinecart cart) { + Vec3 position = cart.position(); + Vec3 motion = VecHelper.clamp(cart.getDeltaMovement(), 1f); return position.add(motion); } - public static boolean canAddMotion(AbstractMinecartEntity c) { - if (c instanceof FurnaceMinecartEntity) - return MathHelper.equal(((FurnaceMinecartEntity) c).xPush, 0) - && MathHelper.equal(((FurnaceMinecartEntity) c).zPush, 0); + public static boolean canAddMotion(AbstractMinecart c) { + if (c instanceof MinecartFurnace) + return Mth.equal(((MinecartFurnace) c).xPush, 0) + && Mth.equal(((MinecartFurnace) c).zPush, 0); LazyOptional capability = c.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY); if (capability.isPresent() && capability.orElse(null) @@ -64,13 +81,13 @@ public class MinecartSim2020 { return true; } - public static void moveCartAlongTrack(AbstractMinecartEntity cart, Vector3d forcedMovement, BlockPos cartPos, + public static void moveCartAlongTrack(AbstractMinecart cart, Vec3 forcedMovement, BlockPos cartPos, BlockState trackState) { - if (forcedMovement.equals(Vector3d.ZERO)) + if (forcedMovement.equals(Vec3.ZERO)) return; - Vector3d previousMotion = cart.getDeltaMovement(); + Vec3 previousMotion = cart.getDeltaMovement(); cart.fallDistance = 0.0F; double x = cart.getX(); @@ -81,10 +98,10 @@ public class MinecartSim2020 { double actualY = y; double actualZ = z; - Vector3d actualVec = cart.getPos(actualX, actualY, actualZ); + Vec3 actualVec = cart.getPos(actualX, actualY, actualZ); actualY = cartPos.getY() + 1; - AbstractRailBlock abstractrailblock = (AbstractRailBlock) trackState.getBlock(); + BaseRailBlock abstractrailblock = (BaseRailBlock) trackState.getBlock(); RailShape railshape = abstractrailblock.getRailDirection(trackState, cart.level, cartPos, cart); switch (railshape) { case ASCENDING_EAST: @@ -106,9 +123,9 @@ public class MinecartSim2020 { break; } - Pair pair = MATRIX.get(railshape); - Vector3i Vector3i = pair.getFirst(); - Vector3i Vector3i1 = pair.getSecond(); + Pair pair = MATRIX.get(railshape); + Vec3i Vector3i = pair.getFirst(); + Vec3i Vector3i1 = pair.getSecond(); double d4 = (double) (Vector3i1.getX() - Vector3i.getX()); double d5 = (double) (Vector3i1.getZ() - Vector3i.getZ()); // double d6 = Math.sqrt(d4 * d4 + d5 * d5); @@ -146,11 +163,11 @@ public class MinecartSim2020 { y = cart.getY(); z = cart.getZ(); - if (Vector3i.getY() != 0 && MathHelper.floor(x) - cartPos.getX() == Vector3i.getX() - && MathHelper.floor(z) - cartPos.getZ() == Vector3i.getZ()) { + if (Vector3i.getY() != 0 && Mth.floor(x) - cartPos.getX() == Vector3i.getX() + && Mth.floor(z) - cartPos.getZ() == Vector3i.getZ()) { 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()) { + } else if (Vector3i1.getY() != 0 && Mth.floor(x) - cartPos.getX() == Vector3i1.getX() + && Mth.floor(z) - cartPos.getZ() == Vector3i1.getZ()) { cart.setPos(x, y + (double) Vector3i1.getY(), z); } @@ -158,10 +175,10 @@ public class MinecartSim2020 { y = cart.getY(); z = cart.getZ(); - Vector3d Vector3d3 = cart.getPos(x, y, z); + Vec3 Vector3d3 = cart.getPos(x, y, z); if (Vector3d3 != null && actualVec != null) { double d17 = (actualVec.y - Vector3d3.y) * 0.05D; - Vector3d Vector3d4 = cart.getDeltaMovement(); + Vec3 Vector3d4 = cart.getDeltaMovement(); double d18 = Math.sqrt(getHorizontalDistanceSqr(Vector3d4)); if (d18 > 0.0D) { cart.setDeltaMovement(Vector3d4.multiply((d18 + d17) / d18, 1.0D, (d18 + d17) / d18)); @@ -174,10 +191,10 @@ public class MinecartSim2020 { y = cart.getY(); z = cart.getZ(); - int j = MathHelper.floor(x); - int i = MathHelper.floor(z); + int j = Mth.floor(x); + int i = Mth.floor(z); if (j != cartPos.getX() || i != cartPos.getZ()) { - Vector3d Vector3d5 = cart.getDeltaMovement(); + Vec3 Vector3d5 = cart.getDeltaMovement(); double d26 = Math.sqrt(getHorizontalDistanceSqr(Vector3d5)); cart.setDeltaMovement(d26 * (double) (j - cartPos.getX()), Vector3d5.y, d26 * (double) (i - cartPos.getZ())); } @@ -185,24 +202,24 @@ public class MinecartSim2020 { cart.setDeltaMovement(previousMotion); } - public static Vector3d getRailVec(RailShape shape) { + public static Vec3 getRailVec(RailShape shape) { switch (shape) { case ASCENDING_NORTH: case ASCENDING_SOUTH: case NORTH_SOUTH: - return new Vector3d(0, 0, 1); + return new Vec3(0, 0, 1); case ASCENDING_EAST: case ASCENDING_WEST: case EAST_WEST: - return new Vector3d(1, 0, 0); + return new Vec3(1, 0, 0); case NORTH_EAST: case SOUTH_WEST: - return new Vector3d(1, 0, 1).normalize(); + return new Vec3(1, 0, 1).normalize(); case NORTH_WEST: case SOUTH_EAST: - return new Vector3d(1, 0, -1).normalize(); + return new Vec3(1, 0, -1).normalize(); default: - return new Vector3d(0, 1, 0); + return new Vec3(0, 1, 0); } } 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 7dcb896ba..2618afe5c 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 @@ -19,16 +19,16 @@ import com.simibubi.create.foundation.utility.WorldAttached; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectLists; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; @@ -39,13 +39,13 @@ import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.world.ChunkEvent; -public class CapabilityMinecartController implements ICapabilitySerializable { +public class CapabilityMinecartController implements ICapabilitySerializable { /* Global map of loaded carts */ public static WorldAttached> loadedMinecartsByUUID; public static WorldAttached> loadedMinecartsWithCoupling; - static WorldAttached> queuedAdditions; + static WorldAttached> queuedAdditions; static WorldAttached> queuedUnloads; /** @@ -54,10 +54,10 @@ public class CapabilityMinecartController implements ICapabilitySerializable> { - private World world; - private AbstractMinecartEntity cart; + private Level world; + private AbstractMinecart cart; - public MinecartRemovalListener(World world, AbstractMinecartEntity cart) { + public MinecartRemovalListener(Level world, AbstractMinecart cart) { this.world = world; this.cart = cart; } @@ -86,10 +86,10 @@ public class CapabilityMinecartController implements ICapabilitySerializable($ -> ObjectLists.synchronize(new ObjectArrayList<>())); } - public static void tick(World world) { + public static void tick(Level world) { List toRemove = new ArrayList<>(); Map carts = loadedMinecartsByUUID.get(world); - List queued = queuedAdditions.get(world); + List queued = queuedAdditions.get(world); List queuedRemovals = queuedUnloads.get(world); Set cartsWithCoupling = loadedMinecartsWithCoupling.get(world); Set keySet = carts.keySet(); @@ -97,13 +97,13 @@ public class CapabilityMinecartController implements ICapabilitySerializable carts = loadedMinecartsByUUID.get(world); List unloads = queuedUnloads.get(world); UUID uniqueID = entity.getUUID(); @@ -169,7 +169,7 @@ public class CapabilityMinecartController implements ICapabilitySerializable carts = loadedMinecartsByUUID.get(world); if (carts == null) return null; @@ -211,10 +211,10 @@ public class CapabilityMinecartController implements ICapabilitySerializable event) { Entity entity = event.getObject(); - if (!(entity instanceof AbstractMinecartEntity)) + if (!(entity instanceof AbstractMinecart)) return; - CapabilityMinecartController capability = new CapabilityMinecartController((AbstractMinecartEntity) entity); + CapabilityMinecartController capability = new CapabilityMinecartController((AbstractMinecart) entity); ResourceLocation id = Create.asResource("minecart_controller"); event.addCapability(id, capability); event.addListener(() -> { @@ -222,12 +222,12 @@ public class CapabilityMinecartController implements ICapabilitySerializable() { @Override - public INBT writeNBT(Capability capability, MinecartController instance, + public Tag writeNBT(Capability capability, MinecartController instance, Direction side) { return instance.serializeNBT(); } @Override public void readNBT(Capability capability, MinecartController instance, Direction side, - INBT base) { - instance.deserializeNBT((CompoundNBT) base); + Tag base) { + instance.deserializeNBT((CompoundTag) base); } }, MinecartController::empty); @@ -256,7 +256,7 @@ public class CapabilityMinecartController implements ICapabilitySerializable cap; private MinecartController handler; - public CapabilityMinecartController(AbstractMinecartEntity minecart) { + public CapabilityMinecartController(AbstractMinecart minecart) { handler = new MinecartController(minecart); cap = LazyOptional.of(() -> handler); } @@ -269,12 +269,12 @@ public class CapabilityMinecartController implements ICapabilitySerializable { +public class MinecartController implements INBTSerializable { public static MinecartController EMPTY; private boolean needsEntryRefresh; - private WeakReference weakRef; + private WeakReference weakRef; /* * Stall information, { */ private Couple> couplings; - public MinecartController(AbstractMinecartEntity minecart) { + public MinecartController(AbstractMinecart minecart) { weakRef = new WeakReference<>(minecart); stallData = Couple.create(Optional::empty); couplings = Couple.create(Optional::empty); @@ -66,8 +66,8 @@ public class MinecartController implements INBTSerializable { } public void tick() { - AbstractMinecartEntity cart = cart(); - World world = getWorld(); + AbstractMinecart cart = cart(); + Level world = getWorld(); if (needsEntryRefresh) { CapabilityMinecartController.queuedAdditions.get(world).add(cart); @@ -91,18 +91,18 @@ public class MinecartController implements INBTSerializable { } } - private void disassemble(AbstractMinecartEntity cart) { - if (cart instanceof MinecartEntity) { + private void disassemble(AbstractMinecart cart) { + if (cart instanceof Minecart) { return; } List passengers = cart.getPassengers(); if (passengers.isEmpty() || !(passengers.get(0) instanceof AbstractContraptionEntity)) { return; } - World world = cart.level; - int i = MathHelper.floor(cart.getX()); - int j = MathHelper.floor(cart.getY()); - int k = MathHelper.floor(cart.getZ()); + Level world = cart.level; + int i = Mth.floor(cart.getX()); + int j = Mth.floor(cart.getY()); + int k = Mth.floor(cart.getZ()); if (world.getBlockState(new BlockPos(i, j - 1, k)) .is(BlockTags.RAILS)) { --j; @@ -273,7 +273,7 @@ public class MinecartController implements INBTSerializable { if (isStalled(internal) == stall) return; - AbstractMinecartEntity cart = cart(); + AbstractMinecart cart = cart(); if (stall) { stallData.set(internal, Optional.of(new StallData(cart))); sendData(); @@ -297,8 +297,8 @@ public class MinecartController implements INBTSerializable { } @Override - public CompoundNBT serializeNBT() { - CompoundNBT compoundNBT = new CompoundNBT(); + public CompoundTag serializeNBT() { + CompoundTag compoundNBT = new CompoundTag(); stallData.forEachWithContext((opt, internal) -> opt .ifPresent(sd -> compoundNBT.put(internal ? "InternalStallData" : "StallData", sd.serialize()))); @@ -309,7 +309,7 @@ public class MinecartController implements INBTSerializable { } @Override - public void deserializeNBT(CompoundNBT nbt) { + public void deserializeNBT(CompoundTag nbt) { Optional internalSD = Optional.empty(); Optional externalSD = Optional.empty(); Optional mainCD = Optional.empty(); @@ -333,7 +333,7 @@ public class MinecartController implements INBTSerializable { return weakRef.get() != null && cart().isAlive(); } - public AbstractMinecartEntity cart() { + public AbstractMinecart cart() { return weakRef.get(); } @@ -341,7 +341,7 @@ public class MinecartController implements INBTSerializable { return EMPTY != null ? EMPTY : (EMPTY = new MinecartController(null)); } - private World getWorld() { + private Level getWorld() { return cart().getCommandSenderWorld(); } @@ -365,18 +365,18 @@ public class MinecartController implements INBTSerializable { connectedCartID = swap; } - CompoundNBT serialize() { - CompoundNBT nbt = new CompoundNBT(); - nbt.put("Main", NBTUtil.createUUID(mainCartID)); - nbt.put("Connected", NBTUtil.createUUID(connectedCartID)); + CompoundTag serialize() { + CompoundTag nbt = new CompoundTag(); + nbt.put("Main", NbtUtils.createUUID(mainCartID)); + nbt.put("Connected", NbtUtils.createUUID(connectedCartID)); nbt.putFloat("Length", length); nbt.putBoolean("Contraption", contraption); return nbt; } - static CouplingData read(CompoundNBT nbt) { - UUID mainCartID = NBTUtil.loadUUID(NBTHelper.getINBT(nbt, "Main")); - UUID connectedCartID = NBTUtil.loadUUID(NBTHelper.getINBT(nbt, "Connected")); + static CouplingData read(CompoundTag nbt) { + UUID mainCartID = NbtUtils.loadUUID(NBTHelper.getINBT(nbt, "Main")); + UUID connectedCartID = NbtUtils.loadUUID(NBTHelper.getINBT(nbt, "Connected")); float length = nbt.getFloat("Length"); boolean contraption = nbt.getBoolean("Contraption"); return new CouplingData(mainCartID, connectedCartID, length, contraption); @@ -389,13 +389,13 @@ public class MinecartController implements INBTSerializable { } private static class StallData { - Vector3d position; - Vector3d motion; + Vec3 position; + Vec3 motion; float yaw, pitch; private StallData() {} - StallData(AbstractMinecartEntity entity) { + StallData(AbstractMinecart entity) { position = entity.position(); motion = entity.getDeltaMovement(); yaw = entity.yRot; @@ -403,19 +403,19 @@ public class MinecartController implements INBTSerializable { tick(entity); } - void tick(AbstractMinecartEntity entity) { + void tick(AbstractMinecart entity) { entity.setPos(position.x, position.y, position.z); - entity.setDeltaMovement(Vector3d.ZERO); + entity.setDeltaMovement(Vec3.ZERO); entity.yRot = yaw; entity.xRot = pitch; } - void release(AbstractMinecartEntity entity) { + void release(AbstractMinecart entity) { entity.setDeltaMovement(motion); } - CompoundNBT serialize() { - CompoundNBT nbt = new CompoundNBT(); + CompoundTag serialize() { + CompoundTag nbt = new CompoundTag(); nbt.put("Pos", VecHelper.writeNBT(position)); nbt.put("Motion", VecHelper.writeNBT(motion)); nbt.putFloat("Yaw", yaw); @@ -423,7 +423,7 @@ public class MinecartController implements INBTSerializable { return nbt; } - static StallData read(CompoundNBT nbt) { + static StallData read(CompoundTag nbt) { StallData stallData = new StallData(); stallData.position = VecHelper.readNBT(nbt.getList("Pos", NBT.TAG_DOUBLE)); stallData.motion = VecHelper.readNBT(nbt.getList("Motion", NBT.TAG_DOUBLE)); 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 2f52fb897..ec509b074 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 @@ -5,10 +5,10 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; @@ -17,7 +17,7 @@ import net.minecraftforge.fml.network.NetworkEvent.Context; public class MinecartControllerUpdatePacket extends SimplePacketBase { int entityID; - CompoundNBT nbt; + CompoundTag nbt; public MinecartControllerUpdatePacket(MinecartController controller) { entityID = controller.cart() @@ -25,13 +25,13 @@ public class MinecartControllerUpdatePacket extends SimplePacketBase { nbt = controller.serializeNBT(); } - public MinecartControllerUpdatePacket(PacketBuffer buffer) { + public MinecartControllerUpdatePacket(FriendlyByteBuf buffer) { entityID = buffer.readInt(); nbt = buffer.readNbt(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(entityID); buffer.writeNbt(nbt); } @@ -46,7 +46,7 @@ public class MinecartControllerUpdatePacket extends SimplePacketBase { @OnlyIn(Dist.CLIENT) private void handleCL() { - ClientWorld world = Minecraft.getInstance().level; + ClientLevel world = Minecraft.getInstance().level; if (world == null) return; Entity entityByID = world.getEntity(entityID); 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 2b744df9c..aaed70ce4 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 @@ -2,8 +2,42 @@ package com.simibubi.create.content.contraptions.components.tracks; import static net.minecraft.state.properties.RailShape.NORTH_SOUTH; +import javanet.minimport com.simibubi.create.AllBlocks; +import com.simibubi.create.content.contraptions.wrench.IWrenchable; +import com.simibubi.create.foundation.utility.Iterate; +import com.simibubi.create.foundation.utility.VecHelper; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.Vec3i; +import net.minecraft.util.Mth; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.MinecartFurnace; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.phys.Vec3; + +ecraft.world.level.block.state.properties.RailShapeotation.ParametersAreNonnullByDefault; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.wrench.IWrenchable; @@ -41,7 +75,7 @@ import net.minecraft.world.World; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public class ControllerRailBlock extends AbstractRailBlock implements IWrenchable { +public class ControllerRailBlock extends BaseRailBlock implements IWrenchable { public static final EnumProperty SHAPE = BlockStateProperties.RAIL_SHAPE_STRAIGHT; public static final BooleanProperty BACKWARDS = BooleanProperty.create("backwards"); @@ -55,7 +89,7 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl .setValue(SHAPE, NORTH_SOUTH)); } - public static Vector3i getAccelerationVector(BlockState state) { + public static Vec3i getAccelerationVector(BlockState state) { Direction pointingTo = getPointingTowards(state); return (isStateBackwards(state) ? pointingTo.getOpposite() : pointingTo).getNormal(); } @@ -75,7 +109,7 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl } @Override - protected BlockState updateDir(World world, BlockPos pos, BlockState state, boolean p_208489_4_) { + protected BlockState updateDir(Level 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; @@ -105,24 +139,24 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl return reversedUpdatedState; } - private static void decelerateCart(BlockPos pos, AbstractMinecartEntity cart) { - Vector3d diff = VecHelper.getCenterOf(pos) + private static void decelerateCart(BlockPos pos, AbstractMinecart cart) { + Vec3 diff = VecHelper.getCenterOf(pos) .subtract(cart.position()); cart.setDeltaMovement(diff.x / 16f, 0, diff.z / 16f); - if (cart instanceof FurnaceMinecartEntity) { - FurnaceMinecartEntity fme = (FurnaceMinecartEntity) cart; + if (cart instanceof MinecartFurnace) { + MinecartFurnace fme = (MinecartFurnace) cart; fme.xPush = fme.zPush = 0; } } - private static boolean isStableWith(BlockState testState, IBlockReader world, BlockPos pos) { + private static boolean isStableWith(BlockState testState, BlockGetter world, BlockPos pos) { return canSupportRigidBlock(world, pos.below()) && (!testState.getValue(SHAPE) .isAscending() || canSupportRigidBlock(world, pos.relative(getPointingTowards(testState)))); } @Override - public BlockState getStateForPlacement(BlockItemUseContext p_196258_1_) { + public BlockState getStateForPlacement(BlockPlaceContext p_196258_1_) { Direction direction = p_196258_1_.getHorizontalDirection(); BlockState base = super.getStateForPlacement(p_196258_1_); return (base == null ? defaultBlockState() : base).setValue(BACKWARDS, @@ -135,24 +169,24 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl } @Override - protected void createBlockStateDefinition(StateContainer.Builder p_206840_1_) { + protected void createBlockStateDefinition(StateDefinition.Builder p_206840_1_) { p_206840_1_.add(SHAPE, POWER, BACKWARDS); } @Override - public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) { + public void onMinecartPass(BlockState state, Level world, BlockPos pos, AbstractMinecart cart) { if (world.isClientSide) return; - Vector3d accelerationVec = Vector3d.atLowerCornerOf(getAccelerationVector(state)); + Vec3 accelerationVec = Vec3.atLowerCornerOf(getAccelerationVector(state)); double targetSpeed = cart.getMaxSpeedWithRail() * state.getValue(POWER) / 15f; - if (cart instanceof FurnaceMinecartEntity) { - FurnaceMinecartEntity fme = (FurnaceMinecartEntity) cart; + if (cart instanceof MinecartFurnace) { + MinecartFurnace fme = (MinecartFurnace) cart; fme.xPush = accelerationVec.x; fme.zPush = accelerationVec.z; } - Vector3d motion = cart.getDeltaMovement(); + Vec3 motion = cart.getDeltaMovement(); if ((motion.dot(accelerationVec) >= 0 || motion.lengthSqr() < 0.0001) && targetSpeed > 0) cart.setDeltaMovement(accelerationVec.scale(targetSpeed)); else @@ -160,13 +194,13 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl } @Override - protected void updateState(BlockState state, World world, BlockPos pos, Block block) { + protected void updateState(BlockState state, Level world, BlockPos pos, Block block) { int newPower = calculatePower(world, pos); if (state.getValue(POWER) != newPower) placeAndNotify(state.setValue(POWER, newPower), pos, world); } - private int calculatePower(World world, BlockPos pos) { + private int calculatePower(Level world, BlockPos pos) { int newPower = world.getBestNeighborSignal(pos); if (newPower != 0) return newPower; @@ -206,32 +240,32 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl if (forwardPower == 0 && backwardsDistance <= 8) return backwardsPower; if (backwardsPower != 0 && forwardPower != 0) - return MathHelper.ceil((backwardsPower * forwardDistance + forwardPower * backwardsDistance) + return Mth.ceil((backwardsPower * forwardDistance + forwardPower * backwardsDistance) / (double) (forwardDistance + backwardsDistance)); return 0; } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getLevel(); + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + Level world = context.getLevel(); if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; BlockPos pos = context.getClickedPos(); for (Rotation testRotation : new Rotation[] { Rotation.CLOCKWISE_90, Rotation.CLOCKWISE_180, Rotation.COUNTERCLOCKWISE_90 }) { BlockState testState = rotate(state, testRotation); if (isStableWith(testState, world, pos)) { placeAndNotify(testState, pos, world); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } } BlockState testState = state.setValue(BACKWARDS, !state.getValue(BACKWARDS)); if (isStableWith(testState, world, pos)) placeAndNotify(testState, pos, world); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - private void placeAndNotify(BlockState state, BlockPos pos, World world) { + private void placeAndNotify(BlockState state, BlockPos pos, Level world) { world.setBlock(pos, state, 3); world.updateNeighborsAt(pos.below(), this); if (state.getValue(SHAPE) @@ -240,11 +274,11 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl } @Nullable - private BlockPos findNextRail(BlockPos from, IBlockReader world, boolean reversed) { + private BlockPos findNextRail(BlockPos from, BlockGetter world, boolean reversed) { BlockState current = world.getBlockState(from); if (!(current.getBlock() instanceof ControllerRailBlock)) return null; - Vector3i accelerationVec = getAccelerationVector(current); + Vec3i accelerationVec = getAccelerationVector(current); BlockPos baseTestPos = reversed ? from.subtract(accelerationVec) : from.offset(accelerationVec); for (BlockPos testPos : Iterate.hereBelowAndAbove(baseTestPos)) { if (testPos.getY() > from.getY() && !current.getValue(SHAPE) @@ -264,7 +298,7 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl } @Override - public int getAnalogOutputSignal(BlockState state, World world, BlockPos pos) { + public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) { return state.getValue(POWER); } 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 0cdda2aa0..d8510c7bb 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 @@ -5,10 +5,10 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.Property; -import net.minecraft.state.properties.RailShape; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.properties.RailShape; import net.minecraftforge.client.model.generators.ModelFile; public class ControllerRailGenerator extends SpecialBlockStateGen { 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 22eb42a2d..bc4a84337 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 @@ -2,30 +2,32 @@ package com.simibubi.create.content.contraptions.components.tracks; import javax.annotation.Nonnull; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.Property; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.RailShape; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.NonNullList; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; -public class ReinforcedRailBlock extends AbstractRailBlock { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class ReinforcedRailBlock extends BaseRailBlock { public static Property RAIL_SHAPE = EnumProperty.create("shape", RailShape.class, RailShape.EAST_WEST, RailShape.NORTH_SOUTH); @@ -38,7 +40,7 @@ public class ReinforcedRailBlock extends AbstractRailBlock { } @Override - public void fillItemCategory(ItemGroup p_149666_1_, NonNullList p_149666_2_) { + public void fillItemCategory(CreativeModeTab p_149666_1_, NonNullList p_149666_2_) { // TODO re-add when finished } @@ -55,25 +57,25 @@ public class ReinforcedRailBlock extends AbstractRailBlock { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { 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 - public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos) { + public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull BlockGetter world, @Nonnull BlockPos pos) { return false; } @Override - protected void updateState(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Block block) { + protected void updateState(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Block block) { super.updateState(state, world, pos, block); world.setBlockAndUpdate(pos, updateDir(world, pos, state, true)); } @Override @Nonnull - protected BlockState updateDir(@Nonnull World world, BlockPos pos, BlockState state, + protected BlockState updateDir(@Nonnull Level world, BlockPos pos, BlockState state, boolean p_208489_4_) { boolean alongX = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST; @@ -88,18 +90,18 @@ public class ReinforcedRailBlock extends AbstractRailBlock { @Override @Nonnull - public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos, - ISelectionContext context) { //FIXME - if (context.getEntity() instanceof AbstractMinecartEntity) - return VoxelShapes.empty(); + public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull BlockGetter worldIn, @Nonnull BlockPos pos, + CollisionContext context) { //FIXME + if (context.getEntity() instanceof AbstractMinecart) + return Shapes.empty(); return getShape(state, worldIn, pos, null); } @Override @Nonnull - public VoxelShape getShape(BlockState state, @Nonnull IBlockReader reader, @Nonnull BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, @Nonnull BlockGetter reader, @Nonnull BlockPos pos, CollisionContext context) { 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))); + return Shapes.or(box(0, -2, 0, 16, 2, 16), Shapes.or(box(0, -2, 0, alongX ? 16 : -1, 12, alongX ? -1 : 16), box(alongX ? 0 : 17, -2, alongX ? 17 : 0, 16, 12, 16))); } @Override @@ -115,14 +117,14 @@ public class ReinforcedRailBlock extends AbstractRailBlock { }*/ @Override - public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { - return !(world.getBlockState(pos.below()).getBlock() instanceof AbstractRailBlock || world.getBlockState(pos.above()).getBlock() instanceof AbstractRailBlock); + public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { + return !(world.getBlockState(pos.below()).getBlock() instanceof BaseRailBlock || world.getBlockState(pos.above()).getBlock() instanceof BaseRailBlock); } @Override - public void neighborChanged(@Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull Block block, @Nonnull BlockPos pos2, boolean p_220069_6_) { + public void neighborChanged(@Nonnull BlockState state, Level world, @Nonnull BlockPos pos, @Nonnull Block block, @Nonnull BlockPos pos2, boolean p_220069_6_) { if (!world.isClientSide) { - if ((world.getBlockState(pos.below()).getBlock() instanceof AbstractRailBlock)) { + if ((world.getBlockState(pos.below()).getBlock() instanceof BaseRailBlock)) { if (!p_220069_6_) { dropResources(state, world, pos); } 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 f4cbc379f..be6237781 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 @@ -7,23 +7,25 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class TurntableBlock extends KineticBlock implements ITE { @@ -32,22 +34,22 @@ public class TurntableBlock extends KineticBlock implements ITE 0) @@ -60,14 +62,14 @@ public class TurntableBlock extends KineticBlock implements ITE 1/4f) - speed *= MathHelper.clamp((1/2f - offset.length()) * 2, 0, 1); + speed *= Mth.clamp((1/2f - offset.length()) * 2, 0, 1); 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/turntable/TurntableTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/turntable/TurntableTileEntity.java index a23f4d811..1a778670f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/turntable/TurntableTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/turntable/TurntableTileEntity.java @@ -2,11 +2,11 @@ package com.simibubi.create.content.contraptions.components.turntable; import com.simibubi.create.content.contraptions.base.KineticTileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.entity.BlockEntityType; public class TurntableTileEntity extends KineticTileEntity { - public TurntableTileEntity(TileEntityType type) { + public TurntableTileEntity(BlockEntityType type) { super(type); } 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 e801e40c4..e5a49a6a5 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 @@ -14,23 +14,25 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.BubbleColumnBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.BubbleColumnBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -41,17 +43,17 @@ public class WaterWheelBlock extends DirectionalKineticBlock implements ITE { double flowStrength = 0; @@ -151,17 +153,17 @@ public class WaterWheelBlock extends DirectionalKineticBlock implements ITE tolerance) facing = Direction.DOWN; - else if (Vector3d.atLowerCornerOf(Direction.UP.getNormal()) + else if (Vec3.atLowerCornerOf(Direction.UP.getNormal()) .dot(lookVec.normalize()) > tolerance) facing = Direction.UP; else @@ -191,7 +193,7 @@ public class WaterWheelBlock extends DirectionalKineticBlock implements ITE flows; - public WaterWheelTileEntity(TileEntityType type) { + public WaterWheelTileEntity(BlockEntityType type) { super(type); flows = new HashMap<>(); for (Direction d : Iterate.directions) @@ -27,7 +27,7 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); if (compound.contains("Flows")) { for (Direction d : Iterate.directions) @@ -37,13 +37,13 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity { } @Override - public AxisAlignedBB makeRenderBoundingBox() { - return new AxisAlignedBB(worldPosition).inflate(1); + public AABB makeRenderBoundingBox() { + return new AABB(worldPosition).inflate(1); } @Override - public void write(CompoundNBT compound, boolean clientPacket) { - CompoundNBT flows = new CompoundNBT(); + public void write(CompoundTag compound, boolean clientPacket) { + CompoundTag flows = new CompoundTag(); for (Direction d : Iterate.directions) flows.putFloat(d.getSerializedName(), this.flows.get(d)); compound.put("Flows", flows); 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 22aa2cd07..34ff8b8b7 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 @@ -6,8 +6,8 @@ import java.util.function.Predicate; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.BlockFace; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -51,9 +51,9 @@ public abstract class FlowSource { public abstract boolean isEndpoint(); - public void manageSource(World world) {} + public void manageSource(Level world) {} - public void whileFlowPresent(World world, boolean pulling) {} + public void whileFlowPresent(Level world, boolean pulling) {} public LazyOptional provideHandler() { return EMPTY; @@ -67,10 +67,10 @@ public abstract class FlowSource { fluidHandler = EMPTY; } - public void manageSource(World world) { + public void manageSource(Level world) { if (fluidHandler.isPresent() && world.getGameTime() % 20 != 0) return; - TileEntity tileEntity = world.getBlockEntity(location.getConnectedPos()); + BlockEntity tileEntity = world.getBlockEntity(location.getConnectedPos()); if (tileEntity != null) fluidHandler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, location.getOppositeFace()); @@ -95,7 +95,7 @@ public abstract class FlowSource { } @Override - public void manageSource(World world) { + public void manageSource(Level world) { if (cached != null && cached.get() != null && !cached.get().tileEntity.isRemoved()) return; cached = null; 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 211e5964a..08bd310f7 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 @@ -2,22 +2,24 @@ package com.simibubi.create.content.contraptions.fluids; import com.simibubi.create.Create; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.GlassBottleItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.BottleItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.tags.FluidTags; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.world.item.Item.Properties; + @EventBusSubscriber public class FluidBottleItemHook extends Item { @@ -30,15 +32,15 @@ public class FluidBottleItemHook extends Item { ItemStack itemStack = event.getItemStack(); if (itemStack.isEmpty()) return; - if (!(itemStack.getItem() instanceof GlassBottleItem)) + if (!(itemStack.getItem() instanceof BottleItem)) return; - World world = event.getWorld(); - PlayerEntity player = event.getPlayer(); - RayTraceResult raytraceresult = getPlayerPOVHitResult(world, player, RayTraceContext.FluidMode.SOURCE_ONLY); - if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) + Level world = event.getWorld(); + Player player = event.getPlayer(); + HitResult raytraceresult = getPlayerPOVHitResult(world, player, ClipContext.Fluid.SOURCE_ONLY); + if (raytraceresult.getType() != HitResult.Type.BLOCK) return; - BlockPos blockpos = ((BlockRayTraceResult) raytraceresult).getBlockPos(); + BlockPos blockpos = ((BlockHitResult) raytraceresult).getBlockPos(); if (!world.mayInteract(player, blockpos)) return; @@ -47,7 +49,7 @@ public class FluidBottleItemHook extends Item { .getRegistryName() .getNamespace() .equals(Create.ID)) { - event.setCancellationResult(ActionResultType.PASS); + event.setCancellationResult(InteractionResult.PASS); event.setCanceled(true); return; } 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 8fb4b209f..17ba04b79 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 @@ -8,16 +8,16 @@ import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.particles.BlockParticleData; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; public class FluidFX { @@ -34,22 +34,22 @@ public class FluidFX { return; } - BlockParticleData blockParticleData = new BlockParticleData(ParticleTypes.BLOCK, defaultState.createLegacyBlock()); - Vector3d center = VecHelper.getCenterOf(pos); + BlockParticleOption blockParticleData = new BlockParticleOption(ParticleTypes.BLOCK, defaultState.createLegacyBlock()); + Vec3 center = VecHelper.getCenterOf(pos); for (int i = 0; i < 20; i++) { - Vector3d v = VecHelper.offsetRandomly(Vector3d.ZERO, r, .25f); + Vec3 v = VecHelper.offsetRandomly(Vec3.ZERO, r, .25f); particle(blockParticleData, center.add(v), v); } } - public static IParticleData getFluidParticle(FluidStack fluid) { + public static ParticleOptions getFluidParticle(FluidStack fluid) { return new FluidParticleData(AllParticleTypes.FLUID_PARTICLE.get(), fluid); } - public static IParticleData getDrippingParticle(FluidStack fluid) { - IParticleData particle = null; + public static ParticleOptions getDrippingParticle(FluidStack fluid) { + ParticleOptions particle = null; if (FluidHelper.isWater(fluid.getFluid())) particle = ParticleTypes.DRIPPING_WATER; if (FluidHelper.isLava(fluid.getFluid())) @@ -59,30 +59,30 @@ public class FluidFX { return particle; } - public static void spawnRimParticles(World world, BlockPos pos, Direction side, int amount, IParticleData particle, + public static void spawnRimParticles(Level world, BlockPos pos, Direction side, int amount, ParticleOptions particle, float rimRadius) { - Vector3d directionVec = Vector3d.atLowerCornerOf(side.getNormal()); + Vec3 directionVec = Vec3.atLowerCornerOf(side.getNormal()); for (int i = 0; i < amount; i++) { - Vector3d vec = VecHelper.offsetRandomly(Vector3d.ZERO, r, 1) + Vec3 vec = VecHelper.offsetRandomly(Vec3.ZERO, r, 1) .normalize(); vec = VecHelper.clampComponentWise(vec, rimRadius) .multiply(VecHelper.axisAlingedPlaneOf(directionVec)) .add(directionVec.scale(.45 + r.nextFloat() / 16f)); - Vector3d m = vec.scale(.05f); + Vec3 m = vec.scale(.05f); vec = vec.add(VecHelper.getCenterOf(pos)); world.addAlwaysVisibleParticle(particle, vec.x, vec.y - 1 / 16f, vec.z, m.x, m.y, m.z); } } - public static void spawnPouringLiquid(World world, BlockPos pos, int amount, IParticleData particle, - float rimRadius, Vector3d directionVec, boolean inbound) { + public static void spawnPouringLiquid(Level world, BlockPos pos, int amount, ParticleOptions particle, + float rimRadius, Vec3 directionVec, boolean inbound) { for (int i = 0; i < amount; i++) { - Vector3d vec = VecHelper.offsetRandomly(Vector3d.ZERO, r, rimRadius * .75f); + Vec3 vec = VecHelper.offsetRandomly(Vec3.ZERO, r, rimRadius * .75f); vec = vec.multiply(VecHelper.axisAlingedPlaneOf(directionVec)) .add(directionVec.scale(.5 + r.nextFloat() / 4f)); - Vector3d m = vec.scale(1 / 4f); - Vector3d centerOf = VecHelper.getCenterOf(pos); + Vec3 m = vec.scale(1 / 4f); + Vec3 centerOf = VecHelper.getCenterOf(pos); vec = vec.add(centerOf); if (inbound) { vec = vec.add(m); @@ -94,11 +94,11 @@ public class FluidFX { } } - private static void particle(IParticleData data, Vector3d pos, Vector3d motion) { + private static void particle(ParticleOptions data, Vec3 pos, Vec3 motion) { world().addParticle(data, pos.x, pos.y, pos.z, motion.x, motion.y, motion.z); } - private static World world() { + private static Level world() { return Minecraft.getInstance().level; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidNetwork.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidNetwork.java index eedcc0cd9..156f65405 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidNetwork.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidNetwork.java @@ -20,9 +20,9 @@ import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -32,7 +32,7 @@ public class FluidNetwork { private static int CYCLES_PER_TICK = 16; - World world; + Level world; BlockFace start; Supplier> sourceSupplier; @@ -47,7 +47,7 @@ public class FluidNetwork { List>> targets; Map> cache; - public FluidNetwork(World world, BlockFace location, Supplier> sourceSupplier) { + public FluidNetwork(Level world, BlockFace location, Supplier> sourceSupplier) { this.world = world; this.start = location; this.sourceSupplier = sourceSupplier; 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 cf4d8f3a7..cb3349cb5 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 @@ -17,23 +17,23 @@ import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FlowingFluidBlock; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; public class FluidPropagator { - public static void propagateChangedPipe(IWorld world, BlockPos pipePos, BlockState pipeState) { + public static void propagateChangedPipe(LevelAccessor world, BlockPos pipePos, BlockState pipeState) { List> frontier = new ArrayList<>(); Set visited = new HashSet<>(); Set> discoveredPumps = new HashSet<>(); @@ -58,7 +58,7 @@ public class FluidPropagator { if (!world.isAreaLoaded(target, 0)) continue; - TileEntity tileEntity = world.getBlockEntity(target); + BlockEntity tileEntity = world.getBlockEntity(target); BlockState targetState = world.getBlockState(target); if (tileEntity instanceof PumpTileEntity) { if (!AllBlocks.MECHANICAL_PUMP.has(targetState) || targetState.getValue(PumpBlock.FACING) @@ -84,7 +84,7 @@ public class FluidPropagator { .updatePipesOnSide(pair.getSecond())); } - public static void resetAffectedFluidNetworks(World world, BlockPos start, Direction side) { + public static void resetAffectedFluidNetworks(Level world, BlockPos start, Direction side) { List frontier = new ArrayList<>(); Set visited = new HashSet<>(); frontier.add(start); @@ -121,7 +121,7 @@ public class FluidPropagator { } } - public static Direction validateNeighbourChange(BlockState state, World world, BlockPos pos, Block otherBlock, + public static Direction validateNeighbourChange(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { if (world.isClientSide) return null; @@ -131,7 +131,7 @@ public class FluidPropagator { return null; if (otherBlock instanceof PumpBlock) return null; - if (otherBlock instanceof FlowingFluidBlock) + if (otherBlock instanceof LiquidBlock) return null; if (getStraightPipeAxis(state) == null) return null; @@ -144,11 +144,11 @@ public class FluidPropagator { return null; } - public static FluidTransportBehaviour getPipe(IBlockReader reader, BlockPos pos) { + public static FluidTransportBehaviour getPipe(BlockGetter reader, BlockPos pos) { return TileEntityBehaviour.get(reader, pos, FluidTransportBehaviour.TYPE); } - public static boolean isOpenEnd(IBlockReader reader, BlockPos pos, Direction side) { + public static boolean isOpenEnd(BlockGetter reader, BlockPos pos, Direction side) { BlockPos connectedPos = pos.relative(side); BlockState connectedState = reader.getBlockState(connectedPos); FluidTransportBehaviour pipe = FluidPropagator.getPipe(reader, connectedPos); @@ -203,8 +203,8 @@ public class FluidPropagator { // .lineWidth(1 / 16f); // } - public static boolean hasFluidCapability(IBlockReader world, BlockPos pos, Direction side) { - TileEntity tileEntity = world.getBlockEntity(pos); + public static boolean hasFluidCapability(BlockGetter world, BlockPos pos, Direction side) { + BlockEntity tileEntity = world.getBlockEntity(pos); return tileEntity != null && tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side) .isPresent(); } 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 9c249f8fd..cf14a0a20 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 @@ -5,19 +5,19 @@ import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.utility.BlockHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; import net.minecraft.tags.FluidTags; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; public class FluidReactions { - public static void handlePipeFlowCollision(World world, BlockPos pos, FluidStack fluid, FluidStack fluid2) { + public static void handlePipeFlowCollision(Level world, BlockPos pos, FluidStack fluid, FluidStack fluid2) { Fluid f1 = fluid.getFluid(); Fluid f2 = fluid2.getFluid(); BlockHelper.destroyBlock(world, pos, 1); @@ -38,7 +38,7 @@ public class FluidReactions { } } - public static void handlePipeSpillCollision(World world, BlockPos pos, Fluid pipeFluid, FluidState worldFluid) { + public static void handlePipeSpillCollision(Level world, BlockPos pos, Fluid pipeFluid, FluidState worldFluid) { Fluid pf = FluidHelper.convertToStill(pipeFluid); Fluid wf = worldFluid.getType(); if (pf.is(FluidTags.WATER) && wf == Fluids.LAVA) 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 0d7bb5199..77964b4d4 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 @@ -16,13 +16,13 @@ import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.WorldAttached; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; public abstract class FluidTransportBehaviour extends TileEntityBehaviour { @@ -58,7 +58,7 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { @Override public void tick() { super.tick(); - World world = getWorld(); + Level world = getWorld(); BlockPos pos = getPos(); boolean onServer = !world.isClientSide || tileEntity.isVirtual(); @@ -140,7 +140,7 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { } @Override - public void read(CompoundNBT nbt, boolean clientPacket) { + public void read(CompoundTag nbt, boolean clientPacket) { super.read(nbt, clientPacket); if (interfaces == null) interfaces = new IdentityHashMap<>(); @@ -159,7 +159,7 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { } @Override - public void write(CompoundNBT nbt, boolean clientPacket) { + public void write(CompoundTag nbt, boolean clientPacket) { super.write(nbt, clientPacket); if (clientPacket) createConnectionData(); @@ -233,7 +233,7 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { interfaces.put(d, new PipeConnection(d)); } - public AttachmentTypes getRenderedRimAttachment(IBlockDisplayReader world, BlockPos pos, BlockState state, + public AttachmentTypes getRenderedRimAttachment(BlockAndTintGetter world, BlockPos pos, BlockState state, Direction direction) { if (!canHaveFlowToward(state, direction)) return AttachmentTypes.NONE; @@ -274,14 +274,14 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { public static final WorldAttached>> interfaceTransfer = new WorldAttached<>($ -> new HashMap<>()); - public static void cacheFlows(IWorld world, BlockPos pos) { + public static void cacheFlows(LevelAccessor world, BlockPos pos) { FluidTransportBehaviour pipe = TileEntityBehaviour.get(world, pos, FluidTransportBehaviour.TYPE); if (pipe != null) interfaceTransfer.get(world) .put(pos, pipe.interfaces); } - public static void loadFlows(IWorld world, BlockPos pos) { + public static void loadFlows(LevelAccessor world, BlockPos pos) { FluidTransportBehaviour newPipe = TileEntityBehaviour.get(world, pos, FluidTransportBehaviour.TYPE); if (newPipe != null) newPipe.interfaces = interfaceTransfer.get(world) 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 47e344737..2bddd3a0a 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,7 +1,7 @@ package com.simibubi.create.content.contraptions.fluids; import static net.minecraft.state.properties.BlockStateProperties.LEVEL_HONEY; -import static net.minecraft.state.properties.BlockStateProperties.WATERLOGGED; +import staticnet.minecraft.world.level.block.state.properties.BlockStatePropertiess.WATERLOGGED; import java.util.ArrayList; import java.util.List; @@ -15,30 +15,32 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.utility.BlockFace; -import net.minecraft.block.BlockState; -import net.minecraft.block.FlowingFluidBlock; -import net.minecraft.entity.LivingEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.potion.Effect; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.PotionUtils; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.tags.FluidTags; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.common.Tags; import net.minecraftforge.common.util.LazyOptional; 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 { private static final List EFFECT_HANDLERS = new ArrayList<>(); @@ -48,23 +50,23 @@ public class OpenEndedPipe extends FlowSource { registerEffectHandler(new MilkEffectHandler()); } - private World world; + private Level world; private BlockPos pos; - private AxisAlignedBB aoe; + private AABB aoe; private OpenEndFluidHandler fluidHandler; private BlockPos outputPos; private boolean wasPulling; private FluidStack cachedFluid; - private List cachedEffects; + private List cachedEffects; public OpenEndedPipe(BlockFace face) { super(face); fluidHandler = new OpenEndFluidHandler(); outputPos = face.getConnectedPos(); pos = face.getPos(); - aoe = new AxisAlignedBB(outputPos).expandTowards(0, -1, 0); + aoe = new AABB(outputPos).expandTowards(0, -1, 0); if (face.getFace() == Direction.DOWN) aoe = aoe.expandTowards(0, -1, 0); } @@ -73,7 +75,7 @@ public class OpenEndedPipe extends FlowSource { EFFECT_HANDLERS.add(handler); } - public World getWorld() { + public Level getWorld() { return world; } @@ -85,12 +87,12 @@ public class OpenEndedPipe extends FlowSource { return outputPos; } - public AxisAlignedBB getAOE() { + public AABB getAOE() { return aoe; } @Override - public void manageSource(World world) { + public void manageSource(Level world) { this.world = world; } @@ -104,15 +106,15 @@ public class OpenEndedPipe extends FlowSource { return true; } - public CompoundNBT serializeNBT() { - CompoundNBT compound = new CompoundNBT(); + public CompoundTag serializeNBT() { + CompoundTag compound = new CompoundTag(); fluidHandler.writeToNBT(compound); compound.putBoolean("Pulling", wasPulling); compound.put("Location", location.serializeNBT()); return compound; } - public static OpenEndedPipe fromNBT(CompoundNBT compound, BlockPos tilePos) { + public static OpenEndedPipe fromNBT(CompoundTag compound, BlockPos tilePos) { BlockFace fromNBT = BlockFace.fromNBT(compound.getCompound("Location")); OpenEndedPipe oep = new OpenEndedPipe(new BlockFace(tilePos, fromNBT.getFace())); oep.fluidHandler.readFromNBT(compound); @@ -158,7 +160,7 @@ public class OpenEndedPipe extends FlowSource { return stack; } world.setBlock(outputPos, fluidState.createLegacyBlock() - .setValue(FlowingFluidBlock.LEVEL, 14), 3); + .setValue(LiquidBlock.LEVEL, 14), 3); return stack; } @@ -202,7 +204,7 @@ public class OpenEndedPipe extends FlowSource { int i = outputPos.getX(); int j = outputPos.getY(); int k = outputPos.getZ(); - world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, + world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); return true; } @@ -356,12 +358,12 @@ public class OpenEndedPipe extends FlowSource { List list = pipe.getWorld().getEntitiesOfClass(LivingEntity.class, pipe.getAOE(), LivingEntity::isAffectedByPotions); for (LivingEntity livingentity : list) { - for (EffectInstance effectinstance : pipe.cachedEffects) { - Effect effect = effectinstance.getEffect(); + for (MobEffectInstance effectinstance : pipe.cachedEffects) { + MobEffect effect = effectinstance.getEffect(); if (effect.isInstantenous()) { effect.applyInstantenousEffect(null, null, livingentity, effectinstance.getAmplifier(), 0.5D); } else { - livingentity.addEffect(new EffectInstance(effectinstance)); + livingentity.addEffect(new MobEffectInstance(effectinstance)); } } } @@ -376,7 +378,7 @@ public class OpenEndedPipe extends FlowSource { @Override public void applyEffects(OpenEndedPipe pipe, FluidStack fluid) { - World world = pipe.getWorld(); + Level world = pipe.getWorld(); if (world.getGameTime() % 5 != 0) return; List list = 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 686d00915..52242d9dc 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 @@ -13,13 +13,13 @@ import com.simibubi.create.foundation.block.connected.BakedModelWrapperWithData; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelDataMap.Builder; @@ -29,12 +29,12 @@ public class PipeAttachmentModel extends BakedModelWrapperWithData { private static ModelProperty PIPE_PROPERTY = new ModelProperty<>(); - public PipeAttachmentModel(IBakedModel template) { + public PipeAttachmentModel(BakedModel template) { super(template); } @Override - protected Builder gatherModelData(Builder builder, IBlockDisplayReader world, BlockPos pos, BlockState state) { + protected Builder gatherModelData(Builder builder, BlockAndTintGetter world, BlockPos pos, BlockState state) { PipeModelData data = new PipeModelData(); FluidTransportBehaviour transport = TileEntityBehaviour.get(world, pos, FluidTransportBehaviour.TYPE); BracketedTileEntityBehaviour bracket = TileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE); @@ -73,7 +73,7 @@ public class PipeAttachmentModel extends BakedModelWrapperWithData { if (pipeData.isEncased()) quads.addAll(AllBlockPartials.FLUID_PIPE_CASING.get() .getQuads(state, side, rand, data)); - IBakedModel bracket = pipeData.getBracket(); + BakedModel bracket = pipeData.getBracket(); if (bracket != null) quads.addAll(bracket.getQuads(state, side, rand, data)); } @@ -81,7 +81,7 @@ public class PipeAttachmentModel extends BakedModelWrapperWithData { private class PipeModelData { AttachmentTypes[] rims; boolean encased; - IBakedModel bracket; + BakedModel bracket; public PipeModelData() { rims = new AttachmentTypes[6]; @@ -94,7 +94,7 @@ public class PipeAttachmentModel extends BakedModelWrapperWithData { .getBlockModel(state); } - public IBakedModel getBracket() { + public BakedModel getBracket() { return bracket; } 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 3ef881ba0..7d12c1d9f 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 @@ -14,16 +14,16 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.FloatNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.particles.IParticleData; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.Entity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.FloatTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.Constants.NBT; @@ -81,14 +81,14 @@ public class PipeConnection { return true; } - public void manageSource(World world, BlockPos pos) { + public void manageSource(Level world, BlockPos pos) { if (!source.isPresent() && !determineSource(world, pos)) return; FlowSource flowSource = source.get(); flowSource.manageSource(world); } - public boolean manageFlows(World world, BlockPos pos, FluidStack internalFluid, + public boolean manageFlows(Level world, BlockPos pos, FluidStack internalFluid, Predicate extractionPredicate) { // Only keep network if still valid @@ -159,7 +159,7 @@ public class PipeConnection { return true; } - private boolean determineSource(World world, BlockPos pos) { + private boolean determineSource(Level world, BlockPos pos) { if (!world.isAreaLoaded(pos, 1)) return false; BlockFace location = new BlockFace(pos, side); @@ -183,7 +183,7 @@ public class PipeConnection { return true; } - public void tickFlowProgress(World world, BlockPos pos) { + public void tickFlowProgress(Level world, BlockPos pos) { if (!hasFlow()) return; Flow flow = this.flow.get(); @@ -200,7 +200,7 @@ public class PipeConnection { particleSplashNextTick = false; } - float flowSpeed = 1 / 32f + MathHelper.clamp(pressure.get(flow.inbound) / 512f, 0, 1) * 31 / 32f; + float flowSpeed = 1 / 32f + Mth.clamp(pressure.get(flow.inbound) / 512f, 0, 1) * 31 / 32f; flow.progress.setValue(Math.min(flow.progress.getValue() + flowSpeed, 1)); if (flow.progress.getValue() >= 1) { flow.complete = true; @@ -209,14 +209,14 @@ public class PipeConnection { } } - public void serializeNBT(CompoundNBT tag, boolean clientPacket) { - CompoundNBT connectionData = new CompoundNBT(); + public void serializeNBT(CompoundTag tag, boolean clientPacket) { + CompoundTag connectionData = new CompoundTag(); tag.put(side.getName(), connectionData); if (hasPressure()) { - ListNBT pressureData = new ListNBT(); - pressureData.add(FloatNBT.valueOf(getInboundPressure())); - pressureData.add(FloatNBT.valueOf(getOutwardPressure())); + ListTag pressureData = new ListTag(); + pressureData.add(FloatTag.valueOf(getInboundPressure())); + pressureData.add(FloatTag.valueOf(getOutwardPressure())); connectionData.put("Pressure", pressureData); } @@ -224,7 +224,7 @@ public class PipeConnection { connectionData.put("OpenEnd", ((OpenEndedPipe) source.get()).serializeNBT()); if (hasFlow()) { - CompoundNBT flowData = new CompoundNBT(); + CompoundTag flowData = new CompoundTag(); Flow flow = this.flow.get(); flow.fluid.writeToNBT(flowData); flowData.putBoolean("In", flow.inbound); @@ -239,11 +239,11 @@ public class PipeConnection { return source.orElse(null) instanceof OpenEndedPipe; } - public void deserializeNBT(CompoundNBT tag, BlockPos tilePos, boolean clientPacket) { - CompoundNBT connectionData = tag.getCompound(side.getName()); + public void deserializeNBT(CompoundTag tag, BlockPos tilePos, boolean clientPacket) { + CompoundTag connectionData = tag.getCompound(side.getName()); if (connectionData.contains("Pressure")) { - ListNBT pressureData = connectionData.getList("Pressure", NBT.TAG_FLOAT); + ListTag pressureData = connectionData.getList("Pressure", NBT.TAG_FLOAT); pressure = Couple.create(pressureData.getFloat(0), pressureData.getFloat(1)); } else pressure.replace(f -> 0f); @@ -253,7 +253,7 @@ public class PipeConnection { source = Optional.of(OpenEndedPipe.fromNBT(connectionData.getCompound("OpenEnd"), tilePos)); if (connectionData.contains("Flow")) { - CompoundNBT flowData = connectionData.getCompound("Flow"); + CompoundTag flowData = connectionData.getCompound("Flow"); FluidStack fluid = FluidStack.loadFluidStackFromNBT(flowData); boolean inbound = flowData.getBoolean("In"); if (!flow.isPresent()) { @@ -357,16 +357,16 @@ public class PipeConnection { public static final float RIM_RADIUS = 1 / 4f + 1 / 64f; public static final Random r = new Random(); - public void spawnSplashOnRim(World world, BlockPos pos, FluidStack fluid) { + public void spawnSplashOnRim(Level world, BlockPos pos, FluidStack fluid) { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> spawnSplashOnRimInner(world, pos, fluid)); } - public void spawnParticles(World world, BlockPos pos, FluidStack fluid) { + public void spawnParticles(Level world, BlockPos pos, FluidStack fluid) { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> spawnParticlesInner(world, pos, fluid)); } @OnlyIn(Dist.CLIENT) - private void spawnParticlesInner(World world, BlockPos pos, FluidStack fluid) { + private void spawnParticlesInner(Level world, BlockPos pos, FluidStack fluid) { if (world == Minecraft.getInstance().level) if (!isRenderEntityWithinDistance(pos)) return; @@ -377,7 +377,7 @@ public class PipeConnection { } @OnlyIn(Dist.CLIENT) - private void spawnSplashOnRimInner(World world, BlockPos pos, FluidStack fluid) { + private void spawnSplashOnRimInner(Level world, BlockPos pos, FluidStack fluid) { if (world == Minecraft.getInstance().level) if (!isRenderEntityWithinDistance(pos)) return; @@ -385,20 +385,20 @@ public class PipeConnection { } @OnlyIn(Dist.CLIENT) - private void spawnRimParticles(World world, BlockPos pos, FluidStack fluid, int amount) { + private void spawnRimParticles(Level world, BlockPos pos, FluidStack fluid, int amount) { if (hasOpenEnd()) { spawnPouringLiquid(world, pos, fluid, amount); return; } - IParticleData particle = FluidFX.getDrippingParticle(fluid); + ParticleOptions particle = FluidFX.getDrippingParticle(fluid); FluidFX.spawnRimParticles(world, pos, side, amount, particle, RIM_RADIUS); } @OnlyIn(Dist.CLIENT) - private void spawnPouringLiquid(World world, BlockPos pos, FluidStack fluid, int amount) { - IParticleData particle = FluidFX.getFluidParticle(fluid); - Vector3d directionVec = Vector3d.atLowerCornerOf(side.getNormal()); + private void spawnPouringLiquid(Level world, BlockPos pos, FluidStack fluid, int amount) { + ParticleOptions particle = FluidFX.getFluidParticle(fluid); + Vec3 directionVec = Vec3.atLowerCornerOf(side.getNormal()); if (!hasFlow()) return; Flow flow = this.flow.get(); @@ -411,7 +411,7 @@ public class PipeConnection { .getCameraEntity(); if (renderViewEntity == null) return false; - Vector3d center = VecHelper.getCenterOf(pos); + Vec3 center = VecHelper.getCenterOf(pos); if (renderViewEntity.position() .distanceTo(center) > MAX_PARTICLE_RENDER_DISTANCE) return false; 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 1caa73897..99349830f 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 @@ -7,30 +7,32 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.network.DebugPacketSender; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.TickPriority; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.network.protocol.game.DebugPackets; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.TickPriority; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; -public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable, ICogWheel { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class PumpBlock extends DirectionalKineticBlock implements SimpleWaterloggedBlock, ICogWheel { public PumpBlock(Properties p_i48415_1_) { super(p_i48415_1_); @@ -43,7 +45,7 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.MECHANICAL_PUMP.create(); } @@ -54,7 +56,7 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable } @Override - public BlockState updateAfterWrenched(BlockState newState, ItemUseContext context) { + public BlockState updateAfterWrenched(BlockState newState, UseOnContext context) { return super.updateAfterWrenched(newState, context); } @@ -65,15 +67,15 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable } @Override - public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return AllShapes.PUMP.get(state.getValue(FACING)); } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.sendNeighborsUpdatePacket(world, pos); + DebugPackets.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; @@ -96,7 +98,7 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) { if (state.getValue(BlockStateProperties.WATERLOGGED)) { world.getLiquidTicks() @@ -106,7 +108,7 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { FluidState FluidState = context.getLevel() .getFluidState(context.getClickedPos()); return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, @@ -118,7 +120,7 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) { super.onPlace(state, world, pos, oldState, isMoving); if (world.isClientSide) return; @@ -128,7 +130,7 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable if (isPump(state) && isPump(oldState) && state.getValue(FACING) == oldState.getValue(FACING) .getOpposite()) { - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity tileEntity = world.getBlockEntity(pos); if (!(tileEntity instanceof PumpTileEntity)) return; PumpTileEntity pump = (PumpTileEntity) tileEntity; @@ -142,12 +144,12 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable } @Override - public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @Override - public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); @@ -156,7 +158,7 @@ public class PumpBlock extends DirectionalKineticBlock implements IWaterLoggable } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 2b2ea5417..c97b531b9 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 @@ -2,8 +2,15 @@ package com.simibubi.create.content.contraptions.fluids; import static net.minecraft.state.properties.BlockStateProperties.FACING; -import com.jozufozu.flywheel.backend.instancing.Instancer; +import com.net.minimport com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; +import com.simibubi.create.content.contraptions.base.RotatingData; +import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockState; + +ecraft.world.level.block.state.properties.BlockStatePropertiesport com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatingData; 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 9c92d47d9..1213ae0a1 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 @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.fluids; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -9,30 +9,30 @@ import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class PumpRenderer extends KineticTileEntityRenderer { - public PumpRenderer(TileEntityRendererDispatcher dispatcher) { + public PumpRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); if (!(te instanceof PumpTileEntity)) return; PumpTileEntity pump = (PumpTileEntity) te; - Vector3d rotationOffset = new Vector3d(.5, 14 / 16f, .5); + Vec3 rotationOffset = new Vec3(.5, 14 / 16f, .5); BlockState blockState = te.getBlockState(); - float angle = MathHelper.lerp(pump.arrowDirection.getValue(partialTicks), 0, 90) - 90; + float angle = Mth.lerp(pump.arrowDirection.getValue(partialTicks), 0, 90) - 90; for (float yRot : new float[] { 0, 90 }) { ms.pushPose(); SuperByteBuffer arrow = PartialBufferer.get(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState); 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 9428867f0..87b743657 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 @@ -23,14 +23,14 @@ import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -42,7 +42,7 @@ public class PumpTileEntity extends KineticTileEntity { boolean pressureUpdate; boolean reversed; - public PumpTileEntity(TileEntityType typeIn) { + public PumpTileEntity(BlockEntityType typeIn) { super(typeIn); arrowDirection = LerpedFloat.linear() .startWithValue(1); @@ -274,10 +274,10 @@ public class PumpTileEntity extends KineticTileEntity { return atLeastOneBranchSuccessful; } - private boolean hasReachedValidEndpoint(IWorld world, BlockFace blockFace, boolean pull) { + private boolean hasReachedValidEndpoint(LevelAccessor world, BlockFace blockFace, boolean pull) { BlockPos connectedPos = blockFace.getConnectedPos(); BlockState connectedState = world.getBlockState(connectedPos); - TileEntity tileEntity = world.getBlockEntity(connectedPos); + BlockEntity tileEntity = world.getBlockEntity(connectedPos); Direction face = blockFace.getFace(); // facing a pump @@ -305,13 +305,13 @@ public class PumpTileEntity extends KineticTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("Reversed", reversed); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { reversed = compound.getBoolean("Reversed"); super.fromTag(state, compound, clientPacket); } @@ -380,7 +380,7 @@ public class PumpTileEntity extends KineticTileEntity { } @Override - public AttachmentTypes getRenderedRimAttachment(IBlockDisplayReader world, BlockPos pos, BlockState state, + public AttachmentTypes getRenderedRimAttachment(BlockAndTintGetter world, BlockPos pos, BlockState state, Direction direction) { AttachmentTypes attachment = super.getRenderedRimAttachment(world, pos, state, direction); if (attachment == AttachmentTypes.RIM) 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 c7b5c930c..ab045f890 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 @@ -1,13 +1,15 @@ package com.simibubi.create.content.contraptions.fluids; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.Item; -import net.minecraft.item.Items; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraftforge.fluids.ForgeFlowingFluid; +import net.minecraftforge.fluids.ForgeFlowingFluid.Properties; + public class VirtualFluid extends ForgeFlowingFluid { public VirtualFluid(Properties properties) { 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 314a02e88..e49bea738 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 @@ -7,9 +7,9 @@ import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRecipe; import com.simibubi.create.foundation.fluid.FluidIngredient; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.wrapper.RecipeWrapper; @@ -18,7 +18,7 @@ public class FillingBySpout { static RecipeWrapper wrapper = new RecipeWrapper(new ItemStackHandler(1)); - public static boolean canItemBeFilled(World world, ItemStack stack) { + public static boolean canItemBeFilled(Level world, ItemStack stack) { wrapper.setItem(0, stack); Optional assemblyRecipe = @@ -32,7 +32,7 @@ public class FillingBySpout { return GenericItemFilling.canItemBeFilled(world, stack); } - public static int getRequiredAmountForItem(World world, ItemStack stack, FluidStack availableFluid) { + public static int getRequiredAmountForItem(Level world, ItemStack stack, FluidStack availableFluid) { wrapper.setItem(0, stack); Optional assemblyRecipe = @@ -44,7 +44,7 @@ public class FillingBySpout { return requiredFluid.getRequiredAmount(); } - for (IRecipe recipe : world.getRecipeManager() + for (Recipe recipe : world.getRecipeManager() .getRecipesFor(AllRecipeTypes.FILLING.getType(), wrapper, world)) { FillingRecipe fillingRecipe = (FillingRecipe) recipe; FluidIngredient requiredFluid = fillingRecipe.getRequiredFluid(); @@ -54,7 +54,7 @@ public class FillingBySpout { return GenericItemFilling.getRequiredAmountForItem(world, stack, availableFluid); } - public static ItemStack fillItem(World world, int requiredAmount, ItemStack stack, FluidStack availableFluid) { + public static ItemStack fillItem(Level world, int requiredAmount, ItemStack stack, FluidStack availableFluid) { FluidStack toFill = availableFluid.copy(); toFill.setAmount(requiredAmount); @@ -65,7 +65,7 @@ public class FillingBySpout { .filter(fr -> fr.getRequiredFluid() .test(toFill)) .orElseGet(() -> { - for (IRecipe recipe : world.getRecipeManager() + for (Recipe recipe : world.getRecipeManager() .getRecipesFor(AllRecipeTypes.FILLING.getType(), wrapper, world)) { FillingRecipe fr = (FillingRecipe) recipe; FluidIngredient requiredFluid = fr.getRequiredFluid(); 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 21e3d3499..1d85000cf 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 @@ -13,12 +13,12 @@ import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuild import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.ItemLike; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidStack; @@ -31,7 +31,7 @@ public class FillingRecipe extends ProcessingRecipe implements IA } @Override - public boolean matches(RecipeWrapper inv, World p_77569_2_) { + public boolean matches(RecipeWrapper inv, Level p_77569_2_) { return ingredients.get(0) .test(inv.getItem(0)); } @@ -67,18 +67,18 @@ public class FillingRecipe extends ProcessingRecipe implements IA @Override @OnlyIn(Dist.CLIENT) - public ITextComponent getDescriptionForAssembly() { + public Component getDescriptionForAssembly() { List matchingFluidStacks = fluidIngredients.get(0) .getMatchingFluidStacks(); if (matchingFluidStacks.size() == 0) - return new StringTextComponent("Invalid"); + return new TextComponent("Invalid"); return Lang.translate("recipe.assembly.spout_filling_fluid", - new TranslationTextComponent(matchingFluidStacks.get(0) + new TranslatableComponent(matchingFluidStacks.get(0) .getTranslationKey()).getString()); } @Override - public void addRequiredMachines(Set list) { + public void addRequiredMachines(Set list) { list.add(AllBlocks.SPOUT.get()); } 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 73d864880..f46c768d9 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 @@ -15,17 +15,17 @@ import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import it.unimi.dsi.fastutil.PriorityQueue; import it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FlowingFluidBlock; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.Fluids; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; public class FluidDrainingBehaviour extends FluidManipulationBehaviour { @@ -67,9 +67,9 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { } if (affectedArea == null) - affectedArea = new MutableBoundingBox(root, root); + affectedArea = new BoundingBox(root, root); - World world = getWorld(); + Level world = getWorld(); if (!queue.isEmpty() && !isValid) { rebuildContext(root); return false; @@ -89,13 +89,13 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { 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(); + } else if (blockState.getBlock() instanceof LiquidBlock) { + LiquidBlock flowingFluid = (LiquidBlock) blockState.getBlock(); emptied = Blocks.AIR.defaultBlockState(); - if (blockState.getValue(FlowingFluidBlock.LEVEL) == 0) + if (blockState.getValue(LiquidBlock.LEVEL) == 0) fluid = flowingFluid.getFluid(); else { - affectedArea.expand(new MutableBoundingBox(currentPos, currentPos)); + affectedArea.expand(new BoundingBox(currentPos, currentPos)); if (!tileEntity.isVirtual()) world.setBlock(currentPos, emptied, 2 | 16); queue.dequeue(); @@ -107,7 +107,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { } } else if (blockState.getFluidState() .getType() != Fluids.EMPTY - && blockState.getCollisionShape(world, currentPos, ISelectionContext.empty()) + && blockState.getCollisionShape(world, currentPos, CollisionContext.empty()) .isEmpty()) { fluid = blockState.getFluidState() .getType(); @@ -139,7 +139,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { if (!tileEntity.isVirtual()) world.setBlock(currentPos, emptied, 2 | 16); - affectedArea.expand(new MutableBoundingBox(currentPos, currentPos)); + affectedArea.expand(new BoundingBox(currentPos, currentPos)); queue.dequeue(); if (queue.isEmpty()) { @@ -173,7 +173,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { tileEntity.sendData(); } - protected boolean checkValid(World world, BlockPos root) { + protected boolean checkValid(Level world, BlockPos root) { BlockPos currentPos = root; for (int timeout = 1000; timeout > 0 && !root.equals(tileEntity.getBlockPos()); timeout--) { FluidBlockType canPullFluidsFrom = canPullFluidsFrom(world.getBlockState(currentPos), currentPos); @@ -193,7 +193,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { } @Override - public void read(CompoundNBT nbt, boolean clientPacket) { + public void read(CompoundTag nbt, boolean clientPacket) { super.read(nbt, clientPacket); if (!clientPacket && affectedArea != null) frontier.add(new BlockPosEntry(rootPos, 0)); @@ -202,10 +202,10 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { protected FluidBlockType canPullFluidsFrom(BlockState blockState, BlockPos pos) { if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)) return FluidBlockType.SOURCE; - if (blockState.getBlock() instanceof FlowingFluidBlock) - return blockState.getValue(FlowingFluidBlock.LEVEL) == 0 ? FluidBlockType.SOURCE : FluidBlockType.FLOWING; + if (blockState.getBlock() instanceof LiquidBlock) + return blockState.getValue(LiquidBlock.LEVEL) == 0 ? FluidBlockType.SOURCE : FluidBlockType.FLOWING; if (blockState.getFluidState() - .getType() != Fluids.EMPTY && blockState.getCollisionShape(getWorld(), pos, ISelectionContext.empty()) + .getType() != Fluids.EMPTY && blockState.getCollisionShape(getWorld(), pos, CollisionContext.empty()) .isEmpty()) return FluidBlockType.SOURCE; return FluidBlockType.NONE; @@ -236,7 +236,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { public void rebuildContext(BlockPos root) { reset(); rootPos = root; - affectedArea = new MutableBoundingBox(rootPos, rootPos); + affectedArea = new BoundingBox(rootPos, rootPos); if (isValid) frontier.add(new BlockPosEntry(root, 0)); } @@ -255,7 +255,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour { validationSet.add(e); }, false); - World world = getWorld(); + Level world = getWorld(); int maxBlocks = maxBlocks(); if (visited.size() > maxBlocks && canDrainInfinitely(fluid)) { infinite = true; 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 814651f9d..0e55b9c02 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 @@ -15,30 +15,30 @@ import com.simibubi.create.foundation.utility.Iterate; import it.unimi.dsi.fastutil.PriorityQueue; import it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.DoorBlock; -import net.minecraft.block.FlowingFluidBlock; -import net.minecraft.block.material.Material; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.ITickList; -import net.minecraft.world.NextTickListEntry; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerTickList; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.TickList; +import net.minecraft.world.level.TickNextTickData; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.ServerTickList; public class FluidFillingBehaviour extends FluidManipulationBehaviour { @@ -99,7 +99,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { reset(); rootPos = root; queue.enqueue(new BlockPosEntry(root, 0)); - affectedArea = new MutableBoundingBox(rootPos, rootPos); + affectedArea = new BoundingBox(rootPos, rootPos); return false; } @@ -110,7 +110,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { } if (affectedArea == null) - affectedArea = new MutableBoundingBox(root, root); + affectedArea = new BoundingBox(root, root); if (revalidateIn == 0) { visited.clear(); @@ -121,7 +121,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { softReset(root); } - World world = getWorld(); + Level world = getWorld(); int maxRange = maxRange(); int maxRangeSq = maxRange * maxRange; int maxBlocks = maxBlocks(); @@ -142,7 +142,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { int i = root.getX(); int j = root.getY(); int k = root.getZ(); - world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, + world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); } else if (!canPlaceSources) AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getBlockPos(), 8); @@ -191,11 +191,11 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { .createLegacyBlock(), 2 | 16); } - ITickList pendingFluidTicks = world.getLiquidTicks(); + TickList pendingFluidTicks = world.getLiquidTicks(); if (pendingFluidTicks instanceof ServerTickList) { ServerTickList serverTickList = (ServerTickList) pendingFluidTicks; - NextTickListEntry removedEntry = null; - for (NextTickListEntry nextTickListEntry : serverTickList.tickNextTickSet) { + TickNextTickData removedEntry = null; + for (TickNextTickData nextTickListEntry : serverTickList.tickNextTickSet) { if (nextTickListEntry.pos.equals(currentPos)) { removedEntry = nextTickListEntry; break; @@ -207,7 +207,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { } } - affectedArea.expand(new MutableBoundingBox(currentPos, currentPos)); + affectedArea.expand(new BoundingBox(currentPos, currentPos)); } } @@ -251,7 +251,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { FILLABLE, FILLED, BLOCKING } - protected SpaceType getAtPos(World world, BlockPos pos, Fluid toFill) { + protected SpaceType getAtPos(Level world, BlockPos pos, Fluid toFill) { BlockState blockState = world.getBlockState(pos); FluidState fluidState = blockState.getFluidState(); @@ -260,27 +260,27 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { ? blockState.getValue(BlockStateProperties.WATERLOGGED) ? SpaceType.FILLED : SpaceType.FILLABLE : SpaceType.BLOCKING; - if (blockState.getBlock() instanceof FlowingFluidBlock) - return blockState.getValue(FlowingFluidBlock.LEVEL) == 0 + if (blockState.getBlock() instanceof LiquidBlock) + return blockState.getValue(LiquidBlock.LEVEL) == 0 ? toFill.isSame(fluidState.getType()) ? SpaceType.FILLED : SpaceType.BLOCKING : SpaceType.FILLABLE; if (fluidState.getType() != Fluids.EMPTY - && blockState.getCollisionShape(getWorld(), pos, ISelectionContext.empty()) + && blockState.getCollisionShape(getWorld(), pos, CollisionContext.empty()) .isEmpty()) 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() + protected void replaceBlock(Level world, BlockPos pos, BlockState state) { + BlockEntity tileentity = state.getBlock() .hasTileEntity(state) ? world.getBlockEntity(pos) : null; Block.dropResources(state, world, pos, tileentity); } // From FlowingFluidBlock#isBlocked - protected boolean canBeReplacedByFluid(IBlockReader world, BlockPos pos, BlockState state) { + protected boolean canBeReplacedByFluid(BlockGetter world, BlockPos pos, BlockState state) { Block block = state.getBlock(); if (!(block instanceof DoorBlock) && !block.is(BlockTags.SIGNS) && block != Blocks.LADDER && block != Blocks.SUGAR_CANE && block != Blocks.BUBBLE_COLUMN) { 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 186aa9589..9d50372a3 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 @@ -15,21 +15,21 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; import net.minecraft.tags.FluidTags; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.fluids.FluidStack; public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { @@ -44,7 +44,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { } } - MutableBoundingBox affectedArea; + BoundingBox affectedArea; BlockPos rootPos; boolean infinite; protected boolean counterpartActed; @@ -112,7 +112,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { } protected void scheduleUpdatesInAffectedArea() { - World world = getWorld(); + Level world = getWorld(); BlockPos .betweenClosedStream(new BlockPos(affectedArea.x0 - 1, affectedArea.y0 - 1, affectedArea.z0 - 1), new BlockPos(affectedArea.x1 + 1, affectedArea.y1 + 1, affectedArea.z1 + 1)) @@ -127,7 +127,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { } protected int comparePositions(BlockPosEntry e1, BlockPosEntry e2) { - Vector3d centerOfRoot = VecHelper.getCenterOf(rootPos); + Vec3 centerOfRoot = VecHelper.getCenterOf(rootPos); BlockPos pos2 = e2.pos; BlockPos pos1 = e1.pos; if (pos1.getY() != pos2.getY()) @@ -143,7 +143,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { protected Fluid search(Fluid fluid, List frontier, Set visited, BiConsumer add, boolean searchDownward) { - World world = getWorld(); + Level world = getWorld(); int maxBlocks = maxBlocks(); int maxRange = canDrainInfinitely(fluid) ? maxRange() : maxRange() / 2; int maxRangeSq = maxRange * maxRange; @@ -194,7 +194,7 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { return fluid; } - protected void playEffect(World world, BlockPos pos, Fluid fluid, boolean fillSound) { + protected void playEffect(Level world, BlockPos pos, Fluid fluid, boolean fillSound) { BlockPos splooshPos = pos == null ? tileEntity.getBlockPos() : pos; SoundEvent soundevent = fillSound ? fluid.getAttributes() @@ -206,8 +206,8 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { 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) + world.playSound(null, splooshPos, soundevent, SoundSource.BLOCKS, 0.3F, 1.0F); + if (world instanceof ServerLevel) AllPackets.sendToNear(world, splooshPos, 10, new FluidSplashPacket(splooshPos, new FluidStack(fluid, 1))); } @@ -216,25 +216,25 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour { } @Override - public void write(CompoundNBT nbt, boolean clientPacket) { + public void write(CompoundTag nbt, boolean clientPacket) { if (rootPos != null) - nbt.put("LastPos", NBTUtil.writeBlockPos(rootPos)); + nbt.put("LastPos", NbtUtils.writeBlockPos(rootPos)); if (affectedArea != null) { nbt.put("AffectedAreaFrom", - NBTUtil.writeBlockPos(new BlockPos(affectedArea.x0, affectedArea.y0, affectedArea.z0))); + NbtUtils.writeBlockPos(new BlockPos(affectedArea.x0, affectedArea.y0, affectedArea.z0))); nbt.put("AffectedAreaTo", - NBTUtil.writeBlockPos(new BlockPos(affectedArea.x1, affectedArea.y1, affectedArea.z1))); + NbtUtils.writeBlockPos(new BlockPos(affectedArea.x1, affectedArea.y1, affectedArea.z1))); } super.write(nbt, clientPacket); } @Override - public void read(CompoundNBT nbt, boolean clientPacket) { + public void read(CompoundTag nbt, boolean clientPacket) { if (nbt.contains("LastPos")) - rootPos = NBTUtil.readBlockPos(nbt.getCompound("LastPos")); + rootPos = NbtUtils.readBlockPos(nbt.getCompound("LastPos")); if (nbt.contains("AffectedAreaFrom") && nbt.contains("AffectedAreaTo")) - affectedArea = new MutableBoundingBox(NBTUtil.readBlockPos(nbt.getCompound("AffectedAreaFrom")), - NBTUtil.readBlockPos(nbt.getCompound("AffectedAreaTo"))); + affectedArea = new BoundingBox(NbtUtils.readBlockPos(nbt.getCompound("AffectedAreaFrom")), + NbtUtils.readBlockPos(nbt.getCompound("AffectedAreaTo"))); super.read(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 8704f92a7..f84f21b92 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 @@ -6,9 +6,9 @@ import com.simibubi.create.content.contraptions.fluids.FluidFX; import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.DistExecutor; @@ -24,12 +24,12 @@ public class FluidSplashPacket extends SimplePacketBase { this.fluid = fluid; } - public FluidSplashPacket(PacketBuffer buffer) { + public FluidSplashPacket(FriendlyByteBuf buffer) { pos = buffer.readBlockPos(); fluid = buffer.readFluidStack(); } - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBlockPos(pos); buffer.writeFluidStack(fluid); } @@ -38,7 +38,7 @@ public class FluidSplashPacket extends SimplePacketBase { ctx.get() .enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { if (Minecraft.getInstance().player.position() - .distanceTo(new Vector3d(pos.getX(), pos.getY(), pos.getZ())) > 100) + .distanceTo(new Vec3(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 e8aeb3a9c..880c8e7e0 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 @@ -4,15 +4,15 @@ import com.simibubi.create.AllFluids; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import com.simibubi.create.foundation.fluid.FluidHelper; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BucketItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.MilkBucketItem; -import net.minecraft.potion.PotionUtils; -import net.minecraft.potion.Potions; -import net.minecraft.world.World; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.MilkBucketItem; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -49,7 +49,7 @@ public class GenericItemFilling { return true; } - public static boolean canItemBeFilled(World world, ItemStack stack) { + public static boolean canItemBeFilled(Level world, ItemStack stack) { if (stack.getItem() == Items.GLASS_BOTTLE) return true; if (stack.getItem() == Items.MILK_BUCKET) @@ -70,7 +70,7 @@ public class GenericItemFilling { return false; } - public static int getRequiredAmountForItem(World world, ItemStack stack, FluidStack availableFluid) { + public static int getRequiredAmountForItem(Level world, ItemStack stack, FluidStack availableFluid) { if (stack.getItem() == Items.GLASS_BOTTLE && canFillGlassBottleInternally(availableFluid)) return PotionFluidHandler.getRequiredAmountForFilledBottle(stack, availableFluid); if (stack.getItem() == Items.BUCKET && canFillBucketInternally(availableFluid)) @@ -107,7 +107,7 @@ public class GenericItemFilling { return false; } - public static ItemStack fillItem(World world, int requiredAmount, ItemStack stack, FluidStack availableFluid) { + public static ItemStack fillItem(Level world, int requiredAmount, ItemStack stack, FluidStack availableFluid) { FluidStack toFill = availableFluid.copy(); toFill.setAmount(requiredAmount); availableFluid.shrink(requiredAmount); 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 b79cfc316..296b7c39a 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 @@ -8,17 +8,19 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class HosePulleyBlock extends HorizontalKineticBlock implements ITE { @@ -34,7 +36,7 @@ public class HosePulleyBlock extends HorizontalKineticBlock implements ITE typeIn) { + public HosePulleyTileEntity(BlockEntityType typeIn) { super(typeIn); offset = LerpedFloat.linear() .startWithValue(0); @@ -52,7 +52,7 @@ public class HosePulleyTileEntity extends KineticTileEntity { } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { boolean addToGoggleTooltip = super.addToGoggleTooltip(tooltip, isPlayerSneaking); if (infinite) TooltipHelper.addHint(tooltip, "hint.hose_pulley"); @@ -99,7 +99,7 @@ public class HosePulleyTileEntity extends KineticTileEntity { @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { + public AABB getRenderBoundingBox() { return super.getRenderBoundingBox().expandTowards(0, -offset.getValue(), 0); } @@ -151,16 +151,16 @@ public class HosePulleyTileEntity extends KineticTileEntity { } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { compound.put("Offset", offset.writeNBT()); - compound.put("Tank", internalTank.writeToNBT(new CompoundNBT())); + compound.put("Tank", internalTank.writeToNBT(new CompoundTag())); super.write(compound, clientPacket); if (clientPacket) compound.putBoolean("Infinite", infinite); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { offset.readNBT(compound.getCompound("Offset"), clientPacket); internalTank.readFromNBT(compound.getCompound("Tank")); super.fromTag(state, compound, clientPacket); 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 4a31fd084..5e62efe53 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 @@ -8,25 +8,27 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.tileEntity.ComparatorUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.InventoryHelper; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.Containers; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class ItemDrainBlock extends Block implements IWrenchable, ITE { public ItemDrainBlock(Properties p_i48440_1_) { @@ -34,19 +36,19 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE { if (!heldItem.isEmpty()) { te.internalTank.allowInsertion(); - ActionResultType tryExchange = tryExchange(worldIn, player, handIn, heldItem, te); + InteractionResult tryExchange = tryExchange(worldIn, player, handIn, heldItem, te); te.internalTank.forbidInsertion(); if (tryExchange.consumesAction()) return tryExchange; @@ -58,33 +60,33 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE { ItemStack heldItemStack = te.getHeldItemStack(); if (!heldItemStack.isEmpty()) - InventoryHelper.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), heldItemStack); + Containers.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), heldItemStack); }); worldIn.removeBlockEntity(pos); } @@ -95,7 +97,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE { - public ItemDrainRenderer(TileEntityRendererDispatcher dispatcher) { + public ItemDrainRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(ItemDrainTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(ItemDrainTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); renderFluid(te, partialTicks, ms, buffer, light); renderItem(te, partialTicks, ms, buffer, light, overlay); } - protected void renderItem(ItemDrainTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderItem(ItemDrainTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { TransportedItemStack transported = te.heldItem; if (transported == null) return; MatrixTransformStack msr = MatrixTransformStack.of(ms); - Vector3d itemPosition = VecHelper.getCenterOf(te.getBlockPos()); + Vec3 itemPosition = VecHelper.getCenterOf(te.getBlockPos()); Direction insertedFrom = transported.insertedFrom; if (!insertedFrom.getAxis() @@ -59,10 +59,10 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer> itemHandlers; - public ItemDrainTileEntity(TileEntityType tileEntityTypeIn) { + public ItemDrainTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); itemHandlers = new IdentityHashMap<>(); for (Direction d : Iterate.horizontalDirections) { @@ -151,11 +151,11 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI if (!BlockHelper.hasBlockSolidSide(level.getBlockState(nextPosition), level, nextPosition, side.getOpposite())) { ItemStack ejected = heldItem.stack; - Vector3d outPos = VecHelper.getCenterOf(worldPosition) - .add(Vector3d.atLowerCornerOf(side.getNormal()) + Vec3 outPos = VecHelper.getCenterOf(worldPosition) + .add(Vec3.atLowerCornerOf(side.getNormal()) .scale(.75)); float movementSpeed = itemMovementPerTick(); - Vector3d outMotion = Vector3d.atLowerCornerOf(side.getNormal()) + Vec3 outMotion = Vec3.atLowerCornerOf(side.getNormal()) .scale(movementSpeed) .add(0, 1 / 8f, 0); outPos.add(outMotion.normalize()); @@ -262,7 +262,7 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("ProcessingTicks", processingTicks); if (heldItem != null) compound.put("HeldItem", heldItem.serializeNBT()); @@ -270,7 +270,7 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { heldItem = null; processingTicks = compound.getInt("ProcessingTicks"); if (compound.contains("HeldItem")) @@ -293,7 +293,7 @@ public class ItemDrainTileEntity extends SmartTileEntity implements IHaveGoggleI } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { return containedFluidTooltip(tooltip, isPlayerSneaking, getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)); } 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 30ea3345e..68f3fc474 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 @@ -5,15 +5,17 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.tileEntity.ComparatorUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class SpoutBlock extends Block implements IWrenchable { @@ -27,13 +29,13 @@ public class SpoutBlock extends Block implements IWrenchable { } @Override - public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return AllShapes.SPOUT; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.SPOUT.create(); } @@ -43,12 +45,12 @@ public class SpoutBlock extends Block implements IWrenchable { } @Override - public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { + public int getAnalogOutputSignal(BlockState blockState, Level worldIn, BlockPos pos) { return ComparatorUtil.levelOfSmartFluidTank(worldIn, pos); } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 2136e2b4c..2c1cafbea 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 @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.fluids.actors; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.render.PartialBufferer; @@ -9,16 +9,16 @@ import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankB import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.phys.AABB; +import net.minecraft.util.Mth; import net.minecraftforge.fluids.FluidStack; public class SpoutRenderer extends SafeTileEntityRenderer { - public SpoutRenderer(TileEntityRendererDispatcher dispatcher) { + public SpoutRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @@ -26,7 +26,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer { { AllBlockPartials.SPOUT_TOP, AllBlockPartials.SPOUT_MIDDLE, AllBlockPartials.SPOUT_BOTTOM }; @Override - protected void renderSafe(SpoutTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(SpoutTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { SmartFluidTankBehaviour tank = te.tank; @@ -53,12 +53,12 @@ public class SpoutRenderer extends SafeTileEntityRenderer { int processingTicks = te.processingTicks; float processingPT = processingTicks - partialTicks; float processingProgress = 1 - (processingPT - 5) / 10; - processingProgress = MathHelper.clamp(processingProgress, 0, 1); + processingProgress = Mth.clamp(processingProgress, 0, 1); float radius = 0; 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).inflate(radius / 32f); + AABB bb = new AABB(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); } @@ -67,7 +67,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer { if (processingPT < 0) squeeze = 0; else if (processingPT < 2) - squeeze = MathHelper.lerp(processingPT / 2f, 0, -1); + squeeze = Mth.lerp(processingPT / 2f, 0, -1); else if (processingPT < 10) squeeze = -1; 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 8d3c6515a..5bb689f5e 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 @@ -21,17 +21,17 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.PotionItem; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.IParticleData; -import net.minecraft.potion.PotionUtils; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.PotionItem; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.Capability; @@ -50,16 +50,16 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor SmartFluidTankBehaviour tank; - public SpoutTileEntity(TileEntityType tileEntityTypeIn) { + public SpoutTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); processingTicks = -1; } - protected AxisAlignedBB cachedBoundingBox; + protected AABB cachedBoundingBox; @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { + public AABB getRenderBoundingBox() { if (cachedBoundingBox == null) cachedBoundingBox = super.getRenderBoundingBox().expandTowards(0, -2, 0); return cachedBoundingBox; @@ -139,7 +139,7 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); compound.putInt("ProcessingTicks", processingTicks); @@ -150,7 +150,7 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); processingTicks = compound.getInt("ProcessingTicks"); if (!clientPacket) @@ -207,9 +207,9 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor protected void spawnProcessingParticles(FluidStack fluid) { if (isVirtual()) return; - Vector3d vec = VecHelper.getCenterOf(worldPosition); + Vec3 vec = VecHelper.getCenterOf(worldPosition); vec = vec.subtract(0, 8 / 16f, 0); - IParticleData particle = FluidFX.getFluidParticle(fluid); + ParticleOptions particle = FluidFX.getFluidParticle(fluid); level.addAlwaysVisibleParticle(particle, vec.x, vec.y, vec.z, 0, -.1f, 0); } @@ -218,18 +218,18 @@ public class SpoutTileEntity extends SmartTileEntity implements IHaveGoggleInfor protected void spawnSplash(FluidStack fluid) { if (isVirtual()) return; - Vector3d vec = VecHelper.getCenterOf(worldPosition); + Vec3 vec = VecHelper.getCenterOf(worldPosition); vec = vec.subtract(0, 2 - 5 / 16f, 0); - IParticleData particle = FluidFX.getFluidParticle(fluid); + ParticleOptions particle = FluidFX.getFluidParticle(fluid); for (int i = 0; i < SPLASH_PARTICLE_COUNT; i++) { - Vector3d m = VecHelper.offsetRandomly(Vector3d.ZERO, level.random, 0.125f); - m = new Vector3d(m.x, Math.abs(m.y), m.z); + Vec3 m = VecHelper.offsetRandomly(Vec3.ZERO, level.random, 0.125f); + m = new Vec3(m.x, Math.abs(m.y), m.z); level.addAlwaysVisibleParticle(particle, vec.x, vec.y, vec.z, m.x, m.y, m.z); } } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { return containedFluidTooltip(tooltip, isPlayerSneaking, getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)); } 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 05fa110d9..ed13570cf 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 @@ -1,27 +1,27 @@ package com.simibubi.create.content.contraptions.fluids.particle; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.processing.BasinTileEntity; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.Camera; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import com.mojang.math.Quaternion; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.FluidStack; public class BasinFluidParticle extends FluidStackParticle { BlockPos basinPos; - Vector3d targetPos; - Vector3d centerOfBasin; + Vec3 targetPos; + Vec3 centerOfBasin; float yOffset; - public BasinFluidParticle(ClientWorld world, FluidStack fluid, double x, double y, double z, double vx, double vy, + public BasinFluidParticle(ClientLevel world, FluidStack fluid, double x, double y, double z, double vx, double vy, double vz) { super(world, fluid, x, y, z, vx, vy, vz); gravity = 0; @@ -32,14 +32,14 @@ public class BasinFluidParticle extends FluidStackParticle { y += yOffset; quadSize = 0; lifetime = 60; - Vector3d currentPos = new Vector3d(x, y, z); + Vec3 currentPos = new Vec3(x, y, z); basinPos = new BlockPos(currentPos); centerOfBasin = VecHelper.getCenterOf(basinPos); if (vx != 0) { lifetime = 20; - Vector3d centerOf = VecHelper.getCenterOf(basinPos); - Vector3d diff = currentPos.subtract(centerOf) + Vec3 centerOf = VecHelper.getCenterOf(basinPos); + Vec3 diff = currentPos.subtract(centerOf) .multiply(1, 0, 1) .normalize() .scale(.375); @@ -61,12 +61,12 @@ public class BasinFluidParticle extends FluidStackParticle { return; } - TileEntity tileEntity = level.getBlockEntity(basinPos); + BlockEntity 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); + float fluidLevel = Mth.clamp(totalUnits / 2000, 0, 1); y = 2 / 16f + basinPos.getY() + 12 / 16f * fluidLevel + yOffset; } @@ -74,7 +74,7 @@ public class BasinFluidParticle extends FluidStackParticle { if (targetPos != null) { float progess = (1f * age) / lifetime; - Vector3d currentPos = centerOfBasin.add(targetPos.subtract(centerOfBasin) + Vec3 currentPos = centerOfBasin.add(targetPos.subtract(centerOfBasin) .scale(progess)); x = currentPos.x; z = currentPos.z; @@ -82,7 +82,7 @@ public class BasinFluidParticle extends FluidStackParticle { } @Override - public void render(IVertexBuilder vb, ActiveRenderInfo info, float pt) { + public void render(VertexConsumer vb, Camera info, float pt) { Quaternion rotation = info.rotation(); Quaternion prevRotation = new Quaternion(rotation); rotation.set(1, 0, 0, 1); 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 b1ee8f926..444ba7c63 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 @@ -9,19 +9,21 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import com.simibubi.create.AllParticleTypes; import com.simibubi.create.content.contraptions.particle.ICustomParticleData; -import net.minecraft.client.particle.IParticleFactory; -import net.minecraft.fluid.Fluids; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleType; -import net.minecraft.util.registry.Registry; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.Registry; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.registries.ForgeRegistries; -public class FluidParticleData implements IParticleData, ICustomParticleData { +import net.minecraft.core.particles.ParticleOptions.Deserializer; + +public class FluidParticleData implements ParticleOptions, ICustomParticleData { private ParticleType type; private FluidStack fluid; @@ -36,7 +38,7 @@ public class FluidParticleData implements IParticleData, ICustomParticleData getFactory() { + public ParticleProvider getFactory() { return (data, world, x, y, z, vx, vy, vz) -> FluidStackParticle.create(data.type, world, data.fluid, x, y, z, vx, vy, vz); } @@ -47,7 +49,7 @@ public class FluidParticleData implements IParticleData, ICustomParticleData { return Optional.ofNullable(fs.getTag()); })) @@ -83,8 +85,8 @@ public class FluidParticleData implements IParticleData, ICustomParticleData p.fluid)) .apply(i, fs -> new FluidParticleData(AllParticleTypes.FLUID_DRIP.get(), fs))); - public static final IParticleData.IDeserializer DESERIALIZER = - new IParticleData.IDeserializer() { + public static final ParticleOptions.Deserializer DESERIALIZER = + new ParticleOptions.Deserializer() { // TODO Fluid particles on command public FluidParticleData fromCommand(ParticleType particleTypeIn, StringReader reader) @@ -92,13 +94,13 @@ public class FluidParticleData implements IParticleData, ICustomParticleData particleTypeIn, PacketBuffer buffer) { + public FluidParticleData fromNetwork(ParticleType particleTypeIn, FriendlyByteBuf buffer) { return new FluidParticleData(particleTypeIn, buffer.readFluidStack()); } }; @Override - public IDeserializer getDeserializer() { + public Deserializer getDeserializer() { return DESERIALIZER; } 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 08927cb60..b19856cee 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 @@ -5,33 +5,33 @@ import com.simibubi.create.content.contraptions.fluids.potion.PotionFluid; import com.simibubi.create.foundation.utility.Color; import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.IParticleRenderType; -import net.minecraft.client.particle.SpriteTexturedParticle; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.inventory.container.PlayerContainer; -import net.minecraft.particles.ParticleType; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.particle.ParticleRenderType; +import net.minecraft.client.particle.TextureSheetParticle; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.FluidStack; -public class FluidStackParticle extends SpriteTexturedParticle { +public class FluidStackParticle extends TextureSheetParticle { private final float uo; private final float vo; private FluidStack fluid; - public static FluidStackParticle create(ParticleType type, ClientWorld world, FluidStack fluid, double x, + public static FluidStackParticle create(ParticleType type, ClientLevel world, FluidStack fluid, double x, double y, double z, double vx, double vy, double vz) { if (type == AllParticleTypes.BASIN_FLUID.get()) return new BasinFluidParticle(world, fluid, x, y, z, vx, vy, vz); return new FluidStackParticle(world, fluid, x, y, z, vx, vy, vz); } - public FluidStackParticle(ClientWorld world, FluidStack fluid, double x, double y, double z, double vx, double vy, + public FluidStackParticle(ClientLevel world, FluidStack fluid, double x, double y, double z, double vx, double vy, double vz) { super(world, x, y, z, vx, vy, vz); this.fluid = fluid; this.setSprite(Minecraft.getInstance() - .getTextureAtlas(PlayerContainer.BLOCK_ATLAS) + .getTextureAtlas(InventoryMenu.BLOCK_ATLAS) .apply(fluid.getFluid() .getAttributes() .getStillTexture())); @@ -98,7 +98,7 @@ public class FluidStackParticle extends SpriteTexturedParticle { if (!onGround && level.random.nextFloat() < 1 / 8f) return; - Vector3d rgb = Color.vectorFromRGB(fluid.getFluid() + Vec3 rgb = Color.vectorFromRGB(fluid.getFluid() .getAttributes() .getColor(fluid)); level.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, rgb.x, rgb.y, rgb.z); @@ -109,8 +109,8 @@ public class FluidStackParticle extends SpriteTexturedParticle { } @Override - public IParticleRenderType getRenderType() { - return IParticleRenderType.TERRAIN_SHEET; + public ParticleRenderType getRenderType() { + return ParticleRenderType.TERRAIN_SHEET; } } 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 76ec1811d..1cff33b0c 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 @@ -14,29 +14,31 @@ import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.RotatedPillarBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.DebugPacketSender; -import net.minecraft.state.BooleanProperty; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.TickPriority; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.protocol.game.DebugPackets; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.TickPriority; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWithBracket, IAxisPipe { @@ -45,7 +47,7 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith } @Override - public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); @@ -56,10 +58,10 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult hit) { if (!AllBlocks.COPPER_CASING.isIn(player.getItemInHand(hand))) - return ActionResultType.PASS; + return InteractionResult.PASS; if (!world.isClientSide) { BlockState newState = AllBlocks.ENCASED_FLUID_PIPE.getDefaultState(); for (Direction d : Iterate.directionsInAxis(getAxis(state))) @@ -69,11 +71,11 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith FluidTransportBehaviour.loadFlows(world, pos); } AllTriggers.triggerFor(AllTriggers.CASING_PIPE, player); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) { if (world.isClientSide) return; if (state != oldState) @@ -82,15 +84,15 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith } @Override - public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, - PlayerEntity player) { + public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, + Player player) { return AllBlocks.FLUID_PIPE.asStack(); } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.sendNeighborsUpdatePacket(world, pos); + DebugPackets.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; @@ -105,17 +107,17 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith } @Override - public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel 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_) { + public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return AllShapes.EIGHT_VOXEL_POLE.get(state.getValue(AXIS)); } - public BlockState toRegularPipe(IWorld world, BlockPos pos, BlockState state) { + public BlockState toRegularPipe(LevelAccessor world, BlockPos pos, BlockState state) { Direction side = Direction.get(AxisDirection.POSITIVE, state.getValue(AXIS)); Map facingToPropertyMap = FluidPipeBlock.PROPERTY_BY_DIRECTION; return AllBlocks.FLUID_PIPE.get() @@ -130,7 +132,7 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith } @Override - public Optional removeBracket(IBlockReader world, BlockPos pos, boolean inOnReplacedContext) { + public Optional removeBracket(BlockGetter world, BlockPos pos, boolean inOnReplacedContext) { BracketedTileEntityBehaviour behaviour = TileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE); if (behaviour == null) return Optional.empty(); 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 588f3f620..91dce25ef 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 @@ -10,14 +10,16 @@ import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.IStringSerializable; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.util.StringRepresentable; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class BracketBlock extends WrenchableDirectionalBlock { @@ -25,7 +27,7 @@ public class BracketBlock extends WrenchableDirectionalBlock { DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; public static final EnumProperty TYPE = EnumProperty.create("type", BracketType.class); - public static enum BracketType implements IStringSerializable { + public static enum BracketType implements StringRepresentable { PIPE, COG, SHAFT; @Override 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 b636ce1f6..46130b5c0 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 @@ -5,17 +5,19 @@ import java.util.Optional; import com.simibubi.create.content.contraptions.relays.elementary.BracketedTileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; + +import net.minecraft.world.item.Item.Properties; public class BracketBlockItem extends BlockItem { @@ -24,28 +26,28 @@ public class BracketBlockItem extends BlockItem { } @Override - public ActionResultType useOn(ItemUseContext context) { - World world = context.getLevel(); + public InteractionResult useOn(UseOnContext context) { + Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); BlockState state = world.getBlockState(pos); BracketBlock bracketBlock = getBracketBlock(); - PlayerEntity player = context.getPlayer(); + Player player = context.getPlayer(); BracketedTileEntityBehaviour behaviour = TileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE); if (behaviour == null) - return ActionResultType.FAIL; + return InteractionResult.FAIL; if (!behaviour.canHaveBracket()) - return ActionResultType.FAIL; + return InteractionResult.FAIL; if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; Optional suitableBracket = bracketBlock.getSuitableBracket(state, context.getClickedFace()); if (!suitableBracket.isPresent() && player != null) suitableBracket = bracketBlock.getSuitableBracket(state, Direction.orderedByNearest(player)[0].getOpposite()); if (!suitableBracket.isPresent()) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; BlockState bracket = behaviour.getBracket(); behaviour.applyBracket(suitableBracket.get()); @@ -64,7 +66,7 @@ public class BracketBlockItem extends BlockItem { player.inventory.placeItemBackInInventory(world, returnedStack); } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } private BracketBlock getBracketBlock() { 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 e31ac7a86..f1014f286 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 @@ -6,9 +6,9 @@ import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; import com.tterrag.registrate.util.nullness.NonNullFunction; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItem; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.BlockItem; import net.minecraftforge.client.model.generators.ModelFile; public class BracketGenerator extends DirectionalAxisBlockStateGen { 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 e668ab22c..4482d991f 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 @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.fluids.pipes; import static net.minecraft.state.properties.BlockStateProperties.DOWN; -import static net.minecraft.state.properties.BlockStateProperties.EAST; +import staticnet.minecraft.world.level.block.state.properties.BlockStatePropertiess.EAST; import static net.minecraft.state.properties.BlockStateProperties.NORTH; -import static net.minecraft.state.properties.BlockStateProperties.SOUTH; +import staticnet.minecraft.world.level.block.state.properties.BlockStatePropertiess.SOUTH; import static net.minecraft.state.properties.BlockStateProperties.UP; -import static net.minecraft.state.properties.BlockStateProperties.WEST; +import staticnet.minecraft.world.level.block.state.properties.BlockStatePropertiess.WEST; import java.util.Map; import java.util.Random; @@ -19,28 +19,30 @@ import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SixWayBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.network.DebugPacketSender; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.TickPriority; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.PipeBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.network.protocol.game.DebugPackets; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.TickPriority; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBlockItemRequirement { - public static final Map FACING_TO_PROPERTY_MAP = SixWayBlock.PROPERTY_BY_DIRECTION; + public static final Map FACING_TO_PROPERTY_MAP = PipeBlock.PROPERTY_BY_DIRECTION; public EncasedPipeBlock(Properties p_i48339_1_) { super(p_i48339_1_); @@ -64,7 +66,7 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc } @Override - public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); @@ -73,22 +75,22 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) { if (!world.isClientSide && state != oldState) world.getBlockTicks() .scheduleTick(pos, this, 1, TickPriority.HIGH); } @Override - public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, - PlayerEntity player) { + public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, + Player player) { return AllBlocks.FLUID_PIPE.asStack(); } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.sendNeighborsUpdatePacket(world, pos); + DebugPackets.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; @@ -99,22 +101,22 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc } @Override - public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.ENCASED_FLUID_PIPE.create(); } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getLevel(); + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; context.getLevel() .levelEvent(2001, context.getClickedPos(), Block.getId(state)); @@ -131,7 +133,7 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc world.setBlockAndUpdate(pos, AllBlocks.FLUID_PIPE.get() .updateBlockState(equivalentPipe, firstFound, null, world, pos)); FluidTransportBehaviour.loadFlows(world, pos); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } public static BlockState transferSixWayProperties(BlockState from, BlockState to) { @@ -143,7 +145,7 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc } @Override - public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) { return ItemRequirement.of(AllBlocks.FLUID_PIPE.getDefaultState(), te); } 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 dbf49a8f3..118cb6f33 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 @@ -16,38 +16,40 @@ import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.block.SixWayBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.network.DebugPacketSender; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockDisplayReader; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.TickPriority; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.block.PipeBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.network.protocol.game.DebugPackets; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.TickPriority; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; -public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWrenchableWithBracket { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class FluidPipeBlock extends PipeBlock implements SimpleWaterloggedBlock, IWrenchableWithBracket { public FluidPipeBlock(Properties properties) { super(4 / 16f, properties); @@ -55,24 +57,24 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onWrenched(BlockState state, UseOnContext context) { if (tryRemoveBracket(context)) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; - World world = context.getLevel(); + Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); Direction clickedFace = context.getClickedFace(); Axis axis = getAxis(world, pos, state); if (axis == null) { - Vector3d clickLocation = context.getClickLocation() + Vec3 clickLocation = context.getClickLocation() .subtract(pos.getX(), pos.getY(), pos.getZ()); double closest = Float.MAX_VALUE; Direction argClosest = Direction.UP; for (Direction direction : Iterate.directions) { if (clickedFace.getAxis() == direction.getAxis()) continue; - Vector3d centerOf = Vector3d.atCenterOf(direction.getNormal()); + Vec3 centerOf = Vec3.atCenterOf(direction.getNormal()); double distance = centerOf.distanceToSqr(clickLocation); if (distance < closest) { closest = distance; @@ -83,7 +85,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } if (clickedFace.getAxis() == axis) - return ActionResultType.PASS; + return InteractionResult.PASS; if (!world.isClientSide) { FluidTransportBehaviour.cacheFlows(world, pos); world.setBlockAndUpdate(pos, AllBlocks.GLASS_FLUID_PIPE.getDefaultState() @@ -91,14 +93,14 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren .setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED))); FluidTransportBehaviour.loadFlows(world, pos); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult hit) { if (!AllBlocks.COPPER_CASING.isIn(player.getItemInHand(hand))) - return ActionResultType.PASS; + return InteractionResult.PASS; AllTriggers.triggerFor(AllTriggers.CASING_PIPE, player); if (!world.isClientSide) { FluidTransportBehaviour.cacheFlows(world, pos); @@ -106,7 +108,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren EncasedPipeBlock.transferSixWayProperties(state, AllBlocks.ENCASED_FLUID_PIPE.getDefaultState())); FluidTransportBehaviour.loadFlows(world, pos); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } public BlockState getAxisState(Axis axis) { @@ -117,7 +119,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Nullable - private Axis getAxis(IBlockReader world, BlockPos pos, BlockState state) { + private Axis getAxis(BlockGetter world, BlockPos pos, BlockState state) { return FluidPropagator.getStraightPipeAxis(state); } @@ -127,12 +129,12 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.FLUID_PIPE.create(); } @Override - public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); @@ -143,7 +145,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) { if (world.isClientSide) return; if (state != oldState) @@ -152,9 +154,9 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.sendNeighborsUpdatePacket(world, pos); + DebugPackets.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; @@ -165,7 +167,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @@ -173,7 +175,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren return state.getBlock() instanceof FluidPipeBlock; } - public static boolean canConnectTo(IBlockDisplayReader world, BlockPos neighbourPos, BlockState neighbour, + public static boolean canConnectTo(BlockAndTintGetter world, BlockPos neighbourPos, BlockState neighbour, Direction direction) { if (FluidPropagator.hasFluidCapability(world, neighbourPos, direction.getOpposite())) return true; @@ -190,7 +192,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren return transport.canHaveFlowToward(neighbour, direction.getOpposite()); } - public static boolean shouldDrawRim(IBlockDisplayReader world, BlockPos pos, BlockState state, + public static boolean shouldDrawRim(BlockAndTintGetter world, BlockPos pos, BlockState state, Direction direction) { BlockPos offsetPos = pos.relative(direction); BlockState facingState = world.getBlockState(offsetPos); @@ -213,12 +215,12 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren return state.getValue(PROPERTY_BY_DIRECTION.get(direction)); } - public static boolean isCornerOrEndPipe(IBlockDisplayReader world, BlockPos pos, BlockState state) { + public static boolean isCornerOrEndPipe(BlockAndTintGetter world, BlockPos pos, BlockState state) { return isPipe(state) && FluidPropagator.getStraightPipeAxis(state) == null && !shouldDrawCasing(world, pos, state); } - public static boolean shouldDrawCasing(IBlockDisplayReader world, BlockPos pos, BlockState state) { + public static boolean shouldDrawCasing(BlockAndTintGetter world, BlockPos pos, BlockState state) { if (!isPipe(state)) return false; for (Axis axis : Iterate.axes) { @@ -239,7 +241,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { FluidState FluidState = context.getLevel() .getFluidState(context.getClickedPos()); return updateBlockState(defaultBlockState(), context.getNearestLookingDirection(), null, context.getLevel(), @@ -248,7 +250,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) { if (state.getValue(BlockStateProperties.WATERLOGGED)) world.getLiquidTicks() @@ -260,7 +262,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } public BlockState updateBlockState(BlockState state, Direction preferredDirection, @Nullable Direction ignore, - IBlockDisplayReader world, BlockPos pos) { + BlockAndTintGetter world, BlockPos pos) { BracketedTileEntityBehaviour bracket = TileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE); if (bracket != null && bracket.isBracketPresent()) @@ -309,7 +311,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public Optional removeBracket(IBlockReader world, BlockPos pos, boolean inOnReplacedContext) { + public Optional removeBracket(BlockGetter world, BlockPos pos, boolean inOnReplacedContext) { BracketedTileEntityBehaviour behaviour = BracketedTileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE); if (behaviour == null) @@ -322,7 +324,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 0b34ef02e..0cefec993 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 @@ -9,15 +9,17 @@ import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; + +import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes; public class FluidPipeTileEntity extends SmartTileEntity { - public FluidPipeTileEntity(TileEntityType tileEntityTypeIn) { + public FluidPipeTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } @@ -45,7 +47,7 @@ public class FluidPipeTileEntity extends SmartTileEntity { } @Override - public AttachmentTypes getRenderedRimAttachment(IBlockDisplayReader world, BlockPos pos, BlockState state, + public AttachmentTypes getRenderedRimAttachment(BlockAndTintGetter world, BlockPos pos, BlockState state, Direction direction) { AttachmentTypes attachment = super.getRenderedRimAttachment(world, pos, state, direction); 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 b4f03bf4e..01b1fb577 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 @@ -10,23 +10,25 @@ import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock import com.simibubi.create.content.contraptions.fluids.FluidPropagator; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.network.DebugPacketSender; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.TickPriority; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.network.protocol.game.DebugPackets; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.TickPriority; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxisPipe { @@ -38,8 +40,8 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return AllShapes.FLUID_VALVE.get(getPipeAxis(state)); } @@ -49,7 +51,7 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - protected boolean prefersConnectionTo(IWorldReader reader, BlockPos pos, Direction facing, boolean shaftAxis) { + protected boolean prefersConnectionTo(LevelReader reader, BlockPos pos, Direction facing, boolean shaftAxis) { if (!shaftAxis) { BlockPos offset = pos.relative(facing); BlockState blockState = reader.getBlockState(offset); @@ -59,7 +61,7 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.FLUID_VALVE.create(); } @@ -87,7 +89,7 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); @@ -96,12 +98,12 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - public boolean canSurvive(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { + public boolean canSurvive(BlockState p_196260_1_, LevelReader p_196260_2_, BlockPos p_196260_3_) { return true; } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) { super.onPlace(state, world, pos, oldState, isMoving); if (world.isClientSide) return; @@ -111,9 +113,9 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.sendNeighborsUpdatePacket(world, pos); + DebugPackets.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; @@ -128,12 +130,12 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi } @Override - public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 d6b657bfb..26a0e1b32 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 @@ -5,7 +5,7 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -13,8 +13,10 @@ import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; + +import ModelData; public class FluidValveInstance extends ShaftInstance implements IDynamicInstance { @@ -56,9 +58,9 @@ public class FluidValveInstance extends ShaftInstance implements IDynamicInstanc } private void transformPointer(FluidValveTileEntity valve) { - float pointerRotation = MathHelper.lerp(valve.pointer.getValue(AnimationTickHolder.getPartialTicks()), 0, -90); + float pointerRotation = Mth.lerp(valve.pointer.getValue(AnimationTickHolder.getPartialTicks()), 0, -90); - MatrixStack ms = new MatrixStack(); + PoseStack ms = new PoseStack(); MatrixTransformStack.of(ms) .translate(getInstancePosition()) .centre() 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 495c13858..6d56e1562 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 @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.fluids.pipes; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -10,22 +10,22 @@ import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.util.Mth; public class FluidValveRenderer extends KineticTileEntityRenderer { - public FluidValveRenderer(TileEntityRendererDispatcher dispatcher) { + public FluidValveRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; @@ -38,7 +38,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer { if (!(te instanceof FluidValveTileEntity)) return; FluidValveTileEntity valve = (FluidValveTileEntity) te; - float pointerRotation = MathHelper.lerp(valve.pointer.getValue(partialTicks), 0, -90); + float pointerRotation = Mth.lerp(valve.pointer.getValue(partialTicks), 0, -90); Axis pipeAxis = FluidValveBlock.getPipeAxis(blockState); Axis shaftAxis = KineticTileEntityRenderer.getRotationAxisOf(te); 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 524a02405..7809a0148 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 @@ -9,18 +9,18 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; import net.minecraftforge.fluids.FluidStack; public class FluidValveTileEntity extends KineticTileEntity { LerpedFloat pointer; - public FluidValveTileEntity(TileEntityType tileEntityTypeIn) { + public FluidValveTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); pointer = LerpedFloat.linear() .startWithValue(0) @@ -59,17 +59,17 @@ public class FluidValveTileEntity extends KineticTileEntity { } private float getChaseSpeed() { - return MathHelper.clamp(Math.abs(getSpeed()) / 16 / 20, 0, 1); + return Mth.clamp(Math.abs(getSpeed()) / 16 / 20, 0, 1); } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); compound.put("Pointer", pointer.writeNBT()); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); pointer.readNBT(compound.getCompound("Pointer"), clientPacket); } 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 b1a4729f2..9d6db77ad 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 @@ -9,26 +9,28 @@ import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -public class GlassFluidPipeBlock extends AxisPipeBlock implements IWaterLoggable, ISpecialBlockItemRequirement { +public class GlassFluidPipeBlock extends AxisPipeBlock implements SimpleWaterloggedBlock, ISpecialBlockItemRequirement { public static final BooleanProperty ALT = BooleanProperty.create("alt"); @@ -48,26 +50,26 @@ public class GlassFluidPipeBlock extends AxisPipeBlock implements IWaterLoggable } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.GLASS_FLUID_PIPE.create(); } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onWrenched(BlockState state, UseOnContext context) { if (tryRemoveBracket(context)) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; BlockState newState; - World world = context.getLevel(); + Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); FluidTransportBehaviour.cacheFlows(world, pos); newState = toRegularPipe(world, pos, state).setValue(BlockStateProperties.WATERLOGGED, state.getValue(BlockStateProperties.WATERLOGGED)); world.setBlock(pos, newState, 3); FluidTransportBehaviour.loadFlows(world, pos); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { FluidState ifluidstate = context.getLevel() .getFluidState(context.getClickedPos()); BlockState state = super.getStateForPlacement(context); @@ -82,12 +84,12 @@ public class GlassFluidPipeBlock extends AxisPipeBlock implements IWaterLoggable } @Override - public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) { return ItemRequirement.of(AllBlocks.FLUID_PIPE.getDefaultState(), te); } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/IAxisPipe.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/IAxisPipe.java index 2d5242a03..a92b2c8a1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/IAxisPipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/IAxisPipe.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.fluids.pipes; import javax.annotation.Nullable; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction.Axis; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction.Axis; public interface IAxisPipe { 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 0a1637e17..d7474e1a0 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 @@ -9,27 +9,29 @@ import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VoxelShaper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalFaceBlock; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.network.DebugPacketSender; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.AttachFace; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.TickPriority; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.network.protocol.game.DebugPackets; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.TickPriority; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; -public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPipe, IWrenchable { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class SmartFluidPipeBlock extends FaceAttachedHorizontalDirectionalBlock implements IAxisPipe, IWrenchable { public SmartFluidPipeBlock(Properties p_i48339_1_) { super(p_i48339_1_); @@ -42,11 +44,11 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } @Override - public BlockState getStateForPlacement(BlockItemUseContext ctx) { + public BlockState getStateForPlacement(BlockPlaceContext ctx) { BlockState stateForPlacement = super.getStateForPlacement(ctx); Axis prefferedAxis = null; BlockPos pos = ctx.getClickedPos(); - World world = ctx.getLevel(); + Level world = ctx.getLevel(); for (Direction side : Iterate.directions) { if (!prefersConnectionTo(world, pos, side)) continue; @@ -74,14 +76,14 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip return stateForPlacement; } - protected boolean prefersConnectionTo(IWorldReader reader, BlockPos pos, Direction facing) { + protected boolean prefersConnectionTo(LevelReader reader, BlockPos pos, Direction facing) { BlockPos offset = pos.relative(facing); BlockState blockState = reader.getBlockState(offset); return FluidPipeBlock.canConnectTo(reader, offset, blockState, facing); } @Override - public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { boolean blockTypeChanged = state.getBlock() != newState.getBlock(); if (blockTypeChanged && !world.isClientSide) FluidPropagator.propagateChangedPipe(world, pos, state); @@ -90,12 +92,12 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } @Override - public boolean canSurvive(BlockState p_196260_1_, IWorldReader p_196260_2_, BlockPos p_196260_3_) { + public boolean canSurvive(BlockState p_196260_1_, LevelReader p_196260_2_, BlockPos p_196260_3_) { return true; } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) { if (world.isClientSide) return; if (state != oldState) @@ -104,9 +106,9 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block otherBlock, BlockPos neighborPos, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos, boolean isMoving) { - DebugPacketSender.sendNeighborsUpdatePacket(world, pos); + DebugPackets.sendNeighborsUpdatePacket(world, pos); Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving); if (d == null) return; @@ -121,7 +123,7 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } @Override - public void tick(BlockState state, ServerWorld world, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel world, BlockPos pos, Random r) { FluidPropagator.propagateChangedPipe(world, pos, state); } @@ -137,13 +139,13 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.SMART_FLUID_PIPE.create(); } @Override - public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { 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; @@ -156,7 +158,7 @@ public class SmartFluidPipeBlock extends HorizontalFaceBlock implements IAxisPip } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 aff0ac8f5..4e688c80a 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 @@ -5,9 +5,9 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.AttachFace; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.AttachFace; import net.minecraftforge.client.model.generators.ModelFile; public class SmartFluidPipeGenerator extends SpecialBlockStateGen { 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 31c88e29f..ed480be2d 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.fluids.pipes; import java.util.List; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.fluids.FluidPropagator; import com.simibubi.create.content.contraptions.fluids.pipes.StraightPipeTileEntity.StraightPipeFluidTransportBehaviour; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; @@ -13,20 +13,20 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBe import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.state.properties.AttachFace; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.FluidStack; public class SmartFluidPipeTileEntity extends SmartTileEntity { private FilteringBehaviour filter; - public SmartFluidPipeTileEntity(TileEntityType tileEntityTypeIn) { + public SmartFluidPipeTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } @@ -67,7 +67,7 @@ public class SmartFluidPipeTileEntity extends SmartTileEntity { class SmartPipeFilterSlot extends ValueBoxTransform { @Override - protected Vector3d getLocalOffset(BlockState state) { + protected Vec3 getLocalOffset(BlockState state) { 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; @@ -75,7 +75,7 @@ public class SmartFluidPipeTileEntity extends SmartTileEntity { } @Override - protected void rotate(BlockState state, MatrixStack ms) { + protected void rotate(BlockState state, PoseStack ms) { AttachFace face = state.getValue(SmartFluidPipeBlock.FACE); MatrixTransformStack.of(ms) .rotateY(angleY(state)) 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 c8d365642..a283fce7d 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 @@ -7,17 +7,19 @@ import com.simibubi.create.content.contraptions.relays.elementary.BracketedTileE import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; + +import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes; public class StraightPipeTileEntity extends SmartTileEntity { - public StraightPipeTileEntity(TileEntityType tileEntityTypeIn) { + public StraightPipeTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } @@ -39,7 +41,7 @@ public class StraightPipeTileEntity extends SmartTileEntity { } @Override - public AttachmentTypes getRenderedRimAttachment(IBlockDisplayReader world, BlockPos pos, BlockState state, + public AttachmentTypes getRenderedRimAttachment(BlockAndTintGetter world, BlockPos pos, BlockState state, Direction direction) { AttachmentTypes attachment = super.getRenderedRimAttachment(world, pos, state, direction); BlockState otherState = world.getBlockState(pos.relative(direction)); 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 2b65b410d..af85a4e6d 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 @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.fluids.pipes; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour; import com.simibubi.create.content.contraptions.fluids.PipeConnection.Flow; import com.simibubi.create.foundation.fluid.FluidRenderer; @@ -9,19 +9,19 @@ import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.animation.LerpedFloat; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; import net.minecraftforge.fluids.FluidStack; public class TransparentStraightPipeRenderer extends SafeTileEntityRenderer { - public TransparentStraightPipeRenderer(TileEntityRendererDispatcher dispatcher) { + public TransparentStraightPipeRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(StraightPipeTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(StraightPipeTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { FluidTransportBehaviour pipe = te.getBehaviour(FluidTransportBehaviour.TYPE); if (pipe == null) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/potion/PotionFluid.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/potion/PotionFluid.java index d65ffb09a..57ca7677c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/potion/PotionFluid.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/potion/PotionFluid.java @@ -7,19 +7,22 @@ import com.simibubi.create.AllFluids; import com.simibubi.create.content.contraptions.fluids.VirtualFluid; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.fluid.Fluid; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionUtils; -import net.minecraft.potion.Potions; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.fluids.FluidAttributes.Builder; +import net.minecraftforge.fluids.ForgeFlowingFluid.Properties; + public class PotionFluid extends VirtualFluid { public enum BottleType { @@ -30,7 +33,7 @@ public class PotionFluid extends VirtualFluid { super(properties); } - public static FluidStack withEffects(int amount, Potion potion, List customEffects) { + public static FluidStack withEffects(int amount, Potion potion, List customEffects) { FluidStack fluidStack = new FluidStack(AllFluids.POTION.get() .getSource(), amount); addPotionToFluidStack(fluidStack, potion); @@ -46,15 +49,15 @@ public class PotionFluid extends VirtualFluid { @Override public int getColor(FluidStack stack) { - CompoundNBT tag = stack.getOrCreateTag(); + CompoundTag tag = stack.getOrCreateTag(); int color = PotionUtils.getColor(PotionUtils.getAllEffects(tag)) | 0xff000000; return color; } @Override public String getTranslationKey(FluidStack stack) { - CompoundNBT tag = stack.getOrCreateTag(); - IItemProvider itemFromBottleType = + CompoundTag tag = stack.getOrCreateTag(); + ItemLike itemFromBottleType = PotionFluidHandler.itemFromBottleType(NBTHelper.readEnum(tag, "Bottle", BottleType.class)); return PotionUtils.getPotion(tag) .getName(itemFromBottleType.asItem() @@ -74,13 +77,13 @@ public class PotionFluid extends VirtualFluid { return fs; } - public static FluidStack appendEffects(FluidStack fs, Collection customEffects) { + public static FluidStack appendEffects(FluidStack fs, Collection customEffects) { if (customEffects.isEmpty()) return fs; - CompoundNBT compoundnbt = fs.getOrCreateTag(); - ListNBT listnbt = compoundnbt.getList("CustomPotionEffects", 9); - for (EffectInstance effectinstance : customEffects) - listnbt.add(effectinstance.save(new CompoundNBT())); + CompoundTag compoundnbt = fs.getOrCreateTag(); + ListTag listnbt = compoundnbt.getList("CustomPotionEffects", 9); + for (MobEffectInstance effectinstance : customEffects) + listnbt.add(effectinstance.save(new CompoundTag())); 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 e53d83064..9b24b3bd6 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 @@ -11,25 +11,25 @@ import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.potion.Effect; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.EffectUtils; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionUtils; -import net.minecraft.potion.Potions; -import net.minecraft.util.IItemProvider; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffectUtil; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.level.ItemLike; import net.minecraft.util.Tuple; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidStack; @@ -50,7 +50,7 @@ public class PotionFluidHandler { public static FluidStack getFluidFromPotionItem(ItemStack stack) { Potion potion = PotionUtils.getPotion(stack); - List list = PotionUtils.getCustomEffects(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) @@ -68,7 +68,7 @@ public class PotionFluidHandler { return BottleType.REGULAR; } - public static IItemProvider itemFromBottleType(BottleType type) { + public static ItemLike itemFromBottleType(BottleType type) { switch (type) { case LINGERING: return Items.LINGERING_POTION; @@ -85,7 +85,7 @@ public class PotionFluidHandler { } public static ItemStack fillBottle(ItemStack stack, FluidStack availableFluid) { - CompoundNBT tag = availableFluid.getOrCreateTag(); + CompoundTag tag = availableFluid.getOrCreateTag(); ItemStack potionStack = new ItemStack(itemFromBottleType(NBTHelper.readEnum(tag, "Bottle", BottleType.class))); PotionUtils.setPotion(potionStack, PotionUtils.getPotion(tag)); PotionUtils.setCustomEffects(potionStack, PotionUtils.getCustomEffects(tag)); @@ -94,15 +94,15 @@ public class PotionFluidHandler { // Modified version of PotionUtils#addPotionTooltip @OnlyIn(Dist.CLIENT) - public static void addPotionTooltip(FluidStack fs, List tooltip, float p_185182_2_) { - List list = PotionUtils.getAllEffects(fs.getOrCreateTag()); + public static void addPotionTooltip(FluidStack fs, List tooltip, float p_185182_2_) { + List list = PotionUtils.getAllEffects(fs.getOrCreateTag()); List> list1 = Lists.newArrayList(); if (list.isEmpty()) { - tooltip.add((new TranslationTextComponent("effect.none")).withStyle(TextFormatting.GRAY)); + tooltip.add((new TranslatableComponent("effect.none")).withStyle(ChatFormatting.GRAY)); } else { - for (EffectInstance effectinstance : list) { - TranslationTextComponent textcomponent = new TranslationTextComponent(effectinstance.getDescriptionId()); - Effect effect = effectinstance.getEffect(); + for (MobEffectInstance effectinstance : list) { + TranslatableComponent textcomponent = new TranslatableComponent(effectinstance.getDescriptionId()); + MobEffect effect = effectinstance.getEffect(); Map map = effect.getAttributeModifiers(); if (!map.isEmpty()) { for (Entry entry : map.entrySet()) { @@ -118,12 +118,12 @@ public class PotionFluidHandler { if (effectinstance.getAmplifier() > 0) { textcomponent.append(" ") - .append(new TranslationTextComponent("potion.potency." + effectinstance.getAmplifier()).getString()); + .append(new TranslatableComponent("potion.potency." + effectinstance.getAmplifier()).getString()); } if (effectinstance.getDuration() > 20) { textcomponent.append(" (") - .append(EffectUtils.formatDuration(effectinstance, p_185182_2_)) + .append(MobEffectUtil.formatDuration(effectinstance, p_185182_2_)) .append(")"); } @@ -133,8 +133,8 @@ public class PotionFluidHandler { } if (!list1.isEmpty()) { - tooltip.add(new StringTextComponent("")); - tooltip.add((new TranslationTextComponent("potion.whenDrank")).withStyle(TextFormatting.DARK_PURPLE)); + tooltip.add(new TextComponent("")); + tooltip.add((new TranslatableComponent("potion.whenDrank")).withStyle(ChatFormatting.DARK_PURPLE)); for (Tuple tuple : list1) { AttributeModifier attributemodifier2 = tuple.getB(); @@ -148,20 +148,20 @@ public class PotionFluidHandler { } if (d0 > 0.0D) { - tooltip.add((new TranslationTextComponent( + tooltip.add((new TranslatableComponent( "attribute.modifier.plus." + attributemodifier2.getOperation() .toValue(), ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1), - new TranslationTextComponent(tuple.getA()))) - .withStyle(TextFormatting.BLUE)); + new TranslatableComponent(tuple.getA()))) + .withStyle(ChatFormatting.BLUE)); } else if (d0 < 0.0D) { d1 = d1 * -1.0D; - tooltip.add((new TranslationTextComponent( + tooltip.add((new TranslatableComponent( "attribute.modifier.take." + attributemodifier2.getOperation() .toValue(), ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1), - new TranslationTextComponent(tuple.getA()))) - .withStyle(TextFormatting.RED)); + new TranslatableComponent(tuple.getA()))) + .withStyle(ChatFormatting.RED)); } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java index d77dd5520..1bf7e0d43 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java @@ -5,8 +5,8 @@ import java.util.List; import com.simibubi.create.foundation.utility.ISimpleReloadListener; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; public class FluidTransferRecipes { 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 52e356dd0..75c7bf4ea 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 @@ -17,13 +17,13 @@ import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuild import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.utility.ISimpleReloadListener; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionBrewing; -import net.minecraft.potion.PotionUtils; -import net.minecraft.potion.Potions; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionBrewing; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; import net.minecraftforge.common.brewing.BrewingRecipeRegistry; import net.minecraftforge.common.brewing.IBrewingRecipe; import net.minecraftforge.common.brewing.VanillaBrewingRecipe; 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..068db8ac8 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 @@ -5,13 +5,15 @@ import java.util.function.Consumer; import com.simibubi.create.foundation.fluid.SmartFluidTank; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.network.chat.Component; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; + public class CreativeFluidTankTileEntity extends FluidTankTileEntity { - public CreativeFluidTankTileEntity(TileEntityType tileEntityTypeIn) { + public CreativeFluidTankTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } @@ -21,7 +23,7 @@ public class CreativeFluidTankTileEntity extends FluidTankTileEntity { } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { return false; } 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 0ad417194..5e9a8e040 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 @@ -11,42 +11,44 @@ import com.simibubi.create.foundation.fluid.FluidHelper.FluidExchange; import com.simibubi.create.foundation.tileEntity.ComparatorUtil; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SoundType; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.particles.BlockParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.StateContainer.Builder; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.tags.FluidTags; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class FluidTankBlock extends Block implements IWrenchable, ITE { public static final BooleanProperty TOP = BooleanProperty.create("top"); @@ -76,7 +78,7 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE tankCapability = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY); if (!tankCapability.isPresent()) - return ActionResultType.PASS; + return InteractionResult.PASS; IFluidHandler fluidTank = tankCapability.orElse(null); FluidStack prevFluidInTank = fluidTank.getFluidInTank(0) .copy(); @@ -137,8 +139,8 @@ 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/FluidTankCTBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankCTBehaviour.java index 3f7ff915f..04c77c6e4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankCTBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankCTBehaviour.java @@ -3,10 +3,10 @@ package com.simibubi.create.content.contraptions.fluids.tank; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.block.connected.HorizontalCTBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; public class FluidTankCTBehaviour extends HorizontalCTBehaviour { @@ -19,7 +19,7 @@ public class FluidTankCTBehaviour extends HorizontalCTBehaviour { } @Override - public boolean connectsTo(BlockState state, BlockState other, IBlockDisplayReader reader, BlockPos pos, BlockPos otherPos, + public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, Direction face) { return state.getBlock() == other.getBlock() && FluidTankConnectivityHandler.isConnected(reader, pos, otherPos); } 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 02f1d3116..fc9d59780 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 @@ -17,15 +17,15 @@ import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.content.contraptions.fluids.tank.CreativeFluidTankTileEntity.CreativeSmartFluidTank; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -42,7 +42,7 @@ public class FluidTankConnectivityHandler { formTanks(te.getType(), te.getLevel(), cache, frontier); } - private static void formTanks(TileEntityType type, IBlockReader world, TankSearchCache cache, + private static void formTanks(BlockEntityType type, BlockGetter world, TankSearchCache cache, List frontier) { PriorityQueue> creationQueue = makeCreationQueue(); Set visited = new HashSet<>(); @@ -149,8 +149,8 @@ public class FluidTankConnectivityHandler { boolean simulate) { int amount = 0; int height = 0; - TileEntityType type = te.getType(); - World world = te.getLevel(); + BlockEntityType type = te.getType(); + Level world = te.getLevel(); BlockPos origin = te.getBlockPos(); LazyOptional capability = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY); FluidTank teTank = (FluidTank) capability.orElse(null); @@ -253,7 +253,7 @@ public class FluidTankConnectivityHandler { if (width == 1 && height == 1) return; - World world = te.getLevel(); + Level world = te.getLevel(); BlockPos origin = te.getBlockPos(); List frontier = new ArrayList<>(); FluidStack toDistribute = te.tankInventory.getFluid() @@ -316,16 +316,16 @@ public class FluidTankConnectivityHandler { } @Nullable - public static FluidTankTileEntity tankAt(TileEntityType type, IBlockReader world, BlockPos pos) { - TileEntity te = world.getBlockEntity(pos); + public static FluidTankTileEntity tankAt(BlockEntityType type, BlockGetter world, BlockPos pos) { + BlockEntity te = world.getBlockEntity(pos); if (te instanceof FluidTankTileEntity && te.getType() == type) return (FluidTankTileEntity) te; return null; } @Nullable - public static FluidTankTileEntity anyTankAt(IBlockReader world, BlockPos pos) { - TileEntity te = world.getBlockEntity(pos); + public static FluidTankTileEntity anyTankAt(BlockGetter world, BlockPos pos) { + BlockEntity te = world.getBlockEntity(pos); if (te instanceof FluidTankTileEntity) return (FluidTankTileEntity) te; return null; @@ -350,7 +350,7 @@ public class FluidTankConnectivityHandler { return controllerMap.containsKey(pos); } - Optional getOrCache(TileEntityType type, IBlockReader world, BlockPos pos) { + Optional getOrCache(BlockEntityType type, BlockGetter world, BlockPos pos) { if (hasVisited(pos)) return controllerMap.get(pos); FluidTankTileEntity tankAt = tankAt(type, world, pos); @@ -369,9 +369,9 @@ public class FluidTankConnectivityHandler { } - public static boolean isConnected(IBlockReader world, BlockPos tankPos, BlockPos otherTankPos) { - TileEntity te1 = world.getBlockEntity(tankPos); - TileEntity te2 = world.getBlockEntity(otherTankPos); + public static boolean isConnected(BlockGetter world, BlockPos tankPos, BlockPos otherTankPos) { + BlockEntity te1 = world.getBlockEntity(tankPos); + BlockEntity 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 71fdd634b..a5349224d 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 @@ -6,8 +6,8 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.client.model.generators.ModelFile; public class FluidTankGenerator extends SpecialBlockStateGen { 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 348fbcb45..e9cb22c5f 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 @@ -1,19 +1,21 @@ package com.simibubi.create.content.contraptions.fluids.tank; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; +import net.minecraft.world.item.Item.Properties; + public class FluidTankItem extends BlockItem { public FluidTankItem(Block p_i48527_1_, Properties p_i48527_2_) { @@ -21,8 +23,8 @@ public class FluidTankItem extends BlockItem { } @Override - public ActionResultType place(BlockItemUseContext ctx) { - ActionResultType initialResult = super.place(ctx); + public InteractionResult place(BlockPlaceContext ctx) { + InteractionResult initialResult = super.place(ctx); if (!initialResult.consumesAction()) return initialResult; tryMultiPlace(ctx); @@ -30,12 +32,12 @@ public class FluidTankItem extends BlockItem { } @Override - protected boolean updateCustomBlockEntityTag(BlockPos p_195943_1_, World p_195943_2_, PlayerEntity p_195943_3_, + protected boolean updateCustomBlockEntityTag(BlockPos p_195943_1_, Level p_195943_2_, Player 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_.getTagElement("BlockEntityTag"); + CompoundTag nbt = p_195943_4_.getTagElement("BlockEntityTag"); if (nbt != null) { nbt.remove("Luminosity"); nbt.remove("Size"); @@ -46,15 +48,15 @@ public class FluidTankItem extends BlockItem { FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt.getCompound("TankContent")); if (!fluid.isEmpty()) { fluid.setAmount(Math.min(FluidTankTileEntity.getCapacityMultiplier(), fluid.getAmount())); - nbt.put("TankContent", fluid.writeToNBT(new CompoundNBT())); + nbt.put("TankContent", fluid.writeToNBT(new CompoundTag())); } } } 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(); + private void tryMultiPlace(BlockPlaceContext ctx) { + Player player = ctx.getPlayer(); if (player == null) return; if (player.isShiftKeyDown()) @@ -64,7 +66,7 @@ public class FluidTankItem extends BlockItem { .isVertical()) return; ItemStack stack = ctx.getItemInHand(); - World world = ctx.getLevel(); + Level world = ctx.getLevel(); BlockPos pos = ctx.getClickedPos(); BlockPos placedOnPos = pos.relative(face.getOpposite()); BlockState placedOnState = world.getBlockState(placedOnPos); @@ -113,7 +115,7 @@ public class FluidTankItem extends BlockItem { BlockState blockState = world.getBlockState(offsetPos); if (FluidTankBlock.isTank(blockState)) continue; - BlockItemUseContext context = BlockItemUseContext.at(ctx, offsetPos, face); + BlockPlaceContext context = BlockPlaceContext.at(ctx, offsetPos, face); player.getPersistentData() .putBoolean("SilenceTankSound", true); super.place(context); 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 08019b105..c8da5d253 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 @@ -11,12 +11,12 @@ import com.simibubi.create.foundation.block.connected.CTModel; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap.Builder; import net.minecraftforge.client.model.data.ModelProperty; @@ -25,20 +25,20 @@ public class FluidTankModel extends CTModel { protected static ModelProperty CULL_PROPERTY = new ModelProperty<>(); - public static FluidTankModel standard(IBakedModel originalModel) { + public static FluidTankModel standard(BakedModel originalModel) { return new FluidTankModel(originalModel, AllSpriteShifts.FLUID_TANK, AllSpriteShifts.COPPER_CASING); } - public static FluidTankModel creative(IBakedModel originalModel) { + public static FluidTankModel creative(BakedModel originalModel) { return new FluidTankModel(originalModel, AllSpriteShifts.CREATIVE_FLUID_TANK, AllSpriteShifts.CREATIVE_CASING); } - private FluidTankModel(IBakedModel originalModel, CTSpriteShiftEntry side, CTSpriteShiftEntry top) { + private FluidTankModel(BakedModel originalModel, CTSpriteShiftEntry side, CTSpriteShiftEntry top) { super(originalModel, new FluidTankCTBehaviour(side, top)); } @Override - protected Builder gatherModelData(Builder builder, IBlockDisplayReader world, BlockPos pos, BlockState state) { + protected Builder gatherModelData(Builder builder, BlockAndTintGetter world, BlockPos pos, BlockState state) { CullData cullData = new CullData(); for (Direction d : Iterate.horizontalDirections) cullData.setCulled(d, FluidTankConnectivityHandler.isConnected(world, pos, pos.relative(d))); 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 fc46d3386..adffc6db1 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 @@ -1,24 +1,24 @@ package com.simibubi.create.content.contraptions.fluids.tank; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.util.Mth; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.templates.FluidTank; public class FluidTankRenderer extends SafeTileEntityRenderer { - public FluidTankRenderer(TileEntityRendererDispatcher dispatcher) { + public FluidTankRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(FluidTankTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(FluidTankTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (!te.isController()) return; @@ -37,7 +37,7 @@ public class FluidTankRenderer extends SafeTileEntityRenderer tileEntityTypeIn) { + public FluidTankTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); tankInventory = createInventory(); fluidCapability = LazyOptional.of(() -> tankInventory); @@ -181,7 +181,7 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI public FluidTankTileEntity getControllerTE() { if (isController()) return this; - TileEntity tileEntity = level.getBlockEntity(controller); + BlockEntity tileEntity = level.getBlockEntity(controller); if (tileEntity instanceof FluidTankTileEntity) return (FluidTankTileEntity) tileEntity; return null; @@ -308,7 +308,7 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { + public AABB getRenderBoundingBox() { if (renderBoundingBox == null) { renderBoundingBox = super.getRenderBoundingBox(); } @@ -324,14 +324,14 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI @Nullable public FluidTankTileEntity getOtherFluidTankTileEntity(Direction direction) { - TileEntity otherTE = level.getBlockEntity(worldPosition.relative(direction)); + BlockEntity otherTE = level.getBlockEntity(worldPosition.relative(direction)); if (otherTE instanceof FluidTankTileEntity) return (FluidTankTileEntity) otherTE; return null; } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { FluidTankTileEntity controllerTE = getControllerTE(); if (controllerTE == null) return false; @@ -340,7 +340,7 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); BlockPos controllerBefore = controller; @@ -354,9 +354,9 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI lastKnownPos = null; if (compound.contains("LastKnownPos")) - lastKnownPos = NBTUtil.readBlockPos(compound.getCompound("LastKnownPos")); + lastKnownPos = NbtUtils.readBlockPos(compound.getCompound("LastKnownPos")); if (compound.contains("Controller")) - controller = NBTUtil.readBlockPos(compound.getCompound("Controller")); + controller = NbtUtils.readBlockPos(compound.getCompound("Controller")); if (isController()) { window = compound.getBoolean("Window"); @@ -404,16 +404,16 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { if (updateConnectivity) compound.putBoolean("Uninitialized", true); if (lastKnownPos != null) - compound.put("LastKnownPos", NBTUtil.writeBlockPos(lastKnownPos)); + compound.put("LastKnownPos", NbtUtils.writeBlockPos(lastKnownPos)); if (!isController()) - compound.put("Controller", NBTUtil.writeBlockPos(controller)); + compound.put("Controller", NbtUtils.writeBlockPos(controller)); if (isController()) { compound.putBoolean("Window", window); - compound.put("TankContent", tankInventory.writeToNBT(new CompoundNBT())); + compound.put("TankContent", tankInventory.writeToNBT(new CompoundTag())); compound.putInt("Size", width); compound.putInt("Height", height); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleConfigScreen.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleConfigScreen.java index 18e4088bb..555443382 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleConfigScreen.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleConfigScreen.java @@ -3,47 +3,47 @@ package com.simibubi.create.content.contraptions.goggles; import java.util.ArrayList; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.gui.AbstractSimiScreen; import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.ITextProperties; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; public class GoggleConfigScreen extends AbstractSimiScreen { private int offsetX; private int offsetY; - private final List tooltip; + private final List tooltip; public GoggleConfigScreen() { - ITextComponent componentSpacing = new StringTextComponent(" "); + Component componentSpacing = new TextComponent(" "); tooltip = new ArrayList<>(); tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay1"))); tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay2") - .withStyle(TextFormatting.GRAY))); - tooltip.add(StringTextComponent.EMPTY); + .withStyle(ChatFormatting.GRAY))); + tooltip.add(TextComponent.EMPTY); tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay3"))); tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay4"))); - tooltip.add(StringTextComponent.EMPTY); + tooltip.add(TextComponent.EMPTY); tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay5") - .withStyle(TextFormatting.GRAY))); + .withStyle(ChatFormatting.GRAY))); tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay6") - .withStyle(TextFormatting.GRAY))); - tooltip.add(StringTextComponent.EMPTY); + .withStyle(ChatFormatting.GRAY))); + tooltip.add(TextComponent.EMPTY); tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("gui.config.overlay7"))); tooltip.add(componentSpacing.plainCopy() @@ -88,7 +88,7 @@ public class GoggleConfigScreen extends AbstractSimiScreen { int titleLinesCount = 1; int tooltipTextWidth = 0; - for (ITextProperties textLine : tooltip) { + for (FormattedText textLine : tooltip) { int textLineWidth = minecraft.font.width(textLine); if (textLineWidth > tooltipTextWidth) tooltipTextWidth = textLineWidth; @@ -100,12 +100,12 @@ public class GoggleConfigScreen extends AbstractSimiScreen { tooltipHeight += 2; // gap between title lines and next lines } - offsetX = MathHelper.clamp(offsetX, -(width / 2) - 5, (width / 2) - tooltipTextWidth - 20); - offsetY = MathHelper.clamp(offsetY, -(height / 2) + 17, (height / 2) - tooltipHeight + 5); + offsetX = Mth.clamp(offsetX, -(width / 2) - 5, (width / 2) - tooltipTextWidth - 20); + offsetY = Mth.clamp(offsetY, -(height / 2) + 17, (height / 2) - tooltipHeight + 5); } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int posX = this.width / 2 + offsetX; int posY = this.height / 2 + offsetY; renderComponentTooltip(ms, tooltip, posX, posY); 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 51a5575b1..55e2f5aff 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 @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; import java.util.function.Supplier; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.CreateClient; @@ -24,22 +24,22 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.outliner.Outline; import com.simibubi.create.foundation.utility.outliner.Outliner.OutlineEntry; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.ITextProperties; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.HitResult; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.fml.client.gui.GuiUtils; public class GoggleOverlayRenderer { @@ -50,11 +50,11 @@ public class GoggleOverlayRenderer { public static int hoverTicks = 0; public static BlockPos lastHovered = null; - public static void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, + public static void renderOverlay(PoseStack ms, MultiBufferSource buffer, int light, int overlay, float partialTicks) { - RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; + HitResult objectMouseOver = Minecraft.getInstance().hitResult; - if (!(objectMouseOver instanceof BlockRayTraceResult)) { + if (!(objectMouseOver instanceof BlockHitResult)) { lastHovered = null; hoverTicks = 0; return; @@ -68,12 +68,12 @@ public class GoggleOverlayRenderer { return; } - BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; + BlockHitResult result = (BlockHitResult) objectMouseOver; Minecraft mc = Minecraft.getInstance(); - ClientWorld world = mc.level; + ClientLevel world = mc.level; BlockPos pos = result.getBlockPos(); - ItemStack headSlot = mc.player.getItemBySlot(EquipmentSlotType.HEAD); - TileEntity te = world.getBlockEntity(pos); + ItemStack headSlot = mc.player.getItemBySlot(EquipmentSlot.HEAD); + BlockEntity te = world.getBlockEntity(pos); if (lastHovered == null || lastHovered.equals(pos)) hoverTicks++; @@ -91,7 +91,7 @@ public class GoggleOverlayRenderer { boolean goggleAddedInformation = false; boolean hoverAddedInformation = false; - List tooltip = new ArrayList<>(); + List tooltip = new ArrayList<>(); if (hasGoggleInformation && wearingGoggles) { IHaveGoggleInformation gte = (IHaveGoggleInformation) te; @@ -100,7 +100,7 @@ public class GoggleOverlayRenderer { if (hasHoveringInformation) { if (!tooltip.isEmpty()) - tooltip.add(StringTextComponent.EMPTY); + tooltip.add(TextComponent.EMPTY); IHaveHoveringInformation hte = (IHaveHoveringInformation) te; hoverAddedInformation = hte.addToTooltip(tooltip, mc.player.isShiftKeyDown()); @@ -138,11 +138,11 @@ public class GoggleOverlayRenderer { if (!pistonFound) return; if (!tooltip.isEmpty()) - tooltip.add(StringTextComponent.EMPTY); + tooltip.add(TextComponent.EMPTY); tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy() .append(Lang.translate("gui.goggles.pole_length")) - .append(new StringTextComponent(" " + poles))); + .append(new TextComponent(" " + poles))); } if (tooltip.isEmpty()) @@ -157,7 +157,7 @@ public class GoggleOverlayRenderer { int titleLinesCount = 1; int tooltipTextWidth = 0; - for (ITextProperties textLine : tooltip) { + for (FormattedText textLine : tooltip) { int textLineWidth = mc.font.width(textLine); if (textLineWidth > tooltipTextWidth) tooltipTextWidth = textLineWidth; @@ -177,7 +177,7 @@ public class GoggleOverlayRenderer { posX = Math.min(posX, tooltipScreen.width - tooltipTextWidth - 20); posY = Math.min(posY, tooltipScreen.height - tooltipHeight - 20); - float fade = MathHelper.clamp((hoverTicks + partialTicks) / 12f, 0, 1); + float fade = Mth.clamp((hoverTicks + partialTicks) / 12f, 0, 1); Boolean useCustom = cfg.overlayCustomColor.get(); Color colorBackground = useCustom ? new Color(cfg.overlayBackgroundColor.get()) : @@ -215,7 +215,7 @@ public class GoggleOverlayRenderer { } public static final class TooltipScreen extends Screen { - public TooltipScreen(ITextComponent p_i51108_1_) { + public TooltipScreen(Component p_i51108_1_) { super(p_i51108_1_); } 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 f85c88d8a..d37f824fe 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 @@ -2,17 +2,19 @@ package com.simibubi.create.content.contraptions.goggles; import com.simibubi.create.AllItems; -import net.minecraft.block.DispenserBlock; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.world.World; +import net.minecraft.world.level.block.DispenserBlock; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.level.Level; + +import net.minecraft.world.item.Item.Properties; public class GogglesItem extends Item { @@ -22,24 +24,24 @@ public class GogglesItem extends Item { } @Override - public EquipmentSlotType getEquipmentSlot(ItemStack stack) { - return EquipmentSlotType.HEAD; + public EquipmentSlot getEquipmentSlot(ItemStack stack) { + return EquipmentSlot.HEAD; } - public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { + public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { ItemStack itemstack = playerIn.getItemInHand(handIn); - EquipmentSlotType equipmentslottype = MobEntity.getEquipmentSlotForItem(itemstack); + EquipmentSlot equipmentslottype = Mob.getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = playerIn.getItemBySlot(equipmentslottype); if (itemstack1.isEmpty()) { playerIn.setItemSlot(equipmentslottype, itemstack.copy()); itemstack.setCount(0); - return new ActionResult<>(ActionResultType.SUCCESS, itemstack); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, itemstack); } else { - return new ActionResult<>(ActionResultType.FAIL, itemstack); + return new InteractionResultHolder<>(InteractionResult.FAIL, itemstack); } } - public static boolean canSeeParticles(PlayerEntity player) { + public static boolean canSeeParticles(Player player) { for (ItemStack itemStack : player.getArmorSlots()) if (AllItems.GOGGLES.isIn(itemStack)) return true; diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesModel.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesModel.java index 9ba2b63dd..09b865ed1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesModel.java @@ -1,20 +1,20 @@ package com.simibubi.create.content.contraptions.goggles; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraftforge.client.model.BakedModelWrapper; -public class GogglesModel extends BakedModelWrapper { +public class GogglesModel extends BakedModelWrapper { - public GogglesModel(IBakedModel template) { + public GogglesModel(BakedModel template) { super(template); } @Override - public IBakedModel handlePerspective(TransformType cameraTransformType, MatrixStack mat) { + public BakedModel handlePerspective(TransformType cameraTransformType, PoseStack mat) { if (cameraTransformType == TransformType.HEAD) return AllBlockPartials.GOGGLES.get() .handlePerspective(cameraTransformType, mat); 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 f9a34b0eb..5f93eaf9c 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 @@ -8,10 +8,10 @@ import java.util.Optional; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.Minecraft; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -23,7 +23,7 @@ public interface IHaveGoggleInformation { Format numberFormat = new Format(); String spacing = " "; - ITextComponent componentSpacing = new StringTextComponent(spacing); + Component componentSpacing = new TextComponent(spacing); /** * this method will be called when looking at a TileEntity that implemented this @@ -32,7 +32,7 @@ public interface IHaveGoggleInformation { * @return {@code true} if the tooltip creation was successful and should be displayed, * or {@code false} if the overlay should not be displayed * */ - default boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking){ + default boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking){ return false; } @@ -41,9 +41,9 @@ public interface IHaveGoggleInformation { .format(d).replace("\u00A0", " "); } - default boolean containedFluidTooltip(List tooltip, boolean isPlayerSneaking, LazyOptional handler) { + default boolean containedFluidTooltip(List tooltip, boolean isPlayerSneaking, LazyOptional handler) { tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.goggles.fluid_container"))); - TranslationTextComponent mb = Lang.translate("generic.unit.millibuckets"); + TranslatableComponent mb = Lang.translate("generic.unit.millibuckets"); Optional resolve = handler.resolve(); if (!resolve.isPresent()) return false; @@ -52,7 +52,7 @@ public interface IHaveGoggleInformation { if (tank.getTanks() == 0) return false; - ITextComponent indent = new StringTextComponent(spacing + " "); + Component indent = new TextComponent(spacing + " "); boolean isEmpty = true; for (int i = 0; i < tank.getTanks(); i++) { @@ -60,10 +60,10 @@ public interface IHaveGoggleInformation { if (fluidStack.isEmpty()) continue; - 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); + Component fluidName = new TranslatableComponent(fluidStack.getTranslationKey()).withStyle(ChatFormatting.GRAY); + Component contained = new TextComponent(format(fluidStack.getAmount())).append(mb).withStyle(ChatFormatting.GOLD); + Component slash = new TextComponent(" / ").withStyle(ChatFormatting.GRAY); + Component capacity = new TextComponent(format(tank.getTankCapacity(i))).append(mb).withStyle(ChatFormatting.DARK_GRAY); tooltip.add(indent.plainCopy() .append(fluidName)); @@ -84,8 +84,8 @@ public interface IHaveGoggleInformation { if (!isEmpty) return true; - 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); + Component capacity = Lang.translate("gui.goggles.fluid_container.capacity").withStyle(ChatFormatting.GRAY); + Component amount = new TextComponent(format(tank.getTankCapacity(0))).append(mb).withStyle(ChatFormatting.GOLD); tooltip.add(indent.plainCopy() .append(capacity) diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveHoveringInformation.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveHoveringInformation.java index e4531bc91..1db2b6a22 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveHoveringInformation.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveHoveringInformation.java @@ -2,14 +2,14 @@ package com.simibubi.create.content.contraptions.goggles; import java.util.List; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.network.chat.Component; /* * Implement this Interface in the TileEntity class that wants to add info to the screen * */ public interface IHaveHoveringInformation { - default boolean addToTooltip(List tooltip, boolean isPlayerSneaking){ + default boolean addToTooltip(List tooltip, boolean isPlayerSneaking){ return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/IAssemblyRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/IAssemblyRecipe.java index 9958cf457..1344c2a7d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/IAssemblyRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/itemAssembly/IAssemblyRecipe.java @@ -7,9 +7,9 @@ import java.util.function.Supplier; import com.simibubi.create.compat.jei.category.sequencedAssembly.SequencedAssemblySubCategory; import com.simibubi.create.foundation.fluid.FluidIngredient; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.ItemLike; +import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -20,9 +20,9 @@ public interface IAssemblyRecipe { } @OnlyIn(Dist.CLIENT) - public ITextComponent getDescriptionForAssembly(); + public Component getDescriptionForAssembly(); - public void addRequiredMachines(Set list); + public void addRequiredMachines(Set list); public void addAssemblyIngredients(List list); 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 36eead8d9..ae2d620d2 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 @@ -2,12 +2,14 @@ package com.simibubi.create.content.contraptions.itemAssembly; import com.simibubi.create.foundation.utility.Color; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.NonNullList; +import net.minecraft.util.Mth; + +import net.minecraft.world.item.Item.Properties; public class SequencedAssemblyItem extends Item { @@ -16,16 +18,16 @@ public class SequencedAssemblyItem extends Item { } @Override - public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) {} + public void fillItemCategory(CreativeModeTab p_150895_1_, NonNullList p_150895_2_) {} @Override public double getDurabilityForDisplay(ItemStack stack) { if (!stack.hasTag()) return 1; - CompoundNBT tag = stack.getTag(); + CompoundTag tag = stack.getTag(); if (!tag.contains("SequencedAssembly")) return 1; - return MathHelper.lerp(tag.getCompound("SequencedAssembly") + return Mth.lerp(tag.getCompound("SequencedAssembly") .getFloat("Progress"), 1, 0); } 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 92f4f70a7..5eaa4a84e 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 @@ -16,25 +16,25 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Pair; import net.minecraft.client.Minecraft; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.wrapper.RecipeWrapper; -public class SequencedAssemblyRecipe implements IRecipe { +public class SequencedAssemblyRecipe implements Recipe { protected ResourceLocation id; protected SequencedAssemblyRecipeSerializer serializer; @@ -53,15 +53,15 @@ public class SequencedAssemblyRecipe implements IRecipe { loops = 5; } - public static > Optional getRecipe(World world, C inv, - IRecipeType type, Class recipeClass) { + public static > Optional getRecipe(Level world, C inv, + RecipeType type, Class recipeClass) { //return getRecipe(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) { + public static > Optional getRecipe(Level world, ItemStack item, + RecipeType type, Class recipeClass) { List all = world.getRecipeManager() .getAllRecipesFor(AllRecipeTypes.SEQUENCED_ASSEMBLY.getType()); for (SequencedAssemblyRecipe sequencedAssemblyRecipe : all) { @@ -77,8 +77,8 @@ public class SequencedAssemblyRecipe implements IRecipe { return Optional.empty(); } - public static > Stream getRecipes(World world, ItemStack item, - IRecipeType type, Class recipeClass) { + public static > Stream getRecipes(Level world, ItemStack item, + RecipeType type, Class recipeClass) { List all = world.getRecipeManager() .getAllRecipesFor(AllRecipeTypes.SEQUENCED_ASSEMBLY.getType()); @@ -101,8 +101,8 @@ public class SequencedAssemblyRecipe implements IRecipe { return rollResult(); ItemStack advancedItem = ItemHandlerHelper.copyStackWithSize(getTransitionalItem(), 1); - CompoundNBT itemTag = advancedItem.getOrCreateTag(); - CompoundNBT tag = new CompoundNBT(); + CompoundTag itemTag = advancedItem.getOrCreateTag(); + CompoundTag tag = new CompoundTag(); tag.putString("id", id.toString()); tag.putInt("Step", step + 1); tag.putFloat("Progress", (step + 1f) / (sequence.size() * loops)); @@ -118,7 +118,7 @@ public class SequencedAssemblyRecipe implements IRecipe { public void addAdditionalIngredientsAndMachines(List list) { sequence.forEach(sr -> sr.getAsAssemblyRecipe() .addAssemblyIngredients(list)); - Set machines = new HashSet<>(); + Set machines = new HashSet<>(); sequence.forEach(sr -> sr.getAsAssemblyRecipe() .addRequiredMachines(machines)); machines.stream() @@ -162,7 +162,7 @@ public class SequencedAssemblyRecipe implements IRecipe { private int getStep(ItemStack input) { if (!input.hasTag()) return 0; - CompoundNBT tag = input.getTag(); + CompoundTag tag = input.getTag(); if (!tag.contains("SequencedAssembly")) return 0; int step = tag.getCompound("SequencedAssembly") @@ -171,7 +171,7 @@ public class SequencedAssemblyRecipe implements IRecipe { } @Override - public boolean matches(RecipeWrapper inv, World p_77569_2_) { + public boolean matches(RecipeWrapper inv, Level p_77569_2_) { return false; } @@ -205,7 +205,7 @@ public class SequencedAssemblyRecipe implements IRecipe { } @Override - public IRecipeSerializer getSerializer() { + public RecipeSerializer getSerializer() { return serializer; } @@ -215,23 +215,23 @@ public class SequencedAssemblyRecipe implements IRecipe { } @Override - public IRecipeType getType() { + public RecipeType getType() { return AllRecipeTypes.SEQUENCED_ASSEMBLY.getType(); } @OnlyIn(Dist.CLIENT) - public static void addToTooltip(List toolTip, ItemStack stack) { + public static void addToTooltip(List toolTip, ItemStack stack) { if (!stack.hasTag() || !stack.getTag() .contains("SequencedAssembly")) return; - CompoundNBT compound = stack.getTag() + CompoundTag compound = stack.getTag() .getCompound("SequencedAssembly"); ResourceLocation resourceLocation = new ResourceLocation(compound.getString("id")); - Optional> recipe = Minecraft.getInstance().level.getRecipeManager() + Optional> recipe = Minecraft.getInstance().level.getRecipeManager() .byKey(resourceLocation); if (!recipe.isPresent()) return; - IRecipe iRecipe = recipe.get(); + Recipe iRecipe = recipe.get(); if (!(iRecipe instanceof SequencedAssemblyRecipe)) return; @@ -239,25 +239,25 @@ public class SequencedAssemblyRecipe implements IRecipe { int length = sequencedAssemblyRecipe.sequence.size(); int step = sequencedAssemblyRecipe.getStep(stack); int total = length * sequencedAssemblyRecipe.loops; - toolTip.add(new StringTextComponent("")); + toolTip.add(new TextComponent("")); toolTip.add(Lang.translate("recipe.sequenced_assembly") - .withStyle(TextFormatting.GRAY)); + .withStyle(ChatFormatting.GRAY)); toolTip.add(Lang.translate("recipe.assembly.progress", step, total) - .withStyle(TextFormatting.DARK_GRAY)); + .withStyle(ChatFormatting.DARK_GRAY)); int remaining = total - step; for (int i = 0; i < length; i++) { if (i >= remaining) break; SequencedRecipe sequencedRecipe = sequencedAssemblyRecipe.sequence.get((i + step) % length); - ITextComponent textComponent = sequencedRecipe.getAsAssemblyRecipe() + Component textComponent = sequencedRecipe.getAsAssemblyRecipe() .getDescriptionForAssembly(); if (i == 0) toolTip.add(Lang.translate("recipe.assembly.next", textComponent) - .withStyle(TextFormatting.AQUA)); + .withStyle(ChatFormatting.AQUA)); else - toolTip.add(new StringTextComponent("-> ").append(textComponent) - .withStyle(TextFormatting.DARK_AQUA)); + toolTip.add(new TextComponent("-> ").append(textComponent) + .withStyle(ChatFormatting.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 c1095a0b4..a6a01cb51 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 @@ -13,14 +13,14 @@ import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeFactory; -import net.minecraft.data.IFinishedRecipe; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.tags.ITag; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.tags.Tag; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.conditions.ICondition; @@ -48,11 +48,11 @@ public class SequencedAssemblyRecipeBuilder { return this; } - public SequencedAssemblyRecipeBuilder require(IItemProvider ingredient) { + public SequencedAssemblyRecipeBuilder require(ItemLike ingredient) { return require(Ingredient.of(ingredient)); } - public SequencedAssemblyRecipeBuilder require(ITag.INamedTag tag) { + public SequencedAssemblyRecipeBuilder require(Tag.Named tag) { return require(Ingredient.of(tag)); } @@ -61,7 +61,7 @@ public class SequencedAssemblyRecipeBuilder { return this; } - public SequencedAssemblyRecipeBuilder transitionTo(IItemProvider item) { + public SequencedAssemblyRecipeBuilder transitionTo(ItemLike item) { recipe.transitionalItem = new ProcessingOutput(new ItemStack(item), 1); return this; } @@ -71,7 +71,7 @@ public class SequencedAssemblyRecipeBuilder { return this; } - public SequencedAssemblyRecipeBuilder addOutput(IItemProvider item, float weight) { + public SequencedAssemblyRecipeBuilder addOutput(ItemLike item, float weight) { return addOutput(new ItemStack(item), weight); } @@ -84,11 +84,11 @@ public class SequencedAssemblyRecipeBuilder { return recipe; } - public void build(Consumer consumer) { + public void build(Consumer consumer) { consumer.accept(new DataGenResult(build(), recipeConditions)); } - public static class DataGenResult implements IFinishedRecipe { + public static class DataGenResult implements FinishedRecipe { private SequencedAssemblyRecipe recipe; private List recipeConditions; @@ -120,7 +120,7 @@ public class SequencedAssemblyRecipeBuilder { } @Override - public IRecipeSerializer getType() { + public RecipeSerializer getType() { return serializer; } 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 91d54fd21..11e82e65d 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 @@ -5,15 +5,15 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.simibubi.create.content.contraptions.processing.ProcessingOutput; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.ForgeRegistryEntry; -public class SequencedAssemblyRecipeSerializer extends ForgeRegistryEntry> - implements IRecipeSerializer { +public class SequencedAssemblyRecipeSerializer extends ForgeRegistryEntry> + implements RecipeSerializer { public SequencedAssemblyRecipeSerializer() {} @@ -32,18 +32,18 @@ public class SequencedAssemblyRecipeSerializer extends ForgeRegistryEntry sr.writeToBuffer(buffer)); @@ -53,7 +53,7 @@ public class SequencedAssemblyRecipeSerializer extends ForgeRegistryEntry> { @@ -42,7 +42,7 @@ public class SequencedRecipe> { public static SequencedRecipe fromJson(JsonObject json, SequencedAssemblyRecipe parent, int index) { ResourceLocation parentId = parent.getId(); - IRecipe recipe = RecipeManager.fromJson( + Recipe recipe = RecipeManager.fromJson( new ResourceLocation(parentId.getNamespace(), parentId.getPath() + "_step_" + index), json); if (recipe instanceof ProcessingRecipe && recipe instanceof IAssemblyRecipe) { ProcessingRecipe processingRecipe = (ProcessingRecipe) recipe; @@ -58,7 +58,7 @@ public class SequencedRecipe> { throw new JsonParseException("Not a supported recipe type"); } - public void writeToBuffer(PacketBuffer buffer) { + public void writeToBuffer(FriendlyByteBuf buffer) { @SuppressWarnings("unchecked") ProcessingRecipeSerializer serializer = (ProcessingRecipeSerializer) wrapped.getSerializer(); buffer.writeResourceLocation(ForgeRegistries.RECIPE_SERIALIZERS.getKey(serializer)); @@ -66,10 +66,10 @@ public class SequencedRecipe> { serializer.toNetwork(buffer, wrapped); } - public static SequencedRecipe readFromBuffer(PacketBuffer buffer) { + public static SequencedRecipe readFromBuffer(FriendlyByteBuf buffer) { ResourceLocation resourcelocation = buffer.readResourceLocation(); ResourceLocation resourcelocation1 = buffer.readResourceLocation(); - IRecipeSerializer serializer = ForgeRegistries.RECIPE_SERIALIZERS.getValue(resourcelocation); + RecipeSerializer serializer = ForgeRegistries.RECIPE_SERIALIZERS.getValue(resourcelocation); if (!(serializer instanceof ProcessingRecipeSerializer)) throw new JsonParseException("Not a supported recipe type"); @SuppressWarnings("rawtypes") 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 62c88b26f..4cafb00d2 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 @@ -8,34 +8,34 @@ import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.Blocks; -import net.minecraft.client.particle.IAnimatedSprite; -import net.minecraft.client.particle.IParticleFactory; -import net.minecraft.client.particle.IParticleRenderType; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.SimpleAnimatedParticle; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particles.BlockParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class AirFlowParticle extends SimpleAnimatedParticle { private final IAirCurrentSource source; - protected AirFlowParticle(ClientWorld world, IAirCurrentSource source, double x, double y, double z, - IAnimatedSprite sprite) { + protected AirFlowParticle(ClientLevel world, IAirCurrentSource source, double x, double y, double z, + SpriteSet sprite) { super(world, x, y, z, sprite, world.random.nextFloat() * .5f); this.source = source; this.quadSize *= 0.75F; this.lifetime = 40; hasPhysics = false; selectSprite(7); - Vector3d offset = VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .25f); + Vec3 offset = VecHelper.offsetRandomly(Vec3.ZERO, Create.RANDOM, .25f); this.setPos(x + offset.x, y + offset.y, z + offset.z); this.xo = x; this.yo = y; @@ -44,8 +44,8 @@ public class AirFlowParticle extends SimpleAnimatedParticle { } @Nonnull - public IParticleRenderType getRenderType() { - return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT; + public ParticleRenderType getRenderType() { + return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT; } @Override @@ -65,19 +65,19 @@ public class AirFlowParticle extends SimpleAnimatedParticle { return; } - Vector3d directionVec = Vector3d.atLowerCornerOf(source.getAirCurrent().direction.getNormal()); - Vector3d motion = directionVec.scale(1 / 8f); + Vec3 directionVec = Vec3.atLowerCornerOf(source.getAirCurrent().direction.getNormal()); + Vec3 motion = directionVec.scale(1 / 8f); if (!source.getAirCurrent().pushing) motion = motion.scale(-1); - double distance = new Vector3d(x, y, z).subtract(VecHelper.getCenterOf(source.getAirCurrentPos())) + double distance = new Vec3(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 + level.random.nextInt(4), + selectSprite((int) Mth.clamp((distance / source.getAirCurrent().maxDistance) * 8 + level.random.nextInt(4), 0, 7)); morphType(distance); @@ -133,7 +133,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle { 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, + level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, Blocks.LAVA.defaultBlockState()), x, y, z, xd * .25f, yd * .25f, zd * .25f); } @@ -150,23 +150,23 @@ public class AirFlowParticle extends SimpleAnimatedParticle { 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; + return this.level.isLoaded(blockpos) ? LevelRenderer.getLightColor(level, blockpos) : 0; } private void selectSprite(int index) { setSprite(sprites.get(index, 8)); } - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + public static class Factory implements ParticleProvider { + private final SpriteSet spriteSet; - public Factory(IAnimatedSprite animatedSprite) { + public Factory(SpriteSet animatedSprite) { this.spriteSet = animatedSprite; } - public Particle createParticle(AirFlowParticleData data, ClientWorld worldIn, double x, double y, double z, + public Particle createParticle(AirFlowParticleData data, ClientLevel worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { - TileEntity te = worldIn.getBlockEntity(new BlockPos(data.posX, data.posY, data.posZ)); + BlockEntity 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 bff77492d..4e5e7f88e 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 @@ -8,15 +8,17 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import com.simibubi.create.AllParticleTypes; -import net.minecraft.client.particle.ParticleManager.IParticleMetaFactory; -import net.minecraft.network.PacketBuffer; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleType; -import net.minecraft.util.math.vector.Vector3i; +import net.minecraft.client.particle.ParticleEngine.SpriteParticleRegistration; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.Vec3i; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public class AirFlowParticleData implements IParticleData, ICustomParticleDataWithSprite { +import net.minecraft.core.particles.ParticleOptions.Deserializer; + +public class AirFlowParticleData implements ParticleOptions, ICustomParticleDataWithSprite { public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( @@ -25,7 +27,7 @@ public class AirFlowParticleData implements IParticleData, ICustomParticleDataWi Codec.INT.fieldOf("z").forGetter(p -> p.posZ)) .apply(i, AirFlowParticleData::new)); - public static final IParticleData.IDeserializer DESERIALIZER = new IParticleData.IDeserializer() { + public static final ParticleOptions.Deserializer DESERIALIZER = new ParticleOptions.Deserializer() { public AirFlowParticleData fromCommand(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { reader.expect(' '); @@ -37,7 +39,7 @@ public class AirFlowParticleData implements IParticleData, ICustomParticleDataWi return new AirFlowParticleData(x, y, z); } - public AirFlowParticleData fromNetwork(ParticleType particleTypeIn, PacketBuffer buffer) { + public AirFlowParticleData fromNetwork(ParticleType particleTypeIn, FriendlyByteBuf buffer) { return new AirFlowParticleData(buffer.readInt(), buffer.readInt(), buffer.readInt()); } }; @@ -46,7 +48,7 @@ public class AirFlowParticleData implements IParticleData, ICustomParticleDataWi final int posY; final int posZ; - public AirFlowParticleData(Vector3i pos) { + public AirFlowParticleData(Vec3i pos) { this(pos.getX(), pos.getY(), pos.getZ()); } @@ -66,7 +68,7 @@ public class AirFlowParticleData implements IParticleData, ICustomParticleDataWi } @Override - public void writeToNetwork(PacketBuffer buffer) { + public void writeToNetwork(FriendlyByteBuf buffer) { buffer.writeInt(posX); buffer.writeInt(posY); buffer.writeInt(posZ); @@ -78,7 +80,7 @@ public class AirFlowParticleData implements IParticleData, ICustomParticleDataWi } @Override - public IDeserializer getDeserializer() { + public Deserializer getDeserializer() { return DESERIALIZER; } @@ -89,7 +91,7 @@ public class AirFlowParticleData implements IParticleData, ICustomParticleDataWi @Override @OnlyIn(Dist.CLIENT) - public IParticleMetaFactory getMetaFactory() { + public SpriteParticleRegistration getMetaFactory() { return AirFlowParticle.Factory::new; } 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 1951cdedb..9b7cf2e06 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 @@ -3,17 +3,17 @@ package com.simibubi.create.content.contraptions.particle; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.client.particle.IAnimatedSprite; -import net.minecraft.client.particle.IParticleFactory; -import net.minecraft.client.particle.IParticleRenderType; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.SimpleAnimatedParticle; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class AirParticle extends SimpleAnimatedParticle { @@ -24,8 +24,8 @@ public class AirParticle extends SimpleAnimatedParticle { private float twirlRadius, twirlAngleOffset; private Axis twirlAxis; - protected AirParticle(ClientWorld world, AirParticleData data, double x, double y, double z, double dx, double dy, - double dz, IAnimatedSprite sprite) { + protected AirParticle(ClientLevel world, AirParticleData data, double x, double y, double z, double dx, double dy, + double dz, SpriteSet sprite) { super(world, x, y, z, sprite, world.random.nextFloat() * .5f); quadSize *= 0.75F; hasPhysics = false; @@ -44,7 +44,7 @@ public class AirParticle extends SimpleAnimatedParticle { twirlAxis = Create.RANDOM.nextBoolean() ? Axis.X : Axis.Z; // speed in m/ticks - double length = new Vector3d(dx, dy, dz).length(); + double length = new Vec3(dx, dy, dz).length(); lifetime = Math.min((int) (length / data.speed), 60); selectSprite(7); setAlpha(.25f); @@ -55,8 +55,8 @@ public class AirParticle extends SimpleAnimatedParticle { } } - public IParticleRenderType getRenderType() { - return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT; + public ParticleRenderType getRenderType() { + return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT; } @Override @@ -71,11 +71,11 @@ public class AirParticle extends SimpleAnimatedParticle { 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); + Vec3 twirl = VecHelper.rotate(new Vec3(0, twirlRadius, 0), angle, twirlAxis); - float x = (float) (MathHelper.lerp(progress, originX, targetX) + twirl.x); - float y = (float) (MathHelper.lerp(progress, originY, targetY) + twirl.y); - float z = (float) (MathHelper.lerp(progress, originZ, targetZ) + twirl.z); + float x = (float) (Mth.lerp(progress, originX, targetX) + twirl.x); + float y = (float) (Mth.lerp(progress, originY, targetY) + twirl.y); + float z = (float) (Mth.lerp(progress, originZ, targetZ) + twirl.z); xd = x - this.x; yd = y - this.y; @@ -87,21 +87,21 @@ public class AirParticle extends SimpleAnimatedParticle { 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; + return this.level.isLoaded(blockpos) ? LevelRenderer.getLightColor(level, blockpos) : 0; } private void selectSprite(int index) { setSprite(sprites.get(index, 8)); } - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + public static class Factory implements ParticleProvider { + private final SpriteSet spriteSet; - public Factory(IAnimatedSprite animatedSprite) { + public Factory(SpriteSet animatedSprite) { this.spriteSet = animatedSprite; } - public Particle createParticle(AirParticleData data, ClientWorld worldIn, double x, double y, double z, double xSpeed, + public Particle createParticle(AirParticleData data, ClientLevel 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 133dc3180..9ab47e610 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 @@ -8,14 +8,16 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import com.simibubi.create.AllParticleTypes; -import net.minecraft.client.particle.ParticleManager.IParticleMetaFactory; -import net.minecraft.network.PacketBuffer; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleType; +import net.minecraft.client.particle.ParticleEngine.SpriteParticleRegistration; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public class AirParticleData implements IParticleData, ICustomParticleDataWithSprite { +import net.minecraft.core.particles.ParticleOptions.Deserializer; + +public class AirParticleData implements ParticleOptions, ICustomParticleDataWithSprite { public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( @@ -23,8 +25,8 @@ public class AirParticleData implements IParticleData, ICustomParticleDataWithSp Codec.FLOAT.fieldOf("speed").forGetter(p -> p.speed)) .apply(i, AirParticleData::new)); - public static final IParticleData.IDeserializer DESERIALIZER = - new IParticleData.IDeserializer() { + public static final ParticleOptions.Deserializer DESERIALIZER = + new ParticleOptions.Deserializer() { public AirParticleData fromCommand(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { reader.expect(' '); @@ -34,7 +36,7 @@ public class AirParticleData implements IParticleData, ICustomParticleDataWithSp return new AirParticleData(drag, speed); } - public AirParticleData fromNetwork(ParticleType particleTypeIn, PacketBuffer buffer) { + public AirParticleData fromNetwork(ParticleType particleTypeIn, FriendlyByteBuf buffer) { return new AirParticleData(buffer.readFloat(), buffer.readFloat()); } }; @@ -57,7 +59,7 @@ public class AirParticleData implements IParticleData, ICustomParticleDataWithSp } @Override - public void writeToNetwork(PacketBuffer buffer) { + public void writeToNetwork(FriendlyByteBuf buffer) { buffer.writeFloat(drag); buffer.writeFloat(speed); } @@ -68,7 +70,7 @@ public class AirParticleData implements IParticleData, ICustomParticleDataWithSp } @Override - public IDeserializer getDeserializer() { + public Deserializer getDeserializer() { return DESERIALIZER; } @@ -79,7 +81,7 @@ public class AirParticleData implements IParticleData, ICustomParticleDataWithSp @Override @OnlyIn(Dist.CLIENT) - public IParticleMetaFactory getMetaFactory() { + public SpriteParticleRegistration getMetaFactory() { return AirParticle.Factory::new; } 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 bc68081d2..d9884d276 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 @@ -4,46 +4,46 @@ import org.lwjgl.opengl.GL11; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.particle.IParticleFactory; -import net.minecraft.client.particle.IParticleRenderType; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.Particle; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.Camera; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.Tesselator; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class CubeParticle extends Particle { - public static final Vector3d[] CUBE = { + public static final Vec3[] CUBE = { // TOP - new Vector3d(1, 1, -1), new Vector3d(1, 1, 1), new Vector3d(-1, 1, 1), new Vector3d(-1, 1, -1), + new Vec3(1, 1, -1), new Vec3(1, 1, 1), new Vec3(-1, 1, 1), new Vec3(-1, 1, -1), // BOTTOM - new Vector3d(-1, -1, -1), new Vector3d(-1, -1, 1), new Vector3d(1, -1, 1), new Vector3d(1, -1, -1), + new Vec3(-1, -1, -1), new Vec3(-1, -1, 1), new Vec3(1, -1, 1), new Vec3(1, -1, -1), // FRONT - new Vector3d(-1, -1, 1), new Vector3d(-1, 1, 1), new Vector3d(1, 1, 1), new Vector3d(1, -1, 1), + new Vec3(-1, -1, 1), new Vec3(-1, 1, 1), new Vec3(1, 1, 1), new Vec3(1, -1, 1), // BACK - new Vector3d(1, -1, -1), new Vector3d(1, 1, -1), new Vector3d(-1, 1, -1), new Vector3d(-1, -1, -1), + new Vec3(1, -1, -1), new Vec3(1, 1, -1), new Vec3(-1, 1, -1), new Vec3(-1, -1, -1), // LEFT - new Vector3d(-1, -1, -1), new Vector3d(-1, 1, -1), new Vector3d(-1, 1, 1), new Vector3d(-1, -1, 1), + new Vec3(-1, -1, -1), new Vec3(-1, 1, -1), new Vec3(-1, 1, 1), new Vec3(-1, -1, 1), // RIGHT - new Vector3d(1, -1, 1), new Vector3d(1, 1, 1), new Vector3d(1, 1, -1), new Vector3d(1, -1, -1) }; + new Vec3(1, -1, 1), new Vec3(1, 1, 1), new Vec3(1, 1, -1), new Vec3(1, -1, -1) }; - public static final Vector3d[] CUBE_NORMALS = { + public static final Vec3[] CUBE_NORMALS = { // modified normals for the sides - new Vector3d(0, 1, 0), new Vector3d(0, -1, 0), new Vector3d(0, 0, 1), new Vector3d(0, 0, 1), new Vector3d(0, 0, 1), - new Vector3d(0, 0, 1), + new Vec3(0, 1, 0), new Vec3(0, -1, 0), new Vec3(0, 0, 1), new Vec3(0, 0, 1), new Vec3(0, 0, 1), + new Vec3(0, 0, 1), /* * new Vector3d(0, 1, 0), new Vector3d(0, -1, 0), new Vector3d(0, 0, 1), new Vector3d(0, 0, @@ -51,7 +51,7 @@ public class CubeParticle extends Particle { */ }; - private static final IParticleRenderType renderType = new IParticleRenderType() { + private static final ParticleRenderType renderType = new ParticleRenderType() { @Override public void begin(BufferBuilder builder, TextureManager textureManager) { RenderSystem.disableTexture(); @@ -68,11 +68,11 @@ public class CubeParticle extends Particle { // RenderSystem.disableBlend(); // RenderSystem.enableLighting(); - builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + builder.begin(GL11.GL_QUADS, DefaultVertexFormat.BLOCK); } @Override - public void end(Tessellator tessellator) { + public void end(Tesselator tessellator) { tessellator.end(); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); @@ -84,7 +84,7 @@ public class CubeParticle extends Particle { protected float scale; protected boolean hot; - public CubeParticle(ClientWorld world, double x, double y, double z, double motionX, double motionY, double motionZ) { + public CubeParticle(ClientLevel world, double x, double y, double z, double motionX, double motionY, double motionZ) { super(world, x, y, z); this.xd = motionX; this.yd = motionY; @@ -115,7 +115,7 @@ public class CubeParticle extends Particle { billowing = true; 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); + Vec3 diff = Vec3.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; } @@ -130,11 +130,11 @@ public class CubeParticle extends Particle { } @Override - 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()); + public void render(VertexConsumer builder, Camera renderInfo, float p_225606_3_) { + Vec3 projectedView = renderInfo.getPosition(); + float lerpedX = (float) (Mth.lerp(p_225606_3_, this.xo, this.x) - projectedView.x()); + float lerpedY = (float) (Mth.lerp(p_225606_3_, this.yo, this.y) - projectedView.y()); + float lerpedZ = (float) (Mth.lerp(p_225606_3_, this.zo, this.z) - projectedView.z()); // int light = getBrightnessForRender(p_225606_3_); int light = 15728880;// 15<<20 && 15<<4 @@ -143,13 +143,13 @@ public class CubeParticle extends Particle { for (int i = 0; i < 6; i++) { // 6 faces to a cube for (int j = 0; j < 4; j++) { - Vector3d vec = CUBE[i * 4 + j]; + Vec3 vec = CUBE[i * 4 + j]; vec = vec /* .rotate(?) */ .scale(scale * ageMultiplier) .add(lerpedX, lerpedY, lerpedZ); - Vector3d normal = CUBE_NORMALS[i]; + Vec3 normal = CUBE_NORMALS[i]; builder.vertex(vec.x, vec.y, vec.z) .color(rCol, gCol, bCol, alpha) .uv(0, 0) @@ -161,16 +161,16 @@ public class CubeParticle extends Particle { } @Override - public IParticleRenderType getRenderType() { + public ParticleRenderType getRenderType() { return renderType; } - public static class Factory implements IParticleFactory { + public static class Factory implements ParticleProvider { public Factory() {} @Override - public Particle createParticle(CubeParticleData data, ClientWorld world, double x, double y, double z, double motionX, + public Particle createParticle(CubeParticleData data, ClientLevel 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 7bf66ce3c..6dac3a883 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 @@ -8,14 +8,16 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import com.simibubi.create.AllParticleTypes; -import net.minecraft.client.particle.IParticleFactory; -import net.minecraft.network.PacketBuffer; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleType; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public class CubeParticleData implements IParticleData, ICustomParticleData { +import net.minecraft.core.particles.ParticleOptions.Deserializer; + +public class CubeParticleData implements ParticleOptions, ICustomParticleData { public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( @@ -27,7 +29,7 @@ public class CubeParticleData implements IParticleData, ICustomParticleData p.hot)) .apply(i, CubeParticleData::new)); - public static final IParticleData.IDeserializer DESERIALIZER = new IParticleData.IDeserializer() { + public static final ParticleOptions.Deserializer DESERIALIZER = new ParticleOptions.Deserializer() { @Override public CubeParticleData fromCommand(ParticleType type, StringReader reader) throws CommandSyntaxException { reader.expect(' '); @@ -46,7 +48,7 @@ public class CubeParticleData implements IParticleData, ICustomParticleData type, PacketBuffer buffer) { + public CubeParticleData fromNetwork(ParticleType type, FriendlyByteBuf buffer) { return new CubeParticleData(buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readInt(), buffer.readBoolean()); } }; @@ -72,7 +74,7 @@ public class CubeParticleData implements IParticleData, ICustomParticleData getDeserializer() { + public Deserializer getDeserializer() { return DESERIALIZER; } @@ -83,7 +85,7 @@ public class CubeParticleData implements IParticleData, ICustomParticleData getFactory() { + public ParticleProvider getFactory() { return new CubeParticle.Factory(); } @@ -93,7 +95,7 @@ public class CubeParticleData implements IParticleData, ICustomParticleData> 16 & 255; @@ -94,15 +94,15 @@ public class HeaterParticle extends SimpleAnimatedParticle { } } - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + public static class Factory implements ParticleProvider { + private final SpriteSet spriteSet; - public Factory(IAnimatedSprite animatedSprite) { + public Factory(SpriteSet animatedSprite) { this.spriteSet = animatedSprite; } @Override - public Particle createParticle(HeaterParticleData data, ClientWorld worldIn, double x, double y, double z, double vx, + public Particle createParticle(HeaterParticleData data, ClientLevel 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 c2cf4c37e..a1c760c57 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 @@ -11,16 +11,18 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import com.simibubi.create.AllParticleTypes; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.client.particle.ParticleManager.IParticleMetaFactory; -import net.minecraft.network.PacketBuffer; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleType; +import net.minecraft.client.particle.ParticleEngine.SpriteParticleRegistration; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.core.particles.ParticleOptions.Deserializer; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public class HeaterParticleData implements IParticleData, ICustomParticleDataWithSprite { +public class HeaterParticleData implements ParticleOptions, ICustomParticleDataWithSprite { public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( @@ -29,8 +31,8 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit Codec.FLOAT.fieldOf("b").forGetter(p -> p.b)) .apply(i, HeaterParticleData::new)); - public static final IParticleData.IDeserializer DESERIALIZER = - new IParticleData.IDeserializer() { + public static final ParticleOptions.Deserializer DESERIALIZER = + new ParticleOptions.Deserializer() { @Override public HeaterParticleData fromCommand(ParticleType arg0, StringReader reader) throws CommandSyntaxException { @@ -44,7 +46,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit } @Override - public HeaterParticleData fromNetwork(ParticleType type, PacketBuffer buffer) { + public HeaterParticleData fromNetwork(ParticleType type, FriendlyByteBuf buffer) { return new HeaterParticleData(buffer.readFloat(), buffer.readFloat(), buffer.readFloat()); } }; @@ -64,7 +66,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit } @Override - public IDeserializer getDeserializer() { + public Deserializer getDeserializer() { return DESERIALIZER; } @@ -75,7 +77,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit @Override @OnlyIn(Dist.CLIENT) - public IParticleMetaFactory getMetaFactory() { + public SpriteParticleRegistration getMetaFactory() { return HeaterParticle.Factory::new; } @@ -90,7 +92,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit } @Override - public void writeToNetwork(PacketBuffer buffer) { + public void writeToNetwork(FriendlyByteBuf 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 8d76c0788..93e8ac5d9 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 @@ -2,17 +2,17 @@ package com.simibubi.create.content.contraptions.particle; import com.mojang.serialization.Codec; -import net.minecraft.client.particle.IParticleFactory; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.IParticleData.IDeserializer; -import net.minecraft.particles.ParticleType; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleOptions.Deserializer; +import net.minecraft.core.particles.ParticleType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public interface ICustomParticleData { +public interface ICustomParticleData { - IDeserializer getDeserializer(); + Deserializer getDeserializer(); Codec getCodec(ParticleType type); @@ -27,10 +27,10 @@ public interface ICustomParticleData { } @OnlyIn(Dist.CLIENT) - public IParticleFactory getFactory(); + public ParticleProvider getFactory(); @OnlyIn(Dist.CLIENT) - public default void register(ParticleType type, ParticleManager particles) { + public default void register(ParticleType type, ParticleEngine particles) { 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 30c554549..09299c05f 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 @@ -2,18 +2,18 @@ package com.simibubi.create.content.contraptions.particle; import com.mojang.serialization.Codec; -import net.minecraft.client.particle.IParticleFactory; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.client.particle.ParticleManager.IParticleMetaFactory; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.IParticleData.IDeserializer; -import net.minecraft.particles.ParticleType; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.client.particle.ParticleEngine.SpriteParticleRegistration; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleOptions.Deserializer; +import net.minecraft.core.particles.ParticleType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public interface ICustomParticleDataWithSprite extends ICustomParticleData { +public interface ICustomParticleDataWithSprite extends ICustomParticleData { - IDeserializer getDeserializer(); + Deserializer getDeserializer(); public default ParticleType createType() { return new ParticleType(false, getDeserializer()) { @@ -27,16 +27,16 @@ public interface ICustomParticleDataWithSprite extends @Override @OnlyIn(Dist.CLIENT) - default IParticleFactory getFactory() { + default ParticleProvider getFactory() { throw new IllegalAccessError("This particle type uses a metaFactory!"); } @OnlyIn(Dist.CLIENT) - public IParticleMetaFactory getMetaFactory(); + public SpriteParticleRegistration getMetaFactory(); @Override @OnlyIn(Dist.CLIENT) - public default void register(ParticleType type, ParticleManager particles) { + public default void register(ParticleType type, ParticleEngine particles) { 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 17480d203..faa662684 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 @@ -1,21 +1,21 @@ package com.simibubi.create.content.contraptions.particle; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.content.contraptions.goggles.GogglesItem; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.particle.IAnimatedSprite; -import net.minecraft.client.particle.IParticleFactory; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.particle.ParticleProvider; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.SimpleAnimatedParticle; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.Camera; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.Vec3; public class RotationIndicatorParticle extends SimpleAnimatedParticle { @@ -24,17 +24,17 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { protected float radius2; protected float speed; protected Axis axis; - protected Vector3d origin; - protected Vector3d offset; + protected Vec3 origin; + protected Vec3 offset; protected boolean isVisible; - 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) { + private RotationIndicatorParticle(ClientLevel world, double x, double y, double z, int color, float radius1, + float radius2, float speed, Axis axis, int lifeSpan, boolean isVisible, SpriteSet sprite) { super(world, x, y, z, sprite, 0); this.xd = 0; this.yd = 0; this.zd = 0; - this.origin = new Vector3d(x, y, z); + this.origin = new Vec3(x, y, z); this.quadSize *= 0.75F; this.lifetime = lifeSpan + this.random.nextInt(32); this.setFadeColor(color); @@ -46,7 +46,7 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { this.speed = speed; this.axis = axis; this.isVisible = isVisible; - this.offset = axis.isHorizontal() ? new Vector3d(0, 1, 0) : new Vector3d(1, 0, 0); + this.offset = axis.isHorizontal() ? new Vec3(0, 1, 0) : new Vec3(1, 0, 0); move(0, 0, 0); this.xo = this.x; this.yo = this.y; @@ -60,7 +60,7 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { } @Override - public void render(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { + public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) { if (!isVisible) return; super.render(buffer, renderInfo, partialTicks); @@ -71,23 +71,23 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { 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); + Vec3 position = VecHelper.rotate(this.offset.scale(radius), angle, axis).add(origin); x = position.x; y = position.y; z = position.z; } - public static class Factory implements IParticleFactory { - private final IAnimatedSprite spriteSet; + public static class Factory implements ParticleProvider { + private final SpriteSet spriteSet; - public Factory(IAnimatedSprite animatedSprite) { + public Factory(SpriteSet animatedSprite) { this.spriteSet = animatedSprite; } - public Particle createParticle(RotationIndicatorParticleData data, ClientWorld worldIn, double x, double y, double z, + public Particle createParticle(RotationIndicatorParticleData data, ClientLevel worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { Minecraft mc = Minecraft.getInstance(); - ClientPlayerEntity player = mc.player; + LocalPlayer player = mc.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 2827b49a8..50bdaca6e 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 @@ -11,16 +11,18 @@ import com.mojang.serialization.codecs.PrimitiveCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import com.simibubi.create.AllParticleTypes; -import net.minecraft.client.particle.ParticleManager.IParticleMetaFactory; -import net.minecraft.network.PacketBuffer; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleType; -import net.minecraft.util.Direction.Axis; +import net.minecraft.client.particle.ParticleEngine.SpriteParticleRegistration; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.Direction.Axis; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.core.particles.ParticleOptions.Deserializer; + public class RotationIndicatorParticleData - implements IParticleData, ICustomParticleDataWithSprite { + implements ParticleOptions, ICustomParticleDataWithSprite { // TODO 1.16 make this unnecessary public static final PrimitiveCodec CHAR = new PrimitiveCodec() { @@ -56,8 +58,8 @@ public class RotationIndicatorParticleData .forGetter(p -> p.axis)) .apply(i, RotationIndicatorParticleData::new)); - public static final IParticleData.IDeserializer DESERIALIZER = - new IParticleData.IDeserializer() { + public static final ParticleOptions.Deserializer DESERIALIZER = + new ParticleOptions.Deserializer() { public RotationIndicatorParticleData fromCommand(ParticleType particleTypeIn, StringReader reader) throws CommandSyntaxException { reader.expect(' '); @@ -76,7 +78,7 @@ public class RotationIndicatorParticleData } public RotationIndicatorParticleData fromNetwork(ParticleType particleTypeIn, - PacketBuffer buffer) { + FriendlyByteBuf 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 writeToNetwork(PacketBuffer buffer) { + public void writeToNetwork(FriendlyByteBuf buffer) { buffer.writeInt(color); buffer.writeFloat(speed); buffer.writeFloat(radius1); @@ -129,7 +131,7 @@ public class RotationIndicatorParticleData } @Override - public IDeserializer getDeserializer() { + public Deserializer getDeserializer() { return DESERIALIZER; } @@ -140,7 +142,7 @@ public class RotationIndicatorParticleData @Override @OnlyIn(Dist.CLIENT) - public IParticleMetaFactory getMetaFactory() { + public SpriteParticleRegistration getMetaFactory() { return RotationIndicatorParticle.Factory::new; } 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 673115935..c6159adba 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 @@ -16,31 +16,31 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.Items; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -48,6 +48,8 @@ import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class BasinBlock extends Block implements ITE, IWrenchable { public static final DirectionProperty FACING = BlockStateProperties.FACING_HOPPER; @@ -68,49 +70,49 @@ public class BasinBlock extends Block implements ITE, IWrenchab } @Override - public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { - TileEntity tileEntity = world.getBlockEntity(pos.above()); + public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { + BlockEntity tileEntity = world.getBlockEntity(pos.above()); if (tileEntity instanceof BasinOperatingTileEntity) return false; return true; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.BASIN.create(); } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onWrenched(BlockState state, UseOnContext context) { if (!context.getLevel().isClientSide) withTileEntityDo(context.getLevel(), context.getClickedPos(), bte -> bte.onWrenched(context.getClickedFace())); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { ItemStack heldItem = player.getItemInHand(handIn); return onTileEntityUse(worldIn, pos, te -> { if (!heldItem.isEmpty()) { if (FluidHelper.tryEmptyItemIntoTE(worldIn, player, handIn, heldItem, te)) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; if (FluidHelper.tryFillItemFromTE(worldIn, player, handIn, heldItem, te)) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; if (EmptyingByBasin.canItemBeEmptied(worldIn, heldItem) || GenericItemFilling.canItemBeFilled(worldIn, heldItem)) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; if (heldItem.getItem() .equals(Items.SPONGE) && !te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) .map(iFluidHandler -> iFluidHandler.drain(Integer.MAX_VALUE, IFluidHandler.FluidAction.EXECUTE)) .orElse(FluidStack.EMPTY) .isEmpty()) { - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } IItemHandlerModifiable inv = te.itemCapability.orElse(new ItemStackHandler(1)); @@ -124,15 +126,15 @@ public class BasinBlock extends Block implements ITE, IWrenchab success = true; } if (success) - worldIn.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .2f, + worldIn.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, .2f, 1f + Create.RANDOM.nextFloat()); te.onEmptied(); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; }); } @Override - public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) { super.updateEntityAfterFallOn(worldIn, entityIn); if (!AllBlocks.BASIN.has(worldIn.getBlockState(entityIn.blockPosition()))) return; @@ -162,24 +164,24 @@ public class BasinBlock extends Block implements ITE, IWrenchab } @Override - public VoxelShape getInteractionShape(BlockState p_199600_1_, IBlockReader p_199600_2_, BlockPos p_199600_3_) { + public VoxelShape getInteractionShape(BlockState p_199600_1_, BlockGetter p_199600_2_, BlockPos p_199600_3_) { return AllShapes.BASIN_RAYTRACE_SHAPE; } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.BASIN_BLOCK_SHAPE; } @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext ctx) { + public VoxelShape getCollisionShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext ctx) { if (ctx.getEntity() instanceof ItemEntity) return AllShapes.BASIN_COLLISION_SHAPE; return getShape(state, reader, pos, ctx); } @Override - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (!state.hasTileEntity() || state.getBlock() == newState.getBlock()) return; TileEntityBehaviour.destroy(worldIn, pos, FilteringBehaviour.TYPE); @@ -197,7 +199,7 @@ public class BasinBlock extends Block implements ITE, IWrenchab } @Override - public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { + public int getAnalogOutputSignal(BlockState blockState, Level worldIn, BlockPos pos) { return getTileEntityOptional(worldIn, pos).map(BasinTileEntity::getInputInventory) .map(ItemHelper::calcRedstoneFromInventory) .orElse(0); @@ -208,7 +210,7 @@ public class BasinBlock extends Block implements ITE, IWrenchab return BasinTileEntity.class; } - public static boolean canOutputTo(IBlockReader world, BlockPos basinPos, Direction direction) { + public static boolean canOutputTo(BlockGetter world, BlockPos basinPos, Direction direction) { BlockPos neighbour = basinPos.relative(direction); BlockPos output = neighbour.below(); BlockState blockState = world.getBlockState(neighbour); @@ -220,7 +222,7 @@ public class BasinBlock extends Block implements ITE, IWrenchab .isEmpty()) { return false; } else { - TileEntity tileEntity = world.getBlockEntity(output); + BlockEntity 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 isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 5df06ac99..84704801e 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 @@ -5,8 +5,8 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.client.model.generators.ModelFile; public class BasinGenerator extends SpecialBlockStateGen { diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinInventory.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinInventory.java index 70e5bce70..c0e3bed77 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinInventory.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinInventory.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.processing; import com.simibubi.create.foundation.item.SmartInventory; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.ItemHandlerHelper; public class BasinInventory extends SmartInventory { 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 1bf64f5ae..621e9b459 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 @@ -6,11 +6,11 @@ import java.util.Map; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.items.ItemStackHandler; public class BasinMovementBehaviour extends MovementBehaviour { @@ -31,14 +31,14 @@ 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.atLowerCornerOf(Direction.UP.getNormal())); + Vec3 facingVec = context.rotation.apply(Vec3.atLowerCornerOf(Direction.UP.getNormal())); facingVec.normalize(); if (Direction.getNearest(facingVec.x, facingVec.y, facingVec.z) == Direction.DOWN) dump(context, facingVec); } } - private void dump(MovementContext context, Vector3d facingVec) { + private void dump(MovementContext context, Vec3 facingVec) { getOrReadInventory(context).forEach((key, itemStackHandler) -> { for (int i = 0; i < itemStackHandler.getSlots(); i++) { if (itemStackHandler.getStackInSlot(i) @@ -52,7 +52,7 @@ public class BasinMovementBehaviour extends MovementBehaviour { } context.tileData.put(key, itemStackHandler.serializeNBT()); }); - TileEntity tileEntity = context.contraption.presentTileEntities.get(context.localPos); + BlockEntity tileEntity = context.contraption.presentTileEntities.get(context.localPos); if (tileEntity instanceof BasinTileEntity) ((BasinTileEntity) tileEntity).readOnlyItems(context.tileData); context.temporaryData = false; // did already dump, so can't any more 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 9eae5b034..0157b61a0 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 @@ -11,18 +11,18 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.simple.DeferralBehaviour; import com.simibubi.create.foundation.utility.recipe.RecipeFinder; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.Container; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; public abstract class BasinOperatingTileEntity extends KineticTileEntity { public DeferralBehaviour basinChecker; public boolean basinRemoved; - protected IRecipe currentRecipe; + protected Recipe currentRecipe; - public BasinOperatingTileEntity(TileEntityType typeIn) { + public BasinOperatingTileEntity(BlockEntityType typeIn) { super(typeIn); } @@ -67,7 +67,7 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { .isPresent()) return true; - List> recipes = getMatchingRecipes(); + List> recipes = getMatchingRecipes(); if (recipes.isEmpty()) return true; currentRecipe = recipes.get(0); @@ -84,7 +84,7 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { return true; } - protected boolean matchBasinRecipe(IRecipe recipe) { + protected boolean matchBasinRecipe(Recipe recipe) { if (recipe == null) return false; Optional basin = getBasin(); @@ -118,8 +118,8 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { basin.notifyChangeOfContents(); } - protected List> getMatchingRecipes() { - List> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters); + protected List> getMatchingRecipes() { + List> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters); return list.stream() .filter(this::matchBasinRecipe) .sorted((r1, r2) -> r2.getIngredients() @@ -134,7 +134,7 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { protected Optional getBasin() { if (level == null) return Optional.empty(); - TileEntity basinTE = level.getBlockEntity(worldPosition.below(2)); + BlockEntity basinTE = level.getBlockEntity(worldPosition.below(2)); if (!(basinTE instanceof BasinTileEntity)) return Optional.empty(); return Optional.of((BasinTileEntity) basinTE); @@ -144,7 +144,7 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { return Optional.empty(); } - protected abstract boolean matchStaticFilters(IRecipe recipe); + protected abstract boolean matchStaticFilters(Recipe recipe); protected abstract Object getRecipeCacheKey(); 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 b7e57b5bd..a9a923d40 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 @@ -18,10 +18,10 @@ import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankB import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.world.World; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -30,7 +30,7 @@ import net.minecraftforge.items.IItemHandler; public class BasinRecipe extends ProcessingRecipe { - public static boolean match(BasinTileEntity basin, IRecipe recipe) { + public static boolean match(BasinTileEntity basin, Recipe recipe) { FilteringBehaviour filter = basin.getFilter(); if (filter == null) return false; @@ -52,11 +52,11 @@ public class BasinRecipe extends ProcessingRecipe { return apply(basin, recipe, true); } - public static boolean apply(BasinTileEntity basin, IRecipe recipe) { + public static boolean apply(BasinTileEntity basin, Recipe recipe) { return apply(basin, recipe, false); } - private static boolean apply(BasinTileEntity basin, IRecipe recipe, boolean test) { + private static boolean apply(BasinTileEntity basin, Recipe recipe, boolean test) { boolean isBasinRecipe = recipe instanceof BasinRecipe; IItemHandler availableItems = basin.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) .orElse(null); @@ -165,7 +165,7 @@ public class BasinRecipe extends ProcessingRecipe { return true; } - public static BasinRecipe convertShapeless(IRecipe recipe) { + public static BasinRecipe convertShapeless(Recipe recipe) { BasinRecipe basinRecipe = new ProcessingRecipeBuilder<>(BasinRecipe::new, recipe.getId()).withItemIngredients(recipe.getIngredients()) .withSingleItemOutput(recipe.getResultItem()) @@ -207,7 +207,7 @@ public class BasinRecipe extends ProcessingRecipe { } @Override - public boolean matches(SmartInventory inv, @Nonnull World worldIn) { + public boolean matches(SmartInventory inv, @Nonnull Level worldIn) { return false; } 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 d8249efa3..efa2ee8ba 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.processing; import java.util.Random; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment; @@ -13,34 +13,34 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemStackHandler; public class BasinRenderer extends SmartTileEntityRenderer { - public BasinRenderer(TileEntityRendererDispatcher dispatcher) { + public BasinRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(BasinTileEntity basin, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(BasinTileEntity basin, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(basin, partialTicks, ms, buffer, light, overlay); float fluidLevel = renderFluids(basin, partialTicks, ms, buffer, light, overlay); - float level = MathHelper.clamp(fluidLevel - .3f, .125f, .6f); + float level = Mth.clamp(fluidLevel - .3f, .125f, .6f); ms.pushPose(); @@ -50,7 +50,7 @@ public class BasinRenderer extends SmartTileEntityRenderer { .rotateY(basin.ingredientRotation.getValue(partialTicks)); Random r = new Random(pos.hashCode()); - Vector3d baseVector = new Vector3d(.125, level, 0); + Vec3 baseVector = new Vec3(.125, level, 0); IItemHandlerModifiable inv = basin.itemCapability.orElse(new ItemStackHandler()); int itemCount = 0; @@ -60,7 +60,7 @@ public class BasinRenderer extends SmartTileEntityRenderer { itemCount++; if (itemCount == 1) - baseVector = new Vector3d(0, level, 0); + baseVector = new Vec3(0, level, 0); float anglePartition = 360f / itemCount; for (int slot = 0; slot < inv.getSlots(); slot++) { @@ -72,13 +72,13 @@ public class BasinRenderer extends SmartTileEntityRenderer { if (fluidLevel > 0) { ms.translate(0, - (MathHelper.sin( + (Mth.sin( AnimationTickHolder.getRenderTime(basin.getLevel()) / 12f + anglePartition * itemCount) + 1.5f) * 1 / 32f, 0); } - Vector3d itemPosition = VecHelper.rotate(baseVector, anglePartition * itemCount, Axis.Y); + Vec3 itemPosition = VecHelper.rotate(baseVector, anglePartition * itemCount, Axis.Y); ms.translate(itemPosition.x, itemPosition.y, itemPosition.z); MatrixTransformStack.of(ms) .rotateY(anglePartition * itemCount + 35) @@ -87,7 +87,7 @@ public class BasinRenderer extends SmartTileEntityRenderer { for (int i = 0; i <= stack.getCount() / 8; i++) { ms.pushPose(); - Vector3d vec = VecHelper.offsetRandomly(Vector3d.ZERO, r, 1 / 16f); + Vec3 vec = VecHelper.offsetRandomly(Vec3.ZERO, r, 1 / 16f); ms.translate(vec.x, vec.y, vec.z); renderItem(ms, buffer, light, overlay, stack); @@ -105,8 +105,8 @@ public class BasinRenderer extends SmartTileEntityRenderer { Direction direction = blockState.getValue(BasinBlock.FACING); if (direction == Direction.DOWN) return; - Vector3d directionVec = Vector3d.atLowerCornerOf(direction.getNormal()); - Vector3d outVec = VecHelper.getCenterOf(BlockPos.ZERO) + Vec3 directionVec = Vec3.atLowerCornerOf(direction.getNormal()); + Vec3 outVec = VecHelper.getCenterOf(BlockPos.ZERO) .add(directionVec.scale(.55) .subtract(0, 1 / 2f, 0)); @@ -124,7 +124,7 @@ public class BasinRenderer extends SmartTileEntityRenderer { ms.pushPose(); MatrixTransformStack.of(ms) .translate(outVec) - .translate(new Vector3d(0, Math.max(-.55f, -(progress * progress * 2)), 0)) + .translate(new Vec3(0, Math.max(-.55f, -(progress * progress * 2)), 0)) .translate(directionVec.scale(progress * .5f)) .rotateY(AngleHelper.horizontalAngle(direction)) .rotateX(progress * 180); @@ -133,13 +133,13 @@ public class BasinRenderer extends SmartTileEntityRenderer { } } - protected void renderItem(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, ItemStack stack) { + protected void renderItem(PoseStack ms, MultiBufferSource buffer, int light, int overlay, ItemStack stack) { Minecraft.getInstance() .getItemRenderer() .renderStatic(stack, TransformType.GROUND, light, overlay, ms, buffer); } - protected float renderFluids(BasinTileEntity basin, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected float renderFluids(BasinTileEntity basin, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { SmartFluidTankBehaviour inputFluids = basin.getBehaviour(SmartFluidTankBehaviour.INPUT); SmartFluidTankBehaviour outputFluids = basin.getBehaviour(SmartFluidTankBehaviour.OUTPUT); @@ -148,7 +148,7 @@ public class BasinRenderer extends SmartTileEntityRenderer { if (totalUnits < 1) return 0; - float fluidLevel = MathHelper.clamp(totalUnits / 2000, 0, 1); + float fluidLevel = Mth.clamp(totalUnits / 2000, 0, 1); float xMin = 2 / 16f; float xMax = 2 / 16f; @@ -168,7 +168,7 @@ public class BasinRenderer extends SmartTileEntityRenderer { if (units < 1) continue; - float partial = MathHelper.clamp(units / totalUnits, 0, 1); + float partial = Mth.clamp(units / totalUnits, 0, 1); xMax += partial * 12 / 16f; FluidRenderer.renderTiledFluidBB(renderedFluid, xMin, yMin, zMin, xMax, yMax, zMax, buffer, ms, light, false); 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 e71fa7d2b..db3ffbf64 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 @@ -36,21 +36,21 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.nbt.StringNBT; -import net.minecraft.particles.IParticleData; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.Capability; @@ -94,7 +94,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor List> visualizedOutputItems; List> visualizedOutputFluids; - public BasinTileEntity(TileEntityType type) { + public BasinTileEntity(BlockEntityType type) { super(type); inputInventory = new BasinInventory(9, this); inputInventory.whenContentsChanged($ -> contentsChanged = true); @@ -121,7 +121,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor @Override public void addBehaviours(List behaviours) { behaviours.add(new DirectBeltInputBehaviour(this)); - filtering = new FilteringBehaviour(this, new BasinValueBox()).moveText(new Vector3d(2, -8, 0)) + filtering = new FilteringBehaviour(this, new BasinValueBox()).moveText(new Vec3(2, -8, 0)) .withCallback(newFilter -> contentsChanged = true) .forRecipes(); behaviours.add(filtering); @@ -142,7 +142,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); inputInventory.deserializeNBT(compound.getCompound("InputItems")); outputInventory.deserializeNBT(compound.getCompound("OutputItems")); @@ -151,8 +151,8 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (compound.contains("PreferredSpoutput")) 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).getAsString()))); + ListTag disabledList = compound.getList("DisabledSpoutput", NBT.TAG_STRING); + disabledList.forEach(d -> disabledSpoutputs.add(Direction.valueOf(((StringTag) d).getAsString()))); spoutputBuffer = NBTHelper.readItemList(compound.getList("Overflow", NBT.TAG_COMPOUND)); spoutputFluidBuffer = NBTHelper.readCompoundList(compound.getList("FluidOverflow", NBT.TAG_COMPOUND), FluidStack::loadFluidStackFromNBT); @@ -168,19 +168,19 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); compound.put("InputItems", inputInventory.serializeNBT()); compound.put("OutputItems", outputInventory.serializeNBT()); if (preferredSpoutput != null) NBTHelper.writeEnum(compound, "PreferredSpoutput", preferredSpoutput); - ListNBT disabledList = new ListNBT(); - disabledSpoutputs.forEach(d -> disabledList.add(StringNBT.valueOf(d.name()))); + ListTag disabledList = new ListTag(); + disabledSpoutputs.forEach(d -> disabledList.add(StringTag.valueOf(d.name()))); compound.put("DisabledSpoutput", disabledList); compound.put("Overflow", NBTHelper.writeItemList(spoutputBuffer)); compound.put("FluidOverflow", - NBTHelper.writeCompoundList(spoutputFluidBuffer, fs -> fs.writeToNBT(new CompoundNBT()))); + NBTHelper.writeCompoundList(spoutputFluidBuffer, fs -> fs.writeToNBT(new CompoundTag()))); if (!clientPacket) return; @@ -188,7 +188,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor compound.put("VisualizedItems", NBTHelper.writeCompoundList(visualizedOutputItems, ia -> ia.getValue() .serializeNBT())); compound.put("VisualizedFluids", NBTHelper.writeCompoundList(visualizedOutputFluids, ia -> ia.getValue() - .writeToNBT(new CompoundNBT()))); + .writeToNBT(new CompoundTag()))); visualizedOutputItems.clear(); visualizedOutputFluids.clear(); } @@ -227,7 +227,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (!level.isClientSide) return; - TileEntity tileEntity = level.getBlockEntity(worldPosition.above(2)); + BlockEntity tileEntity = level.getBlockEntity(worldPosition.above(2)); if (!(tileEntity instanceof MechanicalMixerTileEntity)) { setAreFluidsMoving(false); return; @@ -300,7 +300,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor BlockState stateToUpdate = level.getBlockState(toUpdate); if (stateToUpdate.getBlock() instanceof BasinBlock && stateToUpdate.getValue(BasinBlock.FACING) == offset.getOpposite()) { - TileEntity te = level.getBlockEntity(toUpdate); + BlockEntity te = level.getBlockEntity(toUpdate); if (te instanceof BasinTileEntity) ((BasinTileEntity) te).contentsChanged = true; } @@ -312,7 +312,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (!(blockState.getBlock() instanceof BasinBlock)) return; Direction direction = blockState.getValue(BasinBlock.FACING); - TileEntity te = level.getBlockEntity(worldPosition.below() + BlockEntity te = level.getBlockEntity(worldPosition.below() .relative(direction)); FilteringBehaviour filter = null; @@ -419,7 +419,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor private Optional getOperator() { if (level == null) return Optional.empty(); - TileEntity te = level.getBlockEntity(worldPosition.above(2)); + BlockEntity te = level.getBlockEntity(worldPosition.above(2)); if (te instanceof BasinOperatingTileEntity) return Optional.of((BasinOperatingTileEntity) te); return Optional.empty(); @@ -468,7 +468,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor Direction direction = blockState.getValue(BasinBlock.FACING); if (direction != Direction.DOWN) { - TileEntity te = level.getBlockEntity(worldPosition.below() + BlockEntity te = level.getBlockEntity(worldPosition.below() .relative(direction)); InvManipulationBehaviour inserter = @@ -531,7 +531,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor return true; } - public void readOnlyItems(CompoundNBT compound) { + public void readOnlyItems(CompoundTag compound) { inputInventory.deserializeNBT(compound.getCompound("InputItems")); outputInventory.deserializeNBT(compound.getCompound("OutputItems")); } @@ -582,7 +582,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor float totalUnits = getTotalFluidUnits(0); if (totalUnits == 0) return; - float fluidLevel = MathHelper.clamp(totalUnits / 2000, 0, 1); + float fluidLevel = Mth.clamp(totalUnits / 2000, 0, 1); float rim = 2 / 16f; float space = 12 / 16f; float surface = worldPosition.getY() + rim + space * fluidLevel + 1 / 32f; @@ -614,27 +614,27 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor Direction direction = blockState.getValue(BasinBlock.FACING); if (direction == Direction.DOWN) return; - Vector3d directionVec = Vector3d.atLowerCornerOf(direction.getNormal()); - Vector3d outVec = VecHelper.getCenterOf(worldPosition) + Vec3 directionVec = Vec3.atLowerCornerOf(direction.getNormal()); + Vec3 outVec = VecHelper.getCenterOf(worldPosition) .add(directionVec.scale(.65) .subtract(0, 1 / 4f, 0)); - Vector3d outMotion = directionVec.scale(1 / 16f) + Vec3 outMotion = directionVec.scale(1 / 16f) .add(0, -1 / 16f, 0); for (int i = 0; i < 3; i++) { visualizedOutputFluids.forEach(ia -> { FluidStack fluidStack = ia.getValue(); - IParticleData fluidParticle = FluidFX.getFluidParticle(fluidStack); - Vector3d m = VecHelper.offsetRandomly(outMotion, r, 1 / 16f); + ParticleOptions fluidParticle = FluidFX.getFluidParticle(fluidStack); + Vec3 m = VecHelper.offsetRandomly(outMotion, r, 1 / 16f); level.addAlwaysVisibleParticle(fluidParticle, outVec.x, outVec.y, outVec.z, m.x, m.y, m.z); }); } } private void createMovingFluidParticles(float surface, int segments) { - Vector3d pointer = new Vector3d(1, 0, 0).scale(1 / 16f); + Vec3 pointer = new Vec3(1, 0, 0).scale(1 / 16f); float interval = 360f / segments; - Vector3d centerOf = VecHelper.getCenterOf(worldPosition); + Vec3 centerOf = VecHelper.getCenterOf(worldPosition); float intervalOffset = (AnimationTickHolder.getTicks() * 18) % 360; int currentSegment = 0; @@ -645,7 +645,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (tankSegment.isEmpty(0)) continue; float angle = interval * (1 + currentSegment) + intervalOffset; - Vector3d vec = centerOf.add(VecHelper.rotate(pointer, angle, Axis.Y)); + Vec3 vec = centerOf.add(VecHelper.rotate(pointer, angle, Axis.Y)); level.addAlwaysVisibleParticle( new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), tankSegment.getRenderedFluid()), vec.x(), surface, vec.z(), 1, 0, 0); @@ -665,7 +665,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { return containedFluidTooltip(tooltip, isPlayerSneaking, getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)); } @@ -673,7 +673,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor class BasinValueBox extends ValueBoxTransform.Sided { @Override - protected Vector3d getSouthLocation() { + protected Vec3 getSouthLocation() { return VecHelper.voxelSpace(8, 12, 15.75); } 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 cddadc1cf..1a29725af 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 @@ -7,10 +7,10 @@ import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.item.ItemStack; -import net.minecraft.item.PotionItem; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.PotionItem; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -23,7 +23,7 @@ public class EmptyingByBasin { static RecipeWrapper wrapper = new RecipeWrapper(new ItemStackHandler(1)); - public static boolean canItemBeEmptied(World world, ItemStack stack) { + public static boolean canItemBeEmptied(Level world, ItemStack stack) { if (stack.getItem() instanceof PotionItem) return true; @@ -45,7 +45,7 @@ public class EmptyingByBasin { return false; } - public static Pair emptyItem(World world, ItemStack stack, boolean simulate) { + public static Pair emptyItem(Level world, ItemStack stack, boolean simulate) { FluidStack resultingFluid = FluidStack.EMPTY; ItemStack resultingItem = ItemStack.EMPTY; @@ -53,7 +53,7 @@ public class EmptyingByBasin { return PotionFluidHandler.emptyPotion(stack, simulate); wrapper.setItem(0, stack); - Optional> recipe = AllRecipeTypes.EMPTYING.find(wrapper, world); + Optional> recipe = AllRecipeTypes.EMPTYING.find(wrapper, world); if (recipe.isPresent()) { EmptyingRecipe emptyingRecipe = (EmptyingRecipe) recipe.get(); List results = emptyingRecipe.rollResults(); 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 8c7cebfab..848d75fde 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.processing; import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.items.wrapper.RecipeWrapper; @@ -14,7 +14,7 @@ public class EmptyingRecipe extends ProcessingRecipe { } @Override - public boolean matches(RecipeWrapper inv, World p_77569_2_) { + public boolean matches(RecipeWrapper inv, Level p_77569_2_) { return ingredients.get(0).test(inv.getItem(0)); } 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 1269ff7fc..7c23ce58b 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 @@ -19,27 +19,27 @@ import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult; import com.simibubi.create.foundation.utility.Color; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.CampfireBlock; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.BlastingRecipe; -import net.minecraft.item.crafting.FurnaceRecipe; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.item.crafting.SmokingRecipe; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.particles.RedstoneParticleData; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.CampfireBlock; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.BlastingRecipe; +import net.minecraft.world.item.crafting.SmeltingRecipe; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SmokingRecipe; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.particles.DustParticleOptions; import net.minecraft.tags.BlockTags; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.wrapper.RecipeWrapper; @@ -54,7 +54,7 @@ public class InWorldProcessing { ; - public static Type byBlock(IBlockReader reader, BlockPos pos) { + public static Type byBlock(BlockGetter reader, BlockPos pos) { BlockState blockState = reader.getBlockState(pos); FluidState fluidState = reader.getFluidState(pos); if (fluidState.getType() == Fluids.WATER || fluidState.getType() == Fluids.FLOWING_WATER) @@ -73,10 +73,10 @@ public class InWorldProcessing { public static boolean canProcess(ItemEntity entity, Type type) { if (entity.getPersistentData() .contains("CreateData")) { - CompoundNBT compound = entity.getPersistentData() + CompoundTag compound = entity.getPersistentData() .getCompound("CreateData"); if (compound.contains("Processing")) { - CompoundNBT processing = compound.getCompound("Processing"); + CompoundTag processing = compound.getCompound("Processing"); if (Type.valueOf(processing.getString("Type")) != type) { boolean canProcess = canProcess(entity.getItem(), type, entity.level); @@ -93,18 +93,18 @@ public class InWorldProcessing { return canProcess(entity.getItem(), type, entity.level); } - private static boolean canProcess(ItemStack stack, Type type, World world) { + private static boolean canProcess(ItemStack stack, Type type, Level world) { if (type == Type.BLASTING) { WRAPPER.setItem(0, stack); - Optional smeltingRecipe = world.getRecipeManager() - .getRecipeFor(IRecipeType.SMELTING, WRAPPER, world); + Optional smeltingRecipe = world.getRecipeManager() + .getRecipeFor(RecipeType.SMELTING, WRAPPER, world); if (smeltingRecipe.isPresent()) return true; WRAPPER.setItem(0, stack); Optional blastingRecipe = world.getRecipeManager() - .getRecipeFor(IRecipeType.BLASTING, WRAPPER, world); + .getRecipeFor(RecipeType.BLASTING, WRAPPER, world); if (blastingRecipe.isPresent()) return true; @@ -115,7 +115,7 @@ public class InWorldProcessing { if (type == Type.SMOKING) { WRAPPER.setItem(0, stack); Optional recipe = world.getRecipeManager() - .getRecipeFor(IRecipeType.SMOKING, WRAPPER, world); + .getRecipeFor(RecipeType.SMOKING, WRAPPER, world); return recipe.isPresent(); } @@ -125,7 +125,7 @@ public class InWorldProcessing { return false; } - public static boolean isWashable(ItemStack stack, World world) { + public static boolean isWashable(ItemStack stack, Level world) { SPLASHING_WRAPPER.setItem(0, stack); Optional recipe = AllRecipeTypes.SPLASHING.find(SPLASHING_WRAPPER, world); return recipe.isPresent(); @@ -149,7 +149,7 @@ public class InWorldProcessing { } } - public static TransportedResult applyProcessing(TransportedItemStack transported, World world, Type type) { + public static TransportedResult applyProcessing(TransportedItemStack transported, Level world, Type type) { TransportedResult ignore = TransportedResult.doNothing(); if (transported.processedBy != type) { transported.processedBy = type; @@ -179,7 +179,7 @@ public class InWorldProcessing { return TransportedResult.convertTo(transportedStacks); } - private static List process(ItemStack stack, Type type, World world) { + private static List process(ItemStack stack, Type type, Level world) { if (type == Type.SPLASHING) { SPLASHING_WRAPPER.setItem(0, stack); Optional recipe = AllRecipeTypes.SPLASHING.find(SPLASHING_WRAPPER, world); @@ -190,20 +190,20 @@ public class InWorldProcessing { WRAPPER.setItem(0, stack); Optional smokingRecipe = world.getRecipeManager() - .getRecipeFor(IRecipeType.SMOKING, WRAPPER, world); + .getRecipeFor(RecipeType.SMOKING, WRAPPER, world); if (type == Type.BLASTING) { if (!smokingRecipe.isPresent()) { WRAPPER.setItem(0, stack); - Optional smeltingRecipe = world.getRecipeManager() - .getRecipeFor(IRecipeType.SMELTING, WRAPPER, world); + Optional smeltingRecipe = world.getRecipeManager() + .getRecipeFor(RecipeType.SMELTING, WRAPPER, world); if (smeltingRecipe.isPresent()) return applyRecipeOn(stack, smeltingRecipe.get()); WRAPPER.setItem(0, stack); Optional blastingRecipe = world.getRecipeManager() - .getRecipeFor(IRecipeType.BLASTING, WRAPPER, world); + .getRecipeFor(RecipeType.BLASTING, WRAPPER, world); if (blastingRecipe.isPresent()) return applyRecipeOn(stack, blastingRecipe.get()); @@ -219,15 +219,15 @@ public class InWorldProcessing { } private static int decrementProcessingTime(ItemEntity entity, Type type) { - CompoundNBT nbt = entity.getPersistentData(); + CompoundTag nbt = entity.getPersistentData(); if (!nbt.contains("CreateData")) - nbt.put("CreateData", new CompoundNBT()); - CompoundNBT createData = nbt.getCompound("CreateData"); + nbt.put("CreateData", new CompoundTag()); + CompoundTag createData = nbt.getCompound("CreateData"); if (!createData.contains("Processing")) - createData.put("Processing", new CompoundNBT()); - CompoundNBT processing = createData.getCompound("Processing"); + createData.put("Processing", new CompoundTag()); + CompoundTag processing = createData.getCompound("Processing"); if (!processing.contains("Type") || Type.valueOf(processing.getString("Type")) != type) { processing.putString("Type", type.name()); @@ -243,7 +243,7 @@ public class InWorldProcessing { return value; } - public static void applyRecipeOn(ItemEntity entity, IRecipe recipe) { + public static void applyRecipeOn(ItemEntity entity, Recipe recipe) { List stacks = applyRecipeOn(entity.getItem(), recipe); if (stacks == null) return; @@ -259,7 +259,7 @@ public class InWorldProcessing { } } - public static List applyRecipeOn(ItemStack stackIn, IRecipe recipe) { + public static List applyRecipeOn(ItemStack stackIn, Recipe recipe) { List stacks; if (recipe instanceof ProcessingRecipe) { @@ -293,7 +293,7 @@ public class InWorldProcessing { return stacks; } - public static void spawnParticlesForProcessing(@Nullable World world, Vector3d vec, Type type) { + public static void spawnParticlesForProcessing(@Nullable Level world, Vec3 vec, Type type) { if (world == null || !world.isClientSide) return; if (world.random.nextInt(8) != 0) @@ -307,8 +307,8 @@ public class InWorldProcessing { world.addParticle(ParticleTypes.POOF, vec.x, vec.y + .25f, vec.z, 0, 1 / 16f, 0); break; case SPLASHING: - Vector3d color = Color.vectorFromRGB(0x0055FF); - world.addParticle(new RedstoneParticleData((float) color.x, (float) color.y, (float) color.z, 1), + Vec3 color = Color.vectorFromRGB(0x0055FF); + world.addParticle(new DustParticleOptions((float) color.x, (float) color.y, (float) color.z, 1), 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.random.nextFloat() - .5f) * .5f, vec.y + .5f, diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingInventory.java b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingInventory.java index 21fb2f34c..de88c825d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingInventory.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingInventory.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.processing; import java.util.function.Consumer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; import net.minecraftforge.items.ItemStackHandler; public class ProcessingInventory extends ItemStackHandler { @@ -52,8 +52,8 @@ public class ProcessingInventory extends ItemStackHandler { } @Override - public CompoundNBT serializeNBT() { - CompoundNBT nbt = super.serializeNBT(); + public CompoundTag serializeNBT() { + CompoundTag nbt = super.serializeNBT(); nbt.putFloat("ProcessingTime", remainingTime); nbt.putFloat("RecipeTime", recipeDuration); nbt.putBoolean("AppliedRecipe", appliedRecipe); @@ -61,7 +61,7 @@ public class ProcessingInventory extends ItemStackHandler { } @Override - public void deserializeNBT(CompoundNBT nbt) { + public void deserializeNBT(CompoundTag nbt) { remainingTime = nbt.getFloat("ProcessingTime"); recipeDuration = nbt.getFloat("RecipeTime"); appliedRecipe = nbt.getBoolean("AppliedRecipe"); 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 c83f362e8..f780bbcf1 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 @@ -10,11 +10,11 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.TagParser; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; public class ProcessingOutput { @@ -79,16 +79,16 @@ public class ProcessingOutput { throw new JsonSyntaxException("ProcessingOutput must be a json object"); JsonObject json = je.getAsJsonObject(); - String itemId = JSONUtils.getAsString(json, "item"); - int count = JSONUtils.getAsInt(json, "count", 1); - float chance = JSONUtils.isValidNode(json, "chance") ? JSONUtils.getAsFloat(json, "chance") : 1; + String itemId = GsonHelper.getAsString(json, "item"); + int count = GsonHelper.getAsInt(json, "count", 1); + float chance = GsonHelper.isValidNode(json, "chance") ? GsonHelper.getAsFloat(json, "chance") : 1; ItemStack itemstack = new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemId)), count); - if (JSONUtils.isValidNode(json, "nbt")) { + if (GsonHelper.isValidNode(json, "nbt")) { try { JsonElement element = json.get("nbt"); - itemstack.setTag(JsonToNBT.parseTag( - element.isJsonObject() ? Create.GSON.toJson(element) : JSONUtils.convertToString(element, "nbt"))); + itemstack.setTag(TagParser.parseTag( + element.isJsonObject() ? Create.GSON.toJson(element) : GsonHelper.convertToString(element, "nbt"))); } catch (CommandSyntaxException e) { e.printStackTrace(); } @@ -97,12 +97,12 @@ public class ProcessingOutput { return new ProcessingOutput(itemstack, chance); } - public void write(PacketBuffer buf) { + public void write(FriendlyByteBuf buf) { buf.writeItem(getStack()); buf.writeFloat(getChance()); } - public static ProcessingOutput read(PacketBuffer buf) { + public static ProcessingOutput read(FriendlyByteBuf buf) { 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 b5eb01f6f..9d46322f0 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 @@ -16,20 +16,20 @@ import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fluids.FluidStack; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -public abstract class ProcessingRecipe implements IRecipe { +public abstract class ProcessingRecipe implements Recipe { protected ResourceLocation id; protected NonNullList ingredients; @@ -39,8 +39,8 @@ public abstract class ProcessingRecipe implements IRecipe< protected int processingDuration; protected HeatCondition requiredHeat; - private IRecipeType type; - private IRecipeSerializer serializer; + private RecipeType type; + private RecipeSerializer serializer; private IRecipeTypeInfo typeInfo; private Supplier forcedResult; @@ -200,12 +200,12 @@ public abstract class ProcessingRecipe implements IRecipe< } @Override - public IRecipeSerializer getSerializer() { + public RecipeSerializer getSerializer() { return serializer; } @Override - public IRecipeType getType() { + public RecipeType getType() { return type; } @@ -217,10 +217,10 @@ public abstract class ProcessingRecipe implements IRecipe< public void readAdditional(JsonObject json) {} - public void readAdditional(PacketBuffer buffer) {} + public void readAdditional(FriendlyByteBuf buffer) {} public void writeAdditional(JsonObject json) {} - public void writeAdditional(PacketBuffer buffer) {} + public void writeAdditional(FriendlyByteBuf buffer) {} } 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 19c839295..480d9823e 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 @@ -11,16 +11,16 @@ import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo; -import net.minecraft.data.IFinishedRecipe; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.tags.ITag; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.tags.Tag; +import net.minecraft.world.level.ItemLike; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.crafting.conditions.ModLoadedCondition; @@ -97,17 +97,17 @@ public class ProcessingRecipeBuilder> { return factory.create(params); } - public void build(Consumer consumer) { + public void build(Consumer consumer) { consumer.accept(new DataGenResult<>(build(), recipeConditions)); } // Datagen shortcuts - public ProcessingRecipeBuilder require(ITag.INamedTag tag) { + public ProcessingRecipeBuilder require(Tag.Named tag) { return require(Ingredient.of(tag)); } - public ProcessingRecipeBuilder require(IItemProvider item) { + public ProcessingRecipeBuilder require(ItemLike item) { return require(Ingredient.of(item)); } @@ -120,7 +120,7 @@ public class ProcessingRecipeBuilder> { return require(FluidIngredient.fromFluid(fluid, amount)); } - public ProcessingRecipeBuilder require(ITag.INamedTag fluidTag, int amount) { + public ProcessingRecipeBuilder require(Tag.Named fluidTag, int amount) { return require(FluidIngredient.fromTag(fluidTag, amount)); } @@ -129,19 +129,19 @@ public class ProcessingRecipeBuilder> { return this; } - public ProcessingRecipeBuilder output(IItemProvider item) { + public ProcessingRecipeBuilder output(ItemLike item) { return output(item, 1); } - public ProcessingRecipeBuilder output(float chance, IItemProvider item) { + public ProcessingRecipeBuilder output(float chance, ItemLike item) { return output(chance, item, 1); } - public ProcessingRecipeBuilder output(IItemProvider item, int amount) { + public ProcessingRecipeBuilder output(ItemLike item, int amount) { return output(1, item, amount); } - public ProcessingRecipeBuilder output(float chance, IItemProvider item, int amount) { + public ProcessingRecipeBuilder output(float chance, ItemLike item, int amount) { return output(chance, new ItemStack(item, amount)); } @@ -211,7 +211,7 @@ public class ProcessingRecipeBuilder> { } - public static class DataGenResult> implements IFinishedRecipe { + public static class DataGenResult> implements FinishedRecipe { private List recipeConditions; private ProcessingRecipeSerializer serializer; @@ -250,7 +250,7 @@ public class ProcessingRecipeBuilder> { } @Override - public IRecipeSerializer getType() { + public RecipeSerializer getType() { return serializer; } 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 38404346b..7820689cc 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 @@ -10,19 +10,19 @@ import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.fluid.FluidIngredient; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.util.GsonHelper; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.registries.ForgeRegistryEntry; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -public class ProcessingRecipeSerializer> extends ForgeRegistryEntry> - implements IRecipeSerializer { +public class ProcessingRecipeSerializer> extends ForgeRegistryEntry> + implements RecipeSerializer { private final ProcessingRecipeFactory factory; @@ -65,16 +65,16 @@ public class ProcessingRecipeSerializer> extends F NonNullList results = NonNullList.create(); NonNullList fluidResults = NonNullList.create(); - for (JsonElement je : JSONUtils.getAsJsonArray(json, "ingredients")) { + for (JsonElement je : GsonHelper.getAsJsonArray(json, "ingredients")) { if (FluidIngredient.isFluidIngredient(je)) fluidIngredients.add(FluidIngredient.deserialize(je)); else ingredients.add(Ingredient.fromJson(je)); } - for (JsonElement je : JSONUtils.getAsJsonArray(json, "results")) { + for (JsonElement je : GsonHelper.getAsJsonArray(json, "results")) { JsonObject jsonObject = je.getAsJsonObject(); - if (JSONUtils.isValidNode(jsonObject, "fluid")) + if (GsonHelper.isValidNode(jsonObject, "fluid")) fluidResults.add(FluidHelper.deserializeFluidStack(jsonObject)); else results.add(ProcessingOutput.deserialize(je)); @@ -85,17 +85,17 @@ public class ProcessingRecipeSerializer> extends F .withFluidIngredients(fluidIngredients) .withFluidOutputs(fluidResults); - if (JSONUtils.isValidNode(json, "processingTime")) - builder.duration(JSONUtils.getAsInt(json, "processingTime")); - if (JSONUtils.isValidNode(json, "heatRequirement")) - builder.requiresHeat(HeatCondition.deserialize(JSONUtils.getAsString(json, "heatRequirement"))); + if (GsonHelper.isValidNode(json, "processingTime")) + builder.duration(GsonHelper.getAsInt(json, "processingTime")); + if (GsonHelper.isValidNode(json, "heatRequirement")) + builder.requiresHeat(HeatCondition.deserialize(GsonHelper.getAsString(json, "heatRequirement"))); T recipe = builder.build(); recipe.readAdditional(json); return recipe; } - protected void writeToBuffer(PacketBuffer buffer, T recipe) { + protected void writeToBuffer(FriendlyByteBuf buffer, T recipe) { NonNullList ingredients = recipe.getIngredients(); NonNullList fluidIngredients = recipe.getFluidIngredients(); NonNullList outputs = recipe.getRollableResults(); @@ -118,7 +118,7 @@ public class ProcessingRecipeSerializer> extends F recipe.writeAdditional(buffer); } - protected T readFromBuffer(ResourceLocation recipeId, PacketBuffer buffer) { + protected T readFromBuffer(ResourceLocation recipeId, FriendlyByteBuf buffer) { NonNullList ingredients = NonNullList.create(); NonNullList fluidIngredients = NonNullList.create(); NonNullList results = NonNullList.create(); @@ -161,12 +161,12 @@ public class ProcessingRecipeSerializer> extends F } @Override - public final void toNetwork(PacketBuffer buffer, T recipe) { + public final void toNetwork(FriendlyByteBuf buffer, T recipe) { writeToBuffer(buffer, recipe); } @Override - public final T fromNetwork(ResourceLocation id, PacketBuffer buffer) { + public final T fromNetwork(ResourceLocation id, FriendlyByteBuf 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 077da0232..ddb4e0280 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 @@ -14,45 +14,47 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.Lang; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.advancements.criterion.StatePropertiesPredicate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.FlintAndSteelItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.ConstantRange; -import net.minecraft.loot.ItemLootEntry; -import net.minecraft.loot.LootPool; -import net.minecraft.loot.LootTable; -import net.minecraft.loot.conditions.BlockStateProperty; -import net.minecraft.loot.conditions.ILootCondition.IBuilder; -import net.minecraft.loot.conditions.SurvivesExplosion; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.NonNullList; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.advancements.critereon.StatePropertiesPredicate; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.FlintAndSteelItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.ConstantIntValue; +import net.minecraft.world.level.storage.loot.entries.LootItem; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition.Builder; +import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.level.ItemLike; +import net.minecraft.util.StringRepresentable; +import net.minecraft.core.NonNullList; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.FakePlayer; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class BlazeBurnerBlock extends Block implements ITE { @@ -71,10 +73,10 @@ public class BlazeBurnerBlock extends Block implements ITE list) { + public void fillItemCategory(CreativeModeTab group, NonNullList list) { list.add(AllItems.EMPTY_BLAZE_BURNER.asStack()); super.fillItemCategory(group, list); } @Nullable @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.HEATER.create(); } @@ -105,27 +107,27 @@ public class BlazeBurnerBlock extends Block implements ITE p.broadcastBreakEvent(hand)); world.setBlockAndUpdate(pos, AllBlocks.LIT_BLAZE_BURNER.getDefaultState()); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } boolean doNotConsume = player.isCreative(); boolean forceOverflow = !(player instanceof FakePlayer); - ActionResult res = tryInsert(state, world, pos, heldItem, doNotConsume, forceOverflow, false); + InteractionResultHolder res = tryInsert(state, world, pos, heldItem, doNotConsume, forceOverflow, false); ItemStack leftover = res.getObject(); if (!world.isClientSide && !doNotConsume && !leftover.isEmpty()) { if (heldItem.isEmpty()) { @@ -135,26 +137,26 @@ public class BlazeBurnerBlock extends Block implements ITE tryInsert(BlockState state, World world, BlockPos pos, ItemStack stack, boolean doNotConsume, + public static InteractionResultHolder tryInsert(BlockState state, Level world, BlockPos pos, ItemStack stack, boolean doNotConsume, boolean forceOverflow, boolean simulate) { if (!state.hasTileEntity()) - return ActionResult.fail(ItemStack.EMPTY); + return InteractionResultHolder.fail(ItemStack.EMPTY); - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (!(te instanceof BlazeBurnerTileEntity)) - return ActionResult.fail(ItemStack.EMPTY); + return InteractionResultHolder.fail(ItemStack.EMPTY); BlazeBurnerTileEntity burnerTE = (BlazeBurnerTileEntity) te; if (burnerTE.isCreativeFuel(stack)) { if (!simulate) burnerTE.applyCreativeFuel(); - return ActionResult.success(ItemStack.EMPTY); + return InteractionResultHolder.success(ItemStack.EMPTY); } if (!burnerTE.tryUpdateFuel(stack, forceOverflow, simulate)) - return ActionResult.fail(ItemStack.EMPTY); + return InteractionResultHolder.fail(ItemStack.EMPTY); if (!doNotConsume) { ItemStack container = stack.getContainerItem(); @@ -162,14 +164,14 @@ public class BlazeBurnerBlock extends Block implements ITE p_150895_2_) { + public void fillItemCategory(CreativeModeTab p_150895_1_, NonNullList p_150895_2_) { if (!hasCapturedBlaze()) return; super.fillItemCategory(p_150895_1_, p_150895_2_); @@ -75,29 +77,29 @@ public class BlazeBurnerBlockItem extends BlockItem { } @Override - public ActionResultType useOn(ItemUseContext context) { + public InteractionResult useOn(UseOnContext context) { if (hasCapturedBlaze()) return super.useOn(context); - World world = context.getLevel(); + Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); - TileEntity te = world.getBlockEntity(pos); - PlayerEntity player = context.getPlayer(); + BlockEntity te = world.getBlockEntity(pos); + Player player = context.getPlayer(); - if (!(te instanceof MobSpawnerTileEntity)) + if (!(te instanceof SpawnerBlockEntity)) return super.useOn(context); - AbstractSpawner spawner = ((MobSpawnerTileEntity) te).getSpawner(); - List possibleSpawns = - ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "field_98285_e"); + BaseSpawner spawner = ((SpawnerBlockEntity) te).getSpawner(); + List possibleSpawns = + ObfuscationReflectionHelper.getPrivateValue(BaseSpawner.class, spawner, "field_98285_e"); if (possibleSpawns.isEmpty()) { possibleSpawns = new ArrayList<>(); possibleSpawns - .add(ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "field_98282_f")); + .add(ObfuscationReflectionHelper.getPrivateValue(BaseSpawner.class, spawner, "field_98282_f")); } ResourceLocation blazeId = EntityType.BLAZE.getRegistryName(); - for (WeightedSpawnerEntity e : possibleSpawns) { + for (SpawnData e : possibleSpawns) { ResourceLocation spawnerEntityId = new ResourceLocation(e.getTag() .getString("id")); if (!spawnerEntityId.equals(blazeId)) @@ -105,33 +107,33 @@ public class BlazeBurnerBlockItem extends BlockItem { spawnCaptureEffects(world, VecHelper.getCenterOf(pos)); if (world.isClientSide || player == null) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; giveBurnerItemTo(player, context.getItemInHand(), context.getHand()); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } return super.useOn(context); } @Override - public ActionResultType interactLivingEntity(ItemStack heldItem, PlayerEntity player, LivingEntity entity, Hand hand) { + public InteractionResult interactLivingEntity(ItemStack heldItem, Player player, LivingEntity entity, InteractionHand hand) { if (hasCapturedBlaze()) - return ActionResultType.PASS; - if (!(entity instanceof BlazeEntity)) - return ActionResultType.PASS; + return InteractionResult.PASS; + if (!(entity instanceof Blaze)) + return InteractionResult.PASS; - World world = player.level; + Level world = player.level; spawnCaptureEffects(world, entity.position()); if (world.isClientSide) - return ActionResultType.FAIL; + return InteractionResult.FAIL; giveBurnerItemTo(player, heldItem, hand); entity.remove(); - return ActionResultType.FAIL; + return InteractionResult.FAIL; } - protected void giveBurnerItemTo(PlayerEntity player, ItemStack heldItem, Hand hand) { + protected void giveBurnerItemTo(Player player, ItemStack heldItem, InteractionHand hand) { ItemStack filled = AllBlocks.BLAZE_BURNER.asStack(); if (!player.isCreative()) heldItem.shrink(1); @@ -142,12 +144,12 @@ public class BlazeBurnerBlockItem extends BlockItem { player.inventory.placeItemBackInInventory(player.level, filled); } - private void spawnCaptureEffects(World world, Vector3d vec) { + private void spawnCaptureEffects(Level world, Vec3 vec) { if (world.isClientSide) { for (int i = 0; i < 40; i++) { - Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, world.random, .125f); + Vec3 motion = VecHelper.offsetRandomly(Vec3.ZERO, world.random, .125f); world.addParticle(ParticleTypes.FLAME, vec.x, vec.y, vec.z, motion.x, motion.y, motion.z); - Vector3d circle = motion.multiply(1, 0, 1) + Vec3 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.BLAZE_HURT, SoundCategory.HOSTILE, .25f, .75f); - world.playSound(null, soundPos, SoundEvents.FIRE_EXTINGUISH, SoundCategory.HOSTILE, .5f, .75f); + world.playSound(null, soundPos, SoundEvents.BLAZE_HURT, SoundSource.HOSTILE, .25f, .75f); + world.playSound(null, soundPos, SoundEvents.FIRE_EXTINGUISH, SoundSource.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 ffd36c804..ec01344b1 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 @@ -4,23 +4,23 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerTileEntity.FuelType; -import net.minecraft.block.BlockState; -import net.minecraft.entity.projectile.EggEntity; -import net.minecraft.entity.projectile.PotionEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionUtils; -import net.minecraft.potion.Potions; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.projectile.ThrownEgg; +import net.minecraft.world.entity.projectile.ThrownPotion; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -35,14 +35,14 @@ public class BlazeBurnerHandler { } public static void thrownEggsGetEatenByBurner(ProjectileImpactEvent.Throwable event) { - if (!(event.getThrowable() instanceof EggEntity)) + if (!(event.getThrowable() instanceof ThrownEgg)) return; if (event.getRayTraceResult() - .getType() != RayTraceResult.Type.BLOCK) + .getType() != HitResult.Type.BLOCK) return; - TileEntity tile = event.getThrowable().level.getBlockEntity(new BlockPos(event.getRayTraceResult() + BlockEntity tile = event.getThrowable().level.getBlockEntity(new BlockPos(event.getRayTraceResult() .getLocation())); if (!(tile instanceof BlazeBurnerTileEntity)) { return; @@ -50,11 +50,11 @@ public class BlazeBurnerHandler { event.setCanceled(true); event.getThrowable() - .setDeltaMovement(Vector3d.ZERO); + .setDeltaMovement(Vec3.ZERO); event.getThrowable() .remove(); - World world = event.getThrowable().level; + Level world = event.getThrowable().level; if (world.isClientSide) return; @@ -63,7 +63,7 @@ public class BlazeBurnerHandler { if (heater.activeFuel != FuelType.SPECIAL) { heater.activeFuel = FuelType.NORMAL; heater.remainingBurnTime = - MathHelper.clamp(heater.remainingBurnTime + 80, 0, BlazeBurnerTileEntity.MAX_HEAT_CAPACITY); + Mth.clamp(heater.remainingBurnTime + 80, 0, BlazeBurnerTileEntity.MAX_HEAT_CAPACITY); heater.updateBlockState(); heater.notifyUpdate(); } @@ -76,19 +76,19 @@ public class BlazeBurnerHandler { if (event.getThrowable().level.isClientSide) return; - if (!(event.getThrowable() instanceof PotionEntity)) + if (!(event.getThrowable() instanceof ThrownPotion)) return; - PotionEntity entity = (PotionEntity) event.getThrowable(); + ThrownPotion entity = (ThrownPotion) event.getThrowable(); if (event.getRayTraceResult() - .getType() != RayTraceResult.Type.BLOCK) + .getType() != HitResult.Type.BLOCK) return; ItemStack stack = entity.getItem(); Potion potion = PotionUtils.getPotion(stack); if (potion == Potions.WATER && PotionUtils.getMobEffects(stack).isEmpty()) { - BlockRayTraceResult result = (BlockRayTraceResult) event.getRayTraceResult(); - World world = entity.level; + BlockHitResult result = (BlockHitResult) event.getRayTraceResult(); + Level world = entity.level; Direction face = result.getDirection(); BlockPos pos = result.getBlockPos().relative(face); @@ -101,10 +101,10 @@ public class BlazeBurnerHandler { } } - private static void extinguishLitBurners(World world, BlockPos pos, Direction direction) { + private static void extinguishLitBurners(Level world, BlockPos pos, Direction direction) { BlockState state = world.getBlockState(pos); if (AllBlocks.LIT_BLAZE_BURNER.has(state)) { - world.playSound(null, pos, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); + world.playSound(null, pos, SoundEvents.FIRE_EXTINGUISH, SoundSource.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 9f000b228..9170ea2b0 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 @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.processing.burner; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; import com.simibubi.create.foundation.render.PartialBufferer; @@ -10,27 +10,27 @@ import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; public class BlazeBurnerRenderer extends SafeTileEntityRenderer { - public BlazeBurnerRenderer(TileEntityRendererDispatcher dispatcher) { + public BlazeBurnerRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(BlazeBurnerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(BlazeBurnerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { HeatLevel heatLevel = te.getHeatLevelFromBlock(); if (heatLevel == HeatLevel.NONE) return; float renderTick = AnimationTickHolder.getRenderTime(te.getLevel()) + (te.hashCode() % 13) * 16f; - float offset = (MathHelper.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f; + float offset = (Mth.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f; PartialModel blazeModel = AllBlockPartials.BLAZES.get(heatLevel); SuperByteBuffer blazeBuffer = PartialBufferer.get(blazeModel, te.getBlockState()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerTileEntity.java index 876e91a60..eb963c8f5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerTileEntity.java @@ -13,15 +13,15 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.util.Mth; import net.minecraftforge.common.ForgeHooks; public class BlazeBurnerTileEntity extends SmartTileEntity { @@ -47,7 +47,7 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { protected LerpedFloat headAngle; protected boolean isCreative; - public BlazeBurnerTileEntity(TileEntityType tileEntityTypeIn) { + public BlazeBurnerTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); activeFuel = FuelType.NONE; remainingBurnTime = 0; @@ -99,7 +99,7 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { private void tickRotation() { float target = 0; - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (player != null) { double x; double z; @@ -112,7 +112,7 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { } double dx = x - (getBlockPos().getX() + 0.5); double dz = z - (getBlockPos().getZ() + 0.5); - target = AngleHelper.deg(-MathHelper.atan2(dz, dx)) - 90; + target = AngleHelper.deg(-Mth.atan2(dz, dx)) - 90; } target = headAngle.getValue() + AngleHelper.getShortestAngleDiff(headAngle.getValue(), target); headAngle.chase(target, .25f, Chaser.exp(5)); @@ -123,7 +123,7 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { public void addBehaviours(List behaviours) {} @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { if (!isCreative) { compound.putInt("fuelLevel", activeFuel.ordinal()); compound.putInt("burnTimeRemaining", remainingBurnTime); @@ -134,7 +134,7 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { activeFuel = FuelType.values()[compound.getInt("fuelLevel")]; remainingBurnTime = compound.getInt("burnTimeRemaining"); isCreative = compound.getBoolean("isCreative"); @@ -187,7 +187,7 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { if (newFuel == activeFuel) { if (remainingBurnTime + newBurnTime > MAX_HEAT_CAPACITY && !forceOverflow) return false; - newBurnTime = MathHelper.clamp(remainingBurnTime + newBurnTime, 0, MAX_HEAT_CAPACITY); + newBurnTime = Mth.clamp(remainingBurnTime + newBurnTime, 0, MAX_HEAT_CAPACITY); } if (simulate) @@ -232,7 +232,7 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { } protected void playSound() { - level.playSound(null, worldPosition, SoundEvents.BLAZE_SHOOT, SoundCategory.BLOCKS, + level.playSound(null, worldPosition, SoundEvents.BLAZE_SHOOT, SoundSource.BLOCKS, .125f + level.random.nextFloat() * .125f, .75f - level.random.nextFloat() * .25f); } 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 f81829625..0b659f684 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 @@ -6,31 +6,33 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.StateContainer.Builder; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.tags.ItemTags; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.util.StringRepresentable; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ToolType; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class LitBlazeBurnerBlock extends Block { public static final EnumProperty FLAME_TYPE = EnumProperty.create("flame_type", FlameType.class); @@ -47,46 +49,46 @@ public class LitBlazeBurnerBlock extends Block { } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult blockRayTraceResult) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult blockRayTraceResult) { ItemStack heldItem = player.getItemInHand(hand); if (heldItem.getToolTypes().contains(ToolType.SHOVEL)) { - world.playSound(player, pos, SoundEvents.GENERIC_EXTINGUISH_FIRE, SoundCategory.BLOCKS, 0.5f, 2); + world.playSound(player, pos, SoundEvents.GENERIC_EXTINGUISH_FIRE, SoundSource.BLOCKS, 0.5f, 2); if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; heldItem.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(hand)); world.setBlockAndUpdate(pos, AllBlocks.BLAZE_BURNER.getDefaultState()); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } 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); + world.playSound(player, pos, SoundEvents.SOUL_SAND_PLACE, SoundSource.BLOCKS, 1.0f, world.random.nextFloat() * 0.4F + 0.8F); if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; world.setBlockAndUpdate(pos, defaultBlockState().setValue(FLAME_TYPE, FlameType.SOUL)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext context) { return AllBlocks.BLAZE_BURNER.get() .getShape(state, reader, pos, context); } @Override - public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, - PlayerEntity player) { + public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, + Player player) { return AllItems.EMPTY_BLAZE_BURNER.asStack(); } @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState state, World world, BlockPos pos, Random random) { + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { 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(), @@ -95,7 +97,7 @@ public class LitBlazeBurnerBlock extends Block { if (random.nextInt(10) == 0) { 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, + (double) ((float) pos.getZ() + 0.5F), SoundEvents.CAMPFIRE_CRACKLE, SoundSource.BLOCKS, 0.25F + random.nextFloat() * .25f, random.nextFloat() * 0.7F + 0.6F, false); } @@ -125,19 +127,19 @@ public class LitBlazeBurnerBlock extends Block { } @Override - public int getAnalogOutputSignal(BlockState state, World p_180641_2_, BlockPos p_180641_3_) { + public int getAnalogOutputSignal(BlockState state, Level p_180641_2_, BlockPos p_180641_3_) { return state.getValue(FLAME_TYPE) == FlameType.REGULAR ? 1 : 2; } @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader reader, BlockPos pos, - ISelectionContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockGetter reader, BlockPos pos, + CollisionContext context) { return AllBlocks.BLAZE_BURNER.get() .getCollisionShape(state, reader, pos, context); } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } @@ -148,7 +150,7 @@ public class LitBlazeBurnerBlock extends Block { return 12; } - public enum FlameType implements IStringSerializable { + public enum FlameType implements StringRepresentable { REGULAR, SOUL; 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 a05ec6708..8cd22c707 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 @@ -16,34 +16,36 @@ import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.placement.PlacementOffset; import com.simibubi.create.foundation.utility.placement.util.PoleHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.Property; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.util.StringRepresentable; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class GantryShaftBlock extends DirectionalKineticBlock { @@ -52,7 +54,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { private static final int placementHelperId = PlacementHelpers.register(new PlacementHelper()); - public enum Part implements IStringSerializable { + public enum Part implements StringRepresentable { START, MIDDLE, END, SINGLE; @Override @@ -67,30 +69,30 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) { ItemStack heldItem = player.getItemInHand(hand); IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId); if (!placementHelper.matchesItem(heldItem)) - return ActionResultType.PASS; + return InteractionResult.PASS; return placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, ((BlockItem) heldItem.getItem()), player, hand, ray); } @Override - public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return AllShapes.EIGHT_VOXEL_POLE.get(state.getValue(FACING) .getAxis()); } @Override - public BlockRenderType getRenderShape(BlockState state) { - return BlockRenderType.ENTITYBLOCK_ANIMATED; + public RenderShape getRenderShape(BlockState state) { + return RenderShape.ENTITYBLOCK_ANIMATED; } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState neighbour, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbour, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) { Direction facing = state.getValue(FACING); Axis axis = facing.getAxis(); @@ -135,10 +137,10 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockState state = super.getStateForPlacement(context); BlockPos pos = context.getClickedPos(); - World world = context.getLevel(); + Level world = context.getLevel(); Direction face = context.getClickedFace(); BlockState neighbour = world.getBlockState(pos.relative(state.getValue(FACING) @@ -159,24 +161,24 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - ActionResultType onWrenched = super.onWrenched(state, context); + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + InteractionResult onWrenched = super.onWrenched(state, context); if (onWrenched.consumesAction()) { BlockPos pos = context.getClickedPos(); - World world = context.getLevel(); + Level world = context.getLevel(); neighborChanged(world.getBlockState(pos), world, pos, state.getBlock(), pos, false); } return onWrenched; } @Override - public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { super.onPlace(state, worldIn, pos, oldState, isMoving); 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.getBlockEntity(pos); + BlockEntity te = worldIn.getBlockEntity(pos); if (te instanceof GantryShaftTileEntity) ((GantryShaftTileEntity) te).checkAttachedCarriageBlocks(); } @@ -184,7 +186,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { if (worldIn.isClientSide) return; @@ -225,7 +227,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { toUpdate.add(pos); for (BlockPos blockPos : toUpdate) { BlockState blockState = worldIn.getBlockState(blockPos); - TileEntity te = worldIn.getBlockEntity(blockPos); + BlockEntity te = worldIn.getBlockEntity(blockPos); if (te instanceof KineticTileEntity) ((KineticTileEntity) te).detachKinetics(); if (blockState.getBlock() instanceof GantryShaftBlock) @@ -233,7 +235,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } } - protected boolean shouldBePowered(BlockState state, World worldIn, BlockPos pos) { + protected boolean shouldBePowered(BlockState state, Level worldIn, BlockPos pos) { boolean shouldPower = worldIn.hasNeighborSignal(pos); Direction facing = state.getValue(FACING); @@ -253,7 +255,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.getValue(FACING) .getAxis(); } @@ -265,7 +267,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.GANTRY_SHAFT.create(); } @@ -286,7 +288,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } @@ -303,7 +305,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } @Override - public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { + public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) { PlacementOffset offset = super.getOffset(player, world, state, pos, ray); 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 2d29850bb..9cac7523a 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 @@ -6,16 +6,16 @@ import com.simibubi.create.content.contraptions.components.structureMovement.gan import com.simibubi.create.content.contraptions.components.structureMovement.gantry.GantryCarriageTileEntity; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; public class GantryShaftTileEntity extends KineticTileEntity { - public GantryShaftTileEntity(TileEntityType typeIn) { + public GantryShaftTileEntity(BlockEntityType typeIn) { super(typeIn); } @@ -32,7 +32,7 @@ public class GantryShaftTileEntity extends KineticTileEntity { continue; if (pinionState.getValue(GantryCarriageBlock.FACING) != d) continue; - TileEntity tileEntity = level.getBlockEntity(offset); + BlockEntity tileEntity = level.getBlockEntity(offset); if (tileEntity instanceof GantryCarriageTileEntity) ((GantryCarriageTileEntity) tileEntity).queueAssembly(); } @@ -99,7 +99,7 @@ public class GantryShaftTileEntity extends KineticTileEntity { BlockState blockState = getBlockState(); if (!AllBlocks.GANTRY_SHAFT.has(blockState)) return 0; - return MathHelper.clamp(convertToLinear(-getSpeed()), -.49f, .49f); + return Mth.clamp(convertToLinear(-getSpeed()), -.49f, .49f); } @Override 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 c0838a5c9..ab7a91222 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 @@ -16,22 +16,24 @@ import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.placement.PlacementOffset; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -44,12 +46,12 @@ public class SpeedControllerBlock extends HorizontalAxisKineticBlock implements } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.ROTATION_SPEED_CONTROLLER.create(); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockState above = context.getLevel() .getBlockState(context.getClickedPos() .above()); @@ -60,26 +62,26 @@ public class SpeedControllerBlock extends HorizontalAxisKineticBlock implements } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, BlockPos neighbourPos, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos neighbourPos, boolean p_220069_6_) { if (neighbourPos.equals(pos.above())) withTileEntityDo(world, pos, SpeedControllerTileEntity::updateBracket); } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult ray) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult ray) { 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); - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.SPEED_CONTROLLER; } @@ -96,7 +98,7 @@ public class SpeedControllerBlock extends HorizontalAxisKineticBlock implements } @Override - public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { + public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) { BlockPos newPos = pos.above(); if (!world.getBlockState(newPos) .getMaterial() 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 54349d915..a22e0765a 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 @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.relays.advanced; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -10,28 +10,28 @@ import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class SpeedControllerRenderer extends SmartTileEntityRenderer { - public SpeedControllerRenderer(TileEntityRendererDispatcher dispatcher) { + public SpeedControllerRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(SpeedControllerTileEntity tileEntityIn, float partialTicks, MatrixStack ms, - IRenderTypeBuffer buffer, int light, int overlay) { + protected void renderSafe(SpeedControllerTileEntity tileEntityIn, float partialTicks, PoseStack ms, + MultiBufferSource buffer, int light, int overlay) { super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay); - IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); + VertexConsumer builder = buffer.getBuffer(RenderType.solid()); if (!Backend.getInstance().canUseInstancing(tileEntityIn.getLevel())) { KineticTileEntityRenderer.renderRotatingBuffer(tileEntityIn, getRotatedModel(tileEntityIn), ms, builder, light); } @@ -40,7 +40,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer type) { + public SpeedControllerTileEntity(BlockEntityType type) { super(type); hasBracket = false; } @@ -46,7 +46,7 @@ public class SpeedControllerTileEntity extends KineticTileEntity { new ScrollValueBehaviour(Lang.translate("generic.speed"), this, new ControllerValueBoxTransform()); targetSpeed.between(-max, max); targetSpeed.value = DEFAULT_SPEED; - targetSpeed.moveText(new Vector3d(9, 0, 10)); + targetSpeed.moveText(new Vec3(9, 0, 10)); targetSpeed.withUnit(i -> Lang.translate("generic.unit.rpm")); targetSpeed.withCallback(i -> this.updateTargetRotation()); targetSpeed.withStepFunction(CreativeMotorTileEntity::step); @@ -125,7 +125,7 @@ public class SpeedControllerTileEntity extends KineticTileEntity { private class ControllerValueBoxTransform extends ValueBoxTransform.Sided { @Override - protected Vector3d getSouthLocation() { + protected Vec3 getSouthLocation() { return VecHelper.voxelSpace(8, 11f, 16); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/ConfigureSequencedGearshiftPacket.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/ConfigureSequencedGearshiftPacket.java index 41f3daff5..8f1d61d2a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/ConfigureSequencedGearshiftPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/ConfigureSequencedGearshiftPacket.java @@ -2,33 +2,33 @@ package com.simibubi.create.content.contraptions.relays.advanced.sequencer; import com.simibubi.create.foundation.networking.TileEntityConfigurationPacket; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; import net.minecraftforge.common.util.Constants.NBT; public class ConfigureSequencedGearshiftPacket extends TileEntityConfigurationPacket { - private ListNBT instructions; + private ListTag instructions; - public ConfigureSequencedGearshiftPacket(BlockPos pos, ListNBT instructions) { + public ConfigureSequencedGearshiftPacket(BlockPos pos, ListTag instructions) { super(pos); this.instructions = instructions; } - public ConfigureSequencedGearshiftPacket(PacketBuffer buffer) { + public ConfigureSequencedGearshiftPacket(FriendlyByteBuf buffer) { super(buffer); } @Override - protected void readSettings(PacketBuffer buffer) { + protected void readSettings(FriendlyByteBuf buffer) { instructions = buffer.readNbt().getList("data", NBT.TAG_COMPOUND); } @Override - protected void writeSettings(PacketBuffer buffer) { - CompoundNBT tag = new CompoundNBT(); + protected void writeSettings(FriendlyByteBuf buffer) { + CompoundTag tag = new CompoundTag(); tag.put("data", instructions); buffer.writeNbt(tag); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/Instruction.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/Instruction.java index 2ffbcae4d..9335285d1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/Instruction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/Instruction.java @@ -5,8 +5,8 @@ import java.util.Vector; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; public class Instruction { @@ -99,17 +99,17 @@ public class Instruction { return instruction == SequencerInstructions.AWAIT ? OnIsPoweredResult.CONTINUE : OnIsPoweredResult.NOTHING; } - public static ListNBT serializeAll(Vector instructions) { - ListNBT list = new ListNBT(); + public static ListTag serializeAll(Vector instructions) { + ListTag list = new ListTag(); instructions.forEach(i -> list.add(i.serialize())); return list; } - public static Vector deserializeAll(ListNBT list) { + public static Vector deserializeAll(ListTag list) { if (list.isEmpty()) return createDefault(); Vector instructions = new Vector<>(5); - list.forEach(inbt -> instructions.add(deserialize((CompoundNBT) inbt))); + list.forEach(inbt -> instructions.add(deserialize((CompoundTag) inbt))); return instructions; } @@ -120,15 +120,15 @@ public class Instruction { return instructions; } - CompoundNBT serialize() { - CompoundNBT tag = new CompoundNBT(); + CompoundTag serialize() { + CompoundTag tag = new CompoundTag(); NBTHelper.writeEnum(tag, "Type", instruction); NBTHelper.writeEnum(tag, "Modifier", speedModifier); tag.putInt("Value", value); return tag; } - static Instruction deserialize(CompoundNBT tag) { + static Instruction deserialize(CompoundTag tag) { Instruction instruction = new Instruction(NBTHelper.readEnum(tag, "Type", SequencerInstructions.class)); instruction.speedModifier = NBTHelper.readEnum(tag, "Modifier", InstructionSpeedModifiers.class); instruction.value = tag.getInt("Value"); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/InstructionSpeedModifiers.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/InstructionSpeedModifiers.java index 6835b54bf..4495a9d79 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/InstructionSpeedModifiers.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/InstructionSpeedModifiers.java @@ -5,8 +5,8 @@ import java.util.List; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public enum InstructionSpeedModifiers { @@ -16,21 +16,21 @@ public enum InstructionSpeedModifiers { String translationKey; int value; - ITextComponent label; + Component label; - private InstructionSpeedModifiers(int modifier, ITextComponent label) { + private InstructionSpeedModifiers(int modifier, Component label) { this.label = label; translationKey = "gui.sequenced_gearshift.speed." + Lang.asId(name()); value = modifier; } private InstructionSpeedModifiers(int modifier, String label) { - this.label = new StringTextComponent(label); + this.label = new TextComponent(label); translationKey = "gui.sequenced_gearshift.speed." + Lang.asId(name()); value = modifier; } - static List getOptions() { - List options = new ArrayList<>(); + static List getOptions() { + List options = new ArrayList<>(); for (InstructionSpeedModifiers entry : values()) options.add(Lang.translate(entry.translationKey)); return options; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java index f66821680..1a4ca5b20 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java @@ -10,32 +10,34 @@ import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.gui.ScreenOpener; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.IntegerProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implements ITE { public static final BooleanProperty VERTICAL = BooleanProperty.create("vertical"); @@ -51,17 +53,17 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.SEQUENCED_GEARSHIFT.create(); } @Override - public boolean shouldCheckWeakPower(BlockState state, IWorldReader world, BlockPos pos, Direction side) { + public boolean shouldCheckWeakPower(BlockState state, LevelReader world, BlockPos pos, Direction side) { return false; } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { if (worldIn.isClientSide) return; @@ -72,7 +74,7 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, Random r) { boolean previouslyPowered = state.getValue(STATE) != 0; boolean isPowered = worldIn.hasNeighborSignal(pos); withTileEntityDo(worldIn, pos, sgte -> sgte.onRedstoneUpdate(isPowered, previouslyPowered)); @@ -84,7 +86,7 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { if (state.getValue(VERTICAL)) return face.getAxis() .isVertical(); @@ -92,30 +94,30 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen } @Override - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { ItemStack held = player.getMainHandItem(); if (AllItems.WRENCH.isIn(held)) - return ActionResultType.PASS; + return InteractionResult.PASS; if (held.getItem() instanceof BlockItem) { BlockItem blockItem = (BlockItem) held.getItem(); if (blockItem.getBlock() instanceof KineticBlock && hasShaftTowards(worldIn, pos, state, hit.getDirection())) - return ActionResultType.PASS; + return InteractionResult.PASS; } DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> withTileEntityDo(worldIn, pos, te -> this.displayScreen(te, player))); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @OnlyIn(value = Dist.CLIENT) - protected void displayScreen(SequencedGearshiftTileEntity te, PlayerEntity player) { - if (player instanceof ClientPlayerEntity) + protected void displayScreen(SequencedGearshiftTileEntity te, Player player) { + if (player instanceof LocalPlayer) ScreenOpener.open(new SequencedGearshiftScreen(te)); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Axis preferredAxis = RotatedPillarKineticBlock.getPreferredAxis(context); if (preferredAxis != null && (context.getPlayer() == null || !context.getPlayer() .isShiftKeyDown())) @@ -125,7 +127,7 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onWrenched(BlockState state, UseOnContext context) { BlockState newState = state; if (context.getClickedFace() @@ -137,7 +139,7 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen return super.onWrenched(newState, context); } - private BlockState withAxis(Axis axis, BlockItemUseContext context) { + private BlockState withAxis(Axis axis, BlockPlaceContext context) { BlockState state = defaultBlockState().setValue(VERTICAL, axis.isVertical()); if (axis.isVertical()) return state.setValue(HORIZONTAL_AXIS, context.getHorizontalDirection() @@ -163,7 +165,7 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen } @Override - public int getAnalogOutputSignal(BlockState state, World world, BlockPos pos) { + public int getAnalogOutputSignal(BlockState state, Level 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 9301fecdd..5b88b2554 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 @@ -4,9 +4,9 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction.Axis; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction.Axis; import net.minecraftforge.client.model.generators.ModelFile; public class SequencedGearshiftGenerator extends SpecialBlockStateGen { 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 30a7063fc..b93884752 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 @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.relays.advanced.sequencer; import java.util.Vector; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.gui.AbstractSimiScreen; import com.simibubi.create.foundation.gui.AllGuiTextures; @@ -14,11 +14,11 @@ import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.ListTag; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class SequencedGearshiftScreen extends AbstractSimiScreen { @@ -26,7 +26,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { private final AllGuiTextures background = AllGuiTextures.SEQUENCER; private IconButton confirmButton; - private ListNBT compareTag; + private ListTag compareTag; private Vector instructions; private BlockPos pos; @@ -126,7 +126,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int x = guiLeft; int y = guiTop; @@ -148,7 +148,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { if (def.hasValueParameter) { String text = def.formatValue(instruction.value); int stringWidth = font.width(text); - label(ms, 90 + (12 - stringWidth / 2), yOffset - 3, new StringTextComponent(text)); + label(ms, 90 + (12 - stringWidth / 2), yOffset - 3, new TextComponent(text)); } if (def.hasSpeedParameter) label(ms, 127, yOffset - 3, instruction.speedModifier.label); @@ -162,12 +162,12 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { .render(ms); } - private void label(MatrixStack ms, int x, int y, ITextComponent text) { + private void label(PoseStack ms, int x, int y, Component text) { font.drawShadow(ms, text, guiLeft + x, guiTop + 26 + y, 0xFFFFEE); } public void sendPacket() { - ListNBT serialized = Instruction.serializeAll(instructions); + ListTag serialized = Instruction.serializeAll(instructions); if (serialized.equals(compareTag)) return; AllPackets.channel.sendToServer(new ConfigureSequencedGearshiftPacket(pos, serialized)); 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 4801c13ac..651be36ea 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 @@ -4,10 +4,10 @@ import java.util.Vector; import com.simibubi.create.content.contraptions.relays.encased.SplitShaftTileEntity; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; import net.minecraftforge.common.util.Constants.NBT; public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { @@ -19,7 +19,7 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { int timer; boolean poweredPreviously; - public SequencedGearshiftTileEntity(TileEntityType type) { + public SequencedGearshiftTileEntity(BlockEntityType type) { super(type); instructions = Instruction.createDefault(); currentInstruction = -1; @@ -134,7 +134,7 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("InstructionIndex", currentInstruction); compound.putInt("InstructionDuration", currentInstructionDuration); compound.putFloat("InstructionProgress", currentInstructionProgress); @@ -145,7 +145,7 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { currentInstruction = compound.getInt("InstructionIndex"); currentInstructionDuration = compound.getInt("InstructionDuration"); currentInstructionProgress = compound.getFloat("InstructionProgress"); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java index ce15fe19c..76647943c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java @@ -6,7 +6,7 @@ import java.util.List; import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.network.chat.Component; public enum SequencerInstructions { @@ -45,8 +45,8 @@ public enum SequencerInstructions { parameterKey = translationKey + "." + parameterName; } - static List getOptions() { - List options = new ArrayList<>(); + static List getOptions() { + List options = new ArrayList<>(); for (SequencerInstructions entry : values()) options.add(Lang.translate(entry.descriptiveTranslationKey)); return options; 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 45a30857e..4d4f6e5b9 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 @@ -27,56 +27,58 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.loot.LootParameters; -import net.minecraft.pathfinding.PathNodeType; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.Property; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Hand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.Rotation; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.gen.DebugChunkGenerator; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.pathfinder.BlockPathTypes; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.NonNullList; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.DebugLevelSource; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.Tags; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class BeltBlock extends HorizontalKineticBlock implements ITE, ISpecialBlockItemRequirement { public static final Property SLOPE = EnumProperty.create("slope", BeltSlope.class); @@ -91,7 +93,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE p_149666_2_) { + public void fillItemCategory(CreativeModeTab p_149666_1_, NonNullList p_149666_2_) { p_149666_2_.add(AllItems.BELT_CONNECTOR.asStack()); } @@ -102,7 +104,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE getDrops(BlockState state, net.minecraft.loot.LootContext.Builder builder) { + public List getDrops(BlockState state, net.minecraft.world.level.storage.loot.LootContext.Builder builder) { List drops = super.getDrops(state, builder); - TileEntity tileEntity = builder.getOptionalParameter(LootParameters.BLOCK_ENTITY); + BlockEntity tileEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY); if (tileEntity instanceof BeltTileEntity && ((BeltTileEntity) tileEntity).hasPulley()) drops.addAll(AllBlocks.SHAFT.getDefaultState() .getDrops(builder)); @@ -136,7 +138,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE te.applyColor(DyeColor.getColor(heldItem))); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (isConnector) @@ -258,14 +260,14 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE { @@ -274,63 +276,63 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE te.setCasingType(CasingType.BRASS)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (AllBlocks.ANDESITE_CASING.isIn(heldItem)) { if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; AllTriggers.triggerFor(AllTriggers.CASING_BELT, player); withTileEntityDo(world, pos, te -> te.setCasingType(CasingType.ANDESITE)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getLevel(); - PlayerEntity player = context.getPlayer(); + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + Level world = context.getLevel(); + Player player = context.getPlayer(); BlockPos pos = context.getClickedPos(); if (state.getValue(CASING)) { if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; withTileEntityDo(world, pos, te -> te.setCasingType(CasingType.NONE)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (state.getValue(PART) == BeltPart.PULLEY) { if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; KineticTileEntity.switchToBlockState(world, pos, state.setValue(PART, BeltPart.MIDDLE)); if (player != null && !player.isCreative()) player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack()); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override @@ -345,27 +347,27 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE { @@ -384,20 +386,20 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE getBeltChain(World world, BlockPos controllerPos) { + public static List getBeltChain(Level world, BlockPos controllerPos) { List positions = new LinkedList<>(); BlockState blockState = world.getBlockState(controllerPos); @@ -563,7 +565,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE required = new ArrayList<>(); if (state.getValue(PART) != BeltPart.MIDDLE) required.add(AllBlocks.SHAFT.asStack()); @@ -593,7 +595,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE { Direction.Axis axis = dir.getAxis(); - Supplier ms = () -> { - MatrixStack modelTransform = new MatrixStack(); + Supplier ms = () -> { + PoseStack modelTransform = new PoseStack(); MatrixTransformStack msr = MatrixTransformStack.of(modelTransform); msr.centre(); if (axis == Direction.Axis.X) 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 5a1539690..cde31ad7a 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 @@ -12,19 +12,19 @@ import com.simibubi.create.foundation.block.render.QuadHelper; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.render.SuperByteBuffer; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.util.Direction; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; +import net.minecraft.core.Direction; import net.minecraftforge.client.model.BakedModelWrapper; import net.minecraftforge.client.model.data.IModelData; -public class BeltModel extends BakedModelWrapper { +public class BeltModel extends BakedModelWrapper { - public BeltModel(IBakedModel template) { + public BeltModel(BakedModel template) { super(template); } @@ -39,7 +39,7 @@ public class BeltModel extends BakedModelWrapper { quads = new ArrayList<>(quads); SpriteShiftEntry spriteShift = AllSpriteShifts.ANDESIDE_BELT_CASING; - VertexFormat format = DefaultVertexFormats.BLOCK; + VertexFormat format = DefaultVertexFormat.BLOCK; for (int i = 0; i < quads.size(); i++) { BakedQuad quad = quads.get(i); 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 d864d7bb8..852c07c97 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 @@ -2,9 +2,9 @@ package com.simibubi.create.content.contraptions.relays.belt; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.IStringSerializable; +import net.minecraft.util.StringRepresentable; -public enum BeltPart implements IStringSerializable { +public enum BeltPart implements StringRepresentable { START, MIDDLE, END, PULLEY; @Override 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 d7855b0cf..3e438da37 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 @@ -6,8 +6,8 @@ import java.util.function.Supplier; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllSpriteShifts; @@ -24,27 +24,27 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.entity.Entity; -import net.minecraft.item.DyeColor; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.math.vector.Vector3i; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.DyeColor; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; +import net.minecraft.core.Vec3i; public class BeltRenderer extends SafeTileEntityRenderer { - public BeltRenderer(TileEntityRendererDispatcher dispatcher) { + public BeltRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @@ -54,7 +54,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { } @Override - protected void renderSafe(BeltTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(BeltTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (!Backend.getInstance().canUseInstancing(te.getLevel())) { @@ -75,9 +75,9 @@ public class BeltRenderer extends SafeTileEntityRenderer { boolean sideways = beltSlope == BeltSlope.SIDEWAYS; boolean alongX = facing.getAxis() == Axis.X; - MatrixStack localTransforms = new MatrixStack(); + PoseStack localTransforms = new PoseStack(); MatrixTransformStack msr = MatrixTransformStack.of(localTransforms); - IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); float renderTick = AnimationTickHolder.getRenderTime(te.getLevel()); msr.centre(); @@ -132,8 +132,8 @@ public class BeltRenderer extends SafeTileEntityRenderer { if (te.hasPulley()) { Direction dir = sideways ? Direction.UP : blockState.getValue(BeltBlock.HORIZONTAL_FACING).getClockWise(); - Supplier matrixStackSupplier = () -> { - MatrixStack stack = new MatrixStack(); + Supplier matrixStackSupplier = () -> { + PoseStack stack = new PoseStack(); MatrixTransformStack stacker = MatrixTransformStack.of(stack); stacker.centre(); if (dir.getAxis() == Axis.X) stacker.rotateY(90); @@ -176,7 +176,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { } } - protected void renderItems(BeltTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderItems(BeltTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (!te.isController()) return; @@ -186,9 +186,9 @@ public class BeltRenderer extends SafeTileEntityRenderer { ms.pushPose(); Direction beltFacing = te.getBeltFacing(); - Vector3i directionVec = beltFacing + Vec3i directionVec = beltFacing .getNormal(); - Vector3d beltStartOffset = Vector3d.atLowerCornerOf(directionVec).scale(-.5) + Vec3 beltStartOffset = Vec3.atLowerCornerOf(directionVec).scale(-.5) .add(.5, 15 / 16f, .5); ms.translate(beltStartOffset.x, beltStartOffset.y, beltStartOffset.z); BeltSlope slope = te.getBlockState() @@ -213,19 +213,19 @@ public class BeltRenderer extends SafeTileEntityRenderer { offset = transported.beltPosition; sideOffset = transported.sideOffset; } else { - offset = MathHelper.lerp(partialTicks, transported.prevBeltPosition, transported.beltPosition); - sideOffset = MathHelper.lerp(partialTicks, transported.prevSideOffset, transported.sideOffset); + offset = Mth.lerp(partialTicks, transported.prevBeltPosition, transported.beltPosition); + sideOffset = Mth.lerp(partialTicks, transported.prevSideOffset, transported.sideOffset); } if (offset < .5) verticalMovement = 0; else verticalMovement = verticality * (Math.min(offset, te.beltLength - .5f) - .5f); - Vector3d offsetVec = Vector3d.atLowerCornerOf(directionVec).scale(offset); + Vec3 offsetVec = Vec3.atLowerCornerOf(directionVec).scale(offset); if (verticalMovement != 0) offsetVec = offsetVec.add(0, verticalMovement, 0); boolean onSlope = - slope != BeltSlope.HORIZONTAL && MathHelper.clamp(offset, .5f, te.beltLength - .5f) == offset; + slope != BeltSlope.HORIZONTAL && Mth.clamp(offset, .5f, te.beltLength - .5f) == offset; boolean tiltForward = (slope == BeltSlope.DOWNWARD ^ beltFacing .getAxisDirection() == AxisDirection.POSITIVE) == (beltFacing .getAxis() == Axis.Z); @@ -246,7 +246,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { boolean renderUpright = BeltHelper.isItemUpright(transported.stack); boolean blockItem = itemRenderer.getModel(transported.stack, te.getLevel(), null) .isGui3d(); - int count = (int) (MathHelper.log2((int) (transported.stack.getCount()))) / 2; + int count = (int) (Mth.log2((int) (transported.stack.getCount()))) / 2; Random r = new Random(transported.angle); boolean slopeShadowOnly = renderUpright && onSlope; @@ -269,10 +269,10 @@ public class BeltRenderer extends SafeTileEntityRenderer { if (renderUpright) { Entity renderViewEntity = Minecraft.getInstance().cameraEntity; if (renderViewEntity != null) { - Vector3d positionVec = renderViewEntity.position(); - Vector3d vectorForOffset = BeltHelper.getVectorForOffset(te, offset); - Vector3d diff = vectorForOffset.subtract(positionVec); - float yRot = (float) (MathHelper.atan2(diff.x, diff.z) + Math.PI); + Vec3 positionVec = renderViewEntity.position(); + Vec3 vectorForOffset = BeltHelper.getVectorForOffset(te, offset); + Vec3 diff = vectorForOffset.subtract(positionVec); + float yRot = (float) (Mth.atan2(diff.x, diff.z) + Math.PI); ms.mulPose(Vector3f.YP.rotation(yRot)); } ms.translate(0, 3 / 32d, 1 / 16f); 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 aa20a4d02..5e077c889 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 @@ -2,8 +2,19 @@ package com.simibubi.create.content.contraptions.relays.belt; import static net.minecraft.block.Block.box; +import javanimport com.simibubi.create.AllShapes; +import com.simibubi.create.foundation.utility.VoxelShaper; import java.util.HashMap; import java.util.Map; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; + +et.minecraft.world.level.block.Blockva.util.Map; import com.simibubi.create.AllShapes; import com.simibubi.create.foundation.utility.VoxelShaper; @@ -113,21 +124,21 @@ public class BeltShapes { static Map collisionCache = new HashMap<>(); private static VoxelShape compose(VoxelShape southPart, VoxelShape northPart){ - return VoxelShapes.or( - VoxelShapes.joinUnoptimized(SOUTH_MASK, southPart, IBooleanFunction.AND), - VoxelShapes.joinUnoptimized(NORTH_MASK, northPart, IBooleanFunction.AND) + return Shapes.or( + Shapes.joinUnoptimized(SOUTH_MASK, southPart, BooleanOp.AND), + Shapes.joinUnoptimized(NORTH_MASK, northPart, BooleanOp.AND) ); } private static VoxelShape makeSlopePart(boolean ascendingInstead) { VoxelShape slice = box(1, 0, 16, 15, 11, 15); - VoxelShape result = VoxelShapes.empty(); + VoxelShape result = Shapes.empty(); for (int i = 0; i < 16; i++) { int yOffset = ascendingInstead ? 10 - i : i - 5; - result = VoxelShapes.or( + result = Shapes.or( result,//move slice i voxels "right" and i-5 voxels "down" slice.move(0, yOffset / 16f, -i / 16f)); } @@ -136,7 +147,7 @@ public class BeltShapes { } private static VoxelShape makeFlatEnding(){ - return VoxelShapes.or( + return Shapes.or( box(1,4,0,15,12,16), box(1,3,1,15,13,15) ); @@ -147,7 +158,7 @@ public class BeltShapes { } private static VoxelShape makeSidewaysEnding(){ - return VoxelShapes.or( + return Shapes.or( box(4,1,0,12,15,16), box(3,1,1,13,15,15) ); @@ -160,7 +171,7 @@ public class BeltShapes { public static VoxelShape getShape(BlockState state) { if (cache.containsKey(state)) return cache.get(state); - VoxelShape createdShape = VoxelShapes.or(getBeltShape(state), getCasingShape(state)); + VoxelShape createdShape = Shapes.or(getBeltShape(state), getCasingShape(state)); cache.put(state, createdShape); return createdShape; } @@ -168,7 +179,7 @@ public class BeltShapes { public static VoxelShape getCollisionShape(BlockState state) { if (collisionCache.containsKey(state)) return collisionCache.get(state); - VoxelShape createdShape = VoxelShapes.joinUnoptimized(AllShapes.BELT_COLLISION_MASK, getShape(state), IBooleanFunction.AND); + VoxelShape createdShape = Shapes.joinUnoptimized(AllShapes.BELT_COLLISION_MASK, getShape(state), BooleanOp.AND); collisionCache.put(state, createdShape); return createdShape; } @@ -213,21 +224,21 @@ public class BeltShapes { return (slope == BeltSlope.DOWNWARD ? SLOPE_DESC_END : SLOPE_ASC_END).get(facing); //bad state - return VoxelShapes.empty(); + return Shapes.empty(); } private static VoxelShape getCasingShape(BlockState state) { if (!state.getValue(BeltBlock.CASING)) - return VoxelShapes.empty(); + return Shapes.empty(); 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(); + return Shapes.empty(); if (slope == BeltSlope.SIDEWAYS) - return VoxelShapes.empty(); + return Shapes.empty(); if (slope == BeltSlope.HORIZONTAL) { return AllShapes.CASING_11PX.get(Direction.UP); @@ -242,17 +253,17 @@ public class BeltShapes { return slope == BeltSlope.DOWNWARD ? AllShapes.CASING_11PX.get(Direction.UP) : PARTIAL_CASING.get(facing); //something went wrong - return VoxelShapes.block(); + return Shapes.block(); } private static class VerticalBeltShaper extends VoxelShaper { public static VoxelShaper make(VoxelShape southBeltShape){ return forDirectionsWithRotation( - rotatedCopy(southBeltShape, new Vector3d(-90,0,0)), + rotatedCopy(southBeltShape, new Vec3(-90,0,0)), Direction.SOUTH, Direction.Plane.HORIZONTAL,//idk, this can probably be improved :S - direction -> new Vector3d( + direction -> new Vec3( direction.getAxisDirection() == Direction.AxisDirection.POSITIVE ? 0 : 180, -direction.toYRot(), 0)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltSlicer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltSlicer.java index 4446ca388..228b5b2c7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltSlicer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltSlicer.java @@ -16,29 +16,29 @@ import com.simibubi.create.content.contraptions.relays.belt.transport.Transporte import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.Constants.BlockFlags; @@ -47,25 +47,25 @@ public class BeltSlicer { public static class Feedback { int color = 0xffffff; - AxisAlignedBB bb; + AABB bb; String langKey; - TextFormatting formatting = TextFormatting.WHITE; + ChatFormatting formatting = ChatFormatting.WHITE; } - public static ActionResultType useWrench(BlockState state, World world, BlockPos pos, PlayerEntity player, - Hand handIn, BlockRayTraceResult hit, Feedback feedBack) { + public static InteractionResult useWrench(BlockState state, Level world, BlockPos pos, Player player, + InteractionHand handIn, BlockHitResult hit, Feedback feedBack) { BeltTileEntity controllerTE = BeltHelper.getControllerTE(world, pos); if (controllerTE == null) - return ActionResultType.PASS; + return InteractionResult.PASS; if (state.getValue(BeltBlock.CASING) && hit.getDirection() != Direction.UP) - return ActionResultType.PASS; + return InteractionResult.PASS; if (state.getValue(BeltBlock.PART) == BeltPart.PULLEY && hit.getDirection() .getAxis() != Axis.Y) - return ActionResultType.PASS; + return InteractionResult.PASS; int beltLength = controllerTE.beltLength; if (beltLength == 2) - return ActionResultType.FAIL; + return InteractionResult.FAIL; BlockPos beltVector = new BlockPos(BeltHelper.getBeltVector(state)); BeltPart part = state.getValue(BeltBlock.PART); @@ -75,7 +75,7 @@ public class BeltSlicer { // Shorten from End if (hoveringEnd(state, hit)) { if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; for (BlockPos blockPos : beltChain) { BeltTileEntity belt = BeltHelper.getSegmentTE(world, blockPos); @@ -120,7 +120,7 @@ public class BeltSlicer { if (transportedItemStack.beltPosition <= 0) { ItemEntity entity = new ItemEntity(world, pos.getX() + .5f, pos.getY() + 11 / 16f, pos.getZ() + .5f, transportedItemStack.stack); - entity.setDeltaMovement(Vector3d.ZERO); + entity.setDeltaMovement(Vec3.ZERO); entity.setDefaultPickUpDelay(); entity.hurtMarked = true; world.addFreshEntity(entity); @@ -130,25 +130,25 @@ public class BeltSlicer { } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } BeltTileEntity segmentTE = BeltHelper.getSegmentTE(world, pos); if (segmentTE == null) - return ActionResultType.PASS; + return InteractionResult.PASS; // Split in half int hitSegment = segmentTE.index; - Vector3d centerOf = VecHelper.getCenterOf(hit.getBlockPos()); - Vector3d subtract = hit.getLocation() + Vec3 centerOf = VecHelper.getCenterOf(hit.getBlockPos()); + Vec3 subtract = hit.getLocation() .subtract(centerOf); - boolean towardPositive = subtract.dot(Vector3d.atLowerCornerOf(beltVector)) > 0; + boolean towardPositive = subtract.dot(Vec3.atLowerCornerOf(beltVector)) > 0; BlockPos next = !towardPositive ? pos.subtract(beltVector) : pos.offset(beltVector); if (hitSegment == 0 || hitSegment == 1 && !towardPositive) - return ActionResultType.FAIL; + return InteractionResult.FAIL; if (hitSegment == controllerTE.beltLength - 1 || hitSegment == controllerTE.beltLength - 2 && towardPositive) - return ActionResultType.FAIL; + return InteractionResult.FAIL; // Look for shafts if (!creative) { @@ -191,7 +191,7 @@ public class BeltSlicer { if (!world.isClientSide) player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack(amountRetrieved)); - return ActionResultType.FAIL; + return InteractionResult.FAIL; } } @@ -211,7 +211,7 @@ public class BeltSlicer { KineticTileEntity.switchToBlockState(world, next, world.getBlockState(next) .setValue(BeltBlock.PART, towardPositive ? BeltPart.START : BeltPart.END)); world.playSound(null, pos, SoundEvents.WOOL_HIT, - player == null ? SoundCategory.BLOCKS : SoundCategory.PLAYERS, 0.5F, 2.3F); + player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 0.5F, 2.3F); // Transfer items to new controller BeltTileEntity newController = towardPositive ? BeltHelper.getSegmentTE(world, next) : segmentTE; @@ -232,18 +232,18 @@ public class BeltSlicer { } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - public static ActionResultType useConnector(BlockState state, World world, BlockPos pos, PlayerEntity player, - Hand handIn, BlockRayTraceResult hit, Feedback feedBack) { + public static InteractionResult useConnector(BlockState state, Level world, BlockPos pos, Player player, + InteractionHand handIn, BlockHitResult hit, Feedback feedBack) { BeltTileEntity controllerTE = BeltHelper.getControllerTE(world, pos); if (controllerTE == null) - return ActionResultType.PASS; + return InteractionResult.PASS; int beltLength = controllerTE.beltLength; if (beltLength == BeltConnectorItem.maxLength()) - return ActionResultType.FAIL; + return InteractionResult.FAIL; BlockPos beltVector = new BlockPos(BeltHelper.getBeltVector(state)); BeltPart part = state.getValue(BeltBlock.PART); @@ -252,7 +252,7 @@ public class BeltSlicer { boolean creative = player.isCreative(); if (!hoveringEnd(state, hit)) - return ActionResultType.PASS; + return InteractionResult.PASS; BlockPos next = part == BeltPart.START ? pos.subtract(beltVector) : pos.offset(beltVector); BeltTileEntity mergedController = null; @@ -263,15 +263,15 @@ public class BeltSlicer { if (!nextState.getMaterial() .isReplaceable()) { if (!AllBlocks.BELT.has(nextState)) - return ActionResultType.FAIL; + return InteractionResult.FAIL; if (!beltStatesCompatible(state, nextState)) - return ActionResultType.FAIL; + return InteractionResult.FAIL; mergedController = BeltHelper.getControllerTE(world, next); if (mergedController == null) - return ActionResultType.FAIL; + return InteractionResult.FAIL; if (mergedController.beltLength + beltLength > BeltConnectorItem.maxLength()) - return ActionResultType.FAIL; + return InteractionResult.FAIL; mergedBeltLength = mergedController.beltLength; @@ -322,7 +322,7 @@ public class BeltSlicer { if (segmentTE != null) segmentTE.color = controllerTE.color; world.playSound(null, pos, SoundEvents.WOOL_PLACE, - player == null ? SoundCategory.BLOCKS : SoundCategory.PLAYERS, 0.5F, 1F); + player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 0.5F, 1F); // Transfer items to new controller if (part == BeltPart.START && segmentTE != null && inventory != null) { @@ -338,7 +338,7 @@ public class BeltSlicer { // Merge with other BeltInventory mergedInventory = mergedController.inventory; world.playSound(null, pos, SoundEvents.WOOL_HIT, - player == null ? SoundCategory.BLOCKS : SoundCategory.PLAYERS, 0.5F, 1.3F); + player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 0.5F, 1.3F); BeltTileEntity segmentTE = BeltHelper.getSegmentTE(world, next); KineticTileEntity.switchToBlockState(world, next, state.setValue(BeltBlock.CASING, segmentTE != null && segmentTE.casing != CasingType.NONE) @@ -387,7 +387,7 @@ public class BeltSlicer { } } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } static boolean beltStatesCompatible(BlockState state, BlockState nextState) { @@ -428,14 +428,14 @@ public class BeltSlicer { return state.setValue(BeltBlock.HORIZONTAL_FACING, facing.getOpposite()); } - static boolean hoveringEnd(BlockState state, BlockRayTraceResult hit) { + static boolean hoveringEnd(BlockState state, BlockHitResult hit) { BeltPart part = state.getValue(BeltBlock.PART); if (part == BeltPart.MIDDLE || part == BeltPart.PULLEY) return false; - Vector3d beltVector = BeltHelper.getBeltVector(state); - Vector3d centerOf = VecHelper.getCenterOf(hit.getBlockPos()); - Vector3d subtract = hit.getLocation() + Vec3 beltVector = BeltHelper.getBeltVector(state); + Vec3 centerOf = VecHelper.getCenterOf(hit.getBlockPos()); + Vec3 subtract = hit.getLocation() .subtract(centerOf); return subtract.dot(beltVector) > 0 == (part == BeltPart.END); @@ -444,16 +444,16 @@ public class BeltSlicer { @OnlyIn(Dist.CLIENT) public static void tickHoveringInformation() { Minecraft mc = Minecraft.getInstance(); - RayTraceResult target = mc.hitResult; - if (target == null || !(target instanceof BlockRayTraceResult)) + HitResult target = mc.hitResult; + if (target == null || !(target instanceof BlockHitResult)) return; - BlockRayTraceResult result = (BlockRayTraceResult) target; - ClientWorld world = mc.level; + BlockHitResult result = (BlockHitResult) target; + ClientLevel world = mc.level; BlockPos pos = result.getBlockPos(); BlockState state = world.getBlockState(pos); - ItemStack held = mc.player.getItemInHand(Hand.MAIN_HAND); - ItemStack heldOffHand = mc.player.getItemInHand(Hand.OFF_HAND); + ItemStack held = mc.player.getItemInHand(InteractionHand.MAIN_HAND); + ItemStack heldOffHand = mc.player.getItemInHand(InteractionHand.OFF_HAND); if (mc.player.isShiftKeyDown()) return; @@ -464,9 +464,9 @@ public class BeltSlicer { // TODO: Populate feedback in the methods for clientside if (AllItems.WRENCH.isIn(held) || AllItems.WRENCH.isIn(heldOffHand)) - useWrench(state, world, pos, mc.player, Hand.MAIN_HAND, result, feedback); + useWrench(state, world, pos, mc.player, InteractionHand.MAIN_HAND, result, feedback); else if (AllItems.BELT_CONNECTOR.isIn(held) || AllItems.BELT_CONNECTOR.isIn(heldOffHand)) - useConnector(state, world, pos, mc.player, Hand.MAIN_HAND, result, feedback); + useConnector(state, world, pos, mc.player, InteractionHand.MAIN_HAND, result, feedback); else return; @@ -474,7 +474,7 @@ public class BeltSlicer { mc.player.displayClientMessage(Lang.translate(feedback.langKey) .withStyle(feedback.formatting), true); else - mc.player.displayClientMessage(new StringTextComponent(""), true); + mc.player.displayClientMessage(new TextComponent(""), true); if (feedback.bb != null) CreateClient.OUTLINER.chaseAABB("BeltSlicer", feedback.bb) 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 16114f955..0001fb187 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 @@ -2,9 +2,9 @@ package com.simibubi.create.content.contraptions.relays.belt; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.IStringSerializable; +import net.minecraft.util.StringRepresentable; -public enum BeltSlope implements IStringSerializable { +public enum BeltSlope implements StringRepresentable { HORIZONTAL, UPWARD, DOWNWARD, VERTICAL, SIDEWAYS; @Override 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 ece64a75b..af9e9caa5 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.relays.belt; import static com.simibubi.create.content.contraptions.relays.belt.BeltPart.MIDDLE; import static com.simibubi.create.content.contraptions.relays.belt.BeltSlope.HORIZONTAL; import static net.minecraft.util.Direction.AxisDirection.NEGATIVE; -import static net.minecraft.util.Direction.AxisDirection.POSITIVE; +import staticnet.minecraft.core.Direction.AxisDirectionn.POSITIVE; import java.util.ArrayList; import java.util.HashMap; @@ -37,18 +37,18 @@ import com.simibubi.create.foundation.utility.NBTHelper; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.item.DyeColor; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.DyeColor; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NBTUtil; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3i; import net.minecraft.world.LightType; @@ -75,7 +75,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis protected BeltInventory inventory; protected LazyOptional itemHandler; - public CompoundNBT trackerUpdateTag; + public CompoundTag trackerUpdateTag; // client public byte[] light; @@ -84,7 +84,7 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis NONE, ANDESITE, BRASS; } - public BeltTileEntity(TileEntityType type) { + public BeltTileEntity(BlockEntityType type) { super(type); controller = BlockPos.ZERO; itemHandler = LazyOptional.empty(); 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 d6c8d2719..7582ea661 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 @@ -9,34 +9,34 @@ import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock; import com.simibubi.create.foundation.config.AllConfigs; import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.particles.RedstoneParticleData; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; public class BeltConnectorHandler { private static Random r = new Random(); public static void tick() { - PlayerEntity player = Minecraft.getInstance().player; - World world = Minecraft.getInstance().level; + Player player = Minecraft.getInstance().player; + Level world = Minecraft.getInstance().level; if (player == null || world == null) return; if (Minecraft.getInstance().screen != null) return; - for (Hand hand : Hand.values()) { + for (InteractionHand hand : InteractionHand.values()) { ItemStack heldItem = player.getItemInHand(hand); if (!AllItems.BELT_CONNECTOR.isIn(heldItem)) @@ -44,57 +44,57 @@ public class BeltConnectorHandler { if (!heldItem.hasTag()) continue; - CompoundNBT tag = heldItem.getTag(); + CompoundTag tag = heldItem.getTag(); if (!tag.contains("FirstPulley")) continue; - BlockPos first = NBTUtil.readBlockPos(tag.getCompound("FirstPulley")); + BlockPos first = NbtUtils.readBlockPos(tag.getCompound("FirstPulley")); if (!world.getBlockState(first).hasProperty(BlockStateProperties.AXIS)) continue; Axis axis = world.getBlockState(first) .getValue(BlockStateProperties.AXIS); - RayTraceResult rayTrace = Minecraft.getInstance().hitResult; - if (rayTrace == null || !(rayTrace instanceof BlockRayTraceResult)) { + HitResult rayTrace = Minecraft.getInstance().hitResult; + if (rayTrace == null || !(rayTrace instanceof BlockHitResult)) { if (r.nextInt(50) == 0) { - world.addParticle(new RedstoneParticleData(.3f, .9f, .5f, 1), + world.addParticle(new DustParticleOptions(.3f, .9f, .5f, 1), first.getX() + .5f + randomOffset(.25f), first.getY() + .5f + randomOffset(.25f), first.getZ() + .5f + randomOffset(.25f), 0, 0, 0); } return; } - BlockPos selected = ((BlockRayTraceResult) rayTrace).getBlockPos(); + BlockPos selected = ((BlockHitResult) rayTrace).getBlockPos(); if (world.getBlockState(selected) .getMaterial() .isReplaceable()) return; if (!ShaftBlock.isShaft(world.getBlockState(selected))) - selected = selected.relative(((BlockRayTraceResult) rayTrace).getDirection()); + selected = selected.relative(((BlockHitResult) 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.atLowerCornerOf(first); - Vector3d end = Vector3d.atLowerCornerOf(selected); - Vector3d actualDiff = end.subtract(start); + Vec3 start = Vec3.atLowerCornerOf(first); + Vec3 end = Vec3.atLowerCornerOf(selected); + Vec3 actualDiff = end.subtract(start); 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); + Vec3 diff = end.subtract(start); double x = Math.abs(diff.x); double y = Math.abs(diff.y); double z = Math.abs(diff.z); float length = (float) Math.max(x, Math.max(y, z)); - Vector3d step = diff.normalize(); + Vec3 step = diff.normalize(); int sames = ((x == y) ? 1 : 0) + ((y == z) ? 1 : 0) + ((z == x) ? 1 : 0); if (sames == 0) { - List validDiffs = new LinkedList<>(); + List validDiffs = new LinkedList<>(); for (int i = -1; i <= 1; i++) for (int j = -1; j <= 1; j++) for (int k = -1; k <= 1; k++) { @@ -104,11 +104,11 @@ public class BeltConnectorHandler { continue; if (i == 0 && j == 0 && k == 0) continue; - validDiffs.add(new Vector3d(i, j, k)); + validDiffs.add(new Vec3(i, j, k)); } int closestIndex = 0; float closest = Float.MAX_VALUE; - for (Vector3d validDiff : validDiffs) { + for (Vec3 validDiff : validDiffs) { double distanceTo = step.distanceTo(validDiff); if (distanceTo < closest) { closest = (float) distanceTo; @@ -121,11 +121,11 @@ public class BeltConnectorHandler { if (axis == Axis.Y && step.x != 0 && step.z != 0) return; - step = new Vector3d(Math.signum(step.x), Math.signum(step.y), Math.signum(step.z)); + step = new Vec3(Math.signum(step.x), Math.signum(step.y), Math.signum(step.z)); for (float f = 0; f < length; f += .0625f) { - Vector3d position = start.add(step.scale(f)); + Vec3 position = start.add(step.scale(f)); if (r.nextInt(10) == 0) { - world.addParticle(new RedstoneParticleData(canConnect ? .3f : .9f, canConnect ? .9f : .3f, .5f, 1), + world.addParticle(new DustParticleOptions(canConnect ? .3f : .9f, canConnect ? .9f : .3f, .5f, 1), position.x + .5f, position.y + .5f, position.z + .5f, 0, 0, 0); } } 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 45507b9fd..c495e7aab 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 @@ -17,25 +17,27 @@ import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.NonNullList; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.NonNullList; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; + +import net.minecraft.world.item.Item.Properties; public class BeltConnectorItem extends BlockItem { @@ -49,7 +51,7 @@ public class BeltConnectorItem extends BlockItem { } @Override - public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + public void fillItemCategory(CreativeModeTab p_150895_1_, NonNullList p_150895_2_) { if (p_150895_1_ == Create.BASE_CREATIVE_TAB) return; super.fillItemCategory(p_150895_1_, p_150895_2_); @@ -57,28 +59,28 @@ public class BeltConnectorItem extends BlockItem { @Nonnull @Override - public ActionResultType useOn(ItemUseContext context) { - PlayerEntity playerEntity = context.getPlayer(); + public InteractionResult useOn(UseOnContext context) { + Player playerEntity = context.getPlayer(); if (playerEntity != null && playerEntity.isShiftKeyDown()) { context.getItemInHand() .setTag(null); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - World world = context.getLevel(); + Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); boolean validAxis = validateAxis(world, pos); if (world.isClientSide) - return validAxis ? ActionResultType.SUCCESS : ActionResultType.FAIL; + return validAxis ? InteractionResult.SUCCESS : InteractionResult.FAIL; - CompoundNBT tag = context.getItemInHand() + CompoundTag 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")); + firstPulley = NbtUtils.readBlockPos(tag.getCompound("FirstPulley")); if (!validateAxis(world, firstPulley) || !firstPulley.closerThan(pos, maxLength() * 2)) { tag.remove("FirstPulley"); context.getItemInHand() @@ -87,12 +89,12 @@ public class BeltConnectorItem extends BlockItem { } if (!validAxis || playerEntity == null) - return ActionResultType.FAIL; + return InteractionResult.FAIL; if (tag.contains("FirstPulley")) { if (!canConnect(world, firstPulley, pos)) - return ActionResultType.FAIL; + return InteractionResult.FAIL; if (firstPulley != null && !firstPulley.equals(pos)) { createBelts(world, firstPulley, pos); @@ -109,20 +111,20 @@ public class BeltConnectorItem extends BlockItem { playerEntity.getCooldowns() .addCooldown(this, 5); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - tag.put("FirstPulley", NBTUtil.writeBlockPos(pos)); + tag.put("FirstPulley", NbtUtils.writeBlockPos(pos)); context.getItemInHand() .setTag(tag); playerEntity.getCooldowns() .addCooldown(this, 5); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - public static void createBelts(World world, BlockPos start, BlockPos end) { + public static void createBelts(Level world, BlockPos start, BlockPos end) { world.playSound(null, new BlockPos(VecHelper.getCenterOf(start.offset(end)) - .scale(.5f)), SoundEvents.WOOL_PLACE, SoundCategory.BLOCKS, 0.5F, 1F); + .scale(.5f)), SoundEvents.WOOL_PLACE, SoundSource.BLOCKS, 0.5F, 1F); BeltSlope slope = getSlopeBetween(start, end); Direction facing = getFacingFromTo(start, end); @@ -198,7 +200,7 @@ public class BeltConnectorItem extends BlockItem { return positions; } - public static boolean canConnect(World world, BlockPos first, BlockPos second) { + public static boolean canConnect(Level world, BlockPos first, BlockPos second) { if (!world.isAreaLoaded(first, 1)) return false; if (!world.isAreaLoaded(second, 1)) @@ -226,8 +228,8 @@ public class BeltConnectorItem extends BlockItem { if (shaftAxis == Axis.Y && x != 0 && z != 0) return false; - TileEntity tileEntity = world.getBlockEntity(first); - TileEntity tileEntity2 = world.getBlockEntity(second); + BlockEntity tileEntity = world.getBlockEntity(first); + BlockEntity tileEntity2 = world.getBlockEntity(second); if (!(tileEntity instanceof KineticTileEntity)) return false; @@ -259,7 +261,7 @@ public class BeltConnectorItem extends BlockItem { return AllConfigs.SERVER.kinetics.maxBeltLength.get(); } - public static boolean validateAxis(World world, BlockPos pos) { + public static boolean validateAxis(Level world, BlockPos pos) { if (!world.isAreaLoaded(pos, 1)) return false; if (!ShaftBlock.isShaft(world.getBlockState(pos))) 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 8399a5788..f8065c99b 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 @@ -4,13 +4,13 @@ import com.simibubi.create.content.contraptions.components.crusher.CrushingWheel import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelControllerTileEntity; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import net.minecraftforge.items.ItemHandlerHelper; public class BeltCrusherInteractionHandler { @@ -21,13 +21,13 @@ public class BeltCrusherInteractionHandler { boolean beltMovementPositive = beltInventory.beltMovementPositive; int firstUpcomingSegment = (int) Math.floor(currentItem.beltPosition); int step = beltMovementPositive ? 1 : -1; - firstUpcomingSegment = MathHelper.clamp(firstUpcomingSegment, 0, beltInventory.belt.beltLength - 1); + firstUpcomingSegment = Mth.clamp(firstUpcomingSegment, 0, beltInventory.belt.beltLength - 1); for (int segment = firstUpcomingSegment; beltMovementPositive ? segment <= nextOffset : segment + 1 >= nextOffset; segment += step) { BlockPos crusherPos = BeltHelper.getPositionForOffset(beltInventory.belt, segment) .above(); - World world = beltInventory.belt.getLevel(); + Level world = beltInventory.belt.getLevel(); BlockState crusherState = world.getBlockState(crusherPos); if (!(crusherState.getBlock() instanceof CrushingWheelControllerBlock)) continue; @@ -46,7 +46,7 @@ public class BeltCrusherInteractionHandler { return false; currentItem.beltPosition = crusherEntry; - TileEntity te = world.getBlockEntity(crusherPos); + BlockEntity 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 b2c504191..eb5736792 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 @@ -7,13 +7,13 @@ import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import net.minecraftforge.items.ItemHandlerHelper; public class BeltFunnelInteractionHandler { @@ -23,13 +23,13 @@ public class BeltFunnelInteractionHandler { boolean beltMovementPositive = beltInventory.beltMovementPositive; int firstUpcomingSegment = (int) Math.floor(currentItem.beltPosition); int step = beltMovementPositive ? 1 : -1; - firstUpcomingSegment = MathHelper.clamp(firstUpcomingSegment, 0, beltInventory.belt.beltLength - 1); + firstUpcomingSegment = Mth.clamp(firstUpcomingSegment, 0, beltInventory.belt.beltLength - 1); for (int segment = firstUpcomingSegment; beltMovementPositive ? segment <= nextOffset : segment + 1 >= nextOffset; segment += step) { BlockPos funnelPos = BeltHelper.getPositionForOffset(beltInventory.belt, segment) .above(); - World world = beltInventory.belt.getLevel(); + Level world = beltInventory.belt.getLevel(); BlockState funnelState = world.getBlockState(funnelPos); if (!(funnelState.getBlock() instanceof BeltFunnelBlock)) continue; @@ -58,7 +58,7 @@ public class BeltFunnelInteractionHandler { else continue; - TileEntity te = world.getBlockEntity(funnelPos); + BlockEntity 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 a7e684e09..2a869ac6c 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 @@ -21,14 +21,14 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.ServerSpeedProvider; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.Constants.NBT; public class BeltInventory { @@ -81,7 +81,7 @@ public class BeltInventory { boolean horizontal = belt.getBlockState() .getValue(BeltBlock.SLOPE) == BeltSlope.HORIZONTAL; float spacing = 1; - World world = belt.getLevel(); + Level world = belt.getLevel(); boolean onClient = world.isClientSide && !belt.isVirtual(); // resolve ending only when items will reach it this tick @@ -296,7 +296,7 @@ public class BeltInventory { } private Ending resolveEnding() { - World world = belt.getLevel(); + Level world = belt.getLevel(); BlockPos nextPosition = BeltHelper.getPositionForOffset(belt, beltMovementPositive ? belt.beltLength : -1); // if (AllBlocks.BRASS_BELT_FUNNEL.has(world.getBlockState(lastPosition.up()))) @@ -377,16 +377,16 @@ public class BeltInventory { return null; } - public void read(CompoundNBT nbt) { + public void read(CompoundTag nbt) { items.clear(); nbt.getList("Items", NBT.TAG_COMPOUND) - .forEach(inbt -> items.add(TransportedItemStack.read((CompoundNBT) inbt))); + .forEach(inbt -> items.add(TransportedItemStack.read((CompoundTag) inbt))); beltMovementPositive = nbt.getBoolean("PositiveOrder"); } - public CompoundNBT write() { - CompoundNBT nbt = new CompoundNBT(); - ListNBT itemsNBT = new ListNBT(); + public CompoundTag write() { + CompoundTag nbt = new CompoundTag(); + ListTag itemsNBT = new ListTag(); items.forEach(stack -> itemsNBT.add(stack.serializeNBT())); nbt.put("Items", itemsNBT); nbt.putBoolean("PositiveOrder", beltMovementPositive); @@ -395,9 +395,9 @@ public class BeltInventory { public void eject(TransportedItemStack stack) { ItemStack ejected = stack.stack; - Vector3d outPos = BeltHelper.getVectorForOffset(belt, stack.beltPosition); + Vec3 outPos = BeltHelper.getVectorForOffset(belt, stack.beltPosition); float movementSpeed = Math.max(Math.abs(belt.getBeltMovementSpeed()), 1 / 8f); - Vector3d outMotion = Vector3d.atLowerCornerOf(belt.getBeltChainDirection()).scale(movementSpeed) + Vec3 outMotion = Vec3.atLowerCornerOf(belt.getBeltChainDirection()).scale(movementSpeed) .add(0, 1 / 8f, 0); outPos = outPos.add(outMotion.normalize().scale(0.001)); ItemEntity entity = new ItemEntity(belt.getLevel(), outPos.x, outPos.y + 6 / 16f, outPos.z, ejected); 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 6983ce99b..102062a03 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 @@ -1,34 +1,35 @@ package com.simibubi.create.content.contraptions.relays.belt.transport; import static net.minecraft.entity.MoverType.SELF; -import static net.minecraft.util.Direction.AxisDirection.NEGATIVE; +import staticnet.minecraft.world.entity.MoverTypeAxisDirection.NEGATIVE; import static net.minecraft.util.Direction.AxisDirection.POSITIVE; -import java.util.List; - -import com.simibubi.create.AllBlocks; +import javanet.minecraft.core.Direction.AxisDirectionAllBlocks; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltPart; import com.simibubi.create.content.contraptions.relays.belt.BeltSlope; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.HangingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Effects; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.decoration.HangingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; + +import com.simibubi.create.AllBlocks; +import java.util.List; public class BeltMovementHandler { @@ -60,16 +61,16 @@ public class BeltMovementHandler { public static boolean canBeTransported(Entity entity) { if (!entity.isAlive()) return false; - if (entity instanceof PlayerEntity && ((PlayerEntity) entity).isShiftKeyDown()) + if (entity instanceof Player && ((Player) entity).isShiftKeyDown()) return false; return true; } public static void transportEntity(BeltTileEntity beltTe, Entity entityIn, TransportedEntityInfo info) { BlockPos pos = info.lastCollidedPos; - World world = beltTe.getLevel(); - TileEntity te = world.getBlockEntity(pos); - TileEntity tileEntityBelowPassenger = world.getBlockEntity(entityIn.blockPosition()); + Level world = beltTe.getLevel(); + BlockEntity te = world.getBlockEntity(pos); + BlockEntity tileEntityBelowPassenger = world.getBlockEntity(entityIn.blockPosition()); BlockState blockState = info.lastCollidedState; Direction movementFacing = Direction.fromAxisAndDirection(blockState.getValue(BlockStateProperties.HORIZONTAL_FACING) @@ -94,9 +95,9 @@ public class BeltMovementHandler { return; // Lock entities in place - boolean isPlayer = entityIn instanceof PlayerEntity; + boolean isPlayer = entityIn instanceof Player; if (entityIn instanceof LivingEntity && !isPlayer) - ((LivingEntity) entityIn).addEffect(new EffectInstance(Effects.MOVEMENT_SLOWDOWN, 10, 1, false, false)); + ((LivingEntity) entityIn).addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 10, 1, false, false)); final Direction beltFacing = blockState.getValue(BlockStateProperties.HORIZONTAL_FACING); final BeltSlope slope = blockState.getValue(BeltBlock.SLOPE); @@ -104,10 +105,10 @@ public class BeltMovementHandler { float movementSpeed = beltTe.getBeltMovementSpeed(); final Direction movementDirection = Direction.get(axis == Axis.X ? NEGATIVE : POSITIVE, axis); - Vector3i centeringDirection = Direction.get(POSITIVE, beltFacing.getClockWise() + Vec3i centeringDirection = Direction.get(POSITIVE, beltFacing.getClockWise() .getAxis()) .getNormal(); - Vector3d movement = Vector3d.atLowerCornerOf(movementDirection.getNormal()) + Vec3 movement = Vec3.atLowerCornerOf(movementDirection.getNormal()) .scale(movementSpeed); double diffCenter = @@ -136,7 +137,7 @@ public class BeltMovementHandler { if (movingDown) movement = movement.add(0, -Math.abs(axis.choose(movement.x, movement.y, movement.z)), 0); - Vector3d centering = Vector3d.atLowerCornerOf(centeringDirection).scale(diffCenter * Math.min(Math.abs(movementSpeed), .1f) * 4); + Vec3 centering = Vec3.atLowerCornerOf(centeringDirection).scale(diffCenter * Math.min(Math.abs(movementSpeed), .1f) * 4); if (!(entityIn instanceof LivingEntity) || ((LivingEntity) entityIn).zza == 0 && ((LivingEntity) entityIn).xxa == 0) @@ -148,10 +149,10 @@ public class BeltMovementHandler { // Entity Collisions if (Math.abs(movementSpeed) < .5f) { - Vector3d checkDistance = movement.normalize() + Vec3 checkDistance = movement.normalize() .scale(0.5); - AxisAlignedBB bb = entityIn.getBoundingBox(); - AxisAlignedBB checkBB = new AxisAlignedBB(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); + AABB bb = entityIn.getBoundingBox(); + AABB checkBB = new AABB(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); checkBB = checkBB.move(checkDistance) .inflate(-Math.abs(checkDistance.x), -Math.abs(checkDistance.y), -Math.abs(checkDistance.z)); List list = world.getEntities(entityIn, checkBB); @@ -168,7 +169,7 @@ public class BeltMovementHandler { if (movingUp) { float minVelocity = .13f; float yMovement = (float) -(Math.max(Math.abs(movement.y), minVelocity)); - entityIn.move(SELF, new Vector3d(0, yMovement, 0)); + entityIn.move(SELF, new Vec3(0, yMovement, 0)); entityIn.move(SELF, movement.multiply(1, 0, 1)); } else if (movingDown) { entityIn.move(SELF, movement.multiply(1, 0, 1)); 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 4dee31a2e..43f4b10f8 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 @@ -13,12 +13,12 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.items.ItemHandlerHelper; public class BeltTunnelInteractionHandler { @@ -40,7 +40,7 @@ public class BeltTunnelInteractionHandler { return true; } - World world = beltInventory.belt.getLevel(); + Level world = beltInventory.belt.getLevel(); boolean onServer = !world.isClientSide || beltInventory.belt.isVirtual(); boolean removed = false; BeltTunnelTileEntity nextTunnel = getTunnelOnSegment(beltInventory, upcomingSegment); @@ -115,7 +115,7 @@ public class BeltTunnelInteractionHandler { .getBlockState(pos) .getBlock() instanceof BrassTunnelBlock)) return false; - TileEntity te = belt.getLevel() + BlockEntity te = belt.getLevel() .getBlockEntity(pos); if (te == null || !(te instanceof BrassTunnelTileEntity)) return false; @@ -138,11 +138,11 @@ public class BeltTunnelInteractionHandler { return getTunnelOnPosition(belt.getLevel(), BeltHelper.getPositionForOffset(belt, offset)); } - public static BeltTunnelTileEntity getTunnelOnPosition(World world, BlockPos pos) { + public static BeltTunnelTileEntity getTunnelOnPosition(Level world, BlockPos pos) { pos = pos.above(); if (!(world.getBlockState(pos).getBlock() instanceof BeltTunnelBlock)) return null; - TileEntity te = world.getBlockEntity(pos); + BlockEntity 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 c29866810..b356d04eb 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 @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.relays.belt.transport; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; public class ItemHandlerBeltSegment implements IItemHandler { 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 522d43fb2..c88d3a0f1 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 @@ -5,9 +5,9 @@ import java.util.Random; import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; public class TransportedItemStack implements Comparable { @@ -64,8 +64,8 @@ public class TransportedItemStack implements Comparable { return copy; } - public CompoundNBT serializeNBT() { - CompoundNBT nbt = new CompoundNBT(); + public CompoundTag serializeNBT() { + CompoundTag nbt = new CompoundTag(); nbt.put("Item", stack.serializeNBT()); nbt.putFloat("Pos", beltPosition); nbt.putFloat("PrevPos", prevBeltPosition); @@ -81,7 +81,7 @@ public class TransportedItemStack implements Comparable { return nbt; } - public static TransportedItemStack read(CompoundNBT nbt) { + public static TransportedItemStack read(CompoundTag nbt) { TransportedItemStack stack = new TransportedItemStack(ItemStack.of(nbt.getCompound("Item"))); stack.beltPosition = nbt.getFloat("Pos"); stack.prevBeltPosition = nbt.getFloat("PrevPos"); 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 992bb5a84..2688ae463 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 @@ -7,31 +7,33 @@ import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.content.contraptions.wrench.IWrenchableWithBracket; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.IWaterLoggable; -import net.minecraft.block.material.PushReaction; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock - implements IWaterLoggable, IWrenchableWithBracket { + implements SimpleWaterloggedBlock, IWrenchableWithBracket { public AbstractShaftBlock(Properties properties) { super(properties); @@ -39,7 +41,7 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onWrenched(BlockState state, UseOnContext context) { return IWrenchableWithBracket.super.onWrenched(state, context); } @@ -49,13 +51,13 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.SIMPLE_KINETIC.create(); } @Override @SuppressWarnings("deprecation") - public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { if (state != newState && !isMoving) removeBracket(world, pos, true).ifPresent(stack -> Block.popResource(world, pos, stack)); super.onRemove(state, world, pos, newState, isMoving); @@ -64,7 +66,7 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock // IRotate: @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.getValue(AXIS); } @@ -87,7 +89,7 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock @Override public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, - IWorld world, BlockPos pos, BlockPos neighbourPos) { + LevelAccessor world, BlockPos pos, BlockPos neighbourPos) { if (state.getValue(BlockStateProperties.WATERLOGGED)) { world.getLiquidTicks() .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); @@ -96,7 +98,7 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { FluidState ifluidstate = context.getLevel() .getFluidState(context.getClickedPos()); return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, @@ -104,7 +106,7 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock } @Override - public Optional removeBracket(IBlockReader world, BlockPos pos, boolean inOnReplacedContext) { + public Optional removeBracket(BlockGetter world, BlockPos pos, boolean inOnReplacedContext) { BracketedTileEntityBehaviour behaviour = TileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE); if (behaviour == null) return Optional.empty(); @@ -116,7 +118,7 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 e4a432b7f..39dcc0386 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 @@ -7,28 +7,28 @@ import java.util.Random; import com.jozufozu.flywheel.util.VirtualEmptyModelData; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.BakedModelWrapper; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelProperty; -public class BracketedKineticBlockModel extends BakedModelWrapper { +public class BracketedKineticBlockModel extends BakedModelWrapper { private static final ModelProperty BRACKET_PROPERTY = new ModelProperty<>(); - public BracketedKineticBlockModel(IBakedModel template) { + public BracketedKineticBlockModel(BakedModel template) { super(template); } @Override - public IModelData getModelData(IBlockDisplayReader world, BlockPos pos, BlockState state, IModelData tileData) { + public IModelData getModelData(BlockAndTintGetter world, BlockPos pos, BlockState state, IModelData tileData) { if (tileData == VirtualEmptyModelData.INSTANCE) return tileData; BracketedModelData data = new BracketedModelData(); @@ -56,14 +56,14 @@ public class BracketedKineticBlockModel extends BakedModelWrapper { private void addQuads(List quads, BlockState state, Direction side, Random rand, IModelData data, BracketedModelData pipeData) { - IBakedModel bracket = pipeData.getBracket(); + BakedModel bracket = pipeData.getBracket(); if (bracket == null) return; quads.addAll(bracket.getQuads(state, side, rand, data)); } private class BracketedModelData { - IBakedModel bracket; + BakedModel bracket; public void putBracket(BlockState state) { this.bracket = Minecraft.getInstance() @@ -71,7 +71,7 @@ public class BracketedKineticBlockModel extends BakedModelWrapper { .getBlockModel(state); } - public IBakedModel getBracket() { + public BakedModel getBracket() { return bracket; } 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 1e677317c..c46558fe9 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 @@ -12,13 +12,13 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.player.Player; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.Level; public class BracketedTileEntityBehaviour extends TileEntityBehaviour { @@ -56,14 +56,14 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { tileEntity.notifyUpdate(); } - public void triggerAdvancements(World world, PlayerEntity player, BlockState state) { + public void triggerAdvancements(Level world, Player player, BlockState state) { if (trigger == null) return; AllTriggers.triggerFor(trigger.apply(state), player); } public void removeBracket(boolean inOnReplacedContext) { - World world = getWorld(); + Level world = getWorld(); if (!world.isClientSide) world.levelEvent(2001, getPos(), Block.getId(getBracket())); this.bracket = Optional.empty(); @@ -93,8 +93,8 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { } @Override - public void write(CompoundNBT nbt, boolean clientPacket) { - bracket.ifPresent(p -> nbt.put("Bracket", NBTUtil.writeBlockState(p))); + public void write(CompoundTag nbt, boolean clientPacket) { + bracket.ifPresent(p -> nbt.put("Bracket", NbtUtils.writeBlockState(p))); if (clientPacket && reRender) { NBTHelper.putMarker(nbt, "Redraw"); reRender = false; @@ -103,10 +103,10 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { } @Override - public void read(CompoundNBT nbt, boolean clientPacket) { + public void read(CompoundTag nbt, boolean clientPacket) { bracket = Optional.empty(); if (nbt.contains("Bracket")) - bracket = Optional.of(NBTUtil.readBlockState(nbt.getCompound("Bracket"))); + bracket = Optional.of(NbtUtils.readBlockState(nbt.getCompound("Bracket"))); if (clientPacket && nbt.contains("Redraw")) 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 b22bb9457..d9791f27b 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 @@ -9,19 +9,21 @@ import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerB import com.simibubi.create.foundation.utility.Iterate; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -53,16 +55,16 @@ public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel { } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return (isLarge ? AllShapes.LARGE_GEAR : AllShapes.SMALL_GEAR).get(state.getValue(AXIS)); } @Override - public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader 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) { + public static boolean isValidCogwheelPosition(boolean large, LevelReader worldIn, BlockPos pos, Axis cogAxis) { for (Direction facing : Iterate.directions) { if (facing.getAxis() == cogAxis) continue; @@ -78,11 +80,11 @@ public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel { return true; } - protected Axis getAxisForPlacement(BlockItemUseContext context) { + protected Axis getAxisForPlacement(BlockPlaceContext context) { if (context.getPlayer() != null && context.getPlayer().isShiftKeyDown()) return context.getClickedFace().getAxis(); - World world = context.getLevel(); + Level world = context.getLevel(); BlockState stateBelow = world.getBlockState(context.getClickedPos().below()); if (AllBlocks.ROTATION_SPEED_CONTROLLER.has(stateBelow) && isLargeCog()) @@ -100,7 +102,7 @@ public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { boolean shouldWaterlog = context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER; return this.defaultBlockState() .setValue(AXIS, getAxisForPlacement(context)) 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 23b34992a..7e7a7d884 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 @@ -15,19 +15,21 @@ import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.placement.PlacementOffset; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.Level; + +import net.minecraft.world.item.Item.Properties; public class CogwheelBlockItem extends BlockItem { @@ -45,14 +47,14 @@ public class CogwheelBlockItem extends BlockItem { } @Override - public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { - World world = context.getLevel(); + public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) { + Level 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.getClickLocation(), context.getClickedFace(), pos, true); + Player player = context.getPlayer(); + BlockHitResult ray = new BlockHitResult(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); } @@ -70,12 +72,12 @@ public class CogwheelBlockItem extends BlockItem { @Override // Trigger cogwheel criterion - protected boolean placeBlock(BlockItemUseContext context, BlockState state) { + protected boolean placeBlock(BlockPlaceContext context, BlockState state) { triggerShiftingGearsAdvancement(context.getLevel(), context.getClickedPos(), state, context.getPlayer()); return super.placeBlock(context, state); } - protected void triggerShiftingGearsAdvancement(World world, BlockPos pos, BlockState state, PlayerEntity player) { + protected void triggerShiftingGearsAdvancement(Level world, BlockPos pos, BlockState state, Player player) { if (world.isClientSide || player == null) return; @@ -117,7 +119,7 @@ public class CogwheelBlockItem extends BlockItem { } @Override - public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { + public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) { if (hitOnShaft(state, ray)) return PlacementOffset.fail(); @@ -156,7 +158,7 @@ public class CogwheelBlockItem extends BlockItem { } @Override - public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { + public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) { if (hitOnShaft(state, ray)) return PlacementOffset.fail(); @@ -196,7 +198,7 @@ public class CogwheelBlockItem extends BlockItem { } @Override - public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { + public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) { // diagonal gears of different size Direction closest = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), state.getValue(AXIS)) .get(0); @@ -220,7 +222,7 @@ public class CogwheelBlockItem extends BlockItem { return PlacementOffset.fail(); } - protected boolean hitOnShaft(BlockState state, BlockRayTraceResult ray) { + protected boolean hitOnShaft(BlockState state, BlockHitResult ray) { return AllShapes.SIX_VOXEL_POLE.get(state.getValue(AXIS)) .bounds() .inflate(0.001) @@ -244,7 +246,7 @@ public class CogwheelBlockItem extends BlockItem { } @Override - public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { + public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) { Direction face = ray.getDirection(); Axis newAxis; @@ -297,7 +299,7 @@ public class CogwheelBlockItem extends BlockItem { } @Override - public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { + public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) { Direction face = ray.getDirection(); Axis newAxis; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ICogWheel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ICogWheel.java index 079987ad8..725aa84c0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ICogWheel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ICogWheel.java @@ -2,11 +2,11 @@ package com.simibubi.create.content.contraptions.relays.elementary; import com.simibubi.create.content.contraptions.base.IRotate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; public interface ICogWheel extends IRotate { 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 c00d1a77f..f4286c701 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 @@ -12,19 +12,21 @@ import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.placement.util.PoleHelper; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class ShaftBlock extends AbstractShaftBlock { @@ -39,7 +41,7 @@ public class ShaftBlock extends AbstractShaftBlock { } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.SIX_VOXEL_POLE.get(state.getValue(AXIS)); } @@ -54,10 +56,10 @@ public class ShaftBlock extends AbstractShaftBlock { } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult ray) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult ray) { if (player.isShiftKeyDown() || !player.mayBuild()) - return ActionResultType.PASS; + return InteractionResult.PASS; ItemStack heldItem = player.getItemInHand(hand); for (EncasedShaftBlock encasedShaft : new EncasedShaftBlock[] { AllBlocks.ANDESITE_ENCASED_SHAFT.get(), @@ -68,19 +70,19 @@ public class ShaftBlock extends AbstractShaftBlock { continue; if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; AllTriggers.triggerFor(AllTriggers.CASING_SHAFT, player); KineticTileEntity.switchToBlockState(world, pos, encasedShaft.defaultBlockState() .setValue(AXIS, state.getValue(AXIS))); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } 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); - return ActionResultType.PASS; + return InteractionResult.PASS; } @MethodsReturnNonnullByDefault 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 4545e3f4a..49f12b8b5 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 @@ -7,14 +7,14 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; public class SimpleKineticTileEntity extends KineticTileEntity { - public SimpleKineticTileEntity(TileEntityType type) { + public SimpleKineticTileEntity(BlockEntityType type) { super(type); } @@ -26,8 +26,8 @@ public class SimpleKineticTileEntity extends KineticTileEntity { } @Override - public AxisAlignedBB makeRenderBoundingBox() { - return new AxisAlignedBB(worldPosition).inflate(1); + public AABB makeRenderBoundingBox() { + return new AABB(worldPosition).inflate(1); } @Override 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 2dcbf534f..46b51d9f2 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 @@ -5,14 +5,16 @@ import javax.annotation.Nullable; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.PushReaction; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.StateContainer; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelReader; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @MethodsReturnNonnullByDefault public abstract class AbstractEncasedShaftBlock extends RotatedPillarKineticBlock { @@ -21,12 +23,12 @@ public abstract class AbstractEncasedShaftBlock extends RotatedPillarKineticBloc } @Override - protected void createBlockStateDefinition(StateContainer.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); } @Override - public boolean shouldCheckWeakPower(BlockState state, IWorldReader world, BlockPos pos, Direction side) { + public boolean shouldCheckWeakPower(BlockState state, LevelReader world, BlockPos pos, Direction side) { return false; } @@ -36,7 +38,7 @@ public abstract class AbstractEncasedShaftBlock extends RotatedPillarKineticBloc } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { if (context.getPlayer() != null && context.getPlayer() .isShiftKeyDown()) return super.getStateForPlacement(context); @@ -47,7 +49,7 @@ public abstract class AbstractEncasedShaftBlock extends RotatedPillarKineticBloc } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == 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 54b44f711..ef46ab58d 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 @@ -3,16 +3,18 @@ package com.simibubi.create.content.contraptions.relays.encased; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class AdjustablePulleyBlock extends EncasedBeltBlock implements ITE { @@ -29,12 +31,12 @@ public class AdjustablePulleyBlock extends EncasedBeltBlock implements ITE type) { + public AdjustablePulleyTileEntity(BlockEntityType type) { super(type); signal = 0; setLazyTickRate(40); } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("Signal", signal); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { signal = compound.getInt("Signal"); super.fromTag(state, compound, clientPacket); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/CasingConnectivity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/CasingConnectivity.java index 936b624d4..de06e9bd6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/CasingConnectivity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/CasingConnectivity.java @@ -6,9 +6,9 @@ import java.util.function.BiPredicate; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; public class CasingConnectivity { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ClutchBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ClutchBlock.java index f0beb78ac..8a55ae6f4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ClutchBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ClutchBlock.java @@ -2,12 +2,14 @@ package com.simibubi.create.content.contraptions.relays.encased; import com.simibubi.create.AllTileEntities; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class ClutchBlock extends GearshiftBlock { @@ -16,12 +18,12 @@ public class ClutchBlock extends GearshiftBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.CLUTCH.create(); } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { if (worldIn.isClientSide) return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ClutchTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ClutchTileEntity.java index dfc0f9ba6..8d7e210be 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ClutchTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ClutchTileEntity.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.relays.encased; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; public class ClutchTileEntity extends SplitShaftTileEntity { - public ClutchTileEntity(TileEntityType type) { + public ClutchTileEntity(BlockEntityType type) { super(type); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/DirectionalShaftHalvesTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/DirectionalShaftHalvesTileEntity.java index 499dd5eb5..586e7d3c9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/DirectionalShaftHalvesTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/DirectionalShaftHalvesTileEntity.java @@ -2,13 +2,13 @@ package com.simibubi.create.content.contraptions.relays.encased; import com.simibubi.create.content.contraptions.base.KineticTileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; public class DirectionalShaftHalvesTileEntity extends KineticTileEntity { - public DirectionalShaftHalvesTileEntity(TileEntityType typeIn) { + public DirectionalShaftHalvesTileEntity(BlockEntityType typeIn) { super(typeIn); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltBlock.java index eb7a15205..7d37b9112 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedBeltBlock.java @@ -7,25 +7,27 @@ import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.PushReaction; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.Property; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.util.StringRepresentable; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class EncasedBeltBlock extends RotatedPillarKineticBlock { @@ -39,7 +41,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { } @Override - public boolean shouldCheckWeakPower(BlockState state, IWorldReader world, BlockPos pos, Direction side) { + public boolean shouldCheckWeakPower(BlockState state, LevelReader world, BlockPos pos, Direction side) { return false; } @@ -54,7 +56,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { Axis placedAxis = context.getNearestLookingDirection() .getAxis(); Axis axis = context.getPlayer() != null && context.getPlayer() @@ -75,7 +77,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { } @Override - public BlockState updateShape(BlockState stateIn, Direction face, BlockState neighbour, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction face, BlockState neighbour, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { Part part = stateIn.getValue(PART); Axis axis = stateIn.getValue(AXIS); @@ -134,7 +136,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { } @Override - public BlockState updateAfterWrenched(BlockState newState, ItemUseContext context) { + public BlockState updateAfterWrenched(BlockState newState, UseOnContext context) { // Blocks.AIR.getDefaultState() // .updateNeighbors(context.getWorld(), context.getPos(), 1); Axis axis = newState.getValue(AXIS); @@ -155,7 +157,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.getValue(AXIS); } @@ -200,11 +202,11 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.ENCASED_SHAFT.create(); } - public enum Part implements IStringSerializable { + public enum Part implements StringRepresentable { START, MIDDLE, END, NONE; @Override 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 0e75bbb16..400cd2a6b 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 @@ -7,9 +7,9 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction.Axis; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction.Axis; import net.minecraftforge.client.model.generators.ModelFile; public class EncasedBeltGenerator extends SpecialBlockStateGen { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCTBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCTBehaviour.java index 566a6f150..8ecd65747 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCTBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCTBehaviour.java @@ -4,10 +4,10 @@ import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; public class EncasedCTBehaviour extends ConnectedTextureBehaviour { @@ -18,7 +18,7 @@ public class EncasedCTBehaviour extends ConnectedTextureBehaviour { } @Override - public boolean connectsTo(BlockState state, BlockState other, IBlockDisplayReader reader, BlockPos pos, BlockPos otherPos, + public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, Direction face) { if (isBeingBlocked(state, reader, pos, otherPos, face)) return false; 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 7ff8a064f..e4e46f9c6 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 @@ -8,12 +8,14 @@ import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement; import com.tterrag.registrate.util.entry.BlockEntry; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.level.BlockGetter; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpecialBlockItemRequirement { @@ -33,7 +35,7 @@ public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpe } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.ENCASED_SHAFT.create(); } @@ -42,16 +44,16 @@ public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpe } @Override - public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onSneakWrenched(BlockState state, UseOnContext context) { if (context.getLevel().isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; 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; + return InteractionResult.SUCCESS; } @Override - public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) { return ItemRequirement.of(AllBlocks.SHAFT.getDefaultState(), te); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftRenderer.java index 0c4541743..456df8a27 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftRenderer.java @@ -3,12 +3,12 @@ package com.simibubi.create.content.contraptions.relays.encased; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; public class EncasedShaftRenderer extends KineticTileEntityRenderer { - public EncasedShaftRenderer(TileEntityRendererDispatcher dispatcher) { + public EncasedShaftRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftTileEntity.java index a34417018..4e5c1e475 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftTileEntity.java @@ -2,11 +2,11 @@ package com.simibubi.create.content.contraptions.relays.encased; import com.simibubi.create.content.contraptions.base.KineticTileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.entity.BlockEntityType; public class EncasedShaftTileEntity extends KineticTileEntity { - public EncasedShaftTileEntity(TileEntityType type) { + public EncasedShaftTileEntity(BlockEntityType type) { super(type); } 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 c96a2cb6d..7adb22887 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 @@ -8,18 +8,20 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.gearbox.GearshiftTileEntity; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.TickPriority; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.TickPriority; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class GearshiftBlock extends AbstractEncasedShaftBlock implements ITE { @@ -31,7 +33,7 @@ public class GearshiftBlock extends AbstractEncasedShaftBlock implements ITE typeIn) { + public SplitShaftTileEntity(BlockEntityType typeIn) { super(typeIn); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeBlock.java index bc2b9b445..659391932 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeBlock.java @@ -11,30 +11,32 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.particles.RedstoneParticleData; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.util.StringRepresentable; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class GaugeBlock extends DirectionalAxisKineticBlock { public static final GaugeShaper GAUGE = GaugeShaper.make(); protected Type type; - public enum Type implements IStringSerializable { + public enum Type implements StringRepresentable { SPEED, STRESS; @Override @@ -57,7 +59,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { switch (type) { case SPEED: return AllTileEntities.SPEEDOMETER.create(); @@ -80,8 +82,8 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { */ @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { - World world = context.getLevel(); + public BlockState getStateForPlacement(BlockPlaceContext context) { + Level world = context.getLevel(); Direction face = context.getClickedFace(); BlockPos placedOnPos = context.getClickedPos() .relative(context.getClickedFace() @@ -112,17 +114,17 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { } @Override - protected Direction getFacingForPlacement(BlockItemUseContext context) { + protected Direction getFacingForPlacement(BlockPlaceContext context) { return context.getClickedFace(); } @Override - protected boolean getAxisAlignmentForPlacement(BlockItemUseContext context) { + protected boolean getAxisAlignmentForPlacement(BlockPlaceContext context) { return context.getHorizontalDirection() .getAxis() != Axis.X; } - public boolean shouldRenderHeadOnFace(World world, BlockPos pos, BlockState state, Direction face) { + public boolean shouldRenderHeadOnFace(Level world, BlockPos pos, BlockState state, Direction face) { if (face.getAxis() .isVertical()) return false; @@ -139,8 +141,8 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { } @Override - public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { - TileEntity te = worldIn.getBlockEntity(pos); + public void animateTick(BlockState stateIn, Level worldIn, BlockPos pos, Random rand) { + BlockEntity te = worldIn.getBlockEntity(pos); if (te == null || !(te instanceof GaugeTileEntity)) return; GaugeTileEntity gaugeTE = (GaugeTileEntity) te; @@ -152,24 +154,24 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { if (!shouldRenderHeadOnFace(worldIn, pos, stateIn, face)) continue; - Vector3d rgb = Color.vectorFromRGB(color); - Vector3d faceVec = Vector3d.atLowerCornerOf(face.getNormal()); + Vec3 rgb = Color.vectorFromRGB(color); + Vec3 faceVec = Vec3.atLowerCornerOf(face.getNormal()); Direction positiveFacing = Direction.get(AxisDirection.POSITIVE, face.getAxis()); - Vector3d positiveFaceVec = Vector3d.atLowerCornerOf(positiveFacing.getNormal()); + Vec3 positiveFaceVec = Vec3.atLowerCornerOf(positiveFacing.getNormal()); int particleCount = gaugeTE.dialTarget > 1 ? 4 : 1; if (particleCount == 1 && rand.nextFloat() > 1 / 4f) continue; for (int i = 0; i < particleCount; i++) { - Vector3d mul = VecHelper.offsetRandomly(Vector3d.ZERO, rand, .25f) - .multiply(new Vector3d(1, 1, 1).subtract(positiveFaceVec)) + Vec3 mul = VecHelper.offsetRandomly(Vec3.ZERO, rand, .25f) + .multiply(new Vec3(1, 1, 1).subtract(positiveFaceVec)) .normalize() .scale(.3f); - Vector3d offset = VecHelper.getCenterOf(pos) + Vec3 offset = VecHelper.getCenterOf(pos) .add(faceVec.scale(.55)) .add(mul); - worldIn.addParticle(new RedstoneParticleData((float) rgb.x, (float) rgb.y, (float) rgb.z, 1), offset.x, + worldIn.addParticle(new DustParticleOptions((float) rgb.x, (float) rgb.y, (float) rgb.z, 1), offset.x, offset.y, offset.z, mul.x, mul.y, mul.z); } @@ -178,7 +180,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return GAUGE.get(state.getValue(FACING), state.getValue(AXIS_ALONG_FIRST_COORDINATE)); } @@ -188,17 +190,17 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { } @Override - public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { - TileEntity te = worldIn.getBlockEntity(pos); + public int getAnalogOutputSignal(BlockState blockState, Level worldIn, BlockPos pos) { + BlockEntity te = worldIn.getBlockEntity(pos); if (te instanceof GaugeTileEntity) { GaugeTileEntity gaugeTileEntity = (GaugeTileEntity) te; - return MathHelper.ceil(MathHelper.clamp(gaugeTileEntity.dialTarget * 14, 0, 15)); + return Mth.ceil(Mth.clamp(gaugeTileEntity.dialTarget * 14, 0, 15)); } return 0; } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeGenerator.java index def2c0652..1d319e6e0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeGenerator.java @@ -4,8 +4,8 @@ import com.simibubi.create.foundation.data.DirectionalAxisBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; public class GaugeGenerator extends DirectionalAxisBlockStateGen { 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 9a452834e..6c79ffb71 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 @@ -8,7 +8,7 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; @@ -23,7 +23,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns protected final ArrayList faces; - protected MatrixStack ms; + protected PoseStack ms; protected GaugeInstance(MaterialManager dispatcher, KineticTileEntity tile) { super(dispatcher, tile); 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 ebd9bfad8..2f0c33d9b 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 @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.relays.gauge; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -12,32 +12,32 @@ import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; public class GaugeRenderer extends KineticTileEntityRenderer { protected GaugeBlock.Type type; - public static GaugeRenderer speed(TileEntityRendererDispatcher dispatcher) { + public static GaugeRenderer speed(BlockEntityRenderDispatcher dispatcher) { return new GaugeRenderer(dispatcher, Type.SPEED); } - public static GaugeRenderer stress(TileEntityRendererDispatcher dispatcher) { + public static GaugeRenderer stress(BlockEntityRenderDispatcher dispatcher) { return new GaugeRenderer(dispatcher, Type.STRESS); } - protected GaugeRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) { + protected GaugeRenderer(BlockEntityRenderDispatcher dispatcher, GaugeBlock.Type type) { super(dispatcher); this.type = type; } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; @@ -52,14 +52,14 @@ public class GaugeRenderer extends KineticTileEntityRenderer { SuperByteBuffer dialBuffer = PartialBufferer.get(AllBlockPartials.GAUGE_DIAL, gaugeState); float dialPivot = 5.75f / 16; - float progress = MathHelper.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState); + float progress = Mth.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState); for (Direction facing : Iterate.directions) { if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getLevel(), te.getBlockPos(), gaugeState, facing)) continue; - IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot) .rotate(Direction.EAST, (float) (Math.PI / 2 * -progress)) .translate(0, -dialPivot, -dialPivot) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeShaper.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeShaper.java index b07ded5bb..2fc6cfdc6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeShaper.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeShaper.java @@ -5,9 +5,9 @@ import java.util.Arrays; import com.simibubi.create.AllShapes; import com.simibubi.create.foundation.utility.VoxelShaper; -import net.minecraft.util.Direction; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; public class GaugeShaper extends VoxelShaper { @@ -16,7 +16,7 @@ public class GaugeShaper extends VoxelShaper { static GaugeShaper make(){ GaugeShaper shaper = new GaugeShaper(); shaper.axisFalse = forDirectional(AllShapes.GAUGE_SHAPE_UP, Direction.UP); - shaper.axisTrue = forDirectional(rotatedCopy(AllShapes.GAUGE_SHAPE_UP, new Vector3d(0, 90, 0)), Direction.UP); + shaper.axisTrue = forDirectional(rotatedCopy(AllShapes.GAUGE_SHAPE_UP, new Vec3(0, 90, 0)), Direction.UP); //shapes for X axis need to be swapped Arrays.asList(Direction.EAST, Direction.WEST).forEach(direction -> { VoxelShape mem = shaper.axisFalse.get(direction); 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 dfe96cf3c..dfca8823a 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 @@ -6,10 +6,10 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.network.chat.Component; public class GaugeTileEntity extends KineticTileEntity implements IHaveGoggleInformation { @@ -18,19 +18,19 @@ public class GaugeTileEntity extends KineticTileEntity implements IHaveGoggleInf public float prevDialState; public int color; - public GaugeTileEntity(TileEntityType tileEntityTypeIn) { + public GaugeTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putFloat("Value", dialTarget); compound.putInt("Color", color); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { dialTarget = compound.getFloat("Value"); color = compound.getInt("Color"); super.fromTag(state, compound, clientPacket); @@ -46,7 +46,7 @@ public class GaugeTileEntity extends KineticTileEntity implements IHaveGoggleInf } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { 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 d0c152453..a033ec72f 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 @@ -9,14 +9,14 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; public class SpeedGaugeTileEntity extends GaugeTileEntity { - public SpeedGaugeTileEntity(TileEntityType type) { + public SpeedGaugeTileEntity(BlockEntityType type) { super(type); } @@ -47,19 +47,19 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity { if (speed == 0) target = 0; else if (speed < medium) - target = MathHelper.lerp(speed / medium, 0, .45f); + target = Mth.lerp(speed / medium, 0, .45f); else if (speed < fast) - target = MathHelper.lerp((speed - medium) / (fast - medium), .45f, .75f); + target = Mth.lerp((speed - medium) / (fast - medium), .45f, .75f); else - target = MathHelper.lerp((speed - fast) / (max - fast), .75f, 1.125f); + target = Mth.lerp((speed - fast) / (max - fast), .75f, 1.125f); return target; } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { super.addToGoggleTooltip(tooltip, isPlayerSneaking); - tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.speedometer.title").withStyle(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.speedometer.title").withStyle(ChatFormatting.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 25cb21200..0e7785650 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 @@ -8,15 +8,15 @@ import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; public class StressGaugeTileEntity extends GaugeTileEntity { - public StressGaugeTileEntity(TileEntityType type) { + public StressGaugeTileEntity(BlockEntityType type) { super(type); } @@ -59,7 +59,7 @@ public class StressGaugeTileEntity extends GaugeTileEntity { } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { if (!StressImpact.isEnabled()) return false; @@ -68,30 +68,30 @@ public class StressGaugeTileEntity extends GaugeTileEntity { double capacity = getNetworkCapacity(); double stressFraction = getNetworkStress() / (capacity == 0 ? 1 : capacity); - tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.stressometer.title").withStyle(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.stressometer.title").withStyle(ChatFormatting.GRAY))); if (getTheoreticalSpeed() == 0) - tooltip.add(new StringTextComponent(spacing + ItemDescription.makeProgressBar(3, -1)).append(Lang.translate("gui.stressometer.no_rotation")).withStyle(TextFormatting.DARK_GRAY)); + tooltip.add(new TextComponent(spacing + ItemDescription.makeProgressBar(3, -1)).append(Lang.translate("gui.stressometer.no_rotation")).withStyle(ChatFormatting.DARK_GRAY)); // tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + ItemDescription.makeProgressBar(3, -1) // + Lang.translate("gui.stressometer.no_rotation"))); else { tooltip.add(componentSpacing.plainCopy().append(StressImpact.getFormattedStressText(stressFraction))); - tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.stressometer.capacity").withStyle(TextFormatting.GRAY))); + tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.stressometer.capacity").withStyle(ChatFormatting.GRAY))); double remainingCapacity = capacity - getNetworkStress(); - ITextComponent su = Lang.translate("generic.unit.stress"); - IFormattableTextComponent stressTooltip = componentSpacing.plainCopy() - .append(new StringTextComponent(" " + IHaveGoggleInformation.format(remainingCapacity)) + Component su = Lang.translate("generic.unit.stress"); + MutableComponent stressTooltip = componentSpacing.plainCopy() + .append(new TextComponent(" " + IHaveGoggleInformation.format(remainingCapacity)) .append(su.plainCopy()) .withStyle(StressImpact.of(stressFraction).getRelativeColor())); if (remainingCapacity != capacity) { stressTooltip - .append(new StringTextComponent(" / ").withStyle(TextFormatting.GRAY)) - .append(new StringTextComponent(IHaveGoggleInformation.format(capacity)) + .append(new TextComponent(" / ").withStyle(ChatFormatting.GRAY)) + .append(new TextComponent(IHaveGoggleInformation.format(capacity)) .append(su.plainCopy()) - .withStyle(TextFormatting.DARK_GRAY)); + .withStyle(ChatFormatting.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 83a2a74a9..2d17e8637 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 @@ -7,21 +7,23 @@ import com.simibubi.create.AllItems; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.LootContext.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.NonNullList; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class GearboxBlock extends RotatedPillarKineticBlock { @@ -30,7 +32,7 @@ public class GearboxBlock extends RotatedPillarKineticBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.GEARBOX.create(); } @@ -40,7 +42,7 @@ public class GearboxBlock extends RotatedPillarKineticBlock { } @Override - public void fillItemCategory(ItemGroup group, NonNullList items) { + public void fillItemCategory(CreativeModeTab group, NonNullList items) { super.fillItemCategory(group, items); items.add(AllItems.VERTICAL_GEARBOX.asStack()); } @@ -54,22 +56,22 @@ public class GearboxBlock extends RotatedPillarKineticBlock { } @Override - public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, - PlayerEntity player) { + public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, + Player player) { 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) { + public BlockState getStateForPlacement(BlockPlaceContext context) { return defaultBlockState().setValue(AXIS, Axis.Y); } // IRotate: @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() != 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 cfae9dc94..9dc01c46e 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 @@ -12,10 +12,10 @@ import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.LightType; +import net.minecraft.world.level.LightLayer; public class GearboxInstance extends KineticTileInstance { @@ -29,8 +29,8 @@ public class GearboxInstance extends KineticTileInstance { final Direction.Axis boxAxis = blockState.getValue(BlockStateProperties.AXIS); - int blockLight = world.getBrightness(LightType.BLOCK, pos); - int skyLight = world.getBrightness(LightType.SKY, pos); + int blockLight = world.getBrightness(LightLayer.BLOCK, pos); + int skyLight = world.getBrightness(LightLayer.SKY, pos); updateSourceFacing(); Material rotatingMaterial = getRotatingMaterial(); 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 2bd534af4..2403cbdd9 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 @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.relays.gearbox; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -10,22 +10,22 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; public class GearboxRenderer extends KineticTileEntityRenderer { - public GearboxRenderer(TileEntityRendererDispatcher dispatcher) { + public GearboxRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxTileEntity.java index add94d709..5a5b3f7d5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxTileEntity.java @@ -2,11 +2,11 @@ package com.simibubi.create.content.contraptions.relays.gearbox; import com.simibubi.create.content.contraptions.relays.encased.DirectionalShaftHalvesTileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.entity.BlockEntityType; public class GearboxTileEntity extends DirectionalShaftHalvesTileEntity { - public GearboxTileEntity(TileEntityType type) { + public GearboxTileEntity(BlockEntityType type) { super(type); } 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 2e4b6cf62..5ac30a8af 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 @@ -2,13 +2,13 @@ package com.simibubi.create.content.contraptions.relays.gearbox; import com.simibubi.create.content.contraptions.relays.encased.SplitShaftTileEntity; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; public class GearshiftTileEntity extends SplitShaftTileEntity { - public GearshiftTileEntity(TileEntityType type) { + public GearshiftTileEntity(BlockEntityType type) { super(type); } 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 23832729b..0a37313fb 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 @@ -6,19 +6,21 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.NonNullList; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; + +import net.minecraft.world.item.Item.Properties; public class VerticalGearboxItem extends BlockItem { @@ -27,7 +29,7 @@ public class VerticalGearboxItem extends BlockItem { } @Override - public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + public void fillItemCategory(CreativeModeTab p_150895_1_, NonNullList p_150895_2_) { } @Override @@ -40,7 +42,7 @@ public class VerticalGearboxItem extends BlockItem { } @Override - protected boolean updateCustomBlockEntityTag(BlockPos pos, World world, PlayerEntity player, ItemStack stack, BlockState state) { + protected boolean updateCustomBlockEntityTag(BlockPos pos, Level world, Player player, ItemStack stack, BlockState state) { Axis prefferedAxis = null; for (Direction side : Iterate.horizontalDirections) { BlockState blockState = world.getBlockState(pos.relative(side)); 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 7c6102815..a693942dc 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 @@ -12,29 +12,29 @@ import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.foundation.utility.DirectionHelper; import com.simibubi.create.foundation.utility.VoxelShaper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; public interface IWrenchable { - default ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getLevel(); + default InteractionResult onWrenched(BlockState state, UseOnContext context) { + Level world = context.getLevel(); BlockState rotated = getRotatedBlockState(state, context.getClickedFace()); if (!rotated.canSurvive(world, context.getClickedPos())) - return ActionResultType.PASS; + return InteractionResult.PASS; KineticTileEntity.switchToBlockState(world, context.getClickedPos(), updateAfterWrenched(rotated, context)); - TileEntity te = context.getLevel() + BlockEntity te = context.getLevel() .getBlockEntity(context.getClickedPos()); if (te != null) te.clearCache(); @@ -45,36 +45,36 @@ public interface IWrenchable { if (world.getBlockState(context.getClickedPos()) != state) playRotateSound(world, context.getClickedPos()); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - default BlockState updateAfterWrenched(BlockState newState, ItemUseContext context) { + default BlockState updateAfterWrenched(BlockState newState, UseOnContext context) { // return newState; return Block.updateFromNeighbourShapes(newState, context.getLevel(), context.getClickedPos()); } - default ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) { - World world = context.getLevel(); + default InteractionResult onSneakWrenched(BlockState state, UseOnContext context) { + Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); - PlayerEntity player = context.getPlayer(); - if (world instanceof ServerWorld) { + Player player = context.getPlayer(); + if (world instanceof ServerLevel) { if (player != null && !player.isCreative()) - Block.getDrops(state, (ServerWorld) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) + Block.getDrops(state, (ServerLevel) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) .forEach(itemStack -> { player.inventory.placeItemBackInInventory(world, itemStack); }); - state.spawnAfterBreak((ServerWorld) world, pos, ItemStack.EMPTY); + state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY); world.destroyBlock(pos, false); playRemoveSound(world, pos); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - default void playRemoveSound(World world, BlockPos pos) { + default void playRemoveSound(Level world, BlockPos pos) { AllSoundEvents.WRENCH_REMOVE.playOnServer(world, pos, 1, Create.RANDOM.nextFloat() * .5f + .5f); } - default void playRotateSound(World world, BlockPos pos) { + default void playRotateSound(Level world, BlockPos pos) { AllSoundEvents.WRENCH_ROTATE.playOnServer(world, pos, 1, Create.RANDOM.nextFloat() + .5f); } 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 9161d4309..1a5d751dd 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 @@ -5,36 +5,36 @@ import java.util.Optional; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.fluids.FluidPropagator; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; public interface IWrenchableWithBracket extends IWrenchable { - public Optional removeBracket(IBlockReader world, BlockPos pos, boolean inOnReplacedContext); + public Optional removeBracket(BlockGetter world, BlockPos pos, boolean inOnReplacedContext); @Override - default ActionResultType onWrenched(BlockState state, ItemUseContext context) { + default InteractionResult onWrenched(BlockState state, UseOnContext context) { if (tryRemoveBracket(context)) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; return IWrenchable.super.onWrenched(state, context); } - default boolean tryRemoveBracket(ItemUseContext context) { - World world = context.getLevel(); + default boolean tryRemoveBracket(UseOnContext context) { + Level 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(); + Player player = context.getPlayer(); if (!world.isClientSide && !player.isCreative()) player.inventory.placeItemBackInInventory(world, bracket.get()); if (!world.isClientSide && AllBlocks.FLUID_PIPE.has(blockState)) { 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 79131ad98..67cff9033 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 @@ -7,21 +7,23 @@ import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTags; import com.simibubi.create.Create; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.DamageSource; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.event.entity.player.AttackEntityEvent; +import net.minecraft.world.item.Item.Properties; + public class WrenchItem extends Item { public WrenchItem(Properties properties) { @@ -30,8 +32,8 @@ public class WrenchItem extends Item { @Nonnull @Override - public ActionResultType useOn(ItemUseContext context) { - PlayerEntity player = context.getPlayer(); + public InteractionResult useOn(UseOnContext context) { + Player player = context.getPlayer(); if (player == null || !player.mayBuild()) return super.useOn(context); @@ -55,33 +57,33 @@ public class WrenchItem extends Item { return AllTags.AllBlockTags.WRENCH_PICKUP.matches(state); } - private ActionResultType onItemUseOnOther(ItemUseContext context) { - PlayerEntity player = context.getPlayer(); - World world = context.getLevel(); + private InteractionResult onItemUseOnOther(UseOnContext context) { + Player player = context.getPlayer(); + Level world = context.getLevel(); BlockPos pos = context.getClickedPos(); BlockState state = world.getBlockState(pos); - if (!(world instanceof ServerWorld)) - return ActionResultType.SUCCESS; + if (!(world instanceof ServerLevel)) + return InteractionResult.SUCCESS; if (player != null && !player.isCreative()) - Block.getDrops(state, (ServerWorld) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) + Block.getDrops(state, (ServerLevel) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) .forEach(itemStack -> player.inventory.placeItemBackInInventory(world, itemStack)); - state.spawnAfterBreak((ServerWorld) world, pos, ItemStack.EMPTY); + state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY); world.destroyBlock(pos, false); AllSoundEvents.WRENCH_REMOVE.playOnServer(world, pos, 1, Create.RANDOM.nextFloat() * .5f + .5f); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } public static void wrenchInstaKillsMinecarts(AttackEntityEvent event) { Entity target = event.getTarget(); - if (!(target instanceof AbstractMinecartEntity)) + if (!(target instanceof AbstractMinecart)) return; - PlayerEntity player = event.getPlayer(); + Player player = event.getPlayer(); ItemStack heldItem = player.getMainHandItem(); if (!AllItems.WRENCH.isIn(heldItem)) return; if (player.isCreative()) return; - AbstractMinecartEntity minecart = (AbstractMinecartEntity) target; + AbstractMinecart minecart = (AbstractMinecart) target; 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 dbc677fd0..44997a660 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 @@ -1,22 +1,22 @@ package com.simibubi.create.content.contraptions.wrench; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueHandler; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.world.item.ItemStack; +import com.mojang.math.Vector3f; public class WrenchItemRenderer extends CustomRenderedItemModelRenderer { @Override - protected void render(ItemStack stack, WrenchModel model, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, - MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + protected void render(ItemStack stack, WrenchModel model, PartialItemModelRenderer renderer, ItemTransforms.TransformType transformType, + PoseStack ms, MultiBufferSource buffer, int light, int overlay) { renderer.render(model.getOriginalModel(), light); float xOffset = -1/16f; @@ -28,7 +28,7 @@ public class WrenchItemRenderer extends CustomRenderedItemModelRenderer use(World p_77659_1_, PlayerEntity p_77659_2_, Hand p_77659_3_) { + public InteractionResultHolder use(Level p_77659_1_, Player p_77659_2_, InteractionHand p_77659_3_) { p_77659_2_.startUsingItem(p_77659_3_); - return ActionResult.success(p_77659_2_.getItemInHand(p_77659_3_)); + return InteractionResultHolder.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 63b4d989f..67027a164 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundColor.java +++ b/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundColor.java @@ -4,11 +4,11 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.Mth; -public class ChromaticCompoundColor implements IItemColor { +public class ChromaticCompoundColor implements ItemColor { @Override public int getColor(ItemStack stack, int layer) { @@ -16,13 +16,13 @@ public class ChromaticCompoundColor implements IItemColor { float pt = AnimationTickHolder.getPartialTicks(); float progress = (float) ((mc.player.getViewYRot(pt)) / 180 * Math.PI) + (AnimationTickHolder.getRenderTime() / 10f); if (layer == 0) - return Color.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2); + return Color.mixColors(0x6e5773, 0x6B3074, ((float) Mth.sin(progress) + 1) / 2); if (layer == 1) return Color.mixColors(0xd45d79, 0x6e5773, - ((float) MathHelper.sin((float) (progress + Math.PI)) + 1) / 2); + ((float) Mth.sin((float) (progress + Math.PI)) + 1) / 2); if (layer == 2) return Color.mixColors(0xea9085, 0xd45d79, - ((float) MathHelper.sin((float) (progress * 1.5f + Math.PI)) + 1) / 2); + ((float) Mth.sin((float) (progress * 1.5f + Math.PI)) + 1) / 2); return 0; } } 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 698024c61..8ecfc1c7f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/ChromaticCompoundItem.java @@ -14,25 +14,27 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.BeaconTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceContext.BlockMode; -import net.minecraft.util.math.RayTraceContext.FluidMode; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.entity.BeaconBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.Heightmap; + +import net.minecraft.world.item.Item.Properties; public class ChromaticCompoundItem extends Item { @@ -73,18 +75,18 @@ public class ChromaticCompoundItem extends Item { public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { double y = entity.getY(); double yMotion = entity.getDeltaMovement().y; - World world = entity.level; - CompoundNBT data = entity.getPersistentData(); - CompoundNBT itemData = entity.getItem() + Level world = entity.level; + CompoundTag data = entity.getPersistentData(); + CompoundTag itemData = entity.getItem() .getOrCreateTag(); - Vector3d positionVec = entity.position(); + Vec3 positionVec = entity.position(); CRecipes config = AllConfigs.SERVER.recipes; if (world.isClientSide) { int light = itemData.getInt("CollectingLight"); if (random.nextInt(config.lightSourceCountForRefinedRadiance.get() + 20) < light) { - Vector3d start = VecHelper.offsetRandomly(positionVec, random, 3); - Vector3d motion = positionVec.subtract(start) + Vec3 start = VecHelper.offsetRandomly(positionVec, random, 3); + Vec3 motion = positionVec.subtract(start) .normalize() .scale(.2f); world.addParticle(ParticleTypes.END_ROD, start.x, start.y, start.z, motion.x, motion.y, motion.z); @@ -122,12 +124,12 @@ public class ChromaticCompoundItem extends Item { // Is inside beacon beam? boolean isOverBeacon = false; - int entityX = MathHelper.floor(entity.getX()); - int entityZ = MathHelper.floor(entity.getZ()); - int localWorldHeight = world.getHeight(Heightmap.Type.WORLD_SURFACE, entityX, entityZ); + int entityX = Mth.floor(entity.getX()); + int entityZ = Mth.floor(entity.getZ()); + int localWorldHeight = world.getHeight(Heightmap.Types.WORLD_SURFACE, entityX, entityZ); - BlockPos.Mutable testPos = - new BlockPos.Mutable(entityX, Math.min(MathHelper.floor(entity.getY()), localWorldHeight), entityZ); + BlockPos.MutableBlockPos testPos = + new BlockPos.MutableBlockPos(entityX, Math.min(Mth.floor(entity.getY()), localWorldHeight), entityZ); while (testPos.getY() > 0) { testPos.move(Direction.DOWN); @@ -135,12 +137,12 @@ public class ChromaticCompoundItem extends Item { if (state.getLightBlock(world, testPos) >= 15 && state.getBlock() != Blocks.BEDROCK) break; if (state.getBlock() == Blocks.BEACON) { - TileEntity te = world.getBlockEntity(testPos); + BlockEntity te = world.getBlockEntity(testPos); - if (!(te instanceof BeaconTileEntity)) + if (!(te instanceof BeaconBlockEntity)) break; - BeaconTileEntity bte = (BeaconTileEntity) te; + BeaconBlockEntity bte = (BeaconBlockEntity) te; if (bte.getLevels() != 0 && !bte.beamSections.isEmpty()) isOverBeacon = true; @@ -208,8 +210,8 @@ public class ChromaticCompoundItem extends Item { return false; } - public boolean checkLight(ItemStack stack, ItemEntity entity, World world, CompoundNBT itemData, - Vector3d positionVec, BlockPos randomOffset, BlockState state) { + public boolean checkLight(ItemStack stack, ItemEntity entity, Level world, CompoundTag itemData, + Vec3 positionVec, BlockPos randomOffset, BlockState state) { if (state.getLightValue(world, randomOffset) == 0) return false; if (state.getDestroySpeed(world, randomOffset) == -1) @@ -217,8 +219,8 @@ public class ChromaticCompoundItem extends Item { if (state.getBlock() == Blocks.BEACON) return false; - RayTraceContext context = new RayTraceContext(positionVec.add(new Vector3d(0, 0.5, 0)), - VecHelper.getCenterOf(randomOffset), BlockMode.COLLIDER, FluidMode.NONE, entity); + ClipContext context = new ClipContext(positionVec.add(new Vec3(0, 0.5, 0)), + VecHelper.getCenterOf(randomOffset), Block.COLLIDER, Fluid.NONE, entity); if (!randomOffset.equals(world.clip(context) .getBlockPos())) return false; 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..7d146d7e8 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/CombustibleItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/CombustibleItem.java @@ -1,7 +1,9 @@ package com.simibubi.create.content.curiosities; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +import net.minecraft.world.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 328164c20..7ae836e13 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java @@ -2,14 +2,16 @@ package com.simibubi.create.content.curiosities; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; + +import net.minecraft.world.item.Item.Properties; public class NoGravMagicalDohickyItem extends Item { @@ -19,21 +21,21 @@ public class NoGravMagicalDohickyItem extends Item { @Override public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { - World world = entity.level; - Vector3d pos = entity.position(); - CompoundNBT persistentData = entity.getPersistentData(); + Level world = entity.level; + Vec3 pos = entity.position(); + CompoundTag persistentData = entity.getPersistentData(); if (world.isClientSide) { if (world.random.nextFloat() < getIdleParticleChance(entity)) { - Vector3d ppos = VecHelper.offsetRandomly(pos, world.random, .5f); + Vec3 ppos = VecHelper.offsetRandomly(pos, world.random, .5f); world.addParticle(ParticleTypes.END_ROD, ppos.x, pos.y, ppos.z, 0, -.1f, 0); } if (entity.isSilent() && !persistentData.getBoolean("PlayEffects")) { - Vector3d basemotion = new Vector3d(0, 1, 0); + Vec3 basemotion = new Vec3(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.random, 1); + Vec3 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); } @@ -52,11 +54,11 @@ public class NoGravMagicalDohickyItem extends Item { } protected float getIdleParticleChance(ItemEntity entity) { - return MathHelper.clamp(entity.getItem() + return Mth.clamp(entity.getItem() .getCount() - 10, 5, 100) / 64f; } - protected void onCreated(ItemEntity entity, CompoundNBT persistentData) { + protected void onCreated(ItemEntity entity, CompoundTag persistentData) { entity.lifespan = 6000; persistentData.remove("JustCreated"); 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 c6aab3c8c..45f93b58e 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/RefinedRadianceItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/RefinedRadianceItem.java @@ -1,8 +1,10 @@ package com.simibubi.create.content.curiosities; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; + +import net.minecraft.world.item.Item.Properties; public class RefinedRadianceItem extends NoGravMagicalDohickyItem { @@ -16,7 +18,7 @@ public class RefinedRadianceItem extends NoGravMagicalDohickyItem { } @Override - protected void onCreated(ItemEntity entity, CompoundNBT persistentData) { + protected void onCreated(ItemEntity entity, CompoundTag persistentData) { super.onCreated(entity, persistentData); entity.setDeltaMovement(entity.getDeltaMovement() .add(0, .25f, 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 9f59e52c8..96bf72d5f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/ShadowSteelItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/ShadowSteelItem.java @@ -1,8 +1,10 @@ package com.simibubi.create.content.curiosities; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; + +import net.minecraft.world.item.Item.Properties; public class ShadowSteelItem extends NoGravMagicalDohickyItem { @@ -11,7 +13,7 @@ public class ShadowSteelItem extends NoGravMagicalDohickyItem { } @Override - protected void onCreated(ItemEntity entity, CompoundNBT persistentData) { + protected void onCreated(ItemEntity entity, CompoundTag persistentData) { super.onCreated(entity, persistentData); float yMotion = (entity.fallDistance + 3) / 50f; entity.setDeltaMovement(0, yMotion, 0); @@ -19,8 +21,8 @@ public class ShadowSteelItem extends NoGravMagicalDohickyItem { @Override protected float getIdleParticleChance(ItemEntity entity) { - return (float) (MathHelper.clamp(entity.getItem() - .getCount() - 10, MathHelper.clamp(entity.getDeltaMovement().y * 20, 5, 20), 100) / 64f); + return (float) (Mth.clamp(entity.getItem() + .getCount() - 10, Mth.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 dc4725be6..35b01c9be 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java @@ -2,16 +2,18 @@ package com.simibubi.create.content.curiosities; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationServerWorld; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.SaplingBlock; -import net.minecraft.item.BoneMealItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SaplingBlock; +import net.minecraft.world.item.BoneMealItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.item.Item.Properties; public class TreeFertilizerItem extends Item { @@ -20,7 +22,7 @@ public class TreeFertilizerItem extends Item { } @Override - public ActionResultType useOn(ItemUseContext context) { + public InteractionResult useOn(UseOnContext context) { BlockState state = context.getLevel() .getBlockState(context.getClickedPos()); Block block = state.getBlock(); @@ -28,11 +30,11 @@ public class TreeFertilizerItem extends Item { if (context.getLevel().isClientSide) { BoneMealItem.addGrowthParticles(context.getLevel(), context.getClickedPos(), 100); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } BlockPos saplingPos = context.getClickedPos(); - TreesDreamWorld world = new TreesDreamWorld((ServerWorld) context.getLevel(), saplingPos); + TreesDreamWorld world = new TreesDreamWorld((ServerLevel) context.getLevel(), saplingPos); for (BlockPos pos : BlockPos.betweenClosed(-1, 0, -1, 1, 0, 1)) { if (context.getLevel() @@ -69,7 +71,7 @@ public class TreeFertilizerItem extends Item { .isCreative()) context.getItemInHand() .shrink(1); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @@ -80,7 +82,7 @@ public class TreeFertilizerItem extends Item { private final BlockPos saplingPos; private final BlockState soil; - protected TreesDreamWorld(ServerWorld wrapped, BlockPos saplingPos) { + protected TreesDreamWorld(ServerLevel wrapped, BlockPos saplingPos) { super(wrapped); this.saplingPos = saplingPos; soil = wrapped.getBlockState(saplingPos.below()); 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 5129dbbdf..a1f557c5b 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 @@ -5,15 +5,15 @@ import java.util.function.Supplier; import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.IArmorMaterial; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.LazyValue; -import net.minecraft.util.SoundEvent; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorMaterial; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.util.LazyLoadedValue; +import net.minecraft.sounds.SoundEvent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public enum AllArmorMaterials implements IArmorMaterial { +public enum AllArmorMaterials implements ArmorMaterial { COPPER("copper", 7, new int[] { 1, 3, 4, 2 }, 25, AllSoundEvents.COPPER_ARMOR_EQUIP.getMainEvent(), 0.0F, 0.0F, () -> Ingredient.of(AllItems.COPPER_INGOT.get())) @@ -28,7 +28,7 @@ public enum AllArmorMaterials implements IArmorMaterial { private final SoundEvent soundEvent; private final float toughness; private final float knockbackResistance; - private final LazyValue repairMaterial; + private final LazyLoadedValue repairMaterial; private AllArmorMaterials(String p_i231593_3_, int p_i231593_4_, int[] p_i231593_5_, int p_i231593_6_, SoundEvent p_i231593_7_, float p_i231593_8_, float p_i231593_9_, Supplier p_i231593_10_) { @@ -39,14 +39,14 @@ public enum AllArmorMaterials implements IArmorMaterial { this.soundEvent = p_i231593_7_; this.toughness = p_i231593_8_; this.knockbackResistance = p_i231593_9_; - this.repairMaterial = new LazyValue<>(p_i231593_10_); + this.repairMaterial = new LazyLoadedValue<>(p_i231593_10_); } - public int getDurabilityForSlot(EquipmentSlotType p_200896_1_) { + public int getDurabilityForSlot(EquipmentSlot p_200896_1_) { return MAX_DAMAGE_ARRAY[p_200896_1_.getIndex()] * this.maxDamageFactor; } - public int getDefenseForSlot(EquipmentSlotType p_200902_1_) { + public int getDefenseForSlot(EquipmentSlot p_200902_1_) { return this.damageReductionAmountArray[p_200902_1_.getIndex()]; } 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 a53b0d477..635a023b2 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 @@ -5,13 +5,13 @@ import com.simibubi.create.AllItems; import com.simibubi.create.foundation.config.AllConfigs; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -29,12 +29,12 @@ public class BackTankUtil { } public static float getAir(ItemStack backtank) { - CompoundNBT tag = backtank.getOrCreateTag(); + CompoundTag tag = backtank.getOrCreateTag(); return Math.min(tag.getFloat("Air"), maxAir(backtank)); } public static void consumeAir(ItemStack backtank, float i) { - CompoundNBT tag = backtank.getOrCreateTag(); + CompoundTag tag = backtank.getOrCreateTag(); tag.putFloat("Air", Math.min(getAir(backtank) - i, maxAir(backtank))); backtank.setTag(tag); } @@ -55,7 +55,7 @@ public class BackTankUtil { public static boolean canAbsorbDamage(LivingEntity entity, int usesPerTank) { if (usesPerTank == 0) return true; - if (entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative()) + if (entity instanceof Player && ((Player) entity).isCreative()) return true; ItemStack backtank = get(entity); if (backtank.isEmpty()) @@ -73,12 +73,12 @@ public class BackTankUtil { public static int getRGBDurabilityForDisplay(ItemStack stack, int usesPerTank) { if (usesPerTank == 0) return 0; - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (player == null) return 0; ItemStack backtank = get(player); if (backtank.isEmpty() || !hasAirRemaining(backtank)) - return MathHelper.hsvToRgb( + return Mth.hsvToRgb( Math.max(0.0F, (float) (1.0F - getDurabilityForDisplay(stack, usesPerTank))) / 3.0F, 1.0F, 1.0F); return backtank.getItem() .getRGBDurabilityForDisplay(backtank); @@ -88,7 +88,7 @@ public class BackTankUtil { public static double getDurabilityForDisplay(ItemStack stack, int usesPerTank) { if (usesPerTank == 0) return 0; - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (player == null) return 0; ItemStack backtank = get(player); @@ -102,7 +102,7 @@ public class BackTankUtil { public static boolean showDurabilityBar(ItemStack stack, int usesPerTank) { if (usesPerTank == 0) return false; - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (player == null) return false; ItemStack backtank = get(player); 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..89d2b28a7 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 @@ -1,13 +1,15 @@ package com.simibubi.create.content.curiosities.armor; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentType; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; + +import net.minecraft.world.item.enchantment.Enchantment.Rarity; public class CapacityEnchantment extends Enchantment { - public CapacityEnchantment(Rarity p_i46731_1_, EnchantmentType p_i46731_2_, EquipmentSlotType[] p_i46731_3_) { + public CapacityEnchantment(Rarity p_i46731_1_, EnchantmentCategory p_i46731_2_, EquipmentSlot[] p_i46731_3_) { super(p_i46731_1_, p_i46731_2_, 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 d036b562e..2ba7dd45d 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 @@ -2,19 +2,21 @@ package com.simibubi.create.content.curiosities.armor; import com.simibubi.create.Create; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; + +import net.minecraft.world.item.Item.Properties; public class CopperArmorItem extends ArmorItem { public static final ResourceLocation TEXTURE = Create.asResource("textures/models/armor/copper.png"); private static final String TEXTURE_STRING = TEXTURE.toString(); - public CopperArmorItem(EquipmentSlotType p_i48534_2_, Properties p_i48534_3_) { + public CopperArmorItem(EquipmentSlot p_i48534_2_, Properties p_i48534_3_) { super(AllArmorMaterials.COPPER, p_i48534_2_, p_i48534_3_.stacksTo(1)); } @@ -26,7 +28,7 @@ public class CopperArmorItem extends ArmorItem { } @Override - public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlotType slot, String type) { + public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { return TEXTURE_STRING; } 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 d6a54c9dd..4d2b6101d 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 @@ -1,6 +1,6 @@ package com.simibubi.create.content.curiosities.armor; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; @@ -11,38 +11,38 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; -import net.minecraft.block.BlockState; -import net.minecraft.client.MainWindow; +import net.minecraft.world.level.block.state.BlockState; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.Atlases; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.IRenderTypeBuffer.Impl; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.Sheets; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.MultiBufferSource.BufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.client.renderer.entity.IEntityRenderer; -import net.minecraft.client.renderer.entity.LivingRenderer; -import net.minecraft.client.renderer.entity.PlayerRenderer; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; -import net.minecraft.client.renderer.entity.model.BipedModel; -import net.minecraft.client.renderer.entity.model.EntityModel; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.Pose; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.client.renderer.entity.RenderLayerParent; +import net.minecraft.client.renderer.entity.LivingEntityRenderer; +import net.minecraft.client.renderer.entity.player.PlayerRenderer; +import net.minecraft.client.renderer.entity.layers.RenderLayer; +import net.minecraft.client.model.HumanoidModel; +import net.minecraft.client.model.EntityModel; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Pose; import net.minecraft.tags.FluidTags; -import net.minecraft.util.Direction; -import net.minecraft.util.StringUtils; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.core.Direction; +import net.minecraft.util.StringUtil; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; -public class CopperBacktankArmorLayer> extends LayerRenderer { +public class CopperBacktankArmorLayer> extends RenderLayer { - public CopperBacktankArmorLayer(IEntityRenderer renderer) { + public CopperBacktankArmorLayer(RenderLayerParent renderer) { super(renderer); } @Override - public void render(MatrixStack ms, IRenderTypeBuffer buffer, int light, LivingEntity entity, float yaw, float pitch, + public void render(PoseStack ms, MultiBufferSource buffer, int light, LivingEntity entity, float yaw, float pitch, float pt, float p_225628_8_, float p_225628_9_, float p_225628_10_) { if (entity.getPose() == Pose.SLEEPING) return; @@ -51,11 +51,11 @@ public class CopperBacktankArmorLayer model = (BipedModel) entityModel; - RenderType renderType = Atlases.cutoutBlockSheet(); + HumanoidModel model = (HumanoidModel) entityModel; + RenderType renderType = Sheets.cutoutBlockSheet(); BlockState renderedState = AllBlocks.COPPER_BACKTANK.getDefaultState() .setValue(CopperBacktankBlock.HORIZONTAL_FACING, Direction.SOUTH); SuperByteBuffer backtank = CreateClient.BUFFER_CACHE.renderBlock(renderedState); @@ -87,7 +87,7 @@ public class CopperBacktankArmorLayer renderer : renderManager.renderers.values()) @@ -96,17 +96,17 @@ public class CopperBacktankArmorLayer entityRenderer) { - if (!(entityRenderer instanceof LivingRenderer)) + if (!(entityRenderer instanceof LivingEntityRenderer)) return; - LivingRenderer livingRenderer = (LivingRenderer) entityRenderer; - if (!(livingRenderer.getModel() instanceof BipedModel)) + LivingEntityRenderer livingRenderer = (LivingEntityRenderer) entityRenderer; + if (!(livingRenderer.getModel() instanceof HumanoidModel)) return; CopperBacktankArmorLayer layer = new CopperBacktankArmorLayer<>(livingRenderer); livingRenderer.addLayer((CopperBacktankArmorLayer) layer); } - public static void renderRemainingAirOverlay(MatrixStack ms, Impl buffers, int light, int overlay, float pt) { - ClientPlayerEntity player = Minecraft.getInstance().player; + public static void renderRemainingAirOverlay(PoseStack ms, BufferSource buffers, int light, int overlay, float pt) { + LocalPlayer player = Minecraft.getInstance().player; if (player == null) return; if (player.isSpectator() || player.isCreative()) @@ -122,11 +122,11 @@ public class CopperBacktankArmorLayer, IWaterLoggable { + implements ITE, SimpleWaterloggedBlock { public CopperBacktankBlock(Properties properties) { super(properties); @@ -70,14 +72,14 @@ public class CopperBacktankBlock extends HorizontalKineticBlock } @Override - public int getAnalogOutputSignal(BlockState p_180641_1_, World world, BlockPos pos) { + public int getAnalogOutputSignal(BlockState p_180641_1_, Level world, BlockPos pos) { return getTileEntityOptional(world, pos).map(CopperBacktankTileEntity::getComparatorOutput) .orElse(0); } @Override public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, - IWorld world, BlockPos pos, BlockPos neighbourPos) { + LevelAccessor world, BlockPos pos, BlockPos neighbourPos) { if (state.getValue(BlockStateProperties.WATERLOGGED)) { world.getLiquidTicks() .scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); @@ -86,7 +88,7 @@ public class CopperBacktankBlock extends HorizontalKineticBlock } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { FluidState ifluidstate = context.getLevel() .getFluidState(context.getClickedPos()); return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, @@ -94,7 +96,7 @@ public class CopperBacktankBlock extends HorizontalKineticBlock } @Override - public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) { return face == Direction.UP; } @@ -104,7 +106,7 @@ public class CopperBacktankBlock extends HorizontalKineticBlock } @Override - public void setPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { + public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { super.setPlacedBy(worldIn, pos, state, placer, stack); if (worldIn.isClientSide) return; @@ -122,47 +124,47 @@ public class CopperBacktankBlock extends HorizontalKineticBlock } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand p_225533_5_, - BlockRayTraceResult p_225533_6_) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand p_225533_5_, + BlockHitResult p_225533_6_) { if (player == null) - return ActionResultType.PASS; + return InteractionResult.PASS; if (player instanceof FakePlayer) - return ActionResultType.PASS; + return InteractionResult.PASS; if (player.isShiftKeyDown()) - return ActionResultType.PASS; + return InteractionResult.PASS; if (player.getMainHandItem() .getItem() instanceof BlockItem) - return ActionResultType.PASS; - if (!player.getItemBySlot(EquipmentSlotType.CHEST) + return InteractionResult.PASS; + if (!player.getItemBySlot(EquipmentSlot.CHEST) .isEmpty()) - return ActionResultType.PASS; + return InteractionResult.PASS; if (!world.isClientSide) { - world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .75f, 1); - player.setItemSlot(EquipmentSlotType.CHEST, getCloneItemStack(world, pos, state)); + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, .75f, 1); + player.setItemSlot(EquipmentSlot.CHEST, getCloneItemStack(world, pos, state)); world.destroyBlock(pos, false); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public ItemStack getCloneItemStack(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { + public ItemStack getCloneItemStack(BlockGetter 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_); int air = tileEntityOptional.map(CopperBacktankTileEntity::getAirLevel) .orElse(0); - CompoundNBT tag = item.getOrCreateTag(); + CompoundTag tag = item.getOrCreateTag(); tag.putInt("Air", air); - ListNBT enchants = tileEntityOptional.map(CopperBacktankTileEntity::getEnchantmentTag) - .orElse(new ListNBT()); + ListTag enchants = tileEntityOptional.map(CopperBacktankTileEntity::getEnchantmentTag) + .orElse(new ListTag()); if (!enchants.isEmpty()) { - ListNBT enchantmentTagList = item.getEnchantmentTags(); + ListTag enchantmentTagList = item.getEnchantmentTags(); enchantmentTagList.addAll(enchants); tag.put("Enchantments", enchantmentTagList); } - ITextComponent customName = tileEntityOptional.map(CopperBacktankTileEntity::getCustomName) + Component customName = tileEntityOptional.map(CopperBacktankTileEntity::getCustomName) .orElse(null); if (customName != null) item.setHoverName(customName); @@ -170,13 +172,13 @@ public class CopperBacktankBlock extends HorizontalKineticBlock } @Override - public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return AllShapes.BACKTANK; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.COPPER_BACKTANK.create(); } @@ -186,7 +188,7 @@ public class CopperBacktankBlock extends HorizontalKineticBlock } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 81df65440..725c54a9b 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 @@ -2,15 +2,17 @@ package com.simibubi.create.content.curiosities.armor; import com.simibubi.create.content.curiosities.armor.CapacityEnchantment.ICapacityEnchantable; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.NonNullList; +import net.minecraft.util.Mth; + +import net.minecraft.world.item.Item.Properties; public class CopperBacktankItem extends CopperArmorItem implements ICapacityEnchantable { @@ -18,12 +20,12 @@ public class CopperBacktankItem extends CopperArmorItem implements ICapacityEnch private BlockItem blockItem; public CopperBacktankItem(Properties p_i48534_3_, BlockItem blockItem) { - super(EquipmentSlotType.CHEST, p_i48534_3_); + super(EquipmentSlot.CHEST, p_i48534_3_); this.blockItem = blockItem; } @Override - public ActionResultType useOn(ItemUseContext p_195939_1_) { + public InteractionResult useOn(UseOnContext p_195939_1_) { return blockItem.useOn(p_195939_1_); } @@ -43,12 +45,12 @@ public class CopperBacktankItem extends CopperArmorItem implements ICapacityEnch } @Override - public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + public void fillItemCategory(CreativeModeTab p_150895_1_, NonNullList p_150895_2_) { if (!allowdedIn(p_150895_1_)) return; ItemStack stack = new ItemStack(this); - CompoundNBT nbt = new CompoundNBT(); + CompoundTag nbt = new CompoundTag(); nbt.putInt("Air", BackTankUtil.maxAirWithoutEnchants()); stack.setTag(nbt); p_150895_2_.add(stack); @@ -56,7 +58,7 @@ public class CopperBacktankItem extends CopperArmorItem implements ICapacityEnch @Override public double getDurabilityForDisplay(ItemStack stack) { - return 1 - MathHelper + return 1 - Mth .clamp(getRemainingAir(stack) / ((float) BackTankUtil.maxAir(stack)), 0, 1); } @@ -66,7 +68,7 @@ public class CopperBacktankItem extends CopperArmorItem implements ICapacityEnch } public static int getRemainingAir(ItemStack stack) { - CompoundNBT orCreateTag = stack.getOrCreateTag(); + CompoundTag orCreateTag = stack.getOrCreateTag(); return orCreateTag.getInt("Air"); } 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 387f26e67..592fdf601 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 @@ -1,6 +1,6 @@ package com.simibubi.create.content.curiosities.armor; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.base.KineticTileEntity; @@ -10,20 +10,20 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; public class CopperBacktankRenderer extends KineticTileEntityRenderer { - public CopperBacktankRenderer(TileEntityRendererDispatcher dispatcher) { + public CopperBacktankRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); 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 b03b79038..f4c4f9371 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 @@ -8,33 +8,33 @@ import com.simibubi.create.content.contraptions.particle.AirParticleData; import com.simibubi.create.foundation.tileEntity.ComparatorUtil; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.INameable; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.Nameable; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.common.util.Constants.NBT; -public class CopperBacktankTileEntity extends KineticTileEntity implements INameable { +public class CopperBacktankTileEntity extends KineticTileEntity implements Nameable { public int airLevel; public int airLevelTimer; - private ITextComponent customName; + private Component customName; private int capacityEnchantLevel; - private ListNBT enchantmentTag; + private ListTag enchantmentTag; - public CopperBacktankTileEntity(TileEntityType typeIn) { + public CopperBacktankTileEntity(BlockEntityType typeIn) { super(typeIn); - enchantmentTag = new ListNBT(); + enchantmentTag = new ListTag(); } @Override @@ -55,9 +55,9 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName int max = BackTankUtil.maxAir(capacityEnchantLevel); if (level.isClientSide) { - Vector3d centerOf = VecHelper.getCenterOf(worldPosition); - Vector3d v = VecHelper.offsetRandomly(centerOf, Create.RANDOM, .65f); - Vector3d m = centerOf.subtract(v); + Vec3 centerOf = VecHelper.getCenterOf(worldPosition); + Vec3 v = VecHelper.offsetRandomly(centerOf, Create.RANDOM, .65f); + Vec3 m = centerOf.subtract(v); if (airLevel != max) level.addParticle(new AirParticleData(1, .05f), v.x, v.y, v.z, m.x, m.y, m.z); return; @@ -68,13 +68,13 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName int prevComparatorLevel = getComparatorOutput(); float abs = Math.abs(getSpeed()); - int increment = MathHelper.clamp(((int) abs - 100) / 20, 1, 5); + int increment = Mth.clamp(((int) abs - 100) / 20, 1, 5); airLevel = Math.min(max, airLevel + increment); if (getComparatorOutput() != prevComparatorLevel && !level.isClientSide) level.updateNeighbourForOutputSignal(worldPosition, state.getBlock()); if (airLevel == max) sendData(); - airLevelTimer = MathHelper.clamp((int) (128f - abs / 5f) - 108, 0, 20); + airLevelTimer = Mth.clamp((int) (128f - abs / 5f) - 108, 0, 20); } public int getComparatorOutput() { @@ -83,18 +83,18 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); compound.putInt("Air", airLevel); compound.putInt("Timer", airLevelTimer); compound.putInt("CapacityEnchantment", capacityEnchantLevel); if (this.customName != null) - compound.putString("CustomName", ITextComponent.Serializer.toJson(this.customName)); + compound.putString("CustomName", Component.Serializer.toJson(this.customName)); compound.put("Enchantments", enchantmentTag); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); int prev = airLevel; capacityEnchantLevel = compound.getInt("CapacityEnchantment"); @@ -102,18 +102,18 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName airLevelTimer = compound.getInt("Timer"); enchantmentTag = compound.getList("Enchantments", NBT.TAG_COMPOUND); if (compound.contains("CustomName", 8)) - this.customName = ITextComponent.Serializer.fromJson(compound.getString("CustomName")); + this.customName = Component.Serializer.fromJson(compound.getString("CustomName")); if (prev != 0 && prev != airLevel && airLevel == BackTankUtil.maxAir(capacityEnchantLevel) && clientPacket) playFilledEffect(); } protected void playFilledEffect() { AllSoundEvents.CONFIRM.playAt(level, worldPosition, 0.4f, 1, true); - Vector3d baseMotion = new Vector3d(.25, 0.1, 0); - Vector3d baseVec = VecHelper.getCenterOf(worldPosition); + Vec3 baseMotion = new Vec3(.25, 0.1, 0); + Vec3 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() + Vec3 m = VecHelper.rotate(baseMotion, i, Axis.Y); + Vec3 v = baseVec.add(m.normalize() .scale(.25f)); level.addParticle(ParticleTypes.SPIT, v.x, v.y, v.z, m.x, m.y, m.z); @@ -121,9 +121,9 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName } @Override - public ITextComponent getName() { + public Component getName() { return this.customName != null ? this.customName - : new TranslationTextComponent(AllItems.COPPER_BACKTANK.get() + : new TranslatableComponent(AllItems.COPPER_BACKTANK.get() .getDescriptionId()); } @@ -141,19 +141,19 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName sendData(); } - public void setCustomName(ITextComponent customName) { + public void setCustomName(Component customName) { this.customName = customName; } - public ITextComponent getCustomName() { + public Component getCustomName() { return customName; } - public ListNBT getEnchantmentTag() { + public ListTag getEnchantmentTag() { return enchantmentTag; } - public void setEnchantmentTag(ListNBT enchantmentTag) { + public void setEnchantmentTag(ListTag enchantmentTag) { this.enchantmentTag = enchantmentTag; } 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 bde20ed32..cb4ef9c1b 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 @@ -3,21 +3,23 @@ package com.simibubi.create.content.curiosities.armor; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.Pose; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import net.minecraft.world.item.Item.Properties; + @EventBusSubscriber public class DivingBootsItem extends CopperArmorItem { public DivingBootsItem(Properties p_i48534_3_) { - super(EquipmentSlotType.FEET, p_i48534_3_); + super(EquipmentSlot.FEET, p_i48534_3_); } @SubscribeEvent @@ -26,7 +28,7 @@ public class DivingBootsItem extends CopperArmorItem { if (!affects(entity)) return; - Vector3d motion = entity.getDeltaMovement(); + Vec3 motion = entity.getDeltaMovement(); Boolean isJumping = ObfuscationReflectionHelper.getPrivateValue(LivingEntity.class, entity, "field_70703_bu"); // jumping entity.onGround |= entity.verticalCollision; @@ -57,8 +59,8 @@ public class DivingBootsItem extends CopperArmorItem { return false; if (entity.getPose() == Pose.SWIMMING) return false; - if (entity instanceof PlayerEntity) { - PlayerEntity playerEntity = (PlayerEntity) entity; + if (entity instanceof Player) { + Player playerEntity = (Player) entity; if (playerEntity.abilities.flying) return false; } 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 18d5f81ed..f888bcc9b 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 @@ -2,29 +2,31 @@ package com.simibubi.create.content.curiosities.armor; import com.simibubi.create.AllItems; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Effects; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; import net.minecraft.tags.FluidTags; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.world.item.Item.Properties; + @EventBusSubscriber public class DivingHelmetItem extends CopperArmorItem { public DivingHelmetItem(Properties p_i48534_3_) { - super(EquipmentSlotType.HEAD, p_i48534_3_); + super(EquipmentSlot.HEAD, p_i48534_3_); } @SubscribeEvent public static void breatheUnderwater(LivingUpdateEvent event) { LivingEntity entity = event.getEntityLiving(); - World world = entity.level; + Level world = entity.level; boolean second = world.getGameTime() % 20 == 0; boolean drowning = entity.getAirSupply() == 0; @@ -37,7 +39,7 @@ public class DivingHelmetItem extends CopperArmorItem { return; if (!entity.isEyeInFluid(FluidTags.WATER)) return; - if (entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative()) + if (entity instanceof Player && ((Player) entity).isCreative()) return; ItemStack backtank = BackTankUtil.get(entity); @@ -57,7 +59,7 @@ public class DivingHelmetItem extends CopperArmorItem { return; entity.setAirSupply(Math.min(entity.getMaxAirSupply(), entity.getAirSupply() + 10)); - entity.addEffect(new EffectInstance(Effects.WATER_BREATHING, 30, 0, true, false, true)); + entity.addEffect(new MobEffectInstance(MobEffects.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 c3f4e7bc5..fb3da161e 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 @@ -5,20 +5,22 @@ import javax.annotation.Nullable; import com.simibubi.create.AllShapes; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.BellBlock; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.state.properties.BellAttachment; +import net.minecraft.world.level.block.BellBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.state.properties.BellAttachType; import net.minecraft.stats.Stats; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public abstract class AbstractBellBlock extends BellBlock implements ITE { @@ -28,12 +30,12 @@ public abstract class AbstractBellBlock exten @Override @Nullable - public TileEntity newBlockEntity(IBlockReader block) { + public BlockEntity newBlockEntity(BlockGetter block) { return null; } @Override - public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext selection) { + public VoxelShape getShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext selection) { Direction facing = state.getValue(FACING); switch (state.getValue(ATTACHMENT)) { case CEILING: @@ -45,12 +47,12 @@ public abstract class AbstractBellBlock exten case SINGLE_WALL: return AllShapes.BELL_WALL.get(facing); default: - return VoxelShapes.block(); + return Shapes.block(); } } @Override - public boolean onHit(World world, BlockState state, BlockRayTraceResult hit, @Nullable PlayerEntity player, + public boolean onHit(Level world, BlockState state, BlockHitResult hit, @Nullable Player player, boolean flag) { BlockPos pos = hit.getBlockPos(); Direction direction = hit.getDirection(); @@ -81,7 +83,7 @@ public abstract class AbstractBellBlock exten return false; Direction direction = state.getValue(FACING); - BellAttachment bellAttachment = state.getValue(ATTACHMENT); + BellAttachType bellAttachment = state.getValue(ATTACHMENT); switch (bellAttachment) { case FLOOR: case CEILING: @@ -94,6 +96,6 @@ public abstract class AbstractBellBlock exten } } - public abstract void playSound(World world, BlockPos pos); + public abstract void playSound(Level world, BlockPos pos); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellTileEntity.java index 0957d7f19..91289e722 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellTileEntity.java @@ -6,10 +6,10 @@ import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public abstract class AbstractBellTileEntity extends SmartTileEntity { @@ -19,14 +19,14 @@ public abstract class AbstractBellTileEntity extends SmartTileEntity { public int ringingTicks; public Direction ringDirection; - public AbstractBellTileEntity(TileEntityType type) { + public AbstractBellTileEntity(BlockEntityType type) { super(type); } @Override public void addBehaviours(List behaviours) { } - public boolean ring(World world, BlockPos pos, Direction direction) { + public boolean ring(Level world, BlockPos pos, Direction direction) { isRinging = true; ringingTicks = 0; ringDirection = direction; 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 4ff8f8328..6ab600672 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 @@ -7,34 +7,36 @@ import com.mojang.serialization.Codec; import com.simibubi.create.content.contraptions.particle.ICustomParticleDataWithSprite; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.client.particle.IAnimatedSprite; +import net.minecraft.client.particle.SpriteSet; import net.minecraft.client.particle.Particle; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.network.PacketBuffer; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleType; -import net.minecraft.util.registry.Registry; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.Registry; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.core.particles.ParticleOptions.Deserializer; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public abstract class BasicParticleData implements IParticleData, ICustomParticleDataWithSprite> { +public abstract class BasicParticleData implements ParticleOptions, ICustomParticleDataWithSprite> { public BasicParticleData() { } @Override - public IDeserializer> getDeserializer() { + public Deserializer> getDeserializer() { BasicParticleData data = this; - return new IParticleData.IDeserializer>() { + return new ParticleOptions.Deserializer>() { @Override public BasicParticleData fromCommand(ParticleType> arg0, StringReader reader) { return data; } @Override - public BasicParticleData fromNetwork(ParticleType> type, PacketBuffer buffer) { + public BasicParticleData fromNetwork(ParticleType> type, FriendlyByteBuf buffer) { return data; } }; @@ -46,7 +48,7 @@ public abstract class BasicParticleData implements IParticle } public interface IBasicParticleFactory { - U makeParticle(ClientWorld worldIn, double x, double y, double z, double vx, double vy, double vz, IAnimatedSprite sprite); + U makeParticle(ClientLevel worldIn, double x, double y, double z, double vx, double vy, double vz, SpriteSet sprite); } @OnlyIn(Dist.CLIENT) @@ -54,7 +56,7 @@ public abstract class BasicParticleData implements IParticle @Override @OnlyIn(Dist.CLIENT) - public ParticleManager.IParticleMetaFactory> getMetaFactory() { + public ParticleEngine.SpriteParticleRegistration> getMetaFactory() { return animatedSprite -> (data, worldIn, x, y, z, vx, vy, vz) -> getBasicFactory().makeParticle(worldIn, x, y, z, vx, vy, vz, animatedSprite); } @@ -65,5 +67,5 @@ public abstract class BasicParticleData implements IParticle } @Override - public void writeToNetwork(PacketBuffer buffer) { } + public void writeToNetwork(FriendlyByteBuf 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 c32fce701..e175f2cf0 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 @@ -1,31 +1,31 @@ package com.simibubi.create.content.curiosities.bell; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.block.BellBlock; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.BellBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.state.properties.BellAttachment; -import net.minecraft.util.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.level.block.state.properties.BellAttachType; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; public class BellRenderer extends SafeTileEntityRenderer { - public BellRenderer(TileEntityRendererDispatcher dispatcher) { + public BellRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(TE te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + protected void renderSafe(TE te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { BlockState state = te.getBlockState(); Direction facing = state.getValue(BellBlock.FACING); - BellAttachment attachment = state.getValue(BellBlock.ATTACHMENT); + BellAttachType attachment = state.getValue(BellBlock.ATTACHMENT); SuperByteBuffer bell = PartialBufferer.get(te.getBellModel(), state); @@ -33,7 +33,7 @@ public class BellRenderer extends SafeTileEnt bell.rotateCentered(te.ringDirection.getCounterClockWise(), getSwingAngle(te.ringingTicks + partialTicks)); float rY = AngleHelper.horizontalAngle(facing); - if (attachment == BellAttachment.SINGLE_WALL || attachment == BellAttachment.DOUBLE_WALL) + if (attachment == BellAttachType.SINGLE_WALL || attachment == BellAttachType.DOUBLE_WALL) rY += 90; bell.rotateCentered(Direction.UP, AngleHelper.rad(rY)); @@ -43,7 +43,7 @@ public class BellRenderer extends SafeTileEnt public static float getSwingAngle(float time) { float t = time / 1.5f; - return 1.2f * MathHelper.sin(t / (float) Math.PI) / (2.5f + t / 3.0f); + return 1.2f * Mth.sin(t / (float) Math.PI) / (2.5f + t / 3.0f); } } 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 66e708d8d..71146ddf7 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 @@ -1,47 +1,47 @@ package com.simibubi.create.content.curiosities.bell; import com.jozufozu.flywheel.backend.OptifineHandler; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.particle.IAnimatedSprite; +import net.minecraft.client.particle.SpriteSet; import net.minecraft.client.particle.SimpleAnimatedParticle; -import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.Camera; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.util.Mth; +import com.mojang.math.Quaternion; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; public class CustomRotationParticle extends SimpleAnimatedParticle { protected boolean mirror; protected int loopLength; - public CustomRotationParticle(ClientWorld worldIn, double x, double y, double z, IAnimatedSprite spriteSet, float yAccel) { + public CustomRotationParticle(ClientLevel worldIn, double x, double y, double z, SpriteSet spriteSet, float yAccel) { super(worldIn, x, y, z, spriteSet, yAccel); } - public void selectSpriteLoopingWithAge(IAnimatedSprite sprite) { + public void selectSpriteLoopingWithAge(SpriteSet sprite) { int loopFrame = age % loopLength; this.setSprite(sprite.get(loopFrame, loopLength)); } - public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) { + public Quaternion getCustomRotation(Camera camera, float partialTicks) { Quaternion quaternion = new Quaternion(camera.rotation()); if (roll != 0.0F) { - float angle = MathHelper.lerp(partialTicks, oRoll, roll); + float angle = Mth.lerp(partialTicks, oRoll, roll); quaternion.mul(Vector3f.ZP.rotation(angle)); } return quaternion; } @Override - 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()); + public void render(VertexConsumer builder, Camera camera, float partialTicks) { + Vec3 cameraPos = camera.getPosition(); + float originX = (float) (Mth.lerp(partialTicks, xo, x) - cameraPos.x()); + float originY = (float) (Mth.lerp(partialTicks, yo, y) - cameraPos.y()); + float originZ = (float) (Mth.lerp(partialTicks, zo, z) - cameraPos.z()); Vector3f[] vertices = new Vector3f[] { new Vector3f(-1.0F, -1.0F, 0.0F), 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 7b02626a5..e5db69e19 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 @@ -3,11 +3,13 @@ package com.simibubi.create.content.curiosities.bell; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTileEntities; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class HauntedBellBlock extends AbstractBellBlock { @@ -16,7 +18,7 @@ public class HauntedBellBlock extends AbstractBellBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.HAUNTED_BELL.create(); } @@ -26,12 +28,12 @@ public class HauntedBellBlock extends AbstractBellBlock { } @Override - public void playSound(World world, BlockPos pos) { + public void playSound(Level world, BlockPos pos) { AllSoundEvents.HAUNTED_BELL_USE.playOnServer(world, pos, 4f, 1f); } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level 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 bbd46e191..4eeec2f61 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.curiosities.bell; import com.simibubi.create.content.contraptions.components.actors.BellMovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; public class HauntedBellMovementBehaviour extends BellMovementBehaviour { 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 a26c96c1f..0dbcb6086 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 @@ -10,10 +10,10 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.IntAttached; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.entity.Entity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.LogicalSide; @@ -60,8 +60,8 @@ public class HauntedBellPulser { sendPulse(player.level, event.player.blockPosition(), DISTANCE, false); } - public static void sendPulse(World world, BlockPos pos, int distance, boolean canOverlap) { - Chunk chunk = world.getChunkAt(pos); + public static void sendPulse(Level world, BlockPos pos, int distance, boolean canOverlap) { + LevelChunk chunk = world.getChunkAt(pos); AllPackets.channel.send(PacketDistributor.TRACKING_CHUNK.with(() -> chunk), new SoulPulseEffectPacket(pos, distance, 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 4847c815e..b62d7535d 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 @@ -7,15 +7,15 @@ import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class HauntedBellTileEntity extends AbstractBellTileEntity { @@ -25,7 +25,7 @@ public class HauntedBellTileEntity extends AbstractBellTileEntity { public int effectTicks = 0; - public HauntedBellTileEntity(TileEntityType type) { + public HauntedBellTileEntity(BlockEntityType type) { super(type); } @@ -38,7 +38,7 @@ public class HauntedBellTileEntity extends AbstractBellTileEntity { } @Override - public boolean ring(World world, BlockPos pos, Direction direction) { + public boolean ring(Level world, BlockPos pos, Direction direction) { if (isRinging && ringingTicks < RECHARGE_TICKS) return false; @@ -59,13 +59,13 @@ public class HauntedBellTileEntity extends AbstractBellTileEntity { } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); compound.putInt("EffectTicks", effectTicks); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); effectTicks = compound.getInt("EffectTicks"); } @@ -102,7 +102,7 @@ public class HauntedBellTileEntity extends AbstractBellTileEntity { 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; - level.playSound(null, worldPosition, SoundEvents.SOUL_ESCAPE, SoundCategory.BLOCKS, vol, pitch); + level.playSound(null, worldPosition, SoundEvents.SOUL_ESCAPE, SoundSource.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 e701844c1..409470fdb 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 @@ -6,18 +6,20 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTileEntities; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class PeculiarBellBlock extends AbstractBellBlock { @@ -26,7 +28,7 @@ public class PeculiarBellBlock extends AbstractBellBlock } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.PECULIAR_BELL.create(); } @@ -36,23 +38,23 @@ public class PeculiarBellBlock extends AbstractBellBlock } @Override - public void playSound(World world, BlockPos pos) { + public void playSound(Level world, BlockPos pos) { AllSoundEvents.PECULIAR_BELL_USE.playOnServer(world, pos, 2f, 0.94f); } @Override - public BlockState getStateForPlacement(BlockItemUseContext ctx) { + public BlockState getStateForPlacement(BlockPlaceContext ctx) { BlockState newState = super.getStateForPlacement(ctx); if (newState == null) return null; - World world = ctx.getLevel(); + Level world = ctx.getLevel(); BlockPos pos = ctx.getClickedPos(); return tryConvert(world, pos, newState, world.getBlockState(pos.relative(Direction.DOWN))); } @Override - public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, IWorld world, + public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) { BlockState newState = super.updateShape(state, facing, facingState, world, currentPos, facingPos); if (facing != Direction.DOWN) @@ -61,7 +63,7 @@ public class PeculiarBellBlock extends AbstractBellBlock return tryConvert(world, currentPos, newState, facingState); } - protected BlockState tryConvert(IWorld world, BlockPos pos, BlockState state, BlockState underState) { + protected BlockState tryConvert(LevelAccessor world, BlockPos pos, BlockState state, BlockState underState) { if (!AllBlocks.PECULIAR_BELL.has(state)) return state; @@ -71,8 +73,8 @@ public class PeculiarBellBlock extends AbstractBellBlock if (world.isClientSide()) { spawnConversionParticles(world, pos); - } else if (world instanceof World) { - AllSoundEvents.HAUNTED_BELL_CONVERT.playOnServer((World) world, pos); + } else if (world instanceof Level) { + AllSoundEvents.HAUNTED_BELL_CONVERT.playOnServer((Level) world, pos); } return AllBlocks.HAUNTED_BELL.getDefaultState() @@ -81,14 +83,14 @@ public class PeculiarBellBlock extends AbstractBellBlock .setValue(HauntedBellBlock.POWERED, state.getValue(POWERED)); } - public void spawnConversionParticles(IWorld world, BlockPos blockPos) { + public void spawnConversionParticles(LevelAccessor world, BlockPos blockPos) { Random random = world.getRandom(); int num = random.nextInt(10) + 15; for (int i = 0; i < num; i++) { float pitch = random.nextFloat() * 120 - 90; float yaw = random.nextFloat() * 360; - Vector3d vel = Vector3d.directionFromRotation(pitch, yaw).scale(random.nextDouble() * 0.1 + 0.1); - Vector3d pos = Vector3d.atCenterOf(blockPos); + Vec3 vel = Vec3.directionFromRotation(pitch, yaw).scale(random.nextDouble() * 0.1 + 0.1); + Vec3 pos = Vec3.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/PeculiarBellTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/bell/PeculiarBellTileEntity.java index e58434e49..25c04e663 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/PeculiarBellTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/PeculiarBellTileEntity.java @@ -3,11 +3,11 @@ package com.simibubi.create.content.curiosities.bell; import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlockPartials; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.entity.BlockEntityType; public class PeculiarBellTileEntity extends AbstractBellTileEntity { - public PeculiarBellTileEntity(TileEntityType type) { + public PeculiarBellTileEntity(BlockEntityType type) { super(type); } 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 d65e73073..c5811122a 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 @@ -2,20 +2,20 @@ package com.simibubi.create.content.curiosities.bell; import com.simibubi.create.AllParticleTypes; -import net.minecraft.client.particle.IAnimatedSprite; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particles.ParticleType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.Camera; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.BlockPos; +import com.mojang.math.Quaternion; +import com.mojang.math.Vector3f; public class SoulBaseParticle extends CustomRotationParticle { - private final IAnimatedSprite animatedSprite; + private final SpriteSet animatedSprite; - public SoulBaseParticle(ClientWorld worldIn, double x, double y, double z, double vx, double vy, double vz, - IAnimatedSprite spriteSet) { + public SoulBaseParticle(ClientLevel worldIn, double x, double y, double z, double vx, double vy, double vz, + SpriteSet spriteSet) { super(worldIn, x, y, z, spriteSet, 0); this.animatedSprite = spriteSet; this.quadSize = 0.5f; @@ -36,7 +36,7 @@ public class SoulBaseParticle extends CustomRotationParticle { } @Override - public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) { + public Quaternion getCustomRotation(Camera camera, float partialTicks) { return Vector3f.XP.rotationDegrees(90); } 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 32eb92bdf..664ef7d44 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 @@ -1,20 +1,20 @@ package com.simibubi.create.content.curiosities.bell; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllParticleTypes; -import net.minecraft.client.particle.IAnimatedSprite; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.Camera; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.BlockPos; +import com.mojang.math.Quaternion; +import com.mojang.math.Vector3f; public class SoulParticle extends CustomRotationParticle { - private final IAnimatedSprite animatedSprite; + private final SpriteSet animatedSprite; protected int startTicks; protected int endTicks; @@ -39,8 +39,8 @@ public class SoulParticle extends CustomRotationParticle { protected boolean isVisible = true; protected int perimeterFrames = 8; - public SoulParticle(ClientWorld worldIn, double x, double y, double z, double vx, double vy, double vz, - IAnimatedSprite spriteSet, IParticleData data) { + public SoulParticle(ClientLevel worldIn, double x, double y, double z, double vx, double vy, double vz, + SpriteSet spriteSet, ParticleOptions data) { super(worldIn, x, y, z, spriteSet, 0); this.animatedSprite = spriteSet; this.quadSize = 0.5f; @@ -82,7 +82,7 @@ public class SoulParticle extends CustomRotationParticle { } @Override - public void render(IVertexBuilder builder, ActiveRenderInfo camera, float partialTicks) { + public void render(VertexConsumer builder, Camera camera, float partialTicks) { if (!isVisible) return; super.render(builder, camera, partialTicks); @@ -94,7 +94,7 @@ public class SoulParticle extends CustomRotationParticle { } @Override - public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) { + public Quaternion getCustomRotation(Camera camera, float partialTicks) { if (isPerimeter) return Vector3f.XP.rotationDegrees(90); return new Quaternion(0, -camera.getYRot(), 0, true); 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 437555c64..e625d0458 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 @@ -8,15 +8,15 @@ import java.util.stream.Stream; import com.simibubi.create.content.curiosities.bell.SoulParticle.ExpandingPerimeterData; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.entity.EntitySpawnPlacementRegistry; -import net.minecraft.entity.EntityType; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.LightType; -import net.minecraft.world.World; -import net.minecraft.world.spawner.WorldEntitySpawner; +import net.minecraft.world.entity.SpawnPlacements; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.NaturalSpawner; public class SoulPulseEffect { @@ -45,7 +45,7 @@ public class SoulPulseEffect { return added == null; } - public List tick(World world) { + public List tick(Level world) { if (finished()) return null; @@ -65,7 +65,7 @@ public class SoulPulseEffect { return distance - ticks / TICKS_PER_LAYER - 1; } - public List getPotentialSoulSpawns(World world) { + public List getPotentialSoulSpawns(Level world) { if (world == null) return new ArrayList<>(); @@ -74,38 +74,38 @@ public class SoulPulseEffect { .collect(Collectors.toList()); } - public static boolean isDark(World world, BlockPos at) { - return world.getBrightness(LightType.BLOCK, at) < 8; + public static boolean isDark(Level world, BlockPos at) { + return world.getBrightness(LightLayer.BLOCK, at) < 8; } - public static boolean canSpawnSoulAt(World world, BlockPos at, boolean ignoreLight) { + public static boolean canSpawnSoulAt(Level world, BlockPos at, boolean ignoreLight) { EntityType dummy = EntityType.ZOMBIE; double dummyWidth = 0.2, dummyHeight = 0.75; double w2 = dummyWidth / 2; return world != null - && WorldEntitySpawner - .isSpawnPositionOk(EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, world, at, dummy) + && NaturalSpawner + .isSpawnPositionOk(SpawnPlacements.Type.ON_GROUND, world, at, dummy) && (ignoreLight || isDark(world, at)) && world .getBlockCollisions(null, - new AxisAlignedBB(at.getX() + 0.5 - w2, at.getY(), at.getZ() + 0.5 - w2, at.getX() + 0.5 + w2, + new AABB(at.getX() + 0.5 - w2, at.getY(), at.getZ() + 0.5 - w2, at.getX() + 0.5 + w2, at.getY() + dummyHeight, at.getZ() + 0.5 + w2), (a, b) -> true) .allMatch(VoxelShape::isEmpty); } - public void spawnParticles(World world, BlockPos at) { + public void spawnParticles(Level world, BlockPos at) { if (world == null || !world.isClientSide) return; - Vector3d p = Vector3d.atLowerCornerOf(at); + Vec3 p = Vec3.atLowerCornerOf(at); if (canOverlap()) 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.getBrightness(LightType.BLOCK, at) < 8) { + if (world.getBrightness(LightLayer.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); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffectHandler.java b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffectHandler.java index c52d112bd..99217687e 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffectHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffectHandler.java @@ -5,8 +5,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class SoulPulseEffectHandler { @@ -18,7 +18,7 @@ public class SoulPulseEffectHandler { occupied = new HashSet<>(); } - public void tick(World world) { + public void tick(Level world) { for (SoulPulseEffect pulse : pulses) { List spawns = pulse.tick(world); if (spawns == null) diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffectPacket.java b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffectPacket.java index 939c4aaf4..c2b673cef 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffectPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffectPacket.java @@ -5,8 +5,8 @@ import java.util.function.Supplier; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; import net.minecraftforge.fml.network.NetworkEvent; public class SoulPulseEffectPacket extends SimplePacketBase { @@ -21,14 +21,14 @@ public class SoulPulseEffectPacket extends SimplePacketBase { this.canOverlap = overlaps; } - public SoulPulseEffectPacket(PacketBuffer buffer) { + public SoulPulseEffectPacket(FriendlyByteBuf buffer) { pos = buffer.readBlockPos(); distance = buffer.readInt(); canOverlap = buffer.readBoolean(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBlockPos(pos); buffer.writeInt(distance); buffer.writeBoolean(canOverlap); diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/ConfigureSymmetryWandPacket.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/ConfigureSymmetryWandPacket.java index 9484111cc..e9e28c71c 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/ConfigureSymmetryWandPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/ConfigureSymmetryWandPacket.java @@ -5,29 +5,29 @@ import java.util.function.Supplier; import com.simibubi.create.content.curiosities.symmetry.mirror.SymmetryMirror; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Hand; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.InteractionHand; import net.minecraftforge.fml.network.NetworkEvent.Context; public class ConfigureSymmetryWandPacket extends SimplePacketBase { - protected Hand hand; + protected InteractionHand hand; protected SymmetryMirror mirror; - public ConfigureSymmetryWandPacket(Hand hand, SymmetryMirror mirror) { + public ConfigureSymmetryWandPacket(InteractionHand hand, SymmetryMirror mirror) { this.hand = hand; this.mirror = mirror; } - public ConfigureSymmetryWandPacket(PacketBuffer buffer) { - hand = buffer.readEnum(Hand.class); + public ConfigureSymmetryWandPacket(FriendlyByteBuf buffer) { + hand = buffer.readEnum(InteractionHand.class); mirror = SymmetryMirror.fromNBT(buffer.readNbt()); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeEnum(hand); buffer.writeNbt(mirror.writeToNbt()); } @@ -35,7 +35,7 @@ public class ConfigureSymmetryWandPacket extends SimplePacketBase { @Override public void handle(Supplier context) { context.get().enqueueWork(() -> { - ServerPlayerEntity player = context.get().getSender(); + ServerPlayer player = context.get().getSender(); if (player == null) { return; } 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 90609b6a3..7b0df3b35 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 @@ -7,9 +7,9 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.NetworkEvent.Context; @@ -24,7 +24,7 @@ public class SymmetryEffectPacket extends SimplePacketBase { this.positions = positions; } - public SymmetryEffectPacket(PacketBuffer buffer) { + public SymmetryEffectPacket(FriendlyByteBuf buffer) { mirror = buffer.readBlockPos(); int amt = buffer.readInt(); positions = new ArrayList<>(amt); @@ -33,7 +33,7 @@ public class SymmetryEffectPacket extends SimplePacketBase { } } - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBlockPos(mirror); buffer.writeInt(positions.size()); for (BlockPos blockPos : positions) { @@ -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.position().distanceTo(Vector3d.atLowerCornerOf(mirror)) > 100) + if (Minecraft.getInstance().player.position().distanceTo(Vec3.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 644999081..6fcfc7bea 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 @@ -2,29 +2,29 @@ package com.simibubi.create.content.curiosities.symmetry; import java.util.Random; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllItems; import com.simibubi.create.content.curiosities.symmetry.mirror.EmptyMirror; import com.simibubi.create.content.curiosities.symmetry.mirror.SymmetryMirror; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.particles.RedstoneParticleData; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderWorldLastEvent; @@ -48,12 +48,12 @@ public class SymmetryHandler { if (event.getWorld() .isClientSide()) return; - if (!(event.getEntity() instanceof PlayerEntity)) + if (!(event.getEntity() instanceof Player)) return; - PlayerEntity player = (PlayerEntity) event.getEntity(); - PlayerInventory inv = player.inventory; - for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + Player player = (Player) event.getEntity(); + Inventory inv = player.inventory; + for (int i = 0; i < Inventory.getSelectionSize(); i++) { if (!inv.getItem(i) .isEmpty() && inv.getItem(i) @@ -70,9 +70,9 @@ public class SymmetryHandler { .isClientSide()) return; - PlayerEntity player = event.getPlayer(); - PlayerInventory inv = player.inventory; - for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + Player player = event.getPlayer(); + Inventory inv = player.inventory; + for (int i = 0; i < Inventory.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()); @@ -84,9 +84,9 @@ public class SymmetryHandler { @SubscribeEvent public static void render(RenderWorldLastEvent event) { Minecraft mc = Minecraft.getInstance(); - ClientPlayerEntity player = mc.player; + LocalPlayer player = mc.player; - for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + for (int i = 0; i < Inventory.getSelectionSize(); i++) { ItemStack stackInSlot = player.inventory.getItem(i); if (!AllItems.WAND_OF_SYMMETRY.isIn(stackInSlot)) continue; @@ -100,28 +100,28 @@ public class SymmetryHandler { float yShift = 0; double speed = 1 / 16d; - yShift = MathHelper.sin((float) (AnimationTickHolder.getRenderTime() * speed)) / 5f; + yShift = Mth.sin((float) (AnimationTickHolder.getRenderTime() * speed)) / 5f; - IRenderTypeBuffer.Impl buffer = Minecraft.getInstance() + MultiBufferSource.BufferSource buffer = Minecraft.getInstance() .renderBuffers() .bufferSource(); - ActiveRenderInfo info = mc.gameRenderer.getMainCamera(); - Vector3d view = info.getPosition(); + Camera info = mc.gameRenderer.getMainCamera(); + Vec3 view = info.getPosition(); - MatrixStack ms = event.getMatrixStack(); + PoseStack ms = event.getMatrixStack(); 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() + BakedModel model = mirror.getModel() .get(); - IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); + VertexConsumer builder = buffer.getBuffer(RenderType.solid()); mc.getBlockRenderer() .getModelRenderer() .renderModel(player.level, model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true, - player.level.getRandom(), MathHelper.getSeed(pos), OverlayTexture.NO_OVERLAY, + player.level.getRandom(), Mth.getSeed(pos), OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE); buffer.endBatch(); @@ -135,7 +135,7 @@ public class SymmetryHandler { if (event.phase == Phase.START) return; Minecraft mc = Minecraft.getInstance(); - ClientPlayerEntity player = mc.player; + LocalPlayer player = mc.player; if (mc.level == null) return; @@ -145,7 +145,7 @@ public class SymmetryHandler { tickCounter++; if (tickCounter % 10 == 0) { - for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + for (int i = 0; i < Inventory.getSelectionSize(); i++) { ItemStack stackInSlot = player.inventory.getItem(i); if (stackInSlot != null && AllItems.WAND_OF_SYMMETRY.isIn(stackInSlot) @@ -159,9 +159,9 @@ public class SymmetryHandler { double offsetX = (r.nextDouble() - 0.5) * 0.3; double offsetZ = (r.nextDouble() - 0.5) * 0.3; - Vector3d pos = mirror.getPosition() + Vec3 pos = mirror.getPosition() .add(0.5 + offsetX, 1 / 4d, 0.5 + offsetZ); - Vector3d speed = new Vector3d(0, r.nextDouble() * 1 / 8f, 0); + Vec3 speed = new Vec3(0, r.nextDouble() * 1 / 8f, 0); mc.level.addParticle(ParticleTypes.END_ROD, pos.x, pos.y, pos.z, speed.x, speed.y, speed.z); } } @@ -171,29 +171,29 @@ public class SymmetryHandler { public static void drawEffect(BlockPos from, BlockPos to) { double density = 0.8f; - 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); + Vec3 start = Vec3.atLowerCornerOf(from).add(0.5, 0.5, 0.5); + Vec3 end = Vec3.atLowerCornerOf(to).add(0.5, 0.5, 0.5); + Vec3 diff = end.subtract(start); - Vector3d step = diff.normalize() + Vec3 step = diff.normalize() .scale(density); int steps = (int) (diff.length() / step.length()); Random r = new Random(); for (int i = 3; i < steps - 1; i++) { - Vector3d pos = start.add(step.scale(i)); - Vector3d speed = new Vector3d(0, r.nextDouble() * -40f, 0); + Vec3 pos = start.add(step.scale(i)); + Vec3 speed = new Vec3(0, r.nextDouble() * -40f, 0); - Minecraft.getInstance().level.addParticle(new RedstoneParticleData(1, 1, 1, 1), pos.x, pos.y, pos.z, + Minecraft.getInstance().level.addParticle(new DustParticleOptions(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)); + Vec3 speed = new Vec3(0, r.nextDouble() * 1 / 32f, 0); + Vec3 pos = start.add(step.scale(2)); 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); + speed = new Vec3(0, r.nextDouble() * 1 / 32f, 0); pos = start.add(step.scale(steps)); 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 c2a39906a..2e5354767 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 @@ -19,27 +19,27 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.material.Material; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.Rarity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.Rarity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.BlockSnapshot; @@ -48,6 +48,8 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.PacketDistributor; +import net.minecraft.world.item.Item.Properties; + public class SymmetryWandItem extends Item { public static final String SYMMETRY = "symmetry"; @@ -60,11 +62,11 @@ public class SymmetryWandItem extends Item { @Nonnull @Override - public ActionResultType useOn(ItemUseContext context) { - PlayerEntity player = context.getPlayer(); + public InteractionResult useOn(UseOnContext context) { + Player player = context.getPlayer(); BlockPos pos = context.getClickedPos(); if (player == null) - return ActionResultType.PASS; + return InteractionResult.PASS; player.getCooldowns() .addCooldown(this, 5); ItemStack wand = player.getItemInHand(context.getHand()); @@ -79,13 +81,13 @@ public class SymmetryWandItem extends Item { player.getCooldowns() .addCooldown(this, 5); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - if (context.getLevel().isClientSide || context.getHand() != Hand.MAIN_HAND) - return ActionResultType.SUCCESS; + if (context.getLevel().isClientSide || context.getHand() != InteractionHand.MAIN_HAND) + return InteractionResult.SUCCESS; - CompoundNBT compound = wand.getTag() + CompoundTag compound = wand.getTag() .getCompound(SYMMETRY); pos = pos.relative(context.getClickedFace()); SymmetryMirror previousElement = SymmetryMirror.fromNBT(compound); @@ -93,7 +95,7 @@ public class SymmetryWandItem extends Item { // No Shift -> Make / Move Mirror wand.getTag() .putBoolean(ENABLE, true); - Vector3d pos3d = new Vector3d(pos.getX(), pos.getY(), pos.getZ()); + Vec3 pos3d = new Vec3(pos.getX(), pos.getY(), pos.getZ()); SymmetryMirror newElement = new PlaneMirror(pos3d); if (previousElement instanceof EmptyMirror) { @@ -131,11 +133,11 @@ public class SymmetryWandItem extends Item { .put(SYMMETRY, compound); player.setItemInHand(context.getHand(), wand); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { + public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { ItemStack wand = playerIn.getItemInHand(handIn); checkNBT(wand); @@ -148,26 +150,26 @@ public class SymmetryWandItem extends Item { playerIn.getCooldowns() .addCooldown(this, 5); } - return new ActionResult(ActionResultType.SUCCESS, wand); + return new InteractionResultHolder(InteractionResult.SUCCESS, wand); } // No Shift -> Clear Mirror wand.getTag() .putBoolean(ENABLE, false); - return new ActionResult(ActionResultType.SUCCESS, wand); + return new InteractionResultHolder(InteractionResult.SUCCESS, wand); } @OnlyIn(Dist.CLIENT) - private void openWandGUI(ItemStack wand, Hand hand) { + private void openWandGUI(ItemStack wand, InteractionHand hand) { ScreenOpener.open(new SymmetryWandScreen(wand, hand)); } private static void checkNBT(ItemStack wand) { if (!wand.hasTag() || !wand.getTag() .contains(SYMMETRY)) { - wand.setTag(new CompoundNBT()); + wand.setTag(new CompoundTag()); wand.getTag() - .put(SYMMETRY, new EmptyMirror(new Vector3d(0, 0, 0)).writeToNbt()); + .put(SYMMETRY, new EmptyMirror(new Vec3(0, 0, 0)).writeToNbt()); wand.getTag() .putBoolean(ENABLE, false); } @@ -175,7 +177,7 @@ public class SymmetryWandItem extends Item { public static boolean isEnabled(ItemStack stack) { checkNBT(stack); - CompoundNBT tag = stack.getTag(); + CompoundTag tag = stack.getTag(); return tag.getBoolean(ENABLE) && !tag.getBoolean("Simulate"); } @@ -190,7 +192,7 @@ public class SymmetryWandItem extends Item { stack.getTag().put(SYMMETRY, mirror.writeToNbt()); } - public static void apply(World world, ItemStack wand, PlayerEntity player, BlockPos pos, BlockState block) { + public static void apply(Level world, ItemStack wand, Player player, BlockPos pos, BlockState block) { checkNBT(wand); if (!isEnabled(wand)) return; @@ -199,11 +201,11 @@ public class SymmetryWandItem extends Item { Map blockSet = new HashMap<>(); blockSet.put(pos, block); - SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundNBT) wand.getTag() + SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundTag) wand.getTag() .getCompound(SYMMETRY)); - Vector3d mirrorPos = symmetry.getPosition(); - if (mirrorPos.distanceTo(Vector3d.atLowerCornerOf(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) + Vec3 mirrorPos = symmetry.getPosition(); + if (mirrorPos.distanceTo(Vec3.atLowerCornerOf(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) return; if (!player.isCreative() && isHoldingBlock(player, block) && BlockHelper.findAndRemoveInInventory(block, player, 1) == 0) @@ -218,7 +220,7 @@ public class SymmetryWandItem extends Item { if (position.equals(pos)) continue; - if (world.isUnobstructed(block, position, ISelectionContext.of(player))) { + if (world.isUnobstructed(block, position, CollisionContext.of(player))) { BlockState blockState = blockSet.get(position); for (Direction face : Iterate.directions) blockState = blockState.updateShape(face, world.getBlockState(position.relative(face)), world, @@ -253,7 +255,7 @@ public class SymmetryWandItem extends Item { world.setBlock(position, ifluidstate.createLegacyBlock(), BlockFlags.UPDATE_NEIGHBORS); world.setBlockAndUpdate(position, blockState); - CompoundNBT wandNbt = wand.getOrCreateTag(); + CompoundTag wandNbt = wand.getOrCreateTag(); wandNbt.putBoolean("Simulate", true); boolean placeInterrupted = ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP); wandNbt.putBoolean("Simulate", false); @@ -270,7 +272,7 @@ public class SymmetryWandItem extends Item { new SymmetryEffectPacket(to, targets)); } - private static boolean isHoldingBlock(PlayerEntity player, BlockState block) { + private static boolean isHoldingBlock(Player player, BlockState block) { ItemStack itemBlock = BlockHelper.getRequiredItem(block); return player.getMainHandItem() .sameItem(itemBlock) @@ -278,7 +280,7 @@ public class SymmetryWandItem extends Item { .sameItem(itemBlock); } - public static void remove(World world, ItemStack wand, PlayerEntity player, BlockPos pos) { + public static void remove(Level world, ItemStack wand, Player player, BlockPos pos) { BlockState air = Blocks.AIR.defaultBlockState(); BlockState ogBlock = world.getBlockState(pos); checkNBT(wand); @@ -287,11 +289,11 @@ public class SymmetryWandItem extends Item { Map blockSet = new HashMap<>(); blockSet.put(pos, air); - SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundNBT) wand.getTag() + SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundTag) wand.getTag() .getCompound(SYMMETRY)); - Vector3d mirrorPos = symmetry.getPosition(); - if (mirrorPos.distanceTo(Vector3d.atLowerCornerOf(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) + Vec3 mirrorPos = symmetry.getPosition(); + if (mirrorPos.distanceTo(Vec3.atLowerCornerOf(pos)) > AllConfigs.SERVER.curiosities.maxSymmetryWandRange.get()) return; symmetry.process(blockSet); @@ -318,7 +320,7 @@ public class SymmetryWandItem extends Item { .isEmpty()) player.getMainHandItem() .mineBlock(world, blockstate, position, player); - TileEntity tileentity = blockstate.hasTileEntity() ? world.getBlockEntity(position) : null; + BlockEntity 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 875326f8b..8aea04247 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 @@ -1,6 +1,6 @@ package com.simibubi.create.content.curiosities.symmetry; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.curiosities.symmetry.mirror.CrossPlaneMirror; import com.simibubi.create.content.curiosities.symmetry.mirror.EmptyMirror; import com.simibubi.create.content.curiosities.symmetry.mirror.PlaneMirror; @@ -17,12 +17,12 @@ import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class SymmetryWandScreen extends AbstractSimiScreen { @@ -34,19 +34,19 @@ public class SymmetryWandScreen extends AbstractSimiScreen { private Label labelAlign; private IconButton confirmButton; - private final ITextComponent mirrorType = Lang.translate("gui.symmetryWand.mirrorType"); - private final ITextComponent orientation = Lang.translate("gui.symmetryWand.orientation"); + private final Component mirrorType = Lang.translate("gui.symmetryWand.mirrorType"); + private final Component orientation = Lang.translate("gui.symmetryWand.orientation"); private SymmetryMirror currentElement; private ItemStack wand; - private Hand hand; + private InteractionHand hand; - public SymmetryWandScreen(ItemStack wand, Hand hand) { + public SymmetryWandScreen(ItemStack wand, InteractionHand hand) { background = AllGuiTextures.WAND_OF_SYMMETRY; currentElement = SymmetryWandItem.getMirror(wand); if (currentElement instanceof EmptyMirror) { - currentElement = new PlaneMirror(Vector3d.ZERO); + currentElement = new PlaneMirror(Vec3.ZERO); } this.hand = hand; this.wand = wand; @@ -62,9 +62,9 @@ public class SymmetryWandScreen extends AbstractSimiScreen { int x = guiLeft; int y = guiTop; - labelType = new Label(x + 49, y + 28, StringTextComponent.EMPTY).colored(0xFFFFFFFF) + labelType = new Label(x + 49, y + 28, TextComponent.EMPTY).colored(0xFFFFFFFF) .withShadow(); - labelAlign = new Label(x + 49, y + 50, StringTextComponent.EMPTY).colored(0xFFFFFFFF) + labelAlign = new Label(x + 49, y + 50, TextComponent.EMPTY).colored(0xFFFFFFFF) .withShadow(); int state = @@ -115,7 +115,7 @@ public class SymmetryWandScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int x = guiLeft; int y = guiTop; @@ -130,7 +130,7 @@ public class SymmetryWandScreen extends AbstractSimiScreen { .render(ms); } - protected void renderBlock(MatrixStack ms, int x, int y) { + protected void renderBlock(PoseStack ms, int x, int y) { ms.pushPose(); ms.translate(x + 26, y + 39, 20); ms.scale(16, 16, 16); 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 ef8089330..f0b03c9bd 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 @@ -1,22 +1,22 @@ package com.simibubi.create.content.curiosities.symmetry.client; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.Mth; +import com.mojang.math.Vector3f; public class SymmetryWandItemRenderer extends CustomRenderedItemModelRenderer { @Override - protected void render(ItemStack stack, SymmetryWandModel model, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, - MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + protected void render(ItemStack stack, SymmetryWandModel model, PartialItemModelRenderer renderer, ItemTransforms.TransformType transformType, + PoseStack ms, MultiBufferSource buffer, int light, int overlay) { float worldTime = AnimationTickHolder.getRenderTime() / 20; int maxLight = 0xF000F0; @@ -24,7 +24,7 @@ public class SymmetryWandItemRenderer extends CustomRenderedItemModelRenderer getAlignToolTips() { + public List getAlignToolTips() { return ImmutableList.of(Lang.translate("orientation.orthogonal"), Lang.translate("orientation.diagonal")); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java index 779713abb..32c067ce5 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java @@ -7,15 +7,15 @@ import java.util.Map; import com.google.common.collect.ImmutableList; import com.jozufozu.flywheel.core.PartialModel; -import net.minecraft.block.BlockState; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.util.StringRepresentable; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; public class EmptyMirror extends SymmetryMirror { - public static enum Align implements IStringSerializable { + public static enum Align implements StringRepresentable { None("none"); private final String name; @@ -24,7 +24,7 @@ public class EmptyMirror extends SymmetryMirror { @Override public String toString() { return name; } } - public EmptyMirror(Vector3d pos) { + public EmptyMirror(Vec3 pos) { super(pos); orientation = Align.None; } @@ -55,7 +55,7 @@ public class EmptyMirror extends SymmetryMirror { } @Override - public List getAlignToolTips() { + public List getAlignToolTips() { return ImmutableList.of(); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java index 3c4b476d0..7451f779c 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java @@ -7,19 +7,19 @@ import java.util.Map; import com.google.common.collect.ImmutableList; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.util.StringRepresentable; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; public class PlaneMirror extends SymmetryMirror { - public static enum Align implements IStringSerializable { + public static enum Align implements StringRepresentable { XY("xy"), YZ("yz"); private final String name; @@ -39,7 +39,7 @@ public class PlaneMirror extends SymmetryMirror { } } - public PlaneMirror(Vector3d pos) { + public PlaneMirror(Vec3 pos) { super(pos); orientation = Align.XY; } @@ -88,7 +88,7 @@ public class PlaneMirror extends SymmetryMirror { } @Override - public void applyModelTransform(MatrixStack ms) { + public void applyModelTransform(PoseStack ms) { super.applyModelTransform(ms); MatrixTransformStack.of(ms) .centre() @@ -97,7 +97,7 @@ public class PlaneMirror extends SymmetryMirror { } @Override - public List getAlignToolTips() { + public List getAlignToolTips() { return ImmutableList.of(Lang.translate("orientation.alongZ"), Lang.translate("orientation.alongX")); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java index a763b2528..a1231c09d 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java @@ -6,23 +6,23 @@ import java.util.Map; import com.google.common.collect.ImmutableList; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.FloatNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.Property; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.FloatTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; public abstract class SymmetryMirror { @@ -31,27 +31,27 @@ public abstract class SymmetryMirror { public static final String CROSS_PLANE = "cross_plane"; public static final String TRIPLE_PLANE = "triple_plane"; - protected Vector3d position; - protected IStringSerializable orientation; + protected Vec3 position; + protected StringRepresentable orientation; protected int orientationIndex; public boolean enable; - public SymmetryMirror(Vector3d pos) { + public SymmetryMirror(Vec3 pos) { position = pos; enable = true; orientationIndex = 0; } - public static List getMirrors() { + public static List getMirrors() { return ImmutableList.of(Lang.translate("symmetry.mirror.plane"), Lang.translate("symmetry.mirror.doublePlane"), Lang.translate("symmetry.mirror.triplePlane")); } - public IStringSerializable getOrientation() { + public StringRepresentable getOrientation() { return orientation; } - public Vector3d getPosition() { + public Vec3 getPosition() { return position; } @@ -82,21 +82,21 @@ public abstract class SymmetryMirror { public abstract PartialModel getModel(); - public void applyModelTransform(MatrixStack ms) {} + public void applyModelTransform(PoseStack ms) {} private static final String $ORIENTATION = "direction"; private static final String $POSITION = "pos"; private static final String $TYPE = "type"; private static final String $ENABLE = "enable"; - public CompoundNBT writeToNbt() { - CompoundNBT nbt = new CompoundNBT(); + public CompoundTag writeToNbt() { + CompoundTag nbt = new CompoundTag(); nbt.putInt($ORIENTATION, orientationIndex); - ListNBT floatList = new ListNBT(); - floatList.add(FloatNBT.valueOf((float) position.x)); - floatList.add(FloatNBT.valueOf((float) position.y)); - floatList.add(FloatNBT.valueOf((float) position.z)); + ListTag floatList = new ListTag(); + floatList.add(FloatTag.valueOf((float) position.x)); + floatList.add(FloatTag.valueOf((float) position.y)); + floatList.add(FloatTag.valueOf((float) position.z)); nbt.put($POSITION, floatList); nbt.putString($TYPE, typeName()); nbt.putBoolean($ENABLE, enable); @@ -104,9 +104,9 @@ public abstract class SymmetryMirror { return nbt; } - public static SymmetryMirror fromNBT(CompoundNBT nbt) { - ListNBT floatList = nbt.getList($POSITION, 5); - Vector3d pos = new Vector3d(floatList.getFloat(0), floatList.getFloat(1), floatList.getFloat(2)); + public static SymmetryMirror fromNBT(CompoundTag nbt) { + ListTag floatList = nbt.getList($POSITION, 5); + Vec3 pos = new Vec3(floatList.getFloat(0), floatList.getFloat(1), floatList.getFloat(2)); SymmetryMirror element; switch (nbt.getString($TYPE)) { @@ -130,13 +130,13 @@ public abstract class SymmetryMirror { return element; } - protected Vector3d getDiff(BlockPos position) { + protected Vec3 getDiff(BlockPos position) { return this.position.scale(-1) .add(position.getX(), position.getY(), position.getZ()); } protected BlockPos getIDiff(BlockPos position) { - Vector3d diff = getDiff(position); + Vec3 diff = getDiff(position); return new BlockPos((int) diff.x, (int) diff.y, (int) diff.z); } @@ -202,10 +202,10 @@ public abstract class SymmetryMirror { position.getZ() - diff.getZ() - diff.getX()); } - public void setPosition(Vector3d pos3d) { + public void setPosition(Vec3 pos3d) { this.position = pos3d; } - public abstract List getAlignToolTips(); + public abstract List getAlignToolTips(); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java index abf923a58..5b6dcb08e 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java @@ -9,15 +9,15 @@ import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.util.StringRepresentable; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; public class TriplePlaneMirror extends SymmetryMirror { - public TriplePlaneMirror(Vector3d pos) { + public TriplePlaneMirror(Vec3 pos) { super(pos); orientationIndex = 0; } @@ -57,12 +57,12 @@ public class TriplePlaneMirror extends SymmetryMirror { } @Override - public IStringSerializable getOrientation() { + public StringRepresentable getOrientation() { return CrossPlaneMirror.Align.Y; } @Override - public List getAlignToolTips() { + public List getAlignToolTips() { return ImmutableList.of(Lang.translate("orientation.horizontal")); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ItemReturnInvWrapper.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ItemReturnInvWrapper.java index 3b4f24dc3..7110649d7 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ItemReturnInvWrapper.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ItemReturnInvWrapper.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.curiosities.toolbox; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.wrapper.InvWrapper; /** @@ -9,7 +9,7 @@ import net.minecraftforge.items.wrapper.InvWrapper; */ public class ItemReturnInvWrapper extends InvWrapper { - public ItemReturnInvWrapper(IInventory inv) { + public ItemReturnInvWrapper(Container inv) { super(inv); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/RadialToolboxMenu.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/RadialToolboxMenu.java index 406f8cd54..9244aeb0d 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/RadialToolboxMenu.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/RadialToolboxMenu.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.curiosities.toolbox; import java.util.List; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllKeys; @@ -16,14 +16,14 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.util.InputMappings; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; public class RadialToolboxMenu extends AbstractSimiScreen { @@ -56,18 +56,18 @@ public class RadialToolboxMenu extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - float fade = MathHelper.clamp((ticksOpen + AnimationTickHolder.getPartialTicks()) / 10f, 1 / 512f, 1); + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { + float fade = Mth.clamp((ticksOpen + AnimationTickHolder.getPartialTicks()) / 10f, 1 / 512f, 1); hoveredSlot = -1; - MainWindow window = getMinecraft().getWindow(); + Window window = getMinecraft().getWindow(); float hoveredX = mouseX - window.getGuiScaledWidth() / 2; float hoveredY = mouseY - window.getGuiScaledHeight() / 2; float distance = hoveredX * hoveredX + hoveredY * hoveredY; if (distance > 25 && distance < 10000) hoveredSlot = - (MathHelper.floor((AngleHelper.deg(MathHelper.atan2(hoveredY, hoveredX)) + 360 + 180 - 22.5f)) % 360) + (Mth.floor((AngleHelper.deg(Mth.atan2(hoveredY, hoveredX)) + 360 + 180 - 22.5f)) % 360) / 45; boolean renderCenterSlot = state == State.SELECT_ITEM_UNEQUIP; if (scrollMode && distance > 150) @@ -77,7 +77,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen { ms.pushPose(); ms.translate(width / 2, height / 2, 0); - ITextComponent tip = null; + Component tip = null; if (state == State.DETACH) { @@ -100,7 +100,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen { if (!scrollMode && hoveredSlot == UNEQUIP) { AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.draw(ms, this, -13, -13); tip = Lang.translate("toolbox.detach") - .withStyle(TextFormatting.GOLD); + .withStyle(ChatFormatting.GOLD); } ms.popPose(); @@ -118,7 +118,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen { if (!scrollMode && hoveredSlot == DEPOSIT) { AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.draw(ms, this, -13, -13); tip = Lang.translate(state == State.SELECT_BOX ? "toolbox.depositAll" : "toolbox.depositBox") - .withStyle(TextFormatting.GOLD); + .withStyle(ChatFormatting.GOLD); } ms.popPose(); @@ -181,7 +181,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen { AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.draw(ms, this, -13, -13); tip = Lang.translate("toolbox.unequip", minecraft.player.getMainHandItem() .getHoverName()) - .withStyle(TextFormatting.GOLD); + .withStyle(ChatFormatting.GOLD); } ms.popPose(); } @@ -210,7 +210,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen { } @Override - public void renderBackground(MatrixStack p_238651_1_, int p_238651_2_) { + public void renderBackground(PoseStack p_238651_1_, int p_238651_2_) { int a = ((int) (0x50 * Math.min(1, (ticksOpen + AnimationTickHolder.getPartialTicks()) / 20f))) << 24; fillGradient(p_238651_1_, 0, 0, this.width, this.height, 0x101010 | a, 0x101010 | a); } @@ -267,7 +267,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen { @Override public boolean mouseScrolled(double mouseX, double mouseY, double delta) { - MainWindow window = getMinecraft().getWindow(); + Window window = getMinecraft().getWindow(); double hoveredX = mouseX - window.getGuiScaledWidth() / 2; double hoveredY = mouseY - window.getGuiScaledHeight() / 2; double distance = hoveredX * hoveredX + hoveredY * hoveredY; @@ -292,7 +292,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen { if (state == State.DETACH) break; - scrollSlot -= MathHelper.sign(delta); + scrollSlot -= Mth.sign(delta); scrollSlot = (scrollSlot + 8) % 8; } return true; @@ -330,7 +330,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen { @Override public boolean keyReleased(int code, int p_keyPressed_2_, int p_keyPressed_3_) { - InputMappings.Input mouseKey = InputMappings.getKey(code, p_keyPressed_2_); + InputConstants.Key mouseKey = InputConstants.getKey(code, p_keyPressed_2_); if (AllKeys.TOOLBELT.getKeybind() .isActiveAndMatches(mouseKey)) { this.onClose(); diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxBlock.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxBlock.java index d053c9854..9ca384ed0 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxBlock.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxBlock.java @@ -2,9 +2,47 @@ package com.simibubi.create.content.curiosities.toolbox; import static net.minecraft.state.properties.BlockStateProperties.WATERLOGGED; +import javanet.minimport com.simibubi.create.AllBlocks; +import com.simibubi.create.AllShapes; +import com.simibubi.create.AllTileEntities; +import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.utility.BlockHelper; import java.util.Optional; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.fml.network.NetworkHooks; -import com.simibubi.create.AllBlocks; +ecraft.world.level.block.state.properties.BlockStatePropertiesocks; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; @@ -43,7 +81,7 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.network.NetworkHooks; -public class ToolboxBlock extends HorizontalBlock implements IWaterLoggable, ITE { +public class ToolboxBlock extends HorizontalDirectionalBlock implements SimpleWaterloggedBlock, ITE { protected final DyeColor color; @@ -54,8 +92,8 @@ public class ToolboxBlock extends HorizontalBlock implements IWaterLoggable, ITE } @Override - public void fillItemCategory(ItemGroup group, NonNullList p_149666_2_) { - if (group != ItemGroup.TAB_SEARCH && color != DyeColor.BROWN) + public void fillItemCategory(CreativeModeTab group, NonNullList p_149666_2_) { + if (group != CreativeModeTab.TAB_SEARCH && color != DyeColor.BROWN) return; super.fillItemCategory(group, p_149666_2_); } @@ -72,7 +110,7 @@ public class ToolboxBlock extends HorizontalBlock implements IWaterLoggable, ITE } @Override - public void setPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { + public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { super.setPlacedBy(worldIn, pos, state, placer, stack); if (worldIn.isClientSide) return; @@ -87,19 +125,19 @@ public class ToolboxBlock extends HorizontalBlock implements IWaterLoggable, ITE } @Override - public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean moving) { + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moving) { if (state.hasTileEntity() && (!newState.hasTileEntity() || !(newState.getBlock() instanceof ToolboxBlock))) world.removeBlockEntity(pos); } @Override - public void attack(BlockState state, World world, BlockPos pos, PlayerEntity player) { + public void attack(BlockState state, Level world, BlockPos pos, Player player) { if (player instanceof FakePlayer) return; if (world.isClientSide) return; withTileEntityDo(world, pos, ToolboxTileEntity::unequipTracked); - if (world instanceof ServerWorld) { + if (world instanceof ServerLevel) { ItemStack cloneItemStack = getCloneItemStack(world, pos, state); world.destroyBlock(pos, false); if (world.getBlockState(pos) != state) @@ -108,16 +146,16 @@ public class ToolboxBlock extends HorizontalBlock implements IWaterLoggable, ITE } @Override - public ItemStack getCloneItemStack(IBlockReader world, BlockPos pos, BlockState state) { + public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { ItemStack item = new ItemStack(this); Optional tileEntityOptional = getTileEntityOptional(world, pos); - CompoundNBT tag = item.getOrCreateTag(); - CompoundNBT inv = tileEntityOptional.map(tb -> tb.inventory.serializeNBT()) - .orElse(new CompoundNBT()); + CompoundTag tag = item.getOrCreateTag(); + CompoundTag inv = tileEntityOptional.map(tb -> tb.inventory.serializeNBT()) + .orElse(new CompoundTag()); tag.put("Inventory", inv); - ITextComponent customName = tileEntityOptional.map(ToolboxTileEntity::getCustomName) + Component customName = tileEntityOptional.map(ToolboxTileEntity::getCustomName) .orElse(null); if (customName != null) item.setHoverName(customName); @@ -125,7 +163,7 @@ public class ToolboxBlock extends HorizontalBlock implements IWaterLoggable, ITE } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) { if (state.getValue(WATERLOGGED)) world.getLiquidTicks() @@ -134,8 +172,8 @@ public class ToolboxBlock extends HorizontalBlock implements IWaterLoggable, ITE } @Override - public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, - ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, + CollisionContext context) { return AllShapes.TOOLBOX.get(state.getValue(FACING)); } @@ -145,39 +183,39 @@ public class ToolboxBlock extends HorizontalBlock implements IWaterLoggable, ITE } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult ray) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult ray) { if (player == null || player.isCrouching()) - return ActionResultType.PASS; + return InteractionResult.PASS; ItemStack stack = player.getItemInHand(hand); DyeColor color = DyeColor.getColor(stack); if (color != null && color != this.color) { if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; BlockState newState = BlockHelper.copyProperties(state, AllBlocks.TOOLBOXES.get(color).getDefaultState()); world.setBlockAndUpdate(pos, newState); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (player instanceof FakePlayer) - return ActionResultType.PASS; + return InteractionResult.PASS; if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; withTileEntityDo(world, pos, - toolbox -> NetworkHooks.openGui((ServerPlayerEntity) player, toolbox, toolbox::sendToContainer)); - return ActionResultType.SUCCESS; + toolbox -> NetworkHooks.openGui((ServerPlayer) player, toolbox, toolbox::sendToContainer)); + return InteractionResult.SUCCESS; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.TOOLBOX.create(); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { FluidState ifluidstate = context.getLevel() .getFluidState(context.getClickedPos()); return super.getStateForPlacement(context).setValue(FACING, context.getHorizontalDirection() diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxContainer.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxContainer.java index 7856d3bec..3fedd0422 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxContainer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxContainer.java @@ -6,41 +6,41 @@ import com.simibubi.create.AllContainerTypes; import com.simibubi.create.foundation.gui.ContainerBase; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ClickType; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; import net.minecraftforge.items.SlotItemHandler; public class ToolboxContainer extends ContainerBase { - public static ToolboxContainer create(int id, PlayerInventory inv, ToolboxTileEntity te) { + public static ToolboxContainer create(int id, Inventory inv, ToolboxTileEntity te) { return new ToolboxContainer(AllContainerTypes.TOOLBOX.get(), id, inv, te); } - public ToolboxContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + public ToolboxContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { super(type, id, inv, extraData); } - public ToolboxContainer(ContainerType type, int id, PlayerInventory inv, ToolboxTileEntity te) { + public ToolboxContainer(MenuType type, int id, Inventory inv, ToolboxTileEntity te) { super(type, id, inv, te); te.startOpen(player); } @Override - protected ToolboxTileEntity createOnClient(PacketBuffer extraData) { + protected ToolboxTileEntity createOnClient(FriendlyByteBuf extraData) { BlockPos readBlockPos = extraData.readBlockPos(); - CompoundNBT readNbt = extraData.readNbt(); + CompoundTag readNbt = extraData.readNbt(); - ClientWorld world = Minecraft.getInstance().level; - TileEntity tileEntity = world.getBlockEntity(readBlockPos); + ClientLevel world = Minecraft.getInstance().level; + BlockEntity tileEntity = world.getBlockEntity(readBlockPos); if (tileEntity instanceof ToolboxTileEntity) { ToolboxTileEntity toolbox = (ToolboxTileEntity) tileEntity; toolbox.handleUpdateTag(toolbox.getBlockState(), readNbt); @@ -51,7 +51,7 @@ public class ToolboxContainer extends ContainerBase { } @Override - public ItemStack quickMoveStack(PlayerEntity player, int index) { + public ItemStack quickMoveStack(Player player, int index) { Slot clickedSlot = getSlot(index); if (!clickedSlot.hasItem()) return ItemStack.EMPTY; @@ -73,13 +73,13 @@ public class ToolboxContainer extends ContainerBase { } @Override - public ItemStack clicked(int index, int flags, ClickType type, PlayerEntity player) { + public ItemStack clicked(int index, int flags, ClickType type, Player player) { int size = contentHolder.inventory.getSlots(); if (index >= 0 && index < size) { ItemStack itemInClickedSlot = getSlot(index).getItem(); - PlayerInventory playerInv = player.inventory; + Inventory playerInv = player.inventory; ItemStack carried = playerInv.getCarried(); if (type == ClickType.PICKUP && !carried.isEmpty() && !itemInClickedSlot.isEmpty() @@ -149,7 +149,7 @@ public class ToolboxContainer extends ContainerBase { } @Override - public void removed(PlayerEntity playerIn) { + public void removed(Player playerIn) { super.removed(playerIn); if (!playerIn.level.isClientSide) contentHolder.stopOpen(playerIn); diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxDisposeAllPacket.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxDisposeAllPacket.java index 071c61df6..55d8eaec8 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxDisposeAllPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxDisposeAllPacket.java @@ -6,14 +6,14 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.network.NetworkEvent.Context; import net.minecraftforge.items.ItemHandlerHelper; @@ -25,12 +25,12 @@ public class ToolboxDisposeAllPacket extends SimplePacketBase { this.toolboxPos = toolboxPos; } - public ToolboxDisposeAllPacket(PacketBuffer buffer) { + public ToolboxDisposeAllPacket(FriendlyByteBuf buffer) { toolboxPos = buffer.readBlockPos(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBlockPos(toolboxPos); } @@ -38,9 +38,9 @@ public class ToolboxDisposeAllPacket extends SimplePacketBase { public void handle(Supplier context) { Context ctx = context.get(); ctx.enqueueWork(() -> { - ServerPlayerEntity player = ctx.getSender(); - World world = player.level; - TileEntity blockEntity = world.getBlockEntity(toolboxPos); + ServerPlayer player = ctx.getSender(); + Level world = player.level; + BlockEntity blockEntity = world.getBlockEntity(toolboxPos); double maxRange = ToolboxHandler.getMaxRange(player); if (player.distanceToSqr(toolboxPos.getX() + 0.5, toolboxPos.getY(), toolboxPos.getZ() + 0.5) > maxRange @@ -50,14 +50,14 @@ public class ToolboxDisposeAllPacket extends SimplePacketBase { return; ToolboxTileEntity toolbox = (ToolboxTileEntity) blockEntity; - CompoundNBT compound = player.getPersistentData() + CompoundTag compound = player.getPersistentData() .getCompound("CreateToolboxData"); MutableBoolean sendData = new MutableBoolean(false); toolbox.inventory.inLimitedMode(inventory -> { for (int i = 0; i < 36; i++) { String key = String.valueOf(i); - if (compound.contains(key) && NBTUtil.readBlockPos(compound.getCompound(key) + if (compound.contains(key) && NbtUtils.readBlockPos(compound.getCompound(key) .getCompound("Pos")) .equals(toolboxPos)) { ToolboxHandler.unequip(player, i, true); diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxDyeingRecipe.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxDyeingRecipe.java index f70e9afe3..7cc177a56 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxDyeingRecipe.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxDyeingRecipe.java @@ -3,24 +3,24 @@ package com.simibubi.create.content.curiosities.toolbox; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllRecipeTypes; -import net.minecraft.block.Block; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.SpecialRecipe; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import net.minecraftforge.common.Tags; -public class ToolboxDyeingRecipe extends SpecialRecipe { +public class ToolboxDyeingRecipe extends CustomRecipe { public ToolboxDyeingRecipe(ResourceLocation rl) { super(rl); } @Override - public boolean matches(CraftingInventory inventory, World world) { + public boolean matches(CraftingContainer inventory, Level world) { int toolboxes = 0; int dyes = 0; @@ -47,7 +47,7 @@ public class ToolboxDyeingRecipe extends SpecialRecipe { } @Override - public ItemStack assemble(CraftingInventory inventory) { + public ItemStack assemble(CraftingContainer inventory) { ItemStack toolbox = ItemStack.EMPTY; DyeColor color = DyeColor.BROWN; @@ -79,7 +79,7 @@ public class ToolboxDyeingRecipe extends SpecialRecipe { } @Override - public IRecipeSerializer getSerializer() { + public RecipeSerializer getSerializer() { return AllRecipeTypes.TOOLBOX_DYEING.getSerializer(); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxEquipPacket.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxEquipPacket.java index 1c3b39e7a..fdb64380b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxEquipPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxEquipPacket.java @@ -4,14 +4,14 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.network.NetworkEvent.Context; import net.minecraftforge.items.ItemHandlerHelper; @@ -27,7 +27,7 @@ public class ToolboxEquipPacket extends SimplePacketBase { this.hotbarSlot = hotbarSlot; } - public ToolboxEquipPacket(PacketBuffer buffer) { + public ToolboxEquipPacket(FriendlyByteBuf buffer) { if (buffer.readBoolean()) toolboxPos = buffer.readBlockPos(); slot = buffer.readVarInt(); @@ -35,7 +35,7 @@ public class ToolboxEquipPacket extends SimplePacketBase { } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBoolean(toolboxPos != null); if (toolboxPos != null) buffer.writeBlockPos(toolboxPos); @@ -47,8 +47,8 @@ public class ToolboxEquipPacket extends SimplePacketBase { public void handle(Supplier context) { Context ctx = context.get(); ctx.enqueueWork(() -> { - ServerPlayerEntity player = ctx.getSender(); - World world = player.level; + ServerPlayer player = ctx.getSender(); + Level world = player.level; if (toolboxPos == null) { ToolboxHandler.unequip(player, hotbarSlot, false); @@ -56,7 +56,7 @@ public class ToolboxEquipPacket extends SimplePacketBase { return; } - TileEntity blockEntity = world.getBlockEntity(toolboxPos); + BlockEntity blockEntity = world.getBlockEntity(toolboxPos); double maxRange = ToolboxHandler.getMaxRange(player); if (player.distanceToSqr(toolboxPos.getX() + 0.5, toolboxPos.getY(), toolboxPos.getZ() + 0.5) > maxRange @@ -87,13 +87,13 @@ public class ToolboxEquipPacket extends SimplePacketBase { }); } - CompoundNBT compound = player.getPersistentData() + CompoundTag compound = player.getPersistentData() .getCompound("CreateToolboxData"); String key = String.valueOf(hotbarSlot); - CompoundNBT data = new CompoundNBT(); + CompoundTag data = new CompoundTag(); data.putInt("Slot", slot); - data.put("Pos", NBTUtil.writeBlockPos(toolboxPos)); + data.put("Pos", NbtUtils.writeBlockPos(toolboxPos)); compound.put(key, data); player.getPersistentData() diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java index e21a775be..5eb72dcbd 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandler.java @@ -9,17 +9,17 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.ISyncPersistentData; import com.simibubi.create.foundation.utility.WorldAttached; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.fml.network.PacketDistributor; public class ToolboxHandler { @@ -39,31 +39,31 @@ public class ToolboxHandler { static int validationTimer = 20; - public static void entityTick(Entity entity, World world) { + public static void entityTick(Entity entity, Level world) { if (world.isClientSide) return; - if (!(world instanceof ServerWorld)) + if (!(world instanceof ServerLevel)) return; - if (!(entity instanceof ServerPlayerEntity)) + if (!(entity instanceof ServerPlayer)) return; if (entity.tickCount % validationTimer != 0) return; - ServerPlayerEntity player = (ServerPlayerEntity) entity; + ServerPlayer player = (ServerPlayer) entity; if (!player.getPersistentData() .contains("CreateToolboxData")) return; boolean sendData = false; - CompoundNBT compound = player.getPersistentData() + CompoundTag compound = player.getPersistentData() .getCompound("CreateToolboxData"); for (int i = 0; i < 9; i++) { String key = String.valueOf(i); if (!compound.contains(key)) continue; - CompoundNBT data = compound.getCompound(key); - BlockPos pos = NBTUtil.readBlockPos(data.getCompound("Pos")); + CompoundTag data = compound.getCompound(key); + BlockPos pos = NbtUtils.readBlockPos(data.getCompound("Pos")); int slot = data.getInt("Slot"); if (!world.isAreaLoaded(pos, 0)) @@ -75,7 +75,7 @@ public class ToolboxHandler { continue; } - TileEntity prevBlockEntity = world.getBlockEntity(pos); + BlockEntity prevBlockEntity = world.getBlockEntity(pos); if (prevBlockEntity instanceof ToolboxTileEntity) ((ToolboxTileEntity) prevBlockEntity).connectPlayer(slot, player, i); } @@ -84,8 +84,8 @@ public class ToolboxHandler { syncData(player); } - public static void playerLogin(PlayerEntity player) { - if (!(player instanceof ServerPlayerEntity)) + public static void playerLogin(Player player) { + if (!(player instanceof ServerPlayer)) return; if (player.getPersistentData() .contains("CreateToolboxData") @@ -96,13 +96,13 @@ public class ToolboxHandler { } } - public static void syncData(PlayerEntity player) { - AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), + public static void syncData(Player player) { + AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new ISyncPersistentData.Packet(player)); } - public static List getNearest(IWorld world, PlayerEntity player, int maxAmount) { - Vector3d location = player.position(); + public static List getNearest(LevelAccessor world, Player player, int maxAmount) { + Vec3 location = player.position(); double maxRange = getMaxRange(player); return toolboxes.get(world) .keySet() @@ -114,19 +114,19 @@ public class ToolboxHandler { .collect(Collectors.toList()); } - public static void unequip(PlayerEntity player, int hotbarSlot, boolean keepItems) { - CompoundNBT compound = player.getPersistentData() + public static void unequip(Player player, int hotbarSlot, boolean keepItems) { + CompoundTag compound = player.getPersistentData() .getCompound("CreateToolboxData"); - World world = player.level; + Level world = player.level; String key = String.valueOf(hotbarSlot); if (!compound.contains(key)) return; - CompoundNBT prevData = compound.getCompound(key); - BlockPos prevPos = NBTUtil.readBlockPos(prevData.getCompound("Pos")); + CompoundTag prevData = compound.getCompound(key); + BlockPos prevPos = NbtUtils.readBlockPos(prevData.getCompound("Pos")); int prevSlot = prevData.getInt("Slot"); - TileEntity prevBlockEntity = world.getBlockEntity(prevPos); + BlockEntity prevBlockEntity = world.getBlockEntity(prevPos); if (prevBlockEntity instanceof ToolboxTileEntity) { ToolboxTileEntity toolbox = (ToolboxTileEntity) prevBlockEntity; toolbox.unequip(prevSlot, player, hotbarSlot, keepItems || !ToolboxHandler.withinRange(player, toolbox)); @@ -134,18 +134,18 @@ public class ToolboxHandler { compound.remove(key); } - public static boolean withinRange(PlayerEntity player, ToolboxTileEntity box) { + public static boolean withinRange(Player player, ToolboxTileEntity box) { if (player.level != box.getLevel()) return false; double maxRange = getMaxRange(player); return distance(player.position(), box.getBlockPos()) < maxRange * maxRange; } - public static double distance(Vector3d location, BlockPos p) { + public static double distance(Vec3 location, BlockPos p) { return location.distanceToSqr(p.getX() + 0.5f, p.getY(), p.getZ() + 0.5f); } - public static double getMaxRange(PlayerEntity player) { + public static double getMaxRange(Player player) { return AllConfigs.SERVER.curiosities.toolboxRange.get() .doubleValue(); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java index 741eb326b..b36fbfde6 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxHandlerClient.java @@ -8,30 +8,30 @@ import static com.simibubi.create.foundation.gui.AllGuiTextures.TOOLBELT_SELECTE import java.util.List; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllKeys; import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.networking.AllPackets; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.client.MainWindow; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.level.Level; public class ToolboxHandlerClient { @@ -44,13 +44,13 @@ public class ToolboxHandlerClient { public static boolean onPickItem() { Minecraft mc = Minecraft.getInstance(); - ClientPlayerEntity player = mc.player; + LocalPlayer player = mc.player; if (player == null) return false; - World level = player.level; - RayTraceResult hitResult = mc.hitResult; + Level level = player.level; + HitResult hitResult = mc.hitResult; - if (hitResult == null || hitResult.getType() == RayTraceResult.Type.MISS) + if (hitResult == null || hitResult.getType() == HitResult.Type.MISS) return false; if (player.isCreative()) return false; @@ -61,15 +61,15 @@ public class ToolboxHandlerClient { if (toolboxes.isEmpty()) return false; - if (hitResult.getType() == RayTraceResult.Type.BLOCK) { - BlockPos pos = ((BlockRayTraceResult) hitResult).getBlockPos(); + if (hitResult.getType() == HitResult.Type.BLOCK) { + BlockPos pos = ((BlockHitResult) hitResult).getBlockPos(); BlockState state = level.getBlockState(pos); if (state.getMaterial() == Material.AIR) return false; result = state.getPickBlock(hitResult, level, pos, player); - } else if (hitResult.getType() == RayTraceResult.Type.ENTITY) { - Entity entity = ((EntityRayTraceResult) hitResult).getEntity(); + } else if (hitResult.getType() == HitResult.Type.ENTITY) { + Entity entity = ((EntityHitResult) hitResult).getEntity(); result = entity.getPickedResult(hitResult); } @@ -102,26 +102,26 @@ public class ToolboxHandlerClient { return; if (COOLDOWN > 0) return; - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (player == null) return; - World level = player.level; + Level level = player.level; List toolboxes = ToolboxHandler.getNearest(player.level, player, 8); - CompoundNBT compound = player.getPersistentData() + CompoundTag compound = player.getPersistentData() .getCompound("CreateToolboxData"); String slotKey = String.valueOf(player.inventory.selected); boolean equipped = compound.contains(slotKey); if (equipped) { - BlockPos pos = NBTUtil.readBlockPos(compound.getCompound(slotKey) + BlockPos pos = NbtUtils.readBlockPos(compound.getCompound(slotKey) .getCompound("Pos")); double max = ToolboxHandler.getMaxRange(player); boolean canReachToolbox = ToolboxHandler.distance(player.position(), pos) < max * max; if (canReachToolbox) { - TileEntity blockEntity = level.getBlockEntity(pos); + BlockEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof ToolboxTileEntity) { RadialToolboxMenu screen = new RadialToolboxMenu(ImmutableList.of((ToolboxTileEntity) blockEntity), RadialToolboxMenu.State.SELECT_ITEM_UNEQUIP); @@ -145,20 +145,20 @@ public class ToolboxHandlerClient { ScreenOpener.open(new RadialToolboxMenu(toolboxes, RadialToolboxMenu.State.SELECT_BOX)); } - public static void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, + public static void renderOverlay(PoseStack ms, MultiBufferSource buffer, int light, int overlay, float partialTicks) { - MainWindow mainWindow = Minecraft.getInstance() + Window mainWindow = Minecraft.getInstance() .getWindow(); int x = mainWindow.getGuiScaledWidth() / 2 - 90; int y = mainWindow.getGuiScaledHeight() - 23; RenderSystem.enableDepthTest(); - PlayerEntity player = Minecraft.getInstance().player; - CompoundNBT persistentData = player.getPersistentData(); + Player player = Minecraft.getInstance().player; + CompoundTag persistentData = player.getPersistentData(); if (!persistentData.contains("CreateToolboxData")) return; - CompoundNBT compound = player.getPersistentData() + CompoundTag compound = player.getPersistentData() .getCompound("CreateToolboxData"); if (compound.isEmpty()) @@ -169,7 +169,7 @@ public class ToolboxHandlerClient { String key = String.valueOf(slot); if (!compound.contains(key)) continue; - BlockPos pos = NBTUtil.readBlockPos(compound.getCompound(key) + BlockPos pos = NbtUtils.readBlockPos(compound.getCompound(key) .getCompound("Pos")); double max = ToolboxHandler.getMaxRange(player); boolean selected = player.inventory.selected == slot; diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxInventory.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxInventory.java index a1c4dffec..18f6175f6 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxInventory.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxInventory.java @@ -10,8 +10,8 @@ import com.simibubi.create.AllItems; import com.simibubi.create.AllTags.AllItemTags; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; @@ -128,8 +128,8 @@ public class ToolboxInventory extends ItemStackHandler { } @Override - public CompoundNBT serializeNBT() { - CompoundNBT compound = super.serializeNBT(); + public CompoundTag serializeNBT() { + CompoundTag compound = super.serializeNBT(); compound.put("Compartments", NBTHelper.writeItemList(filters)); return compound; } @@ -142,7 +142,7 @@ public class ToolboxInventory extends ItemStackHandler { } @Override - public void deserializeNBT(CompoundNBT nbt) { + public void deserializeNBT(CompoundTag nbt) { filters = NBTHelper.readItemList(nbt.getList("Compartments", NBT.TAG_COMPOUND)); if (filters.size() != 8) { filters.clear(); diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxRenderer.java index 01b3d19ce..7f82efb77 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxRenderer.java @@ -1,28 +1,28 @@ package com.simibubi.create.content.curiosities.toolbox; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; public class ToolboxRenderer extends SmartTileEntityRenderer { - public ToolboxRenderer(TileEntityRendererDispatcher dispatcher) { + public ToolboxRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(ToolboxTileEntity tileEntityIn, float partialTicks, MatrixStack ms, - IRenderTypeBuffer buffer, int light, int overlay) { + protected void renderSafe(ToolboxTileEntity tileEntityIn, float partialTicks, PoseStack ms, + MultiBufferSource buffer, int light, int overlay) { BlockState blockState = tileEntityIn.getBlockState(); Direction facing = blockState.getValue(ToolboxBlock.FACING) @@ -34,7 +34,7 @@ public class ToolboxRenderer extends SmartTileEntityRenderer float lidAngle = tileEntityIn.lid.getValue(partialTicks); float drawerOffset = tileEntityIn.drawers.getValue(partialTicks); - IVertexBuilder builder = buffer.getBuffer(RenderType.cutoutMipped()); + VertexConsumer builder = buffer.getBuffer(RenderType.cutoutMipped()); lid.matrixStacker() .centre() .rotateY(-facing.toYRot()) diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxScreen.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxScreen.java index a6ecd7889..f279f6940 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxScreen.java @@ -5,7 +5,7 @@ import java.util.List; import com.google.common.collect.ImmutableList; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; @@ -18,12 +18,12 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.chat.Component; public class ToolboxScreen extends AbstractSimiContainerScreen { @@ -34,9 +34,9 @@ public class ToolboxScreen extends AbstractSimiContainerScreen private IconButton disposeButton; private DyeColor color; - private List extraAreas = Collections.emptyList(); + private List extraAreas = Collections.emptyList(); - public ToolboxScreen(ToolboxContainer container, PlayerInventory inv, ITextComponent title) { + public ToolboxScreen(ToolboxContainer container, Inventory inv, Component title) { super(container, inv, title); init(); } @@ -53,12 +53,12 @@ public class ToolboxScreen extends AbstractSimiContainerScreen widgets.add(disposeButton); color = menu.contentHolder.getColor(); - extraAreas = ImmutableList.of(new Rectangle2d(getGuiLeft() + -28, getGuiTop() + 141, 80, 100), - new Rectangle2d(getGuiLeft() + 162, getGuiTop() + 111, 100, 70)); + extraAreas = ImmutableList.of(new Rect2i(getGuiLeft() + -28, getGuiTop() + 141, 80, 100), + new Rect2i(getGuiLeft() + 162, getGuiTop() + 111, 100, 70)); } @Override - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { menu.renderPass = true; super.render(matrixStack, mouseX, mouseY, partialTicks); menu.renderPass = false; @@ -70,7 +70,7 @@ public class ToolboxScreen extends AbstractSimiContainerScreen } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { BG.draw(ms, this, leftPos + 10, topPos); PLAYER.draw(ms, this, leftPos + (BG.width - PLAYER.width) / 2 - 26, topPos + imageHeight - PLAYER.height); font.draw(ms, title, leftPos + 24, topPos + 4, 0x442000); @@ -113,7 +113,7 @@ public class ToolboxScreen extends AbstractSimiContainerScreen } } - private void renderToolbox(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + private void renderToolbox(PoseStack ms, int mouseX, int mouseY, float partialTicks) { ms.pushPose(); ms.translate(leftPos + 247, topPos + 180, 100); MatrixTransformStack.of(ms) @@ -146,7 +146,7 @@ public class ToolboxScreen extends AbstractSimiContainerScreen } @Override - protected void renderWindowForeground(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowForeground(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { if (hoveredToolboxSlot != null) hoveredSlot = hoveredToolboxSlot; super.renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks); @@ -171,7 +171,7 @@ public class ToolboxScreen extends AbstractSimiContainerScreen } @Override - public List getExtraAreas() { + public List getExtraAreas() { return extraAreas; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxTileEntity.java index d14e83214..61e3b1f39 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxTileEntity.java @@ -17,30 +17,30 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.INameable; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.world.Nameable; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; -public class ToolboxTileEntity extends SmartTileEntity implements INamedContainerProvider, INameable { +public class ToolboxTileEntity extends SmartTileEntity implements MenuProvider, Nameable { public LerpedFloat lid = LerpedFloat.linear() .startWithValue(0); @@ -53,11 +53,11 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine ResetableLazy colorProvider; protected int openCount; - Map> connectedPlayers; + Map> connectedPlayers; - private ITextComponent customName; + private Component customName; - public ToolboxTileEntity(TileEntityType tileEntityTypeIn) { + public ToolboxTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); connectedPlayers = new HashMap<>(); inventory = new ToolboxInventory(this); @@ -108,21 +108,21 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine private void tickPlayers() { boolean update = false; - for (Iterator>> toolboxSlots = connectedPlayers.entrySet() + for (Iterator>> toolboxSlots = connectedPlayers.entrySet() .iterator(); toolboxSlots.hasNext();) { - Entry> toolboxSlotEntry = toolboxSlots.next(); - WeakHashMap set = toolboxSlotEntry.getValue(); + Entry> toolboxSlotEntry = toolboxSlots.next(); + WeakHashMap set = toolboxSlotEntry.getValue(); int slot = toolboxSlotEntry.getKey(); ItemStack referenceItem = inventory.filters.get(slot); boolean clear = referenceItem.isEmpty(); - for (Iterator> playerEntries = set.entrySet() + for (Iterator> playerEntries = set.entrySet() .iterator(); playerEntries.hasNext();) { - Entry playerEntry = playerEntries.next(); + Entry playerEntry = playerEntries.next(); - PlayerEntity player = playerEntry.getKey(); + Player player = playerEntry.getKey(); int hotbarSlot = playerEntry.getValue(); if (!clear && !ToolboxHandler.withinRange(player, this)) @@ -136,7 +136,7 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine .getCompound("CreateToolboxData") .remove(String.valueOf(hotbarSlot)); playerEntries.remove(); - if (player instanceof ServerPlayerEntity) + if (player instanceof ServerPlayer) ToolboxHandler.syncData(player); continue; } @@ -199,7 +199,7 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine } - private boolean isOpenInContainer(PlayerEntity player) { + private boolean isOpenInContainer(Player player) { return player.containerMenu instanceof ToolboxContainer && ((ToolboxContainer) player.containerMenu).contentHolder == this; } @@ -208,33 +208,33 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine if (level.isClientSide) return; - Set affected = new HashSet<>(); + Set affected = new HashSet<>(); - for (Iterator>> toolboxSlots = connectedPlayers.entrySet() + for (Iterator>> toolboxSlots = connectedPlayers.entrySet() .iterator(); toolboxSlots.hasNext();) { - Entry> toolboxSlotEntry = toolboxSlots.next(); - WeakHashMap set = toolboxSlotEntry.getValue(); + Entry> toolboxSlotEntry = toolboxSlots.next(); + WeakHashMap set = toolboxSlotEntry.getValue(); - for (Iterator> playerEntries = set.entrySet() + for (Iterator> playerEntries = set.entrySet() .iterator(); playerEntries.hasNext();) { - Entry playerEntry = playerEntries.next(); + Entry playerEntry = playerEntries.next(); - PlayerEntity player = playerEntry.getKey(); + Player player = playerEntry.getKey(); int hotbarSlot = playerEntry.getValue(); ToolboxHandler.unequip(player, hotbarSlot, false); - if (player instanceof ServerPlayerEntity) - affected.add((ServerPlayerEntity) player); + if (player instanceof ServerPlayer) + affected.add((ServerPlayer) player); } } - for (ServerPlayerEntity player : affected) + for (ServerPlayer player : affected) ToolboxHandler.syncData(player); connectedPlayers.clear(); } - public void unequip(int slot, PlayerEntity player, int hotbarSlot, boolean keepItems) { + public void unequip(int slot, Player player, int hotbarSlot, boolean keepItems) { if (!connectedPlayers.containsKey(slot)) return; connectedPlayers.get(slot) @@ -251,21 +251,21 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine } private void tickAudio() { - Vector3d vec = VecHelper.getCenterOf(worldPosition); + Vec3 vec = VecHelper.getCenterOf(worldPosition); if (lid.settled()) { if (openCount > 0 && lid.getChaseTarget() == 0) { - level.playLocalSound(vec.x, vec.y, vec.z, SoundEvents.IRON_DOOR_OPEN, SoundCategory.BLOCKS, 0.25F, + level.playLocalSound(vec.x, vec.y, vec.z, SoundEvents.IRON_DOOR_OPEN, SoundSource.BLOCKS, 0.25F, level.random.nextFloat() * 0.1F + 1.2F, true); - level.playLocalSound(vec.x, vec.y, vec.z, SoundEvents.CHEST_OPEN, SoundCategory.BLOCKS, 0.1F, + level.playLocalSound(vec.x, vec.y, vec.z, SoundEvents.CHEST_OPEN, SoundSource.BLOCKS, 0.1F, level.random.nextFloat() * 0.1F + 1.1F, true); } if (openCount == 0 && lid.getChaseTarget() == 1) - level.playLocalSound(vec.x, vec.y, vec.z, SoundEvents.CHEST_CLOSE, SoundCategory.BLOCKS, 0.1F, + level.playLocalSound(vec.x, vec.y, vec.z, SoundEvents.CHEST_CLOSE, SoundSource.BLOCKS, 0.1F, level.random.nextFloat() * 0.1F + 1.1F, true); } else if (openCount == 0 && lid.getChaseTarget() == 0 && lid.getValue(0) > 1 / 16f && lid.getValue(1) < 1 / 16f) - level.playLocalSound(vec.x, vec.y, vec.z, SoundEvents.IRON_DOOR_CLOSE, SoundCategory.BLOCKS, 0.25F, + level.playLocalSound(vec.x, vec.y, vec.z, SoundEvents.IRON_DOOR_CLOSE, SoundSource.BLOCKS, 0.25F, level.random.nextFloat() * 0.1F + 1.2F, true); } @@ -277,27 +277,27 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { inventory.deserializeNBT(compound.getCompound("Inventory")); super.fromTag(state, compound, clientPacket); if (compound.contains("CustomName", 8)) - this.customName = ITextComponent.Serializer.fromJson(compound.getString("CustomName")); + this.customName = Component.Serializer.fromJson(compound.getString("CustomName")); if (clientPacket) openCount = compound.getInt("OpenCount"); } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { compound.put("Inventory", inventory.serializeNBT()); if (customName != null) - compound.putString("CustomName", ITextComponent.Serializer.toJson(customName)); + compound.putString("CustomName", Component.Serializer.toJson(customName)); super.write(compound, clientPacket); if (clientPacket) compound.putInt("OpenCount", openCount); } @Override - public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) { return ToolboxContainer.create(id, inv, this); } @@ -318,8 +318,8 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine int prevOpenCount = openCount; openCount = 0; - for (PlayerEntity playerentity : level.getEntitiesOfClass(PlayerEntity.class, - new AxisAlignedBB(worldPosition).inflate(8))) + for (Player playerentity : level.getEntitiesOfClass(Player.class, + new AABB(worldPosition).inflate(8))) if (playerentity.containerMenu instanceof ToolboxContainer && ((ToolboxContainer) playerentity.containerMenu).contentHolder == this) openCount++; @@ -328,7 +328,7 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine sendData(); } - public void startOpen(PlayerEntity player) { + public void startOpen(Player player) { if (player.isSpectator()) return; if (openCount < 0) @@ -337,17 +337,17 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine sendData(); } - public void stopOpen(PlayerEntity player) { + public void stopOpen(Player player) { if (player.isSpectator()) return; openCount--; sendData(); } - public void connectPlayer(int slot, PlayerEntity player, int hotbarSlot) { + public void connectPlayer(int slot, Player player, int hotbarSlot) { if (level.isClientSide) return; - WeakHashMap map = connectedPlayers.computeIfAbsent(slot, WeakHashMap::new); + WeakHashMap map = connectedPlayers.computeIfAbsent(slot, WeakHashMap::new); Integer previous = map.get(player); if (previous != null) { if (previous == hotbarSlot) @@ -357,24 +357,24 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine map.put(player, hotbarSlot); } - public void readInventory(CompoundNBT compound) { + public void readInventory(CompoundTag compound) { inventory.deserializeNBT(compound); } - public void setCustomName(ITextComponent customName) { + public void setCustomName(Component customName) { this.customName = customName; } @Override - public ITextComponent getDisplayName() { + public Component getDisplayName() { return customName != null ? customName - : new TranslationTextComponent(AllBlocks.TOOLBOXES.get(getColor()) + : new TranslatableComponent(AllBlocks.TOOLBOXES.get(getColor()) .get() .getDescriptionId()); } @Override - public ITextComponent getCustomName() { + public Component getCustomName() { return customName; } @@ -384,7 +384,7 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine } @Override - public ITextComponent getName() { + public Component getName() { return customName; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintAssignCompleteRecipePacket.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintAssignCompleteRecipePacket.java index eb5796c75..0342d9614 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintAssignCompleteRecipePacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintAssignCompleteRecipePacket.java @@ -4,9 +4,9 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.network.NetworkEvent.Context; public class BlueprintAssignCompleteRecipePacket extends SimplePacketBase { @@ -17,12 +17,12 @@ public class BlueprintAssignCompleteRecipePacket extends SimplePacketBase { this.recipeID = recipeID; } - public BlueprintAssignCompleteRecipePacket(PacketBuffer buffer) { + public BlueprintAssignCompleteRecipePacket(FriendlyByteBuf buffer) { recipeID = buffer.readResourceLocation(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeResourceLocation(recipeID); } @@ -30,7 +30,7 @@ public class BlueprintAssignCompleteRecipePacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity player = context.get() + ServerPlayer player = context.get() .getSender(); if (player == null) return; 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 966e65579..eb0d52e7a 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 @@ -7,18 +7,18 @@ import com.simibubi.create.content.curiosities.tools.BlueprintEntity.BlueprintSe import com.simibubi.create.foundation.gui.GhostItemContainer; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.ICraftingRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.server.SSetSlotPacket; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.IItemHandler; @@ -27,15 +27,15 @@ import net.minecraftforge.items.SlotItemHandler; public class BlueprintContainer extends GhostItemContainer { - public BlueprintContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + public BlueprintContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { super(type, id, inv, extraData); } - public BlueprintContainer(ContainerType type, int id, PlayerInventory inv, BlueprintSection section) { + public BlueprintContainer(MenuType type, int id, Inventory inv, BlueprintSection section) { super(type, id, inv, section); } - public static BlueprintContainer create(int id, PlayerInventory inv, BlueprintSection section) { + public static BlueprintContainer create(int id, Inventory inv, BlueprintSection section) { return new BlueprintContainer(AllContainerTypes.CRAFTING_BLUEPRINT.get(), id, inv, section); } @@ -63,11 +63,11 @@ public class BlueprintContainer extends GhostItemContainer { if (contentHolder.getBlueprintWorld().isClientSide) return; - ServerPlayerEntity serverplayerentity = (ServerPlayerEntity) player; - CraftingInventory craftingInventory = new BlueprintCraftingInventory(this, ghostInventory); - Optional optional = player.getServer() + ServerPlayer serverplayerentity = (ServerPlayer) player; + CraftingContainer craftingInventory = new BlueprintCraftingInventory(this, ghostInventory); + Optional optional = player.getServer() .getRecipeManager() - .getRecipeFor(IRecipeType.CRAFTING, craftingInventory, player.getCommandSenderWorld()); + .getRecipeFor(RecipeType.CRAFTING, craftingInventory, player.getCommandSenderWorld()); if (!optional.isPresent()) { if (ghostInventory.getStackInSlot(9) @@ -77,19 +77,19 @@ public class BlueprintContainer extends GhostItemContainer { return; ghostInventory.setStackInSlot(9, ItemStack.EMPTY); - serverplayerentity.connection.send(new SSetSlotPacket(containerId, 36 + 9, ItemStack.EMPTY)); + serverplayerentity.connection.send(new ClientboundContainerSetSlotPacket(containerId, 36 + 9, ItemStack.EMPTY)); contentHolder.inferredIcon = false; return; } - ICraftingRecipe icraftingrecipe = optional.get(); + CraftingRecipe icraftingrecipe = optional.get(); ItemStack itemstack = icraftingrecipe.assemble(craftingInventory); ghostInventory.setStackInSlot(9, itemstack); contentHolder.inferredIcon = true; ItemStack toSend = itemstack.copy(); toSend.getOrCreateTag() .putBoolean("InferredFromRecipe", true); - serverplayerentity.connection.send(new SSetSlotPacket(containerId, 36 + 9, toSend)); + serverplayerentity.connection.send(new ClientboundContainerSetSlotPacket(containerId, 36 + 9, toSend)); } @Override @@ -123,7 +123,7 @@ public class BlueprintContainer extends GhostItemContainer { @Override @OnlyIn(Dist.CLIENT) - protected BlueprintSection createOnClient(PacketBuffer extraData) { + protected BlueprintSection createOnClient(FriendlyByteBuf extraData) { int entityID = extraData.readVarInt(); int section = extraData.readVarInt(); Entity entityByID = Minecraft.getInstance().level.getEntity(entityID); @@ -135,13 +135,13 @@ public class BlueprintContainer extends GhostItemContainer { } @Override - public boolean stillValid(PlayerEntity player) { + public boolean stillValid(Player player) { return contentHolder != null && contentHolder.canPlayerUse(player); } - static class BlueprintCraftingInventory extends CraftingInventory { + static class BlueprintCraftingInventory extends CraftingContainer { - public BlueprintCraftingInventory(Container container, ItemStackHandler items) { + public BlueprintCraftingInventory(AbstractContainerMenu container, ItemStackHandler items) { super(container, 3, 3); for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { @@ -167,8 +167,8 @@ public class BlueprintContainer extends GhostItemContainer { super.setChanged(); if (index == 9 && hasItem() && !contentHolder.getBlueprintWorld().isClientSide) { contentHolder.inferredIcon = false; - ServerPlayerEntity serverplayerentity = (ServerPlayerEntity) player; - serverplayerentity.connection.send(new SSetSlotPacket(containerId, 36 + 9, getItem())); + ServerPlayer serverplayerentity = (ServerPlayer) player; + serverplayerentity.connection.send(new ClientboundContainerSetSlotPacket(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 e1fbc0f48..f1733af32 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 @@ -21,42 +21,42 @@ import com.simibubi.create.foundation.networking.ISyncPersistentData; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.RedstoneDiodeBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntitySize; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.Pose; -import net.minecraft.entity.item.HangingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.ICraftingRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.IPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.GameRules; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.DiodeBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.entity.decoration.HangingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.NonNullList; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ForgeHooks; @@ -76,12 +76,12 @@ public class BlueprintEntity extends HangingEntity protected Direction verticalOrientation; @SuppressWarnings("unchecked") - public BlueprintEntity(EntityType p_i50221_1_, World p_i50221_2_) { + public BlueprintEntity(EntityType p_i50221_1_, Level p_i50221_2_) { super((EntityType) p_i50221_1_, p_i50221_2_); size = 1; } - public BlueprintEntity(World world, BlockPos pos, Direction facing, Direction verticalOrientation) { + public BlueprintEntity(Level world, BlockPos pos, Direction facing, Direction verticalOrientation) { super(AllEntityTypes.CRAFTING_BLUEPRINT.get(), world, pos); for (int size = 3; size > 0; size--) { @@ -99,12 +99,12 @@ public class BlueprintEntity extends HangingEntity } @Override - public IPacket getAddEntityPacket() { + public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override - public void addAdditionalSaveData(CompoundNBT p_213281_1_) { + public void addAdditionalSaveData(CompoundTag 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); @@ -112,7 +112,7 @@ public class BlueprintEntity extends HangingEntity } @Override - public void readAdditionalSaveData(CompoundNBT p_70037_1_) { + public void readAdditionalSaveData(CompoundTag 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"); @@ -141,7 +141,7 @@ public class BlueprintEntity extends HangingEntity } @Override - protected float getEyeHeight(Pose p_213316_1_, EntitySize p_213316_2_) { + protected float getEyeHeight(Pose p_213316_1_, EntityDimensions p_213316_2_) { return 0; } @@ -152,9 +152,9 @@ public class BlueprintEntity extends HangingEntity if (this.verticalOrientation == null) return; - Vector3d pos = Vector3d.atLowerCornerOf(getPos()) + Vec3 pos = Vec3.atLowerCornerOf(getPos()) .add(.5, .5, .5) - .subtract(Vector3d.atLowerCornerOf(direction.getNormal()) + .subtract(Vec3.atLowerCornerOf(direction.getNormal()) .scale(0.46875)); double d1 = pos.x; double d2 = pos.y; @@ -163,12 +163,12 @@ public class BlueprintEntity extends HangingEntity Axis axis = direction.getAxis(); if (size == 2) - pos = pos.add(Vector3d.atLowerCornerOf(axis.isHorizontal() ? direction.getCounterClockWise() + pos = pos.add(Vec3.atLowerCornerOf(axis.isHorizontal() ? direction.getCounterClockWise() .getNormal() : verticalOrientation.getClockWise() .getNormal()) .scale(0.5)) - .add(Vector3d + .add(Vec3 .atLowerCornerOf(axis.isHorizontal() ? Direction.UP.getNormal() : direction == Direction.UP ? verticalOrientation.getNormal() : verticalOrientation.getOpposite() @@ -197,7 +197,7 @@ public class BlueprintEntity extends HangingEntity d4 = d4 / 32.0D; d5 = d5 / 32.0D; d6 = d6 / 32.0D; - this.setBoundingBox(new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6)); + this.setBoundingBox(new AABB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6)); } @Override @@ -213,7 +213,7 @@ public class BlueprintEntity extends HangingEntity : direction == Direction.UP ? verticalOrientation : verticalOrientation.getOpposite(); Direction newDirection = direction.getAxis() .isVertical() ? verticalOrientation.getClockWise() : direction.getCounterClockWise(); - BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(); + BlockPos.MutableBlockPos blockpos$mutable = new BlockPos.MutableBlockPos(); for (int k = 0; k < i; ++k) { for (int l = 0; l < j; ++l) { @@ -226,7 +226,7 @@ public class BlueprintEntity extends HangingEntity if (Block.canSupportCenter(this.level, blockpos$mutable, this.direction)) continue; if (!blockstate.getMaterial() - .isSolid() && !RedstoneDiodeBlock.isDiode(blockstate)) { + .isSolid() && !DiodeBlock.isDiode(blockstate)) { return false; } } @@ -248,22 +248,22 @@ public class BlueprintEntity extends HangingEntity @Override public boolean skipAttackInteraction(Entity source) { - if (!(source instanceof PlayerEntity) || level.isClientSide) + if (!(source instanceof Player) || level.isClientSide) return super.skipAttackInteraction(source); - PlayerEntity player = (PlayerEntity) source; + Player player = (Player) source; double attrib = player.getAttribute(ForgeMod.REACH_DISTANCE.get()) .getValue() + (player.isCreative() ? 0 : -0.5F); - Vector3d eyePos = source.getEyePosition(1); - Vector3d look = source.getViewVector(1); - Vector3d target = eyePos.add(look.scale(attrib)); + Vec3 eyePos = source.getEyePosition(1); + Vec3 look = source.getViewVector(1); + Vec3 target = eyePos.add(look.scale(attrib)); - Optional rayTrace = getBoundingBox().clip(eyePos, target); + Optional rayTrace = getBoundingBox().clip(eyePos, target); if (!rayTrace.isPresent()) return super.skipAttackInteraction(source); - Vector3d hitVec = rayTrace.get(); + Vec3 hitVec = rayTrace.get(); BlueprintSection sectionAt = getSectionAt(hitVec.subtract(position())); ItemStackHandler items = sectionAt.getItems(); @@ -283,8 +283,8 @@ public class BlueprintEntity extends HangingEntity return; playSound(SoundEvents.PAINTING_BREAK, 1.0F, 1.0F); - if (p_110128_1_ instanceof PlayerEntity) { - PlayerEntity playerentity = (PlayerEntity) p_110128_1_; + if (p_110128_1_ instanceof Player) { + Player playerentity = (Player) p_110128_1_; if (playerentity.abilities.instabuild) { return; } @@ -294,7 +294,7 @@ public class BlueprintEntity extends HangingEntity } @Override - public ItemStack getPickedResult(RayTraceResult target) { + public ItemStack getPickedResult(HitResult target) { return AllItems.CRAFTING_BLUEPRINT.asStack(); } @@ -324,23 +324,23 @@ public class BlueprintEntity extends HangingEntity } @Override - public void writeSpawnData(PacketBuffer buffer) { - CompoundNBT compound = new CompoundNBT(); + public void writeSpawnData(FriendlyByteBuf buffer) { + CompoundTag compound = new CompoundTag(); addAdditionalSaveData(compound); buffer.writeNbt(compound); buffer.writeNbt(getPersistentData()); } @Override - public void readSpawnData(PacketBuffer additionalData) { + public void readSpawnData(FriendlyByteBuf additionalData) { readAdditionalSaveData(additionalData.readNbt()); getPersistentData().merge(additionalData.readNbt()); } @Override - public ActionResultType interactAt(PlayerEntity player, Vector3d vec, Hand hand) { + public InteractionResult interactAt(Player player, Vec3 vec, InteractionHand hand) { if (player instanceof FakePlayer) - return ActionResultType.PASS; + return InteractionResult.PASS; boolean holdingWrench = AllItems.WRENCH.isIn(player.getItemInHand(hand)); BlueprintSection section = getSectionAt(vec); @@ -353,7 +353,7 @@ public class BlueprintEntity extends HangingEntity boolean firstPass = true; int amountCrafted = 0; ForgeHooks.setCraftingPlayer(player); - Optional recipe = Optional.empty(); + Optional recipe = Optional.empty(); do { Map stacksTaken = new HashMap<>(); @@ -385,11 +385,11 @@ public class BlueprintEntity extends HangingEntity } if (success) { - CraftingInventory craftingInventory = new BlueprintCraftingInventory(craftingGrid); + CraftingContainer craftingInventory = new BlueprintCraftingInventory(craftingGrid); if (!recipe.isPresent()) recipe = level.getRecipeManager() - .getRecipeFor(IRecipeType.CRAFTING, craftingInventory, level); + .getRecipeFor(RecipeType.CRAFTING, craftingInventory, level); ItemStack result = recipe.filter(r -> r.matches(craftingInventory, level)) .map(r -> r.assemble(craftingInventory)) .orElse(ItemStack.EMPTY); @@ -403,11 +403,11 @@ public class BlueprintEntity extends HangingEntity result.onCraftedBy(player.level, player, 1); BasicEventHooks.firePlayerCraftingEvent(player, result, craftingInventory); NonNullList nonnulllist = level.getRecipeManager() - .getRemainingItemsFor(IRecipeType.CRAFTING, craftingInventory, level); + .getRemainingItemsFor(RecipeType.CRAFTING, craftingInventory, level); if (firstPass) level.playSound(null, player.blockPosition(), SoundEvents.ITEM_PICKUP, - SoundCategory.PLAYERS, .2f, 1f + Create.RANDOM.nextFloat()); + SoundSource.PLAYERS, .2f, 1f + Create.RANDOM.nextFloat()); player.inventory.placeItemBackInInventory(level, result); for (ItemStack itemStack : nonnulllist) player.inventory.placeItemBackInInventory(level, itemStack); @@ -423,21 +423,21 @@ public class BlueprintEntity extends HangingEntity } while (player.isShiftKeyDown()); ForgeHooks.setCraftingPlayer(null); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } int i = section.index; - if (!level.isClientSide && player instanceof ServerPlayerEntity) { - NetworkHooks.openGui((ServerPlayerEntity) player, section, buf -> { + if (!level.isClientSide && player instanceof ServerPlayer) { + NetworkHooks.openGui((ServerPlayer) player, section, buf -> { buf.writeVarInt(getId()); buf.writeVarInt(i); }); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - public BlueprintSection getSectionAt(Vector3d vec) { + public BlueprintSection getSectionAt(Vec3 vec) { int index = 0; if (size > 1) { vec = VecHelper.rotate(vec, yRot, Axis.Y); @@ -445,8 +445,8 @@ public class BlueprintEntity extends HangingEntity vec = vec.add(0.5, 0.5, 0); if (size == 3) vec = vec.add(1, 1, 0); - int x = MathHelper.clamp(MathHelper.floor(vec.x), 0, size - 1); - int y = MathHelper.clamp(MathHelper.floor(vec.y), 0, size - 1); + int x = Mth.clamp(Mth.floor(vec.x), 0, size - 1); + int y = Mth.clamp(Mth.floor(vec.y), 0, size - 1); index = x + y * size; } @@ -454,10 +454,10 @@ public class BlueprintEntity extends HangingEntity return section; } - static class BlueprintCraftingInventory extends CraftingInventory { + static class BlueprintCraftingInventory extends CraftingContainer { - private static Container dummyContainer = new Container(null, -1) { - public boolean stillValid(PlayerEntity playerIn) { + private static AbstractContainerMenu dummyContainer = new AbstractContainerMenu(null, -1) { + public boolean stillValid(Player playerIn) { return false; } }; @@ -474,10 +474,10 @@ public class BlueprintEntity extends HangingEntity } - public CompoundNBT getOrCreateRecipeCompound() { - CompoundNBT persistentData = getPersistentData(); + public CompoundTag getOrCreateRecipeCompound() { + CompoundTag persistentData = getPersistentData(); if (!persistentData.contains("Recipes")) - persistentData.put("Recipes", new CompoundNBT()); + persistentData.put("Recipes", new CompoundTag()); return persistentData.getCompound("Recipes"); } @@ -487,7 +487,7 @@ public class BlueprintEntity extends HangingEntity return sectionCache.computeIfAbsent(index, i -> new BlueprintSection(i)); } - class BlueprintSection implements INamedContainerProvider, IInteractionChecker { + class BlueprintSection implements MenuProvider, IInteractionChecker { int index; Couple cachedDisplayItems; public boolean inferredIcon = false; @@ -505,8 +505,8 @@ public class BlueprintEntity extends HangingEntity public ItemStackHandler getItems() { ItemStackHandler newInv = new ItemStackHandler(11); - CompoundNBT list = getOrCreateRecipeCompound(); - CompoundNBT invNBT = list.getCompound(index + ""); + CompoundTag list = getOrCreateRecipeCompound(); + CompoundTag invNBT = list.getCompound(index + ""); inferredIcon = list.getBoolean("InferredIcon"); if (!invNBT.isEmpty()) newInv.deserializeNBT(invNBT); @@ -514,7 +514,7 @@ public class BlueprintEntity extends HangingEntity } public void save(ItemStackHandler inventory) { - CompoundNBT list = getOrCreateRecipeCompound(); + CompoundTag list = getOrCreateRecipeCompound(); list.put(index + "", inventory.serializeNBT()); list.putBoolean("InferredIcon", inferredIcon); cachedDisplayItems = null; @@ -526,23 +526,23 @@ public class BlueprintEntity extends HangingEntity return isAlive(); } - public World getBlueprintWorld() { + public Level getBlueprintWorld() { return level; } @Override - public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) { return BlueprintContainer.create(id, inv, this); } @Override - public ITextComponent getDisplayName() { - return new TranslationTextComponent(AllItems.CRAFTING_BLUEPRINT.get() + public Component getDisplayName() { + return new TranslatableComponent(AllItems.CRAFTING_BLUEPRINT.get() .getDescriptionId()); } @Override - public boolean canPlayerUse(PlayerEntity player) { + public boolean canPlayerUse(Player player) { return BlueprintEntity.this.canPlayerUse(player); } @@ -554,8 +554,8 @@ public class BlueprintEntity extends HangingEntity } @Override - public boolean canPlayerUse(PlayerEntity player) { - AxisAlignedBB box = getBoundingBox(); + public boolean canPlayerUse(Player player) { + AABB box = getBoundingBox(); double dx = 0; if (box.minX > player.getX()) { 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 7e3b069e1..bd78f755e 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 @@ -7,31 +7,33 @@ import com.simibubi.create.content.logistics.item.filter.AttributeFilterContaine import com.simibubi.create.content.logistics.item.filter.FilterItem; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.item.HangingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.Ingredient.IItemList; -import net.minecraft.item.crafting.Ingredient.SingleItemList; -import net.minecraft.item.crafting.Ingredient.TagList; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.decoration.HangingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.Ingredient.Value; +import net.minecraft.world.item.crafting.Ingredient.ItemValue; +import net.minecraft.world.item.crafting.Ingredient.TagValue; +import net.minecraft.world.item.crafting.ShapedRecipe; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.util.GsonHelper; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.common.crafting.StackList; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.items.ItemStackHandler; +import net.minecraft.world.item.Item.Properties; + public class BlueprintItem extends Item { public BlueprintItem(Properties p_i48487_1_) { @@ -39,40 +41,40 @@ public class BlueprintItem extends Item { } @Override - public ActionResultType useOn(ItemUseContext ctx) { + public InteractionResult useOn(UseOnContext ctx) { Direction face = ctx.getClickedFace(); - PlayerEntity player = ctx.getPlayer(); + Player player = ctx.getPlayer(); ItemStack stack = ctx.getItemInHand(); BlockPos pos = ctx.getClickedPos() .relative(face); if (player != null && !player.mayUseItemAt(pos, face, stack)) - return ActionResultType.FAIL; + return InteractionResult.FAIL; - World world = ctx.getLevel(); + Level world = ctx.getLevel(); HangingEntity hangingentity = new BlueprintEntity(world, pos, face, face.getAxis() .isHorizontal() ? Direction.DOWN : ctx.getHorizontalDirection()); - CompoundNBT compoundnbt = stack.getTag(); + CompoundTag compoundnbt = stack.getTag(); if (compoundnbt != null) EntityType.updateCustomEntityTag(world, player, hangingentity, compoundnbt); if (!hangingentity.survives()) - return ActionResultType.CONSUME; + return InteractionResult.CONSUME; if (!world.isClientSide) { hangingentity.playPlacementSound(); world.addFreshEntity(hangingentity); } stack.shrink(1); - return ActionResultType.sidedSuccess(world.isClientSide); + return InteractionResult.sidedSuccess(world.isClientSide); } - protected boolean canPlace(PlayerEntity p_200127_1_, Direction p_200127_2_, ItemStack p_200127_3_, + protected boolean canPlace(Player p_200127_1_, Direction p_200127_2_, ItemStack p_200127_3_, BlockPos p_200127_4_) { return p_200127_1_.mayUseItemAt(p_200127_4_, p_200127_2_, p_200127_3_); } - public static void assignCompleteRecipe(ItemStackHandler inv, IRecipe recipe) { + public static void assignCompleteRecipe(ItemStackHandler inv, Recipe recipe) { NonNullList ingredients = recipe.getIngredients(); for (int i = 0; i < 9; i++) @@ -92,7 +94,7 @@ public class BlueprintItem extends Item { } private static ItemStack convertIngredientToFilter(Ingredient ingredient) { - Ingredient.IItemList[] acceptedItems = + Ingredient.Value[] acceptedItems = ObfuscationReflectionHelper.getPrivateValue(Ingredient.class, ingredient, "field_199807_b"); // values if (acceptedItems == null || acceptedItems.length > 18) return ItemStack.EMPTY; @@ -110,21 +112,21 @@ public class BlueprintItem extends Item { return result; } - private static ItemStack convertIItemListToFilter(IItemList itemList) { + private static ItemStack convertIItemListToFilter(Value itemList) { Collection stacks = itemList.getItems(); - if (itemList instanceof SingleItemList) { + if (itemList instanceof ItemValue) { for (ItemStack itemStack : stacks) return itemStack; } - if (itemList instanceof TagList) { - ResourceLocation resourcelocation = new ResourceLocation(JSONUtils.getAsString(itemList.serialize(), "tag")); + if (itemList instanceof TagValue) { + ResourceLocation resourcelocation = new ResourceLocation(GsonHelper.getAsString(itemList.serialize(), "tag")); ItemStack filterItem = AllItems.ATTRIBUTE_FILTER.asStack(); filterItem.getOrCreateTag() .putInt("WhitelistMode", WhitelistMode.WHITELIST_DISJ.ordinal()); - ListNBT attributes = new ListNBT(); + ListTag attributes = new ListTag(); ItemAttribute at = new ItemAttribute.InTag(resourcelocation); - CompoundNBT compoundNBT = new CompoundNBT(); + CompoundTag compoundNBT = new CompoundTag(); at.serializeNBT(compoundNBT); compoundNBT.putBoolean("Inverted", false); attributes.add(compoundNBT); @@ -142,7 +144,7 @@ public class BlueprintItem extends Item { break; filterItems.setStackInSlot(i++, itemStack); } - CompoundNBT tag = result.getOrCreateTag(); + CompoundTag tag = result.getOrCreateTag(); tag.put("Items", filterItems.serializeNBT()); tag.putBoolean("RespectNBT", true); return result; 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 f52ad6750..9997b4f3d 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 @@ -7,7 +7,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; import com.simibubi.create.content.curiosities.tools.BlueprintEntity.BlueprintCraftingInventory; @@ -21,22 +21,22 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Pair; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.ICraftingRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.tags.ITag; -import net.minecraft.tags.TagCollectionManager; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.tags.Tag; +import net.minecraft.tags.SerializationTags; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.ChatFormatting; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; @@ -55,7 +55,7 @@ public class BlueprintOverlayRenderer { public static void tick() { Minecraft mc = Minecraft.getInstance(); - RayTraceResult mouseOver = mc.hitResult; + HitResult mouseOver = mc.hitResult; BlueprintSection last = lastTargetedSection; boolean sneak = mc.player.isShiftKeyDown(); lastTargetedSection = null; @@ -65,7 +65,7 @@ public class BlueprintOverlayRenderer { if (mouseOver.getType() != Type.ENTITY) return; - EntityRayTraceResult entityRay = (EntityRayTraceResult) mouseOver; + EntityHitResult entityRay = (EntityHitResult) mouseOver; if (!(entityRay.getEntity() instanceof BlueprintEntity)) return; @@ -110,7 +110,7 @@ public class BlueprintOverlayRenderer { .copy()); int amountCrafted = 0; - Optional recipe = Optional.empty(); + Optional recipe = Optional.empty(); Map craftingGrid = new HashMap<>(); ingredients.clear(); ItemStackHandler missingItems = new ItemStackHandler(64); @@ -145,10 +145,10 @@ public class BlueprintOverlayRenderer { } if (success) { - CraftingInventory craftingInventory = new BlueprintCraftingInventory(craftingGrid); + CraftingContainer craftingInventory = new BlueprintCraftingInventory(craftingGrid); if (!recipe.isPresent()) recipe = mc.level.getRecipeManager() - .getRecipeFor(IRecipeType.CRAFTING, craftingInventory, mc.level); + .getRecipeFor(RecipeType.CRAFTING, craftingInventory, mc.level); ItemStack resultFromRecipe = recipe.filter(r -> r.matches(craftingInventory, mc.level)) .map(r -> r.assemble(craftingInventory)) .orElse(ItemStack.EMPTY); @@ -202,7 +202,7 @@ public class BlueprintOverlayRenderer { } } - public static void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, + public static void renderOverlay(PoseStack ms, MultiBufferSource buffer, int light, int overlay, float partialTicks) { if (!active || empty) return; @@ -219,7 +219,7 @@ public class BlueprintOverlayRenderer { RenderSystem.enableBlend(); (pair.getSecond() ? AllGuiTextures.HOTSLOT_ACTIVE : AllGuiTextures.HOTSLOT).draw(ms, x, y); ItemStack itemStack = pair.getFirst(); - String count = pair.getSecond() ? null : TextFormatting.GOLD.toString() + itemStack.getCount(); + String count = pair.getSecond() ? null : ChatFormatting.GOLD.toString() + itemStack.getCount(); drawItemStack(ms, mc, x, y, itemStack, count); x += 21; } @@ -241,7 +241,7 @@ public class BlueprintOverlayRenderer { } } - public static void drawItemStack(MatrixStack ms, Minecraft mc, int x, int y, ItemStack itemStack, String count) { + public static void drawItemStack(PoseStack ms, Minecraft mc, int x, int y, ItemStack itemStack, String count) { if (itemStack.getItem() instanceof FilterItem) { int step = AnimationTickHolder.getTicks(mc.level) / 10; ItemStack[] itemsMatchingFilter = getItemsMatchingFilter(itemStack); @@ -258,7 +258,7 @@ public class BlueprintOverlayRenderer { private static ItemStack[] getItemsMatchingFilter(ItemStack filter) { return cachedRenderedFilters.computeIfAbsent(filter, itemStack -> { - CompoundNBT tag = itemStack.getOrCreateTag(); + CompoundTag tag = itemStack.getOrCreateTag(); if (AllItems.FILTER.isIn(itemStack) && !tag.getBoolean("Blacklist")) { ItemStackHandler filterItems = FilterItem.getFilterItems(itemStack); @@ -273,12 +273,12 @@ public class BlueprintOverlayRenderer { if (AllItems.ATTRIBUTE_FILTER.isIn(itemStack)) { WhitelistMode whitelistMode = WhitelistMode.values()[tag.getInt("WhitelistMode")]; - ListNBT attributes = tag.getList("MatchedAttributes", NBT.TAG_COMPOUND); + ListTag attributes = tag.getList("MatchedAttributes", NBT.TAG_COMPOUND); if (whitelistMode == WhitelistMode.WHITELIST_DISJ && attributes.size() == 1) { - ItemAttribute fromNBT = ItemAttribute.fromNBT((CompoundNBT) attributes.get(0)); + ItemAttribute fromNBT = ItemAttribute.fromNBT((CompoundTag) attributes.get(0)); if (fromNBT instanceof ItemAttribute.InTag) { ItemAttribute.InTag inTag = (ItemAttribute.InTag) fromNBT; - ITag itag = TagCollectionManager.getInstance() + Tag itag = SerializationTags.getInstance() .getItems() .getTag(inTag.tagName); if (itag != null) 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 02474015d..63a45f7e5 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 @@ -2,34 +2,34 @@ package com.simibubi.create.content.curiosities.tools; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.curiosities.tools.BlueprintEntity.BlueprintSection; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.Couple; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Atlases; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.Sheets; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix3f; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import com.mojang.math.Matrix3f; public class BlueprintRenderer extends EntityRenderer { - public BlueprintRenderer(EntityRendererManager manager) { + public BlueprintRenderer(EntityRenderDispatcher manager) { super(manager); } @Override - public void render(BlueprintEntity entity, float yaw, float pt, MatrixStack ms, IRenderTypeBuffer buffer, + public void render(BlueprintEntity entity, float yaw, float pt, PoseStack ms, MultiBufferSource buffer, int light) { PartialModel partialModel = entity.size == 3 ? AllBlockPartials.CRAFTING_BLUEPRINT_3x3 : entity.size == 2 ? AllBlockPartials.CRAFTING_BLUEPRINT_2x2 : AllBlockPartials.CRAFTING_BLUEPRINT_1x1; @@ -43,7 +43,7 @@ public class BlueprintRenderer extends EntityRenderer { sbb.forEntityRender() .light(light) - .renderInto(ms, buffer.getBuffer(Atlases.solidBlockSheet())); + .renderInto(ms, buffer.getBuffer(Sheets.solidBlockSheet())); super.render(entity, yaw, pt, ms, buffer, light); ms.pushPose(); @@ -58,7 +58,7 @@ public class BlueprintRenderer extends EntityRenderer { bl /= 1.35; sl /= 1.35; } - int itemLight = MathHelper.floor(sl + .5) << 20 | (MathHelper.floor(bl + .5) & 0xf) << 4; + int itemLight = Mth.floor(sl + .5) << 20 | (Mth.floor(bl + .5) & 0xf) << 4; MatrixTransformStack.of(ms) .rotateY(vertical ? 0 : -yaw) @@ -78,7 +78,7 @@ public class BlueprintRenderer extends EntityRenderer { if (entity.size == 3) ms.translate(-1, -1, 0); - MatrixStack squashedMS = new MatrixStack(); + PoseStack squashedMS = new PoseStack(); squashedMS.last() .pose() .multiply(ms.last() 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 5fba8bbbc..b2ae1f12e 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 @@ -7,7 +7,7 @@ import java.util.LinkedList; import java.util.List; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket; import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket.Option; @@ -19,21 +19,21 @@ import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; public class BlueprintScreen extends AbstractSimiContainerScreen { protected AllGuiTextures background; - private List extraAreas = Collections.emptyList(); + private List extraAreas = Collections.emptyList(); private IconButton resetButton; private IconButton confirmButton; - public BlueprintScreen(BlueprintContainer container, PlayerInventory inv, ITextComponent title) { + public BlueprintScreen(BlueprintContainer container, Inventory inv, Component title) { super(container, inv, title); this.background = AllGuiTextures.BLUEPRINT; } @@ -55,12 +55,12 @@ public class BlueprintScreen extends AbstractSimiContainerScreen getTooltipFromItem(ItemStack stack) { - List list = super.getTooltipFromItem(stack); + public List getTooltipFromItem(ItemStack stack) { + List list = super.getTooltipFromItem(stack); if (hoveredSlot.container == menu.playerInventory) return list; return hoveredSlot != null ? addToTooltip(list, hoveredSlot.getSlotIndex(), false) : list; } - private List addToTooltip(List list, int slot, boolean isEmptySlot) { + private List addToTooltip(List list, int slot, boolean isEmptySlot) { if (slot < 0 || slot > 10) return list; if (slot < 9) { list.add(Lang.createTranslationTextComponent("crafting_blueprint.crafting_slot") - .withStyle(TextFormatting.GOLD)); + .withStyle(ChatFormatting.GOLD)); if (isEmptySlot) list.add(Lang.createTranslationTextComponent("crafting_blueprint.filter_items_viable") - .withStyle(TextFormatting.GRAY)); + .withStyle(ChatFormatting.GRAY)); } else if (slot == 9) { list.add(Lang.createTranslationTextComponent("crafting_blueprint.display_slot") - .withStyle(TextFormatting.GOLD)); + .withStyle(ChatFormatting.GOLD)); if (!isEmptySlot) list.add(Lang .createTranslationTextComponent("crafting_blueprint." + (menu.contentHolder.inferredIcon ? "inferred" : "manually_assigned")) - .withStyle(TextFormatting.GRAY)); + .withStyle(ChatFormatting.GRAY)); } else if (slot == 10) { list.add(Lang.createTranslationTextComponent("crafting_blueprint.secondary_display_slot") - .withStyle(TextFormatting.GOLD)); + .withStyle(ChatFormatting.GOLD)); if (isEmptySlot) list.add(Lang.createTranslationTextComponent("crafting_blueprint.optional") - .withStyle(TextFormatting.GRAY)); + .withStyle(ChatFormatting.GRAY)); } return list; @@ -185,7 +185,7 @@ public class BlueprintScreen extends AbstractSimiContainerScreen getExtraAreas() { + public List getExtraAreas() { return extraAreas; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripInteractionPacket.java b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripInteractionPacket.java index 9575cb268..0f24ce027 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripInteractionPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripInteractionPacket.java @@ -4,44 +4,44 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Hand; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.Entity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.fml.network.NetworkEvent.Context; public class ExtendoGripInteractionPacket extends SimplePacketBase { - private Hand interactionHand; + private InteractionHand interactionHand; private int target; - private Vector3d specificPoint; + private Vec3 specificPoint; public ExtendoGripInteractionPacket(Entity target) { this(target, null); } - public ExtendoGripInteractionPacket(Entity target, Hand hand) { + public ExtendoGripInteractionPacket(Entity target, InteractionHand hand) { this(target, hand, null); } - public ExtendoGripInteractionPacket(Entity target, Hand hand, Vector3d specificPoint) { + public ExtendoGripInteractionPacket(Entity target, InteractionHand hand, Vec3 specificPoint) { interactionHand = hand; this.specificPoint = specificPoint; this.target = target.getId(); } - public ExtendoGripInteractionPacket(PacketBuffer buffer) { + public ExtendoGripInteractionPacket(FriendlyByteBuf buffer) { target = buffer.readInt(); int handId = buffer.readInt(); - interactionHand = handId == -1 ? null : Hand.values()[handId]; + interactionHand = handId == -1 ? null : InteractionHand.values()[handId]; if (buffer.readBoolean()) - specificPoint = new Vector3d(buffer.readDouble(), buffer.readDouble(), buffer.readDouble()); + specificPoint = new Vec3(buffer.readDouble(), buffer.readDouble(), buffer.readDouble()); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(target); buffer.writeInt(interactionHand == null ? -1 : interactionHand.ordinal()); buffer.writeBoolean(specificPoint != null); @@ -55,7 +55,7 @@ public class ExtendoGripInteractionPacket extends SimplePacketBase { @Override public void handle(Supplier context) { context.get().enqueueWork(() -> { - ServerPlayerEntity sender = context.get().getSender(); + ServerPlayer sender = context.get().getSender(); if (sender == null) return; Entity entityByID = sender.getLevel().getEntity(target); 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 4947f3636..c0bd800c8 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 @@ -12,27 +12,27 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.item.ItemFrameEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.entity.projectile.ProjectileHelper; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Rarity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Hand; -import net.minecraft.util.LazyValue; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.decoration.ItemFrame; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.projectile.ProjectileUtil; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Rarity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.util.LazyLoadedValue; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.InputEvent.ClickInputEvent; @@ -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.world.item.Item.Properties; + @EventBusSubscriber public class ExtendoGripItem extends Item { private static DamageSource lastActiveDamageSource; @@ -62,11 +64,11 @@ public class ExtendoGripItem extends Item { new AttributeModifier(UUID.fromString("8f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier", 5, AttributeModifier.Operation.ADDITION); - static LazyValue> rangeModifier = new LazyValue<>(() -> + static LazyLoadedValue> rangeModifier = new LazyLoadedValue<>(() -> // Holding an ExtendoGrip ImmutableMultimap.of(ForgeMod.REACH_DISTANCE.get(), singleRangeAttributeModifier)); - static LazyValue> doubleRangeModifier = new LazyValue<>(() -> + static LazyLoadedValue> doubleRangeModifier = new LazyLoadedValue<>(() -> // Holding two ExtendoGrips o.O ImmutableMultimap.of(ForgeMod.REACH_DISTANCE.get(), doubleRangeAttributeModifier)); @@ -80,12 +82,12 @@ public class ExtendoGripItem extends Item { @SubscribeEvent public static void holdingExtendoGripIncreasesRange(LivingUpdateEvent event) { - if (!(event.getEntity() instanceof PlayerEntity)) + if (!(event.getEntity() instanceof Player)) return; - PlayerEntity player = (PlayerEntity) event.getEntityLiving(); + Player player = (Player) event.getEntityLiving(); - CompoundNBT persistentData = player.getPersistentData(); + CompoundTag persistentData = player.getPersistentData(); boolean inOff = AllItems.EXTENDO_GRIP.isIn(player.getOffhandItem()); boolean inMain = AllItems.EXTENDO_GRIP.isIn(player.getMainHandItem()); boolean holdingDualExtendo = inOff && inMain; @@ -100,8 +102,8 @@ public class ExtendoGripItem extends Item { .removeAttributeModifiers(rangeModifier.get()); persistentData.remove(EXTENDO_MARKER); } else { - if (player instanceof ServerPlayerEntity) - AllTriggers.EXTENDO.trigger((ServerPlayerEntity) player); + if (player instanceof ServerPlayer) + AllTriggers.EXTENDO.trigger((ServerPlayer) player); player.getAttributes() .addTransientAttributeModifiers(rangeModifier.get()); persistentData.putBoolean(EXTENDO_MARKER, true); @@ -114,8 +116,8 @@ public class ExtendoGripItem extends Item { .removeAttributeModifiers(doubleRangeModifier.get()); persistentData.remove(DUAL_EXTENDO_MARKER); } else { - if (player instanceof ServerPlayerEntity) - AllTriggers.GIGA_EXTENDO.trigger((ServerPlayerEntity) player); + if (player instanceof ServerPlayer) + AllTriggers.GIGA_EXTENDO.trigger((ServerPlayer) player); player.getAttributes() .addTransientAttributeModifiers(doubleRangeModifier.get()); persistentData.putBoolean(DUAL_EXTENDO_MARKER, true); @@ -126,8 +128,8 @@ public class ExtendoGripItem extends Item { @SubscribeEvent public static void addReachToJoiningPlayersHoldingExtendo(PlayerEvent.PlayerLoggedInEvent event) { - PlayerEntity player = event.getPlayer(); - CompoundNBT persistentData = player.getPersistentData(); + Player player = event.getPlayer(); + CompoundTag persistentData = player.getPersistentData(); if (persistentData.contains(DUAL_EXTENDO_MARKER)) player.getAttributes() @@ -141,12 +143,12 @@ public class ExtendoGripItem extends Item { @OnlyIn(Dist.CLIENT) public static void dontMissEntitiesWhenYouHaveHighReachDistance(ClickInputEvent event) { Minecraft mc = Minecraft.getInstance(); - ClientPlayerEntity player = mc.player; + LocalPlayer player = mc.player; if (mc.level == null || player == null) return; if (!isHoldingExtendoGrip(player)) return; - if (mc.hitResult instanceof BlockRayTraceResult && mc.hitResult.getType() != Type.MISS) + if (mc.hitResult instanceof BlockHitResult && mc.hitResult.getType() != Type.MISS) return; // Modified version of GameRenderer#getMouseOver @@ -154,23 +156,23 @@ public class ExtendoGripItem extends Item { .getValue(); if (!player.isCreative()) d0 -= 0.5f; - Vector3d Vector3d = player.getEyePosition(AnimationTickHolder.getPartialTicks()); - Vector3d Vector3d1 = player.getViewVector(1.0F); - Vector3d Vector3d2 = Vector3d.add(Vector3d1.x * d0, Vector3d1.y * d0, Vector3d1.z * d0); - AxisAlignedBB axisalignedbb = player.getBoundingBox() + Vec3 Vector3d = player.getEyePosition(AnimationTickHolder.getPartialTicks()); + Vec3 Vector3d1 = player.getViewVector(1.0F); + Vec3 Vector3d2 = Vector3d.add(Vector3d1.x * d0, Vector3d1.y * d0, Vector3d1.z * d0); + AABB axisalignedbb = player.getBoundingBox() .expandTowards(Vector3d1.scale(d0)) .inflate(1.0D, 1.0D, 1.0D); - EntityRayTraceResult entityraytraceresult = - ProjectileHelper.getEntityHitResult(player, Vector3d, Vector3d2, axisalignedbb, (e) -> { + EntityHitResult entityraytraceresult = + ProjectileUtil.getEntityHitResult(player, Vector3d, Vector3d2, axisalignedbb, (e) -> { return !e.isSpectator() && e.isPickable(); }, d0 * d0); if (entityraytraceresult != null) { Entity entity1 = entityraytraceresult.getEntity(); - Vector3d Vector3d3 = entityraytraceresult.getLocation(); + Vec3 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) + if (entity1 instanceof LivingEntity || entity1 instanceof ItemFrame) mc.crosshairPickEntity = entity1; } } @@ -184,8 +186,8 @@ public class ExtendoGripItem extends Item { @SubscribeEvent(priority = EventPriority.LOWEST) public static void consumeDurabilityOnPlace(EntityPlaceEvent event) { Entity entity = event.getEntity(); - if (entity instanceof PlayerEntity) - findAndDamageExtendoGrip((PlayerEntity) entity); + if (entity instanceof Player) + findAndDamageExtendoGrip((Player) entity); } @SubscribeEvent(priority = EventPriority.LOWEST) @@ -193,20 +195,20 @@ public class ExtendoGripItem extends Item { // findAndDamageExtendoGrip(event.getPlayer()); } - private static void findAndDamageExtendoGrip(PlayerEntity player) { + private static void findAndDamageExtendoGrip(Player player) { if (player == null) return; if (player.level.isClientSide) return; - Hand hand = Hand.MAIN_HAND; + InteractionHand hand = InteractionHand.MAIN_HAND; ItemStack extendo = player.getMainHandItem(); if (!AllItems.EXTENDO_GRIP.isIn(extendo)) { extendo = player.getOffhandItem(); - hand = Hand.OFF_HAND; + hand = InteractionHand.OFF_HAND; } if (!AllItems.EXTENDO_GRIP.isIn(extendo)) return; - final Hand h = hand; + final InteractionHand h = hand; if (!BackTankUtil.canAbsorbDamage(player, maxUses())) extendo.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(h)); } @@ -249,8 +251,8 @@ public class ExtendoGripItem extends Item { if (source == null) return; Entity trueSource = source.getEntity(); - if (trueSource instanceof PlayerEntity) - findAndDamageExtendoGrip((PlayerEntity) trueSource); + if (trueSource instanceof Player) + findAndDamageExtendoGrip((Player) trueSource); } @SubscribeEvent @@ -258,9 +260,9 @@ public class ExtendoGripItem extends Item { if (lastActiveDamageSource == null) return; Entity entity = lastActiveDamageSource.getDirectEntity(); - if (!(entity instanceof PlayerEntity)) + if (!(entity instanceof Player)) return; - PlayerEntity player = (PlayerEntity) entity; + Player player = (Player) entity; if (!isHoldingExtendoGrip(player)) return; event.setStrength(event.getStrength() + 2); @@ -272,7 +274,7 @@ public class ExtendoGripItem extends Item { return false; if (!entity.level.isClientSide) return false; - if (!(entity instanceof PlayerEntity)) + if (!(entity instanceof Player)) return false; return true; } @@ -284,7 +286,7 @@ public class ExtendoGripItem extends Item { Entity target = event.getTarget(); if (!isUncaughtClientInteraction(entity, target)) return; - PlayerEntity player = (PlayerEntity) entity; + Player player = (Player) entity; if (isHoldingExtendoGrip(player)) AllPackets.channel.sendToServer(new ExtendoGripInteractionPacket(target)); } @@ -296,7 +298,7 @@ public class ExtendoGripItem extends Item { Entity target = event.getTarget(); if (!isUncaughtClientInteraction(entity, target)) return; - PlayerEntity player = (PlayerEntity) entity; + Player player = (Player) entity; if (isHoldingExtendoGrip(player)) AllPackets.channel.sendToServer(new ExtendoGripInteractionPacket(target, event.getHand())); } @@ -308,13 +310,13 @@ public class ExtendoGripItem extends Item { Entity target = event.getTarget(); if (!isUncaughtClientInteraction(entity, target)) return; - PlayerEntity player = (PlayerEntity) entity; + Player player = (Player) entity; if (isHoldingExtendoGrip(player)) AllPackets.channel .sendToServer(new ExtendoGripInteractionPacket(target, event.getHand(), event.getLocalPos())); } - public static boolean isHoldingExtendoGrip(PlayerEntity player) { + public static boolean isHoldingExtendoGrip(Player player) { boolean inOff = AllItems.EXTENDO_GRIP.isIn(player.getOffhandItem()); boolean inMain = AllItems.EXTENDO_GRIP.isIn(player.getMainHandItem()); boolean holdingGrip = inOff || inMain; 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 41b2bad89..b195f719d 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 @@ -1,38 +1,38 @@ package com.simibubi.create.content.curiosities.tools; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer { - private static final Vector3d rotationOffset = new Vector3d(0, 1 / 2f, 1 / 2f); - private static final Vector3d cogRotationOffset = new Vector3d(0, 1 / 16f, 0); + private static final Vec3 rotationOffset = new Vec3(0, 1 / 2f, 1 / 2f); + private static final Vec3 cogRotationOffset = new Vec3(0, 1 / 16f, 0); @Override protected void render(ItemStack stack, ExtendoGripModel model, PartialItemModelRenderer renderer, TransformType transformType, - MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + PoseStack ms, MultiBufferSource buffer, int light, int overlay) { MatrixTransformStack stacker = MatrixTransformStack.of(ms); float animation = 0.25f; boolean leftHand = transformType == TransformType.FIRST_PERSON_LEFT_HAND; boolean rightHand = transformType == TransformType.FIRST_PERSON_RIGHT_HAND; if (leftHand || rightHand) - animation = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), + animation = Mth.lerp(AnimationTickHolder.getPartialTicks(), ExtendoGripRenderHandler.lastMainHandAnimation, ExtendoGripRenderHandler.mainHandAnimation); animation = animation * animation * animation; - float extensionAngle = MathHelper.lerp(animation, 24f, 156f); + float extensionAngle = Mth.lerp(animation, 24f, 156f); float halfAngle = extensionAngle / 2; float oppositeAngle = 180 - extensionAngle; @@ -109,7 +109,7 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer mainHandAnimation && swingProgress > 0) mainHandAnimation = 0.95f; - float animation = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), + float animation = Mth.lerp(AnimationTickHolder.getPartialTicks(), ExtendoGripRenderHandler.lastMainHandAnimation, ExtendoGripRenderHandler.mainHandAnimation); animation = animation * animation * animation; @@ -107,7 +107,7 @@ public class ExtendoGripRenderHandler { // Render gun ms.pushPose(); ms.translate(flip * -0.1f, 0, -0.3f); - FirstPersonRenderer firstPersonRenderer = mc.getItemInHandRenderer(); + ItemInHandRenderer 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, 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 5ee736091..3ba6d36e2 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 @@ -5,28 +5,30 @@ import javax.annotation.ParametersAreNonnullByDefault; import com.simibubi.create.foundation.utility.VecHelper; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.UseAction; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ItemParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.UseAnim; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.FakePlayer; +import net.minecraft.world.item.Item.Properties; + @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class SandPaperItem extends Item { @@ -36,27 +38,27 @@ public class SandPaperItem extends Item { } @Override - public UseAction getUseAnimation(ItemStack stack) { - return UseAction.EAT; + public UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.EAT; } @Override - public ActionResultType useOn(ItemUseContext context) { - return ActionResultType.PASS; + public InteractionResult useOn(UseOnContext context) { + return InteractionResult.PASS; } @Override - public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { + public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { ItemStack itemstack = playerIn.getItemInHand(handIn); - ActionResult FAIL = new ActionResult<>(ActionResultType.FAIL, itemstack); + InteractionResultHolder FAIL = new InteractionResultHolder<>(InteractionResult.FAIL, itemstack); if (itemstack.getOrCreateTag() .contains("Polishing")) { playerIn.startUsingItem(handIn); - return new ActionResult<>(ActionResultType.PASS, itemstack); + return new InteractionResultHolder<>(InteractionResult.PASS, itemstack); } - Hand otherHand = handIn == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND; + InteractionHand otherHand = handIn == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; ItemStack itemInOtherHand = playerIn.getItemInHand(otherHand); if (SandPaperPolishingRecipe.canPolish(worldIn, itemInOtherHand)) { ItemStack item = itemInOtherHand.copy(); @@ -65,16 +67,16 @@ public class SandPaperItem extends Item { itemstack.getOrCreateTag() .put("Polishing", toPolish.serializeNBT()); playerIn.setItemInHand(otherHand, item); - return new ActionResult<>(ActionResultType.SUCCESS, itemstack); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, itemstack); } - RayTraceResult raytraceresult = getPlayerPOVHitResult(worldIn, playerIn, RayTraceContext.FluidMode.NONE); - if (!(raytraceresult instanceof BlockRayTraceResult)) + HitResult raytraceresult = getPlayerPOVHitResult(worldIn, playerIn, ClipContext.Fluid.NONE); + if (!(raytraceresult instanceof BlockHitResult)) return FAIL; - BlockRayTraceResult ray = (BlockRayTraceResult) raytraceresult; - Vector3d hitVec = ray.getLocation(); + BlockHitResult ray = (BlockHitResult) raytraceresult; + Vec3 hitVec = ray.getLocation(); - AxisAlignedBB bb = new AxisAlignedBB(hitVec, hitVec).inflate(1f); + AABB bb = new AABB(hitVec, hitVec).inflate(1f); ItemEntity pickUp = null; for (ItemEntity itemEntity : worldIn.getEntitiesOfClass(ItemEntity.class, bb)) { if (!itemEntity.isAlive()) @@ -107,7 +109,7 @@ public class SandPaperItem extends Item { pickUp.setItem(item); } - return new ActionResult<>(ActionResultType.SUCCESS, itemstack); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, itemstack); } @Override @@ -121,11 +123,11 @@ public class SandPaperItem extends Item { } @Override - public ItemStack finishUsingItem(ItemStack stack, World worldIn, LivingEntity entityLiving) { - if (!(entityLiving instanceof PlayerEntity)) + public ItemStack finishUsingItem(ItemStack stack, Level worldIn, LivingEntity entityLiving) { + if (!(entityLiving instanceof Player)) return stack; - PlayerEntity player = (PlayerEntity) entityLiving; - CompoundNBT tag = stack.getOrCreateTag(); + Player player = (Player) entityLiving; + CompoundTag tag = stack.getOrCreateTag(); if (tag.contains("Polishing")) { ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing")); ItemStack polished = @@ -153,20 +155,20 @@ public class SandPaperItem extends Item { return stack; } - public static void spawnParticles(Vector3d location, ItemStack polishedStack, World world) { + public static void spawnParticles(Vec3 location, ItemStack polishedStack, Level world) { for (int i = 0; i < 20; i++) { - Vector3d motion = VecHelper.offsetRandomly(Vector3d.ZERO, world.random, 1 / 8f); - world.addParticle(new ItemParticleData(ParticleTypes.ITEM, polishedStack), location.x, location.y, + Vec3 motion = VecHelper.offsetRandomly(Vec3.ZERO, world.random, 1 / 8f); + world.addParticle(new ItemParticleOption(ParticleTypes.ITEM, polishedStack), location.x, location.y, location.z, motion.x, motion.y, motion.z); } } @Override - public void releaseUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) { - if (!(entityLiving instanceof PlayerEntity)) + public void releaseUsing(ItemStack stack, Level worldIn, LivingEntity entityLiving, int timeLeft) { + if (!(entityLiving instanceof Player)) return; - PlayerEntity player = (PlayerEntity) entityLiving; - CompoundNBT tag = stack.getOrCreateTag(); + Player player = (Player) entityLiving; + CompoundTag tag = stack.getOrCreateTag(); if (tag.contains("Polishing")) { ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing")); player.inventory.placeItemBackInInventory(worldIn, toPolish); 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 6a1524742..c1256664b 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 @@ -1,35 +1,35 @@ package com.simibubi.create.content.curiosities.tools; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.item.render.CreateCustomRenderedItemModel; import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; +import com.mojang.math.Vector3f; public class SandPaperItemRenderer extends CustomRenderedItemModelRenderer { @Override protected void render(ItemStack stack, SandPaperModel model, PartialItemModelRenderer renderer, - TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + TransformType transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; float partialTicks = AnimationTickHolder.getPartialTicks(); boolean leftHand = transformType == TransformType.FIRST_PERSON_LEFT_HAND; boolean firstPerson = leftHand || transformType == TransformType.FIRST_PERSON_RIGHT_HAND; - CompoundNBT tag = stack.getOrCreateTag(); + CompoundTag tag = stack.getOrCreateTag(); boolean jeiMode = tag.contains("JEI"); ms.pushPose(); @@ -49,7 +49,7 @@ public class SandPaperItemRenderer extends CustomRenderedItemModelRenderer { } @Override - public boolean matches(SandPaperInv inv, World worldIn) { + public boolean matches(SandPaperInv inv, Level worldIn) { return ingredients.get(0) .test(inv.getItem(0)); } @@ -39,12 +39,12 @@ public class SandPaperPolishingRecipe extends ProcessingRecipe { return 1; } - public static boolean canPolish(World world, ItemStack stack) { + public static boolean canPolish(Level world, ItemStack stack) { return !getMatchingRecipes(world, stack).isEmpty(); } - public static ItemStack applyPolish(World world, Vector3d position, ItemStack stack, ItemStack sandPaperStack) { - List> matchingRecipes = getMatchingRecipes(world, stack); + public static ItemStack applyPolish(Level world, Vec3 position, ItemStack stack, ItemStack sandPaperStack) { + List> matchingRecipes = getMatchingRecipes(world, stack); if (!matchingRecipes.isEmpty()) return matchingRecipes.get(0) .assemble(new SandPaperInv(stack)) @@ -52,7 +52,7 @@ public class SandPaperPolishingRecipe extends ProcessingRecipe { return stack; } - public static List> getMatchingRecipes(World world, ItemStack stack) { + public static List> getMatchingRecipes(Level world, ItemStack stack) { return world.getRecipeManager() .getRecipesFor(AllRecipeTypes.SANDPAPER_POLISHING.getType(), new SandPaperInv(stack), world); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/BuiltinPotatoProjectileTypes.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/BuiltinPotatoProjectileTypes.java index c3856616c..5fe66885a 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/BuiltinPotatoProjectileTypes.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/BuiltinPotatoProjectileTypes.java @@ -10,34 +10,34 @@ import com.simibubi.create.AllItems; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.WorldAttached; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.FallingBlockEntity; -import net.minecraft.entity.monster.ZombieVillagerEntity; -import net.minecraft.entity.passive.FoxEntity; -import net.minecraft.item.Food; -import net.minecraft.item.Foods; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.potion.Effect; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Effects; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.FallingBlockEntity; +import net.minecraft.world.entity.monster.ZombieVillager; +import net.minecraft.world.entity.animal.Fox; +import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.food.Foods; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.ForgeEventFactory; @@ -49,7 +49,7 @@ public class BuiltinPotatoProjectileTypes { private static final GameProfile ZOMBIE_CONVERTER_NAME = new GameProfile(UUID.fromString("be12d3dc-27d3-4992-8c97-66be53fd49c5"), "Converter"); private static final WorldAttached ZOMBIE_CONVERTERS = - new WorldAttached<>(w -> new FakePlayer((ServerWorld) w, ZOMBIE_CONVERTER_NAME)); + new WorldAttached<>(w -> new FakePlayer((ServerLevel) w, ZOMBIE_CONVERTER_NAME)); public static final PotatoCannonProjectileType @@ -112,7 +112,7 @@ public class BuiltinPotatoProjectileTypes { .knockback(0.05f) .velocity(1.25f) .renderTumbling() - .onEntityHit(potion(Effects.POISON, 1,160, true)) + .onEntityHit(potion(MobEffects.POISON, 1,160, true)) .registerAndAssign(Items.POISONOUS_POTATO), CHORUS_FRUIT = create("chorus_fruit").damage(3) @@ -137,7 +137,7 @@ public class BuiltinPotatoProjectileTypes { .knockback(0.1f) .renderTumbling() .soundPitch(1.1f) - .onEntityHit(potion(Effects.MOVEMENT_SLOWDOWN, 2,160, true)) + .onEntityHit(potion(MobEffects.MOVEMENT_SLOWDOWN, 2,160, true)) .registerAndAssign(AllItems.HONEYED_APPLE.get()), GOLDEN_APPLE = create("golden_apple").damage(1) @@ -148,17 +148,17 @@ public class BuiltinPotatoProjectileTypes { .soundPitch(1.1f) .onEntityHit(ray -> { Entity entity = ray.getEntity(); - World world = entity.level; + Level world = entity.level; - if (!(entity instanceof ZombieVillagerEntity) - || !((ZombieVillagerEntity) entity).hasEffect(Effects.WEAKNESS)) + if (!(entity instanceof ZombieVillager) + || !((ZombieVillager) entity).hasEffect(MobEffects.WEAKNESS)) return foodEffects(Foods.GOLDEN_APPLE, false).test(ray); if (world.isClientSide) return false; FakePlayer dummy = ZOMBIE_CONVERTERS.get(world); - dummy.setItemInHand(Hand.MAIN_HAND, new ItemStack(Items.GOLDEN_APPLE, 1)); - ((ZombieVillagerEntity) entity).mobInteract(dummy, Hand.MAIN_HAND); + dummy.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLDEN_APPLE, 1)); + ((ZombieVillager) entity).mobInteract(dummy, InteractionHand.MAIN_HAND); return true; }) .registerAndAssign(Items.GOLDEN_APPLE), @@ -194,7 +194,7 @@ public class BuiltinPotatoProjectileTypes { .velocity(1.45f) .renderTumbling() .soundPitch(1.5f) - .onEntityHit(potion(Effects.GLOWING, 1, 100, true)) + .onEntityHit(potion(MobEffects.GLOWING, 1, 100, true)) .registerAndAssign(Items.GLISTERING_MELON_SLICE), MELON_BLOCK = create("melon_block").damage(8) @@ -249,48 +249,48 @@ public class BuiltinPotatoProjectileTypes { return new PotatoCannonProjectileType.Builder(Create.asResource(name)); } - private static Predicate setFire(int seconds) { + private static Predicate setFire(int seconds) { return ray -> { ray.getEntity().setSecondsOnFire(seconds); return false; }; } - private static Predicate potion(Effect effect, int level, int ticks, boolean recoverable) { + private static Predicate potion(MobEffect effect, int level, int ticks, boolean recoverable) { return ray -> { Entity entity = ray.getEntity(); if (entity.level.isClientSide) return true; if (entity instanceof LivingEntity) - applyEffect((LivingEntity) entity, new EffectInstance(effect, ticks, level - 1)); + applyEffect((LivingEntity) entity, new MobEffectInstance(effect, ticks, level - 1)); return !recoverable; }; } - private static Predicate foodEffects(Food food, boolean recoverable) { + private static Predicate foodEffects(FoodProperties food, boolean recoverable) { return ray -> { Entity entity = ray.getEntity(); if (entity.level.isClientSide) return true; if (entity instanceof LivingEntity) { - for (Pair effect : food.getEffects()) { + for (Pair effect : food.getEffects()) { if (Create.RANDOM.nextFloat() < effect.getSecond()) - applyEffect((LivingEntity) entity, new EffectInstance(effect.getFirst())); + applyEffect((LivingEntity) entity, new MobEffectInstance(effect.getFirst())); } } return !recoverable; }; } - public static void applyEffect(LivingEntity entity, EffectInstance effect) { + public static void applyEffect(LivingEntity entity, MobEffectInstance effect) { if (effect.getEffect().isInstantenous()) effect.getEffect().applyInstantenousEffect(null, null, entity, effect.getDuration(), 1.0); else entity.addEffect(effect); } - private static BiPredicate plantCrop(IRegistryDelegate cropBlock) { + private static BiPredicate plantCrop(IRegistryDelegate cropBlock) { return (world, ray) -> { if (world.isClientSide()) return true; @@ -314,7 +314,7 @@ public class BuiltinPotatoProjectileTypes { }; } - private static BiPredicate placeBlockOnGround(IRegistryDelegate block) { + private static BiPredicate placeBlockOnGround(IRegistryDelegate block) { return (world, ray) -> { if (world.isClientSide()) return true; @@ -331,14 +331,14 @@ public class BuiltinPotatoProjectileTypes { if (face == Direction.UP) { world.setBlock(placePos, block.get().defaultBlockState(), 3); - } else if (world instanceof World) { + } else if (world instanceof Level) { double y = ray.getLocation().y - 0.5; if (!world.isEmptyBlock(placePos.above())) y = Math.min(y, placePos.getY()); if (!world.isEmptyBlock(placePos.below())) y = Math.max(y, placePos.getY()); - FallingBlockEntity falling = new FallingBlockEntity((World) world, placePos.getX() + 0.5, y, + FallingBlockEntity falling = new FallingBlockEntity((Level) world, placePos.getX() + 0.5, y, placePos.getZ() + 0.5, block.get().defaultBlockState()); falling.time = 1; world.addFreshEntity(falling); @@ -348,10 +348,10 @@ public class BuiltinPotatoProjectileTypes { }; } - private static Predicate chorusTeleport(double teleportDiameter) { + private static Predicate chorusTeleport(double teleportDiameter) { return ray -> { Entity entity = ray.getEntity(); - World world = entity.getCommandSenderWorld(); + Level world = entity.getCommandSenderWorld(); if (world.isClientSide) return true; if (!(entity instanceof LivingEntity)) @@ -364,7 +364,7 @@ public class BuiltinPotatoProjectileTypes { for (int teleportTry = 0; teleportTry < 16; ++teleportTry) { 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 teleportY = Mth.clamp(entityY + (livingEntity.getRandom().nextInt((int) teleportDiameter) - (int) (teleportDiameter / 2)), 0.0D, world.getHeight() - 1); double teleportZ = entityZ + (livingEntity.getRandom().nextDouble() - 0.5D) * teleportDiameter; EntityTeleportEvent.ChorusFruit event = ForgeEventFactory.onChorusFruitTeleport(livingEntity, teleportX, teleportY, teleportZ); @@ -374,10 +374,10 @@ public class BuiltinPotatoProjectileTypes { if (livingEntity.isPassenger()) livingEntity.stopRiding(); - 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); + SoundEvent soundevent = livingEntity instanceof Fox ? SoundEvents.FOX_TELEPORT : SoundEvents.CHORUS_FRUIT_TELEPORT; + world.playSound(null, entityX, entityY, entityZ, soundevent, SoundSource.PLAYERS, 1.0F, 1.0F); livingEntity.playSound(soundevent, 1.0F, 1.0F); - livingEntity.setDeltaMovement(Vector3d.ZERO); + livingEntity.setDeltaMovement(Vec3.ZERO); return true; } } 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 46fb0767d..464a4ada9 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 @@ -15,36 +15,38 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.ShootableItem; -import net.minecraft.item.UseAction; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.ProjectileWeaponItem; +import net.minecraft.world.item.UseAnim; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public class PotatoCannonItem extends ShootableItem { +import net.minecraft.world.item.Item.Properties; + +public class PotatoCannonItem extends ProjectileWeaponItem { public static ItemStack CLIENT_CURRENT_AMMO = ItemStack.EMPTY; public static final int MAX_DAMAGE = 100; @@ -54,7 +56,7 @@ public class PotatoCannonItem extends ShootableItem { } @Override - public boolean canAttackBlock(BlockState state, World world, BlockPos pos, PlayerEntity player) { + public boolean canAttackBlock(BlockState state, Level world, BlockPos pos, Player player) { return false; } @@ -74,7 +76,7 @@ public class PotatoCannonItem extends ShootableItem { } @Override - public ActionResultType useOn(ItemUseContext context) { + public InteractionResult useOn(UseOnContext context) { return use(context.getLevel(), context.getPlayer(), context.getHand()).getResult(); } @@ -117,36 +119,36 @@ public class PotatoCannonItem extends ShootableItem { } @Override - public ActionResult use(World world, PlayerEntity player, Hand hand) { + public InteractionResultHolder use(Level world, Player player, InteractionHand 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); + return InteractionResultHolder.fail(stack); if (world.isClientSide) { CreateClient.POTATO_CANNON_RENDER_HANDLER.dontAnimateItem(hand); - return ActionResult.success(stack); + return InteractionResultHolder.success(stack); } - Vector3d barrelPos = ShootableGadgetItemMethods.getGunBarrelVec(player, hand == Hand.MAIN_HAND, - new Vector3d(.75f, -0.15f, 1.5f)); - Vector3d correction = - ShootableGadgetItemMethods.getGunBarrelVec(player, hand == Hand.MAIN_HAND, new Vector3d(-.05f, 0, 0)) + Vec3 barrelPos = ShootableGadgetItemMethods.getGunBarrelVec(player, hand == InteractionHand.MAIN_HAND, + new Vec3(.75f, -0.15f, 1.5f)); + Vec3 correction = + ShootableGadgetItemMethods.getGunBarrelVec(player, hand == InteractionHand.MAIN_HAND, new Vec3(-.05f, 0, 0)) .subtract(player.position() .add(0, player.getEyeHeight(), 0)); PotatoCannonProjectileType projectileType = PotatoProjectileTypeManager.getTypeForStack(itemStack) .orElse(BuiltinPotatoProjectileTypes.FALLBACK); - Vector3d lookVec = player.getLookAngle(); - Vector3d motion = lookVec.add(correction) + Vec3 lookVec = player.getLookAngle(); + Vec3 motion = lookVec.add(correction) .normalize() .scale(projectileType.getVelocityMultiplier()); float soundPitch = projectileType.getSoundPitch() + (Create.RANDOM.nextFloat() - .5f) / 4f; boolean spray = projectileType.getSplit() > 1; - Vector3d sprayBase = VecHelper.rotate(new Vector3d(0, 0.1, 0), 360 * Create.RANDOM.nextFloat(), Axis.Z); + Vec3 sprayBase = VecHelper.rotate(new Vec3(0, 0.1, 0), 360 * Create.RANDOM.nextFloat(), Axis.Z); float sprayChange = 360f / projectileType.getSplit(); for (int i = 0; i < projectileType.getSplit(); i++) { @@ -154,10 +156,10 @@ public class PotatoCannonItem extends ShootableItem { projectile.setItem(itemStack); projectile.setEnchantmentEffectsFromCannon(stack); - Vector3d splitMotion = motion; + Vec3 splitMotion = motion; if (spray) { float imperfection = 40 * (Create.RANDOM.nextFloat() - 0.5f); - Vector3d sprayOffset = VecHelper.rotate(sprayBase, i * sprayChange + imperfection, Axis.Z); + Vec3 sprayOffset = VecHelper.rotate(sprayBase, i * sprayChange + imperfection, Axis.Z); splitMotion = splitMotion.add(VecHelper.lookAt(sprayOffset, motion)); } @@ -187,9 +189,9 @@ public class PotatoCannonItem extends ShootableItem { ShootableGadgetItemMethods.applyCooldown(player, stack, hand, this::isCannon, cooldown); ShootableGadgetItemMethods.sendPackets(player, b -> new PotatoCannonPacket(barrelPos, lookVec.normalize(), itemStack, hand, soundPitch, b)); - return ActionResult.success(stack); + return InteractionResultHolder.success(stack); }) - .orElse(ActionResult.pass(stack)); + .orElse(InteractionResultHolder.pass(stack)); } @Override @@ -197,7 +199,7 @@ public class PotatoCannonItem extends ShootableItem { return slotChanged || newStack.getItem() != oldStack.getItem(); } - private Optional findAmmoInInventory(World world, PlayerEntity player, ItemStack held) { + private Optional findAmmoInInventory(Level world, Player player, ItemStack held) { ItemStack findAmmo = player.getProjectile(held); return PotatoProjectileTypeManager.getTypeForStack(findAmmo) .map($ -> findAmmo); @@ -209,7 +211,7 @@ public class PotatoCannonItem extends ShootableItem { return Optional.of(CLIENT_CURRENT_AMMO) .filter(stack -> !stack.isEmpty()); - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; CLIENT_CURRENT_AMMO = ItemStack.EMPTY; if (player == null) return Optional.empty(); @@ -222,7 +224,7 @@ public class PotatoCannonItem extends ShootableItem { @Override @OnlyIn(Dist.CLIENT) - public void appendHoverText(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { + public void appendHoverText(ItemStack stack, Level world, List tooltip, TooltipFlag flag) { int power = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, stack); int punch = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.PUNCH_ARROWS, stack); final float additionalDamageMult = 1 + power * .2f; @@ -233,21 +235,21 @@ public class PotatoCannonItem extends ShootableItem { String _reload = "potato_cannon.ammo.reload_ticks"; String _knockback = "potato_cannon.ammo.knockback"; - tooltip.add(new StringTextComponent("")); - tooltip.add(new TranslationTextComponent(ammo.getDescriptionId()).append(new StringTextComponent(":")) - .withStyle(TextFormatting.GRAY)); + tooltip.add(new TextComponent("")); + tooltip.add(new TranslatableComponent(ammo.getDescriptionId()).append(new TextComponent(":")) + .withStyle(ChatFormatting.GRAY)); PotatoCannonProjectileType type = PotatoProjectileTypeManager.getTypeForStack(ammo) .get(); - StringTextComponent spacing = new StringTextComponent(" "); - TextFormatting green = TextFormatting.GREEN; - TextFormatting darkGreen = TextFormatting.DARK_GREEN; + TextComponent spacing = new TextComponent(" "); + ChatFormatting green = ChatFormatting.GREEN; + ChatFormatting darkGreen = ChatFormatting.DARK_GREEN; float damageF = type.getDamage() * additionalDamageMult; - IFormattableTextComponent damage = new StringTextComponent( - damageF == MathHelper.floor(damageF) ? "" + MathHelper.floor(damageF) : "" + damageF); - IFormattableTextComponent reloadTicks = new StringTextComponent("" + type.getReloadTicks()); - IFormattableTextComponent knockback = - new StringTextComponent("" + (type.getKnockback() + additionalKnockback)); + MutableComponent damage = new TextComponent( + damageF == Mth.floor(damageF) ? "" + Mth.floor(damageF) : "" + damageF); + MutableComponent reloadTicks = new TextComponent("" + type.getReloadTicks()); + MutableComponent knockback = + new TextComponent("" + (type.getKnockback() + additionalKnockback)); damage = damage.withStyle(additionalDamageMult > 1 ? green : darkGreen); knockback = knockback.withStyle(additionalKnockback > 0 ? green : darkGreen); @@ -283,8 +285,8 @@ public class PotatoCannonItem extends ShootableItem { } @Override - public UseAction getUseAnimation(ItemStack stack) { - return UseAction.NONE; + public UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.NONE; } @Override 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 b4280d984..da1162bfa 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 @@ -1,36 +1,36 @@ package com.simibubi.create.content.curiosities.weapons; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.item.ItemStack; -import net.minecraft.util.HandSide; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.util.Mth; +import com.mojang.math.Vector3f; public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer { @Override protected void render(ItemStack stack, PotatoCannonModel model, PartialItemModelRenderer renderer, - TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + TransformType transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { ItemRenderer itemRenderer = Minecraft.getInstance() .getItemRenderer(); renderer.render(model.getOriginalModel(), light); - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; boolean mainHand = player.getMainHandItem() == stack; boolean offHand = player.getOffhandItem() == stack; - boolean leftHanded = player.getMainArm() == HandSide.LEFT; + boolean leftHanded = player.getMainArm() == HumanoidArm.LEFT; float offset = .5f / 16; float worldTime = AnimationTickHolder.getRenderTime() / 10; @@ -39,7 +39,7 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer { - MatrixStack localMs = new MatrixStack(); + PoseStack localMs = new PoseStack(); localMs.translate(-1 / 4f, -1 / 4f, 1); localMs.scale(.5f, .5f, .5f); MatrixTransformStack.of(localMs) @@ -64,7 +64,7 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer preEntityHit = e -> false; // True if hit should be canceled - private Predicate onEntityHit = e -> false; // True if shouldn't recover projectile - private BiPredicate onBlockHit = (w, ray) -> false; + private Predicate preEntityHit = e -> false; // True if hit should be canceled + private Predicate onEntityHit = e -> false; // True if shouldn't recover projectile + private BiPredicate onBlockHit = (w, ray) -> false; protected PotatoCannonProjectileType() { } @@ -87,15 +87,15 @@ public class PotatoCannonProjectileType { return renderMode; } - public boolean preEntityHit(EntityRayTraceResult ray) { + public boolean preEntityHit(EntityHitResult ray) { return preEntityHit.test(ray); } - public boolean onEntityHit(EntityRayTraceResult ray) { + public boolean onEntityHit(EntityHitResult ray) { return onEntityHit.test(ray); } - public boolean onBlockHit(IWorld world, BlockRayTraceResult ray) { + public boolean onBlockHit(LevelAccessor world, BlockHitResult ray) { return onBlockHit.test(world, ray); } @@ -146,7 +146,7 @@ public class PotatoCannonProjectileType { } } - public static void toBuffer(PotatoCannonProjectileType type, PacketBuffer buffer) { + public static void toBuffer(PotatoCannonProjectileType type, FriendlyByteBuf buffer) { buffer.writeVarInt(type.items.size()); for (IRegistryDelegate delegate : type.items) { buffer.writeResourceLocation(delegate.name()); @@ -162,7 +162,7 @@ public class PotatoCannonProjectileType { buffer.writeBoolean(type.sticky); } - public static PotatoCannonProjectileType fromBuffer(PacketBuffer buffer) { + public static PotatoCannonProjectileType fromBuffer(FriendlyByteBuf buffer) { PotatoCannonProjectileType type = new PotatoCannonProjectileType(); int size = buffer.readVarInt(); for (int i = 0; i < size; i++) { @@ -258,23 +258,23 @@ public class PotatoCannonProjectileType { return this; } - public Builder preEntityHit(Predicate callback) { + public Builder preEntityHit(Predicate callback) { result.preEntityHit = callback; return this; } - public Builder onEntityHit(Predicate callback) { + public Builder onEntityHit(Predicate callback) { result.onEntityHit = callback; return this; } - public Builder onBlockHit(BiPredicate callback) { + public Builder onBlockHit(BiPredicate callback) { result.onBlockHit = callback; return this; } - public Builder addItems(IItemProvider... items) { - for (IItemProvider provider : items) + public Builder addItems(ItemLike... items) { + for (ItemLike provider : items) result.items.add(provider.asItem().delegate); return this; } @@ -284,7 +284,7 @@ public class PotatoCannonProjectileType { return result; } - public PotatoCannonProjectileType registerAndAssign(IItemProvider... items) { + public PotatoCannonProjectileType registerAndAssign(ItemLike... items) { addItems(items); register(); return result; 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 9f19f3ee6..6141f85f8 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 @@ -1,7 +1,7 @@ package com.simibubi.create.content.curiosities.weapons; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.particle.AirParticleData; @@ -9,19 +9,19 @@ import com.simibubi.create.content.curiosities.zapper.ShootableGadgetRenderHandl import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.ItemParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Hand; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.Vec3; public class PotatoCannonRenderHandler extends ShootableGadgetRenderHandler { private float nextPitch; @Override - protected void playSound(Hand hand, Vector3d position) { + protected void playSound(InteractionHand hand, Vec3 position) { PotatoProjectileEntity.playLaunchSound(Minecraft.getInstance().level, position, nextPitch); } @@ -31,23 +31,23 @@ public class PotatoCannonRenderHandler extends ShootableGadgetRenderHandler { .isCannon(stack); } - public void beforeShoot(float nextPitch, Vector3d location, Vector3d motion, ItemStack stack) { + public void beforeShoot(float nextPitch, Vec3 location, Vec3 motion, ItemStack stack) { this.nextPitch = nextPitch; if (stack.isEmpty()) return; - ClientWorld world = Minecraft.getInstance().level; + ClientLevel 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, + Vec3 m = VecHelper.offsetRandomly(motion.scale(0.1f), Create.RANDOM, .025f); + world.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), location.x, location.y, location.z, m.x, m.y, m.z); - Vector3d m2 = VecHelper.offsetRandomly(motion.scale(2f), Create.RANDOM, .5f); + Vec3 m2 = VecHelper.offsetRandomly(motion.scale(2f), Create.RANDOM, .5f); world.addParticle(new AirParticleData(1, 1 / 4f), location.x, location.y, location.z, m2.x, m2.y, m2.z); } } @Override - protected void transformTool(MatrixStack ms, float flip, float equipProgress, float recoil, float pt) { + protected void transformTool(PoseStack ms, float flip, float equipProgress, float recoil, float pt) { ms.translate(flip * -.1f, 0, .14f); ms.scale(.75f, .75f, .75f); MatrixTransformStack.of(ms) @@ -55,7 +55,7 @@ public class PotatoCannonRenderHandler extends ShootableGadgetRenderHandler { } @Override - protected void transformHand(MatrixStack ms, float flip, float equipProgress, float recoil, float pt) { + protected void transformHand(PoseStack ms, float flip, float equipProgress, float recoil, float pt) { ms.translate(flip * -.09, -.275, -.25); MatrixTransformStack.of(ms) .rotateZ(flip * -10); 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 73c5d924d..2134123d1 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 @@ -8,42 +8,42 @@ import com.simibubi.create.content.contraptions.particle.AirParticleData; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.boss.WitherEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.entity.projectile.DamagingProjectileEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.IPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.server.SChangeGameStatePacket; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ItemParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.DamageSource; -import net.minecraft.util.IndirectEntityDamageSource; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.protocol.game.ClientboundGameEventPacket; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.IndirectEntityDamageSource; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.ItemHandlerHelper; -public class PotatoProjectileEntity extends DamagingProjectileEntity implements IEntityAdditionalSpawnData { +public class PotatoProjectileEntity extends AbstractHurtingProjectile implements IEntityAdditionalSpawnData { protected PotatoCannonProjectileType type; protected ItemStack stack = ItemStack.EMPTY; protected Entity stuckEntity; - protected Vector3d stuckOffset; + protected Vec3 stuckOffset; protected PotatoProjectileRenderMode stuckRenderer; protected double stuckFallSpeed; @@ -51,7 +51,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements protected float additionalKnockback = 0; protected float recoveryChance = 0; - public PotatoProjectileEntity(EntityType type, World world) { + public PotatoProjectileEntity(EntityType type, Level world) { super(type, world); } @@ -87,7 +87,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements } @Override - public void readAdditionalSaveData(CompoundNBT nbt) { + public void readAdditionalSaveData(CompoundTag nbt) { stack = ItemStack.of(nbt.getCompound("Item")); additionalDamageMult = nbt.getFloat("AdditionalDamage"); additionalKnockback = nbt.getFloat("AdditionalKnockback"); @@ -96,7 +96,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements } @Override - public void addAdditionalSaveData(CompoundNBT nbt) { + public void addAdditionalSaveData(CompoundTag nbt) { nbt.put("Item", stack.serializeNBT()); nbt.putFloat("AdditionalDamage", additionalDamageMult); nbt.putFloat("AdditionalKnockback", additionalKnockback); @@ -117,7 +117,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements this.stuckOffset = position().subtract(stuckEntity.position()); this.stuckRenderer = new PotatoProjectileRenderMode.StuckToEntity(stuckOffset); this.stuckFallSpeed = 0.0; - setDeltaMovement(Vector3d.ZERO); + setDeltaMovement(Vec3.ZERO); } public PotatoProjectileRenderMode getRenderMode() { @@ -138,7 +138,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements } else { stuckFallSpeed += 0.007 * projectileType.getGravityMultiplier(); stuckOffset = stuckOffset.add(0, -stuckFallSpeed, 0); - Vector3d pos = stuckEntity.position() + Vec3 pos = stuckEntity.position() .add(stuckOffset); setPos(pos.x, pos.y, pos.z); } @@ -156,7 +156,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements } @Override - protected IParticleData getTrailParticle() { + protected ParticleOptions getTrailParticle() { return new AirParticleData(1, 10); } @@ -166,13 +166,13 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements } @Override - protected void onHitEntity(EntityRayTraceResult ray) { + protected void onHitEntity(EntityHitResult ray) { super.onHitEntity(ray); if (getStuckEntity() != null) return; - Vector3d hit = ray.getLocation(); + Vec3 hit = ray.getLocation(); Entity target = ray.getEntity(); PotatoCannonProjectileType projectileType = getProjectileType(); float damage = projectileType.getDamage() * additionalDamageMult; @@ -188,7 +188,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements pop(hit); - if (target instanceof WitherEntity && ((WitherEntity) target).isPowered()) + if (target instanceof WitherBoss && ((WitherBoss) target).isPowered()) return; if (projectileType.preEntityHit(ray)) return; @@ -224,7 +224,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements livingentity.invulnerableTime = type.getReloadTicks() + 10; if (onServer && knockback > 0) { - Vector3d appliedMotion = this.getDeltaMovement() + Vec3 appliedMotion = this.getDeltaMovement() .multiply(1.0D, 0.0D, 1.0D) .normalize() .scale(knockback * 0.6); @@ -237,17 +237,17 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements EnchantmentHelper.doPostDamageEffects((LivingEntity) owner, livingentity); } - if (livingentity != owner && livingentity instanceof PlayerEntity && owner instanceof ServerPlayerEntity + if (livingentity != owner && livingentity instanceof Player && owner instanceof ServerPlayer && !this.isSilent()) { - ((ServerPlayerEntity) owner).connection - .send(new SChangeGameStatePacket(SChangeGameStatePacket.ARROW_HIT_PLAYER, 0.0F)); + ((ServerPlayer) owner).connection + .send(new ClientboundGameEventPacket(ClientboundGameEventPacket.ARROW_HIT_PLAYER, 0.0F)); } - if (onServer && owner instanceof ServerPlayerEntity) { - ServerPlayerEntity serverplayerentity = (ServerPlayerEntity) owner; + if (onServer && owner instanceof ServerPlayer) { + ServerPlayer serverplayerentity = (ServerPlayer) owner; if (!target.isAlive() && target.getType() - .getCategory() == EntityClassification.MONSTER - || (target instanceof PlayerEntity && target != owner)) + .getCategory() == MobCategory.MONSTER + || (target instanceof Player && target != owner)) AllTriggers.POTATO_KILL.trigger(serverplayerentity); } @@ -264,17 +264,17 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements spawnAtLocation(ItemHandlerHelper.copyStackWithSize(stack, 1)); } - public static void playHitSound(World world, Vector3d location) { + public static void playHitSound(Level world, Vec3 location) { AllSoundEvents.POTATO_HIT.playOnServer(world, new BlockPos(location)); } - public static void playLaunchSound(World world, Vector3d location, float pitch) { + public static void playLaunchSound(Level world, Vec3 location, float pitch) { AllSoundEvents.FWOOMP.playAt(world, location, 1, pitch, true); } @Override - protected void onHitBlock(BlockRayTraceResult ray) { - Vector3d hit = ray.getLocation(); + protected void onHitBlock(BlockHitResult ray) { + Vec3 hit = ray.getLocation(); pop(hit); if (!getProjectileType().onBlockHit(level, ray) && !level.isClientSide) if (random.nextDouble() <= recoveryChance) @@ -294,11 +294,11 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements return true; } - private void pop(Vector3d hit) { + private void pop(Vec3 hit) { if (!stack.isEmpty()) { for (int i = 0; i < 7; i++) { - 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); + Vec3 m = VecHelper.offsetRandomly(Vec3.ZERO, this.random, .25f); + level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), hit.x, hit.y, hit.z, m.x, m.y, m.z); } } if (!level.isClientSide) @@ -324,19 +324,19 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements } @Override - public IPacket getAddEntityPacket() { + public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override - public void writeSpawnData(PacketBuffer buffer) { - CompoundNBT compound = new CompoundNBT(); + public void writeSpawnData(FriendlyByteBuf buffer) { + CompoundTag compound = new CompoundTag(); addAdditionalSaveData(compound); buffer.writeNbt(compound); } @Override - public void readSpawnData(PacketBuffer additionalData) { + public void readSpawnData(FriendlyByteBuf additionalData) { 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 5ef85b0dc..0c6df49f7 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 @@ -3,20 +3,20 @@ package com.simibubi.create.content.curiosities.weapons; import static com.simibubi.create.content.curiosities.weapons.PotatoProjectileRenderMode.entityRandom; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.AngleHelper; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.Entity; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public interface PotatoProjectileRenderMode { @OnlyIn(Dist.CLIENT) - void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt); + void transform(PoseStack ms, PotatoProjectileEntity entity, float pt); public static class Billboard implements PotatoProjectileRenderMode { @@ -24,17 +24,17 @@ public interface PotatoProjectileRenderMode { @Override @OnlyIn(Dist.CLIENT) - public void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt) { + public void transform(PoseStack ms, PotatoProjectileEntity entity, float pt) { Minecraft mc = Minecraft.getInstance(); - Vector3d p1 = mc.getCameraEntity() + Vec3 p1 = mc.getCameraEntity() .getEyePosition(pt); - Vector3d diff = entity.getBoundingBox() + Vec3 diff = entity.getBoundingBox() .getCenter() .subtract(p1); MatrixTransformStack.of(ms) - .rotateY(AngleHelper.deg(MathHelper.atan2(diff.x, diff.z)) + 180) - .rotateX(AngleHelper.deg(MathHelper.atan2(diff.y, MathHelper.sqrt(diff.x * diff.x + diff.z * diff.z)))); + .rotateY(AngleHelper.deg(Mth.atan2(diff.x, diff.z)) + 180) + .rotateX(AngleHelper.deg(Mth.atan2(diff.y, Mth.sqrt(diff.x * diff.x + diff.z * diff.z)))); } } @@ -45,7 +45,7 @@ public interface PotatoProjectileRenderMode { @Override @OnlyIn(Dist.CLIENT) - public void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt) { + public void transform(PoseStack ms, PotatoProjectileEntity entity, float pt) { super.transform(ms, entity, pt); MatrixTransformStack.of(ms) .rotateZ((entity.tickCount + pt) * 2 * entityRandom(entity, 16)) @@ -66,12 +66,12 @@ public interface PotatoProjectileRenderMode { @Override @OnlyIn(Dist.CLIENT) - public void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt) { - Vector3d diff = entity.getDeltaMovement(); + public void transform(PoseStack ms, PotatoProjectileEntity entity, float pt) { + Vec3 diff = entity.getDeltaMovement(); MatrixTransformStack.of(ms) - .rotateY(AngleHelper.deg(MathHelper.atan2(diff.x, diff.z))) + .rotateY(AngleHelper.deg(Mth.atan2(diff.x, diff.z))) .rotateX(270 - + AngleHelper.deg(MathHelper.atan2(diff.y, -MathHelper.sqrt(diff.x * diff.x + diff.z * diff.z)))); + + AngleHelper.deg(Mth.atan2(diff.y, -Mth.sqrt(diff.x * diff.x + diff.z * diff.z)))); MatrixTransformStack.of(ms) .rotateY((entity.tickCount + pt) * 20 * spin + entityRandom(entity, 360)) .rotateZ(-spriteAngleOffset); @@ -81,16 +81,16 @@ public interface PotatoProjectileRenderMode { public static class StuckToEntity implements PotatoProjectileRenderMode { - private Vector3d offset; + private Vec3 offset; - public StuckToEntity(Vector3d offset) { + public StuckToEntity(Vec3 offset) { this.offset = offset; } @Override @OnlyIn(Dist.CLIENT) - public void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt) { - MatrixTransformStack.of(ms).rotateY(AngleHelper.deg(MathHelper.atan2(offset.x, offset.z))); + public void transform(PoseStack ms, PotatoProjectileEntity entity, float pt) { + MatrixTransformStack.of(ms).rotateY(AngleHelper.deg(Mth.atan2(offset.x, offset.z))); } } 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 48138d20b..637f8687c 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 @@ -1,24 +1,24 @@ package com.simibubi.create.content.curiosities.weapons; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; public class PotatoProjectileRenderer extends EntityRenderer { - public PotatoProjectileRenderer(EntityRendererManager p_i46179_1_) { + public PotatoProjectileRenderer(EntityRenderDispatcher p_i46179_1_) { super(p_i46179_1_); } @Override - public void render(PotatoProjectileEntity entity, float yaw, float pt, MatrixStack ms, IRenderTypeBuffer buffer, + public void render(PotatoProjectileEntity entity, float yaw, float pt, PoseStack ms, MultiBufferSource buffer, int light) { ItemStack item = entity.getItem(); if (item.isEmpty()) diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileTypeManager.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileTypeManager.java index 86539ef5e..b0bbe9533 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileTypeManager.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoProjectileTypeManager.java @@ -12,14 +12,14 @@ import com.simibubi.create.AllItems; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.client.resources.JsonReloadListener; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.profiler.IProfiler; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.network.NetworkEvent.Context; import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.registries.IRegistryDelegate; @@ -75,7 +75,7 @@ public class PotatoProjectileTypeManager { ITEM_TO_TYPE_MAP.remove(AllItems.POTATO_CANNON.get().delegate); } - public static void toBuffer(PacketBuffer buffer) { + public static void toBuffer(FriendlyByteBuf buffer) { buffer.writeVarInt(CUSTOM_TYPE_MAP.size()); for (Map.Entry entry : CUSTOM_TYPE_MAP.entrySet()) { buffer.writeResourceLocation(entry.getKey()); @@ -83,7 +83,7 @@ public class PotatoProjectileTypeManager { } } - public static void fromBuffer(PacketBuffer buffer) { + public static void fromBuffer(FriendlyByteBuf buffer) { clear(); int size = buffer.readVarInt(); @@ -94,7 +94,7 @@ public class PotatoProjectileTypeManager { fillItemMap(); } - public static void syncTo(ServerPlayerEntity player) { + public static void syncTo(ServerPlayer player) { AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SyncPacket()); } @@ -102,7 +102,7 @@ public class PotatoProjectileTypeManager { AllPackets.channel.send(PacketDistributor.ALL.noArg(), new SyncPacket()); } - public static class ReloadListener extends JsonReloadListener { + public static class ReloadListener extends SimpleJsonResourceReloadListener { private static final Gson GSON = new Gson(); @@ -113,7 +113,7 @@ public class PotatoProjectileTypeManager { } @Override - protected void apply(Map map, IResourceManager resourceManager, IProfiler profiler) { + protected void apply(Map map, ResourceManager resourceManager, ProfilerFiller profiler) { clear(); for (Map.Entry entry : map.entrySet()) { @@ -133,17 +133,17 @@ public class PotatoProjectileTypeManager { public static class SyncPacket extends SimplePacketBase { - private PacketBuffer buffer; + private FriendlyByteBuf buffer; public SyncPacket() { } - public SyncPacket(PacketBuffer buffer) { + public SyncPacket(FriendlyByteBuf buffer) { this.buffer = buffer; } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { toBuffer(buffer); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoRecoveryEnchantment.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoRecoveryEnchantment.java index d6f770279..0cd8963ad 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoRecoveryEnchantment.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoRecoveryEnchantment.java @@ -1,13 +1,15 @@ package com.simibubi.create.content.curiosities.weapons; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentType; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; + +import net.minecraft.world.item.enchantment.Enchantment.Rarity; public class PotatoRecoveryEnchantment extends Enchantment { - public PotatoRecoveryEnchantment(Rarity p_i46731_1_, EnchantmentType p_i46731_2_, EquipmentSlotType[] p_i46731_3_) { + public PotatoRecoveryEnchantment(Rarity p_i46731_1_, EnchantmentCategory p_i46731_2_, EquipmentSlot[] p_i46731_3_) { super(p_i46731_1_, p_i46731_2_, p_i46731_3_); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ConfigureZapperPacket.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ConfigureZapperPacket.java index ee0026820..760306ac7 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ConfigureZapperPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ConfigureZapperPacket.java @@ -4,29 +4,29 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Hand; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.InteractionHand; import net.minecraftforge.fml.network.NetworkEvent.Context; public abstract class ConfigureZapperPacket extends SimplePacketBase { - protected Hand hand; + protected InteractionHand hand; protected PlacementPatterns pattern; - public ConfigureZapperPacket(Hand hand, PlacementPatterns pattern) { + public ConfigureZapperPacket(InteractionHand hand, PlacementPatterns pattern) { this.hand = hand; this.pattern = pattern; } - public ConfigureZapperPacket(PacketBuffer buffer) { - hand = buffer.readEnum(Hand.class); + public ConfigureZapperPacket(FriendlyByteBuf buffer) { + hand = buffer.readEnum(InteractionHand.class); pattern = buffer.readEnum(PlacementPatterns.class); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeEnum(hand); buffer.writeEnum(pattern); } @@ -34,7 +34,7 @@ public abstract class ConfigureZapperPacket extends SimplePacketBase { @Override public void handle(Supplier context) { context.get().enqueueWork(() -> { - ServerPlayerEntity player = context.get().getSender(); + ServerPlayer player = context.get().getSender(); if (player == null) { return; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/PlacementPatterns.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/PlacementPatterns.java index 9a8f85b9e..c4e5f20da 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/PlacementPatterns.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/PlacementPatterns.java @@ -8,9 +8,9 @@ import com.google.common.base.Predicates; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.BlockPos; public enum PlacementPatterns { @@ -30,7 +30,7 @@ public enum PlacementPatterns { } public static void applyPattern(List blocksIn, ItemStack stack) { - CompoundNBT tag = stack.getTag(); + CompoundTag tag = stack.getTag(); PlacementPatterns pattern = !tag.contains("Pattern") ? Solid : valueOf(tag.getString("Pattern")); Random r = new Random(); 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 8226cc221..91503470c 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 @@ -5,35 +5,35 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Hand; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.Entity; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkEvent.Context; public abstract class ShootGadgetPacket extends SimplePacketBase { - public Vector3d location; - public Hand hand; + public Vec3 location; + public InteractionHand hand; public boolean self; - public ShootGadgetPacket(Vector3d location, Hand hand, boolean self) { + public ShootGadgetPacket(Vec3 location, InteractionHand hand, boolean self) { this.location = location; this.hand = hand; this.self = self; } - public ShootGadgetPacket(PacketBuffer buffer) { - hand = buffer.readBoolean() ? Hand.MAIN_HAND : Hand.OFF_HAND; + public ShootGadgetPacket(FriendlyByteBuf buffer) { + hand = buffer.readBoolean() ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; self = buffer.readBoolean(); - location = new Vector3d(buffer.readDouble(), buffer.readDouble(), buffer.readDouble()); + location = new Vec3(buffer.readDouble(), buffer.readDouble(), buffer.readDouble()); readAdditional(buffer); } - public final void write(PacketBuffer buffer) { - buffer.writeBoolean(hand == Hand.MAIN_HAND); + public final void write(FriendlyByteBuf buffer) { + buffer.writeBoolean(hand == InteractionHand.MAIN_HAND); buffer.writeBoolean(self); buffer.writeDouble(location.x); buffer.writeDouble(location.y); @@ -41,9 +41,9 @@ public abstract class ShootGadgetPacket extends SimplePacketBase { writeAdditional(buffer); } - protected abstract void readAdditional(PacketBuffer buffer); + protected abstract void readAdditional(FriendlyByteBuf buffer); - protected abstract void writeAdditional(PacketBuffer buffer); + protected abstract void writeAdditional(FriendlyByteBuf buffer); @OnlyIn(Dist.CLIENT) protected abstract void handleAdditional(); 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 4ea63ab04..b7a933b40 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 @@ -5,39 +5,39 @@ import java.util.function.Predicate; import com.simibubi.create.foundation.networking.AllPackets; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.HandSide; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fml.network.PacketDistributor; public class ShootableGadgetItemMethods { - public static void applyCooldown(PlayerEntity player, ItemStack item, Hand hand, Predicate predicate, + public static void applyCooldown(Player player, ItemStack item, InteractionHand hand, Predicate predicate, int cooldown) { if (cooldown <= 0) return; boolean gunInOtherHand = - predicate.test(player.getItemInHand(hand == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND)); + predicate.test(player.getItemInHand(hand == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND)); player.getCooldowns() .addCooldown(item.getItem(), gunInOtherHand ? cooldown * 2 / 3 : cooldown); } - public static void sendPackets(PlayerEntity player, Function factory) { - if (!(player instanceof ServerPlayerEntity)) + public static void sendPackets(Player player, Function factory) { + if (!(player instanceof ServerPlayer)) return; AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> player), factory.apply(false)); - AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), factory.apply(true)); + AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), factory.apply(true)); } - public static boolean shouldSwap(PlayerEntity player, ItemStack item, Hand hand, Predicate predicate) { + public static boolean shouldSwap(Player player, ItemStack item, InteractionHand hand, Predicate predicate) { boolean isSwap = item.getTag() .contains("_Swap"); - boolean mainHand = hand == Hand.MAIN_HAND; - boolean gunInOtherHand = predicate.test(player.getItemInHand(mainHand ? Hand.OFF_HAND : Hand.MAIN_HAND)); + boolean mainHand = hand == InteractionHand.MAIN_HAND; + boolean gunInOtherHand = predicate.test(player.getItemInHand(mainHand ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND)); // Pass To Offhand if (mainHand && isSwap && gunInOtherHand) @@ -49,21 +49,21 @@ public class ShootableGadgetItemMethods { item.getTag() .remove("_Swap"); if (!mainHand && gunInOtherHand) - player.getItemInHand(Hand.MAIN_HAND) + player.getItemInHand(InteractionHand.MAIN_HAND) .getTag() .remove("_Swap"); player.startUsingItem(hand); return false; } - public static Vector3d getGunBarrelVec(PlayerEntity player, boolean mainHand, Vector3d rightHandForward) { - Vector3d start = player.position() + public static Vec3 getGunBarrelVec(Player player, boolean mainHand, Vec3 rightHandForward) { + Vec3 start = player.position() .add(0, player.getEyeHeight(), 0); 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.xRot(pitch) + int flip = mainHand == (player.getMainArm() == HumanoidArm.RIGHT) ? -1 : 1; + Vec3 barrelPosNoTransform = new Vec3(flip * rightHandForward.x, rightHandForward.y, rightHandForward.z); + Vec3 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 e381b7be9..178ee161a 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 @@ -1,21 +1,21 @@ package com.simibubi.create.content.curiosities.zapper; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.AbstractClientPlayerEntity; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.FirstPersonRenderer; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.entity.PlayerRenderer; -import net.minecraft.client.renderer.model.ItemCameraTransforms; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.ItemInHandRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.player.PlayerRenderer; +import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.HandSide; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.eventbus.api.IEventBus; @@ -36,7 +36,7 @@ public abstract class ShootableGadgetRenderHandler { } public float getAnimation(boolean rightHand, float partialTicks) { - return MathHelper.lerp(partialTicks, rightHand ? lastRightHandAnimation : lastLeftHandAnimation, + return Mth.lerp(partialTicks, rightHand ? lastRightHandAnimation : lastLeftHandAnimation, rightHand ? rightHandAnimation : leftHandAnimation); } @@ -44,9 +44,9 @@ public abstract class ShootableGadgetRenderHandler { return 0.8f; } - public void shoot(Hand hand, Vector3d location) { - ClientPlayerEntity player = Minecraft.getInstance().player; - boolean rightHand = hand == Hand.MAIN_HAND ^ player.getMainArm() == HandSide.LEFT; + public void shoot(InteractionHand hand, Vec3 location) { + LocalPlayer player = Minecraft.getInstance().player; + boolean rightHand = hand == InteractionHand.MAIN_HAND ^ player.getMainArm() == HumanoidArm.LEFT; if (rightHand) { rightHandAnimation = .2f; dontReequipRight = false; @@ -57,13 +57,13 @@ public abstract class ShootableGadgetRenderHandler { playSound(hand, location); } - protected abstract void playSound(Hand hand, Vector3d position); + protected abstract void playSound(InteractionHand hand, Vec3 position); protected abstract boolean appliesTo(ItemStack stack); - protected abstract void transformTool(MatrixStack ms, float flip, float equipProgress, float recoil, float pt); + protected abstract void transformTool(PoseStack ms, float flip, float equipProgress, float recoil, float pt); - protected abstract void transformHand(MatrixStack ms, float flip, float equipProgress, float recoil, float pt); + protected abstract void transformHand(PoseStack ms, float flip, float equipProgress, float recoil, float pt); public void registerListeners(IEventBus bus) { bus.addListener(this::onRenderPlayerHand); @@ -75,20 +75,20 @@ public abstract class ShootableGadgetRenderHandler { return; Minecraft mc = Minecraft.getInstance(); - AbstractClientPlayerEntity player = mc.player; + AbstractClientPlayer player = mc.player; TextureManager textureManager = mc.getTextureManager(); PlayerRenderer playerrenderer = (PlayerRenderer) mc.getEntityRenderDispatcher() .getRenderer(player); - FirstPersonRenderer firstPersonRenderer = mc.getItemInHandRenderer(); + ItemInHandRenderer firstPersonRenderer = mc.getItemInHandRenderer(); - MatrixStack ms = event.getMatrixStack(); - IRenderTypeBuffer buffer = event.getBuffers(); + PoseStack ms = event.getMatrixStack(); + MultiBufferSource buffer = event.getBuffers(); int light = event.getLight(); float pt = event.getPartialTicks(); - 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); + boolean rightHand = event.getHand() == InteractionHand.MAIN_HAND ^ mc.player.getMainArm() == HumanoidArm.LEFT; + float recoil = rightHand ? Mth.lerp(pt, lastRightHandAnimation, rightHandAnimation) + : Mth.lerp(pt, lastLeftHandAnimation, leftHandAnimation); float equipProgress = event.getEquipProgress(); if (rightHand && (rightHandAnimation > .01f || dontReequipRight)) @@ -101,12 +101,12 @@ public abstract class ShootableGadgetRenderHandler { textureManager.bind(player.getSkinTextureLocation()); float flip = rightHand ? 1.0F : -1.0F; - float f1 = MathHelper.sqrt(event.getSwingProgress()); - float f2 = -0.3F * MathHelper.sin(f1 * (float) Math.PI); - float f3 = 0.4F * MathHelper.sin(f1 * ((float) Math.PI * 2F)); - float f4 = -0.4F * MathHelper.sin(event.getSwingProgress() * (float) Math.PI); - float f5 = MathHelper.sin(event.getSwingProgress() * event.getSwingProgress() * (float) Math.PI); - float f6 = MathHelper.sin(f1 * (float) Math.PI); + float f1 = Mth.sqrt(event.getSwingProgress()); + float f2 = -0.3F * Mth.sin(f1 * (float) Math.PI); + float f3 = 0.4F * Mth.sin(f1 * ((float) Math.PI * 2F)); + float f4 = -0.4F * Mth.sin(event.getSwingProgress() * (float) Math.PI); + float f5 = Mth.sin(event.getSwingProgress() * event.getSwingProgress() * (float) Math.PI); + float f6 = Mth.sin(f1 * (float) Math.PI); ms.translate(flip * (f2 + 0.64F - .1f), f3 + -0.4F + equipProgress * -0.6F, f4 + -0.72F + .3f + recoil); ms.mulPose(Vector3f.YP.rotationDegrees(flip * 75.0F)); @@ -132,17 +132,17 @@ public abstract class ShootableGadgetRenderHandler { 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 ? ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND + : ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !rightHand, ms, buffer, light); ms.popPose(); event.setCanceled(true); } - public void dontAnimateItem(Hand hand) { - ClientPlayerEntity player = Minecraft.getInstance().player; - boolean rightHand = hand == Hand.MAIN_HAND ^ player.getMainArm() == HandSide.LEFT; + public void dontAnimateItem(InteractionHand hand) { + LocalPlayer player = Minecraft.getInstance().player; + boolean rightHand = hand == InteractionHand.MAIN_HAND ^ player.getMainArm() == HumanoidArm.LEFT; dontReequipRight |= rightHand; dontReequipLeft |= !rightHand; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperBeamPacket.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperBeamPacket.java index 0bf447cbe..352728857 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperBeamPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperBeamPacket.java @@ -3,32 +3,32 @@ package com.simibubi.create.content.curiosities.zapper; import com.simibubi.create.CreateClient; import com.simibubi.create.content.curiosities.zapper.ZapperRenderHandler.LaserBeam; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Hand; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class ZapperBeamPacket extends ShootGadgetPacket { - public Vector3d target; + public Vec3 target; - public ZapperBeamPacket(Vector3d start, Vector3d target, Hand hand, boolean self) { + public ZapperBeamPacket(Vec3 start, Vec3 target, InteractionHand hand, boolean self) { super(start, hand, self); this.target = target; } - public ZapperBeamPacket(PacketBuffer buffer) { + public ZapperBeamPacket(FriendlyByteBuf buffer) { super(buffer); } @Override - protected void readAdditional(PacketBuffer buffer) { - target = new Vector3d(buffer.readDouble(), buffer.readDouble(), buffer.readDouble()); + protected void readAdditional(FriendlyByteBuf buffer) { + target = new Vec3(buffer.readDouble(), buffer.readDouble(), buffer.readDouble()); } @Override - protected void writeAdditional(PacketBuffer buffer) { + protected void writeAdditional(FriendlyByteBuf buffer) { buffer.writeDouble(target.x); buffer.writeDouble(target.y); buffer.writeDouble(target.z); 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 7a7ba0e59..453b20c29 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 @@ -6,21 +6,21 @@ import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.foundation.utility.BlockHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.StairsShape; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceContext.BlockMode; -import net.minecraft.util.math.RayTraceContext.FluidMode; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.StairsShape; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -35,21 +35,21 @@ public class ZapperInteractionHandler { ItemStack heldItem = event.getPlayer() .getMainHandItem(); if (heldItem.getItem() instanceof ZapperItem && trySelect(heldItem, event.getPlayer())) { - event.setCancellationResult(ActionResultType.FAIL); + event.setCancellationResult(InteractionResult.FAIL); event.setCanceled(true); } } - public static boolean trySelect(ItemStack stack, PlayerEntity player) { + public static boolean trySelect(ItemStack stack, Player player) { if (player.isShiftKeyDown()) return false; - Vector3d start = player.position() + Vec3 start = player.position() .add(0, player.getEyeHeight(), 0); - Vector3d range = player.getLookAngle() + Vec3 range = player.getLookAngle() .scale(getRange(stack)); - BlockRayTraceResult raytrace = player.level - .clip(new RayTraceContext(start, start.add(range), BlockMode.OUTLINE, FluidMode.NONE, player)); + BlockHitResult raytrace = player.level + .clip(new ClipContext(start, start.add(range), Block.OUTLINE, Fluid.NONE, player)); BlockPos pos = raytrace.getBlockPos(); if (pos == null) return false; @@ -77,22 +77,22 @@ public class ZapperInteractionHandler { if (newState.hasProperty(BlockStateProperties.WATERLOGGED)) newState = newState.setValue(BlockStateProperties.WATERLOGGED, false); - CompoundNBT data = null; - TileEntity tile = player.level.getBlockEntity(pos); + CompoundTag data = null; + BlockEntity tile = player.level.getBlockEntity(pos); if (tile != null) { - data = tile.save(new CompoundNBT()); + data = tile.save(new CompoundTag()); data.remove("x"); data.remove("y"); data.remove("z"); data.remove("id"); } - CompoundNBT tag = stack.getOrCreateTag(); - if (tag.contains("BlockUsed") && NBTUtil.readBlockState(stack.getTag() + CompoundTag tag = stack.getOrCreateTag(); + if (tag.contains("BlockUsed") && NbtUtils.readBlockState(stack.getTag() .getCompound("BlockUsed")) == newState && Objects.equals(data, tag.get("BlockData"))) { return false; } - tag.put("BlockUsed", NBTUtil.writeBlockState(newState)); + tag.put("BlockUsed", NbtUtils.writeBlockState(newState)); if (data == null) tag.remove("BlockData"); else 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 a42370581..4b3139c4c 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 @@ -13,36 +13,38 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTProcessors; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.UseAction; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceContext.BlockMode; -import net.minecraft.util.math.RayTraceContext.FluidMode; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.UseAnim; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fml.DistExecutor; +import net.minecraft.world.item.Item.Properties; + public abstract class ZapperItem extends Item { public ZapperItem(Properties properties) { @@ -51,17 +53,17 @@ public abstract class ZapperItem extends Item { @Override @OnlyIn(Dist.CLIENT) - public void appendHoverText(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + public void appendHoverText(ItemStack stack, Level worldIn, List tooltip, TooltipFlag flagIn) { if (stack.hasTag() && stack.getTag() .contains("BlockUsed")) { - String usedblock = NBTUtil.readBlockState(stack.getTag() + String usedblock = NbtUtils.readBlockState(stack.getTag() .getCompound("BlockUsed")) .getBlock() .getDescriptionId(); ItemDescription.add(tooltip, Lang.translate("terrainzapper.usingBlock", - new TranslationTextComponent(usedblock).withStyle(TextFormatting.GRAY)) - .withStyle(TextFormatting.DARK_GRAY)); + new TranslatableComponent(usedblock).withStyle(ChatFormatting.GRAY)) + .withStyle(ChatFormatting.DARK_GRAY)); } } @@ -72,8 +74,8 @@ public abstract class ZapperItem extends Item { .contains("BlockUsed") && newStack.getTag() .contains("BlockUsed")) - differentBlock = NBTUtil.readBlockState(oldStack.getTag() - .getCompound("BlockUsed")) != NBTUtil.readBlockState( + differentBlock = NbtUtils.readBlockState(oldStack.getTag() + .getCompound("BlockUsed")) != NbtUtils.readBlockState( newStack.getTag() .getCompound("BlockUsed")); return slotChanged || !isZapper(newStack) || differentBlock; @@ -85,7 +87,7 @@ public abstract class ZapperItem extends Item { @Nonnull @Override - public ActionResultType useOn(ItemUseContext context) { + public InteractionResult useOn(UseOnContext context) { // Shift -> open GUI if (context.getPlayer() != null && context.getPlayer() .isShiftKeyDown()) { @@ -98,16 +100,16 @@ public abstract class ZapperItem extends Item { .addCooldown(context.getItemInHand() .getItem(), 10); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } return super.useOn(context); } @Override - public ActionResult use(World world, PlayerEntity player, Hand hand) { + public InteractionResultHolder use(Level world, Player player, InteractionHand hand) { ItemStack item = player.getItemInHand(hand); - CompoundNBT nbt = item.getOrCreateTag(); - boolean mainHand = hand == Hand.MAIN_HAND; + CompoundTag nbt = item.getOrCreateTag(); + boolean mainHand = hand == InteractionHand.MAIN_HAND; // Shift -> Open GUI if (player.isShiftKeyDown()) { @@ -118,53 +120,53 @@ public abstract class ZapperItem extends Item { player.getCooldowns() .addCooldown(item.getItem(), 10); } - return new ActionResult<>(ActionResultType.SUCCESS, item); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, item); } if (ShootableGadgetItemMethods.shouldSwap(player, item, hand, this::isZapper)) - return new ActionResult<>(ActionResultType.FAIL, item); + return new InteractionResultHolder<>(InteractionResult.FAIL, item); // Check if can be used - ITextComponent msg = validateUsage(item); + Component msg = validateUsage(item); if (msg != null) { AllSoundEvents.DENY.play(world, player, player.blockPosition()); player.displayClientMessage(msg.plainCopy() - .withStyle(TextFormatting.RED), true); - return new ActionResult<>(ActionResultType.FAIL, item); + .withStyle(ChatFormatting.RED), true); + return new InteractionResultHolder<>(InteractionResult.FAIL, item); } BlockState stateToUse = Blocks.AIR.defaultBlockState(); if (nbt.contains("BlockUsed")) - stateToUse = NBTUtil.readBlockState(nbt.getCompound("BlockUsed")); + stateToUse = NbtUtils.readBlockState(nbt.getCompound("BlockUsed")); stateToUse = BlockHelper.setZeroAge(stateToUse); - CompoundNBT data = null; + CompoundTag data = null; if (AllBlockTags.SAFE_NBT.matches(stateToUse) && nbt.contains("BlockData", NBT.TAG_COMPOUND)) { data = nbt.getCompound("BlockData"); } // Raytrace - Find the target - Vector3d start = player.position() + Vec3 start = player.position() .add(0, player.getEyeHeight(), 0); - Vector3d range = player.getLookAngle() + Vec3 range = player.getLookAngle() .scale(getZappingRange(item)); - BlockRayTraceResult raytrace = world - .clip(new RayTraceContext(start, start.add(range), BlockMode.OUTLINE, FluidMode.NONE, player)); + BlockHitResult raytrace = world + .clip(new ClipContext(start, start.add(range), Block.OUTLINE, Fluid.NONE, player)); BlockPos pos = raytrace.getBlockPos(); BlockState stateReplaced = world.getBlockState(pos); // No target if (pos == null || stateReplaced.getBlock() == Blocks.AIR) { ShootableGadgetItemMethods.applyCooldown(player, item, hand, this::isZapper, getCooldownDelay(item)); - return new ActionResult<>(ActionResultType.SUCCESS, item); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, item); } // Find exact position of gun barrel for VFX - Vector3d barrelPos = ShootableGadgetItemMethods.getGunBarrelVec(player, mainHand, new Vector3d(.35f, -0.1f, 1)); + Vec3 barrelPos = ShootableGadgetItemMethods.getGunBarrelVec(player, mainHand, new Vec3(.35f, -0.1f, 1)); // Client side if (world.isClientSide) { CreateClient.ZAPPER_RENDER_HANDLER.dontAnimateItem(hand); - return new ActionResult<>(ActionResultType.SUCCESS, item); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, item); } // Server side @@ -174,21 +176,21 @@ public abstract class ZapperItem extends Item { b -> new ZapperBeamPacket(barrelPos, raytrace.getLocation(), hand, b)); } - return new ActionResult<>(ActionResultType.SUCCESS, item); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, item); } - public ITextComponent validateUsage(ItemStack item) { - CompoundNBT tag = item.getOrCreateTag(); + public Component validateUsage(ItemStack item) { + CompoundTag tag = item.getOrCreateTag(); if (!canActivateWithoutSelectedBlock(item) && !tag.contains("BlockUsed")) return Lang.createTranslationTextComponent("terrainzapper.leftClickToSet"); return null; } - protected abstract boolean activate(World world, PlayerEntity player, ItemStack item, BlockState stateToUse, - BlockRayTraceResult raytrace, CompoundNBT data); + protected abstract boolean activate(Level world, Player player, ItemStack item, BlockState stateToUse, + BlockHitResult raytrace, CompoundTag data); @OnlyIn(Dist.CLIENT) - protected abstract void openHandgunGUI(ItemStack item, Hand hand); + protected abstract void openHandgunGUI(ItemStack item, InteractionHand hand); protected abstract int getCooldownDelay(ItemStack item); @@ -204,23 +206,23 @@ public abstract class ZapperItem extends Item { } @Override - public boolean canAttackBlock(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { + public boolean canAttackBlock(BlockState state, Level worldIn, BlockPos pos, Player player) { return false; } @Override - public UseAction getUseAnimation(ItemStack stack) { - return UseAction.NONE; + public UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.NONE; } public static void configureSettings(ItemStack stack, PlacementPatterns pattern) { - CompoundNBT nbt = stack.getOrCreateTag(); + CompoundTag nbt = stack.getOrCreateTag(); NBTHelper.writeEnum(nbt, "Pattern", pattern); } - public static void setTileData(World world, BlockPos pos, BlockState state, CompoundNBT data, PlayerEntity player) { + public static void setTileData(Level world, BlockPos pos, BlockState state, CompoundTag data, Player player) { if (data != null && AllBlockTags.SAFE_NBT.matches(state)) { - TileEntity tile = world.getBlockEntity(pos); + BlockEntity tile = world.getBlockEntity(pos); if (tile != null) { data = NBTProcessors.process(tile, data, !player.isCreative()); if (data == null) 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 4b6aa2dcc..cfa036e88 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 @@ -1,44 +1,44 @@ package com.simibubi.create.content.curiosities.zapper; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.item.render.CustomRenderedItemModel; import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; -import net.minecraft.block.BlockState; -import net.minecraft.block.FourWayBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.CrossCollisionBlock; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.util.Mth; public abstract class ZapperItemRenderer extends CustomRenderedItemModelRenderer { @Override protected void render(ItemStack stack, M model, PartialItemModelRenderer renderer, TransformType transformType, - MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + PoseStack ms, MultiBufferSource buffer, int light, int overlay) { // Block indicator if (transformType == TransformType.GUI && stack.hasTag() && stack.getTag() .contains("BlockUsed")) renderBlockUsed(stack, ms, buffer, light, overlay); } - private void renderBlockUsed(ItemStack stack, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - BlockState state = NBTUtil.readBlockState(stack.getTag() + private void renderBlockUsed(ItemStack stack, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { + BlockState state = NbtUtils.readBlockState(stack.getTag() .getCompound("BlockUsed")); ms.pushPose(); ms.translate(-0.3F, -0.45F, -0.0F); ms.scale(0.25F, 0.25F, 0.25F); - IBakedModel modelForState = Minecraft.getInstance() + BakedModel modelForState = Minecraft.getInstance() .getBlockRenderer() .getBlockModel(state); - if (state.getBlock() instanceof FourWayBlock) + if (state.getBlock() instanceof CrossCollisionBlock) modelForState = Minecraft.getInstance() .getItemRenderer() .getModel(new ItemStack(state.getBlock()), Minecraft.getInstance().level, null); @@ -52,7 +52,7 @@ public abstract class ZapperItemRenderer exte protected float getAnimationProgress(float pt, boolean leftHanded, boolean mainHand) { float animation = CreateClient.ZAPPER_RENDER_HANDLER.getAnimation(mainHand ^ leftHanded, pt); - return MathHelper.clamp(animation * 5, 0, 1); + return Mth.clamp(animation * 5, 0, 1); } } 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 6aa5be7bc..b24aad06d 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 @@ -4,15 +4,15 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template.BlockInfo; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; public class ZapperLog { - private World activeWorld; - private List> log = new LinkedList<>(); + private Level activeWorld; + private List> log = new LinkedList<>(); // private int redoIndex; /* @@ -27,16 +27,16 @@ public class ZapperLog { * */ - public void record(World world, List positions) { + public void record(Level world, List positions) { // if (maxLogLength() == 0) // return; if (world != activeWorld) log.clear(); activeWorld = world; - List blocks = positions.stream().map(pos -> { - TileEntity tileEntity = world.getBlockEntity(pos); - return new BlockInfo(pos, world.getBlockState(pos), tileEntity == null ? null : tileEntity.serializeNBT()); + List blocks = positions.stream().map(pos -> { + BlockEntity tileEntity = world.getBlockEntity(pos); + return new StructureBlockInfo(pos, world.getBlockState(pos), tileEntity == null ? null : tileEntity.serializeNBT()); }).collect(Collectors.toList()); log.add(0, blocks); 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 d04acb1e4..47b6f2cf8 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 @@ -5,17 +5,17 @@ import java.util.List; import java.util.Random; import java.util.function.Supplier; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.CreateClient; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Hand; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; public class ZapperRenderHandler extends ShootableGadgetRenderHandler { @@ -48,17 +48,17 @@ public class ZapperRenderHandler extends ShootableGadgetRenderHandler { } @Override - protected void transformTool(MatrixStack ms, float flip, float equipProgress, float recoil, float pt) { + protected void transformTool(PoseStack ms, float flip, float equipProgress, float recoil, float pt) { ms.translate(flip * -0.1f, 0.1f, -0.4f); ms.mulPose(Vector3f.YP.rotationDegrees(flip * 5.0F)); } @Override - protected void transformHand(MatrixStack ms, float flip, float equipProgress, float recoil, float pt) {} + protected void transformHand(PoseStack ms, float flip, float equipProgress, float recoil, float pt) {} @Override - protected void playSound(Hand hand, Vector3d position) { - float pitch = hand == Hand.MAIN_HAND ? 0.1f : 0.9f; + protected void playSound(InteractionHand hand, Vec3 position) { + float pitch = hand == InteractionHand.MAIN_HAND ? 0.1f : 0.9f; Minecraft mc = Minecraft.getInstance(); AllSoundEvents.WORLDSHAPER_PLACE.play(mc.level, mc.player, position, 0.1f, pitch); } @@ -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().level; + ClientLevel world = Minecraft.getInstance().level; Supplier randomSpeed = () -> (r.nextDouble() - .5d) * .2f; Supplier randomOffset = () -> (r.nextDouble() - .5d) * .2f; for (int i = 0; i < 10; i++) { @@ -82,10 +82,10 @@ public class ZapperRenderHandler extends ShootableGadgetRenderHandler { public static class LaserBeam { float itensity; - Vector3d start; - Vector3d end; + Vec3 start; + Vec3 end; - public LaserBeam(Vector3d start, Vector3d end) { + public LaserBeam(Vec3 start, Vec3 end) { this.start = start; this.end = end; itensity = 1; 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 feaf0561e..3640079ee 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 @@ -2,7 +2,7 @@ package com.simibubi.create.content.curiosities.zapper; import java.util.Vector; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.AbstractSimiScreen; import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.AllIcons; @@ -12,27 +12,27 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.Hand; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.InteractionHand; +import com.mojang.math.Vector3f; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public abstract class ZapperScreen extends AbstractSimiScreen { - protected final ITextComponent patternSection = Lang.translate("gui.terrainzapper.patternSection"); + protected final Component patternSection = Lang.translate("gui.terrainzapper.patternSection"); protected AllGuiTextures background; protected ItemStack zapper; - protected Hand hand; + protected InteractionHand hand; protected float animationProgress; - protected ITextComponent title; + protected Component title; protected Vector patternButtons = new Vector<>(6); private IconButton confirmButton; protected int brightColor; @@ -40,15 +40,15 @@ public abstract class ZapperScreen extends AbstractSimiScreen { protected PlacementPatterns currentPattern; - public ZapperScreen(AllGuiTextures background, ItemStack zapper, Hand hand) { + public ZapperScreen(AllGuiTextures background, ItemStack zapper, InteractionHand hand) { this.background = background; this.zapper = zapper; this.hand = hand; - title = StringTextComponent.EMPTY; + title = TextComponent.EMPTY; brightColor = 0xFEFEFE; fontColor = AllGuiTextures.FONT_COLOR; - CompoundNBT nbt = zapper.getOrCreateTag(); + CompoundTag nbt = zapper.getOrCreateTag(); currentPattern = NBTHelper.readEnum(nbt, "Pattern", PlacementPatterns.class); } @@ -86,7 +86,7 @@ public abstract class ZapperScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int x = guiLeft; int y = guiTop; @@ -97,7 +97,7 @@ public abstract class ZapperScreen extends AbstractSimiScreen { renderZapper(ms, x, y); } - protected void drawOnBackground(MatrixStack ms, int x, int y) { + protected void drawOnBackground(PoseStack ms, int x, int y) { font.draw(ms, title, x + 11, y + 4, 0x54214F); } @@ -133,14 +133,14 @@ public abstract class ZapperScreen extends AbstractSimiScreen { return super.mouseClicked(x, y, button); } - protected void renderZapper(MatrixStack ms, int x, int y) { + protected void renderZapper(PoseStack ms, int x, int y) { GuiGameElement.of(zapper) .scale(4) .at(x + background.width, y + background.height - 48, -200) .render(ms); } - protected void renderBlock(MatrixStack ms, int x, int y) { + protected void renderBlock(PoseStack ms, int x, int y) { ms.pushPose(); ms.translate(x + 32, y + 42, 120); ms.mulPose(new Vector3f(1f, 0, 0).rotationDegrees(-25f)); @@ -150,7 +150,7 @@ public abstract class ZapperScreen extends AbstractSimiScreen { BlockState state = Blocks.AIR.defaultBlockState(); if (zapper.hasTag() && zapper.getTag() .contains("BlockUsed")) - state = NBTUtil.readBlockState(zapper.getTag() + state = NbtUtils.readBlockState(zapper.getTag() .getCompound("BlockUsed")); GuiGameElement.of(state) diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/Brush.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/Brush.java index 8ff5ac568..53e245c99 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/Brush.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/Brush.java @@ -4,11 +4,11 @@ import java.util.Collection; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.IWorld; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.LevelAccessor; public abstract class Brush { @@ -51,7 +51,7 @@ public abstract class Brush { return 0; } - ITextComponent getParamLabel(int paramIndex) { + Component getParamLabel(int paramIndex) { return Lang .translate(paramIndex == 0 ? "generic.width" : paramIndex == 1 ? "generic.height" : "generic.length"); } @@ -60,11 +60,11 @@ public abstract class Brush { return paramIndex == 0 ? param0 : paramIndex == 1 ? param1 : param2; } - public BlockPos getOffset(Vector3d ray, Direction face, PlacementOptions option) { + public BlockPos getOffset(Vec3 ray, Direction face, PlacementOptions option) { return BlockPos.ZERO; } - public abstract Collection addToGlobalPositions(IWorld world, BlockPos targetPos, Direction targetFace, + public abstract Collection addToGlobalPositions(LevelAccessor world, BlockPos targetPos, Direction targetFace, Collection affectedPositions, TerrainTools usedTool); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/ConfigureWorldshaperPacket.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/ConfigureWorldshaperPacket.java index a5b849c85..6649c84a3 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/ConfigureWorldshaperPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/ConfigureWorldshaperPacket.java @@ -3,9 +3,9 @@ package com.simibubi.create.content.curiosities.zapper.terrainzapper; import com.simibubi.create.content.curiosities.zapper.ConfigureZapperPacket; import com.simibubi.create.content.curiosities.zapper.PlacementPatterns; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Hand; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.InteractionHand; public class ConfigureWorldshaperPacket extends ConfigureZapperPacket { @@ -16,7 +16,7 @@ public class ConfigureWorldshaperPacket extends ConfigureZapperPacket { protected TerrainTools tool; protected PlacementOptions placement; - public ConfigureWorldshaperPacket(Hand hand, PlacementPatterns pattern, TerrainBrushes brush, int brushParamX, int brushParamY, int brushParamZ, TerrainTools tool, PlacementOptions placement) { + public ConfigureWorldshaperPacket(InteractionHand hand, PlacementPatterns pattern, TerrainBrushes brush, int brushParamX, int brushParamY, int brushParamZ, TerrainTools tool, PlacementOptions placement) { super(hand, pattern); this.brush = brush; this.brushParamX = brushParamX; @@ -26,7 +26,7 @@ public class ConfigureWorldshaperPacket extends ConfigureZapperPacket { this.placement = placement; } - public ConfigureWorldshaperPacket(PacketBuffer buffer) { + public ConfigureWorldshaperPacket(FriendlyByteBuf buffer) { super(buffer); brush = buffer.readEnum(TerrainBrushes.class); brushParamX = buffer.readVarInt(); @@ -37,7 +37,7 @@ public class ConfigureWorldshaperPacket extends ConfigureZapperPacket { } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { super.write(buffer); buffer.writeEnum(brush); buffer.writeVarInt(brushParamX); 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 f7c5d7f45..b63caa1e7 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 @@ -4,10 +4,10 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class CuboidBrush extends ShapedBrush { @@ -44,7 +44,7 @@ public class CuboidBrush extends ShapedBrush { } @Override - public BlockPos getOffset(Vector3d ray, Direction face, PlacementOptions option) { + public BlockPos getOffset(Vec3 ray, Direction face, PlacementOptions option) { if (option == PlacementOptions.Merged) return BlockPos.ZERO; 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 9ca87ced9..5e04846e0 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 @@ -11,11 +11,11 @@ import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; public class CylinderBrush extends ShapedBrush { @@ -48,7 +48,7 @@ public class CylinderBrush extends ShapedBrush { } @Override - public BlockPos getOffset(Vector3d ray, Direction face, PlacementOptions option) { + public BlockPos getOffset(Vec3 ray, Direction face, PlacementOptions option) { if (option == PlacementOptions.Merged) return BlockPos.ZERO; @@ -73,7 +73,7 @@ public class CylinderBrush extends ShapedBrush { } @Override - ITextComponent getParamLabel(int paramIndex) { + Component getParamLabel(int paramIndex) { return paramIndex == 0 ? Lang.translate("generic.radius") : super.getParamLabel(paramIndex); } 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 7e262093d..1fa0aa89f 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 @@ -9,11 +9,11 @@ import java.util.Set; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.LevelAccessor; public class DynamicBrush extends Brush { @@ -26,7 +26,7 @@ public class DynamicBrush extends Brush { this.surface = surface; } - ITextComponent getParamLabel(int paramIndex) { + Component getParamLabel(int paramIndex) { return Lang.translate("generic.range"); } @@ -64,7 +64,7 @@ public class DynamicBrush extends Brush { } @Override - public Collection addToGlobalPositions(IWorld world, BlockPos targetPos, Direction targetFace, + public Collection addToGlobalPositions(LevelAccessor world, BlockPos targetPos, Direction targetFace, Collection affectedPositions, TerrainTools usedTool) { boolean searchDiagonals = param1 == 0; 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 fc7287ca7..eddbc36cd 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 @@ -7,12 +7,12 @@ import java.util.Map; import org.apache.commons.lang3.tuple.Pair; -import net.minecraft.block.BlockState; -import net.minecraft.block.FlowingFluidBlock; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; public class FlattenTool { @@ -47,13 +47,13 @@ public class FlattenTool { newValue += kernel[iOffset + 2][jOffset + 2] * ref; } } - result[i][j] = MathHelper.floor(newValue + .5f); + result[i][j] = Mth.floor(newValue + .5f); } } return result; } - public static void apply(World world, List targetPositions, Direction facing) { + public static void apply(Level world, List targetPositions, Direction facing) { List surfaces = new ArrayList<>(); Map, Integer> heightMap = new HashMap<>(); int offset = facing.getAxisDirection().getStep(); @@ -153,7 +153,7 @@ public class FlattenTool { // Raise surface while (surfaceCoord < targetCoord) { BlockPos above = p.relative(facing); - if (!(blockState.getBlock() instanceof FlowingFluidBlock)) + if (!(blockState.getBlock() instanceof LiquidBlock)) world.setBlockAndUpdate(above, blockState); world.setBlockAndUpdate(p, world.getBlockState(p.relative(facing.getOpposite()))); p = p.relative(facing); 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 c89e5c7a3..54b5ed258 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 @@ -3,9 +3,9 @@ package com.simibubi.create.content.curiosities.zapper.terrainzapper; import java.util.Collection; import java.util.List; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; public abstract class ShapedBrush extends Brush { @@ -14,7 +14,7 @@ public abstract class ShapedBrush extends Brush { } @Override - public Collection addToGlobalPositions(IWorld world, BlockPos targetPos, Direction targetFace, + public Collection addToGlobalPositions(LevelAccessor world, BlockPos targetPos, Direction targetFace, Collection affectedPositions, TerrainTools usedTool) { List includedPositions = getIncludedPositions(); if (includedPositions == null) 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 544e70d1d..ffc9e8e58 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 @@ -8,10 +8,10 @@ import java.util.stream.Collectors; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; public class SphereBrush extends ShapedBrush { @@ -34,7 +34,7 @@ public class SphereBrush extends ShapedBrush { } @Override - public BlockPos getOffset(Vector3d ray, Direction face, PlacementOptions option) { + public BlockPos getOffset(Vec3 ray, Direction face, PlacementOptions option) { if (option == PlacementOptions.Merged) return BlockPos.ZERO; @@ -50,7 +50,7 @@ public class SphereBrush extends ShapedBrush { } @Override - ITextComponent getParamLabel(int paramIndex) { + Component getParamLabel(int paramIndex) { return Lang.translate("generic.radius"); } 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 1c51a6883..0492f375e 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 @@ -8,13 +8,13 @@ import com.simibubi.create.content.curiosities.zapper.ZapperItem; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.player.Player; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public enum TerrainTools { @@ -39,7 +39,7 @@ public enum TerrainTools { return this != Clear && this != Flatten; } - public void run(World world, List targetPositions, Direction facing, @Nullable BlockState paintedState, @Nullable CompoundNBT data, PlayerEntity player) { + public void run(Level world, List targetPositions, Direction facing, @Nullable BlockState paintedState, @Nullable CompoundTag data, Player player) { switch (this) { case Clear: targetPositions.forEach(p -> world.setBlockAndUpdate(p, Blocks.AIR.defaultBlockState())); 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 ddaf57ad8..c0d6e7919 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 @@ -9,19 +9,21 @@ import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.item.Item.Properties; + public class WorldshaperItem extends ZapperItem { public WorldshaperItem(Properties properties) { @@ -30,7 +32,7 @@ public class WorldshaperItem extends ZapperItem { @Override @OnlyIn(value = Dist.CLIENT) - protected void openHandgunGUI(ItemStack item, Hand hand) { + protected void openHandgunGUI(ItemStack item, InteractionHand hand) { ScreenOpener.open(new WorldshaperScreen(item, hand)); } @@ -45,7 +47,7 @@ public class WorldshaperItem extends ZapperItem { } @Override - public ITextComponent validateUsage(ItemStack item) { + public Component validateUsage(ItemStack item) { if (!item.getOrCreateTag() .contains("BrushParams")) return Lang.createTranslationTextComponent("terrainzapper.shiftRightClickToSet"); @@ -54,22 +56,22 @@ public class WorldshaperItem extends ZapperItem { @Override protected boolean canActivateWithoutSelectedBlock(ItemStack stack) { - CompoundNBT tag = stack.getOrCreateTag(); + CompoundTag tag = stack.getOrCreateTag(); TerrainTools tool = NBTHelper.readEnum(tag, "Tool", TerrainTools.class); return !tool.requiresSelectedBlock(); } @Override - protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState stateToUse, - BlockRayTraceResult raytrace, CompoundNBT data) { + protected boolean activate(Level world, Player player, ItemStack stack, BlockState stateToUse, + BlockHitResult raytrace, CompoundTag data) { BlockPos targetPos = raytrace.getBlockPos(); List affectedPositions = new ArrayList<>(); - CompoundNBT tag = stack.getOrCreateTag(); + CompoundTag tag = stack.getOrCreateTag(); Brush brush = NBTHelper.readEnum(tag, "Brush", TerrainBrushes.class) .get(); - BlockPos params = NBTUtil.readBlockPos(tag.getCompound("BrushParams")); + BlockPos params = NbtUtils.readBlockPos(tag.getCompound("BrushParams")); PlacementOptions option = NBTHelper.readEnum(tag, "Placement", PlacementOptions.class); TerrainTools tool = NBTHelper.readEnum(tag, "Tool", TerrainTools.class); @@ -85,9 +87,9 @@ public class WorldshaperItem extends ZapperItem { public static void configureSettings(ItemStack stack, PlacementPatterns pattern, TerrainBrushes brush, int brushParamX, int brushParamY, int brushParamZ, TerrainTools tool, PlacementOptions placement) { ZapperItem.configureSettings(stack, pattern); - CompoundNBT nbt = stack.getOrCreateTag(); + CompoundTag nbt = stack.getOrCreateTag(); NBTHelper.writeEnum(nbt, "Brush", brush); - nbt.put("BrushParams", NBTUtil.writeBlockPos(new BlockPos(brushParamX, brushParamY, brushParamZ))); + nbt.put("BrushParams", NbtUtils.writeBlockPos(new BlockPos(brushParamX, brushParamY, brushParamZ))); NBTHelper.writeEnum(nbt, "Tool", tool); NBTHelper.writeEnum(nbt, "Placement", placement); } 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 810272fd5..2700cf96f 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 @@ -3,27 +3,27 @@ package com.simibubi.create.content.curiosities.zapper.terrainzapper; import static java.lang.Math.max; import static net.minecraft.util.math.MathHelper.clamp; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.curiosities.zapper.ZapperItemRenderer; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.item.ItemStack; -import net.minecraft.util.HandSide; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.util.Mth; +import com.mojang.math.Vector3f; public class WorldshaperItemRenderer extends ZapperItemRenderer { @Override - protected void render(ItemStack stack, WorldshaperModel model, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, - MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + protected void render(ItemStack stack, WorldshaperModel model, PartialItemModelRenderer renderer, ItemTransforms.TransformType transformType, + PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.render(stack, model, renderer, transformType, ms, buffer, light, overlay); float pt = AnimationTickHolder.getPartialTicks(); @@ -31,14 +31,14 @@ public class WorldshaperItemRenderer extends ZapperItemRenderer brushOptions = + protected final Component placementSection = Lang.translate("gui.terrainzapper.placement"); + protected final Component toolSection = Lang.translate("gui.terrainzapper.tool"); + protected final List brushOptions = Lang.translatedOptions("gui.terrainzapper.brush", "cuboid", "sphere", "cylinder", "surface", "cluster"); protected Vector toolButtons; @@ -52,15 +52,15 @@ public class WorldshaperScreen extends ZapperScreen { protected TerrainTools currentTool; protected PlacementOptions currentPlacement; - public WorldshaperScreen(ItemStack zapper, Hand hand) { + public WorldshaperScreen(ItemStack zapper, InteractionHand hand) { super(AllGuiTextures.TERRAINZAPPER, zapper, hand); fontColor = 0x767676; title = zapper.getHoverName(); - CompoundNBT nbt = zapper.getOrCreateTag(); + CompoundTag nbt = zapper.getOrCreateTag(); currentBrush = NBTHelper.readEnum(nbt, "Brush", TerrainBrushes.class); if (nbt.contains("BrushParams", Constants.NBT.TAG_COMPOUND)) { - BlockPos paramsData = NBTUtil.readBlockPos(nbt.getCompound("BrushParams")); + BlockPos paramsData = NbtUtils.readBlockPos(nbt.getCompound("BrushParams")); currentBrushParams[0] = paramsData.getX(); currentBrushParams[1] = paramsData.getY(); currentBrushParams[2] = paramsData.getZ(); @@ -82,7 +82,7 @@ public class WorldshaperScreen extends ZapperScreen { int x = guiLeft; int y = guiTop; - brushLabel = new Label(x + 61, y + 25, StringTextComponent.EMPTY).withShadow(); + brushLabel = new Label(x + 61, y + 25, TextComponent.EMPTY).withShadow(); brushInput = new SelectionScrollInput(x + 56, y + 20, 77, 18).forOptions(brushOptions) .titled(Lang.translate("gui.terrainzapper.brush")) .writingTo(brushLabel) @@ -111,7 +111,7 @@ public class WorldshaperScreen extends ZapperScreen { brushParams.clear(); for (int index = 0; index < 3; index++) { - Label label = new Label(x + 65 + 20 * index, y + 45, StringTextComponent.EMPTY).withShadow(); + Label label = new Label(x + 65 + 20 * index, y + 45, TextComponent.EMPTY).withShadow(); final int finalIndex = index; ScrollInput input = new ScrollInput(x + 56 + 20 * index, y + 40, 18, 18) @@ -155,10 +155,10 @@ public class WorldshaperScreen extends ZapperScreen { if (currentBrush.hasConnectivityOptions()) { int x1 = x + 7 + 4 * 18; int y1 = y + 79; - followDiagonalsIndicator = new Indicator(x1, y1 - 6, StringTextComponent.EMPTY); + followDiagonalsIndicator = new Indicator(x1, y1 - 6, TextComponent.EMPTY); followDiagonals = new IconButton(x1, y1, AllIcons.I_FOLLOW_DIAGONAL); x1 += 18; - acrossMaterialsIndicator = new Indicator(x1, y1 - 6, StringTextComponent.EMPTY); + acrossMaterialsIndicator = new Indicator(x1, y1 - 6, TextComponent.EMPTY); acrossMaterials = new IconButton(x1, y1, AllIcons.I_FOLLOW_MATERIAL); followDiagonals.setToolTip(Lang.translate("gui.terrainzapper.searchDiagonal")); @@ -257,7 +257,7 @@ public class WorldshaperScreen extends ZapperScreen { } @Override - protected void drawOnBackground(MatrixStack matrixStack, int x, int y) { + protected void drawOnBackground(PoseStack matrixStack, int x, int y) { super.drawOnBackground(matrixStack, x, y); Brush currentBrush = this.currentBrush.get(); diff --git a/src/main/java/com/simibubi/create/content/logistics/IRedstoneLinkable.java b/src/main/java/com/simibubi/create/content/logistics/IRedstoneLinkable.java index 34286e6f6..a881f4a0f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/IRedstoneLinkable.java +++ b/src/main/java/com/simibubi/create/content/logistics/IRedstoneLinkable.java @@ -4,7 +4,7 @@ import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler.Frequency; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; public interface IRedstoneLinkable { 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 d16baef0e..59d4b86b9 100644 --- a/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java @@ -14,14 +14,14 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour; import com.simibubi.create.foundation.utility.WorldHelper; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.world.IWorld; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.LevelAccessor; public class RedstoneLinkNetworkHandler { - static final Map, Set>> connections = + static final Map, Set>> connections = new IdentityHashMap<>(); public static class Frequency { @@ -42,7 +42,7 @@ public class RedstoneLinkNetworkHandler { private Frequency(ItemStack stack) { this.stack = stack; item = stack.getItem(); - CompoundNBT displayTag = stack.getTagElement("display"); + CompoundTag displayTag = stack.getTagElement("display"); color = displayTag != null && displayTag.contains("color") ? displayTag.getInt("color") : -1; } @@ -65,17 +65,17 @@ public class RedstoneLinkNetworkHandler { } - public void onLoadWorld(IWorld world) { + public void onLoadWorld(LevelAccessor world) { connections.put(world, new HashMap<>()); Create.LOGGER.debug("Prepared Redstone Network Space for " + WorldHelper.getDimensionID(world)); } - public void onUnloadWorld(IWorld world) { + public void onUnloadWorld(LevelAccessor world) { connections.remove(world); Create.LOGGER.debug("Removed Redstone Network Space for " + WorldHelper.getDimensionID(world)); } - public Set getNetworkOf(IWorld world, IRedstoneLinkable actor) { + public Set getNetworkOf(LevelAccessor world, IRedstoneLinkable actor) { Map, Set> networksInWorld = networksIn(world); Pair key = actor.getNetworkKey(); if (!networksInWorld.containsKey(key)) @@ -83,12 +83,12 @@ public class RedstoneLinkNetworkHandler { return networksInWorld.get(key); } - public void addToNetwork(IWorld world, IRedstoneLinkable actor) { + public void addToNetwork(LevelAccessor world, IRedstoneLinkable actor) { getNetworkOf(world, actor).add(actor); updateNetworkOf(world, actor); } - public void removeFromNetwork(IWorld world, IRedstoneLinkable actor) { + public void removeFromNetwork(LevelAccessor world, IRedstoneLinkable actor) { Set network = getNetworkOf(world, actor); network.remove(actor); if (network.isEmpty()) { @@ -98,7 +98,7 @@ public class RedstoneLinkNetworkHandler { updateNetworkOf(world, actor); } - public void updateNetworkOf(IWorld world, IRedstoneLinkable actor) { + public void updateNetworkOf(LevelAccessor world, IRedstoneLinkable actor) { Set network = getNetworkOf(world, actor); int power = 0; @@ -141,7 +141,7 @@ public class RedstoneLinkNetworkHandler { .closerThan(to.getLocation(), AllConfigs.SERVER.logistics.linkRange.get()); } - public Map, Set> networksIn(IWorld world) { + public Map, Set> networksIn(LevelAccessor world) { if (!connections.containsKey(world)) { Create.LOGGER.warn("Tried to Access unprepared network space of " + WorldHelper.getDimensionID(world)); return new HashMap<>(); 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 72207158e..97237915e 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 @@ -4,8 +4,8 @@ import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.core.materials.IFlatLight; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.core.BlockPos; +import com.mojang.math.Vector3f; public class FlapData extends InstanceData implements IFlatLight { 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 561ed4619..f87944bb6 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 @@ -12,28 +12,30 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputB import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.Property; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class BeltTunnelBlock extends Block implements ITE, IWrenchable { @@ -45,7 +47,7 @@ public class BeltTunnelBlock extends Block implements ITE, registerDefaultState(defaultBlockState().setValue(SHAPE, Shape.STRAIGHT)); } - public enum Shape implements IStringSerializable { + public enum Shape implements StringRepresentable { STRAIGHT, WINDOW, CLOSED, T_LEFT, T_RIGHT, CROSS; @Override @@ -60,17 +62,17 @@ public class BeltTunnelBlock extends Block implements ITE, } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return BeltTunnelShapes.getShape(state); } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.ANDESITE_TUNNEL.create(); } @Override - public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) { BlockState blockState = worldIn.getBlockState(pos.below()); if (!isValidPositionForPlacement(state, worldIn, pos)) return false; @@ -79,7 +81,7 @@ public class BeltTunnelBlock extends Block implements ITE, return true; } - public boolean isValidPositionForPlacement(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean isValidPositionForPlacement(BlockState state, LevelReader worldIn, BlockPos pos) { BlockState blockState = worldIn.getBlockState(pos.below()); if (!AllBlocks.BELT.has(blockState)) return false; @@ -102,18 +104,18 @@ public class BeltTunnelBlock extends Block implements ITE, } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { return getTunnelState(context.getLevel(), context.getClickedPos()); } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) { + public void onPlace(BlockState state, Level 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 updateShape(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { if (facing.getAxis() .isVertical()) @@ -129,18 +131,18 @@ public class BeltTunnelBlock extends Block implements ITE, return tunnelState; } - public void updateTunnel(IWorld world, BlockPos pos) { + public void updateTunnel(LevelAccessor world, BlockPos pos) { BlockState tunnel = world.getBlockState(pos); BlockState newTunnel = getTunnelState(world, pos); if (tunnel != newTunnel && !world.isClientSide()) { world.setBlock(pos, newTunnel, 3); - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (te != null && (te instanceof BeltTunnelTileEntity)) ((BeltTunnelTileEntity) te).updateTunnelConnections(); } } - private BlockState getTunnelState(IBlockReader reader, BlockPos pos) { + private BlockState getTunnelState(BlockGetter reader, BlockPos pos) { BlockState state = defaultBlockState(); BlockState belt = reader.getBlockState(pos.below()); if (AllBlocks.BELT.has(belt)) @@ -170,7 +172,7 @@ public class BeltTunnelBlock extends Block implements ITE, return state; } - protected boolean canHaveWindow(IBlockReader reader, BlockPos pos, Axis axis) { + protected boolean canHaveWindow(BlockGetter reader, BlockPos pos, Axis axis) { Direction fw = Direction.get(AxisDirection.POSITIVE, axis); BlockState blockState1 = reader.getBlockState(pos.relative(fw)); BlockState blockState2 = reader.getBlockState(pos.relative(fw.getOpposite())); @@ -188,7 +190,7 @@ public class BeltTunnelBlock extends Block implements ITE, return canHaveWindow; } - private boolean hasValidOutput(IBlockReader world, BlockPos pos, Direction side) { + private boolean hasValidOutput(BlockGetter world, BlockPos pos, Direction side) { BlockState blockState = world.getBlockState(pos.relative(side)); if (AllBlocks.BELT.has(blockState)) return blockState.getValue(BeltBlock.HORIZONTAL_FACING) @@ -199,17 +201,17 @@ public class BeltTunnelBlock extends Block implements ITE, } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onWrenched(BlockState state, UseOnContext context) { if (!hasWindow(state)) - return ActionResultType.PASS; + return InteractionResult.PASS; // Toggle windows Shape shape = state.getValue(SHAPE); shape = shape == Shape.CLOSED ? Shape.WINDOW : Shape.CLOSED; - World world = context.getLevel(); + Level world = context.getLevel(); if (!world.isClientSide) world.setBlock(context.getClickedPos(), state.setValue(SHAPE, shape), 2); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override @@ -221,7 +223,7 @@ public class BeltTunnelBlock extends Block implements ITE, } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { if (worldIn.isClientSide) return; 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 c43b898f9..21f24d13e 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 @@ -16,8 +16,8 @@ import com.simibubi.create.foundation.gui.widgets.InterpolatedValue; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.Direction; -import net.minecraft.world.LightType; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LightLayer; public class BeltTunnelInstance extends TileEntityInstance implements IDynamicInstance { @@ -32,8 +32,8 @@ public class BeltTunnelInstance extends TileEntityInstance .material(AllMaterialSpecs.FLAPS) .getModel(AllBlockPartials.BELT_TUNNEL_FLAP, blockState); - int blockLight = world.getBrightness(LightType.BLOCK, pos); - int skyLight = world.getBrightness(LightType.SKY, pos); + int blockLight = world.getBrightness(LightLayer.BLOCK, pos); + int skyLight = world.getBrightness(LightLayer.SKY, pos); tile.flaps.forEach((direction, flapValue) -> { 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 5bcb5aac3..42068d6a7 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 @@ -6,15 +6,17 @@ import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType; import com.simibubi.create.foundation.advancement.AllTriggers; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.level.Level; + +import net.minecraft.world.item.Item.Properties; public class BeltTunnelItem extends BlockItem { @@ -23,18 +25,18 @@ public class BeltTunnelItem extends BlockItem { } @Override - protected boolean canPlace(BlockItemUseContext ctx, BlockState state) { - PlayerEntity playerentity = ctx.getPlayer(); - ISelectionContext iselectioncontext = - playerentity == null ? ISelectionContext.empty() : ISelectionContext.of(playerentity); - World world = ctx.getLevel(); + protected boolean canPlace(BlockPlaceContext ctx, BlockState state) { + Player playerentity = ctx.getPlayer(); + CollisionContext iselectioncontext = + playerentity == null ? CollisionContext.empty() : CollisionContext.of(playerentity); + Level 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 updateCustomBlockEntityTag(BlockPos pos, World world, PlayerEntity p_195943_3_, ItemStack p_195943_4_, + protected boolean updateCustomBlockEntityTag(BlockPos pos, Level world, Player p_195943_3_, ItemStack p_195943_4_, BlockState state) { boolean flag = super.updateCustomBlockEntityTag(pos, world, p_195943_3_, p_195943_4_, state); if (!world.isClientSide) { 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 bd9f4348b..8faa94892 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 @@ -2,8 +2,8 @@ package com.simibubi.create.content.logistics.block.belts.tunnel; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -12,30 +12,30 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class BeltTunnelRenderer extends SmartTileEntityRenderer { - public BeltTunnelRenderer(TileEntityRendererDispatcher dispatcher) { + public BeltTunnelRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(BeltTunnelTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(BeltTunnelTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); if (Backend.getInstance().canUseInstancing(te.getLevel())) return; SuperByteBuffer flapBuffer = PartialBufferer.get(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState()); - IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); - Vector3d pivot = VecHelper.voxelSpace(0, 10, 1f); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); + Vec3 pivot = VecHelper.voxelSpace(0, 10, 1f); MatrixTransformStack msr = MatrixTransformStack.of(ms); for (Direction direction : Iterate.directions) { @@ -55,7 +55,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer 0) flapAngle *= .5f; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelShapes.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelShapes.java index 563cfaebe..89e292420 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelShapes.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelShapes.java @@ -3,7 +3,15 @@ package com.simibubi.create.content.logistics.block.belts.tunnel; import static net.minecraft.block.Block.box; -import com.simibubi.create.foundation.utility.VoxelShaper; +import com.nimport com.simibubi.create.foundation.utility.VoxelShaper; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; + +et.minecraft.world.level.block.Blockn.utility.VoxelShaper; import net.minecraft.block.BlockState; import net.minecraft.util.Direction; @@ -19,19 +27,19 @@ public class BeltTunnelShapes { private static VoxelShaper opening = VoxelShaper.forHorizontal(box(2, -5, 14, 14, 10, 16), Direction.SOUTH); - private static final VoxelShaper STRAIGHT = VoxelShaper.forHorizontalAxis(VoxelShapes.join(block, - VoxelShapes.or(opening.get(Direction.SOUTH), opening.get(Direction.NORTH)), IBooleanFunction.NOT_SAME), + private static final VoxelShaper STRAIGHT = VoxelShaper.forHorizontalAxis(Shapes.join(block, + Shapes.or(opening.get(Direction.SOUTH), opening.get(Direction.NORTH)), BooleanOp.NOT_SAME), Axis.Z), TEE = VoxelShaper.forHorizontal( - VoxelShapes.join(block, VoxelShapes.or(opening.get(Direction.NORTH), - opening.get(Direction.WEST), opening.get(Direction.EAST)), IBooleanFunction.NOT_SAME), + Shapes.join(block, Shapes.or(opening.get(Direction.NORTH), + opening.get(Direction.WEST), opening.get(Direction.EAST)), BooleanOp.NOT_SAME), Direction.SOUTH); - private static final VoxelShape CROSS = VoxelShapes.join(block, - VoxelShapes.or(opening.get(Direction.SOUTH), opening.get(Direction.NORTH), opening.get(Direction.WEST), + private static final VoxelShape CROSS = Shapes.join(block, + Shapes.or(opening.get(Direction.SOUTH), opening.get(Direction.NORTH), opening.get(Direction.WEST), opening.get(Direction.EAST)), - IBooleanFunction.NOT_SAME); + BooleanOp.NOT_SAME); public static VoxelShape getShape(BlockState state) { BeltTunnelBlock.Shape shape = state.getValue(BeltTunnelBlock.SHAPE); @@ -50,6 +58,6 @@ public class BeltTunnelShapes { return TEE.get(axis == Direction.Axis.Z ? Direction.WEST : Direction.SOUTH); // something went wrong - return VoxelShapes.block(); + return Shapes.block(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java index 102fa0a40..4237783cb 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java @@ -21,17 +21,17 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.IntNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.IntTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.Constants.NBT; @@ -48,7 +48,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe protected LazyOptional cap = LazyOptional.empty(); protected List> flapsToSend; - public BeltTunnelTileEntity(TileEntityType type) { + public BeltTunnelTileEntity(BlockEntityType type) { super(type); flaps = new EnumMap<>(Direction.class); sides = new HashSet<>(); @@ -62,33 +62,33 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe } @Override - public void write(CompoundNBT compound, boolean clientPacket) { - ListNBT flapsNBT = new ListNBT(); + public void write(CompoundTag compound, boolean clientPacket) { + ListTag flapsNBT = new ListTag(); for (Direction direction : flaps.keySet()) - flapsNBT.add(IntNBT.valueOf(direction.get3DDataValue())); + flapsNBT.add(IntTag.valueOf(direction.get3DDataValue())); compound.put("Flaps", flapsNBT); - ListNBT sidesNBT = new ListNBT(); + ListTag sidesNBT = new ListTag(); for (Direction direction : sides) - sidesNBT.add(IntNBT.valueOf(direction.get3DDataValue())); + sidesNBT.add(IntTag.valueOf(direction.get3DDataValue())); compound.put("Sides", sidesNBT); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { Set newFlaps = new HashSet<>(6); - ListNBT flapsNBT = compound.getList("Flaps", NBT.TAG_INT); - for (INBT inbt : flapsNBT) - if (inbt instanceof IntNBT) - newFlaps.add(Direction.from3DDataValue(((IntNBT) inbt).getAsInt())); + ListTag flapsNBT = compound.getList("Flaps", NBT.TAG_INT); + for (Tag inbt : flapsNBT) + if (inbt instanceof IntTag) + newFlaps.add(Direction.from3DDataValue(((IntTag) inbt).getAsInt())); sides.clear(); - ListNBT sidesNBT = compound.getList("Sides", NBT.TAG_INT); - for (INBT inbt : sidesNBT) - if (inbt instanceof IntNBT) - sides.add(Direction.from3DDataValue(((IntNBT) inbt).getAsInt())); + ListTag sidesNBT = compound.getList("Sides", NBT.TAG_INT); + for (Tag inbt : sidesNBT) + if (inbt instanceof IntTag) + sides.add(Direction.from3DDataValue(((IntTag) inbt).getAsInt())); for (Direction d : Iterate.directions) if (!newFlaps.contains(d)) @@ -190,7 +190,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe if (!this.cap.isPresent()) { if (AllBlocks.BELT.has(level.getBlockState(worldPosition.below()))) { - TileEntity teBelow = level.getBlockEntity(worldPosition.below()); + BlockEntity teBelow = level.getBlockEntity(worldPosition.below()); if (teBelow != null) { T capBelow = teBelow.getCapability(capability, Direction.UP) .orElse(null); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelBlock.java index 4a17665c2..1f7d11fbd 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelBlock.java @@ -7,62 +7,62 @@ import com.simibubi.create.Create; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; public class BrassTunnelBlock extends BeltTunnelBlock { - public BrassTunnelBlock(AbstractBlock.Properties properties) { + public BrassTunnelBlock(BlockBehaviour.Properties properties) { super(properties); } @Override - public ActionResultType use(BlockState p_225533_1_, World world, BlockPos pos, PlayerEntity player, - Hand p_225533_5_, BlockRayTraceResult p_225533_6_) { + public InteractionResult use(BlockState p_225533_1_, Level world, BlockPos pos, Player player, + InteractionHand p_225533_5_, BlockHitResult p_225533_6_) { return onTileEntityUse(world, pos, te -> { if (!(te instanceof BrassTunnelTileEntity)) - return ActionResultType.PASS; + return InteractionResult.PASS; BrassTunnelTileEntity bte = (BrassTunnelTileEntity) te; List stacksOfGroup = bte.grabAllStacksOfGroup(world.isClientSide); if (stacksOfGroup.isEmpty()) - return ActionResultType.PASS; + return InteractionResult.PASS; if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; for (ItemStack itemStack : stacksOfGroup) player.inventory.placeItemBackInInventory(world, itemStack.copy()); - world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.PLAYERS, .2f, + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, .2f, 1f + Create.RANDOM.nextFloat()); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; }); } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.BRASS_TUNNEL.create(); } @Override - public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { return super.updateShape(state, facing, facingState, worldIn, currentPos, facingPos); } @Override - public void onRemove(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, + public void onRemove(BlockState p_196243_1_, Level 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())) { 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 2c8196db3..64c7a141a 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 @@ -4,11 +4,13 @@ import com.simibubi.create.AllSpriteShifts; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; + +import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour.CTContext; public class BrassTunnelCTBehaviour extends ConnectedTextureBehaviour { @@ -18,14 +20,14 @@ public class BrassTunnelCTBehaviour extends ConnectedTextureBehaviour { } @Override - public boolean connectsTo(BlockState state, BlockState other, IBlockDisplayReader reader, BlockPos pos, BlockPos otherPos, + public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, Direction face) { int yDiff = otherPos.getY() - pos.getY(); int zDiff = otherPos.getZ() - pos.getZ(); if (yDiff != 0) return false; - TileEntity te = reader.getBlockEntity(pos); + BlockEntity te = reader.getBlockEntity(pos); if (!(te instanceof BrassTunnelTileEntity)) return false; BrassTunnelTileEntity tunnelTE = (BrassTunnelTileEntity) te; @@ -34,7 +36,7 @@ public class BrassTunnelCTBehaviour extends ConnectedTextureBehaviour { } @Override - public CTContext buildContext(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face) { + public CTContext buildContext(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) { return super.buildContext(reader, pos, state, face); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelFilterSlot.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelFilterSlot.java index df3e8eca9..66c9aa1d9 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelFilterSlot.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelFilterSlot.java @@ -3,12 +3,12 @@ package com.simibubi.create.content.logistics.block.belts.tunnel; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public class BrassTunnelFilterSlot extends ValueBoxTransform.Sided { @Override - protected Vector3d getSouthLocation() { + protected Vec3 getSouthLocation() { return VecHelper.voxelSpace(8, 13, 15.5f); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelItemHandler.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelItemHandler.java index 317457f24..688740989 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelItemHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelItemHandler.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.belts.tunnel; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; 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 e86042119..0f5a2c448 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 @@ -32,21 +32,21 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.LazyOptional; @@ -77,7 +77,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave private LazyOptional beltCapability; private LazyOptional tunnelCapability; - public BrassTunnelTileEntity(TileEntityType type) { + public BrassTunnelTileEntity(BlockEntityType type) { super(type); distributionTargets = Couple.create(ArrayList::new); syncSet = new HashSet<>(); @@ -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 = level.getBlockEntity(tunnelPos); + BlockEntity te = level.getBlockEntity(tunnelPos); if (!(te instanceof BrassTunnelTileEntity)) continue; validTargets.add(Pair.of((BrassTunnelTileEntity) te, output)); @@ -390,8 +390,8 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave float beltMovementSpeed = below.getDirectionAwareBeltMovementSpeed(); 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.atLowerCornerOf(side.getNormal()) + Vec3 outPos = BeltHelper.getVectorForOffset(controllerTE, below.index + additionalOffset); + Vec3 outMotion = Vec3.atLowerCornerOf(side.getNormal()) .scale(movementSpeed) .add(0, 1 / 8f, 0); outPos.add(outMotion.normalize()); @@ -556,7 +556,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("SyncedOutput", syncedOutputActive); compound.putBoolean("ConnectedLeft", connectedLeft); compound.putBoolean("ConnectedRight", connectedRight); @@ -569,8 +569,8 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave for (boolean filtered : Iterate.trueAndFalse) { compound.put(filtered ? "FilteredTargets" : "Targets", NBTHelper.writeCompoundList(distributionTargets.get(filtered), pair -> { - CompoundNBT nbt = new CompoundNBT(); - nbt.put("Pos", NBTUtil.writeBlockPos(pair.getKey())); + CompoundTag nbt = new CompoundTag(); + nbt.put("Pos", NbtUtils.writeBlockPos(pair.getKey())); nbt.putInt("Face", pair.getValue() .get3DDataValue()); return nbt; @@ -581,7 +581,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { boolean wasConnectedLeft = connectedLeft; boolean wasConnectedRight = connectedRight; @@ -597,7 +597,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave for (boolean filtered : Iterate.trueAndFalse) { distributionTargets.set(filtered, NBTHelper .readCompoundList(compound.getList(filtered ? "FilteredTargets" : "Targets", NBT.TAG_COMPOUND), nbt -> { - BlockPos pos = NBTUtil.readBlockPos(nbt.getCompound("Pos")); + BlockPos pos = NbtUtils.readBlockPos(nbt.getCompound("Pos")); Direction face = Direction.from3DDataValue(nbt.getInt("Face")); return Pair.of(pos, face); })); @@ -679,7 +679,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave return null; if (adjacentBlockState.getValue(BrassTunnelBlock.HORIZONTAL_AXIS) != axis) return null; - TileEntity adjacentTE = level.getBlockEntity(adjacentPos); + BlockEntity adjacentTE = level.getBlockEntity(adjacentPos); if (adjacentTE.isRemoved()) return null; if (!(adjacentTE instanceof BrassTunnelTileEntity)) @@ -702,7 +702,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave public LazyOptional getBeltCapability() { if (!beltCapability.isPresent()) { - TileEntity tileEntity = level.getBlockEntity(worldPosition.below()); + BlockEntity tileEntity = level.getBlockEntity(worldPosition.below()); if (tileEntity != null) beltCapability = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); } @@ -744,23 +744,23 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { List allStacks = grabAllStacksOfGroup(true); if (allStacks.isEmpty()) return false; tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.brass_tunnel.contains")) - .withStyle(TextFormatting.WHITE)); + .withStyle(ChatFormatting.WHITE)); for (ItemStack item : allStacks) { tooltip.add(componentSpacing.plainCopy() - .append(Lang.translate("tooltip.brass_tunnel.contains_entry", new TranslationTextComponent(item.getItem() + .append(Lang.translate("tooltip.brass_tunnel.contains_entry", new TranslatableComponent(item.getItem() .getDescriptionId(item)).getString(), item.getCount())) - .withStyle(TextFormatting.GRAY)); + .withStyle(ChatFormatting.GRAY)); } tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.brass_tunnel.retrieve")) - .withStyle(TextFormatting.DARK_GRAY)); + .withStyle(ChatFormatting.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 5e142fc13..f6d36f8a7 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 @@ -10,28 +10,30 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBe import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public abstract class AbstractChuteBlock extends Block implements IWrenchable, ITE { public AbstractChuteBlock(Properties p_i48440_1_) { @@ -73,10 +75,10 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I } @Override - public abstract TileEntity createTileEntity(BlockState state, IBlockReader world); + public abstract BlockEntity createTileEntity(BlockState state, BlockGetter world); @Override - public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) { super.updateEntityAfterFallOn(worldIn, entityIn); if (!(entityIn instanceof ItemEntity)) return; @@ -102,14 +104,14 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) { + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) { withTileEntityDo(world, pos, ChuteTileEntity::onAdded); if (p_220082_5_) return; updateDiagonalNeighbour(state, world, pos); } - protected void updateDiagonalNeighbour(BlockState state, World world, BlockPos pos) { + protected void updateDiagonalNeighbour(BlockState state, Level world, BlockPos pos) { if (!isChute(state)) return; AbstractChuteBlock block = (AbstractChuteBlock) state.getBlock(); @@ -126,7 +128,7 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I } @Override - public void onRemove(BlockState state, World world, BlockPos pos, BlockState p_196243_4_, boolean p_196243_5_) { + public void onRemove(BlockState state, Level 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); @@ -152,7 +154,7 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState above, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState above, LevelAccessor world, BlockPos pos, BlockPos p_196271_6_) { if (direction != Direction.UP) return state; @@ -160,7 +162,7 @@ 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_, + public void neighborChanged(BlockState p_220069_1_, Level world, BlockPos pos, Block p_220069_4_, BlockPos neighbourPos, boolean p_220069_6_) { if (pos.below() .equals(neighbourPos)) @@ -170,24 +172,24 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I withTileEntityDo(world, pos, chute -> chute.capAbove = LazyOptional.empty()); } - public abstract BlockState updateChuteState(BlockState state, BlockState above, IBlockReader world, BlockPos pos); + public abstract BlockState updateChuteState(BlockState state, BlockState above, BlockGetter world, BlockPos pos); @Override @OnlyIn(Dist.CLIENT) - public boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager manager) { + public boolean addDestroyEffects(BlockState state, Level world, BlockPos pos, ParticleEngine manager) { BlockHelper.addReducedDestroyEffects(state, world, pos, manager); return true; } @Override - public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return ChuteShapes.getShape(p_220053_1_); } @Override - public VoxelShape getCollisionShape(BlockState p_220071_1_, IBlockReader p_220071_2_, BlockPos p_220071_3_, - ISelectionContext p_220071_4_) { + public VoxelShape getCollisionShape(BlockState p_220071_1_, BlockGetter p_220071_2_, BlockPos p_220071_3_, + CollisionContext p_220071_4_) { return ChuteShapes.getCollisionShape(p_220071_1_); } @@ -197,20 +199,20 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I } @Override - public ActionResultType use(BlockState p_225533_1_, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult p_225533_6_) { + public InteractionResult use(BlockState p_225533_1_, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult p_225533_6_) { if (!player.getItemInHand(hand) .isEmpty()) - return ActionResultType.PASS; + return InteractionResult.PASS; if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; return onTileEntityUse(world, pos, te -> { if (te.item.isEmpty()) - return ActionResultType.PASS; + return InteractionResult.PASS; player.inventory.placeItemBackInInventory(world, te.item); te.setItem(ItemStack.EMPTY); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; }); } 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 fb885f469..9a4194730 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 @@ -8,24 +8,26 @@ import com.simibubi.create.content.logistics.block.funnel.FunnelBlock; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.EnumProperty; -import net.minecraft.state.Property; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.util.StringRepresentable; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class ChuteBlock extends AbstractChuteBlock { @@ -38,7 +40,7 @@ public class ChuteBlock extends AbstractChuteBlock { .setValue(FACING, Direction.DOWN)); } - public enum Shape implements IStringSerializable { + public enum Shape implements StringRepresentable { INTERSECTION, WINDOW, NORMAL; @Override @@ -48,7 +50,7 @@ public class ChuteBlock extends AbstractChuteBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.CHUTE.create(); } @@ -68,7 +70,7 @@ public class ChuteBlock extends AbstractChuteBlock { } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + public InteractionResult onWrenched(BlockState state, UseOnContext context) { Shape shape = state.getValue(SHAPE); boolean down = state.getValue(FACING) == Direction.DOWN; if (!context.getLevel().isClientSide && down && shape != Shape.INTERSECTION) { @@ -76,16 +78,16 @@ public class ChuteBlock extends AbstractChuteBlock { .setBlockAndUpdate(context.getClickedPos(), state.setValue(SHAPE, shape == Shape.WINDOW ? Shape.NORMAL : Shape.WINDOW)); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public BlockState getStateForPlacement(BlockItemUseContext ctx) { + public BlockState getStateForPlacement(BlockPlaceContext ctx) { BlockState state = super.getStateForPlacement(ctx); Direction face = ctx.getClickedFace(); if (face.getAxis() .isHorizontal() && !ctx.isSecondaryUseActive()) { - World world = ctx.getLevel(); + Level world = ctx.getLevel(); BlockPos pos = ctx.getClickedPos(); return updateChuteState(state.setValue(FACING, face), world.getBlockState(pos.above()), world, pos); } @@ -98,13 +100,13 @@ public class ChuteBlock extends AbstractChuteBlock { } @Override - public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { BlockState above = world.getBlockState(pos.above()); return !isChute(above) || getChuteFacing(above) == Direction.DOWN; } @Override - public BlockState updateChuteState(BlockState state, BlockState above, IBlockReader world, BlockPos pos) { + public BlockState updateChuteState(BlockState state, BlockState above, BlockGetter world, BlockPos pos) { if (!(state.getBlock() instanceof ChuteBlock)) return state; @@ -148,7 +150,7 @@ public class ChuteBlock extends AbstractChuteBlock { } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType 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 641bfde5e..a2f917360 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 @@ -6,9 +6,9 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; import net.minecraftforge.client.model.generators.ModelFile; public class ChuteGenerator extends SpecialBlockStateGen { 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 6a279ae18..cfc22ca70 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 @@ -1,13 +1,15 @@ package com.simibubi.create.content.logistics.block.chute; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; + +import net.minecraft.world.item.Item.Properties; public class ChuteItem extends BlockItem { @@ -16,11 +18,11 @@ public class ChuteItem extends BlockItem { } @Override - public ActionResultType place(BlockItemUseContext context) { + public InteractionResult place(BlockPlaceContext context) { Direction face = context.getClickedFace(); BlockPos placedOnPos = context.getClickedPos() .relative(face.getOpposite()); - World world = context.getLevel(); + Level world = context.getLevel(); BlockState placedOnState = world.getBlockState(placedOnPos); if (!AbstractChuteBlock.isChute(placedOnState) || context.isSecondaryUseActive()) @@ -35,17 +37,17 @@ public class ChuteItem extends BlockItem { BlockState blockState = world.getBlockState(correctPos); if (blockState.getMaterial() .isReplaceable()) - context = BlockItemUseContext.at(context, correctPos, face); + context = BlockPlaceContext.at(context, correctPos, face); else { if (!(blockState.getBlock() instanceof ChuteBlock) || world.isClientSide) - return ActionResultType.FAIL; + return InteractionResult.FAIL; AbstractChuteBlock block = (AbstractChuteBlock) blockState.getBlock(); if (block.getFacing(blockState) == Direction.DOWN) { world.setBlockAndUpdate(correctPos, block.updateChuteState(blockState.setValue(ChuteBlock.FACING, face), world.getBlockState(correctPos.above()), world, correctPos)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.FAIL; + return InteractionResult.FAIL; } return super.place(context); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteItemHandler.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteItemHandler.java index 4188d2816..b1bb46ff9 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteItemHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteItemHandler.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.chute; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; public class ChuteItemHandler implements IItemHandler { 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 cb6a65b88..bb7b2f27c 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 @@ -1,26 +1,26 @@ package com.simibubi.create.content.logistics.block.chute; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.logistics.block.chute.ChuteBlock.Shape; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.Direction; public class ChuteRenderer extends SafeTileEntityRenderer { - public ChuteRenderer(TileEntityRendererDispatcher dispatcher) { + public ChuteRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(ChuteTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(ChuteTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (te.item.isEmpty()) return; @@ -34,7 +34,7 @@ public class ChuteRenderer extends SafeTileEntityRenderer { renderItem(te, partialTicks, ms, buffer, light, overlay); } - public static void renderItem(ChuteTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + public static void renderItem(ChuteTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { ItemRenderer itemRenderer = Minecraft.getInstance() .getItemRenderer(); 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 e70ed6621..923f79956 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 @@ -7,12 +7,12 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.content.logistics.block.chute.ChuteBlock.Shape; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.math.shapes.IBooleanFunction; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; public class ChuteShapes { @@ -31,12 +31,12 @@ public class ChuteShapes { boolean intersection = shape == Shape.INTERSECTION; if (direction == Direction.DOWN) - return intersection ? VoxelShapes.block() : AllShapes.CHUTE; + return intersection ? Shapes.block() : AllShapes.CHUTE; - VoxelShape combineWith = intersection ? VoxelShapes.block() : VoxelShapes.empty(); - VoxelShape result = VoxelShapes.or(combineWith, AllShapes.CHUTE_SLOPE.get(direction)); + VoxelShape combineWith = intersection ? Shapes.block() : Shapes.empty(); + VoxelShape result = Shapes.or(combineWith, AllShapes.CHUTE_SLOPE.get(direction)); if (intersection) - result = VoxelShapes.joinUnoptimized(INTERSECTION_MASK, result, IBooleanFunction.AND); + result = Shapes.joinUnoptimized(INTERSECTION_MASK, result, BooleanOp.AND); return result; } @@ -51,7 +51,7 @@ public class ChuteShapes { public static VoxelShape getCollisionShape(BlockState state) { if (collisionCache.containsKey(state)) return collisionCache.get(state); - VoxelShape createdShape = VoxelShapes.joinUnoptimized(COLLISION_MASK, getShape(state), IBooleanFunction.AND); + VoxelShape createdShape = Shapes.joinUnoptimized(COLLISION_MASK, getShape(state), BooleanOp.AND); collisionCache.put(state, createdShape); return createdShape; } @@ -59,10 +59,10 @@ public class ChuteShapes { public static final VoxelShape PANEL = Block.box(1, -15, 0, 15, 4, 1); public static VoxelShape createSlope() { - VoxelShape shape = VoxelShapes.empty(); + VoxelShape shape = Shapes.empty(); for (int i = 0; i < 16; i++) { float offset = i / 16f; - shape = VoxelShapes.join(shape, PANEL.move(0, offset, offset), IBooleanFunction.OR); + shape = Shapes.join(shape, PANEL.move(0, offset, offset), BooleanOp.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 c15dfa3f9..e0c1e1a58 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 @@ -31,24 +31,24 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.inventory.InventoryHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ItemParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntity; -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.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.Containers; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; @@ -84,7 +84,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor LazyOptional capAbove; LazyOptional capBelow; - public ChuteTileEntity(TileEntityType tileEntityTypeIn) { + public ChuteTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); item = ItemStack.EMPTY; itemPosition = new InterpolatedValue(); @@ -127,8 +127,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } @Override - public AxisAlignedBB getRenderBoundingBox() { - return new AxisAlignedBB(worldPosition).expandTowards(0, -3, 0); + public AABB getRenderBoundingBox() { + return new AABB(worldPosition).expandTowards(0, -3, 0); } @Override @@ -192,7 +192,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor else if (speed >= 32) maxPullDistance = 1; else - maxPullDistance = MathHelper.lerp(speed / 32, 0, 1); + maxPullDistance = Mth.lerp(speed / 32, 0, 1); if (AbstractChuteBlock.isChute(level.getBlockState(worldPosition.below()))) maxPullDistance = 0; @@ -221,9 +221,9 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return; if (!canCollectItemsFromBelow()) return; - Vector3d center = VecHelper.getCenterOf(worldPosition); - AxisAlignedBB searchArea = - new AxisAlignedBB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f); + Vec3 center = VecHelper.getCenterOf(worldPosition); + AABB searchArea = + new AABB(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; @@ -311,11 +311,11 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (level == null) return; AirParticleData airParticleData = new AirParticleData(drag, motion); - Vector3d origin = Vector3d.atLowerCornerOf(worldPosition); + Vec3 origin = Vec3.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) + Vec3 v = origin.add(xOff, verticalStart, zOff); + Vec3 d = origin.add(xOff, verticalEnd, zOff) .subtract(v); if (Create.RANDOM.nextFloat() < 2 * motion) level.addAlwaysVisibleParticle(airParticleData, v.x, v.y, v.z, d.x, d.y, d.z); @@ -389,7 +389,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return false; if (!simulate) { - Vector3d dropVec = VecHelper.getCenterOf(worldPosition) + Vec3 dropVec = VecHelper.getCenterOf(worldPosition) .add(0, -12 / 16f, 0); ItemEntity dropped = new ItemEntity(level, dropVec.x, dropVec.y, dropVec.z, item.copy()); dropped.setDefaultPickUpDelay(); @@ -450,7 +450,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return false; if (!simulate) { - Vector3d dropVec = VecHelper.getCenterOf(worldPosition) + Vec3 dropVec = VecHelper.getCenterOf(worldPosition) .add(0, 8 / 16f, 0); ItemEntity dropped = new ItemEntity(level, dropVec.x, dropVec.y, dropVec.z, item.copy()); dropped.setDefaultPickUpDelay(); @@ -481,7 +481,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor BlockPos pos = this.worldPosition.relative(side); if (level == null) return LazyOptional.empty(); - TileEntity te = level.getBlockEntity(pos); + BlockEntity te = level.getBlockEntity(pos); if (te == null) return LazyOptional.empty(); if (te instanceof ChuteTileEntity) { @@ -510,7 +510,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.put("Item", item.serializeNBT()); compound.putFloat("ItemPosition", itemPosition.value); compound.putFloat("Pull", pull); @@ -520,7 +520,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { ItemStack previousItem = item; item = ItemStack.of(compound.getCompound("Item")); itemPosition.lastValue = itemPosition.value = compound.getFloat("ItemPosition"); @@ -534,10 +534,10 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (hasLevel() && level != null && level.isClientSide && !previousItem.equals(item, false) && !item.isEmpty()) { if (level.random.nextInt(3) != 0) return; - Vector3d p = VecHelper.getCenterOf(worldPosition); + Vec3 p = VecHelper.getCenterOf(worldPosition); p = VecHelper.offsetRandomly(p, level.random, .5f); - Vector3d m = Vector3d.ZERO; - level.addParticle(new ItemParticleData(ParticleTypes.ITEM, item), p.x, p.y, p.z, m.x, m.y, m.z); + Vec3 m = Vec3.ZERO; + level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, item), p.x, p.y, p.z, m.x, m.y, m.z); } } @@ -548,14 +548,14 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor final float gravity = 4f; float motion = (push + pull) * fanSpeedModifier; - return (MathHelper.clamp(motion, -maxItemSpeed, maxItemSpeed) + (motion <= 0 ? -gravity : 0)) / 20f; + return (Mth.clamp(motion, -maxItemSpeed, maxItemSpeed) + (motion <= 0 ? -gravity : 0)) / 20f; } public void onRemoved(BlockState chuteState) { ChuteTileEntity targetChute = getTargetChute(chuteState); List inputChutes = getInputChutes(); if (!item.isEmpty() && level != null) - InventoryHelper.dropItemStack(level, worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), item); + Containers.dropItemStack(level, worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), item); setRemoved(); if (targetChute != null) { targetChute.updatePull(); @@ -605,7 +605,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor BlockState blockStateAbove = level.getBlockState(worldPosition.above()); if (AllBlocks.ENCASED_FAN.has(blockStateAbove) && blockStateAbove.getValue(EncasedFanBlock.FACING) == Direction.DOWN) { - TileEntity te = level.getBlockEntity(worldPosition.above()); + BlockEntity te = level.getBlockEntity(worldPosition.above()); if (te instanceof EncasedFanTileEntity && !te.isRemoved()) { EncasedFanTileEntity fan = (EncasedFanTileEntity) te; return fan.getSpeed(); @@ -627,7 +627,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return 0; BlockState blockStateBelow = level.getBlockState(worldPosition.below()); if (AllBlocks.ENCASED_FAN.has(blockStateBelow) && blockStateBelow.getValue(EncasedFanBlock.FACING) == Direction.UP) { - TileEntity te = level.getBlockEntity(worldPosition.below()); + BlockEntity te = level.getBlockEntity(worldPosition.below()); if (te instanceof EncasedFanTileEntity && !te.isRemoved()) { EncasedFanTileEntity fan = (EncasedFanTileEntity) te; return fan.getSpeed(); @@ -654,7 +654,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor BlockState chuteState = level.getBlockState(chutePos); if (!AbstractChuteBlock.isChute(chuteState)) return null; - TileEntity te = level.getBlockEntity(chutePos); + BlockEntity te = level.getBlockEntity(chutePos); if (te instanceof ChuteTileEntity) return (ChuteTileEntity) te; return null; @@ -684,37 +684,37 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor Direction chuteFacing = AbstractChuteBlock.getChuteFacing(chuteState); if (chuteFacing != direction) return null; - TileEntity te = level.getBlockEntity(chutePos); + BlockEntity te = level.getBlockEntity(chutePos); if (te instanceof ChuteTileEntity && !te.isRemoved()) return (ChuteTileEntity) te; return null; } - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { boolean downward = getItemMotion() < 0; tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.chute.header"))); if (pull == 0 && push == 0) tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.chute.no_fans_attached")) - .withStyle(TextFormatting.GRAY)); + .withStyle(ChatFormatting.GRAY)); if (pull != 0) tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.chute.fans_" + (pull > 0 ? "pull_up" : "push_down")) - .withStyle(TextFormatting.GRAY))); + .withStyle(ChatFormatting.GRAY))); if (push != 0) tooltip.add(componentSpacing.plainCopy() .append(Lang.translate("tooltip.chute.fans_" + (push > 0 ? "push_up" : "pull_down")) - .withStyle(TextFormatting.GRAY))); + .withStyle(ChatFormatting.GRAY))); tooltip.add(componentSpacing.plainCopy() .append("-> ") .append(Lang.translate("tooltip.chute.items_move_" + (downward ? "down" : "up")) - .withStyle(TextFormatting.YELLOW))); + .withStyle(ChatFormatting.YELLOW))); if (!item.isEmpty()) { tooltip.add(componentSpacing.plainCopy() - .append(Lang.translate("tooltip.chute.contains", new TranslationTextComponent(item.getItem() + .append(Lang.translate("tooltip.chute.contains", new TranslatableComponent(item.getItem() .getDescriptionId(item)).getString(), item.getCount())) - .withStyle(TextFormatting.GREEN)); + .withStyle(ChatFormatting.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 14e6f209f..d15d0d6ac 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 @@ -4,18 +4,20 @@ import java.util.Random; import com.simibubi.create.AllTileEntities; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class SmartChuteBlock extends AbstractChuteBlock { @@ -27,7 +29,7 @@ public class SmartChuteBlock extends AbstractChuteBlock { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving); if (worldIn.isClientSide) @@ -39,25 +41,25 @@ public class SmartChuteBlock extends AbstractChuteBlock { } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel 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_) { + public BlockState getStateForPlacement(BlockPlaceContext p_196258_1_) { return super.getStateForPlacement(p_196258_1_).setValue(POWERED, p_196258_1_.getLevel() .hasNeighborSignal(p_196258_1_.getClickedPos())); } @Override - public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { return true; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.SMART_CHUTE.create(); } @@ -67,7 +69,7 @@ public class SmartChuteBlock extends AbstractChuteBlock { } @Override - public BlockState updateChuteState(BlockState state, BlockState above, IBlockReader world, BlockPos pos) { + public BlockState updateChuteState(BlockState state, BlockState above, BlockGetter world, BlockPos pos) { return state; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteFilterSlotPositioning.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteFilterSlotPositioning.java index ad56ba184..e54fd581e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteFilterSlotPositioning.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteFilterSlotPositioning.java @@ -4,18 +4,18 @@ import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.Vec3; public class SmartChuteFilterSlotPositioning extends ValueBoxTransform.Sided { @Override - protected Vector3d getLocalOffset(BlockState state) { + protected Vec3 getLocalOffset(BlockState state) { Direction side = getSide(); float horizontalAngle = AngleHelper.horizontalAngle(side); - Vector3d southLocation = VecHelper.voxelSpace(8, 12, 15.5f); + Vec3 southLocation = VecHelper.voxelSpace(8, 12, 15.5f); return VecHelper.rotateCentered(southLocation, horizontalAngle, Axis.Y); } @@ -26,8 +26,8 @@ public class SmartChuteFilterSlotPositioning extends ValueBoxTransform.Sided { } @Override - protected Vector3d getSouthLocation() { - return Vector3d.ZERO; + protected Vec3 getSouthLocation() { + return Vec3.ZERO; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteRenderer.java index 2098babf7..5f78d41b4 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteRenderer.java @@ -1,20 +1,20 @@ package com.simibubi.create.content.logistics.block.chute; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; public class SmartChuteRenderer extends SmartTileEntityRenderer { - public SmartChuteRenderer(TileEntityRendererDispatcher dispatcher) { + public SmartChuteRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(SmartChuteTileEntity tileEntityIn, float partialTicks, MatrixStack ms, - IRenderTypeBuffer buffer, int light, int overlay) { + protected void renderSafe(SmartChuteTileEntity tileEntityIn, float partialTicks, PoseStack ms, + MultiBufferSource buffer, int light, int overlay) { super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay); if (tileEntityIn.item.isEmpty()) return; 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 da88a5a24..dcbac420b 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 @@ -6,17 +6,17 @@ import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; public class SmartChuteTileEntity extends ChuteTileEntity { FilteringBehaviour filtering; - public SmartChuteTileEntity(TileEntityType tileEntityTypeIn) { + public SmartChuteTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } 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 8c8d29659..e3cc81e27 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 @@ -23,15 +23,15 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.inventory.InventoryHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.Containers; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.LazyOptional; @@ -76,7 +76,7 @@ public class DepotBehaviour extends TileEntityBehaviour { public void tick() { super.tick(); - World world = tileEntity.getLevel(); + Level world = tileEntity.getLevel(); for (Iterator iterator = incoming.iterator(); iterator.hasNext();) { TransportedItemStack ts = iterator.next(); @@ -88,8 +88,8 @@ public class DepotBehaviour extends TileEntityBehaviour { heldItem = ts; } else { if (!ItemHelper.canItemStackAmountsStack(heldItem.stack, ts.stack)) { - Vector3d vec = VecHelper.getCenterOf(tileEntity.getBlockPos()); - InventoryHelper.dropItemStack(tileEntity.getLevel(), vec.x, vec.y + .5f, vec.z, ts.stack); + Vec3 vec = VecHelper.getCenterOf(tileEntity.getBlockPos()); + Containers.dropItemStack(tileEntity.getLevel(), vec.x, vec.y + .5f, vec.z, ts.stack); } else { heldItem.stack.grow(ts.stack.getCount()); } @@ -189,7 +189,7 @@ public class DepotBehaviour extends TileEntityBehaviour { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { if (heldItem != null) compound.put("HeldItem", heldItem.serializeNBT()); compound.put("OutputBuffer", processingOutputBuffer.serializeNBT()); @@ -198,13 +198,13 @@ public class DepotBehaviour extends TileEntityBehaviour { } @Override - public void read(CompoundNBT compound, boolean clientPacket) { + public void read(CompoundTag compound, boolean clientPacket) { heldItem = null; if (compound.contains("HeldItem")) heldItem = TransportedItemStack.read(compound.getCompound("HeldItem")); processingOutputBuffer.deserializeNBT(compound.getCompound("OutputBuffer")); if (canMergeItems()) { - ListNBT list = compound.getList("Incoming", NBT.TAG_COMPOUND); + ListTag list = compound.getList("Incoming", NBT.TAG_COMPOUND); incoming = NBTHelper.readCompoundList(list, TransportedItemStack::read); } } @@ -356,8 +356,8 @@ public class DepotBehaviour extends TileEntityBehaviour { continue; } ItemStack remainder = ItemHandlerHelper.insertItemStacked(processingOutputBuffer, added.stack, false); - Vector3d vec = VecHelper.getCenterOf(tileEntity.getBlockPos()); - InventoryHelper.dropItemStack(tileEntity.getLevel(), vec.x, vec.y + .5f, vec.z, remainder); + Vec3 vec = VecHelper.getCenterOf(tileEntity.getBlockPos()); + Containers.dropItemStack(tileEntity.getLevel(), vec.x, vec.y + .5f, vec.z, remainder); } if (dirty) @@ -376,9 +376,9 @@ public class DepotBehaviour extends TileEntityBehaviour { return true; } - private Vector3d getWorldPositionOf(TransportedItemStack transported) { - Vector3d offsetVec = new Vector3d(.5f, 14 / 16f, .5f); - return offsetVec.add(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); + private Vec3 getWorldPositionOf(TransportedItemStack transported) { + Vec3 offsetVec = new Vec3(.5f, 14 / 16f, .5f); + return offsetVec.add(Vec3.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 eaaf0b0e9..f7c726b80 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 @@ -8,20 +8,22 @@ import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.block.ITE; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -32,8 +34,8 @@ public class DepotBlock extends Block implements ITE, IWrenchab } @Override - public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return AllShapes.DEPOT; } @@ -43,7 +45,7 @@ public class DepotBlock extends Block implements ITE, IWrenchab } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.DEPOT.create(); } @@ -53,18 +55,18 @@ public class DepotBlock extends Block implements ITE, IWrenchab } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult ray) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult ray) { return SharedDepotBlockMethods.onUse(state, world, pos, player, hand, ray); } @Override - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { SharedDepotBlockMethods.onReplaced(state, worldIn, pos, newState, isMoving); } @Override - public void updateEntityAfterFallOn(IBlockReader worldIn, Entity entityIn) { + public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) { super.updateEntityAfterFallOn(worldIn, entityIn); SharedDepotBlockMethods.onLanded(worldIn, entityIn); } @@ -75,12 +77,12 @@ public class DepotBlock extends Block implements ITE, IWrenchab } @Override - public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { + public int getAnalogOutputSignal(BlockState blockState, Level worldIn, BlockPos pos) { return SharedDepotBlockMethods.getComparatorInputOverride(blockState, worldIn, pos); } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotItemHandler.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotItemHandler.java index cfa588a2a..f5836b752 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotItemHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotItemHandler.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.logistics.block.depot; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; public class DepotItemHandler implements IItemHandler { 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 5ad787fc3..f4c43c982 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.logistics.block.depot; import java.util.Random; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; @@ -11,35 +11,35 @@ import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction.Axis; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; public class DepotRenderer extends SafeTileEntityRenderer { - public DepotRenderer(TileEntityRendererDispatcher dispatcher) { + public DepotRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(DepotTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(DepotTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { renderItemsOf(te, partialTicks, ms, buffer, light, overlay, te.depotBehaviour); } - public static void renderItemsOf(SmartTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + public static void renderItemsOf(SmartTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay, DepotBehaviour depotBehaviour) { TransportedItemStack transported = depotBehaviour.heldItem; MatrixTransformStack msr = MatrixTransformStack.of(ms); - Vector3d itemPosition = VecHelper.getCenterOf(te.getBlockPos()); + Vec3 itemPosition = VecHelper.getCenterOf(te.getBlockPos()); ms.pushPose(); ms.translate(.5f, 15 / 16f, .5f); @@ -51,12 +51,12 @@ public class DepotRenderer extends SafeTileEntityRenderer { for (TransportedItemStack tis : depotBehaviour.incoming) { ms.pushPose(); msr.nudge(0); - float offset = MathHelper.lerp(partialTicks, tis.prevBeltPosition, tis.beltPosition); - float sideOffset = MathHelper.lerp(partialTicks, tis.prevSideOffset, tis.sideOffset); + float offset = Mth.lerp(partialTicks, tis.prevBeltPosition, tis.beltPosition); + float sideOffset = Mth.lerp(partialTicks, tis.prevSideOffset, tis.sideOffset); if (tis.insertedFrom.getAxis() .isHorizontal()) { - Vector3d offsetVec = Vector3d.atLowerCornerOf(tis.insertedFrom.getOpposite() + Vec3 offsetVec = Vec3.atLowerCornerOf(tis.insertedFrom.getOpposite() .getNormal()).scale(.5f - offset); ms.translate(offsetVec.x, offsetVec.y, offsetVec.z); boolean alongX = tis.insertedFrom.getClockWise() @@ -98,12 +98,12 @@ public class DepotRenderer extends SafeTileEntityRenderer { ms.popPose(); } - public static void renderItem(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, ItemStack itemStack, - int angle, Random r, Vector3d itemPosition) { + public static void renderItem(PoseStack ms, MultiBufferSource buffer, int light, int overlay, ItemStack itemStack, + int angle, Random r, Vec3 itemPosition) { ItemRenderer itemRenderer = Minecraft.getInstance() .getItemRenderer(); MatrixTransformStack msr = MatrixTransformStack.of(ms); - int count = (int) (MathHelper.log2((int) (itemStack.getCount()))) / 2; + int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2; boolean renderUpright = BeltHelper.isItemUpright(itemStack); boolean blockItem = itemRenderer.getModel(itemStack, null, null) .isGui3d(); @@ -114,10 +114,10 @@ public class DepotRenderer extends SafeTileEntityRenderer { if (renderUpright) { Entity renderViewEntity = Minecraft.getInstance().cameraEntity; if (renderViewEntity != null) { - Vector3d positionVec = renderViewEntity.position(); - Vector3d vectorForOffset = itemPosition; - Vector3d diff = vectorForOffset.subtract(positionVec); - float yRot = (float) (MathHelper.atan2(diff.x, diff.z) + Math.PI); + Vec3 positionVec = renderViewEntity.position(); + Vec3 vectorForOffset = itemPosition; + Vec3 diff = vectorForOffset.subtract(positionVec); + float yRot = (float) (Mth.atan2(diff.x, diff.z) + Math.PI); ms.mulPose(Vector3f.YP.rotation(yRot)); } ms.translate(0, 3 / 32d, -1 / 16f); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotTileEntity.java index ec4233523..bb796c965 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotTileEntity.java @@ -5,8 +5,8 @@ import java.util.List; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; @@ -15,7 +15,7 @@ public class DepotTileEntity extends SmartTileEntity { DepotBehaviour depotBehaviour; - public DepotTileEntity(TileEntityType tileEntityTypeIn) { + public DepotTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } 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 ad96c1481..a36d0794f 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 @@ -12,25 +12,27 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.pathfinding.PathType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class EjectorBlock extends HorizontalKineticBlock implements ITE { @@ -39,26 +41,26 @@ public class EjectorBlock extends HorizontalKineticBlock implements ITE ete.state == State.LAUNCHING) .map($ -> 1f) .orElse(super.getSlipperiness(state, world, pos, entity)); } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { withTileEntityDo(world, pos, EjectorTileEntity::updateSignal); } @Override - public void fallOn(World p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { + public void fallOn(Level p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) { Optional tileEntityOptional = getTileEntityOptional(p_180658_1_, p_180658_2_); if (tileEntityOptional.isPresent() && !p_180658_3_.isSuppressingBounce()) { p_180658_3_.causeFallDamage(p_180658_4_, 0.0F); @@ -68,7 +70,7 @@ public class EjectorBlock extends HorizontalKineticBlock implements ITE 4 / 16f) { entityIn.setPos(vec.x, vec.y, vec.z); @@ -116,15 +118,15 @@ public class EjectorBlock extends HorizontalKineticBlock implements ITE context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity player = context.get() + ServerPlayer player = context.get() .getSender(); if (player == null) return; - World world = player.level; + Level world = player.level; if (world == null || !world.isLoaded(pos)) return; - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity tileEntity = world.getBlockEntity(pos); if (tileEntity instanceof EjectorTileEntity) ((EjectorTileEntity) tileEntity).deployElytra(player); }); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java index 578e1ef6a..361c7e28f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java @@ -9,7 +9,9 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; + +import ModelData; public class EjectorInstance extends ShaftInstance implements IDynamicInstance { @@ -32,7 +34,7 @@ public class EjectorInstance extends ShaftInstance implements IDynamicInstance { public void beginFrame() { float lidProgress = getLidProgress(); - if (MathHelper.equal(lidProgress, lastProgress)) return; + if (Mth.equal(lidProgress, lastProgress)) return; pivotPlate(lidProgress); lastProgress = lidProgress; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorItem.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorItem.java index 26bc2d526..29bed8e11 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorItem.java @@ -1,19 +1,21 @@ package com.simibubi.create.content.logistics.block.depot; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.world.item.Item.Properties; + @EventBusSubscriber public class EjectorItem extends BlockItem { @@ -22,21 +24,21 @@ public class EjectorItem extends BlockItem { } @Override - public ActionResultType useOn(ItemUseContext ctx) { - PlayerEntity player = ctx.getPlayer(); + public InteractionResult useOn(UseOnContext ctx) { + Player player = ctx.getPlayer(); if (player != null && player.isShiftKeyDown()) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; return super.useOn(ctx); } @Override - protected BlockState getPlacementState(BlockItemUseContext p_195945_1_) { + protected BlockState getPlacementState(BlockPlaceContext p_195945_1_) { BlockState stateForPlacement = super.getPlacementState(p_195945_1_); return stateForPlacement; } @Override - protected boolean updateCustomBlockEntityTag(BlockPos pos, World world, PlayerEntity p_195943_3_, ItemStack p_195943_4_, + protected boolean updateCustomBlockEntityTag(BlockPos pos, Level world, Player p_195943_3_, ItemStack p_195943_4_, BlockState p_195943_5_) { if (world.isClientSide) DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> EjectorTargetHandler.flushSettings(pos)); @@ -44,8 +46,8 @@ public class EjectorItem extends BlockItem { } @Override - public boolean canAttackBlock(BlockState state, World world, BlockPos pos, - PlayerEntity p_195938_4_) { + public boolean canAttackBlock(BlockState state, Level world, BlockPos pos, + Player p_195938_4_) { 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 54c8e6198..b7c0c04e1 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 @@ -5,13 +5,13 @@ import java.util.function.Supplier; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.network.NetworkEvent.Context; public class EjectorPlacementPacket extends SimplePacketBase { @@ -27,7 +27,7 @@ public class EjectorPlacementPacket extends SimplePacketBase { this.facing = facing; } - public EjectorPlacementPacket(PacketBuffer buffer) { + public EjectorPlacementPacket(FriendlyByteBuf buffer) { h = buffer.readInt(); v = buffer.readInt(); pos = buffer.readBlockPos(); @@ -35,7 +35,7 @@ public class EjectorPlacementPacket extends SimplePacketBase { } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(h); buffer.writeInt(v); buffer.writeBlockPos(pos); @@ -46,14 +46,14 @@ public class EjectorPlacementPacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity player = context.get() + ServerPlayer player = context.get() .getSender(); if (player == null) return; - World world = player.level; + Level world = player.level; if (world == null || !world.isLoaded(pos)) return; - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity tileEntity = world.getBlockEntity(pos); BlockState state = world.getBlockState(pos); if (tileEntity instanceof EjectorTileEntity) ((EjectorTileEntity) tileEntity).setTarget(h, v); 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 1f3d6a402..3a3e58a61 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 @@ -3,8 +3,8 @@ package com.simibubi.create.content.logistics.block.depot; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -14,20 +14,20 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.Vec3; public class EjectorRenderer extends KineticTileEntityRenderer { - static final Vector3d pivot = VecHelper.voxelSpace(0, 11.25, 0.75); + static final Vec3 pivot = VecHelper.voxelSpace(0, 11.25, 0.75); - public EjectorRenderer(TileEntityRendererDispatcher dispatcher) { + public EjectorRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @@ -37,12 +37,12 @@ public class EjectorRenderer extends KineticTileEntityRenderer { } @Override - protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); EjectorTileEntity ejector = (EjectorTileEntity) te; - IVertexBuilder vertexBuilder = buffer.getBuffer(RenderType.solid()); + VertexConsumer vertexBuilder = buffer.getBuffer(RenderType.solid()); float lidProgress = ((EjectorTileEntity) te).getLidProgress(partialTicks); float angle = lidProgress * 70; @@ -63,9 +63,9 @@ public class EjectorRenderer extends KineticTileEntityRenderer { continue; ms.pushPose(); - Vector3d launchedItemLocation = ejector.getLaunchedItemLocation(time); - msr.translate(launchedItemLocation.subtract(Vector3d.atLowerCornerOf(te.getBlockPos()))); - Vector3d itemRotOffset = VecHelper.voxelSpace(0, 3, 0); + Vec3 launchedItemLocation = ejector.getLaunchedItemLocation(time); + msr.translate(launchedItemLocation.subtract(Vec3.atLowerCornerOf(te.getBlockPos()))); + Vec3 itemRotOffset = VecHelper.voxelSpace(0, 3, 0); msr.translate(itemRotOffset); msr.rotateY(AngleHelper.horizontalAngle(ejector.getFacing())); msr.rotateX(time * 40); @@ -94,7 +94,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer { applyLidAngle(te, pivot, angle, matrixStacker); } - static void applyLidAngle(KineticTileEntity te, Vector3d rotationOffset, float angle, TransformStack matrixStacker) { + static void applyLidAngle(KineticTileEntity te, Vec3 rotationOffset, float angle, TransformStack matrixStacker) { matrixStacker.centre() .rotateY(180 + AngleHelper.horizontalAngle(te.getBlockState() .getValue(EjectorBlock.HORIZONTAL_FACING))) 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 af8e4bca9..688dff49e 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 @@ -10,27 +10,27 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.RedstoneParticleData; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.ChatFormatting; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -49,20 +49,20 @@ public class EjectorTargetHandler { if (currentItem == null) return; BlockPos pos = event.getPos(); - World world = event.getWorld(); + Level world = event.getWorld(); if (!world.isClientSide) return; - PlayerEntity player = event.getPlayer(); + Player player = event.getPlayer(); if (player == null || player.isSpectator() || !player.isShiftKeyDown()) return; String key = "weighted_ejector.target_set"; - TextFormatting colour = TextFormatting.GOLD; + ChatFormatting colour = ChatFormatting.GOLD; player.displayClientMessage(Lang.translate(key).withStyle(colour), true); currentSelection = pos; launcher = null; event.setCanceled(true); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); } @SubscribeEvent @@ -79,7 +79,7 @@ public class EjectorTargetHandler { currentSelection = null; launcher = null; event.setCanceled(true); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); } } @@ -90,9 +90,9 @@ public class EjectorTargetHandler { int h = 0; int v = 0; - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; String key = "weighted_ejector.target_not_valid"; - TextFormatting colour = TextFormatting.WHITE; + ChatFormatting colour = ChatFormatting.WHITE; if (currentSelection == null) key = "weighted_ejector.no_target"; @@ -106,7 +106,7 @@ public class EjectorTargetHandler { } key = "weighted_ejector.targeting"; - colour = TextFormatting.GREEN; + colour = ChatFormatting.GREEN; player.displayClientMessage( Lang.translate(key, currentSelection.getX(), currentSelection.getY(), currentSelection.getZ()) @@ -145,7 +145,7 @@ public class EjectorTargetHandler { } public static void tick() { - PlayerEntity player = Minecraft.getInstance().player; + Player player = Minecraft.getInstance().player; if (player == null) return; @@ -174,10 +174,10 @@ public class EjectorTargetHandler { if (currentItem == null && !wrench) return; - RayTraceResult objectMouseOver = mc.hitResult; - if (!(objectMouseOver instanceof BlockRayTraceResult)) + HitResult objectMouseOver = mc.hitResult; + if (!(objectMouseOver instanceof BlockHitResult)) return; - BlockRayTraceResult blockRayTraceResult = (BlockRayTraceResult) objectMouseOver; + BlockHitResult blockRayTraceResult = (BlockHitResult) objectMouseOver; if (blockRayTraceResult.getType() == Type.MISS) return; @@ -205,18 +205,18 @@ public class EjectorTargetHandler { double tickOffset = totalFlyingTicks / segments; boolean valid = xDiff == validX && zDiff == validZ; int intColor = valid ? 0x9ede73 : 0xff7171; - Vector3d color = Color.vectorFromRGB(intColor); - RedstoneParticleData data = new RedstoneParticleData((float) color.x, (float) color.y, (float) color.z, 1); - ClientWorld world = mc.level; + Vec3 color = Color.vectorFromRGB(intColor); + DustParticleOptions data = new DustParticleOptions((float) color.x, (float) color.y, (float) color.z, 1); + ClientLevel world = mc.level; - AxisAlignedBB bb = new AxisAlignedBB(0, 0, 0, 1, 0, 1).move(currentSelection.offset(-validX, -yDiff, -validZ)); + AABB bb = new AABB(0, 0, 0, 1, 0, 1).move(currentSelection.offset(-validX, -yDiff, -validZ)); CreateClient.OUTLINER.chaseAABB("valid", bb) .colored(intColor) .lineWidth(1 / 16f); for (int i = 0; i < segments; i++) { double ticks = ((AnimationTickHolder.getRenderTime() / 3) % tickOffset) + i * tickOffset; - Vector3d vec = launcher.getGlobalPos(ticks, d, pos) + Vec3 vec = launcher.getGlobalPos(ticks, d, pos) .add(xDiff - validX, 0, zDiff - validZ); world.addParticle(data, vec.x, vec.y, vec.z, 0, 0, 0); } @@ -225,13 +225,13 @@ public class EjectorTargetHandler { private static void checkForWrench(ItemStack heldItem) { if (!AllItems.WRENCH.isIn(heldItem)) return; - RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; - if (!(objectMouseOver instanceof BlockRayTraceResult)) + HitResult objectMouseOver = Minecraft.getInstance().hitResult; + if (!(objectMouseOver instanceof BlockHitResult)) return; - BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; + BlockHitResult result = (BlockHitResult) objectMouseOver; BlockPos pos = result.getBlockPos(); - TileEntity te = Minecraft.getInstance().level.getBlockEntity(pos); + BlockEntity te = Minecraft.getInstance().level.getBlockEntity(pos); if (!(te instanceof EjectorTileEntity)) { lastHoveredBlockPos = -1; currentSelection = null; @@ -252,14 +252,14 @@ public class EjectorTargetHandler { } private static void drawOutline(BlockPos selection) { - World world = Minecraft.getInstance().level; + Level 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.bounds(); + AABB boundingBox = shape.isEmpty() ? new AABB(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 bec57a369..e4572fd29 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 @@ -7,7 +7,7 @@ import java.util.List; import javax.annotation.Nullable; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; @@ -28,33 +28,33 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; -import net.minecraft.block.BlockState; -import net.minecraft.block.ObserverBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ElytraItem; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.network.datasync.EntityDataManager; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceContext.BlockMode; -import net.minecraft.util.math.RayTraceContext.FluidMode; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ObserverBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ElytraItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.Capability; @@ -75,7 +75,7 @@ public class EjectorTileEntity extends KineticTileEntity { // item collision @Nullable - Pair earlyTarget; + Pair earlyTarget; float earlyTargetTime; // runtime stuff int scanCooldown; @@ -85,7 +85,7 @@ public class EjectorTileEntity extends KineticTileEntity { CHARGED, LAUNCHING, RETRACTING; } - public EjectorTileEntity(TileEntityType typeIn) { + public EjectorTileEntity(BlockEntityType typeIn) { super(typeIn); launcher = new EntityLauncher(1, 0); lidProgress = LerpedFloat.linear() @@ -134,7 +134,7 @@ public class EjectorTileEntity extends KineticTileEntity { return; Direction facing = getFacing(); List entities = - level.getEntitiesOfClass(Entity.class, new AxisAlignedBB(worldPosition).inflate(-1 / 16f, 0, -1 / 16f)); + level.getEntitiesOfClass(Entity.class, new AABB(worldPosition).inflate(-1 / 16f, 0, -1 / 16f)); // Launch Items boolean doLogic = !level.isClientSide || isVirtual(); @@ -143,7 +143,7 @@ public class EjectorTileEntity extends KineticTileEntity { // Launch Entities for (Entity entity : entities) { - boolean isPlayerEntity = entity instanceof PlayerEntity; + boolean isPlayerEntity = entity instanceof Player; if (!entity.isAlive()) continue; if (entity instanceof ItemEntity) @@ -159,8 +159,8 @@ public class EjectorTileEntity extends KineticTileEntity { if (!isPlayerEntity) continue; - PlayerEntity playerEntity = (PlayerEntity) entity; - if (!(playerEntity.getItemBySlot(EquipmentSlotType.CHEST) + Player playerEntity = (Player) entity; + if (!(playerEntity.getItemBySlot(EquipmentSlot.CHEST) .getItem() instanceof ElytraItem)) continue; @@ -176,13 +176,13 @@ public class EjectorTileEntity extends KineticTileEntity { lidProgress.chase(1, .8f, Chaser.EXP); state = State.LAUNCHING; 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); + level.playSound(null, worldPosition, SoundEvents.WOODEN_TRAPDOOR_CLOSE, SoundSource.BLOCKS, .35f, 1f); + level.playSound(null, worldPosition, SoundEvents.CHEST_OPEN, SoundSource.BLOCKS, .1f, 1.4f); } } } - public void deployElytra(PlayerEntity playerEntity) { + public void deployElytra(Player playerEntity) { EntityHack.setElytraFlying(playerEntity); } @@ -325,14 +325,14 @@ public class EjectorTileEntity extends KineticTileEntity { sendData(); } - float value = MathHelper.clamp(lidProgress.getValue() - getWindUpSpeed(), 0, 1); + float value = Mth.clamp(lidProgress.getValue() - getWindUpSpeed(), 0, 1); lidProgress.setValue(value); int soundRate = (int) (1 / (getWindUpSpeed() * 5)) + 1; float volume = .125f; float pitch = 1.5f - lidProgress.getValue(); if (((int) level.getGameTime()) % soundRate == 0 && doLogic) - level.playSound(null, worldPosition, SoundEvents.WOODEN_BUTTON_CLICK_OFF, SoundCategory.BLOCKS, volume, + level.playSound(null, worldPosition, SoundEvents.WOODEN_BUTTON_CLICK_OFF, SoundSource.BLOCKS, volume, pitch); } } @@ -345,11 +345,11 @@ public class EjectorTileEntity extends KineticTileEntity { if (time == 0) return false; - Vector3d source = getLaunchedItemLocation(time); - Vector3d target = getLaunchedItemLocation(time + 1); + Vec3 source = getLaunchedItemLocation(time); + Vec3 target = getLaunchedItemLocation(time + 1); - BlockRayTraceResult rayTraceBlocks = - level.clip(new RayTraceContext(source, target, BlockMode.COLLIDER, FluidMode.NONE, null)); + BlockHitResult rayTraceBlocks = + level.clip(new ClipContext(source, target, Block.COLLIDER, Fluid.NONE, null)); if (rayTraceBlocks.getType() == Type.MISS) { if (earlyTarget != null && earlyTargetTime < time + 1) { earlyTarget = null; @@ -358,8 +358,8 @@ public class EjectorTileEntity extends KineticTileEntity { return false; } - Vector3d vec = rayTraceBlocks.getLocation(); - earlyTarget = Pair.of(vec.add(Vector3d.atLowerCornerOf(rayTraceBlocks.getDirection() + Vec3 vec = rayTraceBlocks.getLocation(); + earlyTarget = Pair.of(vec.add(Vec3.atLowerCornerOf(rayTraceBlocks.getDirection() .getNormal()).scale(.25f)), rayTraceBlocks.getBlockPos()); earlyTargetTime = (float) (time + (source.distanceTo(vec) / source.distanceTo(target))); sendData(); @@ -368,8 +368,8 @@ public class EjectorTileEntity extends KineticTileEntity { protected void nudgeEntities() { for (Entity entity : level.getEntitiesOfClass(Entity.class, - new AxisAlignedBB(worldPosition).inflate(-1 / 16f, 0, -1 / 16f))) - if (!(entity instanceof PlayerEntity)) + new AABB(worldPosition).inflate(-1 / 16f, 0, -1 / 16f))) + if (!(entity instanceof Player)) entity.setPos(entity.getX(), entity.getY() + .125f, entity.getZ()); } @@ -423,8 +423,8 @@ public class EjectorTileEntity extends KineticTileEntity { .isEmpty()) return; - Vector3d ejectVec = earlyTarget != null ? earlyTarget.getFirst() : getLaunchedItemLocation(maxTime); - Vector3d ejectMotionVec = getLaunchedItemMotion(maxTime); + Vec3 ejectVec = earlyTarget != null ? earlyTarget.getFirst() : getLaunchedItemLocation(maxTime); + Vec3 ejectMotionVec = getLaunchedItemMotion(maxTime); ItemEntity item = new ItemEntity(level, ejectVec.x, ejectVec.y, ejectVec.z, intAttached.getValue()); item.setDeltaMovement(ejectMotionVec); item.setDefaultPickUpDelay(); @@ -438,19 +438,19 @@ public class EjectorTileEntity extends KineticTileEntity { return TileEntityBehaviour.get(level, targetPos, DirectBeltInputBehaviour.TYPE); } - public Vector3d getLaunchedItemLocation(float time) { + public Vec3 getLaunchedItemLocation(float time) { return launcher.getGlobalPos(time, getFacing().getOpposite(), worldPosition); } - public Vector3d getLaunchedItemMotion(float time) { + public Vec3 getLaunchedItemMotion(float time) { return launcher.getGlobalVelocity(time, getFacing().getOpposite(), worldPosition) .scale(.5f); } public void dropFlyingItems() { for (IntAttached intAttached : launchedItems) { - Vector3d ejectVec = getLaunchedItemLocation(intAttached.getFirst()); - Vector3d ejectMotionVec = getLaunchedItemMotion(intAttached.getFirst()); + Vec3 ejectVec = getLaunchedItemLocation(intAttached.getFirst()); + Vec3 ejectMotionVec = getLaunchedItemMotion(intAttached.getFirst()); ItemEntity item = new ItemEntity(level, 0, 0, 0, intAttached.getValue()); item.setPosRaw(ejectVec.x, ejectVec.y, ejectVec.z); item.setDeltaMovement(ejectMotionVec); @@ -469,12 +469,12 @@ public class EjectorTileEntity extends KineticTileEntity { if (hd == 0 && vd == 0) distanceFactor = 1; else - distanceFactor = 1 * MathHelper.sqrt(Math.pow(hd, 2) + Math.pow(vd, 2)); + distanceFactor = 1 * Mth.sqrt(Math.pow(hd, 2) + Math.pow(vd, 2)); return speedFactor / distanceFactor; } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); compound.putInt("HorizontalDistance", launcher.getHorizontalDistance()); compound.putInt("VerticalDistance", launcher.getVerticalDistance()); @@ -486,20 +486,20 @@ public class EjectorTileEntity extends KineticTileEntity { if (earlyTarget != null) { compound.put("EarlyTarget", VecHelper.writeNBT(earlyTarget.getFirst())); - compound.put("EarlyTargetPos", NBTUtil.writeBlockPos(earlyTarget.getSecond())); + compound.put("EarlyTargetPos", NbtUtils.writeBlockPos(earlyTarget.getSecond())); compound.putFloat("EarlyTargetTime", earlyTargetTime); } } @Override - public void writeSafe(CompoundNBT compound, boolean clientPacket) { + public void writeSafe(CompoundTag compound, boolean clientPacket) { super.writeSafe(compound, clientPacket); compound.putInt("HorizontalDistance", launcher.getHorizontalDistance()); compound.putInt("VerticalDistance", launcher.getVerticalDistance()); } @Override - protected void fromTag(BlockState blockState, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState blockState, CompoundTag compound, boolean clientPacket) { super.fromTag(blockState, compound, clientPacket); int horizontalDistance = compound.getInt("HorizontalDistance"); int verticalDistance = compound.getInt("VerticalDistance"); @@ -520,7 +520,7 @@ public class EjectorTileEntity extends KineticTileEntity { earlyTargetTime = 0; if (compound.contains("EarlyTarget")) { earlyTarget = Pair.of(VecHelper.readNBT(compound.getList("EarlyTarget", NBT.TAG_DOUBLE)), - NBTUtil.readBlockPos(compound.getCompound("EarlyTargetPos"))); + NbtUtils.readBlockPos(compound.getCompound("EarlyTargetPos"))); earlyTargetTime = compound.getFloat("EarlyTargetTime"); } @@ -572,7 +572,7 @@ public class EjectorTileEntity extends KineticTileEntity { @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { + public AABB getRenderBoundingBox() { return INFINITE_EXTENT_AABB; } @@ -584,12 +584,12 @@ public class EjectorTileEntity extends KineticTileEntity { private static abstract class EntityHack extends Entity { - public EntityHack(EntityType p_i48580_1_, World p_i48580_2_) { + public EntityHack(EntityType p_i48580_1_, Level p_i48580_2_) { super(p_i48580_1_, p_i48580_2_); } public static void setElytraFlying(Entity e) { - EntityDataManager data = e.getEntityData(); + SynchedEntityData data = e.getEntityData(); data.set(DATA_SHARED_FLAGS_ID, (byte) (data.get(DATA_SHARED_FLAGS_ID) | 1 << 7)); } @@ -598,12 +598,12 @@ public class EjectorTileEntity extends KineticTileEntity { private static class EjectorSlot extends ValueBoxTransform.Sided { @Override - protected Vector3d getLocalOffset(BlockState state) { - return new Vector3d(.5, 13 / 16f, .5).add(VecHelper.rotate(new Vector3d(0, 0, -.3), angle(state), Axis.Y)); + protected Vec3 getLocalOffset(BlockState state) { + return new Vec3(.5, 13 / 16f, .5).add(VecHelper.rotate(new Vec3(0, 0, -.3), angle(state), Axis.Y)); } @Override - protected void rotate(BlockState state, MatrixStack ms) { + protected void rotate(BlockState state, PoseStack ms) { MatrixTransformStack.of(ms) .rotateY(angle(state)) .rotateX(90); @@ -627,8 +627,8 @@ public class EjectorTileEntity extends KineticTileEntity { } @Override - protected Vector3d getSouthLocation() { - return Vector3d.ZERO; + protected Vec3 getSouthLocation() { + return Vec3.ZERO; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTriggerPacket.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTriggerPacket.java index 09f288fec..1de5ff849 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTriggerPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTriggerPacket.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.logistics.block.depot; import com.simibubi.create.foundation.networking.TileEntityConfigurationPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; public class EjectorTriggerPacket extends TileEntityConfigurationPacket { @@ -11,15 +11,15 @@ public class EjectorTriggerPacket extends TileEntityConfigurationPacket type) { + public AdjustablePulseRepeaterTileEntity(BlockEntityType type) { super(type); } 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 f17b34785..5638f6c3c 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 @@ -3,14 +3,16 @@ package com.simibubi.create.content.logistics.block.diodes; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTileEntities; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class AdjustableRepeaterBlock extends AbstractDiodeBlock { @@ -34,18 +36,18 @@ public class AdjustableRepeaterBlock extends AbstractDiodeBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllBlocks.ADJUSTABLE_REPEATER.is(this) ? AllTileEntities.ADJUSTABLE_REPEATER.create() : AllTileEntities.ADJUSTABLE_PULSE_REPEATER.create(); } @Override - protected int getOutputSignal(IBlockReader worldIn, BlockPos pos, BlockState state) { + protected int getOutputSignal(BlockGetter worldIn, BlockPos pos, BlockState state) { return state.getValue(POWERING) ? 15 : 0; } @Override - public int getSignal(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + public int getSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { return blockState.getValue(FACING) == side ? this.getOutputSignal(blockAccess, pos, blockState) : 0; } @@ -55,7 +57,7 @@ public class AdjustableRepeaterBlock extends AbstractDiodeBlock { } @Override - public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { + public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, Direction side) { if (side == null) return false; return side.getAxis() == state.getValue(FACING) 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 ada44ac84..44095b386 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 @@ -4,9 +4,9 @@ import java.util.Vector; import com.tterrag.registrate.providers.DataGenContext; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.BlockModelProvider; import net.minecraftforge.client.model.generators.ModelFile; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java index bc526e504..6e6fdf9a6 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java @@ -6,10 +6,12 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.utility.Color; +import ModelData; + public class AdjustableRepeaterInstance extends TileEntityInstance implements ITickableInstance { protected final ModelData indicator; @@ -23,7 +25,7 @@ public class AdjustableRepeaterInstance extends TileEntityInstance { - public AdjustableRepeaterRenderer(TileEntityRendererDispatcher dispatcher) { + public AdjustableRepeaterRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } 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 5684ab080..f1c1b03b9 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 @@ -1,24 +1,24 @@ package com.simibubi.create.content.logistics.block.diodes; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.phys.Vec3; public class AdjustableRepeaterScrollSlot extends ValueBoxTransform { @Override - protected Vector3d getLocalOffset(BlockState state) { + protected Vec3 getLocalOffset(BlockState state) { return VecHelper.voxelSpace(8, 3f, 8); } @Override - protected void rotate(BlockState state, MatrixStack ms) { + protected void rotate(BlockState state, PoseStack ms) { float yRot = AngleHelper.horizontalAngle(state.getValue(BlockStateProperties.HORIZONTAL_FACING)) + 180; MatrixTransformStack.of(ms) .rotateY(yRot) 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 e21121bdc..9602a9ee2 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 @@ -12,11 +12,11 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.Component; public class AdjustableRepeaterTileEntity extends SmartTileEntity implements IInstanceRendered { @@ -24,7 +24,7 @@ public class AdjustableRepeaterTileEntity extends SmartTileEntity implements IIn public boolean charging; ScrollValueBehaviour maxState; - public AdjustableRepeaterTileEntity(TileEntityType type) { + public AdjustableRepeaterTileEntity(BlockEntityType type) { super(type); } @@ -41,19 +41,19 @@ public class AdjustableRepeaterTileEntity extends SmartTileEntity implements IIn } private void onMaxDelayChanged(int newMax) { - state = MathHelper.clamp(state, 0, newMax); + state = Mth.clamp(state, 0, newMax); sendData(); } @Override - protected void fromTag(BlockState blockState, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState blockState, CompoundTag compound, boolean clientPacket) { state = compound.getInt("State"); charging = compound.getBoolean("Charging"); super.fromTag(blockState, compound, clientPacket); } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("State", state); compound.putBoolean("Charging", charging); super.write(compound, clientPacket); @@ -79,7 +79,7 @@ public class AdjustableRepeaterTileEntity extends SmartTileEntity implements IIn return (value / 20 / 60) + "m"; } - private ITextComponent getUnit(int value) { + private Component getUnit(int value) { if (value < 20) return Lang.translate("generic.unit.ticks"); if (value < 20 * 60) 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 f5a27b6a5..666b0a7c6 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 @@ -2,19 +2,21 @@ package com.simibubi.create.content.logistics.block.diodes; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.TickPriority; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.TickPriority; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class PoweredLatchBlock extends ToggleLatchBlock { @@ -31,7 +33,7 @@ public class PoweredLatchBlock extends ToggleLatchBlock { } @Override - protected void checkTickOnNeighbor(World worldIn, BlockPos pos, BlockState state) { + protected void checkTickOnNeighbor(Level worldIn, BlockPos pos, BlockState state) { boolean back = state.getValue(POWERED); boolean shouldBack = shouldTurnOn(worldIn, pos, state); boolean side = state.getValue(POWERED_SIDE); @@ -49,7 +51,7 @@ public class PoweredLatchBlock extends ToggleLatchBlock { worldIn.getBlockTicks().scheduleTick(pos, this, this.getDelay(state), tickpriority); } - protected boolean isPoweredOnSides(World worldIn, BlockPos pos, BlockState state) { + protected boolean isPoweredOnSides(Level worldIn, BlockPos pos, BlockState state) { Direction direction = state.getValue(FACING); Direction left = direction.getClockWise(); Direction right = direction.getCounterClockWise(); @@ -60,14 +62,14 @@ public class PoweredLatchBlock extends ToggleLatchBlock { if (i > 0) return true; BlockState blockstate = worldIn.getBlockState(blockpos); - if (blockstate.getBlock() == Blocks.REDSTONE_WIRE && blockstate.getValue(RedstoneWireBlock.POWER) > 0) + if (blockstate.getBlock() == Blocks.REDSTONE_WIRE && blockstate.getValue(RedStoneWireBlock.POWER) > 0) return true; } return false; } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, Random random) { boolean back = state.getValue(POWERED); boolean shouldBack = this.shouldTurnOn(worldIn, pos, state); boolean side = state.getValue(POWERED_SIDE); @@ -95,16 +97,16 @@ public class PoweredLatchBlock extends ToggleLatchBlock { } @Override - protected ActionResultType activated(World worldIn, BlockPos pos, BlockState state) { + protected InteractionResult activated(Level worldIn, BlockPos pos, BlockState state) { if (state.getValue(POWERED) != state.getValue(POWERED_SIDE)) - return ActionResultType.PASS; + return InteractionResult.PASS; if (!worldIn.isClientSide) worldIn.setBlock(pos, state.cycle(POWERING), 2); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { + public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, Direction side) { if (side == null) return false; return side.getAxis().isHorizontal(); 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 e09fabc11..c131f0a01 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 @@ -4,9 +4,9 @@ import java.util.Vector; import com.tterrag.registrate.providers.DataGenContext; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.BlockModelProvider; import net.minecraftforge.client.model.generators.ModelFile; 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 51a04bb4a..1ec6e3c69 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 @@ -2,15 +2,17 @@ package com.simibubi.create.content.logistics.block.diodes; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.TickPriority; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.TickPriority; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class PulseRepeaterBlock extends AbstractDiodeBlock { @@ -27,14 +29,14 @@ public class PulseRepeaterBlock extends AbstractDiodeBlock { } @Override - public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { + public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, Direction side) { if (side == null) return false; return side.getAxis() == state.getValue(FACING).getAxis(); } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, Random random) { boolean powered = state.getValue(POWERED); boolean pulsing = state.getValue(PULSING); boolean shouldPower = shouldTurnOn(worldIn, pos, state); @@ -51,7 +53,7 @@ public class PulseRepeaterBlock extends AbstractDiodeBlock { } @Override - protected int getOutputSignal(IBlockReader worldIn, BlockPos pos, BlockState state) { + protected int getOutputSignal(BlockGetter worldIn, BlockPos pos, BlockState state) { return state.getValue(PULSING) ? 15 : 0; } 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 c301ec552..3b6e01ac9 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 @@ -4,9 +4,9 @@ import java.util.Vector; import com.tterrag.registrate.providers.DataGenContext; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.BlockModelProvider; import net.minecraftforge.client.model.generators.ModelFile; 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 fc07e4a61..c82c9c28c 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 @@ -4,19 +4,21 @@ import java.util.Random; import com.simibubi.create.AllItems; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class ToggleLatchBlock extends AbstractDiodeBlock { @@ -34,7 +36,7 @@ public class ToggleLatchBlock extends AbstractDiodeBlock { } @Override - public int getSignal(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + public int getSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { return blockState.getValue(FACING) == side ? this.getOutputSignal(blockAccess, pos, blockState) : 0; } @@ -44,24 +46,24 @@ public class ToggleLatchBlock extends AbstractDiodeBlock { } @Override - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { if (!player.mayBuild()) - return ActionResultType.PASS; + return InteractionResult.PASS; if (player.isShiftKeyDown()) - return ActionResultType.PASS; + return InteractionResult.PASS; if (AllItems.WRENCH.isIn(player.getItemInHand(handIn))) - return ActionResultType.PASS; + return InteractionResult.PASS; return activated(worldIn, pos, state); } @Override - protected int getOutputSignal(IBlockReader worldIn, BlockPos pos, BlockState state) { + protected int getOutputSignal(BlockGetter worldIn, BlockPos pos, BlockState state) { return state.getValue(POWERING) ? 15 : 0; } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, Random random) { boolean poweredPreviously = state.getValue(POWERED); super.tick(state, worldIn, pos, random); BlockState newState = worldIn.getBlockState(pos); @@ -69,14 +71,14 @@ public class ToggleLatchBlock extends AbstractDiodeBlock { worldIn.setBlock(pos, newState.cycle(POWERING), 2); } - protected ActionResultType activated(World worldIn, BlockPos pos, BlockState state) { + protected InteractionResult activated(Level worldIn, BlockPos pos, BlockState state) { if (!worldIn.isClientSide) worldIn.setBlock(pos, state.cycle(POWERING), 2); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { + public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, Direction side) { if (side == null) return false; return side.getAxis() == state.getValue(FACING) 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 eda899142..04b329b6f 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 @@ -4,9 +4,9 @@ import java.util.Vector; import com.tterrag.registrate.providers.DataGenContext; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.BlockModelProvider; import net.minecraftforge.client.model.generators.ModelFile; 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 58b376395..f638aa28a 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 @@ -1,13 +1,15 @@ package com.simibubi.create.content.logistics.block.funnel; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class AbstractDirectionalFunnelBlock extends AbstractFunnelBlock { 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 4084b5b24..db71eb19b 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 @@ -12,25 +12,27 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBe import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour; import com.simibubi.create.foundation.utility.BlockHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public abstract class AbstractFunnelBlock extends Block implements ITE, IWrenchable { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; @@ -41,13 +43,13 @@ public abstract class AbstractFunnelBlock extends Block implements ITE SHAPE = EnumProperty.create("shape", Shape.class); - public enum Shape implements IStringSerializable { + public enum Shape implements StringRepresentable { RETRACTED(AllShapes.BELT_FUNNEL_RETRACTED), EXTENDED(AllShapes.BELT_FUNNEL_EXTENDED), PUSHING(AllShapes.BELT_FUNNEL_PERPENDICULAR), @@ -71,14 +73,14 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS } @Override - public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { 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_) { + public VoxelShape getCollisionShape(BlockState p_220071_1_, BlockGetter p_220071_2_, BlockPos p_220071_3_, + CollisionContext p_220071_4_) { if (p_220071_4_.getEntity() instanceof ItemEntity && (p_220071_1_.getValue(SHAPE) == Shape.PULLING || p_220071_1_.getValue(SHAPE) == Shape.PUSHING)) return AllShapes.FUNNEL_COLLISION.get(getFacing(p_220071_1_)); @@ -86,10 +88,10 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS } @Override - public BlockState getStateForPlacement(BlockItemUseContext ctx) { + public BlockState getStateForPlacement(BlockPlaceContext ctx) { BlockState stateForPlacement = super.getStateForPlacement(ctx); BlockPos pos = ctx.getClickedPos(); - World world = ctx.getLevel(); + Level world = ctx.getLevel(); Direction facing = ctx.getClickedFace() .getAxis() .isHorizontal() ? ctx.getClickedFace() : ctx.getHorizontalDirection(); @@ -100,7 +102,7 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS return state.setValue(SHAPE, getShapeForPosition(world, pos, facing, !sneaking)); } - public static Shape getShapeForPosition(IBlockReader world, BlockPos pos, Direction facing, boolean extracting) { + public static Shape getShapeForPosition(BlockGetter world, BlockPos pos, Direction facing, boolean extracting) { BlockPos posBelow = pos.below(); BlockState stateBelow = world.getBlockState(posBelow); Shape perpendicularState = extracting ? Shape.PUSHING : Shape.PULLING; @@ -111,13 +113,13 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS } @Override - public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, - PlayerEntity player) { + public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, + Player player) { return parent.asStack(); } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState neighbour, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState neighbour, LevelAccessor world, BlockPos pos, BlockPos p_196271_6_) { if (!isOnValidBelt(state, world, pos)) { BlockState parentState = parent.getDefaultState(); @@ -142,7 +144,7 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS return state.setValue(SHAPE, updatedShape); } - public static boolean isOnValidBelt(BlockState state, IWorldReader world, BlockPos pos) { + public static boolean isOnValidBelt(BlockState state, LevelReader world, BlockPos pos) { BlockState stateBelow = world.getBlockState(pos.below()); if ((stateBelow.getBlock() instanceof BeltBlock)) return BeltBlock.canTransportObjects(stateBelow); @@ -154,10 +156,10 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getLevel(); + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + Level world = context.getLevel(); if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; Shape shape = state.getValue(SHAPE); Shape newShape = shape; @@ -177,7 +179,7 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS } if (newShape == shape) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; world.setBlockAndUpdate(context.getClickedPos(), state.setValue(SHAPE, newShape)); @@ -189,11 +191,11 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS && opposite.getValue(HORIZONTAL_FACING) == facing.getOpposite()) AllTriggers.triggerFor(AllTriggers.BELT_FUNNEL_KISS, context.getPlayer()); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) { return ItemRequirement.of(parent.getDefaultState(), te); } 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 2fe07b546..cd407ca51 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 @@ -4,10 +4,10 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.ModelFile; public class BeltFunnelGenerator extends SpecialBlockStateGen { 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 df3f1a297..badfb4914 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 @@ -2,10 +2,12 @@ package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllBlocks; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class BrassFunnelBlock extends FunnelBlock { @@ -14,7 +16,7 @@ public class BrassFunnelBlock extends FunnelBlock { } @Override - public BlockState getEquivalentBeltFunnel(IBlockReader world, BlockPos pos, BlockState state) { + public BlockState getEquivalentBeltFunnel(BlockGetter world, BlockPos pos, BlockState state) { Direction facing = getFacing(state); return AllBlocks.BRASS_BELT_FUNNEL.getDefaultState() .setValue(BeltFunnelBlock.HORIZONTAL_FACING, facing) 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 dae2ff98e..d5864710a 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 @@ -5,28 +5,30 @@ import com.simibubi.create.AllItems; import com.simibubi.create.AllShapes; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { @@ -37,10 +39,10 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { registerDefaultState(defaultBlockState().setValue(EXTRACTING, false)); } - public abstract BlockState getEquivalentBeltFunnel(IBlockReader world, BlockPos pos, BlockState state); + public abstract BlockState getEquivalentBeltFunnel(BlockGetter world, BlockPos pos, BlockState state); @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockState state = super.getStateForPlacement(context); boolean sneak = context.getPlayer() != null && context.getPlayer() @@ -62,14 +64,14 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { } @Override - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { ItemStack heldItem = player.getItemInHand(handIn); boolean shouldntInsertItem = AllBlocks.MECHANICAL_ARM.isIn(heldItem) || !canInsertIntoFunnel(state); if (AllItems.WRENCH.isIn(heldItem)) - return ActionResultType.PASS; + return InteractionResult.PASS; if (hit.getDirection() == getFunnelFacing(state) && !shouldntInsertItem) { if (!worldIn.isClientSide) @@ -79,22 +81,22 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { if (!ItemStack.matches(remainder, toInsert)) player.setItemInHand(handIn, remainder); }); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - World world = context.getLevel(); + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + Level world = context.getLevel(); if (!world.isClientSide) world.setBlockAndUpdate(context.getClickedPos(), state.cycle(EXTRACTING)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public void entityInside(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) { if (worldIn.isClientSide) return; if (!(entityIn instanceof ItemEntity)) @@ -106,9 +108,9 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { ItemEntity itemEntity = (ItemEntity) entityIn; Direction direction = getFunnelFacing(state); - Vector3d diff = entityIn.position() + Vec3 diff = entityIn.position() .subtract(VecHelper.getCenterOf(pos) - .add(Vector3d.atLowerCornerOf(direction.getNormal()).scale(-.325f))); + .add(Vec3.atLowerCornerOf(direction.getNormal()).scale(-.325f))); double projectedDiff = direction.getAxis() .choose(diff.x, diff.y, diff.z); if (projectedDiff < 0 == (direction.getAxisDirection() == AxisDirection.POSITIVE)) @@ -128,14 +130,14 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { } @Override - public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { Direction facing = state.getValue(FACING); return facing == Direction.DOWN ? AllShapes.FUNNEL_CEILING : facing == Direction.UP ? AllShapes.FUNNEL_FLOOR : AllShapes.FUNNEL_WALL.get(facing); } @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { if (context.getEntity() instanceof ItemEntity && getFacing(state).getAxis() .isHorizontal()) return AllShapes.FUNNEL_COLLISION.get(getFacing(state)); @@ -143,7 +145,7 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock { } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState p_196271_3_, IWorld world, + public BlockState updateShape(BlockState state, Direction direction, BlockState p_196271_3_, LevelAccessor world, BlockPos pos, BlockPos p_196271_6_) { if (getFacing(state).getAxis() .isVertical() || direction != Direction.DOWN) 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 f05f96b68..135bf022f 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 @@ -1,21 +1,21 @@ package com.simibubi.create.content.logistics.block.funnel; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock.Shape; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.Vec3; public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { @Override - protected Vector3d getLocalOffset(BlockState state) { + protected Vec3 getLocalOffset(BlockState state) { Direction side = getSide(); float horizontalAngle = AngleHelper.horizontalAngle(side); Direction funnelFacing = FunnelBlock.getFunnelFacing(state); @@ -37,7 +37,7 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { if (!funnelFacing.getAxis() .isHorizontal()) { - Vector3d southLocation = VecHelper.voxelSpace(8, funnelFacing == Direction.DOWN ? 14 : 2, 15.5f); + Vec3 southLocation = VecHelper.voxelSpace(8, funnelFacing == Direction.DOWN ? 14 : 2, 15.5f); return VecHelper.rotateCentered(southLocation, horizontalAngle, Axis.Y); } @@ -45,7 +45,7 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { } @Override - protected void rotate(BlockState state, MatrixStack ms) { + protected void rotate(BlockState state, PoseStack ms) { Direction facing = FunnelBlock.getFunnelFacing(state); if (facing.getAxis() @@ -94,8 +94,8 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { } @Override - protected Vector3d getSouthLocation() { - return Vector3d.ZERO; + protected Vec3 getSouthLocation() { + return Vec3.ZERO; } } 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 3681ed623..9a54533d1 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 @@ -7,11 +7,11 @@ import com.tterrag.registrate.providers.RegistrateBlockstateProvider; import com.tterrag.registrate.providers.RegistrateItemModelProvider; import com.tterrag.registrate.util.nullness.NonNullBiConsumer; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.Item; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.Item; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.BlockModelBuilder; import net.minecraftforge.client.model.generators.ModelFile; 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 f2cbb4c16..c7b7e46cb 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 @@ -13,8 +13,8 @@ import com.simibubi.create.content.logistics.block.FlapData; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.Direction; -import net.minecraft.world.LightType; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LightLayer; public class FunnelInstance extends TileEntityInstance implements IDynamicInstance { @@ -33,8 +33,8 @@ public class FunnelInstance extends TileEntityInstance impleme .material(AllMaterialSpecs.FLAPS) .getModel(flapPartial, blockState); - int blockLight = world.getBrightness(LightType.BLOCK, pos); - int skyLight = world.getBrightness(LightType.SKY, pos); + int blockLight = world.getBrightness(LightLayer.BLOCK, pos); + int skyLight = world.getBrightness(LightLayer.SKY, pos); Direction direction = FunnelBlock.getFunnelFacing(blockState); 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 3aa9d83b3..918f82039 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 @@ -2,18 +2,20 @@ package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.foundation.advancement.AllTriggers; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.world.item.Item.Properties; + @EventBusSubscriber public class FunnelItem extends BlockItem { @@ -29,8 +31,8 @@ public class FunnelItem extends BlockItem { } @Override - protected BlockState getPlacementState(BlockItemUseContext ctx) { - World world = ctx.getLevel(); + protected BlockState getPlacementState(BlockPlaceContext ctx) { + Level world = ctx.getLevel(); BlockPos pos = ctx.getClickedPos(); BlockState state = super.getPlacementState(ctx); if (state == null) 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 b5951638e..dc9e55fb1 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 @@ -8,15 +8,15 @@ import com.simibubi.create.content.logistics.item.filter.FilterItem; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.item.ItemHelper; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.items.ItemHandlerHelper; public class FunnelMovementBehaviour extends MovementBehaviour { @@ -36,9 +36,9 @@ public class FunnelMovementBehaviour extends MovementBehaviour { } @Override - public Vector3d getActiveAreaOffset(MovementContext context) { + public Vec3 getActiveAreaOffset(MovementContext context) { Direction facing = FunnelBlock.getFunnelFacing(context.state); - Vector3d vec = Vector3d.atLowerCornerOf(facing.getNormal()); + Vec3 vec = Vec3.atLowerCornerOf(facing.getNormal()); if (facing != Direction.UP) return vec.scale(context.state.getValue(FunnelBlock.EXTRACTING) ? .15 : .65); @@ -58,16 +58,16 @@ public class FunnelMovementBehaviour extends MovementBehaviour { } private void extract(MovementContext context, BlockPos pos) { - World world = context.world; + Level world = context.world; - Vector3d entityPos = context.position; + Vec3 entityPos = context.position; 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.getEntitiesOfClass(ItemEntity.class, new AxisAlignedBB(new BlockPos(entityPos))).isEmpty()) + if (!world.getEntitiesOfClass(ItemEntity.class, new AABB(new BlockPos(entityPos))).isEmpty()) return;//don't drop items if there already are any in the target block space ItemStack filter = getFilter(context); @@ -91,15 +91,15 @@ public class FunnelMovementBehaviour extends MovementBehaviour { ItemEntity entity = new ItemEntity(world, entityPos.x, entityPos.y, entityPos.z, extract); - entity.setDeltaMovement(Vector3d.ZERO); + entity.setDeltaMovement(Vec3.ZERO); entity.setPickUpDelay(5); - world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundCategory.BLOCKS, 1/16f, .1f); + world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundSource.BLOCKS, 1/16f, .1f); world.addFreshEntity(entity); } private void succ(MovementContext context, BlockPos pos) { - World world = context.world; - List items = world.getEntitiesOfClass(ItemEntity.class, new AxisAlignedBB(pos)); + Level world = context.world; + List items = world.getEntitiesOfClass(ItemEntity.class, new AABB(pos)); ItemStack filter = getFilter(context); for (ItemEntity item : items) { 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 5a920e52d..36eceec88 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 @@ -3,8 +3,8 @@ package com.simibubi.create.content.logistics.block.funnel; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -12,21 +12,21 @@ import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRendere import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class FunnelRenderer extends SmartTileEntityRenderer { - public FunnelRenderer(TileEntityRendererDispatcher dispatcher) { + public FunnelRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(FunnelTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(FunnelTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); @@ -34,11 +34,11 @@ public class FunnelRenderer extends SmartTileEntityRenderer { return; BlockState blockState = te.getBlockState(); - IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP : AllBlockPartials.BELT_FUNNEL_FLAP); SuperByteBuffer flapBuffer = PartialBufferer.get(partialModel, blockState); - Vector3d pivot = VecHelper.voxelSpace(0, 10, 9.5f); + Vec3 pivot = VecHelper.voxelSpace(0, 10, 9.5f); MatrixTransformStack msr = MatrixTransformStack.of(ms); float horizontalAngle = AngleHelper.horizontalAngle(FunnelBlock.getFunnelFacing(blockState) @@ -56,7 +56,7 @@ public class FunnelRenderer extends SmartTileEntityRenderer { float intensity = segment == 3 ? 1.5f : segment + 1; float abs = Math.abs(f); - float flapAngle = MathHelper.sin((float) ((1 - abs) * Math.PI * intensity)) * 30 * -f; + float flapAngle = Mth.sin((float) ((1 - abs) * Math.PI * intensity)) * 30 * -f; if (f > 0) flapAngle *= .5f; 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 d6e7773bd..04233df08 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 @@ -24,15 +24,15 @@ import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipula import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; @@ -50,7 +50,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn INVALID, PAUSED, COLLECT, PUSHING_TO_BELT, TAKING_FROM_BELT, EXTRACT } - public FunnelTileEntity(TileEntityType tileEntityTypeIn) { + public FunnelTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); extractionCooldown = 0; flap = new InterpolatedChasingValue().start(.25f) @@ -117,7 +117,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn return; boolean trackingEntityPresent = true; - AxisAlignedBB area = getEntityOverflowScanningArea(); + AABB area = getEntityOverflowScanningArea(); // Check if last item is still blocking the extractor if (lastObserved == null) { @@ -153,19 +153,19 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn flap(false); onTransfer(stack); - Vector3d outputPos = VecHelper.getCenterOf(worldPosition); + Vec3 outputPos = VecHelper.getCenterOf(worldPosition); boolean vertical = facing.getAxis() .isVertical(); boolean up = facing == Direction.UP; - outputPos = outputPos.add(Vector3d.atLowerCornerOf(facing.getNormal()) + outputPos = outputPos.add(Vec3.atLowerCornerOf(facing.getNormal()) .scale(vertical ? up ? .15f : .5f : .25f)); if (!vertical) outputPos = outputPos.subtract(0, .45f, 0); - Vector3d motion = Vector3d.ZERO; + Vec3 motion = Vec3.ZERO; if (up) - motion = new Vector3d(0, 4 / 16f, 0); + motion = new Vec3(0, 4 / 16f, 0); ItemEntity item = new ItemEntity(level, outputPos.x, outputPos.y, outputPos.z, stack.copy()); item.setDefaultPickUpDelay(); @@ -176,12 +176,12 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn startCooldown(); } - static final AxisAlignedBB coreBB = - new AxisAlignedBB(VecHelper.CENTER_OF_ORIGIN, VecHelper.CENTER_OF_ORIGIN).inflate(.75f); + static final AABB coreBB = + new AABB(VecHelper.CENTER_OF_ORIGIN, VecHelper.CENTER_OF_ORIGIN).inflate(.75f); - private AxisAlignedBB getEntityOverflowScanningArea() { + private AABB getEntityOverflowScanningArea() { Direction facing = AbstractFunnelBlock.getFunnelFacing(getBlockState()); - AxisAlignedBB bb = coreBB.move(worldPosition); + AABB bb = coreBB.move(worldPosition); if (facing == null || facing == Direction.UP) return bb; return bb.expandTowards(0, -1, 0); @@ -316,13 +316,13 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); compound.putInt("TransferCooldown", extractionCooldown); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); extractionCooldown = compound.getInt("TransferCooldown"); 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 fc50c07f1..e11365c78 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 @@ -4,20 +4,22 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.item.ItemHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class AdjustableCrateBlock extends CrateBlock { public AdjustableCrateBlock(Properties p_i48415_1_) { @@ -30,15 +32,15 @@ public class AdjustableCrateBlock extends CrateBlock { } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.ADJUSTABLE_CRATE.create(); } @Override - public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level 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); + BlockEntity tileEntity = worldIn.getBlockEntity(pos); if (!(tileEntity instanceof AdjustableCrateTileEntity)) return; @@ -57,29 +59,29 @@ public class AdjustableCrateBlock extends CrateBlock { } @Override - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { if (worldIn.isClientSide) { - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } else { - TileEntity te = worldIn.getBlockEntity(pos); + BlockEntity te = worldIn.getBlockEntity(pos); if (te instanceof AdjustableCrateTileEntity) { AdjustableCrateTileEntity fte = (AdjustableCrateTileEntity) te; fte = fte.getMainCrate(); - NetworkHooks.openGui((ServerPlayerEntity) player, fte, fte::sendToContainer); + NetworkHooks.openGui((ServerPlayer) player, fte, fte::sendToContainer); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } } - public static void splitCrate(World world, BlockPos pos) { + public static void splitCrate(Level world, BlockPos pos) { BlockState state = world.getBlockState(pos); if (!AllBlocks.ADJUSTABLE_CRATE.has(state)) return; if (!state.getValue(DOUBLE)) return; - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (!(te instanceof AdjustableCrateTileEntity)) return; AdjustableCrateTileEntity crateTe = (AdjustableCrateTileEntity) te; @@ -89,7 +91,7 @@ public class AdjustableCrateBlock extends CrateBlock { } @Override - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (!(worldIn.getBlockEntity(pos) instanceof AdjustableCrateTileEntity)) return; @@ -108,8 +110,8 @@ public class AdjustableCrateBlock extends CrateBlock { } @Override - public int getAnalogOutputSignal(BlockState blockState, World worldIn, BlockPos pos) { - TileEntity te = worldIn.getBlockEntity(pos); + public int getAnalogOutputSignal(BlockState blockState, Level worldIn, BlockPos pos) { + BlockEntity 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 1df87b977..186b462d5 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 @@ -3,27 +3,27 @@ package com.simibubi.create.content.logistics.block.inventories; import com.simibubi.create.AllContainerTypes; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.items.SlotItemHandler; -public class AdjustableCrateContainer extends Container { +public class AdjustableCrateContainer extends AbstractContainerMenu { public AdjustableCrateTileEntity te; - public PlayerInventory playerInventory; + public Inventory playerInventory; public boolean doubleCrate; - public AdjustableCrateContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + public AdjustableCrateContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { super(type, id); - ClientWorld world = Minecraft.getInstance().level; - TileEntity tileEntity = world.getBlockEntity(extraData.readBlockPos()); + ClientLevel world = Minecraft.getInstance().level; + BlockEntity tileEntity = world.getBlockEntity(extraData.readBlockPos()); this.playerInventory = inv; if (tileEntity instanceof AdjustableCrateTileEntity) { this.te = (AdjustableCrateTileEntity) tileEntity; @@ -32,14 +32,14 @@ public class AdjustableCrateContainer extends Container { } } - public AdjustableCrateContainer(ContainerType type, int id, PlayerInventory inv, AdjustableCrateTileEntity te) { + public AdjustableCrateContainer(MenuType type, int id, Inventory inv, AdjustableCrateTileEntity te) { super(type, id); this.te = te; this.playerInventory = inv; init(); } - public static AdjustableCrateContainer create(int id, PlayerInventory inv, AdjustableCrateTileEntity te) { + public static AdjustableCrateContainer create(int id, Inventory inv, AdjustableCrateTileEntity te) { return new AdjustableCrateContainer(AllContainerTypes.FLEXCRATE.get(), id, inv, te); } @@ -70,7 +70,7 @@ public class AdjustableCrateContainer extends Container { } @Override - public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(Player playerIn, int index) { Slot clickedSlot = getSlot(index); if (!clickedSlot.hasItem()) return ItemStack.EMPTY; @@ -87,7 +87,7 @@ public class AdjustableCrateContainer extends Container { } @Override - public boolean stillValid(PlayerEntity player) { + public boolean stillValid(Player 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 b77d93a1b..e3f4f6c1a 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 @@ -8,7 +8,7 @@ import java.util.Collections; import java.util.List; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.logistics.packet.ConfigureFlexcratePacket; import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; @@ -19,16 +19,16 @@ import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class AdjustableCrateScreen extends AbstractSimiContainerScreen { protected AllGuiTextures background; - private List extraAreas = Collections.emptyList(); + private List extraAreas = Collections.emptyList(); private AdjustableCrateTileEntity te; private Label allowedItemsLabel; @@ -40,9 +40,9 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen getExtraAreas() { + public List getExtraAreas() { return extraAreas; } 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 978cac44b..a17017ffd 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 @@ -3,25 +3,25 @@ package com.simibubi.create.content.logistics.block.inventories; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.InventoryHelper; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.Containers; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.network.chat.Component; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; -public class AdjustableCrateTileEntity extends CrateTileEntity implements INamedContainerProvider { +public class AdjustableCrateTileEntity extends CrateTileEntity implements MenuProvider { public class Inv extends ItemStackHandler { public Inv() { @@ -61,7 +61,7 @@ public class AdjustableCrateTileEntity extends CrateTileEntity implements INamed public int itemCount; protected LazyOptional invHandler; - public AdjustableCrateTileEntity(TileEntityType type) { + public AdjustableCrateTileEntity(BlockEntityType type) { super(type); allowedAmount = 512; itemCount = 10; @@ -70,14 +70,14 @@ public class AdjustableCrateTileEntity extends CrateTileEntity implements INamed } @Override - public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) { + public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) { return AdjustableCrateContainer.create(id, inventory, this); } public AdjustableCrateTileEntity getOtherCrate() { if (!AllBlocks.ADJUSTABLE_CRATE.has(getBlockState())) return null; - TileEntity tileEntity = level.getBlockEntity(worldPosition.relative(getFacing())); + BlockEntity tileEntity = level.getBlockEntity(worldPosition.relative(getFacing())); if (tileEntity instanceof AdjustableCrateTileEntity) return (AdjustableCrateTileEntity) tileEntity; return null; @@ -138,11 +138,11 @@ public class AdjustableCrateTileEntity extends CrateTileEntity implements INamed } private void drop(int slot) { - InventoryHelper.dropItemStack(level, worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), inventory.getStackInSlot(slot)); + Containers.dropItemStack(level, worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), inventory.getStackInSlot(slot)); } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("Main", true); compound.putInt("AllowedAmount", allowedAmount); compound.put("Inventory", inventory.serializeNBT()); @@ -150,14 +150,14 @@ public class AdjustableCrateTileEntity extends CrateTileEntity implements INamed } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { allowedAmount = compound.getInt("AllowedAmount"); inventory.deserializeNBT(compound.getCompound("Inventory")); super.fromTag(state, compound, clientPacket); } @Override - public ITextComponent getDisplayName() { + public Component getDisplayName() { return Lang.translate("gui.adjustable_crate.title"); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/BottomlessItemHandler.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/BottomlessItemHandler.java index 47b54b768..fa1b6c6fe 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/BottomlessItemHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/BottomlessItemHandler.java @@ -5,7 +5,7 @@ import java.util.function.Supplier; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; 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 3a53714ba..3f31df482 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 @@ -5,19 +5,21 @@ import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class CrateBlock extends WrenchableDirectionalBlock implements IWrenchable { @@ -30,17 +32,17 @@ public class CrateBlock extends WrenchableDirectionalBlock implements IWrenchabl } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.CRATE_BLOCK_SHAPE; } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } @Override - public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { boolean isDouble = stateIn.getValue(DOUBLE); @@ -64,9 +66,9 @@ public class CrateBlock extends WrenchableDirectionalBlock implements IWrenchabl } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockPos pos = context.getClickedPos(); - World world = context.getLevel(); + Level world = context.getLevel(); if (context.getPlayer() == null || !context.getPlayer() .isShiftKeyDown()) { 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 427afa31f..4d84fe091 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 @@ -5,13 +5,13 @@ import java.util.List; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; public abstract class CrateTileEntity extends SmartTileEntity { - public CrateTileEntity(TileEntityType tileEntityTypeIn) { + public CrateTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } 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 b7831cfe9..475bd12d6 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 @@ -3,11 +3,13 @@ package com.simibubi.create.content.logistics.block.inventories; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class CreativeCrateBlock extends CrateBlock implements ITE { @@ -21,12 +23,12 @@ public class CreativeCrateBlock extends CrateBlock implements ITE type) { + public CreativeCrateTileEntity(BlockEntityType type) { super(type); inv = new BottomlessItemHandler(filtering::getFilter); itemHandler = LazyOptional.of(() -> inv); @@ -65,7 +65,7 @@ public class CreativeCrateTileEntity extends CrateTileEntity { private CreativeCrateTileEntity getOtherCrate() { if (!AllBlocks.CREATIVE_CRATE.has(getBlockState())) return null; - TileEntity tileEntity = level.getBlockEntity(worldPosition.relative(getFacing())); + BlockEntity tileEntity = level.getBlockEntity(worldPosition.relative(getFacing())); if (tileEntity instanceof CreativeCrateTileEntity) return (CreativeCrateTileEntity) tileEntity; return null; @@ -95,14 +95,14 @@ public class CreativeCrateTileEntity extends CrateTileEntity { return new FilteringBehaviour(this, new ValueBoxTransform() { @Override - protected void rotate(BlockState state, MatrixStack ms) { + protected void rotate(BlockState state, PoseStack ms) { MatrixTransformStack.of(ms) .rotateX(90); } @Override - protected Vector3d getLocalOffset(BlockState state) { - return new Vector3d(0.5, 13 / 16d, 0.5); + protected Vec3 getLocalOffset(BlockState state) { + return new Vec3(0.5, 13 / 16d, 0.5); } protected float getScale() { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmAngleTarget.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmAngleTarget.java index 7d2abe6af..b64157242 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmAngleTarget.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmAngleTarget.java @@ -3,11 +3,11 @@ package com.simibubi.create.content.logistics.block.mechanicalArm; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class ArmAngleTarget { @@ -24,35 +24,35 @@ public class ArmAngleTarget { headAngle = -15; } - public ArmAngleTarget(BlockPos armPos, Vector3d pointTarget, Direction clawFacing, boolean ceiling) { + public ArmAngleTarget(BlockPos armPos, Vec3 pointTarget, Direction clawFacing, boolean ceiling) { // if (ceiling) // clawFacing = clawFacing.getOpposite(); - Vector3d target = pointTarget; - Vector3d origin = VecHelper.getCenterOf(armPos) + Vec3 target = pointTarget; + Vec3 origin = VecHelper.getCenterOf(armPos) .add(0, ceiling ? -4 / 16f : 4 / 16f, 0); - Vector3d clawTarget = target; - target = target.add(Vector3d.atLowerCornerOf(clawFacing.getOpposite() + Vec3 clawTarget = target; + target = target.add(Vec3.atLowerCornerOf(clawFacing.getOpposite() .getNormal()).scale(.5f)); - Vector3d diff = target.subtract(origin); + Vec3 diff = target.subtract(origin); float horizontalDistance = (float) diff.multiply(1, 0, 1) .length(); - float baseAngle = AngleHelper.deg(MathHelper.atan2(diff.x, diff.z)) + 180; + float baseAngle = AngleHelper.deg(Mth.atan2(diff.x, diff.z)) + 180; if (ceiling) { diff = diff.multiply(1, -1, 1); baseAngle = 180 - baseAngle; } - float alphaOffset = AngleHelper.deg(MathHelper.atan2(diff.y, horizontalDistance)); + float alphaOffset = AngleHelper.deg(Mth.atan2(diff.y, horizontalDistance)); float a = 18 / 16f; // lower arm length float a2 = a * a; float b = 17 / 16f; // upper arm length float b2 = b * b; float diffLength = - MathHelper.clamp(MathHelper.sqrt(diff.y * diff.y + horizontalDistance * horizontalDistance), 1 / 8f, a + b); + Mth.clamp(Mth.sqrt(diff.y * diff.y + horizontalDistance * horizontalDistance), 1 / 8f, a + b); float diffLength2 = diffLength * diffLength; float alphaRatio = (-b2 + a2 + diffLength2) / (2 * a * diffLength); @@ -65,13 +65,13 @@ public class ArmAngleTarget { if (Float.isNaN(beta)) beta = 0; - Vector3d headPos = new Vector3d(0, 0, 0); + Vec3 headPos = new Vec3(0, 0, 0); headPos = VecHelper.rotate(headPos.add(0, b, 0), beta + 180, Axis.X); headPos = VecHelper.rotate(headPos.add(0, a, 0), alpha - 90, Axis.X); headPos = VecHelper.rotate(headPos, baseAngle, Axis.Y); headPos = VecHelper.rotate(headPos, ceiling ? 180 : 0, Axis.X); headPos = headPos.add(origin); - Vector3d headDiff = clawTarget.subtract(headPos); + Vec3 headDiff = clawTarget.subtract(headPos); if (ceiling) headDiff = headDiff.multiply(1, -1, 1); @@ -79,7 +79,7 @@ public class ArmAngleTarget { float horizontalHeadDistance = (float) headDiff.multiply(1, 0, 1) .length(); float headAngle = - (float) (alpha + beta + 135 - AngleHelper.deg(MathHelper.atan2(headDiff.y, horizontalHeadDistance))); + (float) (alpha + beta + 135 - AngleHelper.deg(Mth.atan2(headDiff.y, horizontalHeadDistance))); this.lowerArmAngle = alpha; this.upperArmAngle = beta; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmBlock.java index 1279f6a11..7659aec70 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmBlock.java @@ -9,25 +9,27 @@ import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity.Phase; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.InventoryHelper; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.Containers; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class ArmBlock extends KineticBlock implements ITE, ICogWheel { @@ -44,24 +46,24 @@ public class ArmBlock extends KineticBlock implements ITE, ICogWh } @Override - public BlockState getStateForPlacement(BlockItemUseContext ctx) { + public BlockState getStateForPlacement(BlockPlaceContext ctx) { 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_) { + public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return state.getValue(CEILING) ? AllShapes.MECHANICAL_ARM_CEILING : AllShapes.MECHANICAL_ARM; } @Override - public void onPlace(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) { super.onPlace(state, world, pos, oldState, isMoving); withTileEntityDo(world, pos, ArmTileEntity::redstoneUpdate); } @Override - public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, + public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { withTileEntityDo(world, pos, ArmTileEntity::redstoneUpdate); } @@ -72,7 +74,7 @@ public class ArmBlock extends KineticBlock implements ITE, ICogWh } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.MECHANICAL_ARM.create(); } @@ -82,21 +84,21 @@ public class ArmBlock extends KineticBlock implements ITE, ICogWh } @Override - public void onRemove(BlockState p_196243_1_, World world, BlockPos pos, BlockState p_196243_4_, + public void onRemove(BlockState p_196243_1_, Level 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.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), te.heldItem); + Containers.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), te.heldItem); }); world.removeBlockEntity(pos); } } @Override - public ActionResultType use(BlockState p_225533_1_, World world, BlockPos pos, PlayerEntity player, - Hand p_225533_5_, BlockRayTraceResult p_225533_6_) { + public InteractionResult use(BlockState p_225533_1_, Level world, BlockPos pos, Player player, + InteractionHand p_225533_5_, BlockHitResult p_225533_6_) { MutableBoolean success = new MutableBoolean(false); withTileEntityDo(world, pos, te -> { if (te.heldItem.isEmpty()) @@ -111,7 +113,7 @@ public class ArmBlock extends KineticBlock implements ITE, ICogWh te.sendData(); }); - return success.booleanValue() ? ActionResultType.SUCCESS : ActionResultType.PASS; + return success.booleanValue() ? InteractionResult.SUCCESS : InteractionResult.PASS; } } 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 9dd4941c1..3a5ee9612 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 @@ -24,6 +24,8 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; import net.minecraft.util.math.MathHelper; +import ModelData; + public class ArmInstance extends SingleRotatingInstance implements IDynamicInstance { final ModelData base; 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 fd31b69db..fbe29ff23 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 @@ -8,7 +8,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.mutable.MutableBoolean; import com.jozufozu.flywheel.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.Create; @@ -38,26 +38,26 @@ import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipula import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ComposterBlock; -import net.minecraft.block.JukeboxBlock; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.MusicDiscItem; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.JukeboxTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ComposterBlock; +import net.minecraft.world.level.block.JukeboxBlock; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.RecordItem; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.JukeboxBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; @@ -107,7 +107,7 @@ public abstract class ArmInteractionPoint { } @OnlyIn(Dist.CLIENT) - protected void transformFlag(MatrixStack stack) {} + protected void transformFlag(PoseStack stack) {} protected PartialModel getFlagType() { return mode == Mode.TAKE ? AllBlockPartials.FLAG_LONG_OUT : AllBlockPartials.FLAG_LONG_IN; @@ -117,7 +117,7 @@ public abstract class ArmInteractionPoint { mode = mode == Mode.DEPOSIT ? Mode.TAKE : Mode.DEPOSIT; } - protected Vector3d getInteractionPositionVector() { + protected Vec3 getInteractionPositionVector() { return VecHelper.getCenterOf(pos); } @@ -125,15 +125,15 @@ public abstract class ArmInteractionPoint { return Direction.DOWN; } - protected boolean isStillValid(IBlockReader reader) { + protected boolean isStillValid(BlockGetter reader) { return isValid(reader, pos, reader.getBlockState(pos)); } - protected void keepAlive(IWorld world) {} + protected void keepAlive(LevelAccessor world) {} - protected abstract boolean isValid(IBlockReader reader, BlockPos pos, BlockState state); + protected abstract boolean isValid(BlockGetter reader, BlockPos pos, BlockState state); - protected static boolean isInteractable(IBlockReader reader, BlockPos pos, BlockState state) { + protected static boolean isInteractable(BlockGetter reader, BlockPos pos, BlockState state) { for (ArmInteractionPoint armInteractionPoint : POINTS.keySet()) if (armInteractionPoint.isValid(reader, pos, state)) return true; @@ -149,9 +149,9 @@ public abstract class ArmInteractionPoint { } @Nullable - protected IItemHandler getHandler(World world) { + protected IItemHandler getHandler(Level world) { if (!cachedHandler.isPresent()) { - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (te == null) return null; cachedHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP); @@ -159,25 +159,25 @@ public abstract class ArmInteractionPoint { return cachedHandler.orElse(null); } - protected ItemStack insert(World world, ItemStack stack, boolean simulate) { + protected ItemStack insert(Level world, ItemStack stack, boolean simulate) { IItemHandler handler = getHandler(world); if (handler == null) return stack; return ItemHandlerHelper.insertItem(handler, stack, simulate); } - protected ItemStack extract(World world, int slot, int amount, boolean simulate) { + protected ItemStack extract(Level world, int slot, int amount, boolean simulate) { IItemHandler handler = getHandler(world); if (handler == null) return ItemStack.EMPTY; return handler.extractItem(slot, amount, simulate); } - protected ItemStack extract(World world, int slot, boolean simulate) { + protected ItemStack extract(Level world, int slot, boolean simulate) { return extract(world, slot, 64, simulate); } - protected int getSlotCount(World world) { + protected int getSlotCount(Level world) { IItemHandler handler = getHandler(world); if (handler == null) return 0; @@ -185,7 +185,7 @@ public abstract class ArmInteractionPoint { } @Nullable - protected static ArmInteractionPoint createAt(IBlockReader world, BlockPos pos) { + protected static ArmInteractionPoint createAt(BlockGetter world, BlockPos pos) { BlockState state = world.getBlockState(pos); ArmInteractionPoint point = null; @@ -203,15 +203,15 @@ public abstract class ArmInteractionPoint { return point; } - protected CompoundNBT serialize(BlockPos anchor) { - CompoundNBT nbt = new CompoundNBT(); - nbt.put("Pos", NBTUtil.writeBlockPos(pos.subtract(anchor))); + protected CompoundTag serialize(BlockPos anchor) { + CompoundTag nbt = new CompoundTag(); + nbt.put("Pos", NbtUtils.writeBlockPos(pos.subtract(anchor))); NBTHelper.writeEnum(nbt, "Mode", mode); return nbt; } - protected static ArmInteractionPoint deserialize(IBlockReader world, BlockPos anchor, CompoundNBT nbt) { - BlockPos pos = NBTUtil.readBlockPos(nbt.getCompound("Pos")); + protected static ArmInteractionPoint deserialize(BlockGetter world, BlockPos anchor, CompoundTag nbt) { + BlockPos pos = NbtUtils.readBlockPos(nbt.getCompound("Pos")); ArmInteractionPoint interactionPoint = createAt(world, pos.offset(anchor)); if (interactionPoint == null) return null; @@ -219,17 +219,17 @@ public abstract class ArmInteractionPoint { return interactionPoint; } - protected static void transformPos(StructureTransform transform, CompoundNBT nbt) { - BlockPos pos = NBTUtil.readBlockPos(nbt.getCompound("Pos")); + protected static void transformPos(StructureTransform transform, CompoundTag nbt) { + BlockPos pos = NbtUtils.readBlockPos(nbt.getCompound("Pos")); pos = transform.applyWithoutOffset(pos); - nbt.put("Pos", NBTUtil.writeBlockPos(pos)); + nbt.put("Pos", NbtUtils.writeBlockPos(pos)); } public static abstract class TopFaceArmInteractionPoint extends ArmInteractionPoint { @Override - protected Vector3d getInteractionPositionVector() { - return Vector3d.atLowerCornerOf(pos).add(.5f, 1, .5f); + protected Vec3 getInteractionPositionVector() { + return Vec3.atLowerCornerOf(pos).add(.5f, 1, .5f); } } @@ -237,12 +237,12 @@ public abstract class ArmInteractionPoint { public static class Depot extends ArmInteractionPoint { @Override - protected Vector3d getInteractionPositionVector() { - return Vector3d.atLowerCornerOf(pos).add(.5f, 14 / 16f, .5f); + protected Vec3 getInteractionPositionVector() { + return Vec3.atLowerCornerOf(pos).add(.5f, 14 / 16f, .5f); } @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AllBlocks.DEPOT.has(state) || AllBlocks.WEIGHTED_EJECTOR.has(state); } @@ -251,7 +251,7 @@ public abstract class ArmInteractionPoint { public static class Saw extends Depot { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AllBlocks.MECHANICAL_SAW.has(state) && state.getValue(SawBlock.FACING) == Direction.UP && ((KineticTileEntity) reader.getBlockEntity(pos)).getSpeed() != 0; } @@ -261,7 +261,7 @@ public abstract class ArmInteractionPoint { public static class Millstone extends ArmInteractionPoint { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AllBlocks.MILLSTONE.has(state); } @@ -270,7 +270,7 @@ public abstract class ArmInteractionPoint { public static class CrushingWheels extends TopFaceArmInteractionPoint { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(state); } @@ -279,18 +279,18 @@ public abstract class ArmInteractionPoint { public static class Composter extends TopFaceArmInteractionPoint { @Override - protected Vector3d getInteractionPositionVector() { - return Vector3d.atLowerCornerOf(pos).add(.5f, 13 / 16f, .5f); + protected Vec3 getInteractionPositionVector() { + return Vec3.atLowerCornerOf(pos).add(.5f, 13 / 16f, .5f); } @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return Blocks.COMPOSTER.equals(state.getBlock()); } @Nullable @Override - protected IItemHandler getHandler(World world) { + protected IItemHandler getHandler(Level world) { return new InvWrapper( ((ComposterBlock) Blocks.COMPOSTER).getContainer(world.getBlockState(pos), world, pos)); } @@ -299,7 +299,7 @@ public abstract class ArmInteractionPoint { public static class Deployer extends ArmInteractionPoint { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AllBlocks.DEPLOYER.has(state); } @@ -310,9 +310,9 @@ public abstract class ArmInteractionPoint { } @Override - protected Vector3d getInteractionPositionVector() { + protected Vec3 getInteractionPositionVector() { return super.getInteractionPositionVector() - .add(Vector3d.atLowerCornerOf(getInteractionDirection().getNormal()).scale(.65f)); + .add(Vec3.atLowerCornerOf(getInteractionDirection().getNormal()).scale(.65f)); } } @@ -320,25 +320,25 @@ public abstract class ArmInteractionPoint { public static class BlazeBurner extends ArmInteractionPoint { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AllBlocks.BLAZE_BURNER.has(state); } @Override - protected ItemStack extract(World world, int slot, int amount, boolean simulate) { + protected ItemStack extract(Level world, int slot, int amount, boolean simulate) { return ItemStack.EMPTY; } @Override - protected ItemStack insert(World world, ItemStack stack, boolean simulate) { + protected ItemStack insert(Level world, ItemStack stack, boolean simulate) { ItemStack input = stack.copy(); if (!BlazeBurnerBlock.tryInsert(state, world, pos, input, false, false, true) .getObject() .isEmpty()) { return stack; } - ActionResult res = BlazeBurnerBlock.tryInsert(state, world, pos, input, false, false, simulate); - return res.getResult() == ActionResultType.SUCCESS + InteractionResultHolder res = BlazeBurnerBlock.tryInsert(state, world, pos, input, false, false, simulate); + return res.getResult() == InteractionResult.SUCCESS ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1) : stack; } @@ -351,7 +351,7 @@ public abstract class ArmInteractionPoint { public static class Crafter extends ArmInteractionPoint { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AllBlocks.MECHANICAL_CRAFTER.has(state); } @@ -362,8 +362,8 @@ public abstract class ArmInteractionPoint { } @Override - protected ItemStack extract(World world, int slot, int amount, boolean simulate) { - TileEntity te = world.getBlockEntity(pos); + protected ItemStack extract(Level world, int slot, int amount, boolean simulate) { + BlockEntity te = world.getBlockEntity(pos); if (!(te instanceof MechanicalCrafterTileEntity)) return ItemStack.EMPTY; MechanicalCrafterTileEntity crafter = (MechanicalCrafterTileEntity) te; @@ -375,9 +375,9 @@ public abstract class ArmInteractionPoint { } @Override - protected Vector3d getInteractionPositionVector() { + protected Vec3 getInteractionPositionVector() { return super.getInteractionPositionVector() - .add(Vector3d.atLowerCornerOf(getInteractionDirection().getNormal()).scale(.5f)); + .add(Vec3.atLowerCornerOf(getInteractionDirection().getNormal()).scale(.5f)); } } @@ -385,7 +385,7 @@ public abstract class ArmInteractionPoint { public static class Basin extends ArmInteractionPoint { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AllBlocks.BASIN.has(state); } @@ -394,28 +394,28 @@ public abstract class ArmInteractionPoint { public static class Jukebox extends TopFaceArmInteractionPoint { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return state.getBlock() instanceof JukeboxBlock; } @Override - protected int getSlotCount(World world) { + protected int getSlotCount(Level world) { return 1; } @Override - protected ItemStack insert(World world, ItemStack stack, boolean simulate) { - TileEntity tileEntity = world.getBlockEntity(pos); - if (!(tileEntity instanceof JukeboxTileEntity)) + protected ItemStack insert(Level world, ItemStack stack, boolean simulate) { + BlockEntity tileEntity = world.getBlockEntity(pos); + if (!(tileEntity instanceof JukeboxBlockEntity)) return stack; if (!(state.getBlock() instanceof JukeboxBlock)) return stack; JukeboxBlock jukeboxBlock = (JukeboxBlock) state.getBlock(); - JukeboxTileEntity jukeboxTE = (JukeboxTileEntity) tileEntity; + JukeboxBlockEntity jukeboxTE = (JukeboxBlockEntity) tileEntity; if (!jukeboxTE.getRecord() .isEmpty()) return stack; - if (!(stack.getItem() instanceof MusicDiscItem)) + if (!(stack.getItem() instanceof RecordItem)) return stack; ItemStack remainder = stack.copy(); ItemStack toInsert = remainder.split(1); @@ -428,13 +428,13 @@ public abstract class ArmInteractionPoint { } @Override - protected ItemStack extract(World world, int slot, int amount, boolean simulate) { - TileEntity tileEntity = world.getBlockEntity(pos); - if (!(tileEntity instanceof JukeboxTileEntity)) + protected ItemStack extract(Level world, int slot, int amount, boolean simulate) { + BlockEntity tileEntity = world.getBlockEntity(pos); + if (!(tileEntity instanceof JukeboxBlockEntity)) return ItemStack.EMPTY; if (!(state.getBlock() instanceof JukeboxBlock)) return ItemStack.EMPTY; - JukeboxTileEntity jukeboxTE = (JukeboxTileEntity) tileEntity; + JukeboxBlockEntity jukeboxTE = (JukeboxBlockEntity) tileEntity; ItemStack itemstack = jukeboxTE.getRecord(); if (itemstack.isEmpty()) return ItemStack.EMPTY; @@ -451,13 +451,13 @@ public abstract class ArmInteractionPoint { public static class Belt extends Depot { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AllBlocks.BELT.has(state) && !(reader.getBlockState(pos.above()) .getBlock() instanceof BeltTunnelBlock); } @Override - protected void keepAlive(IWorld world) { + protected void keepAlive(LevelAccessor world) { super.keepAlive(world); BeltTileEntity beltTE = BeltHelper.getSegmentTE(world, pos); if (beltTE == null) @@ -481,7 +481,7 @@ public abstract class ArmInteractionPoint { public static class Chute extends TopFaceArmInteractionPoint { @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return AbstractChuteBlock.isChute(state); } } @@ -489,19 +489,19 @@ public abstract class ArmInteractionPoint { public static class Funnel extends ArmInteractionPoint { @Override - protected Vector3d getInteractionPositionVector() { + protected Vec3 getInteractionPositionVector() { return VecHelper.getCenterOf(pos) - .add(Vector3d.atLowerCornerOf(FunnelBlock.getFunnelFacing(state) + .add(Vec3.atLowerCornerOf(FunnelBlock.getFunnelFacing(state) .getNormal()).scale(-.15f)); } @Override - protected int getSlotCount(World world) { + protected int getSlotCount(Level world) { return 0; } @Override - protected ItemStack extract(World world, int slot, int amount, boolean simulate) { + protected ItemStack extract(Level world, int slot, int amount, boolean simulate) { return ItemStack.EMPTY; } @@ -512,7 +512,7 @@ public abstract class ArmInteractionPoint { } @Override - protected ItemStack insert(World world, ItemStack stack, boolean simulate) { + protected ItemStack insert(Level world, ItemStack stack, boolean simulate) { FilteringBehaviour filtering = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE); InvManipulationBehaviour inserter = TileEntityBehaviour.get(world, pos, InvManipulationBehaviour.TYPE); BlockState state = world.getBlockState(pos); @@ -526,7 +526,7 @@ public abstract class ArmInteractionPoint { inserter.simulate(); ItemStack insert = inserter.insert(stack); if (!simulate && insert.getCount() != stack.getCount()) { - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity tileEntity = world.getBlockEntity(pos); if (tileEntity instanceof FunnelTileEntity) { FunnelTileEntity funnelTileEntity = (FunnelTileEntity) tileEntity; funnelTileEntity.onTransfer(stack); @@ -538,7 +538,7 @@ public abstract class ArmInteractionPoint { } @Override - protected boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { + protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { return state.getBlock() instanceof AbstractFunnelBlock && !(state.hasProperty(FunnelBlock.EXTRACTING) && state.getValue(FunnelBlock.EXTRACTING)) && !(state.hasProperty(BeltFunnelBlock.SHAPE) && state.getValue(BeltFunnelBlock.SHAPE) == Shape.PUSHING); 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 7e7142efc..9173a9600 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 @@ -12,20 +12,20 @@ import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionP import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -44,10 +44,10 @@ public class ArmInteractionPointHandler { if (currentItem == null) return; BlockPos pos = event.getPos(); - World world = event.getWorld(); + Level world = event.getWorld(); if (!world.isClientSide) return; - PlayerEntity player = event.getPlayer(); + Player player = event.getPlayer(); if (player != null && player.isSpectator()) return; @@ -64,15 +64,15 @@ public class ArmInteractionPointHandler { selected.cycleMode(); if (player != null) { 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() + ChatFormatting colour = selected.mode == Mode.DEPOSIT ? ChatFormatting.GOLD : ChatFormatting.AQUA; + TranslatableComponent translatedBlock = new TranslatableComponent(selected.state.getBlock() .getDescriptionId()); - player.displayClientMessage((Lang.translate(key, translatedBlock.withStyle(TextFormatting.WHITE, colour)).withStyle(colour)), + player.displayClientMessage((Lang.translate(key, translatedBlock.withStyle(ChatFormatting.WHITE, colour)).withStyle(colour)), true); } event.setCanceled(true); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); } @SubscribeEvent @@ -84,7 +84,7 @@ public class ArmInteractionPointHandler { BlockPos pos = event.getPos(); if (remove(pos) != null) { event.setCanceled(true); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); } } @@ -101,10 +101,10 @@ public class ArmInteractionPointHandler { removed++; } - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (removed > 0) { player.displayClientMessage(Lang.createTranslationTextComponent("mechanical_arm.points_outside_range", removed) - .withStyle(TextFormatting.RED), true); + .withStyle(ChatFormatting.RED), true); } else { int inputs = 0; int outputs = 0; @@ -116,7 +116,7 @@ public class ArmInteractionPointHandler { } if (inputs + outputs > 0) player.displayClientMessage(Lang.createTranslationTextComponent("mechanical_arm.summary", inputs, outputs) - .withStyle(TextFormatting.WHITE), true); + .withStyle(ChatFormatting.WHITE), true); } AllPackets.channel.sendToServer(new ArmPlacementPacket(currentSelection, pos)); @@ -125,7 +125,7 @@ public class ArmInteractionPointHandler { } public static void tick() { - PlayerEntity player = Minecraft.getInstance().player; + Player player = Minecraft.getInstance().player; if (player == null) return; @@ -150,15 +150,15 @@ public class ArmInteractionPointHandler { return; } - RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; - if (!(objectMouseOver instanceof BlockRayTraceResult)) { + HitResult objectMouseOver = Minecraft.getInstance().hitResult; + if (!(objectMouseOver instanceof BlockHitResult)) { return; } - BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; + BlockHitResult result = (BlockHitResult) objectMouseOver; BlockPos pos = result.getBlockPos(); - TileEntity te = Minecraft.getInstance().level.getBlockEntity(pos); + BlockEntity te = Minecraft.getInstance().level.getBlockEntity(pos); if (!(te instanceof ArmTileEntity)) { lastBlockPos = -1; currentSelection.clear(); @@ -179,7 +179,7 @@ public class ArmInteractionPointHandler { } private static void drawOutlines(Collection selection) { - World world = Minecraft.getInstance().level; + Level world = Minecraft.getInstance().level; for (Iterator iterator = selection.iterator(); iterator.hasNext();) { ArmInteractionPoint point = iterator.next(); BlockPos pos = point.pos; 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 5b49ef8ab..693a2652d 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 @@ -1,18 +1,20 @@ package com.simibubi.create.content.logistics.block.mechanicalArm; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraft.world.item.Item.Properties; + @EventBusSubscriber public class ArmItem extends BlockItem { @@ -21,16 +23,16 @@ public class ArmItem extends BlockItem { } @Override - public ActionResultType useOn(ItemUseContext ctx) { - World world = ctx.getLevel(); + public InteractionResult useOn(UseOnContext ctx) { + Level world = ctx.getLevel(); BlockPos pos = ctx.getClickedPos(); if (ArmInteractionPoint.isInteractable(world, pos, world.getBlockState(pos))) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; return super.useOn(ctx); } @Override - protected boolean updateCustomBlockEntityTag(BlockPos pos, World world, PlayerEntity p_195943_3_, ItemStack p_195943_4_, + protected boolean updateCustomBlockEntityTag(BlockPos pos, Level world, Player p_195943_3_, ItemStack p_195943_4_, BlockState p_195943_5_) { if (world.isClientSide) DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ArmInteractionPointHandler.flushSettings(pos)); @@ -38,8 +40,8 @@ public class ArmItem extends BlockItem { } @Override - public boolean canAttackBlock(BlockState state, World world, BlockPos pos, - PlayerEntity p_195938_4_) { + public boolean canAttackBlock(BlockState state, Level world, BlockPos pos, + Player 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 df74cd272..639924877 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 @@ -5,20 +5,20 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fml.network.NetworkEvent.Context; public class ArmPlacementPacket extends SimplePacketBase { private Collection points; - private ListNBT receivedTag; + private ListTag receivedTag; private BlockPos pos; public ArmPlacementPacket(Collection points, BlockPos pos) { @@ -26,16 +26,16 @@ public class ArmPlacementPacket extends SimplePacketBase { this.pos = pos; } - public ArmPlacementPacket(PacketBuffer buffer) { - CompoundNBT nbt = buffer.readNbt(); + public ArmPlacementPacket(FriendlyByteBuf buffer) { + CompoundTag nbt = buffer.readNbt(); receivedTag = nbt.getList("Points", NBT.TAG_COMPOUND); pos = buffer.readBlockPos(); } @Override - public void write(PacketBuffer buffer) { - CompoundNBT nbt = new CompoundNBT(); - ListNBT pointsNBT = new ListNBT(); + public void write(FriendlyByteBuf buffer) { + CompoundTag nbt = new CompoundTag(); + ListTag pointsNBT = new ListTag(); points.stream() .map(aip -> aip.serialize(pos)) .forEach(pointsNBT::add); @@ -48,14 +48,14 @@ public class ArmPlacementPacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity player = context.get() + ServerPlayer player = context.get() .getSender(); if (player == null) return; - World world = player.level; + Level world = player.level; if (world == null || !world.isLoaded(pos)) return; - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity 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 ccc9bdf11..62a6353c0 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 @@ -2,8 +2,8 @@ package com.simibubi.create.content.logistics.block.mechanicalArm; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -14,20 +14,20 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.Mth; public class ArmRenderer extends KineticTileEntityRenderer { - public ArmRenderer(TileEntityRendererDispatcher dispatcher) { + public ArmRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @@ -37,7 +37,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { } @Override - protected void renderSafe(KineticTileEntity te, float pt, MatrixStack ms, IRenderTypeBuffer buffer, int light, + protected void renderSafe(KineticTileEntity te, float pt, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, pt, ms, buffer, light, overlay); @@ -55,10 +55,10 @@ public class ArmRenderer extends KineticTileEntityRenderer { && itemRenderer.getModel(item, Minecraft.getInstance().level, null) .isGui3d(); - IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); + VertexConsumer builder = buffer.getBuffer(RenderType.solid()); BlockState blockState = te.getBlockState(); - MatrixStack msLocal = new MatrixStack(); + PoseStack msLocal = new PoseStack(); MatrixTransformStack msr = MatrixTransformStack.of(msLocal); float baseAngle; @@ -71,8 +71,8 @@ public class ArmRenderer extends KineticTileEntityRenderer { if (rave) { 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); + lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15); + upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95); headAngle = -lowerArmAngle; color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100).getRGB(); } else { @@ -109,7 +109,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { } - private void renderArm(IVertexBuilder builder, MatrixStack ms, MatrixStack msLocal, MatrixTransformStack msr, BlockState blockState, int color, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle, boolean hasItem, boolean isBlockItem, int light) { + private void renderArm(VertexConsumer builder, PoseStack ms, PoseStack msLocal, MatrixTransformStack msr, BlockState blockState, int color, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle, boolean hasItem, boolean isBlockItem, int light) { SuperByteBuffer base = PartialBufferer.get(AllBlockPartials.ARM_BASE, blockState).light(light); SuperByteBuffer lowerBody = PartialBufferer.get(AllBlockPartials.ARM_LOWER_BODY, blockState).light(light); SuperByteBuffer upperBody = PartialBufferer.get(AllBlockPartials.ARM_UPPER_BODY, blockState).light(light); 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 8c374085a..b77a4d6d4 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 @@ -25,20 +25,20 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.JukeboxBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.JukeboxBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.Constants.NBT; @@ -48,7 +48,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE // Server List inputs; List outputs; - ListNBT interactionPointTag; + ListTag interactionPointTag; // Both float chasedPointProgress; @@ -76,11 +76,11 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE SEARCH_INPUTS, MOVE_TO_INPUT, SEARCH_OUTPUTS, MOVE_TO_OUTPUT, DANCING } - public ArmTileEntity(TileEntityType typeIn) { + public ArmTileEntity(BlockEntityType typeIn) { super(typeIn); inputs = new ArrayList<>(); outputs = new ArrayList<>(); - interactionPointTag = new ListNBT(); + interactionPointTag = new ListTag(); heldItem = ItemStack.EMPTY; phase = Phase.SEARCH_INPUTS; previousTarget = ArmAngleTarget.NO_TARGET; @@ -161,7 +161,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB makeRenderBoundingBox() { + public AABB makeRenderBoundingBox() { return super.makeRenderBoundingBox().inflate(3); } @@ -199,8 +199,8 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE previousTarget = ArmAngleTarget.NO_TARGET; float progress = chasedPointProgress == 1 ? 1 : (chasedPointProgress % .5f) * 2; - lowerArmAngle.set(MathHelper.lerp(progress, previousTarget.lowerArmAngle, target.lowerArmAngle)); - upperArmAngle.set(MathHelper.lerp(progress, previousTarget.upperArmAngle, target.upperArmAngle)); + lowerArmAngle.set(Mth.lerp(progress, previousTarget.lowerArmAngle, target.lowerArmAngle)); + upperArmAngle.set(Mth.lerp(progress, previousTarget.upperArmAngle, target.upperArmAngle)); headAngle.set(AngleHelper.angleLerp(progress, previousTarget.headAngle % 360, target.headAngle % 360)); return false; @@ -353,7 +353,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE setChanged(); if (!prevHeld.sameItem(heldItem)) - level.playSound(null, worldPosition, SoundEvents.ITEM_PICKUP, SoundCategory.BLOCKS, .125f, + level.playSound(null, worldPosition, SoundEvents.ITEM_PICKUP, SoundSource.BLOCKS, .125f, .5f + Create.RANDOM.nextFloat() * .25f); return; } @@ -391,8 +391,8 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE if (interactionPointTag == null) return; - for (INBT inbt : interactionPointTag) { - ArmInteractionPoint.transformPos(transform, (CompoundNBT) inbt); + for (Tag inbt : interactionPointTag) { + ArmInteractionPoint.transformPos(transform, (CompoundTag) inbt); } sendData(); @@ -408,8 +408,8 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE outputs.clear(); boolean hasBlazeBurner = false; - for (INBT inbt : interactionPointTag) { - ArmInteractionPoint point = ArmInteractionPoint.deserialize(level, worldPosition, (CompoundNBT) inbt); + for (Tag inbt : interactionPointTag) { + ArmInteractionPoint point = ArmInteractionPoint.deserialize(level, worldPosition, (CompoundTag) inbt); if (point == null) continue; if (point.mode == Mode.DEPOSIT) @@ -431,11 +431,11 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE setChanged(); } - public void writeInteractionPoints(CompoundNBT compound) { + public void writeInteractionPoints(CompoundTag compound) { if (updateInteractionPoints) { compound.put("InteractionPoints", interactionPointTag); } else { - ListNBT pointsNBT = new ListNBT(); + ListTag pointsNBT = new ListTag(); inputs.stream() .map(aip -> aip.serialize(worldPosition)) .forEach(pointsNBT::add); @@ -447,7 +447,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); writeInteractionPoints(compound); @@ -460,17 +460,17 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE } @Override - public void writeSafe(CompoundNBT compound, boolean clientPacket) { + public void writeSafe(CompoundTag compound, boolean clientPacket) { super.writeSafe(compound, clientPacket); writeInteractionPoints(compound); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { int previousIndex = chasedPointIndex; Phase previousPhase = phase; - ListNBT interactionPointTagBefore = interactionPointTag; + ListTag interactionPointTagBefore = interactionPointTag; super.fromTag(state, compound, clientPacket); heldItem = ItemStack.of(compound.getCompound("HeldItem")); @@ -504,7 +504,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE } @Override - public boolean addToTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToTooltip(List tooltip, boolean isPlayerSneaking) { if (super.addToTooltip(tooltip, isPlayerSneaking)) return true; if (isPlayerSneaking) @@ -530,9 +530,9 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE } @Override - protected Vector3d getLocalOffset(BlockState state) { + protected Vec3 getLocalOffset(BlockState state) { int yPos = state.getValue(ArmBlock.CEILING) ? 16 - 3 : 3; - Vector3d location = VecHelper.voxelSpace(8, yPos, 15.95); + Vec3 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 00f805719..15b9b1e6d 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 @@ -5,31 +5,33 @@ import java.util.Random; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.HorizontalFaceBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.particles.RedstoneParticleData; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class AnalogLeverBlock extends FaceAttachedHorizontalDirectionalBlock implements ITE { public AnalogLeverBlock(Properties p_i48402_1_) { super(p_i48402_1_); @@ -41,29 +43,29 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE { boolean sneak = player.isShiftKeyDown(); te.changeState(sneak); float f = .25f + ((te.state + 5) / 15f) * .5f; - worldIn.playSound(null, pos, SoundEvents.LEVER_CLICK, SoundCategory.BLOCKS, 0.2F, f); - return ActionResultType.SUCCESS; + worldIn.playSound(null, pos, SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.2F, f); + return InteractionResult.SUCCESS; }); } @Override - public int getSignal(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + public int getSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { return getTileEntityOptional(blockAccess, pos).map(al -> al.state) .orElse(0); } @@ -74,13 +76,13 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE { if (te.state != 0 && rand.nextFloat() < 0.25F) addParticles(stateIn, worldIn, pos, 0.5F); @@ -88,7 +90,7 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE { @@ -98,7 +100,7 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE implements IDynamicInstance { protected final ModelData handle; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java index 6475f2954..ff38e03e0 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.logistics.block.redstone; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -10,21 +10,21 @@ import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Color; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.state.properties.AttachFace; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.core.Direction; public class AnalogLeverRenderer extends SafeTileEntityRenderer { - public AnalogLeverRenderer(TileEntityRendererDispatcher dispatcher) { + public AnalogLeverRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; @@ -32,7 +32,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer type) { + public AnalogLeverTileEntity(BlockEntityType type) { super(type); } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("State", state); compound.putInt("ChangeTimer", lastChange); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState blockState, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState blockState, CompoundTag compound, boolean clientPacket) { state = compound.getInt("State"); lastChange = compound.getInt("ChangeTimer"); clientState.target(state); @@ -69,14 +69,14 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl public void changeState(boolean back) { int prevState = state; state += back ? -1 : 1; - state = MathHelper.clamp(state, 0, 15); + state = Mth.clamp(state, 0, 15); if (prevState != state) lastChange = 15; sendData(); } @Override - public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { + public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { 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 adbf2b22f..48b7dc79c 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 @@ -4,25 +4,25 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.TickPriority; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.TickPriority; +import net.minecraft.world.level.Level; public class ContactMovementBehaviour extends MovementBehaviour { @Override - public Vector3d getActiveAreaOffset(MovementContext context) { - return Vector3d.atLowerCornerOf(context.state.getValue(RedstoneContactBlock.FACING).getNormal()).scale(.65f); + public Vec3 getActiveAreaOffset(MovementContext context) { + return Vec3.atLowerCornerOf(context.state.getValue(RedstoneContactBlock.FACING).getNormal()).scale(.65f); } @Override public void visitNewPosition(MovementContext context, BlockPos pos) { BlockState block = context.state; - World world = context.world; + Level world = context.world; if (world.isClientSide) return; @@ -34,14 +34,14 @@ public class ContactMovementBehaviour extends MovementBehaviour { if (!AllBlocks.REDSTONE_CONTACT.has(visitedState)) return; - Vector3d contact = Vector3d.atLowerCornerOf(block.getValue(RedstoneContactBlock.FACING).getNormal()); + Vec3 contact = Vec3.atLowerCornerOf(block.getValue(RedstoneContactBlock.FACING).getNormal()); contact = context.rotation.apply(contact); Direction direction = Direction.getNearest(contact.x, contact.y, contact.z); if (!RedstoneContactBlock.hasValidContact(world, pos.relative(direction.getOpposite()), direction)) return; world.setBlockAndUpdate(pos, visitedState.setValue(RedstoneContactBlock.POWERED, true)); - context.data.put("lastContact", NBTUtil.writeBlockPos(pos)); + context.data.put("lastContact", NbtUtils.writeBlockPos(pos)); return; } @@ -52,7 +52,7 @@ public class ContactMovementBehaviour extends MovementBehaviour { public void deactivateLastVisitedContact(MovementContext context) { if (context.data.contains("lastContact")) { - BlockPos last = NBTUtil.readBlockPos(context.data.getCompound("lastContact")); + BlockPos last = NbtUtils.readBlockPos(context.data.getCompound("lastContact")); 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 d281bdc0f..6d6d62242 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 @@ -15,29 +15,31 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBe import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemStack; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -public class ContentObserverBlock extends HorizontalBlock implements ITE, IWrenchable { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class ContentObserverBlock extends HorizontalDirectionalBlock implements ITE, IWrenchable { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; @@ -47,13 +49,13 @@ public class ContentObserverBlock extends HorizontalBlock implements ITE itemCap = CapabilityItemHandler.ITEM_HANDLER_CAPABILITY; Capability fluidCap = CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY; @@ -78,9 +80,9 @@ public class ContentObserverBlock extends HorizontalBlock implements ITE type) { + public ContentObserverTileEntity(BlockEntityType type) { super(type); setLazyTickRate(20); } @Override public void addBehaviours(List behaviours) { - filtering = new FilteringBehaviour(this, new FilteredDetectorFilterSlot()).moveText(new Vector3d(0, 5, 0)); + filtering = new FilteringBehaviour(this, new FilteredDetectorFilterSlot()).moveText(new Vec3(0, 5, 0)); behaviours.add(filtering); InterfaceProvider towardBlockFacing = InterfaceProvider.towardBlockFacing(); @@ -123,13 +123,13 @@ public class ContentObserverTileEntity extends SmartTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putInt("TurnOff", turnOffTicks); super.write(compound, clientPacket); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); turnOffTicks = compound.getInt("TurnOff"); } 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 7528f515f..c2481d9bc 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 @@ -1,26 +1,26 @@ package com.simibubi.create.content.logistics.block.redstone; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.phys.Vec3; public class FilteredDetectorFilterSlot extends ValueBoxTransform { - Vector3d position = VecHelper.voxelSpace(8f, 15.5f, 11f); + Vec3 position = VecHelper.voxelSpace(8f, 15.5f, 11f); @Override - protected Vector3d getLocalOffset(BlockState state) { + protected Vec3 getLocalOffset(BlockState state) { return rotateHorizontally(state, position); } @Override - protected void rotate(BlockState state, MatrixStack ms) { - float yRot = AngleHelper.horizontalAngle(state.getValue(HorizontalBlock.FACING)) + 180; + protected void rotate(BlockState state, PoseStack ms) { + float yRot = AngleHelper.horizontalAngle(state.getValue(HorizontalDirectionalBlock.FACING)) + 180; MatrixTransformStack.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 6911d6b4c..5e1168d50 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 @@ -12,32 +12,34 @@ import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; -public class NixieTubeBlock extends HorizontalBlock +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class NixieTubeBlock extends HorizontalDirectionalBlock implements ITE, IWrenchable, ISpecialBlockItemRequirement { public static final BooleanProperty CEILING = BooleanProperty.create("ceiling"); @@ -51,37 +53,37 @@ public class NixieTubeBlock extends HorizontalBlock } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult ray) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult ray) { if (player.isShiftKeyDown()) - return ActionResultType.PASS; + return InteractionResult.PASS; ItemStack heldItem = player.getItemInHand(hand); NixieTubeTileEntity nixie = getTileEntity(world, pos); if (nixie == null) - return ActionResultType.PASS; + return InteractionResult.PASS; if (heldItem.isEmpty()) { if (nixie.reactsToRedstone()) - return ActionResultType.PASS; + return InteractionResult.PASS; nixie.clearCustomText(); updateDisplayedRedstoneValue(state, world, pos); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } boolean display = heldItem.getItem() == Items.NAME_TAG && heldItem.hasCustomHoverName(); DyeColor dye = DyeColor.getColor(heldItem); if (!display && dye == null) - return ActionResultType.PASS; + return InteractionResult.PASS; Direction left = state.getValue(FACING) .getClockWise(); Direction right = left.getOpposite(); if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; BlockPos currentPos = pos; while (true) { @@ -108,7 +110,7 @@ public class NixieTubeBlock extends HorizontalBlock index++; } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override @@ -117,34 +119,34 @@ public class NixieTubeBlock extends HorizontalBlock } @Override - public void onRemove(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, + public void onRemove(BlockState p_196243_1_, Level 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_.removeBlockEntity(p_196243_3_); } @Override - public ItemStack getCloneItemStack(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { + public ItemStack getCloneItemStack(BlockGetter p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { return AllBlocks.ORANGE_NIXIE_TUBE.asStack(); } @Override - public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) { return new ItemRequirement(ItemUseType.CONSUME, AllBlocks.ORANGE_NIXIE_TUBE.get() .asItem()); } @Override - public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, - ISelectionContext p_220053_4_) { + public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, + CollisionContext p_220053_4_) { return (state.getValue(CEILING) ? AllShapes.NIXIE_TUBE_CEILING : AllShapes.NIXIE_TUBE) .get(state.getValue(FACING) .getAxis()); } @Override - public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, - PlayerEntity player) { + public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, + Player player) { if (color != DyeColor.ORANGE) return AllBlocks.ORANGE_NIXIE_TUBE.get() .getPickBlock(state, target, world, pos, player); @@ -152,10 +154,10 @@ public class NixieTubeBlock extends HorizontalBlock } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockPos pos = context.getClickedPos(); boolean ceiling = context.getClickedFace() == Direction.DOWN; - Vector3d hitVec = context.getClickLocation(); + Vec3 hitVec = context.getClickLocation(); if (hitVec != null) ceiling = hitVec.y - pos.getY() > .5f; return defaultBlockState().setValue(FACING, context.getHorizontalDirection() @@ -164,7 +166,7 @@ public class NixieTubeBlock extends HorizontalBlock } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { if (worldIn.isClientSide) return; @@ -175,19 +177,19 @@ public class NixieTubeBlock extends HorizontalBlock } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, Random r) { updateDisplayedRedstoneValue(state, worldIn, pos); } @Override - public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { if (state.getBlock() == oldState.getBlock() || isMoving) return; updateDisplayedRedstoneValue(state, worldIn, pos); } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return new NixieTubeTileEntity(AllTileEntities.NIXIE_TUBE.get()); } @@ -196,7 +198,7 @@ public class NixieTubeBlock extends HorizontalBlock return true; } - private void updateDisplayedRedstoneValue(BlockState state, World worldIn, BlockPos pos) { + private void updateDisplayedRedstoneValue(BlockState state, Level worldIn, BlockPos pos) { if (worldIn.isClientSide) return; withTileEntityDo(worldIn, pos, te -> { @@ -205,13 +207,13 @@ public class NixieTubeBlock extends HorizontalBlock }); } - static boolean isValidBlock(IBlockReader world, BlockPos pos, boolean above) { + static boolean isValidBlock(BlockGetter world, BlockPos pos, boolean above) { BlockState state = world.getBlockState(pos.above(above ? 1 : -1)); return !state.getShape(world, pos) .isEmpty(); } - private int getPower(World worldIn, BlockPos pos) { + private int getPower(Level worldIn, BlockPos pos) { int power = 0; for (Direction direction : Iterate.directions) power = Math.max(worldIn.getSignal(pos.relative(direction), direction), power); @@ -221,12 +223,12 @@ public class NixieTubeBlock extends HorizontalBlock } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } @Override - public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { + public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, Direction side) { return side != null; } 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 6324405aa..4dcfcec09 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 @@ -4,8 +4,8 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.client.model.generators.ModelFile; public class NixieTubeGenerator extends SpecialBlockStateGen { 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 ca100d540..42db6dc13 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 @@ -5,21 +5,21 @@ import java.util.Random; import com.google.common.collect.ImmutableMap; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Couple; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.fonts.TexturedGlyph; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.IRenderTypeBuffer.Impl; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.item.DyeColor; -import net.minecraft.util.text.Style; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.font.glyphs.BakedGlyph; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.MultiBufferSource.BufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.item.DyeColor; +import net.minecraft.network.chat.Style; public class NixieTubeRenderer extends SafeTileEntityRenderer { @@ -50,12 +50,12 @@ public class NixieTubeRenderer extends SafeTileEntityRenderer displayedStrings; - public NixieTubeTileEntity(TileEntityType tileEntityTypeIn) { + public NixieTubeTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); hasCustomText = false; redstoneStrength = 0; @@ -49,7 +49,7 @@ public class NixieTubeTileEntity extends SmartTileEntity { super.tick(); // Dynamic text components have to be ticked manually and re-sent to the client - if (level instanceof ServerWorld && hasCustomText) { + if (level instanceof ServerLevel && hasCustomText) { Couple currentStrings = displayedStrings; parsedCustomText = parseCustomText(); updateDisplayedStrings(); @@ -83,7 +83,7 @@ public class NixieTubeTileEntity extends SmartTileEntity { } public void displayCustomNameOf(ItemStack stack, int nixiePositionInRow) { - CompoundNBT compoundnbt = stack.getTagElement("display"); + CompoundTag compoundnbt = stack.getTagElement("display"); if (compoundnbt != null && compoundnbt.contains("Name", NBT.TAG_STRING)) { hasCustomText = true; rawCustomText = getJsonFromString(compoundnbt.getString("Name")); @@ -113,19 +113,19 @@ public class NixieTubeTileEntity extends SmartTileEntity { // @Override - protected void fromTag(BlockState state, CompoundNBT nbt, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag nbt, boolean clientPacket) { super.fromTag(state, nbt, clientPacket); if (nbt.contains("RawCustomText", NBT.TAG_STRING)) { rawCustomText = getJsonFromString(nbt.getString("RawCustomText")); // Check if string forms valid JSON if (rawCustomText != null && !rawCustomText.isJsonNull()) { - ITextComponent deserializedComponent = parseCustomText(); + Component deserializedComponent = parseCustomText(); // Check if JSON forms valid component if (deserializedComponent != null) { try { // Try to deserialize previously parsed component - parsedCustomText = ITextComponent.Serializer.fromJson(nbt.getString("CustomText")); + parsedCustomText = Component.Serializer.fromJson(nbt.getString("CustomText")); } catch (JsonParseException e) { // } @@ -149,13 +149,13 @@ public class NixieTubeTileEntity extends SmartTileEntity { } @Override - protected void write(CompoundNBT nbt, boolean clientPacket) { + protected void write(CompoundTag nbt, boolean clientPacket) { super.write(nbt, clientPacket); if (hasCustomText) { nbt.putString("RawCustomText", rawCustomText.toString()); nbt.putInt("CustomTextIndex", customTextIndex); - nbt.putString("CustomText", ITextComponent.Serializer.toJson(parsedCustomText)); + nbt.putString("CustomText", Component.Serializer.toJson(parsedCustomText)); } else { nbt.putInt("RedstoneStrength", redstoneStrength); } @@ -173,18 +173,18 @@ public class NixieTubeTileEntity extends SmartTileEntity { return string.length() <= index ? " " : string.substring(index, index + 1); } - protected ITextComponent parseCustomText() { + protected Component parseCustomText() { try { - return parseDynamicComponent(ITextComponent.Serializer.fromJson(rawCustomText)); + return parseDynamicComponent(Component.Serializer.fromJson(rawCustomText)); } catch (JsonParseException e) { return null; } } - protected ITextComponent parseDynamicComponent(ITextComponent customText) { - if (level instanceof ServerWorld) { + protected Component parseDynamicComponent(Component customText) { + if (level instanceof ServerLevel) { try { - return TextComponentUtils.updateForEntity(getCommandSource(null), customText, null, 0); + return ComponentUtils.updateForEntity(getCommandSource(null), customText, null, 0); } catch (CommandSyntaxException e) { // } @@ -193,10 +193,10 @@ public class NixieTubeTileEntity extends SmartTileEntity { } // From SignTileEntity - public CommandSource getCommandSource(@Nullable ServerPlayerEntity p_195539_1_) { + public CommandSourceStack getCommandSource(@Nullable ServerPlayer 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.NULL, Vector3d.atCenterOf(this.worldPosition), Vector2f.ZERO, (ServerWorld)this.level, 2, s, itextcomponent, this.level.getServer(), p_195539_1_); + Component itextcomponent = (Component)(p_195539_1_ == null ? new TextComponent("Nixie Tube") : p_195539_1_.getDisplayName()); + return new CommandSourceStack(CommandSource.NULL, Vec3.atCenterOf(this.worldPosition), Vec2.ZERO, (ServerLevel)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 fe7886258..9ff002f2e 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 @@ -9,18 +9,20 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -41,7 +43,7 @@ public class RedstoneContactBlock extends WrenchableDirectionalBlock { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockState state = defaultBlockState().setValue(FACING, context.getNearestLookingDirection() .getOpposite()); Direction placeDirection = context.getClickedFace() @@ -57,7 +59,7 @@ public class RedstoneContactBlock extends WrenchableDirectionalBlock { } @Override - public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { if (facing != stateIn.getValue(FACING)) return stateIn; @@ -70,7 +72,7 @@ public class RedstoneContactBlock extends WrenchableDirectionalBlock { @SuppressWarnings("deprecation") @Override - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() == this && newState.getBlock() == this) { if (state == newState.cycle(POWERED)) worldIn.updateNeighborsAt(pos, this); @@ -79,13 +81,13 @@ public class RedstoneContactBlock extends WrenchableDirectionalBlock { } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + public void tick(BlockState state, ServerLevel 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) { + public static boolean hasValidContact(LevelAccessor world, BlockPos pos, Direction direction) { BlockState blockState = world.getBlockState(pos.relative(direction)); return AllBlocks.REDSTONE_CONTACT.has(blockState) && blockState.getValue(FACING) == direction.getOpposite(); } @@ -96,14 +98,14 @@ public class RedstoneContactBlock extends WrenchableDirectionalBlock { } @Override - public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, @Nullable Direction side) { + public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, @Nullable Direction side) { if (side == null) return true; return state.getValue(FACING) != side.getOpposite(); } @Override - public int getSignal(BlockState state, IBlockReader blockAccess, BlockPos pos, Direction side) { + public int getSignal(BlockState state, BlockGetter 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 c3aac94f1..a8ccbb2c0 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 @@ -8,27 +8,29 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE { @@ -42,7 +44,7 @@ public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { if (worldIn.isClientSide) return; @@ -62,18 +64,18 @@ public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, Random r) { updateTransmittedSignal(state, worldIn, pos); } @Override - public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { if (state.getBlock() == oldState.getBlock() || isMoving) return; updateTransmittedSignal(state, worldIn, pos); } - public void updateTransmittedSignal(BlockState state, World worldIn, BlockPos pos) { + public void updateTransmittedSignal(BlockState state, Level worldIn, BlockPos pos) { if (worldIn.isClientSide) return; if (state.getValue(RECEIVER)) @@ -89,7 +91,7 @@ public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE withTileEntityDo(worldIn, pos, te -> te.transmit(transmit)); } - private int getPower(World worldIn, BlockPos pos) { + private int getPower(Level worldIn, BlockPos pos) { int power = 0; for (Direction direction : Iterate.directions) power = Math.max(worldIn.getSignal(pos.relative(direction), direction), power); @@ -104,14 +106,14 @@ public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE } @Override - public int getDirectSignal(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + public int getDirectSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { if (side != blockState.getValue(FACING)) return 0; return getSignal(blockState, blockAccess, pos, side); } @Override - public int getSignal(BlockState state, IBlockReader blockAccess, BlockPos pos, Direction side) { + public int getSignal(BlockState state, BlockGetter blockAccess, BlockPos pos, Direction side) { if (!state.getValue(RECEIVER)) return 0; return getTileEntityOptional(blockAccess, pos).map(RedstoneLinkTileEntity::getReceivedSignal) @@ -130,21 +132,21 @@ public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.REDSTONE_LINK.create(); } @Override - public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, + BlockHitResult hit) { if (player.isShiftKeyDown()) return toggleMode(state, worldIn, pos); - return ActionResultType.PASS; + return InteractionResult.PASS; } - public ActionResultType toggleMode(BlockState state, World worldIn, BlockPos pos) { + public InteractionResult toggleMode(BlockState state, Level worldIn, BlockPos pos) { if (worldIn.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; return onTileEntityUse(worldIn, pos, te -> { Boolean wasReceiver = state.getValue(RECEIVER); @@ -152,14 +154,14 @@ public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE worldIn.setBlock(pos, state.cycle(RECEIVER) .setValue(POWERED, blockPowered), 3); te.transmit(wasReceiver ? 0 : getPower(worldIn, pos)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; }); } @Override - public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - if (toggleMode(state, context.getLevel(), context.getClickedPos()) == ActionResultType.SUCCESS) - return ActionResultType.SUCCESS; + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + if (toggleMode(state, context.getLevel(), context.getClickedPos()) == InteractionResult.SUCCESS) + return InteractionResult.SUCCESS; return super.onWrenched(state, context); } @@ -169,12 +171,12 @@ public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE } @Override - public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { + public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, Direction side) { return side != null; } @Override - public boolean canSurvive(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) { BlockPos neighbourPos = pos.relative(state.getValue(FACING) .getOpposite()); BlockState neighbour = worldIn.getBlockState(neighbourPos); @@ -183,19 +185,19 @@ public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockState state = defaultBlockState(); state = state.setValue(FACING, context.getClickedFace()); return state; } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return AllShapes.REDSTONE_BRIDGE.get(state.getValue(FACING)); } @Override - public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { + public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) { return false; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkFrequencySlot.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkFrequencySlot.java index 010153c70..81fb096de 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkFrequencySlot.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkFrequencySlot.java @@ -1,15 +1,15 @@ package com.simibubi.create.content.logistics.block.redstone; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.Vec3; public class RedstoneLinkFrequencySlot extends ValueBoxTransform.Dual { @@ -17,13 +17,13 @@ public class RedstoneLinkFrequencySlot extends ValueBoxTransform.Dual { super(first); } - Vector3d horizontal = VecHelper.voxelSpace(10f, 5.5f, 2.5f); - Vector3d vertical = VecHelper.voxelSpace(10f, 2.5f, 5.5f); + Vec3 horizontal = VecHelper.voxelSpace(10f, 5.5f, 2.5f); + Vec3 vertical = VecHelper.voxelSpace(10f, 2.5f, 5.5f); @Override - protected Vector3d getLocalOffset(BlockState state) { + protected Vec3 getLocalOffset(BlockState state) { Direction facing = state.getValue(RedstoneLinkBlock.FACING); - Vector3d location = vertical; + Vec3 location = vertical; if (facing.getAxis() .isHorizontal()) { @@ -40,7 +40,7 @@ public class RedstoneLinkFrequencySlot extends ValueBoxTransform.Dual { } @Override - protected void rotate(BlockState state, MatrixStack ms) { + protected void rotate(BlockState state, PoseStack ms) { Direction facing = state.getValue(RedstoneLinkBlock.FACING); float yRot = facing.getAxis() .isVertical() ? 0 : AngleHelper.horizontalAngle(facing) + 180; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkGenerator.java index 09ad309db..33cba17f8 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkGenerator.java @@ -4,9 +4,9 @@ import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; import net.minecraftforge.client.model.generators.ModelFile; public class RedstoneLinkGenerator extends SpecialBlockStateGen { 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 cac4b3355..c106a023a 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 @@ -2,10 +2,21 @@ package com.simibubi.create.content.logistics.block.redstone; import static net.minecraft.state.properties.BlockStateProperties.POWERED; +import javanet.minimport com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.tileEntity.SmartTileEntity; +import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; +import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour; import java.util.List; - +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; import org.apache.commons.lang3.tuple.Pair; +ecraft.world.level.block.state.properties.BlockStatePropertiese.Pair; + import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; @@ -26,7 +37,7 @@ public class RedstoneLinkTileEntity extends SmartTileEntity { private LinkBehaviour link; private boolean transmitter; - public RedstoneLinkTileEntity(TileEntityType type) { + public RedstoneLinkTileEntity(BlockEntityType type) { super(type); } @@ -64,7 +75,7 @@ public class RedstoneLinkTileEntity extends SmartTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putBoolean("Transmitter", transmitter); compound.putInt("Receive", getReceivedSignal()); compound.putBoolean("ReceivedChanged", receivedSignalChanged); @@ -73,7 +84,7 @@ public class RedstoneLinkTileEntity extends SmartTileEntity { } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { transmitter = compound.getBoolean("Transmitter"); super.fromTag(state, compound, clientPacket); 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 d5070ecec..859b2c2b0 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 @@ -10,26 +10,26 @@ import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.IntegerProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.Capability; @@ -39,7 +39,9 @@ import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -public class StockpileSwitchBlock extends HorizontalBlock implements ITE, IWrenchable { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class StockpileSwitchBlock extends HorizontalDirectionalBlock implements ITE, IWrenchable { public static final IntegerProperty INDICATOR = IntegerProperty.create("indicator", 0, 6); @@ -48,12 +50,12 @@ public class StockpileSwitchBlock extends HorizontalBlock implements ITE () -> withTileEntityDo(worldIn, pos, te -> this.displayScreen(te, player))); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @OnlyIn(value = Dist.CLIENT) - protected void displayScreen(StockpileSwitchTileEntity te, PlayerEntity player) { - if (player instanceof ClientPlayerEntity) + protected void displayScreen(StockpileSwitchTileEntity te, Player player) { + if (player instanceof LocalPlayer) ScreenOpener.open(new StockpileSwitchScreen(te)); } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { BlockState state = defaultBlockState(); Capability itemCap = CapabilityItemHandler.ITEM_HANDLER_CAPABILITY; Capability fluidCap = CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY; Direction preferredFacing = null; for (Direction face : Iterate.horizontalDirections) { - TileEntity te = context.getLevel() + BlockEntity te = context.getLevel() .getBlockEntity(context.getClickedPos() .relative(face)); if (te != null && (te.getCapability(itemCap) @@ -165,7 +167,7 @@ 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.plainCopy()) + .titled(TextComponent.EMPTY.plainCopy()) .calling(state -> { lastModification = 0; onAbove.titled(Lang.translate("gui.stockpile_switch.move_to_lower_at", state)); @@ -97,7 +97,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int x = guiLeft; int y = guiTop; 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 c36150c9a..a3689668f 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 @@ -9,15 +9,15 @@ import com.simibubi.create.foundation.tileEntity.behaviour.inventory.CapManipula import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.inventory.TankManipulationBehaviour; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.ITickList; -import net.minecraft.world.TickPriority; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.TickList; +import net.minecraft.world.level.TickPriority; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.IItemHandler; @@ -35,7 +35,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { private InvManipulationBehaviour observedInventory; private TankManipulationBehaviour observedTank; - public StockpileSwitchTileEntity(TileEntityType typeIn) { + public StockpileSwitchTileEntity(BlockEntityType typeIn) { super(typeIn); onWhenAbove = .75f; offWhenBelow = .25f; @@ -47,7 +47,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { } @Override - protected void fromTag(BlockState blockState, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState blockState, CompoundTag compound, boolean clientPacket) { onWhenAbove = compound.getFloat("OnAbove"); offWhenBelow = compound.getFloat("OffBelow"); currentLevel = compound.getFloat("Current"); @@ -58,7 +58,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { compound.putFloat("OnAbove", onWhenAbove); compound.putFloat("OffBelow", offWhenBelow); compound.putFloat("Current", currentLevel); @@ -127,7 +127,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { if (currentLevel != stockLevel) changed = true; currentLevel = stockLevel; - currentLevel = MathHelper.clamp(currentLevel, 0, 1); + currentLevel = Mth.clamp(currentLevel, 0, 1); boolean previouslyPowered = state; if (state && currentLevel <= offWhenBelow) @@ -150,7 +150,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { } protected void scheduleBlockTick() { - ITickList blockTicks = level.getBlockTicks(); + TickList blockTicks = level.getBlockTicks(); Block block = getBlockState().getBlock(); if (!blockTicks.willTickThisTick(worldPosition, block)) blockTicks.scheduleTick(worldPosition, block, 2, TickPriority.NORMAL); @@ -166,7 +166,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity { @Override public void addBehaviours(List behaviours) { - filtering = new FilteringBehaviour(this, new FilteredDetectorFilterSlot()).moveText(new Vector3d(0, 5, 0)) + filtering = new FilteringBehaviour(this, new FilteredDetectorFilterSlot()).moveText(new Vec3(0, 5, 0)) .withCallback($ -> updateCurrentLevel()); behaviours.add(filtering); 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 085727e15..cb9e65df6 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 @@ -4,26 +4,28 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.ItemStackHelper; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.Constants; +import net.minecraft.world.item.Item.Properties; + public class CardboardBoxItem extends Item { static final int SLOTS = 9; @@ -35,7 +37,7 @@ public class CardboardBoxItem extends Item { } @Override - public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { + public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { if (!playerIn.isShiftKeyDown()) return super.use(worldIn, playerIn, handIn); @@ -46,23 +48,23 @@ public class CardboardBoxItem extends Item { if (!playerIn.isCreative()) { box.shrink(1); } - return new ActionResult<>(ActionResultType.SUCCESS, box); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, box); } public static ItemStack containing(List stacks) { ItemStack box = new ItemStack(randomBox()); - CompoundNBT compound = new CompoundNBT(); + CompoundTag compound = new CompoundTag(); NonNullList list = NonNullList.create(); list.addAll(stacks); - ItemStackHelper.saveAllItems(compound, list); + ContainerHelper.saveAllItems(compound, list); box.setTag(compound); return box; } @Override - public void fillItemCategory(ItemGroup group, NonNullList items) { + public void fillItemCategory(CreativeModeTab group, NonNullList items) { } public static void addAddress(ItemStack box, String address) { @@ -85,7 +87,7 @@ public class CardboardBoxItem extends Item { public static List getContents(ItemStack box) { NonNullList list = NonNullList.withSize(SLOTS, ItemStack.EMPTY); - ItemStackHelper.loadAllItems(box.getOrCreateTag(), list); + ContainerHelper.loadAllItems(box.getOrCreateTag(), list); return list; } @@ -95,13 +97,13 @@ public class CardboardBoxItem extends Item { @Override @OnlyIn(value = Dist.CLIENT) - public void appendHoverText(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + public void appendHoverText(ItemStack stack, Level worldIn, List tooltip, TooltipFlag flagIn) { super.appendHoverText(stack, worldIn, tooltip, flagIn); - CompoundNBT compoundnbt = stack.getOrCreateTag(); + CompoundTag compoundnbt = stack.getOrCreateTag(); if (compoundnbt.contains("Address", Constants.NBT.TAG_STRING)) { - tooltip.add(new StringTextComponent("-> " + compoundnbt.getString("Address")) - .withStyle(TextFormatting.GOLD)); + tooltip.add(new TextComponent("-> " + compoundnbt.getString("Address")) + .withStyle(ChatFormatting.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.getHoverName(); + Component itextcomponent = itemstack.getHoverName(); tooltip.add(itextcomponent.plainCopy().append(" x").append(String.valueOf(itemstack.getCount())) - .withStyle(TextFormatting.GRAY)); + .withStyle(ChatFormatting.GRAY)); } } if (j - i > 0) { - tooltip.add((new TranslationTextComponent("container.shulkerBox.more", j - i)) - .withStyle(TextFormatting.ITALIC)); + tooltip.add((new TranslatableComponent("container.shulkerBox.more", j - i)) + .withStyle(ChatFormatting.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 1e8f87a77..41f8e20c5 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 @@ -11,19 +11,21 @@ import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.block.ITE; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.LecternBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LecternBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class LecternControllerBlock extends LecternBlock implements ITE, ISpecialBlockItemRequirement { @@ -34,13 +36,13 @@ public class LecternControllerBlock extends LecternBlock implements ITE te.tryStartUsing(player)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (player.isShiftKeyDown()) { if (!world.isClientSide) replaceWithLectern(state, world, pos); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { if (!state.is(newState.getBlock())) { if (!world.isClientSide) withTileEntityDo(world, pos, te -> te.dropController(state)); @@ -77,18 +79,18 @@ public class LecternControllerBlock extends LecternBlock implements ITE te.setController(controller)); } - public void replaceWithLectern(BlockState state, World world, BlockPos pos) { + public void replaceWithLectern(BlockState state, Level world, BlockPos pos) { AllSoundEvents.CONTROLLER_TAKE.playOnServer(world, pos); world.setBlockAndUpdate(pos, Blocks.LECTERN.defaultBlockState() .setValue(FACING, state.getValue(FACING)) @@ -96,12 +98,12 @@ public class LecternControllerBlock extends LecternBlock implements ITE requiredItems = new ArrayList<>(); requiredItems.add(new ItemStack(Blocks.LECTERN)); requiredItems.add(new ItemStack(AllItems.LINKED_CONTROLLER.get())); 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 33e7d36d5..0fea42fbb 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 @@ -1,28 +1,28 @@ package com.simibubi.create.content.logistics.item; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; public class LecternControllerRenderer extends SafeTileEntityRenderer { - public LecternControllerRenderer(TileEntityRendererDispatcher dispatcher) { + public LecternControllerRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(LecternControllerTileEntity te, float partialTicks, MatrixStack ms, - IRenderTypeBuffer buffer, int light, int overlay) { + protected void renderSafe(LecternControllerTileEntity te, float partialTicks, PoseStack ms, + MultiBufferSource buffer, int light, int overlay) { ItemStack stack = AllItems.LINKED_CONTROLLER.asStack(); TransformType transformType = TransformType.NONE; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerTileEntity.java index 6d241c4f9..9a5dcd098 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerTileEntity.java @@ -7,20 +7,20 @@ import com.simibubi.create.AllSoundEvents; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ForgeMod; @@ -33,7 +33,7 @@ public class LecternControllerTileEntity extends SmartTileEntity { private UUID prevUser; // used only on client private boolean deactivatedThisTick; // used only on server - public LecternControllerTileEntity(TileEntityType type) { + public LecternControllerTileEntity(BlockEntityType type) { super(type); } @@ -41,21 +41,21 @@ public class LecternControllerTileEntity extends SmartTileEntity { public void addBehaviours(List behaviours) { } @Override - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); - compound.put("Controller", controller.save(new CompoundNBT())); + compound.put("Controller", controller.save(new CompoundTag())); if (user != null) compound.putUUID("User", user); } @Override - public void writeSafe(CompoundNBT compound, boolean clientPacket) { + public void writeSafe(CompoundTag compound, boolean clientPacket) { super.writeSafe(compound, clientPacket); - compound.put("Controller", controller.save(new CompoundNBT())); + compound.put("Controller", controller.save(new CompoundTag())); } @Override - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); controller = ItemStack.of(compound.getCompound("Controller")); user = compound.hasUUID("User") ? compound.getUUID("User") : null; @@ -67,27 +67,27 @@ public class LecternControllerTileEntity extends SmartTileEntity { public boolean hasUser() { return user != null; } - public boolean isUsedBy(PlayerEntity player) { + public boolean isUsedBy(Player player) { return hasUser() && user.equals(player.getUUID()); } - public void tryStartUsing(PlayerEntity player) { + public void tryStartUsing(Player player) { if (!deactivatedThisTick && !hasUser() && !playerIsUsingLectern(player) && playerInRange(player, level, worldPosition)) startUsing(player); } - public void tryStopUsing(PlayerEntity player) { + public void tryStopUsing(Player player) { if (isUsedBy(player)) stopUsing(player); } - private void startUsing(PlayerEntity player) { + private void startUsing(Player player) { user = player.getUUID(); player.getPersistentData().putBoolean("IsUsingLecternController", true); sendData(); } - private void stopUsing(PlayerEntity player) { + private void stopUsing(Player player) { user = null; if (player != null) player.getPersistentData().remove("IsUsingLecternController"); @@ -95,7 +95,7 @@ public class LecternControllerTileEntity extends SmartTileEntity { sendData(); } - public static boolean playerIsUsingLectern(PlayerEntity player) { + public static boolean playerIsUsingLectern(Player player) { return player.getPersistentData().contains("IsUsingLecternController"); } @@ -111,18 +111,18 @@ public class LecternControllerTileEntity extends SmartTileEntity { if (!level.isClientSide) { deactivatedThisTick = false; - if (!(level instanceof ServerWorld)) + if (!(level instanceof ServerLevel)) return; if (user == null) return; - Entity entity = ((ServerWorld) level).getEntity(user); - if (!(entity instanceof PlayerEntity)) { + Entity entity = ((ServerLevel) level).getEntity(user); + if (!(entity instanceof Player)) { stopUsing(null); return; } - PlayerEntity player = (PlayerEntity) entity; + Player player = (Player) entity; if (!playerInRange(player, level, worldPosition) || !playerIsUsingLectern(player)) stopUsing(player); } @@ -144,7 +144,7 @@ public class LecternControllerTileEntity extends SmartTileEntity { } } - public void swapControllers(ItemStack stack, PlayerEntity player, Hand hand, BlockState state) { + public void swapControllers(ItemStack stack, Player player, InteractionHand hand, BlockState state) { ItemStack newController = stack.copy(); stack.setCount(0); if (player.getItemInHand(hand).isEmpty()) { @@ -156,9 +156,9 @@ public class LecternControllerTileEntity extends SmartTileEntity { } public void dropController(BlockState state) { - Entity playerEntity = ((ServerWorld) level).getEntity(user); - if (playerEntity instanceof PlayerEntity) - stopUsing((PlayerEntity) playerEntity); + Entity playerEntity = ((ServerLevel) level).getEntity(user); + if (playerEntity instanceof Player) + stopUsing((Player) playerEntity); Direction dir = state.getValue(LecternControllerBlock.FACING); double x = worldPosition.getX() + 0.5 + 0.25*dir.getStepX(); @@ -170,10 +170,10 @@ public class LecternControllerTileEntity extends SmartTileEntity { controller = null; } - public static boolean playerInRange(PlayerEntity player, World world, BlockPos pos) { + public static boolean playerInRange(Player player, Level world, BlockPos pos) { //double modifier = world.isRemote ? 0 : 1.0; double reach = 0.4*player.getAttributeValue(ForgeMod.REACH_DISTANCE.get());// + modifier; - return player.distanceToSqr(Vector3d.atCenterOf(pos)) < reach*reach; + return player.distanceToSqr(Vec3.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 096f4f885..54fdd9bf7 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 @@ -6,10 +6,10 @@ import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler.Frequenc import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; import net.minecraftforge.items.ItemStackHandler; public class LinkedControllerBindPacket extends LinkedControllerPacketBase { @@ -23,21 +23,21 @@ public class LinkedControllerBindPacket extends LinkedControllerPacketBase { this.linkLocation = linkLocation; } - public LinkedControllerBindPacket(PacketBuffer buffer) { + public LinkedControllerBindPacket(FriendlyByteBuf buffer) { super(buffer); this.button = buffer.readVarInt(); this.linkLocation = buffer.readBlockPos(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { super.write(buffer); buffer.writeVarInt(button); buffer.writeBlockPos(linkLocation); } @Override - protected void handleItem(ServerPlayerEntity player, ItemStack heldItem) { + protected void handleItem(ServerPlayer player, ItemStack heldItem) { if (player.isSpectator()) return; @@ -58,6 +58,6 @@ public class LinkedControllerBindPacket extends LinkedControllerPacketBase { } @Override - protected void handleLectern(ServerPlayerEntity player, LecternControllerTileEntity lectern) { } + protected void handleLectern(ServerPlayer player, LecternControllerTileEntity lectern) { } } 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 18f1907d0..6fb30531f 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 @@ -8,7 +8,7 @@ import java.util.Vector; import org.lwjgl.glfw.GLFW; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; @@ -20,18 +20,18 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.GameSettings; +import net.minecraft.client.Options; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.client.util.InputMappings; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.KeyMapping; +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; public class LinkedControllerClientHandler { @@ -40,13 +40,13 @@ public class LinkedControllerClientHandler { public static Collection currentlyPressed = new HashSet<>(); private static BlockPos lecternPos; private static BlockPos selectedLocation = BlockPos.ZERO; - private static Vector controls; + private static Vector controls; private static int packetCooldown; - public static Vector getControls() { + public static Vector getControls() { if (controls == null) { - GameSettings gameSettings = Minecraft.getInstance().options; + Options gameSettings = Minecraft.getInstance().options; controls = new Vector<>(6); controls.add(gameSettings.keyUp); controls.add(gameSettings.keyDown); @@ -112,8 +112,8 @@ public class LinkedControllerClientHandler { LinkedControllerItemRenderer.resetButtons(); } - protected static boolean isActuallyPressed(KeyBinding kb) { - return InputMappings.isKeyDown(Minecraft.getInstance() + protected static boolean isActuallyPressed(KeyMapping kb) { + return InputConstants.isKeyDown(Minecraft.getInstance() .getWindow() .getWindow(), kb.getKey() @@ -129,7 +129,7 @@ public class LinkedControllerClientHandler { packetCooldown--; Minecraft mc = Minecraft.getInstance(); - ClientPlayerEntity player = mc.player; + LocalPlayer player = mc.player; ItemStack heldItem = player.getMainHandItem(); if (player.isSpectator()) { @@ -160,13 +160,13 @@ public class LinkedControllerClientHandler { return; } - if (InputMappings.isKeyDown(mc.getWindow().getWindow(), GLFW.GLFW_KEY_ESCAPE)) { + if (InputConstants.isKeyDown(mc.getWindow().getWindow(), GLFW.GLFW_KEY_ESCAPE)) { MODE = Mode.IDLE; onReset(); return; } - Vector controls = getControls(); + Vector controls = getControls(); Collection pressedKeys = new HashSet<>(); for (int i = 0; i < controls.size(); i++) { if (isActuallyPressed(controls.get(i))) @@ -227,7 +227,7 @@ public class LinkedControllerClientHandler { controls.forEach(kb -> kb.setDown(false)); } - public static void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, + public static void renderOverlay(PoseStack ms, MultiBufferSource buffer, int light, int overlay, float partialTicks) { if (MODE != Mode.BIND) return; @@ -241,23 +241,23 @@ public class LinkedControllerClientHandler { .getGuiScaledHeight()); Object[] keys = new Object[6]; - Vector controls = getControls(); + Vector controls = getControls(); for (int i = 0; i < controls.size(); i++) { - KeyBinding keyBinding = controls.get(i); + KeyMapping keyBinding = controls.get(i); keys[i] = keyBinding.getTranslatedKeyMessage() .getString(); } - List list = new ArrayList<>(); + List list = new ArrayList<>(); list.add(Lang.createTranslationTextComponent("linked_controller.bind_mode") - .withStyle(TextFormatting.GOLD)); + .withStyle(ChatFormatting.GOLD)); list.addAll( TooltipHelper.cutTextComponent(Lang.createTranslationTextComponent("linked_controller.press_keybind", keys), - TextFormatting.GRAY, TextFormatting.GRAY)); + ChatFormatting.GRAY, ChatFormatting.GRAY)); int width = 0; int height = list.size() * mc.font.lineHeight; - for (ITextComponent iTextComponent : list) + for (Component iTextComponent : list) width = Math.max(width, mc.font.width(iTextComponent)); int x = (tooltipScreen.width / 3) - width / 2; int y = tooltipScreen.height - height; 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 3f546e399..74fdcf370 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 @@ -3,29 +3,29 @@ package com.simibubi.create.content.logistics.item; import com.simibubi.create.AllContainerTypes; import com.simibubi.create.foundation.gui.IClearableContainer; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ClickType; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.SlotItemHandler; -public class LinkedControllerContainer extends Container implements IClearableContainer { +public class LinkedControllerContainer extends AbstractContainerMenu implements IClearableContainer { - public PlayerEntity player; - protected PlayerInventory playerInventory; + public Player player; + protected Inventory playerInventory; public ItemStack mainItem; public ItemStackHandler filterInventory; - public LinkedControllerContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + public LinkedControllerContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { this(type, id, inv, extraData.readItem()); } - public LinkedControllerContainer(ContainerType type, int id, PlayerInventory inv, ItemStack filterItem) { + public LinkedControllerContainer(MenuType type, int id, Inventory inv, ItemStack filterItem) { super(type, id); player = inv.player; playerInventory = inv; @@ -33,7 +33,7 @@ public class LinkedControllerContainer extends Container implements IClearableCo init(); } - public static LinkedControllerContainer create(int id, PlayerInventory inv, ItemStack filterItem) { + public static LinkedControllerContainer create(int id, Inventory inv, ItemStack filterItem) { return new LinkedControllerContainer(AllContainerTypes.LINKED_CONTROLLER.get(), id, inv, filterItem); } @@ -87,12 +87,12 @@ public class LinkedControllerContainer extends Container implements IClearableCo } @Override - public boolean stillValid(PlayerEntity playerIn) { + public boolean stillValid(Player playerIn) { return playerInventory.getSelected() == mainItem; } @Override - public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { + public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) { if (slotId == playerInventory.selected && clickTypeIn != ClickType.THROW) return ItemStack.EMPTY; @@ -130,7 +130,7 @@ public class LinkedControllerContainer extends Container implements IClearableCo } @Override - public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(Player playerIn, int index) { if (index < 36) { ItemStack stackToInsert = playerInventory.getItem(index); for (int i = 0; i < filterInventory.getSlots(); i++) { @@ -148,7 +148,7 @@ public class LinkedControllerContainer extends Container implements IClearableCo } @Override - public void removed(PlayerEntity playerIn) { + public void removed(Player playerIn) { super.removed(playerIn); mainItem.getOrCreateTag() .put("Items", filterInventory.serializeNBT()); 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 5a2105141..c511fef2d 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 @@ -5,11 +5,11 @@ import java.util.Collection; import java.util.UUID; import java.util.stream.Collectors; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class LinkedControllerInputPacket extends LinkedControllerPacketBase { @@ -26,7 +26,7 @@ public class LinkedControllerInputPacket extends LinkedControllerPacketBase { this.press = press; } - public LinkedControllerInputPacket(PacketBuffer buffer) { + public LinkedControllerInputPacket(FriendlyByteBuf buffer) { super(buffer); activatedButtons = new ArrayList<>(); press = buffer.readBoolean(); @@ -36,7 +36,7 @@ public class LinkedControllerInputPacket extends LinkedControllerPacketBase { } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { super.write(buffer); buffer.writeBoolean(press); buffer.writeVarInt(activatedButtons.size()); @@ -44,14 +44,14 @@ public class LinkedControllerInputPacket extends LinkedControllerPacketBase { } @Override - protected void handleLectern(ServerPlayerEntity player, LecternControllerTileEntity lectern) { + protected void handleLectern(ServerPlayer player, LecternControllerTileEntity lectern) { if (lectern.isUsedBy(player)) handleItem(player, lectern.getController()); } @Override - protected void handleItem(ServerPlayerEntity player, ItemStack heldItem) { - World world = player.getCommandSenderWorld(); + protected void handleItem(ServerPlayer player, ItemStack heldItem) { + Level world = player.getCommandSenderWorld(); UUID uniqueID = player.getUUID(); BlockPos pos = player.blockPosition(); 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 bbc3d7eff..3cf9bb43c 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 @@ -6,43 +6,45 @@ import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler; import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler.Frequency; import com.simibubi.create.foundation.utility.Couple; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.LecternBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LecternBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.ItemStackHandler; -public class LinkedControllerItem extends Item implements INamedContainerProvider { +import net.minecraft.world.item.Item.Properties; + +public class LinkedControllerItem extends Item implements MenuProvider { public LinkedControllerItem(Properties properties) { super(properties); } @Override - public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext ctx) { - PlayerEntity player = ctx.getPlayer(); + public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext ctx) { + Player player = ctx.getPlayer(); if (player == null) - return ActionResultType.PASS; - World world = ctx.getLevel(); + return InteractionResult.PASS; + Level world = ctx.getLevel(); BlockPos pos = ctx.getClickedPos(); BlockState hitState = world.getBlockState(pos); @@ -52,7 +54,7 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide if (!world.isClientSide) AllBlocks.LECTERN_CONTROLLER.get().withTileEntityDo(world, pos, te -> te.swapControllers(stack, player, ctx.getHand(), hitState)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } } else { if (AllBlocks.REDSTONE_LINK.has(hitState)) { @@ -60,7 +62,7 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> this.toggleBindMode(ctx.getClickedPos())); player.getCooldowns() .addCooldown(this, 2); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (hitState.is(Blocks.LECTERN) && !hitState.getValue(LecternBlock.HAS_BOOK)) { @@ -68,11 +70,11 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide ItemStack lecternStack = player.isCreative() ? stack.copy() : stack.split(1); AllBlocks.LECTERN_CONTROLLER.get().replaceLectern(hitState, world, pos, lecternStack); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } if (AllBlocks.LECTERN_CONTROLLER.has(hitState)) - return ActionResultType.PASS; + return InteractionResult.PASS; } } @@ -80,15 +82,15 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide } @Override - public ActionResult use(World world, PlayerEntity player, Hand hand) { + public InteractionResultHolder use(Level world, Player player, InteractionHand hand) { ItemStack heldItem = player.getItemInHand(hand); - if (player.isShiftKeyDown() && hand == Hand.MAIN_HAND) { - if (!world.isClientSide && player instanceof ServerPlayerEntity && player.mayBuild()) - NetworkHooks.openGui((ServerPlayerEntity) player, this, buf -> { + if (player.isShiftKeyDown() && hand == InteractionHand.MAIN_HAND) { + if (!world.isClientSide && player instanceof ServerPlayer && player.mayBuild()) + NetworkHooks.openGui((ServerPlayer) player, this, buf -> { buf.writeItem(heldItem); }); - return ActionResult.success(heldItem); + return InteractionResultHolder.success(heldItem); } if (!player.isShiftKeyDown()) { @@ -98,7 +100,7 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide .addCooldown(this, 2); } - return ActionResult.pass(heldItem); + return InteractionResultHolder.pass(heldItem); } @OnlyIn(Dist.CLIENT) @@ -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.getOrCreateTagElement("Items"); + CompoundTag invNBT = stack.getOrCreateTagElement("Items"); if (!invNBT.isEmpty()) newInv.deserializeNBT(invNBT); return newInv; @@ -128,14 +130,14 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide } @Override - public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) { ItemStack heldItem = player.getMainHandItem(); return LinkedControllerContainer.create(id, inv, heldItem); } @Override - public ITextComponent getDisplayName() { - return new TranslationTextComponent(getDescriptionId()); + public Component getDisplayName() { + return new TranslatableComponent(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 6ce89cff4..199ce19b7 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.logistics.item; import java.util.Vector; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.content.logistics.item.LinkedControllerClientHandler.Mode; import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer; @@ -13,13 +13,13 @@ import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.item.ItemStack; -import net.minecraft.util.HandSide; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.util.Mth; public class LinkedControllerItemRenderer extends CustomRenderedItemModelRenderer { @@ -62,25 +62,25 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere @Override protected void render(ItemStack stack, LinkedControllerModel model, PartialItemModelRenderer renderer, - ItemCameraTransforms.TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, + ItemTransforms.TransformType transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { renderNormal(stack, model, renderer, transformType, ms, light); } protected static void renderNormal(ItemStack stack, LinkedControllerModel model, - PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, MatrixStack ms, + PartialItemModelRenderer renderer, ItemTransforms.TransformType transformType, PoseStack ms, int light) { render(stack, model, renderer, transformType, ms, light, RenderType.NORMAL, false, false); } public static void renderInLectern(ItemStack stack, LinkedControllerModel model, - PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, MatrixStack ms, + PartialItemModelRenderer renderer, ItemTransforms.TransformType transformType, PoseStack ms, int light, boolean active, boolean renderDepression) { render(stack, model, renderer, transformType, ms, light, RenderType.LECTERN, active, renderDepression); } protected static void render(ItemStack stack, LinkedControllerModel model, - PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, MatrixStack ms, + PartialItemModelRenderer renderer, ItemTransforms.TransformType transformType, PoseStack ms, int light, RenderType renderType, boolean active, boolean renderDepression) { float pt = AnimationTickHolder.getPartialTicks(); MatrixTransformStack msr = MatrixTransformStack.of(ms); @@ -89,7 +89,7 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere if (renderType == RenderType.NORMAL) { Minecraft mc = Minecraft.getInstance(); - boolean rightHanded = mc.options.mainHand == HandSide.RIGHT; + boolean rightHanded = mc.options.mainHand == HumanoidArm.RIGHT; TransformType mainHand = rightHanded ? TransformType.FIRST_PERSON_RIGHT_HAND : TransformType.FIRST_PERSON_LEFT_HAND; TransformType offHand = @@ -126,14 +126,14 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere return; } - IBakedModel button = model.getPartial("button"); + BakedModel button = model.getPartial("button"); float s = 1 / 16f; float b = s * -.75f; int index = 0; if (renderType == RenderType.NORMAL) { if (LinkedControllerClientHandler.MODE == Mode.BIND) { - int i = (int) MathHelper.lerp((MathHelper.sin(AnimationTickHolder.getRenderTime() / 4f) + 1) / 2, 5, 15); + int i = (int) Mth.lerp((Mth.sin(AnimationTickHolder.getRenderTime() / 4f) + 1) / 2, 5, 15); light = i << 20; } } @@ -157,7 +157,7 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere ms.popPose(); } - protected static void renderButton(PartialItemModelRenderer renderer, MatrixStack ms, int light, float pt, IBakedModel button, + protected static void renderButton(PartialItemModelRenderer renderer, PoseStack ms, int light, float pt, BakedModel button, float b, int index, boolean renderDepression) { ms.pushPose(); if (renderDepression) { @@ -169,7 +169,7 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere } @Override - public LinkedControllerModel createModel(IBakedModel originalModel) { + public LinkedControllerModel createModel(BakedModel originalModel) { return new LinkedControllerModel(originalModel); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java index 347940f8a..7b3784d6e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java @@ -2,11 +2,11 @@ package com.simibubi.create.content.logistics.item; import com.simibubi.create.foundation.item.render.CreateCustomRenderedItemModel; -import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.resources.model.BakedModel; public class LinkedControllerModel extends CreateCustomRenderedItemModel { - public LinkedControllerModel(IBakedModel template) { + public LinkedControllerModel(BakedModel template) { super(template, "linked_controller"); addPartials("powered", "button"); } 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 d6c391e69..d0c57da32 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 @@ -5,11 +5,11 @@ import java.util.function.Supplier; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; import net.minecraftforge.fml.network.NetworkEvent.Context; public abstract class LinkedControllerPacketBase extends SimplePacketBase { @@ -20,7 +20,7 @@ public abstract class LinkedControllerPacketBase extends SimplePacketBase { this.lecternPos = lecternPos; } - public LinkedControllerPacketBase(PacketBuffer buffer) { + public LinkedControllerPacketBase(FriendlyByteBuf buffer) { if (buffer.readBoolean()) { lecternPos = new BlockPos(buffer.readInt(), buffer.readInt(), buffer.readInt()); } @@ -31,7 +31,7 @@ public abstract class LinkedControllerPacketBase extends SimplePacketBase { } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBoolean(inLectern()); if (inLectern()) { buffer.writeInt(lecternPos.getX()); @@ -43,12 +43,12 @@ public abstract class LinkedControllerPacketBase extends SimplePacketBase { @Override public void handle(Supplier context) { context.get().enqueueWork(() -> { - ServerPlayerEntity player = context.get().getSender(); + ServerPlayer player = context.get().getSender(); if (player == null) return; if (inLectern()) { - TileEntity te = player.level.getBlockEntity(lecternPos); + BlockEntity te = player.level.getBlockEntity(lecternPos); if (!(te instanceof LecternControllerTileEntity)) return; handleLectern(player, (LecternControllerTileEntity) te); @@ -66,7 +66,7 @@ public abstract class LinkedControllerPacketBase extends SimplePacketBase { context.get().setPacketHandled(true); } - protected abstract void handleItem(ServerPlayerEntity player, ItemStack heldItem); - protected abstract void handleLectern(ServerPlayerEntity player, LecternControllerTileEntity lectern); + protected abstract void handleItem(ServerPlayer player, ItemStack heldItem); + protected abstract void handleLectern(ServerPlayer player, LecternControllerTileEntity lectern); } 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 8c95a94d1..033c6de5f 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 @@ -7,7 +7,7 @@ import java.util.LinkedList; import java.util.List; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.AllIcons; @@ -15,21 +15,21 @@ import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; public class LinkedControllerScreen extends AbstractSimiContainerScreen { protected AllGuiTextures background; - private List extraAreas = Collections.emptyList(); + private List extraAreas = Collections.emptyList(); private IconButton resetButton; private IconButton confirmButton; - public LinkedControllerScreen(LinkedControllerContainer container, PlayerInventory inv, ITextComponent title) { + public LinkedControllerScreen(LinkedControllerContainer container, Inventory inv, Component title) { super(container, inv, title); this.background = AllGuiTextures.LINKED_CONTROLLER; } @@ -51,12 +51,12 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen getTooltipFromItem(ItemStack stack) { - List list = super.getTooltipFromItem(stack); + public List getTooltipFromItem(ItemStack stack) { + List list = super.getTooltipFromItem(stack); if (hoveredSlot.container == menu.playerInventory) return list; return hoveredSlot != null ? addToTooltip(list, hoveredSlot.getSlotIndex()) : list; } - private List addToTooltip(List list, int slot) { + private List addToTooltip(List list, int slot) { if (slot < 0 || slot >= 12) return list; list.add(Lang @@ -128,12 +128,12 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen getExtraAreas() { + public List getExtraAreas() { return extraAreas; } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerServerHandler.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerServerHandler.java index 3ec2b3209..0f0ece673 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerServerHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerServerHandler.java @@ -18,8 +18,8 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.WorldAttached; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; public class LinkedControllerServerHandler { @@ -27,7 +27,7 @@ public class LinkedControllerServerHandler { new WorldAttached<>($ -> new HashMap<>()); static final int TIMEOUT = 30; - public static void tick(IWorld world) { + public static void tick(LevelAccessor world) { Map> map = receivedInputs.get(world); for (Iterator>> iterator = map.entrySet() .iterator(); iterator.hasNext();) { @@ -49,7 +49,7 @@ public class LinkedControllerServerHandler { } } - public static void receivePressed(IWorld world, BlockPos pos, UUID uniqueID, List> collect, + public static void receivePressed(LevelAccessor world, BlockPos pos, UUID uniqueID, List> collect, boolean pressed) { Map> map = receivedInputs.get(world); Collection list = map.computeIfAbsent(uniqueID, $ -> new ArrayList<>()); diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerStopLecternPacket.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerStopLecternPacket.java index 50ab091f6..95b004a8f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerStopLecternPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerStopLecternPacket.java @@ -1,13 +1,13 @@ package com.simibubi.create.content.logistics.item; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; public class LinkedControllerStopLecternPacket extends LinkedControllerPacketBase { - public LinkedControllerStopLecternPacket(PacketBuffer buffer) { + public LinkedControllerStopLecternPacket(FriendlyByteBuf buffer) { super(buffer); } @@ -16,11 +16,11 @@ public class LinkedControllerStopLecternPacket extends LinkedControllerPacketBas } @Override - protected void handleLectern(ServerPlayerEntity player, LecternControllerTileEntity lectern) { + protected void handleLectern(ServerPlayer player, LecternControllerTileEntity lectern) { lectern.tryStopUsing(player); } @Override - protected void handleItem(ServerPlayerEntity player, ItemStack heldItem) { } + protected void handleItem(ServerPlayer player, ItemStack heldItem) { } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java index 68193c4ef..5db02df98 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java @@ -2,27 +2,27 @@ package com.simibubi.create.content.logistics.item.filter; import com.simibubi.create.foundation.gui.GhostItemContainer; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ClickType; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public abstract class AbstractFilterContainer extends GhostItemContainer { - protected AbstractFilterContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + protected AbstractFilterContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { super(type, id, inv, extraData); } - protected AbstractFilterContainer(ContainerType type, int id, PlayerInventory inv, ItemStack contentHolder) { + protected AbstractFilterContainer(MenuType type, int id, Inventory inv, ItemStack contentHolder) { super(type, id, inv, contentHolder); } @Override - public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { + public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) { if (slotId == playerInventory.selected && clickTypeIn != ClickType.THROW) return ItemStack.EMPTY; return super.clicked(slotId, dragType, clickTypeIn, player); @@ -35,7 +35,7 @@ public abstract class AbstractFilterContainer extends GhostItemContainer extends AbstractSimiContainerScreen { protected AllGuiTextures background; - private List extraAreas = Collections.emptyList(); + private List extraAreas = Collections.emptyList(); private IconButton resetButton; private IconButton confirmButton; - protected AbstractFilterScreen(F container, PlayerInventory inv, ITextComponent title, AllGuiTextures background) { + protected AbstractFilterScreen(F container, Inventory inv, Component title, AllGuiTextures background) { super(container, inv, title); this.background = background; } @@ -55,12 +55,12 @@ public abstract class AbstractFilterScreen ex widgets.add(confirmButton); extraAreas = ImmutableList.of( - new Rectangle2d(x + background.width, y + background.height - 40, 80, 48) + new Rect2i(x + background.width, y + background.height - 40, 80, 48) ); } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int invX = getLeftOfCentered(PLAYER_INVENTORY.width); int invY = topPos + background.height + 4; renderPlayerInventory(ms, invX, invY); @@ -92,7 +92,7 @@ public abstract class AbstractFilterScreen ex List tooltipButtons = getTooltipButtons(); for (IconButton button : tooltipButtons) button.active = isButtonEnabled(button); - for (Widget w : widgets) + for (AbstractWidget w : widgets) if (w instanceof Indicator) ((Indicator) w).state = isIndicatorOn((Indicator) w) ? State.ON : State.OFF; } @@ -115,7 +115,7 @@ public abstract class AbstractFilterScreen ex } if (hasShiftDown()) { - List tooltipDescriptions = getTooltipDescriptions(); + List tooltipDescriptions = getTooltipDescriptions(); for (int i = 0; i < tooltipButtons.size(); i++) fillToolTip(tooltipButtons.get(i), tooltipDescriptions.get(i)); } @@ -125,14 +125,14 @@ public abstract class AbstractFilterScreen ex return Collections.emptyList(); } - protected List getTooltipDescriptions() { + protected List getTooltipDescriptions() { return Collections.emptyList(); } - private void fillToolTip(IconButton button, ITextComponent tooltip) { + private void fillToolTip(IconButton button, Component tooltip) { if (!button.isHovered()) return; - List tip = button.getToolTip(); + List tip = button.getToolTip(); tip.addAll(TooltipHelper.cutTextComponent(tooltip, GRAY, GRAY)); } @@ -163,7 +163,7 @@ public abstract class AbstractFilterScreen ex } @Override - public List getExtraAreas() { + public List getExtraAreas() { return extraAreas; } 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 3902a50a9..2710bf206 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 @@ -6,18 +6,18 @@ import java.util.List; import com.simibubi.create.AllContainerTypes; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ClickType; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.SlotItemHandler; @@ -31,15 +31,15 @@ public class AttributeFilterContainer extends AbstractFilterContainer { WhitelistMode whitelistMode; List> selectedAttributes; - public AttributeFilterContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + public AttributeFilterContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { super(type, id, inv, extraData); } - public AttributeFilterContainer(ContainerType type, int id, PlayerInventory inv, ItemStack stack) { + public AttributeFilterContainer(MenuType type, int id, Inventory inv, ItemStack stack) { super(type, id, inv, stack); } - public static AttributeFilterContainer create(int id, PlayerInventory inv, ItemStack stack) { + public static AttributeFilterContainer create(int id, Inventory inv, ItemStack stack) { return new AttributeFilterContainer(AllContainerTypes.ATTRIBUTE_FILTER.get(), id, inv, stack); } @@ -48,11 +48,11 @@ public class AttributeFilterContainer extends AbstractFilterContainer { } @Override - protected void init(PlayerInventory inv, ItemStack contentHolder) { + protected void init(Inventory inv, ItemStack contentHolder) { super.init(inv, contentHolder); ItemStack stack = new ItemStack(Items.NAME_TAG); stack.setHoverName( - new StringTextComponent("Selected Tags").withStyle(TextFormatting.RESET, TextFormatting.BLUE)); + new TextComponent("Selected Tags").withStyle(ChatFormatting.RESET, ChatFormatting.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 mayPickup(PlayerEntity playerIn) { + public boolean mayPickup(Player playerIn) { return false; } }); @@ -88,7 +88,7 @@ public class AttributeFilterContainer extends AbstractFilterContainer { } @Override - public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { + public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) { if (slotId == 37) return ItemStack.EMPTY; return super.clicked(slotId, dragType, clickTypeIn, player); @@ -109,7 +109,7 @@ public class AttributeFilterContainer extends AbstractFilterContainer { } @Override - public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(Player playerIn, int index) { if (index == 37) return ItemStack.EMPTY; if (index == 36) { @@ -131,10 +131,10 @@ public class AttributeFilterContainer extends AbstractFilterContainer { selectedAttributes = new ArrayList<>(); whitelistMode = WhitelistMode.values()[filterItem.getOrCreateTag() .getInt("WhitelistMode")]; - ListNBT attributes = filterItem.getOrCreateTag() + ListTag attributes = filterItem.getOrCreateTag() .getList("MatchedAttributes", NBT.TAG_COMPOUND); attributes.forEach(inbt -> { - CompoundNBT compound = (CompoundNBT) inbt; + CompoundTag compound = (CompoundTag) inbt; selectedAttributes.add(Pair.of(ItemAttribute.fromNBT(compound), compound.getBoolean("Inverted"))); }); } @@ -144,11 +144,11 @@ public class AttributeFilterContainer extends AbstractFilterContainer { super.saveData(filterItem); filterItem.getOrCreateTag() .putInt("WhitelistMode", whitelistMode.ordinal()); - ListNBT attributes = new ListNBT(); + ListTag attributes = new ListTag(); selectedAttributes.forEach(at -> { if (at == null) return; - CompoundNBT compoundNBT = new CompoundNBT(); + CompoundTag compoundNBT = new CompoundTag(); at.getFirst() .serializeNBT(compoundNBT); compoundNBT.putBoolean("Inverted", at.getSecond()); 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 33ed69d69..443eeece8 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 @@ -5,7 +5,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer.WhitelistMode; import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket.Option; import com.simibubi.create.foundation.gui.AllGuiTextures; @@ -18,13 +18,13 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; public class AttributeFilterScreen extends AbstractFilterScreen { @@ -35,27 +35,27 @@ public class AttributeFilterScreen extends AbstractFilterScreen attributesOfItem = new ArrayList<>(); - private List selectedAttributes = new ArrayList<>(); + private List selectedAttributes = new ArrayList<>(); private SelectionScrollInput attributeSelector; private Label attributeSelectorLabel; - public AttributeFilterScreen(AttributeFilterContainer container, PlayerInventory inv, ITextComponent title) { + public AttributeFilterScreen(AttributeFilterContainer container, Inventory inv, Component title) { super(container, inv, title, AllGuiTextures.ATTRIBUTE_FILTER); } @@ -74,9 +74,9 @@ public class AttributeFilterScreen extends AbstractFilterScreen selectedAttributes.add(new StringTextComponent("- ") + .withStyle(ChatFormatting.YELLOW)); + menu.selectedAttributes.forEach(at -> selectedAttributes.add(new TextComponent("- ") .append(at.getFirst() .format(at.getSecond())) - .withStyle(TextFormatting.GRAY))); + .withStyle(ChatFormatting.GRAY))); } private void referenceItemChanged(ItemStack stack) { @@ -114,7 +114,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen { @@ -131,7 +131,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen options = attributesOfItem.stream() + List options = attributesOfItem.stream() .map(a -> a.format(false)) .collect(Collectors.toList()); attributeSelector.forOptions(options); @@ -142,8 +142,8 @@ public class AttributeFilterScreen extends AbstractFilterScreen existing : menu.selectedAttributes) { - CompoundNBT testTag = new CompoundNBT(); - CompoundNBT testTag2 = new CompoundNBT(); + CompoundTag testTag = new CompoundTag(); + CompoundTag testTag2 = new CompoundTag(); existing.getFirst() .serializeNBT(testTag); selected.serializeNBT(testTag2); @@ -160,7 +160,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen getTooltipDescriptions() { + protected List getTooltipDescriptions() { return Arrays.asList(denyDESC.plainCopy(), allowConDESC.plainCopy(), allowDisDESC.plainCopy()); } @@ -245,7 +245,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen type, int id, PlayerInventory inv, PacketBuffer extraData) { + public FilterContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { super(type, id, inv, extraData); } - public FilterContainer(ContainerType type, int id, PlayerInventory inv, ItemStack stack) { + public FilterContainer(MenuType type, int id, Inventory inv, ItemStack stack) { super(type, id, inv, stack); } - public static FilterContainer create(int id, PlayerInventory inv, ItemStack stack) { + public static FilterContainer create(int id, Inventory inv, ItemStack stack) { return new FilterContainer(AllContainerTypes.FILTER.get(), id, inv, stack); } @@ -54,7 +54,7 @@ public class FilterContainer extends AbstractFilterContainer { @Override protected void initAndReadInventory(ItemStack filterItem) { super.initAndReadInventory(filterItem); - CompoundNBT tag = filterItem.getOrCreateTag(); + CompoundTag tag = filterItem.getOrCreateTag(); respectNBT = tag.getBoolean("RespectNBT"); blacklist = tag.getBoolean("Blacklist"); } @@ -62,7 +62,7 @@ public class FilterContainer extends AbstractFilterContainer { @Override protected void saveData(ItemStack filterItem) { super.saveData(filterItem); - CompoundNBT tag = filterItem.getOrCreateTag(); + CompoundTag tag = filterItem.getOrCreateTag(); tag.putBoolean("RespectNBT", respectNBT); tag.putBoolean("Blacklist", blacklist); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java index b971d7cda..2bbcae921 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java @@ -13,26 +13,26 @@ import com.simibubi.create.content.logistics.item.filter.AttributeFilterContaine import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.Constants.NBT; @@ -41,7 +41,9 @@ import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; -public class FilterItem extends Item implements INamedContainerProvider { +import net.minecraft.world.item.Item.Properties; + +public class FilterItem extends Item implements MenuProvider { private FilterType type; @@ -64,44 +66,44 @@ public class FilterItem extends Item implements INamedContainerProvider { @Nonnull @Override - public ActionResultType useOn(ItemUseContext context) { + public InteractionResult useOn(UseOnContext context) { if (context.getPlayer() == null) - return ActionResultType.PASS; + return InteractionResult.PASS; return use(context.getLevel(), context.getPlayer(), context.getHand()).getResult(); } @Override @OnlyIn(Dist.CLIENT) - public void appendHoverText(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + public void appendHoverText(ItemStack stack, Level worldIn, List tooltip, TooltipFlag flagIn) { if (!AllKeys.shiftDown()) { - List makeSummary = makeSummary(stack); + List makeSummary = makeSummary(stack); if (makeSummary.isEmpty()) return; - ItemDescription.add(tooltip, new StringTextComponent(" ")); + ItemDescription.add(tooltip, new TextComponent(" ")); ItemDescription.add(tooltip, makeSummary); } } - private List makeSummary(ItemStack filter) { - List list = new ArrayList<>(); + private List makeSummary(ItemStack filter) { + List list = new ArrayList<>(); if (type == FilterType.REGULAR) { ItemStackHandler filterItems = getFilterItems(filter); boolean blacklist = filter.getOrCreateTag() .getBoolean("Blacklist"); - list.add((blacklist ? Lang.translate("gui.filter.deny_list") : Lang.translate("gui.filter.allow_list")).withStyle(TextFormatting.GOLD)); + list.add((blacklist ? Lang.translate("gui.filter.deny_list") : Lang.translate("gui.filter.allow_list")).withStyle(ChatFormatting.GOLD)); int count = 0; for (int i = 0; i < filterItems.getSlots(); i++) { if (count > 3) { - list.add(new StringTextComponent("- ...").withStyle(TextFormatting.DARK_GRAY)); + list.add(new TextComponent("- ...").withStyle(ChatFormatting.DARK_GRAY)); break; } ItemStack filterStack = filterItems.getStackInSlot(i); if (filterStack.isEmpty()) continue; - list.add(new StringTextComponent("- ").append(filterStack.getHoverName()).withStyle(TextFormatting.GRAY)); + list.add(new TextComponent("- ").append(filterStack.getHoverName()).withStyle(ChatFormatting.GRAY)); count++; } @@ -116,20 +118,20 @@ 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")).withStyle(TextFormatting.GOLD)); + : Lang.translate("gui.attribute_filter.deny_list")).withStyle(ChatFormatting.GOLD)); int count = 0; - ListNBT attributes = filter.getOrCreateTag() + ListTag attributes = filter.getOrCreateTag() .getList("MatchedAttributes", NBT.TAG_COMPOUND); - for (INBT inbt : attributes) { - CompoundNBT compound = (CompoundNBT) inbt; + for (Tag inbt : attributes) { + CompoundTag compound = (CompoundTag) inbt; ItemAttribute attribute = ItemAttribute.fromNBT(compound); boolean inverted = compound.getBoolean("Inverted"); if (count > 3) { - list.add(new StringTextComponent("- ...").withStyle(TextFormatting.DARK_GRAY)); + list.add(new TextComponent("- ...").withStyle(ChatFormatting.DARK_GRAY)); break; } - list.add(new StringTextComponent("- ").append(attribute.format(inverted))); + list.add(new TextComponent("- ").append(attribute.format(inverted))); count++; } @@ -141,21 +143,21 @@ public class FilterItem extends Item implements INamedContainerProvider { } @Override - public ActionResult use(World world, PlayerEntity player, Hand hand) { + public InteractionResultHolder use(Level world, Player player, InteractionHand hand) { ItemStack heldItem = player.getItemInHand(hand); - if (!player.isShiftKeyDown() && hand == Hand.MAIN_HAND) { - if (!world.isClientSide && player instanceof ServerPlayerEntity) - NetworkHooks.openGui((ServerPlayerEntity) player, this, buf -> { + if (!player.isShiftKeyDown() && hand == InteractionHand.MAIN_HAND) { + if (!world.isClientSide && player instanceof ServerPlayer) + NetworkHooks.openGui((ServerPlayer) player, this, buf -> { buf.writeItem(heldItem); }); - return ActionResult.success(heldItem); + return InteractionResultHolder.success(heldItem); } - return ActionResult.pass(heldItem); + return InteractionResultHolder.pass(heldItem); } @Override - public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) { ItemStack heldItem = player.getMainHandItem(); if (type == FilterType.REGULAR) return FilterContainer.create(id, inv, heldItem); @@ -165,29 +167,29 @@ public class FilterItem extends Item implements INamedContainerProvider { } @Override - public ITextComponent getDisplayName() { - return new TranslationTextComponent(getDescriptionId()); + public Component getDisplayName() { + return new TranslatableComponent(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.getOrCreateTagElement("Items"); + CompoundTag invNBT = stack.getOrCreateTagElement("Items"); if (!invNBT.isEmpty()) newInv.deserializeNBT(invNBT); return newInv; } - public static boolean test(World world, ItemStack stack, ItemStack filter) { + public static boolean test(Level world, ItemStack stack, ItemStack filter) { return test(world, stack, filter, false); } - public static boolean test(World world, FluidStack stack, ItemStack filter) { + public static boolean test(Level world, FluidStack stack, ItemStack filter) { return test(world, stack, filter, true); } - private static boolean test(World world, ItemStack stack, ItemStack filter, boolean matchNBT) { + private static boolean test(Level world, ItemStack stack, ItemStack filter, boolean matchNBT) { if (filter.isEmpty()) return true; @@ -215,10 +217,10 @@ public class FilterItem extends Item implements INamedContainerProvider { if (AllItems.ATTRIBUTE_FILTER.get() == filter.getItem()) { WhitelistMode whitelistMode = WhitelistMode.values()[filter.getOrCreateTag() .getInt("WhitelistMode")]; - ListNBT attributes = filter.getOrCreateTag() + ListTag attributes = filter.getOrCreateTag() .getList("MatchedAttributes", NBT.TAG_COMPOUND); - for (INBT inbt : attributes) { - CompoundNBT compound = (CompoundNBT) inbt; + for (Tag inbt : attributes) { + CompoundTag compound = (CompoundTag) inbt; ItemAttribute attribute = ItemAttribute.fromNBT(compound); if (attribute == null) continue; @@ -258,7 +260,7 @@ public class FilterItem extends Item implements INamedContainerProvider { return false; } - private static boolean test(World world, FluidStack stack, ItemStack filter, boolean matchNBT) { + private static boolean test(Level world, FluidStack stack, ItemStack filter, boolean matchNBT) { if (filter.isEmpty()) return true; if (stack.isEmpty()) 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 579c8d711..5872cb461 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 @@ -10,31 +10,31 @@ import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.gui.widgets.Indicator; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class FilterScreen extends AbstractFilterScreen { private static final String PREFIX = "gui.filter."; - private ITextComponent allowN = Lang.translate(PREFIX + "allow_list"); - private ITextComponent allowDESC = Lang.translate(PREFIX + "allow_list.description"); - private ITextComponent denyN = Lang.translate(PREFIX + "deny_list"); - private ITextComponent denyDESC = Lang.translate(PREFIX + "deny_list.description"); + private Component allowN = Lang.translate(PREFIX + "allow_list"); + private Component allowDESC = Lang.translate(PREFIX + "allow_list.description"); + private Component denyN = Lang.translate(PREFIX + "deny_list"); + private Component denyDESC = Lang.translate(PREFIX + "deny_list.description"); - private ITextComponent respectDataN = Lang.translate(PREFIX + "respect_data"); - private ITextComponent respectDataDESC = Lang.translate(PREFIX + "respect_data.description"); - private ITextComponent ignoreDataN = Lang.translate(PREFIX + "ignore_data"); - private ITextComponent ignoreDataDESC = Lang.translate(PREFIX + "ignore_data.description"); + private Component respectDataN = Lang.translate(PREFIX + "respect_data"); + private Component respectDataDESC = Lang.translate(PREFIX + "respect_data.description"); + private Component ignoreDataN = Lang.translate(PREFIX + "ignore_data"); + private Component ignoreDataDESC = Lang.translate(PREFIX + "ignore_data.description"); private IconButton whitelist, blacklist; private IconButton respectNBT, ignoreNBT; private Indicator whitelistIndicator, blacklistIndicator; private Indicator respectNBTIndicator, ignoreNBTIndicator; - public FilterScreen(FilterContainer container, PlayerInventory inv, ITextComponent title) { + public FilterScreen(FilterContainer container, Inventory inv, Component title) { super(container, inv, title, AllGuiTextures.FILTER); } @@ -50,16 +50,16 @@ public class FilterScreen extends AbstractFilterScreen { blacklist.setToolTip(denyN); whitelist = new IconButton(x + 36, y + 73, AllIcons.I_WHITELIST); whitelist.setToolTip(allowN); - blacklistIndicator = new Indicator(x + 18, y + 67, StringTextComponent.EMPTY); - whitelistIndicator = new Indicator(x + 36, y + 67, StringTextComponent.EMPTY); + blacklistIndicator = new Indicator(x + 18, y + 67, TextComponent.EMPTY); + whitelistIndicator = new Indicator(x + 36, y + 67, TextComponent.EMPTY); widgets.addAll(Arrays.asList(blacklist, whitelist, blacklistIndicator, whitelistIndicator)); respectNBT = new IconButton(x + 60, y + 73, AllIcons.I_RESPECT_NBT); respectNBT.setToolTip(respectDataN); ignoreNBT = new IconButton(x + 78, y + 73, AllIcons.I_IGNORE_NBT); ignoreNBT.setToolTip(ignoreDataN); - respectNBTIndicator = new Indicator(x + 60, y + 67, StringTextComponent.EMPTY); - ignoreNBTIndicator = new Indicator(x + 78, y + 67, StringTextComponent.EMPTY); + respectNBTIndicator = new Indicator(x + 60, y + 67, TextComponent.EMPTY); + ignoreNBTIndicator = new Indicator(x + 78, y + 67, TextComponent.EMPTY); widgets.addAll(Arrays.asList(respectNBT, ignoreNBT, respectNBTIndicator, ignoreNBTIndicator)); handleIndicators(); @@ -105,7 +105,7 @@ public class FilterScreen extends AbstractFilterScreen { } @Override - protected List getTooltipDescriptions() { + protected List getTooltipDescriptions() { return Arrays.asList(denyDESC.plainCopy(), allowDESC.plainCopy(), respectDataDESC.plainCopy(), ignoreDataDESC.plainCopy()); } 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 a1e50375a..1e7fefcff 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 @@ -5,9 +5,9 @@ import java.util.function.Supplier; import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer.WhitelistMode; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.network.NetworkEvent.Context; public class FilterScreenPacket extends SimplePacketBase { @@ -17,24 +17,24 @@ public class FilterScreenPacket extends SimplePacketBase { } private final Option option; - private final CompoundNBT data; + private final CompoundTag data; public FilterScreenPacket(Option option) { - this(option, new CompoundNBT()); + this(option, new CompoundTag()); } - public FilterScreenPacket(Option option, CompoundNBT data) { + public FilterScreenPacket(Option option, CompoundTag data) { this.option = option; this.data = data; } - public FilterScreenPacket(PacketBuffer buffer) { + public FilterScreenPacket(FriendlyByteBuf buffer) { option = Option.values()[buffer.readInt()]; data = buffer.readNbt(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(option.ordinal()); buffer.writeNbt(data); } @@ -42,7 +42,7 @@ public class FilterScreenPacket extends SimplePacketBase { @Override public void handle(Supplier context) { context.get().enqueueWork(() -> { - ServerPlayerEntity player = context.get().getSender(); + ServerPlayer player = context.get().getSender(); if (player == null) return; @@ -59,7 +59,7 @@ public class FilterScreenPacket extends SimplePacketBase { if (option == Option.UPDATE_FILTER_ITEM) c.ghostInventory.setStackInSlot( data.getInt("Slot"), - net.minecraft.item.ItemStack.of(data.getCompound("Item"))); + net.minecraft.world.item.ItemStack.of(data.getCompound("Item"))); } if (player.containerMenu instanceof AttributeFilterContainer) { 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 82d2be736..cb342b00f 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 @@ -26,19 +26,19 @@ import com.simibubi.create.content.logistics.item.filter.attribute.astralsorcery import com.simibubi.create.content.logistics.item.filter.attribute.astralsorcery.AstralSorceryPerkGemAttribute; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.AbstractFurnaceTileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.Container; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -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.TAB_MISC)); + static ItemAttribute inItemGroup = register(new InItemGroup(CreativeModeTab.TAB_MISC)); static ItemAttribute addedBy = register(new InItemGroup.AddedBy("dummy")); static ItemAttribute hasEnchant = register(EnchantAttribute.EMPTY); static ItemAttribute shulkerFillLevel = register(ShulkerFillLevelAttribute.EMPTY); @@ -73,13 +73,13 @@ public interface ItemAttribute { return attributeType; } - default boolean appliesTo(ItemStack stack, World world) { + default boolean appliesTo(ItemStack stack, Level world) { return appliesTo(stack); } boolean appliesTo(ItemStack stack); - default List listAttributesOf(ItemStack stack, World world) { + default List listAttributesOf(ItemStack stack, Level world) { return listAttributesOf(stack); } @@ -87,17 +87,17 @@ public interface ItemAttribute { public String getTranslationKey(); - void writeNBT(CompoundNBT nbt); + void writeNBT(CompoundTag nbt); - ItemAttribute readNBT(CompoundNBT nbt); + ItemAttribute readNBT(CompoundTag nbt); - public default void serializeNBT(CompoundNBT nbt) { - CompoundNBT compound = new CompoundNBT(); + public default void serializeNBT(CompoundTag nbt) { + CompoundTag compound = new CompoundTag(); writeNBT(compound); nbt.put(getNBTKey(), compound); } - public static ItemAttribute fromNBT(CompoundNBT nbt) { + public static ItemAttribute fromNBT(CompoundTag nbt) { for (ItemAttribute itemAttribute : types) { if (!itemAttribute.canRead(nbt)) continue; @@ -110,7 +110,7 @@ public interface ItemAttribute { return new String[0]; } - default boolean canRead(CompoundNBT nbt) { + default boolean canRead(CompoundTag nbt) { return nbt.contains(getNBTKey()); } @@ -119,7 +119,7 @@ public interface ItemAttribute { } @OnlyIn(value = Dist.CLIENT) - default TranslationTextComponent format(boolean inverted) { + default TranslatableComponent format(boolean inverted) { return Lang.translate("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""), getTranslationParameters()); } @@ -137,23 +137,23 @@ public interface ItemAttribute { BADLY_DAMAGED(s -> s.isDamaged() && s.getDamageValue() / s.getMaxDamage() > 3 / 4f), NOT_STACKABLE(((Predicate) ItemStack::isStackable).negate()), EQUIPABLE(s -> s.getEquipmentSlot() != null), - FURNACE_FUEL(AbstractFurnaceTileEntity::isFuel), + FURNACE_FUEL(AbstractFurnaceBlockEntity::isFuel), WASHABLE(InWorldProcessing::isWashable), CRUSHABLE((s, w) -> testRecipe(s, w, AllRecipeTypes.CRUSHING.getType()) || testRecipe(s, w, AllRecipeTypes.MILLING.getType())), - SMELTABLE((s, w) -> testRecipe(s, w, IRecipeType.SMELTING)), - SMOKABLE((s, w) -> testRecipe(s, w, IRecipeType.SMOKING)), - BLASTABLE((s, w) -> testRecipe(s, w, IRecipeType.BLASTING)); + SMELTABLE((s, w) -> testRecipe(s, w, RecipeType.SMELTING)), + SMOKABLE((s, w) -> testRecipe(s, w, RecipeType.SMOKING)), + BLASTABLE((s, w) -> testRecipe(s, w, RecipeType.BLASTING)); private static final RecipeWrapper RECIPE_WRAPPER = new RecipeWrapper(new ItemStackHandler(1)); private Predicate test; - private BiPredicate testWithWorld; + private BiPredicate testWithWorld; private StandardTraits(Predicate test) { this.test = test; } - private static boolean testRecipe(ItemStack s, World w, IRecipeType> type) { + private static boolean testRecipe(ItemStack s, Level w, RecipeType> type) { RECIPE_WRAPPER.setItem(0, s.copy()); return w.getRecipeManager() .getRecipeFor(type, RECIPE_WRAPPER, w) @@ -167,12 +167,12 @@ public interface ItemAttribute { .anyMatch(e -> e.getKey().getMaxLevel() <= e.getValue()); } - private StandardTraits(BiPredicate test) { + private StandardTraits(BiPredicate test) { this.testWithWorld = test; } @Override - public boolean appliesTo(ItemStack stack, World world) { + public boolean appliesTo(ItemStack stack, Level world) { if (testWithWorld != null) return testWithWorld.test(stack, world); return appliesTo(stack); @@ -184,7 +184,7 @@ public interface ItemAttribute { } @Override - public List listAttributesOf(ItemStack stack, World world) { + public List listAttributesOf(ItemStack stack, Level world) { List attributes = new ArrayList<>(); for (StandardTraits trait : values()) if (trait.appliesTo(stack, world)) @@ -208,12 +208,12 @@ public interface ItemAttribute { } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putBoolean(name(), true); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { for (StandardTraits trait : values()) if (nbt.contains(trait.name())) return trait; @@ -257,13 +257,13 @@ public interface ItemAttribute { } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putString("space", tagName.getNamespace()); nbt.putString("path", tagName.getPath()); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return new InTag(new ResourceLocation(nbt.getString("space"), nbt.getString("path"))); } @@ -271,9 +271,9 @@ public interface ItemAttribute { public static class InItemGroup implements ItemAttribute { - private ItemGroup group; + private CreativeModeTab group; - public InItemGroup(ItemGroup group) { + public InItemGroup(CreativeModeTab group) { this.group = group; } @@ -285,7 +285,7 @@ public interface ItemAttribute { @Override public List listAttributesOf(ItemStack stack) { - ItemGroup group = stack.getItem() + CreativeModeTab group = stack.getItem() .getItemCategory(); return group == null ? Collections.emptyList() : Arrays.asList(new InItemGroup(group)); } @@ -297,20 +297,20 @@ public interface ItemAttribute { @Override @OnlyIn(value = Dist.CLIENT) - public TranslationTextComponent format(boolean inverted) { + public TranslatableComponent format(boolean inverted) { return Lang.translate("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""), group.getDisplayName()); } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putString("path", group.getRecipeFolderName()); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { String readPath = nbt.getString("path"); - for (ItemGroup group : ItemGroup.TABS) + for (CreativeModeTab group : CreativeModeTab.TABS) if (group.getRecipeFolderName() .equals(readPath)) return new InItemGroup(group); @@ -356,12 +356,12 @@ public interface ItemAttribute { } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putString("id", modId); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return new AddedBy(nbt.getString("id")); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/BookAuthorAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/BookAuthorAttribute.java index 384afc68a..04332e928 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/BookAuthorAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/BookAuthorAttribute.java @@ -5,8 +5,8 @@ import java.util.List; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; public class BookAuthorAttribute implements ItemAttribute { String author; @@ -42,17 +42,17 @@ public class BookAuthorAttribute implements ItemAttribute { } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putString("author", this.author); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return new BookAuthorAttribute(nbt.getString("author")); } private String extractAuthor(ItemStack stack) { - CompoundNBT nbt = stack.getTag(); + CompoundTag nbt = stack.getTag(); if (nbt != null && nbt.contains("author")) { return nbt.getString("author"); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/BookCopyAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/BookCopyAttribute.java index 1688f3c29..aac39d37f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/BookCopyAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/BookCopyAttribute.java @@ -5,9 +5,9 @@ import java.util.List; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.item.ItemStack; -import net.minecraft.item.WrittenBookItem; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.WrittenBookItem; +import net.minecraft.nbt.CompoundTag; public class BookCopyAttribute implements ItemAttribute { int generation; @@ -47,17 +47,17 @@ public class BookCopyAttribute implements ItemAttribute { } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putInt("generation", this.generation); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return new BookCopyAttribute(nbt.getInt("generation")); } private int extractGeneration(ItemStack stack) { - CompoundNBT nbt = stack.getTag(); + CompoundTag nbt = stack.getTag(); if (nbt != null && stack.getItem() instanceof WrittenBookItem) { return nbt.getInt("generation"); } 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 354fe068c..17822e867 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 @@ -10,13 +10,13 @@ import java.util.stream.Collectors; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.item.DyeColor; -import net.minecraft.item.FireworkRocketItem; -import net.minecraft.item.FireworkStarItem; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.FireworkRocketItem; +import net.minecraft.world.item.FireworkStarItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.network.chat.TranslatableComponent; public class ColorAttribute implements ItemAttribute { public static final ColorAttribute EMPTY = new ColorAttribute(DyeColor.PURPLE); @@ -38,7 +38,7 @@ public class ColorAttribute implements ItemAttribute { } private Collection findMatchingDyeColors(ItemStack stack) { - CompoundNBT nbt = stack.getTag(); + CompoundTag nbt = stack.getTag(); DyeColor color = DyeColor.getColor(stack); if (color != null) @@ -46,7 +46,7 @@ public class ColorAttribute implements ItemAttribute { Set colors = new HashSet<>(); if (stack.getItem() instanceof FireworkRocketItem && nbt != null) { - ListNBT listnbt = nbt.getCompound("Fireworks").getList("Explosions", 10); + ListTag listnbt = nbt.getCompound("Fireworks").getList("Explosions", 10); for (int i = 0; i < listnbt.size(); i++) { colors.addAll(getFireworkStarColors(listnbt.getCompound(i))); } @@ -61,7 +61,7 @@ public class ColorAttribute implements ItemAttribute { return colors; } - private Collection getFireworkStarColors(CompoundNBT compound) { + private Collection getFireworkStarColors(CompoundTag compound) { Set colors = new HashSet<>(); Arrays.stream(compound.getIntArray("Colors")).mapToObj(DyeColor::byFireworkColor).forEach(colors::add); Arrays.stream(compound.getIntArray("FadeColors")).mapToObj(DyeColor::byFireworkColor).forEach(colors::add); @@ -75,16 +75,16 @@ public class ColorAttribute implements ItemAttribute { @Override public Object[] getTranslationParameters() { - return new Object[]{new TranslationTextComponent(color.getName()).getContents()}; + return new Object[]{new TranslatableComponent(color.getName()).getContents()}; } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putInt("id", color.getId()); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return nbt.contains("id") ? new ColorAttribute(DyeColor.byId(nbt.getInt("id"))) : EMPTY; 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 d23c806b9..e4ee70e12 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 @@ -7,12 +7,12 @@ import javax.annotation.Nullable; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.registries.ForgeRegistries; public class EnchantAttribute implements ItemAttribute { @@ -43,12 +43,12 @@ public class EnchantAttribute implements ItemAttribute { public Object[] getTranslationParameters() { String parameter = ""; if(enchantment != null) - parameter = new TranslationTextComponent(enchantment.getDescriptionId()).getString(); + parameter = new TranslatableComponent(enchantment.getDescriptionId()).getString(); return new Object[] { parameter }; } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { if (enchantment == null) return; ResourceLocation id = ForgeRegistries.ENCHANTMENTS.getKey(enchantment); @@ -58,7 +58,7 @@ public class EnchantAttribute implements ItemAttribute { } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { 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 dfe0ee944..fe7e8fc57 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 @@ -8,11 +8,11 @@ import javax.annotation.Nullable; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandlerItem; @@ -46,12 +46,12 @@ public class FluidContentsAttribute implements ItemAttribute { public Object[] getTranslationParameters() { String parameter = ""; if(fluid != null) - parameter = new TranslationTextComponent(fluid.getAttributes().getTranslationKey()).getString(); + parameter = new TranslatableComponent(fluid.getAttributes().getTranslationKey()).getString(); return new Object[] { parameter }; } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { if (fluid == null) return; ResourceLocation id = ForgeRegistries.FLUIDS.getKey(fluid); @@ -61,7 +61,7 @@ public class FluidContentsAttribute implements ItemAttribute { } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return nbt.contains("id") ? new FluidContentsAttribute(ForgeRegistries.FLUIDS.getValue(ResourceLocation.tryParse(nbt.getString("id")))) : EMPTY; } 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 ebe7c6024..b6faf97a7 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 @@ -6,9 +6,9 @@ import java.util.List; import com.google.gson.JsonParseException; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; public class ItemNameAttribute implements ItemAttribute { String itemName; @@ -44,20 +44,20 @@ public class ItemNameAttribute implements ItemAttribute { } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putString("name", this.itemName); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return new ItemNameAttribute(nbt.getString("name")); } private String extractCustomName(ItemStack stack) { - CompoundNBT compoundnbt = stack.getTagElement("display"); + CompoundTag compoundnbt = stack.getTagElement("display"); if (compoundnbt != null && compoundnbt.contains("Name", 8)) { try { - ITextComponent itextcomponent = ITextComponent.Serializer.fromJson(compoundnbt.getString("Name")); + Component itextcomponent = Component.Serializer.fromJson(compoundnbt.getString("Name")); if (itextcomponent != null) { return itextcomponent.getString(); } 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 8950409b6..e1cbbcb8c 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 @@ -10,12 +10,12 @@ import javax.annotation.Nullable; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; -import net.minecraft.block.ShulkerBoxBlock; -import net.minecraft.inventory.ItemStackHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.NonNullList; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.ShulkerBoxBlock; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.NonNullList; public class ShulkerFillLevelAttribute implements ItemAttribute { public static final ShulkerFillLevelAttribute EMPTY = new ShulkerFillLevelAttribute(null); @@ -53,13 +53,13 @@ public class ShulkerFillLevelAttribute implements ItemAttribute { } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { if (levels != null) nbt.putString("id", levels.key); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return nbt.contains("id") ? new ShulkerFillLevelAttribute(ShulkerLevels.fromKey(nbt.getString("id"))) : EMPTY; } @@ -88,7 +88,7 @@ public class ShulkerFillLevelAttribute implements ItemAttribute { public boolean canApply(ItemStack testStack) { if (!isShulker(testStack)) return false; - CompoundNBT compoundnbt = testStack.getTagElement("BlockEntityTag"); + CompoundTag compoundnbt = testStack.getTagElement("BlockEntityTag"); if (compoundnbt == null) return requiredSize.test(0); if (compoundnbt.contains("LootTable", 8)) @@ -99,7 +99,7 @@ public class ShulkerFillLevelAttribute implements ItemAttribute { return requiredSize.test(rawSize); NonNullList inventory = NonNullList.withSize(27, ItemStack.EMPTY); - ItemStackHelper.loadAllItems(compoundnbt, inventory); + ContainerHelper.loadAllItems(compoundnbt, inventory); boolean isFull = inventory.stream().allMatch(itemStack -> !itemStack.isEmpty() && itemStack.getCount() == itemStack.getMaxStackSize()); return requiredSize.test(isFull ? Integer.MAX_VALUE : rawSize); } 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 dbc3c8e7a..a47457595 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 @@ -5,13 +5,13 @@ import java.util.List; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.ListTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.registries.ForgeRegistries; public class AstralSorceryAmuletAttribute implements ItemAttribute { @@ -25,9 +25,9 @@ public class AstralSorceryAmuletAttribute implements ItemAttribute { @Override public boolean appliesTo(ItemStack itemStack) { - for (INBT trait : extractTraitList(itemStack)) { - if(((CompoundNBT) trait).getString("ench").equals(this.enchName) - && ((CompoundNBT)trait).getInt("type") == this.enchType) + for (Tag trait : extractTraitList(itemStack)) { + if(((CompoundTag) trait).getString("ench").equals(this.enchName) + && ((CompoundTag)trait).getInt("type") == this.enchType) return true; } return false; @@ -35,7 +35,7 @@ public class AstralSorceryAmuletAttribute implements ItemAttribute { @Override public List listAttributesOf(ItemStack itemStack) { - ListNBT traits = extractTraitList(itemStack); + ListTag traits = extractTraitList(itemStack); List atts = new ArrayList<>(); for (int i = 0; i < traits.size(); i++) { atts.add(new AstralSorceryAmuletAttribute( @@ -56,7 +56,7 @@ public class AstralSorceryAmuletAttribute implements ItemAttribute { Enchantment enchant = ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryParse(enchName)); if(enchant != null) { - something = new TranslationTextComponent(enchant.getDescriptionId()).getString(); + something = new TranslatableComponent(enchant.getDescriptionId()).getString(); } if(enchType == 1) something = "existing " + something; @@ -65,17 +65,17 @@ public class AstralSorceryAmuletAttribute implements ItemAttribute { } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putString("enchName", this.enchName); nbt.putInt("enchType", this.enchType); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return new AstralSorceryAmuletAttribute(nbt.getString("enchName"), nbt.getInt("enchType")); } - private ListNBT extractTraitList(ItemStack stack) { - return stack.getTag() != null ? stack.getTag().getCompound("astralsorcery").getList("amuletEnchantments", 10) : new ListNBT(); + private ListTag extractTraitList(ItemStack stack) { + return stack.getTag() != null ? stack.getTag().getCompound("astralsorcery").getList("amuletEnchantments", 10) : new ListTag(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryAttunementAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryAttunementAttribute.java index 4d503f17b..f62533528 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryAttunementAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryAttunementAttribute.java @@ -5,10 +5,10 @@ import java.util.List; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TranslatableComponent; public class AstralSorceryAttunementAttribute implements ItemAttribute { String constellationName; @@ -19,7 +19,7 @@ public class AstralSorceryAttunementAttribute implements ItemAttribute { @Override public boolean appliesTo(ItemStack itemStack) { - CompoundNBT nbt = extractAstralNBT(itemStack); + CompoundTag nbt = extractAstralNBT(itemStack); String constellation = nbt.contains("constellation") ? nbt.getString("constellation") : nbt.getString("constellationName"); // Special handling for shifting stars @@ -33,7 +33,7 @@ public class AstralSorceryAttunementAttribute implements ItemAttribute { @Override public List listAttributesOf(ItemStack itemStack) { - CompoundNBT nbt = extractAstralNBT(itemStack); + CompoundTag nbt = extractAstralNBT(itemStack); String constellation = nbt.contains("constellation") ? nbt.getString("constellation") : nbt.getString("constellationName"); // Special handling for shifting stars @@ -57,21 +57,21 @@ public class AstralSorceryAttunementAttribute implements ItemAttribute { @Override public Object[] getTranslationParameters() { ResourceLocation constResource = new ResourceLocation(constellationName); - String something = new TranslationTextComponent(String.format("%s.constellation.%s", constResource.getNamespace(), constResource.getPath())).getString(); + String something = new TranslatableComponent(String.format("%s.constellation.%s", constResource.getNamespace(), constResource.getPath())).getString(); return new Object[] { something }; } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putString("constellation", this.constellationName); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return new AstralSorceryAttunementAttribute(nbt.getString("constellation")); } - private CompoundNBT extractAstralNBT(ItemStack stack) { - return stack.getTag() != null ? stack.getTag().getCompound("astralsorcery") : new CompoundNBT(); + private CompoundTag extractAstralNBT(ItemStack stack) { + return stack.getTag() != null ? stack.getTag().getCompound("astralsorcery") : new CompoundTag(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryCrystalAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryCrystalAttribute.java index 3830d7b00..d9b94670c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryCrystalAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryCrystalAttribute.java @@ -5,12 +5,12 @@ import java.util.List; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.ListTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TranslatableComponent; public class AstralSorceryCrystalAttribute implements ItemAttribute { String traitName; @@ -21,8 +21,8 @@ public class AstralSorceryCrystalAttribute implements ItemAttribute { @Override public boolean appliesTo(ItemStack itemStack) { - for (INBT trait : extractTraitList(itemStack)) { - if(((CompoundNBT) trait).getString("property").equals(this.traitName)) + for (Tag trait : extractTraitList(itemStack)) { + if(((CompoundTag) trait).getString("property").equals(this.traitName)) return true; } return false; @@ -30,7 +30,7 @@ public class AstralSorceryCrystalAttribute implements ItemAttribute { @Override public List listAttributesOf(ItemStack itemStack) { - ListNBT traits = extractTraitList(itemStack); + ListTag traits = extractTraitList(itemStack); List atts = new ArrayList<>(); for (int i = 0; i < traits.size(); i++) { atts.add(new AstralSorceryCrystalAttribute(traits.getCompound(i).getString("property"))); @@ -46,21 +46,21 @@ public class AstralSorceryCrystalAttribute implements ItemAttribute { @Override public Object[] getTranslationParameters() { ResourceLocation traitResource = new ResourceLocation(traitName); - String something = new TranslationTextComponent(String.format("crystal.property.%s.%s.name", traitResource.getNamespace(), traitResource.getPath())).getString(); + String something = new TranslatableComponent(String.format("crystal.property.%s.%s.name", traitResource.getNamespace(), traitResource.getPath())).getString(); return new Object[] { something }; } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putString("property", this.traitName); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return new AstralSorceryCrystalAttribute(nbt.getString("property")); } - private ListNBT extractTraitList(ItemStack stack) { - return stack.getTag() != null ? stack.getTag().getCompound("astralsorcery").getCompound("crystalProperties").getList("attributes", 10) : new ListNBT(); + private ListTag extractTraitList(ItemStack stack) { + return stack.getTag() != null ? stack.getTag().getCompound("astralsorcery").getCompound("crystalProperties").getList("attributes", 10) : new ListTag(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryPerkGemAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryPerkGemAttribute.java index 65b7f1994..5fd811b42 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryPerkGemAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/astralsorcery/AstralSorceryPerkGemAttribute.java @@ -5,12 +5,12 @@ import java.util.List; import com.simibubi.create.content.logistics.item.filter.ItemAttribute; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.ListTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TranslatableComponent; public class AstralSorceryPerkGemAttribute implements ItemAttribute { String traitName; @@ -21,8 +21,8 @@ public class AstralSorceryPerkGemAttribute implements ItemAttribute { @Override public boolean appliesTo(ItemStack itemStack) { - for (INBT trait : extractTraitList(itemStack)) { - if(((CompoundNBT) trait).getString("type").equals(this.traitName)) + for (Tag trait : extractTraitList(itemStack)) { + if(((CompoundTag) trait).getString("type").equals(this.traitName)) return true; } return false; @@ -30,7 +30,7 @@ public class AstralSorceryPerkGemAttribute implements ItemAttribute { @Override public List listAttributesOf(ItemStack itemStack) { - ListNBT traits = extractTraitList(itemStack); + ListTag traits = extractTraitList(itemStack); List atts = new ArrayList<>(); for (int i = 0; i < traits.size(); i++) { atts.add(new AstralSorceryPerkGemAttribute(traits.getCompound(i).getString("type"))); @@ -46,21 +46,21 @@ public class AstralSorceryPerkGemAttribute implements ItemAttribute { @Override public Object[] getTranslationParameters() { ResourceLocation traitResource = new ResourceLocation(traitName); - String something = new TranslationTextComponent(String.format("perk.attribute.%s.%s.name", traitResource.getNamespace(), traitResource.getPath())).getString(); + String something = new TranslatableComponent(String.format("perk.attribute.%s.%s.name", traitResource.getNamespace(), traitResource.getPath())).getString(); return new Object[] { something }; } @Override - public void writeNBT(CompoundNBT nbt) { + public void writeNBT(CompoundTag nbt) { nbt.putString("type", this.traitName); } @Override - public ItemAttribute readNBT(CompoundNBT nbt) { + public ItemAttribute readNBT(CompoundTag nbt) { return new AstralSorceryPerkGemAttribute(nbt.getString("type")); } - private ListNBT extractTraitList(ItemStack stack) { - return stack.getTag() != null ? stack.getTag().getCompound("astralsorcery").getList("attribute_modifiers", 10) : new ListNBT(); + private ListTag extractTraitList(ItemStack stack) { + return stack.getTag() != null ? stack.getTag().getCompound("astralsorcery").getList("attribute_modifiers", 10) : new ListTag(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/packet/ConfigureFlexcratePacket.java b/src/main/java/com/simibubi/create/content/logistics/packet/ConfigureFlexcratePacket.java index 0acc1c7ad..c74e73a8e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/packet/ConfigureFlexcratePacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/packet/ConfigureFlexcratePacket.java @@ -3,14 +3,14 @@ package com.simibubi.create.content.logistics.packet; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateTileEntity; import com.simibubi.create.foundation.networking.TileEntityConfigurationPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; public class ConfigureFlexcratePacket extends TileEntityConfigurationPacket { private int maxItems; - public ConfigureFlexcratePacket(PacketBuffer buffer) { + public ConfigureFlexcratePacket(FriendlyByteBuf buffer) { super(buffer); } @@ -20,12 +20,12 @@ public class ConfigureFlexcratePacket extends TileEntityConfigurationPacket { @@ -19,19 +19,19 @@ public class ConfigureStockswitchPacket extends TileEntityConfigurationPacket { private final boolean inwards; - public FunnelFlapPacket(PacketBuffer buffer) { + public FunnelFlapPacket(FriendlyByteBuf buffer) { super(buffer); inwards = buffer.readBoolean(); @@ -21,7 +21,7 @@ public class FunnelFlapPacket extends TileEntityDataPacket { } @Override - protected void writeData(PacketBuffer buffer) { + protected void writeData(FriendlyByteBuf buffer) { buffer.writeBoolean(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 2545b164e..e7f15b0b5 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 @@ -8,14 +8,14 @@ import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelTileEntity; import com.simibubi.create.foundation.networking.TileEntityDataPacket; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Direction; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.Direction; public class TunnelFlapPacket extends TileEntityDataPacket { private List> flaps; - public TunnelFlapPacket(PacketBuffer buffer) { + public TunnelFlapPacket(FriendlyByteBuf buffer) { super(buffer); byte size = buffer.readByte(); @@ -37,7 +37,7 @@ public class TunnelFlapPacket extends TileEntityDataPacket } @Override - protected void writeData(PacketBuffer buffer) { + protected void writeData(FriendlyByteBuf buffer) { buffer.writeByte(flaps.size()); for (Pair flap : flaps) { 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 de6ab5df5..a15a71b1c 100644 --- a/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java +++ b/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java @@ -24,14 +24,14 @@ import com.tterrag.registrate.util.DataIngredient; import com.tterrag.registrate.util.entry.BlockEntry; import com.tterrag.registrate.util.nullness.NonNullBiConsumer; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.GlassBlock; -import net.minecraft.block.SandBlock; -import net.minecraft.block.WoodType; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.GlassBlock; +import net.minecraft.world.level.block.SandBlock; +import net.minecraft.world.level.block.state.properties.WoodType; import net.minecraft.client.renderer.RenderType; import net.minecraft.tags.BlockTags; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags; public class AllPaletteBlocks { 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 b843de134..ba6355eab 100644 --- a/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassBlock.java @@ -1,14 +1,16 @@ package com.simibubi.create.content.palettes; -import net.minecraft.block.BlockState; -import net.minecraft.block.GlassBlock; -import net.minecraft.fluid.FluidState; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.GlassBlock; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class ConnectedGlassBlock extends GlassBlock { public ConnectedGlassBlock(Properties p_i48392_1_) { @@ -23,7 +25,7 @@ public class ConnectedGlassBlock extends GlassBlock { } @Override - public boolean shouldDisplayFluidOverlay(BlockState state, IBlockDisplayReader world, BlockPos pos, FluidState fluidState) { + public boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter world, BlockPos pos, FluidState fluidState) { return true; } } 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 a09a2cb6e..818be791f 100644 --- a/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassPaneBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/ConnectedGlassPaneBlock.java @@ -1,10 +1,12 @@ package com.simibubi.create.content.palettes; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class ConnectedGlassPaneBlock extends GlassPaneBlock { public ConnectedGlassPaneBlock(Properties builder) { 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..0ece88992 100644 --- a/src/main/java/com/simibubi/create/content/palettes/GlassPaneBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/GlassPaneBlock.java @@ -1,8 +1,10 @@ package com.simibubi.create.content.palettes; -import net.minecraft.block.PaneBlock; +import net.minecraft.world.level.block.IronBarsBlock; -public class GlassPaneBlock extends PaneBlock { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class GlassPaneBlock extends IronBarsBlock { public GlassPaneBlock(Properties builder) { super(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 e21cc1e83..493c615e0 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java +++ b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java @@ -14,22 +14,22 @@ import com.tterrag.registrate.providers.loot.RegistrateBlockLootTables; import com.tterrag.registrate.util.DataIngredient; import com.tterrag.registrate.util.nullness.NonnullType; -import net.minecraft.block.AbstractBlock.Properties; -import net.minecraft.block.Block; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.StairsBlock; -import net.minecraft.block.WallBlock; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.level.block.StairBlock; +import net.minecraft.world.level.block.WallBlock; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; import net.minecraft.tags.BlockTags; -import net.minecraft.tags.ITag; +import net.minecraft.tags.Tag; import net.minecraft.tags.ItemTags; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.ModelFile; public abstract class PaletteBlockPartial { - public static final PaletteBlockPartial STAIR = new Stairs(); + public static final PaletteBlockPartial STAIR = new Stairs(); public static final PaletteBlockPartial SLAB = new Slab(false); public static final PaletteBlockPartial UNIQUE_SLAB = new Slab(true); public static final PaletteBlockPartial WALL = new Wall(); @@ -74,9 +74,9 @@ public abstract class PaletteBlockPartial { return builder; } - protected abstract Iterable> getBlockTags(); + protected abstract Iterable> getBlockTags(); - protected abstract Iterable> getItemTags(); + protected abstract Iterable> getItemTags(); protected abstract B createBlock(Supplier block); @@ -86,31 +86,31 @@ public abstract class PaletteBlockPartial { protected abstract void generateBlockState(DataGenContext ctx, RegistrateBlockstateProvider prov, String variantName, PaletteBlockPattern pattern, Supplier block); - private static class Stairs extends PaletteBlockPartial { + private static class Stairs extends PaletteBlockPartial { public Stairs() { super("stairs"); } @Override - protected StairsBlock createBlock(Supplier block) { - return new StairsBlock(() -> block.get() + protected StairBlock createBlock(Supplier block) { + return new StairBlock(() -> block.get() .defaultBlockState(), Properties.copy(block.get())); } @Override - protected void generateBlockState(DataGenContext ctx, RegistrateBlockstateProvider prov, + protected void generateBlockState(DataGenContext ctx, RegistrateBlockstateProvider prov, String variantName, PaletteBlockPattern pattern, Supplier block) { prov.stairsBlock(ctx.get(), getMainTexture(variantName, pattern)); } @Override - protected Iterable> getBlockTags() { + protected Iterable> getBlockTags() { return Arrays.asList(BlockTags.STAIRS); } @Override - protected Iterable> getItemTags() { + protected Iterable> getItemTags() { return Arrays.asList(ItemTags.STAIRS); } @@ -165,12 +165,12 @@ public abstract class PaletteBlockPartial { } @Override - protected Iterable> getBlockTags() { + protected Iterable> getBlockTags() { return Arrays.asList(BlockTags.SLABS); } @Override - protected Iterable> getItemTags() { + protected Iterable> getItemTags() { return Arrays.asList(ItemTags.SLABS); } @@ -218,12 +218,12 @@ public abstract class PaletteBlockPartial { } @Override - protected Iterable> getBlockTags() { + protected Iterable> getBlockTags() { return Arrays.asList(BlockTags.WALLS); } @Override - protected Iterable> getItemTags() { + protected Iterable> getItemTags() { return Arrays.asList(ItemTags.WALLS); } 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 3ef5bfa9b..61e9e352b 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java +++ b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java @@ -24,15 +24,15 @@ import com.tterrag.registrate.util.DataIngredient; import com.tterrag.registrate.util.nullness.NonNullBiConsumer; import com.tterrag.registrate.util.nullness.NonNullFunction; -import net.minecraft.block.AbstractBlock.Properties; -import net.minecraft.block.Block; -import net.minecraft.block.RotatedPillarBlock; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.client.renderer.RenderType; -import net.minecraft.data.CookingRecipeBuilder; -import net.minecraft.data.ShapedRecipeBuilder; -import net.minecraft.item.Item; -import net.minecraft.tags.ITag; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.recipes.SimpleCookingRecipeBuilder; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.world.item.Item; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.generators.ModelFile; @@ -48,7 +48,7 @@ public class PaletteBlockPattern { .addRecipes(v -> (c, p) -> { DataIngredient ingredient = DataIngredient.items(c.get()); Block result = v.getBaseBlock().get(); - CookingRecipeBuilder.smelting(ingredient, result, 0.1f, 200) + SimpleCookingRecipeBuilder.smelting(ingredient, result, 0.1f, 200) .unlockedBy("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) .save(p, p.safeId(result)); }), @@ -118,8 +118,8 @@ public class PaletteBlockPattern { private String id; private boolean isTranslucent; private boolean hasFoliage; - private ITag.INamedTag[] blockTags; - private ITag.INamedTag[] itemTags; + private Tag.Named[] blockTags; + private Tag.Named[] itemTags; private Optional> ctBehaviour; private IPatternBlockStateGenerator blockStateGenerator; @@ -158,11 +158,11 @@ public class PaletteBlockPattern { return hasFoliage; } - public ITag.INamedTag[] getBlockTags() { + public Tag.Named[] getBlockTags() { return blockTags; } - public ITag.INamedTag[] getItemTags() { + public Tag.Named[] getItemTags() { return itemTags; } @@ -216,13 +216,13 @@ public class PaletteBlockPattern { } @SafeVarargs - private final PaletteBlockPattern blockTags(ITag.INamedTag... tags) { + private final PaletteBlockPattern blockTags(Tag.Named... tags) { blockTags = tags; return this; } @SafeVarargs - private final PaletteBlockPattern itemTags(ITag.INamedTag... tags) { + private final PaletteBlockPattern itemTags(Tag.Named... tags) { itemTags = tags; return this; } diff --git a/src/main/java/com/simibubi/create/content/palettes/PaletteStoneVariants.java b/src/main/java/com/simibubi/create/content/palettes/PaletteStoneVariants.java index e7933fcf1..5cb191bf7 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PaletteStoneVariants.java +++ b/src/main/java/com/simibubi/create/content/palettes/PaletteStoneVariants.java @@ -4,8 +4,8 @@ import java.util.function.Supplier; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; public enum PaletteStoneVariants { 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 aa9d5746b..e2716f45a 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PalettesItemGroup.java +++ b/src/main/java/com/simibubi/create/content/palettes/PalettesItemGroup.java @@ -5,8 +5,8 @@ import java.util.EnumSet; import com.simibubi.create.content.AllSections; import com.simibubi.create.foundation.item.CreateItemGroupBase; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.NonNullList; public class PalettesItemGroup extends CreateItemGroupBase { 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 62a91346a..cf0280ae3 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java +++ b/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java @@ -13,11 +13,11 @@ import com.tterrag.registrate.util.DataIngredient; import com.tterrag.registrate.util.entry.BlockEntry; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; import net.minecraft.client.renderer.RenderType; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.tags.ITag; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.tags.Tag; public class PalettesVariantEntry { @@ -42,11 +42,11 @@ public class PalettesVariantEntry { ItemBuilder> itemBuilder = builder.item(); - ITag.INamedTag[] blockTags = pattern.getBlockTags(); + Tag.Named[] blockTags = pattern.getBlockTags(); if (blockTags != null) { builder.tag(blockTags); } - ITag.INamedTag[] itemTags = pattern.getItemTags(); + Tag.Named[] itemTags = pattern.getItemTags(); if (itemTags != null) { itemBuilder.tag(itemTags); } 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 8c29e223b..f328b368a 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PavedBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/PavedBlock.java @@ -1,13 +1,15 @@ package com.simibubi.create.content.palettes; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class PavedBlock extends Block { @@ -24,14 +26,14 @@ public class PavedBlock extends Block { } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { return defaultBlockState().setValue(COVERED, context.getLevel() .getBlockState(context.getClickedPos().above()) .getBlock() == this); } @Override - public BlockState updateShape(BlockState stateIn, Direction face, BlockState neighbour, IWorld worldIn, + public BlockState updateShape(BlockState stateIn, Direction face, BlockState neighbour, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { if (face == Direction.UP) return stateIn.setValue(COVERED, worldIn.getBlockState(facingPos).getBlock() == this); 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 30764cedd..b1cf88956 100644 --- a/src/main/java/com/simibubi/create/content/palettes/WindowBlock.java +++ b/src/main/java/com/simibubi/create/content/palettes/WindowBlock.java @@ -1,12 +1,14 @@ package com.simibubi.create.content.palettes; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.util.Direction; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.core.Direction; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class WindowBlock extends ConnectedGlassBlock { public WindowBlock(Properties p_i48392_1_) { @@ -17,7 +19,7 @@ public class WindowBlock extends ConnectedGlassBlock { @OnlyIn(Dist.CLIENT) public boolean skipRendering(BlockState state, BlockState adjacentBlockState, Direction side) { return adjacentBlockState.getBlock() instanceof ConnectedGlassBlock - ? (!RenderTypeLookup.canRenderInLayer(state, RenderType.translucent()) && side.getAxis() + ? (!ItemBlockRenderTypes.canRenderInLayer(state, RenderType.translucent()) && side.getAxis() .isHorizontal() || state.getBlock() == adjacentBlockState.getBlock()) : 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 51e85900f..a57bf66dc 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java +++ b/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java @@ -22,9 +22,9 @@ import com.simibubi.create.foundation.utility.FilesHelper; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -33,7 +33,7 @@ public class ClientSchematicLoader { public static final int PACKET_DELAY = 10; - private List availableSchematics; + private List availableSchematics; private Map activeUploads; private int packetCycle; @@ -84,7 +84,7 @@ public class ClientSchematicLoader { return true; Integer maxSize = AllConfigs.SERVER.schematics.maxTotalSchematicSize.get(); if (size > maxSize * 1000) { - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (player != null) { player.sendMessage(Lang.translate("schematics.uploadTooLarge").append(" (" + size / 1000 + " KB)."), player.getUUID()); player.sendMessage(Lang.translate("schematics.maxAllowedSize").append(" " + maxSize + " KB"), player.getUUID()); @@ -137,7 +137,7 @@ public class ClientSchematicLoader { if (Files.isDirectory(path)) return; - availableSchematics.add(new StringTextComponent(path.getFileName().toString())); + availableSchematics.add(new TextComponent(path.getFileName().toString())); }); } catch (NoSuchFileException e) { // No Schematics created yet @@ -199,7 +199,7 @@ public class ClientSchematicLoader { }); } - public List getAvailableSchematics() { + public List getAvailableSchematics() { return availableSchematics; } diff --git a/src/main/java/com/simibubi/create/content/schematics/ISpecialBlockItemRequirement.java b/src/main/java/com/simibubi/create/content/schematics/ISpecialBlockItemRequirement.java index d8c65892a..06d293b65 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ISpecialBlockItemRequirement.java +++ b/src/main/java/com/simibubi/create/content/schematics/ISpecialBlockItemRequirement.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.schematics; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; public interface ISpecialBlockItemRequirement { - default ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + default ItemRequirement getRequiredItems(BlockState state, BlockEntity te) { return ItemRequirement.INVALID; } 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 aa52f4374..12942a30f 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java +++ b/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java @@ -8,27 +8,27 @@ import java.util.stream.Stream; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FarmlandBlock; -import net.minecraft.block.GrassPathBlock; -import net.minecraft.block.SeaPickleBlock; -import net.minecraft.block.SnowBlock; -import net.minecraft.block.TurtleEggBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.item.ArmorStandEntity; -import net.minecraft.entity.item.BoatEntity; -import net.minecraft.entity.item.ItemFrameEntity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.SlabType; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FarmBlock; +import net.minecraft.world.level.block.GrassPathBlock; +import net.minecraft.world.level.block.SeaPickleBlock; +import net.minecraft.world.level.block.SnowLayerBlock; +import net.minecraft.world.level.block.TurtleEggBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.decoration.ArmorStand; +import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.decoration.ItemFrame; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.SlabType; +import net.minecraft.world.level.block.entity.BlockEntity; public class ItemRequirement { @@ -71,7 +71,7 @@ public class ItemRequirement { } - public static ItemRequirement of(BlockState state, TileEntity te) { + public static ItemRequirement of(BlockState state, BlockEntity te) { Block block = state.getBlock(); ItemRequirement baseRequirement; @@ -101,11 +101,11 @@ public class ItemRequirement { 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.getValue(SeaPickleBlock.PICKLES).intValue()))); - if (block instanceof SnowBlock) - return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.getValue(SnowBlock.LAYERS).intValue()))); + if (block instanceof SnowLayerBlock) + return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.getValue(SnowLayerBlock.LAYERS).intValue()))); if (block instanceof GrassPathBlock) return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(Items.GRASS_BLOCK))); - if (block instanceof FarmlandBlock) + if (block instanceof FarmBlock) return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(Items.DIRT))); return item == Items.AIR ? INVALID : new ItemRequirement(ItemUseType.CONSUME, item); @@ -118,7 +118,7 @@ public class ItemRequirement { return ((ISpecialEntityItemRequirement) entity).getRequiredItems(); if (type == EntityType.ITEM_FRAME) { - ItemFrameEntity ife = (ItemFrameEntity) entity; + ItemFrame ife = (ItemFrame) entity; ItemStack frame = new ItemStack(Items.ITEM_FRAME); ItemStack displayedItem = ife.getItem(); if (displayedItem.isEmpty()) @@ -131,19 +131,19 @@ public class ItemRequirement { if (type == EntityType.ARMOR_STAND) { List requirements = new ArrayList<>(); - ArmorStandEntity armorStandEntity = (ArmorStandEntity) entity; + ArmorStand armorStandEntity = (ArmorStand) entity; armorStandEntity.getAllSlots().forEach(requirements::add); requirements.add(new ItemStack(Items.ARMOR_STAND)); return new ItemRequirement(ItemUseType.CONSUME, requirements); } - if (entity instanceof AbstractMinecartEntity) { - AbstractMinecartEntity minecartEntity = (AbstractMinecartEntity) entity; + if (entity instanceof AbstractMinecart) { + AbstractMinecart minecartEntity = (AbstractMinecart) entity; return new ItemRequirement(ItemUseType.CONSUME, minecartEntity.getCartItem().getItem()); } - if (entity instanceof BoatEntity) { - BoatEntity boatEntity = (BoatEntity) entity; + if (entity instanceof Boat) { + Boat boatEntity = (Boat) entity; return new ItemRequirement(ItemUseType.CONSUME, boatEntity.getDropItem().getItem()); } 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 bcfd97955..bbc1b586d 100644 --- a/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java +++ b/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java @@ -11,18 +11,18 @@ import com.simibubi.create.foundation.utility.Lang; import it.unimi.dsi.fastutil.objects.Object2IntArrayMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.nbt.StringNBT; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.Style; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Style; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.TranslatableComponent; public class MaterialChecklist { @@ -73,30 +73,30 @@ public class MaterialChecklist { public ItemStack createItem() { ItemStack book = new ItemStack(Items.WRITTEN_BOOK); - CompoundNBT tag = book.getOrCreateTag(); - ListNBT pages = new ListNBT(); + CompoundTag tag = book.getOrCreateTag(); + ListTag pages = new ListTag(); int itemsWritten = 0; - IFormattableTextComponent textComponent; + MutableComponent textComponent; if (blocksNotLoaded) { - textComponent = new StringTextComponent("\n" + TextFormatting.RED); + textComponent = new TextComponent("\n" + ChatFormatting.RED); textComponent = textComponent.append(Lang.createTranslationTextComponent("materialChecklist.blocksNotLoaded")); - pages.add(StringNBT.valueOf(ITextComponent.Serializer.toJson(textComponent))); + pages.add(StringTag.valueOf(Component.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.getDescriptionId()).getString() + String name1 = new TranslatableComponent(item1.getDescriptionId()).getString() .toLowerCase(locale); - String name2 = new TranslationTextComponent(item2.getDescriptionId()).getString() + String name2 = new TranslatableComponent(item2.getDescriptionId()).getString() .toLowerCase(locale); return name1.compareTo(name2); }); - textComponent = new StringTextComponent(""); + textComponent = new TextComponent(""); List completed = new ArrayList<>(); for (Item item : keys) { int amount = getRequiredAmount(item); @@ -110,9 +110,9 @@ public class MaterialChecklist { if (itemsWritten == MAX_ENTRIES_PER_PAGE) { itemsWritten = 0; - textComponent.append(new StringTextComponent("\n >>>").withStyle(TextFormatting.BLUE)); - pages.add(StringNBT.valueOf(ITextComponent.Serializer.toJson(textComponent))); - textComponent = new StringTextComponent(""); + textComponent.append(new TextComponent("\n >>>").withStyle(ChatFormatting.BLUE)); + pages.add(StringTag.valueOf(Component.Serializer.toJson(textComponent))); + textComponent = new TextComponent(""); } itemsWritten++; @@ -122,25 +122,25 @@ public class MaterialChecklist { for (Item item : completed) { if (itemsWritten == MAX_ENTRIES_PER_PAGE) { itemsWritten = 0; - textComponent.append(new StringTextComponent("\n >>>").withStyle(TextFormatting.DARK_GREEN)); - pages.add(StringNBT.valueOf(ITextComponent.Serializer.toJson(textComponent))); - textComponent = new StringTextComponent(""); + textComponent.append(new TextComponent("\n >>>").withStyle(ChatFormatting.DARK_GREEN)); + pages.add(StringTag.valueOf(Component.Serializer.toJson(textComponent))); + textComponent = new TextComponent(""); } itemsWritten++; textComponent.append(entry(new ItemStack(item), getRequiredAmount(item), false)); } - pages.add(StringNBT.valueOf(ITextComponent.Serializer.toJson(textComponent))); + pages.add(StringTag.valueOf(Component.Serializer.toJson(textComponent))); tag.put("pages", pages); tag.putString("author", "Schematicannon"); - tag.putString("title", TextFormatting.BLUE + "Material Checklist"); + tag.putString("title", ChatFormatting.BLUE + "Material Checklist"); textComponent = Lang.createTranslationTextComponent("materialChecklist") - .setStyle(Style.EMPTY.withColor(TextFormatting.BLUE) + .setStyle(Style.EMPTY.withColor(ChatFormatting.BLUE) .withItalic(Boolean.FALSE)); book.getOrCreateTagElement("display") - .putString("Name", ITextComponent.Serializer.toJson(textComponent)); + .putString("Name", Component.Serializer.toJson(textComponent)); book.setTag(tag); return book; @@ -153,16 +153,16 @@ public class MaterialChecklist { return amount; } - private ITextComponent entry(ItemStack item, int amount, boolean unfinished) { + private Component entry(ItemStack item, int amount, boolean unfinished) { int stacks = amount / 64; int remainder = amount % 64; - IFormattableTextComponent tc = new TranslationTextComponent(item.getDescriptionId()); + MutableComponent tc = new TranslatableComponent(item.getDescriptionId()); if (!unfinished) tc.append(" \u2714"); - tc.withStyle(unfinished ? TextFormatting.BLUE : TextFormatting.DARK_GREEN); - return tc.append(new StringTextComponent("\n" + " x" + amount).withStyle(TextFormatting.BLACK)) + tc.withStyle(unfinished ? ChatFormatting.BLUE : ChatFormatting.DARK_GREEN); + return tc.append(new TextComponent("\n" + " x" + amount).withStyle(ChatFormatting.BLACK)) .append( - new StringTextComponent(" | " + stacks + "\u25A4 +" + remainder + "\n").withStyle(TextFormatting.GRAY)); + new TextComponent(" | " + stacks + "\u25A4 +" + remainder + "\n").withStyle(ChatFormatting.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 906a907fe..7fcdf8108 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java @@ -10,22 +10,22 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Str import com.simibubi.create.content.schematics.item.SchematicItem; import com.simibubi.create.foundation.utility.BlockHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.state.properties.BedPart; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.PlacementSettings; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.state.properties.BedPart; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class SchematicPrinter { @@ -48,13 +48,13 @@ public class SchematicPrinter { deferredBlocks = new LinkedList<>(); } - public void fromTag(CompoundNBT compound, boolean clientPacket) { + public void fromTag(CompoundTag compound, boolean clientPacket) { if (compound.contains("CurrentPos")) - currentPos = NBTUtil.readBlockPos(compound.getCompound("CurrentPos")); + currentPos = NbtUtils.readBlockPos(compound.getCompound("CurrentPos")); if (clientPacket) { schematicLoaded = false; if (compound.contains("Anchor")) { - schematicAnchor = NBTUtil.readBlockPos(compound.getCompound("Anchor")); + schematicAnchor = NbtUtils.readBlockPos(compound.getCompound("Anchor")); schematicLoaded = true; } } @@ -62,49 +62,49 @@ public class SchematicPrinter { printingEntityIndex = compound.getInt("EntityProgress"); printStage = PrintStage.valueOf(compound.getString("PrintStage")); compound.getList("DeferredBlocks", 10).stream() - .map(p -> NBTUtil.readBlockPos((CompoundNBT) p)) + .map(p -> NbtUtils.readBlockPos((CompoundTag) p)) .collect(Collectors.toCollection(() -> deferredBlocks)); } - public void write(CompoundNBT compound) { + public void write(CompoundTag compound) { if (currentPos != null) - compound.put("CurrentPos", NBTUtil.writeBlockPos(currentPos)); + compound.put("CurrentPos", NbtUtils.writeBlockPos(currentPos)); if (schematicAnchor != null) - compound.put("Anchor", NBTUtil.writeBlockPos(schematicAnchor)); + compound.put("Anchor", NbtUtils.writeBlockPos(schematicAnchor)); compound.putInt("EntityProgress", printingEntityIndex); compound.putString("PrintStage", printStage.name()); - ListNBT tagDeferredBlocks = new ListNBT(); + ListTag tagDeferredBlocks = new ListTag(); for (BlockPos p : deferredBlocks) - tagDeferredBlocks.add(NBTUtil.writeBlockPos(p)); + tagDeferredBlocks.add(NbtUtils.writeBlockPos(p)); compound.put("DeferredBlocks", tagDeferredBlocks); } - public void loadSchematic(ItemStack blueprint, World originalWorld, boolean processNBT) { + public void loadSchematic(ItemStack blueprint, Level originalWorld, boolean processNBT) { if (!blueprint.hasTag() || !blueprint.getTag().getBoolean("Deployed")) return; - Template activeTemplate = SchematicItem.loadSchematic(blueprint); - PlacementSettings settings = SchematicItem.getSettings(blueprint, processNBT); + StructureTemplate activeTemplate = SchematicItem.loadSchematic(blueprint); + StructurePlaceSettings settings = SchematicItem.getSettings(blueprint, processNBT); - schematicAnchor = NBTUtil.readBlockPos(blueprint.getTag() + schematicAnchor = NbtUtils.readBlockPos(blueprint.getTag() .getCompound("Anchor")); blockReader = new SchematicWorld(schematicAnchor, originalWorld); activeTemplate.placeInWorldChunk(blockReader, schematicAnchor, settings, blockReader.getRandom()); - BlockPos extraBounds = Template.calculateRelativePosition(settings, activeTemplate.getSize() + BlockPos extraBounds = StructureTemplate.calculateRelativePosition(settings, activeTemplate.getSize() .offset(-1, -1, -1)); - blockReader.bounds.expand(new MutableBoundingBox(extraBounds, extraBounds)); + blockReader.bounds.expand(new BoundingBox(extraBounds, extraBounds)); StructureTransform transform = new StructureTransform(settings.getRotationPivot(), Direction.Axis.Y, settings.getRotation(), settings.getMirror()); - for (TileEntity te : blockReader.tileEntities.values()) + for (BlockEntity te : blockReader.tileEntities.values()) transform.apply(te); printingEntityIndex = -1; printStage = PrintStage.BLOCKS; deferredBlocks.clear(); - MutableBoundingBox bounds = blockReader.getBounds(); + BoundingBox bounds = blockReader.getBounds(); currentPos = new BlockPos(bounds.x0 - 1, bounds.y0, bounds.z0); schematicLoaded = true; } @@ -144,7 +144,7 @@ public class SchematicPrinter { @FunctionalInterface public interface BlockTargetHandler { - void handle(BlockPos target, BlockState blockState, TileEntity tileEntity); + void handle(BlockPos target, BlockState blockState, BlockEntity tileEntity); } @FunctionalInterface public interface EntityTargetHandler { @@ -161,20 +161,20 @@ public class SchematicPrinter { entityHandler.handle(target, entity); } else { BlockState blockState = BlockHelper.setZeroAge(blockReader.getBlockState(target)); - TileEntity tileEntity = blockReader.getBlockEntity(target); + BlockEntity tileEntity = blockReader.getBlockEntity(target); blockHandler.handle(target, blockState, tileEntity); } } @FunctionalInterface public interface PlacementPredicate { - boolean shouldPlace(BlockPos target, BlockState blockState, TileEntity tileEntity, + boolean shouldPlace(BlockPos target, BlockState blockState, BlockEntity tileEntity, BlockState toReplace, BlockState toReplaceOther, boolean isNormalCube); } - public boolean shouldPlaceCurrent(World world) { return shouldPlaceCurrent(world, (a,b,c,d,e,f) -> true); } + public boolean shouldPlaceCurrent(Level world) { return shouldPlaceCurrent(world, (a,b,c,d,e,f) -> true); } - public boolean shouldPlaceCurrent(World world, PlacementPredicate predicate) { + public boolean shouldPlaceCurrent(Level world, PlacementPredicate predicate) { if (world == null) return false; @@ -184,9 +184,9 @@ public class SchematicPrinter { return shouldPlaceBlock(world, predicate, getCurrentTarget()); } - public boolean shouldPlaceBlock(World world, PlacementPredicate predicate, BlockPos pos) { + public boolean shouldPlaceBlock(Level world, PlacementPredicate predicate, BlockPos pos) { BlockState state = BlockHelper.setZeroAge(blockReader.getBlockState(pos)); - TileEntity tileEntity = blockReader.getBlockEntity(pos); + BlockEntity tileEntity = blockReader.getBlockEntity(pos); BlockState toReplace = world.getBlockState(pos); BlockState toReplaceOther = null; @@ -219,16 +219,16 @@ public class SchematicPrinter { BlockPos target = getCurrentTarget(); BlockState blockState = BlockHelper.setZeroAge(blockReader.getBlockState(target)); - TileEntity tileEntity = blockReader.getBlockEntity(target); + BlockEntity tileEntity = blockReader.getBlockEntity(target); return ItemRequirement.of(blockState, tileEntity); } - public int markAllBlockRequirements(MaterialChecklist checklist, World world, PlacementPredicate predicate) { + public int markAllBlockRequirements(MaterialChecklist checklist, Level world, PlacementPredicate predicate) { int blocksToPlace = 0; for (BlockPos pos : blockReader.getAllPositions()) { BlockPos relPos = pos.offset(schematicAnchor); BlockState required = blockReader.getBlockState(relPos); - TileEntity requiredTE = blockReader.getBlockEntity(relPos); + BlockEntity requiredTE = blockReader.getBlockEntity(relPos); if (!world.isAreaLoaded(pos.offset(schematicAnchor), 0)) { checklist.warnBlockNotLoaded(); @@ -294,7 +294,7 @@ public class SchematicPrinter { public boolean tryAdvanceCurrentPos() { currentPos = currentPos.relative(Direction.EAST); - MutableBoundingBox bounds = blockReader.getBounds(); + BoundingBox bounds = blockReader.getBounds(); BlockPos posInBounds = currentPos.offset(-bounds.x0, -bounds.y0, -bounds.z0); if (posInBounds.getX() > bounds.getXSpan()) 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 7539d6108..00dd1895d 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicProcessor.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicProcessor.java @@ -7,17 +7,17 @@ import javax.annotation.Nullable; import com.mojang.serialization.Codec; import com.simibubi.create.foundation.utility.NBTProcessors; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.IStructureProcessorType; -import net.minecraft.world.gen.feature.template.PlacementSettings; -import net.minecraft.world.gen.feature.template.StructureProcessor; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class SchematicProcessor extends StructureProcessor { @@ -26,22 +26,22 @@ public class SchematicProcessor extends StructureProcessor { return INSTANCE; }); - public static IStructureProcessorType TYPE; + public static StructureProcessorType TYPE; public static void register() { - TYPE = IStructureProcessorType.register("schematic", CODEC); + TYPE = StructureProcessorType.register("schematic", CODEC); } @Nullable @Override - public Template.BlockInfo process(IWorldReader world, BlockPos pos, BlockPos anotherPos, Template.BlockInfo rawInfo, - Template.BlockInfo info, PlacementSettings settings, @Nullable Template template) { + public StructureTemplate.StructureBlockInfo process(LevelReader world, BlockPos pos, BlockPos anotherPos, StructureTemplate.StructureBlockInfo rawInfo, + StructureTemplate.StructureBlockInfo info, StructurePlaceSettings settings, @Nullable StructureTemplate template) { if (info.nbt != null) { - TileEntity te = info.state.createTileEntity(world); + BlockEntity te = info.state.createTileEntity(world); if (te != null) { - CompoundNBT nbt = NBTProcessors.process(te, info.nbt, false); + CompoundTag nbt = NBTProcessors.process(te, info.nbt, false); if (nbt != info.nbt) - return new Template.BlockInfo(info.pos, info.state, nbt); + return new StructureTemplate.StructureBlockInfo(info.pos, info.state, nbt); } } return info; @@ -49,11 +49,11 @@ public class SchematicProcessor extends StructureProcessor { @Nullable @Override - public Template.EntityInfo processEntity(IWorldReader world, BlockPos pos, Template.EntityInfo rawInfo, - Template.EntityInfo info, PlacementSettings settings, Template template) { + public StructureTemplate.StructureEntityInfo processEntity(LevelReader world, BlockPos pos, StructureTemplate.StructureEntityInfo rawInfo, + StructureTemplate.StructureEntityInfo info, StructurePlaceSettings settings, StructureTemplate template) { return EntityType.by(info.nbt).flatMap(type -> { - if (world instanceof World) { - Entity e = type.create((World) world); + if (world instanceof Level) { + Entity e = type.create((Level) world); if (e != null && !e.onlyOpCanSetNbt()) { return Optional.of(info); } @@ -63,7 +63,7 @@ public class SchematicProcessor extends StructureProcessor { } @Override - protected IStructureProcessorType getType() { + protected StructureProcessorType getType() { return TYPE; } 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 c06e3e938..2f0d6b19b 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java @@ -13,50 +13,50 @@ import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.worldWrappers.WrappedChunkProvider; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; -import net.minecraft.block.AbstractFurnaceBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ArmorStandEntity; -import net.minecraft.entity.item.ItemFrameEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.world.EmptyTickList; -import net.minecraft.world.IServerWorld; -import net.minecraft.world.ITickList; -import net.minecraft.world.LightType; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeRegistry; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.AbstractFurnaceBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.decoration.ArmorStand; +import net.minecraft.world.entity.decoration.ItemFrame; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.level.EmptyTickList; +import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.level.TickList; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.data.worldgen.biome.Biomes; +import net.minecraft.server.level.ServerLevel; -public class SchematicWorld extends WrappedWorld implements IServerWorld { +public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor { protected Map blocks; - protected Map tileEntities; - protected List renderedTileEntities; + protected Map tileEntities; + protected List renderedTileEntities; protected List entities; - protected MutableBoundingBox bounds; + protected BoundingBox bounds; public BlockPos anchor; public boolean renderMode; - public SchematicWorld(World original) { + public SchematicWorld(Level original) { this(BlockPos.ZERO, original); } - public SchematicWorld(BlockPos anchor, World original) { + public SchematicWorld(BlockPos anchor, Level original) { super(original, new WrappedChunkProvider()); this.blocks = new HashMap<>(); this.tileEntities = new HashMap<>(); - this.bounds = new MutableBoundingBox(); + this.bounds = new BoundingBox(); this.anchor = anchor; this.entities = new ArrayList<>(); this.renderedTileEntities = new ArrayList<>(); @@ -68,11 +68,11 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { @Override public boolean addFreshEntity(Entity entityIn) { - if (entityIn instanceof ItemFrameEntity) - ((ItemFrameEntity) entityIn).getItem() + if (entityIn instanceof ItemFrame) + ((ItemFrame) entityIn).getItem() .setTag(null); - if (entityIn instanceof ArmorStandEntity) { - ArmorStandEntity armorStandEntity = (ArmorStandEntity) entityIn; + if (entityIn instanceof ArmorStand) { + ArmorStand armorStandEntity = (ArmorStand) entityIn; armorStandEntity.getAllSlots() .forEach(stack -> stack.setTag(null)); } @@ -85,7 +85,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } @Override - public TileEntity getBlockEntity(BlockPos pos) { + public BlockEntity getBlockEntity(BlockPos pos) { if (isOutsideBuildHeight(pos)) return null; if (tileEntities.containsKey(pos)) @@ -96,7 +96,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { BlockState blockState = getBlockState(pos); if (blockState.hasTileEntity()) { try { - TileEntity tileEntity = blockState.createTileEntity(this); + BlockEntity tileEntity = blockState.createTileEntity(this); if (tileEntity != null) { onTEadded(tileEntity, pos); tileEntities.put(pos, tileEntity); @@ -110,7 +110,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { return null; } - protected void onTEadded(TileEntity tileEntity, BlockPos pos) { + protected void onTEadded(BlockEntity tileEntity, BlockPos pos) { tileEntity.setLevelAndPosition(this, pos); } @@ -136,27 +136,27 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { @Override public Biome getBiome(BlockPos pos) { - return BiomeRegistry.THE_VOID; + return Biomes.THE_VOID; } @Override - public int getBrightness(LightType p_226658_1_, BlockPos p_226658_2_) { + public int getBrightness(LightLayer p_226658_1_, BlockPos p_226658_2_) { return 10; } @Override - public List getEntities(Entity arg0, AxisAlignedBB arg1, Predicate arg2) { + public List getEntities(Entity arg0, AABB arg1, Predicate arg2) { return Collections.emptyList(); } @Override - public List getEntitiesOfClass(Class arg0, AxisAlignedBB arg1, + public List getEntitiesOfClass(Class arg0, AABB arg1, Predicate arg2) { return Collections.emptyList(); } @Override - public List players() { + public List players() { return Collections.emptyList(); } @@ -184,10 +184,10 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { public boolean setBlock(BlockPos pos, BlockState arg1, int arg2) { pos = pos.immutable() .subtract(anchor); - bounds.expand(new MutableBoundingBox(pos, pos)); + bounds.expand(new BoundingBox(pos, pos)); blocks.put(pos, arg1); if (tileEntities.containsKey(pos)) { - TileEntity tileEntity = tileEntities.get(pos); + BlockEntity tileEntity = tileEntities.get(pos); if (!tileEntity.getType() .isValid(arg1.getBlock())) { tileEntities.remove(pos); @@ -195,7 +195,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } } - TileEntity tileEntity = getBlockEntity(pos); + BlockEntity tileEntity = getBlockEntity(pos); if (tileEntity != null) tileEntities.put(pos, tileEntity); @@ -206,20 +206,20 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { public void sendBlockUpdated(BlockPos pos, BlockState oldState, BlockState newState, int flags) { } @Override - public ITickList getBlockTicks() { + public TickList getBlockTicks() { return EmptyTickList.empty(); } @Override - public ITickList getLiquidTicks() { + public TickList getLiquidTicks() { return EmptyTickList.empty(); } - public MutableBoundingBox getBounds() { + public BoundingBox getBounds() { return bounds; } - public Iterable getRenderedTileEntities() { + public Iterable getRenderedTileEntities() { return renderedTileEntities; } @@ -230,9 +230,9 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } @Override - public ServerWorld getLevel() { - if (this.world instanceof ServerWorld) { - return (ServerWorld) this.world; + public ServerLevel getLevel() { + if (this.world instanceof ServerLevel) { + return (ServerLevel) this.world; } throw new IllegalStateException("Cannot use IServerWorld#getWorld in a client environment"); } 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 e63010098..395cca83b 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java +++ b/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java @@ -23,32 +23,32 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.CSchematics; import com.simibubi.create.foundation.utility.FilesHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtIo; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class ServerSchematicLoader { private Map activeUploads; public class SchematicUploadEntry { - public World world; + public Level world; public BlockPos tablePos; public OutputStream stream; public long bytesUploaded; public long totalBytes; public int idleTime; - public SchematicUploadEntry(OutputStream stream, long totalBytes, World world, BlockPos tablePos) { + public SchematicUploadEntry(OutputStream stream, long totalBytes, Level world, BlockPos tablePos) { this.stream = stream; this.totalBytes = totalBytes; this.tablePos = tablePos; @@ -88,7 +88,7 @@ public class ServerSchematicLoader { new HashSet<>(activeUploads.keySet()).forEach(this::cancelUpload); } - public void handleNewUpload(ServerPlayerEntity player, String schematic, long size, BlockPos pos) { + public void handleNewUpload(ServerPlayer player, String schematic, long size, BlockPos pos) { String playerPath = getSchematicPath() + "/" + player.getGameProfile().getName(); String playerSchematicId = player.getGameProfile().getName() + "/" + schematic; FilesHelper.createFolderIfMissing(playerPath); @@ -154,13 +154,13 @@ public class ServerSchematicLoader { } } - protected boolean validateSchematicSizeOnServer(ServerPlayerEntity player, long size) { + protected boolean validateSchematicSizeOnServer(ServerPlayer player, long size) { Integer maxFileSize = getConfig().maxTotalSchematicSize.get(); if (size > maxFileSize * 1000) { - player.sendMessage(new TranslationTextComponent("create.schematics.uploadTooLarge") - .append(new StringTextComponent(" (" + size / 1000 + " KB).")), player.getUUID()); - player.sendMessage(new TranslationTextComponent("create.schematics.maxAllowedSize") - .append(new StringTextComponent(" " + maxFileSize + " KB")), player.getUUID()); + player.sendMessage(new TranslatableComponent("create.schematics.uploadTooLarge") + .append(new TextComponent(" (" + size / 1000 + " KB).")), player.getUUID()); + player.sendMessage(new TranslatableComponent("create.schematics.maxAllowedSize") + .append(new TextComponent(" " + maxFileSize + " KB")), player.getUUID()); return false; } return true; @@ -170,7 +170,7 @@ public class ServerSchematicLoader { return AllConfigs.SERVER.schematics; } - public void handleWriteRequest(ServerPlayerEntity player, String schematic, byte[] data) { + public void handleWriteRequest(ServerPlayer player, String schematic, byte[] data) { String playerSchematicId = player.getGameProfile().getName() + "/" + schematic; if (activeUploads.containsKey(playerSchematicId)) { @@ -232,22 +232,22 @@ public class ServerSchematicLoader { table.finishUpload(); } - public SchematicTableTileEntity getTable(World world, BlockPos pos) { - TileEntity te = world.getBlockEntity(pos); + public SchematicTableTileEntity getTable(Level world, BlockPos pos) { + BlockEntity te = world.getBlockEntity(pos); if (!(te instanceof SchematicTableTileEntity)) return null; SchematicTableTileEntity table = (SchematicTableTileEntity) te; return table; } - public void handleFinishedUpload(ServerPlayerEntity player, String schematic) { + public void handleFinishedUpload(ServerPlayer player, String schematic) { String playerSchematicId = player.getGameProfile().getName() + "/" + schematic; if (activeUploads.containsKey(playerSchematicId)) { try { activeUploads.get(playerSchematicId).stream.close(); SchematicUploadEntry removed = activeUploads.remove(playerSchematicId); - World world = removed.world; + Level world = removed.world; BlockPos pos = removed.tablePos; Create.LOGGER.info("New Schematic Uploaded: " + playerSchematicId); @@ -271,7 +271,7 @@ public class ServerSchematicLoader { } } - public void handleInstantSchematic(ServerPlayerEntity player, String schematic, World world, BlockPos pos, + public void handleInstantSchematic(ServerPlayer player, String schematic, Level world, BlockPos pos, BlockPos bounds) { String playerPath = getSchematicPath() + "/" + player.getGameProfile().getName(); String playerSchematicId = player.getGameProfile().getName() + "/" + schematic; @@ -315,14 +315,14 @@ public class ServerSchematicLoader { Files.deleteIfExists(lastFilePath.get()); } - Template t = new Template(); + StructureTemplate t = new StructureTemplate(); t.fillFromWorld(world, pos, bounds, true, Blocks.AIR); try (OutputStream outputStream = Files.newOutputStream(path)) { - CompoundNBT nbttagcompound = t.save(new CompoundNBT()); + CompoundTag nbttagcompound = t.save(new CompoundTag()); SchematicAndQuillItem.replaceStructureVoidWithAir(nbttagcompound); - CompressedStreamTools.writeCompressed(nbttagcompound, outputStream); - player.setItemInHand(Hand.MAIN_HAND, SchematicItem.create(schematic, player.getGameProfile().getName())); + NbtIo.writeCompressed(nbttagcompound, outputStream); + player.setItemInHand(InteractionHand.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 d542734bd..794dc913d 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 @@ -9,16 +9,16 @@ import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorIt import com.simibubi.create.content.contraptions.relays.elementary.AbstractShaftBlock; import com.simibubi.create.foundation.utility.BlockHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.Constants; public abstract class LaunchedItem { @@ -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.distSqr(start))) * 4f)); + return (int) (Math.max(10, Mth.sqrt(Mth.sqrt(target.distSqr(start))) * 4f)); } LaunchedItem() {} @@ -45,7 +45,7 @@ public abstract class LaunchedItem { this.ticksRemaining = ticksLeft; } - public boolean update(World world) { + public boolean update(Level world) { if (ticksRemaining > 0) { ticksRemaining--; return false; @@ -57,26 +57,26 @@ public abstract class LaunchedItem { return true; } - public CompoundNBT serializeNBT() { - CompoundNBT c = new CompoundNBT(); + public CompoundTag serializeNBT() { + CompoundTag c = new CompoundTag(); c.putInt("TotalTicks", totalTicks); c.putInt("TicksLeft", ticksRemaining); c.put("Stack", stack.serializeNBT()); - c.put("Target", NBTUtil.writeBlockPos(target)); + c.put("Target", NbtUtils.writeBlockPos(target)); return c; } - public static LaunchedItem fromNBT(CompoundNBT c) { + public static LaunchedItem fromNBT(CompoundTag c) { LaunchedItem launched = c.contains("Length") ? new LaunchedItem.ForBelt() : c.contains("BlockState") ? new LaunchedItem.ForBlockState() : new LaunchedItem.ForEntity(); launched.readNBT(c); return launched; } - abstract void place(World world); + abstract void place(Level world); - void readNBT(CompoundNBT c) { - target = NBTUtil.readBlockPos(c.getCompound("Target")); + void readNBT(CompoundTag c) { + target = NbtUtils.readBlockPos(c.getCompound("Target")); ticksRemaining = c.getInt("TicksLeft"); totalTicks = c.getInt("TotalTicks"); stack = ItemStack.of(c.getCompound("Stack")); @@ -84,20 +84,20 @@ public abstract class LaunchedItem { public static class ForBlockState extends LaunchedItem { public BlockState state; - public CompoundNBT data; + public CompoundTag data; ForBlockState() {} - public ForBlockState(BlockPos start, BlockPos target, ItemStack stack, BlockState state, CompoundNBT data) { + public ForBlockState(BlockPos start, BlockPos target, ItemStack stack, BlockState state, CompoundTag data) { super(start, target, stack); this.state = state; this.data = data; } @Override - public CompoundNBT serializeNBT() { - CompoundNBT serializeNBT = super.serializeNBT(); - serializeNBT.put("BlockState", NBTUtil.writeBlockState(state)); + public CompoundTag serializeNBT() { + CompoundTag serializeNBT = super.serializeNBT(); + serializeNBT.put("BlockState", NbtUtils.writeBlockState(state)); if (data != null) { data.remove("x"); data.remove("y"); @@ -109,16 +109,16 @@ public abstract class LaunchedItem { } @Override - void readNBT(CompoundNBT nbt) { + void readNBT(CompoundTag nbt) { super.readNBT(nbt); - state = NBTUtil.readBlockState(nbt.getCompound("BlockState")); + state = NbtUtils.readBlockState(nbt.getCompound("BlockState")); if (nbt.contains("Data", Constants.NBT.TAG_COMPOUND)) { data = nbt.getCompound("Data"); } } @Override - void place(World world) { + void place(Level world) { BlockHelper.placeSchematicBlock(world, state, target, stack, data); } @@ -130,14 +130,14 @@ public abstract class LaunchedItem { public ForBelt() {} @Override - public CompoundNBT serializeNBT() { - CompoundNBT serializeNBT = super.serializeNBT(); + public CompoundTag serializeNBT() { + CompoundTag serializeNBT = super.serializeNBT(); serializeNBT.putInt("Length", length); return serializeNBT; } @Override - void readNBT(CompoundNBT nbt) { + void readNBT(CompoundTag nbt) { length = nbt.getInt("Length"); super.readNBT(nbt); } @@ -148,7 +148,7 @@ public abstract class LaunchedItem { } @Override - void place(World world) { + void place(Level world) { // todo place belt boolean isStart = state.getValue(BeltBlock.PART) == BeltPart.START; BlockPos offset = BeltBlock.nextSegmentPosition(state, BlockPos.ZERO, isStart); @@ -163,7 +163,7 @@ public abstract class LaunchedItem { public static class ForEntity extends LaunchedItem { public Entity entity; - private CompoundNBT deferredTag; + private CompoundTag deferredTag; ForEntity() {} @@ -173,7 +173,7 @@ public abstract class LaunchedItem { } @Override - public boolean update(World world) { + public boolean update(Level world) { if (deferredTag != null && entity == null) { try { Optional loadEntityUnchecked = EntityType.create(deferredTag, world); @@ -189,22 +189,22 @@ public abstract class LaunchedItem { } @Override - public CompoundNBT serializeNBT() { - CompoundNBT serializeNBT = super.serializeNBT(); + public CompoundTag serializeNBT() { + CompoundTag serializeNBT = super.serializeNBT(); if (entity != null) serializeNBT.put("Entity", entity.serializeNBT()); return serializeNBT; } @Override - void readNBT(CompoundNBT nbt) { + void readNBT(CompoundTag nbt) { super.readNBT(nbt); if (nbt.contains("Entity")) deferredTag = nbt.getCompound("Entity"); } @Override - void place(World world) { + void place(Level world) { 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 9ec819e8a..973ff0c32 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 @@ -5,27 +5,29 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.item.ItemHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.network.NetworkHooks; -public class SchematicTableBlock extends HorizontalBlock implements ITE { +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +public class SchematicTableBlock extends HorizontalDirectionalBlock implements ITE { public SchematicTableBlock(Properties properties) { super(properties); @@ -43,18 +45,18 @@ public class SchematicTableBlock extends HorizontalBlock implements ITE NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer)); - return ActionResultType.SUCCESS; + te -> NetworkHooks.openGui((ServerPlayer) player, te, te::sendToContainer)); + return InteractionResult.SUCCESS; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { + public BlockEntity createTileEntity(BlockState state, BlockGetter world) { return AllTileEntities.SCHEMATIC_TABLE.create(); } @Override - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (!state.hasTileEntity() || state.getBlock() == newState.getBlock()) return; @@ -94,7 +96,7 @@ public class SchematicTableBlock extends HorizontalBlock implements ITE type, int id, PlayerInventory inv, PacketBuffer extraData) { + public SchematicTableContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { super(type, id); player = inv.player; - ClientWorld world = Minecraft.getInstance().level; - TileEntity tileEntity = world.getBlockEntity(extraData.readBlockPos()); + ClientLevel world = Minecraft.getInstance().level; + BlockEntity tileEntity = world.getBlockEntity(extraData.readBlockPos()); if (tileEntity instanceof SchematicTableTileEntity) { this.te = (SchematicTableTileEntity) tileEntity; this.te.handleUpdateTag(te.getBlockState(), extraData.readNbt()); @@ -34,14 +34,14 @@ public class SchematicTableContainer extends Container { } } - public SchematicTableContainer(ContainerType type, int id, PlayerInventory inv, SchematicTableTileEntity te) { + public SchematicTableContainer(MenuType type, int id, Inventory inv, SchematicTableTileEntity te) { super(type, id); this.player = inv.player; this.te = te; init(); } - public static SchematicTableContainer create(int id, PlayerInventory inv, SchematicTableTileEntity te) { + public static SchematicTableContainer create(int id, Inventory inv, SchematicTableTileEntity te) { return new SchematicTableContainer(AllContainerTypes.SCHEMATIC_TABLE.get(), id, inv, te); } @@ -83,12 +83,12 @@ public class SchematicTableContainer extends Container { } @Override - public boolean stillValid(PlayerEntity player) { + public boolean stillValid(Player player) { return te != null && te.canPlayerUse(player); } @Override - public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(Player playerIn, int index) { Slot clickedSlot = getSlot(index); if (!clickedSlot.hasItem()) 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 deac70f34..9db75bbb9 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 @@ -8,7 +8,7 @@ import java.util.Collections; import java.util.List; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateClient; @@ -23,18 +23,18 @@ import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Util; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.Util; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class SchematicTableScreen extends AbstractSimiContainerScreen { protected AllGuiTextures background; - private List extraAreas = Collections.emptyList(); + private List extraAreas = Collections.emptyList(); private ScrollInput schematicsArea; private IconButton confirmButton; @@ -42,20 +42,20 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = CreateClient.SCHEMATIC_SENDER.getAvailableSchematics(); + List availableSchematics = CreateClient.SCHEMATIC_SENDER.getAvailableSchematics(); int x = leftPos; int y = topPos; - schematicsLabel = new Label(x + 49, y + 26, StringTextComponent.EMPTY).withShadow(); - schematicsLabel.text = StringTextComponent.EMPTY; + schematicsLabel = new Label(x + 49, y + 26, TextComponent.EMPTY).withShadow(); + schematicsLabel.text = TextComponent.EMPTY; if (!availableSchematics.isEmpty()) { schematicsArea = new SelectionScrollInput(x + 45, y + 21, 139, 18).forOptions(availableSchematics) @@ -96,13 +96,13 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = schematicSender.getAvailableSchematics(); - ITextComponent schematic = availableSchematics.get(schematicsArea.getState()); + List availableSchematics = schematicSender.getAvailableSchematics(); + Component schematic = availableSchematics.get(schematicsArea.getState()); schematicSender.startNewUpload(schematic.getContents()); } @@ -198,7 +198,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = schematicSender.getAvailableSchematics(); + List availableSchematics = schematicSender.getAvailableSchematics(); widgets.remove(schematicsArea); if (!availableSchematics.isEmpty()) { @@ -210,7 +210,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen getExtraAreas() { + public List getExtraAreas() { return extraAreas; } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableTileEntity.java index c0490c1f7..40c7d795c 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableTileEntity.java @@ -4,20 +4,20 @@ import com.simibubi.create.foundation.gui.IInteractionChecker; import com.simibubi.create.foundation.tileEntity.SyncedTileEntity; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.TickableBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.network.chat.Component; import net.minecraftforge.items.ItemStackHandler; -public class SchematicTableTileEntity extends SyncedTileEntity implements ITickableTileEntity, INamedContainerProvider, IInteractionChecker { +public class SchematicTableTileEntity extends SyncedTileEntity implements TickableBlockEntity, MenuProvider, IInteractionChecker { public SchematicTableInventory inventory; public boolean isUploading; @@ -37,27 +37,27 @@ public class SchematicTableTileEntity extends SyncedTileEntity implements ITicka } } - public SchematicTableTileEntity(TileEntityType tileEntityTypeIn) { + public SchematicTableTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); inventory = new SchematicTableInventory(); uploadingSchematic = null; uploadingProgress = 0; } - public void sendToContainer(PacketBuffer buffer) { + public void sendToContainer(FriendlyByteBuf buffer) { buffer.writeBlockPos(getBlockPos()); buffer.writeNbt(getUpdateTag()); } @Override - public void load(BlockState state, CompoundNBT compound) { + public void load(BlockState state, CompoundTag compound) { inventory.deserializeNBT(compound.getCompound("Inventory")); readClientUpdate(state, compound); super.load(state, compound); } @Override - public void readClientUpdate(BlockState state, CompoundNBT compound) { + public void readClientUpdate(BlockState state, CompoundTag compound) { if (compound.contains("Uploading")) { isUploading = true; uploadingSchematic = compound.getString("Schematic"); @@ -70,14 +70,14 @@ public class SchematicTableTileEntity extends SyncedTileEntity implements ITicka } @Override - public CompoundNBT save(CompoundNBT compound) { + public CompoundTag save(CompoundTag compound) { compound.put("Inventory", inventory.serializeNBT()); writeToClient(compound); return super.save(compound); } @Override - public CompoundNBT writeToClient(CompoundNBT compound) { + public CompoundTag writeToClient(CompoundTag compound) { if (isUploading) { compound.putBoolean("Uploading", true); compound.putString("Schematic", uploadingSchematic); @@ -111,17 +111,17 @@ public class SchematicTableTileEntity extends SyncedTileEntity implements ITicka } @Override - public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) { return SchematicTableContainer.create(id, inv, this); } @Override - public ITextComponent getDisplayName() { + public Component getDisplayName() { return Lang.translate("gui.schematicTable.title"); } @Override - public boolean canPlayerUse(PlayerEntity player) { + public boolean canPlayerUse(Player player) { if (level == null || level.getBlockEntity(worldPosition) != this) { return false; } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonBlock.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonBlock.java index 706b29bb5..415761e85 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonBlock.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonBlock.java @@ -5,22 +5,24 @@ import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.item.ItemHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + public class SchematicannonBlock extends Block implements ITE { public SchematicannonBlock(Properties properties) { @@ -33,7 +35,7 @@ public class SchematicannonBlock extends Block implements ITE NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer)); - return ActionResultType.SUCCESS; + te -> NetworkHooks.openGui((ServerPlayer) player, te, te::sendToContainer)); + return InteractionResult.SUCCESS; } @Override - public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (!state.hasTileEntity() || state.getBlock() == newState.getBlock()) return; @@ -72,7 +74,7 @@ public class SchematicannonBlock extends Block implements ITE te.neighbourCheckCooldown = 0); } 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 d58a88a24..cfcf0b9ec 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 @@ -3,27 +3,27 @@ package com.simibubi.create.content.schematics.block; import com.simibubi.create.AllContainerTypes; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.items.SlotItemHandler; -public class SchematicannonContainer extends Container { +public class SchematicannonContainer extends AbstractContainerMenu { private SchematicannonTileEntity te; - private PlayerEntity player; + private Player player; - public SchematicannonContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer buffer) { + public SchematicannonContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf buffer) { super(type, id); player = inv.player; - ClientWorld world = Minecraft.getInstance().level; - TileEntity tileEntity = world.getBlockEntity(buffer.readBlockPos()); + ClientLevel world = Minecraft.getInstance().level; + BlockEntity tileEntity = world.getBlockEntity(buffer.readBlockPos()); if (tileEntity instanceof SchematicannonTileEntity) { this.te = (SchematicannonTileEntity) tileEntity; this.te.handleUpdateTag(te.getBlockState(), buffer.readNbt()); @@ -31,14 +31,14 @@ public class SchematicannonContainer extends Container { } } - public SchematicannonContainer(ContainerType type, int id, PlayerInventory inv, SchematicannonTileEntity te) { + public SchematicannonContainer(MenuType type, int id, Inventory inv, SchematicannonTileEntity te) { super(type, id); player = inv.player; this.te = te; init(); } - public static SchematicannonContainer create(int id, PlayerInventory inv, SchematicannonTileEntity te) { + public static SchematicannonContainer create(int id, Inventory inv, SchematicannonTileEntity te) { return new SchematicannonContainer(AllContainerTypes.SCHEMATICANNON.get(), id, inv, te); } @@ -66,12 +66,12 @@ public class SchematicannonContainer extends Container { } @Override - public boolean stillValid(PlayerEntity player) { + public boolean stillValid(Player player) { return te != null && te.canPlayerUse(player); } @Override - public void removed(PlayerEntity playerIn) { + public void removed(Player playerIn) { super.removed(playerIn); } @@ -80,7 +80,7 @@ public class SchematicannonContainer extends Container { } @Override - public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(Player playerIn, int index) { Slot clickedSlot = getSlot(index); if (!clickedSlot.hasItem()) return ItemStack.EMPTY; 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 72811865e..c86932304 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 @@ -12,6 +12,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.Direction; +import ModelData; + public class SchematicannonInstance extends TileEntityInstance implements IDynamicInstance { private final ModelData connector; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInventory.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInventory.java index b56b28f63..e7252dd8f 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInventory.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInventory.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.schematics.block; import com.simibubi.create.AllItems; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraftforge.items.ItemStackHandler; public class SchematicannonInventory extends ItemStackHandler { diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java index d8473799d..4a8b00577 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java @@ -3,8 +3,8 @@ package com.simibubi.create.content.schematics.block; import java.util.Random; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.schematics.block.LaunchedItem.ForBlockState; import com.simibubi.create.content.schematics.block.LaunchedItem.ForEntity; @@ -12,24 +12,24 @@ import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; import net.minecraftforge.client.model.data.EmptyModelData; public class SchematicannonRenderer extends SafeTileEntityRenderer { - public SchematicannonRenderer(TileEntityRendererDispatcher dispatcher) { + public SchematicannonRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @@ -39,8 +39,8 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer extraAreas = Collections.emptyList(); - protected List placementSettingWidgets; + private List extraAreas = Collections.emptyList(); + protected List placementSettingWidgets; - private final ITextComponent listPrinter = Lang.translate("gui.schematicannon.listPrinter"); + private final Component listPrinter = Lang.translate("gui.schematicannon.listPrinter"); private final String _gunpowderLevel = "gui.schematicannon.gunpowderLevel"; private final String _shotsRemaining = "gui.schematicannon.shotsRemaining"; private final String _showSettings = "gui.schematicannon.showOptions"; @@ -68,8 +95,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen(); } @@ -95,11 +122,11 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen(4); List icons = ImmutableList.of(AllIcons.I_DONT_REPLACE, AllIcons.I_REPLACE_SOLID, AllIcons.I_REPLACE_ANY, AllIcons.I_REPLACE_EMPTY); - List toolTips = ImmutableList.of(Lang.translate("gui.schematicannon.option.dontReplaceSolid"), + List toolTips = ImmutableList.of(Lang.translate("gui.schematicannon.option.dontReplaceSolid"), Lang.translate("gui.schematicannon.option.replaceWithSolid"), Lang.translate("gui.schematicannon.option.replaceWithAny"), Lang.translate("gui.schematicannon.option.replaceWithEmpty")); for (int i = 0; i < 4; i++) { - replaceLevelIndicators.add(new Indicator(x + 33 + i * 18, y + 111, StringTextComponent.EMPTY)); + replaceLevelIndicators.add(new Indicator(x + 33 + i * 18, y + 111, TextComponent.EMPTY)); replaceLevelButtons.add(new IconButton(x + 33 + i * 18, y + 117, icons.get(i))); replaceLevelButtons.get(i) .setToolTip(toolTips.get(i)); @@ -151,12 +178,12 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen tip = button.getToolTip(); + List tip = button.getToolTip(); tip.add((enabled ? optionEnabled : optionDisabled).plainCopy().withStyle(BLUE)); tip.addAll(TooltipHelper.cutTextComponent(Lang.translate("gui.schematicannon.option." + tooltipKey + ".description"), GRAY, GRAY)); } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int invX = getLeftOfCentered(AllGuiTextures.PLAYER_INVENTORY.width); int invY = topPos + BG_TOP.height + BG_BOTTOM.height + 2; renderPlayerInventory(ms, invX, invY); @@ -273,7 +300,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen= fuelX && mouseY >= fuelY && mouseX <= fuelX + AllGuiTextures.SCHEMATICANNON_FUEL.width && mouseY <= fuelY + AllGuiTextures.SCHEMATICANNON_FUEL.height) { - List tooltip = getFuelLevelTooltip(te); + List tooltip = getFuelLevelTooltip(te); renderComponentTooltip(matrixStack, tooltip, mouseX, mouseY); } if (hoveredSlot != null && !hoveredSlot.hasItem()) { if (hoveredSlot.index == 0) renderComponentTooltip(matrixStack, - TooltipHelper.cutTextComponent(Lang.translate(_slotSchematic), GRAY, TextFormatting.BLUE), + TooltipHelper.cutTextComponent(Lang.translate(_slotSchematic), GRAY, ChatFormatting.BLUE), mouseX, mouseY); if (hoveredSlot.index == 2) renderComponentTooltip(matrixStack, - TooltipHelper.cutTextComponent(Lang.translate(_slotListPrinter), GRAY, TextFormatting.BLUE), + TooltipHelper.cutTextComponent(Lang.translate(_slotListPrinter), GRAY, ChatFormatting.BLUE), mouseX, mouseY); if (hoveredSlot.index == 4) renderComponentTooltip(matrixStack, - TooltipHelper.cutTextComponent(Lang.translate(_slotGunpowder), GRAY, TextFormatting.BLUE), + TooltipHelper.cutTextComponent(Lang.translate(_slotGunpowder), GRAY, ChatFormatting.BLUE), mouseX, mouseY); } @@ -361,25 +388,25 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen getFuelLevelTooltip(SchematicannonTileEntity te) { + protected List getFuelLevelTooltip(SchematicannonTileEntity te) { double fuelUsageRate = te.getFuelUsageRate(); int shotsLeft = (int) (te.fuelLevel / fuelUsageRate); int shotsLeftWithItems = (int) (shotsLeft + te.inventory.getStackInSlot(4) .getCount() * (te.getFuelAddedByGunPowder() / fuelUsageRate)); - List tooltip = new ArrayList<>(); + List tooltip = new ArrayList<>(); if (te.hasCreativeCrate) { tooltip.add(Lang.translate(_gunpowderLevel, "" + 100)); - tooltip.add(new StringTextComponent("(").append(new TranslationTextComponent(AllBlocks.CREATIVE_CRATE.get() + tooltip.add(new TextComponent("(").append(new TranslatableComponent(AllBlocks.CREATIVE_CRATE.get() .getDescriptionId())).append(")").withStyle(DARK_PURPLE)); return tooltip; } int fillPercent = (int) (te.fuelLevel * 100); tooltip.add(Lang.translate(_gunpowderLevel, fillPercent)); - tooltip.add(Lang.translate(_shotsRemaining, new StringTextComponent(Integer.toString(shotsLeft)).withStyle(BLUE)).withStyle(GRAY)); + tooltip.add(Lang.translate(_shotsRemaining, new TextComponent(Integer.toString(shotsLeft)).withStyle(BLUE)).withStyle(GRAY)); if (shotsLeftWithItems != shotsLeft) - tooltip.add(Lang.translate(_shotsRemainingWithBackup, new StringTextComponent(Integer.toString(shotsLeftWithItems)).withStyle(BLUE)).withStyle(GRAY)); + tooltip.add(Lang.translate(_shotsRemainingWithBackup, new TextComponent(Integer.toString(shotsLeftWithItems)).withStyle(BLUE)).withStyle(GRAY)); return tooltip; } @@ -422,7 +449,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen getExtraAreas() { + public List getExtraAreas() { return extraAreas; } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index 5521a1475..ff9ea82cd 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -31,31 +31,31 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTProcessors; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.PistonHeadBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.state.properties.BedPart; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.piston.PistonHeadBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.state.properties.BedPart; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; @@ -64,7 +64,7 @@ import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.wrapper.EmptyHandler; -public class SchematicannonTileEntity extends SmartTileEntity implements INamedContainerProvider, IInstanceRendered { +public class SchematicannonTileEntity extends SmartTileEntity implements MenuProvider, IInstanceRendered { public static final int NEIGHBOUR_CHECKING = 100; public static final int MAX_ANCHOR_DISTANCE = 256; @@ -113,7 +113,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC public boolean firstRenderTick; @Override - public AxisAlignedBB getRenderBoundingBox() { + public AABB getRenderBoundingBox() { return INFINITE_EXTENT_AABB; } @@ -123,7 +123,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC return super.getViewDistance() * 16; } - public SchematicannonTileEntity(TileEntityType tileEntityTypeIn) { + public SchematicannonTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); setLazyTickRate(30); attachedInventories = new LinkedHashSet<>(); @@ -147,7 +147,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC if (AllBlocks.CREATIVE_CRATE.has(level.getBlockState(worldPosition.relative(facing)))) hasCreativeCrate = true; - TileEntity tileEntity = level.getBlockEntity(worldPosition.relative(facing)); + BlockEntity tileEntity = level.getBlockEntity(worldPosition.relative(facing)); if (tileEntity != null) { LazyOptional capability = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); @@ -159,7 +159,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } @Override - protected void fromTag(BlockState blockState, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState blockState, CompoundTag compound, boolean clientPacket) { if (!clientPacket) { inventory.deserializeNBT(compound.getCompound("Inventory")); } @@ -178,7 +178,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC missingItem = ItemStack.of(compound.getCompound("MissingItem")); // Settings - CompoundNBT options = compound.getCompound("Options"); + CompoundTag options = compound.getCompound("Options"); replaceMode = options.getInt("ReplaceMode"); skipMissing = options.getBoolean("SkipMissing"); replaceTileEntities = options.getBoolean("ReplaceTileEntities"); @@ -192,15 +192,15 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC super.fromTag(blockState, compound, clientPacket); } - protected void readFlyingBlocks(CompoundNBT compound) { - ListNBT tagBlocks = compound.getList("FlyingBlocks", 10); + protected void readFlyingBlocks(CompoundTag compound) { + ListTag tagBlocks = compound.getList("FlyingBlocks", 10); if (tagBlocks.isEmpty()) flyingBlocks.clear(); boolean pastDead = false; for (int i = 0; i < tagBlocks.size(); i++) { - CompoundNBT c = tagBlocks.getCompound(i); + CompoundTag c = tagBlocks.getCompound(i); LaunchedItem launched = LaunchedItem.fromNBT(c); BlockPos readBlockPos = launched.target; @@ -228,7 +228,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } @Override - public void write(CompoundNBT compound, boolean clientPacket) { + public void write(CompoundTag compound, boolean clientPacket) { if (!clientPacket) { compound.put("Inventory", inventory.serializeNBT()); if (state == State.RUNNING) { @@ -249,18 +249,18 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC compound.put("MissingItem", missingItem.serializeNBT()); // Settings - CompoundNBT options = new CompoundNBT(); + CompoundTag options = new CompoundTag(); options.putInt("ReplaceMode", replaceMode); options.putBoolean("SkipMissing", skipMissing); options.putBoolean("ReplaceTileEntities", replaceTileEntities); compound.put("Options", options); // Printer & Flying Blocks - CompoundNBT printerData = new CompoundNBT(); + CompoundTag printerData = new CompoundTag(); printer.write(printerData); compound.put("Printer", printerData); - ListNBT tagFlyingBlocks = new ListNBT(); + ListTag tagFlyingBlocks = new ListTag(); for (LaunchedItem b : flyingBlocks) tagFlyingBlocks.add(b.serializeNBT()); compound.put("FlyingBlocks", tagFlyingBlocks); @@ -575,7 +575,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC blocksToPlace = 0; } - protected boolean shouldPlace(BlockPos pos, BlockState state, TileEntity te, + protected boolean shouldPlace(BlockPos pos, BlockState state, BlockEntity te, BlockState toReplace, BlockState toReplaceOther, boolean isNormalCube) { if (pos.closerThan(getBlockPos(), 2f)) return false; @@ -604,7 +604,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC return false; } - protected boolean shouldIgnoreBlockState(BlockState state, TileEntity te) { + protected boolean shouldIgnoreBlockState(BlockState state, BlockEntity te) { // Block doesnt have a mapping (Water, lava, etc) if (state.getBlock() == Blocks.STRUCTURE_VOID) return true; @@ -725,7 +725,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC return blockState; } - protected void launchBlockOrBelt(BlockPos target, ItemStack icon, BlockState blockState, TileEntity tile) { + protected void launchBlockOrBelt(BlockPos target, ItemStack icon, BlockState blockState, BlockEntity tile) { if (AllBlocks.BELT.has(blockState)) { blockState = stripBeltIfNotLast(blockState); if (tile instanceof BeltTileEntity && AllBlocks.BELT.has(blockState)) @@ -733,13 +733,13 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC else launchBlock(target, icon, blockState, null); } else { - CompoundNBT data = null; + CompoundTag data = null; if (tile != null) { if (AllBlockTags.SAFE_NBT.matches(blockState)) { - data = tile.save(new CompoundNBT()); + data = tile.save(new CompoundTag()); data = NBTProcessors.process(tile, data, true); } else if (tile instanceof IPartialSafeNBT) { - data = new CompoundNBT(); + data = new CompoundTag(); ((IPartialSafeNBT) tile).writeSafe(data, false); data = NBTProcessors.process(tile, data, true); } @@ -755,7 +755,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC playFiringSound(); } - protected void launchBlock(BlockPos target, ItemStack stack, BlockState state, @Nullable CompoundNBT data) { + protected void launchBlock(BlockPos target, ItemStack stack, BlockState state, @Nullable CompoundTag data) { if (!state.getBlock().isAir(state, level, target)) blocksPlaced++; flyingBlocks.add(new LaunchedItem.ForBlockState(this.getBlockPos(), target, stack, state, data)); @@ -772,18 +772,18 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC AllSoundEvents.SCHEMATICANNON_LAUNCH_BLOCK.playOnServer(level, worldPosition); } - public void sendToContainer(PacketBuffer buffer) { + public void sendToContainer(FriendlyByteBuf buffer) { buffer.writeBlockPos(getBlockPos()); buffer.writeNbt(getUpdateTag()); } @Override - public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) { return SchematicannonContainer.create(id, inv, this); } @Override - public ITextComponent getDisplayName() { + public Component getDisplayName() { return Lang.translate("gui.schematicannon.title"); } 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 7cf0cda24..e174ae056 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 @@ -27,25 +27,25 @@ import com.simibubi.create.foundation.utility.RaycastHelper.PredicateTraceResult import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.outliner.Outliner; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.Hand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtIo; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class SchematicAndQuillHandler { @@ -63,13 +63,13 @@ public class SchematicAndQuillHandler { if (!AllKeys.ctrlDown()) return false; if (secondPos == null) - range = (int) MathHelper.clamp(range + delta, 1, 100); + range = (int) Mth.clamp(range + delta, 1, 100); if (selectedFace == null) return true; - AxisAlignedBB bb = new AxisAlignedBB(firstPos, secondPos); - Vector3i vec = selectedFace.getNormal(); - Vector3d projectedView = Minecraft.getInstance().gameRenderer.getMainCamera() + AABB bb = new AABB(firstPos, secondPos); + Vec3i vec = selectedFace.getNormal(); + Vec3 projectedView = Minecraft.getInstance().gameRenderer.getMainCamera() .getPosition(); if (bb.contains(projectedView)) delta *= -1; @@ -85,7 +85,7 @@ public class SchematicAndQuillHandler { 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); + bb = new AABB(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); @@ -101,7 +101,7 @@ public class SchematicAndQuillHandler { if (!isActive()) return; - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (player.isShiftKeyDown()) { discard(); @@ -129,7 +129,7 @@ public class SchematicAndQuillHandler { } public void discard() { - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; firstPos = null; secondPos = null; Lang.sendStatus(player, "schematicAndQuill.abort"); @@ -139,21 +139,21 @@ public class SchematicAndQuillHandler { if (!isActive()) return; - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (AllKeys.ACTIVATE_TOOL.isPressed()) { float pt = AnimationTickHolder.getPartialTicks(); - Vector3d targetVec = player.getEyePosition(pt) + Vec3 targetVec = player.getEyePosition(pt) .add(player.getLookAngle() .scale(range)); selectedPos = new BlockPos(targetVec); } else { - BlockRayTraceResult trace = RaycastHelper.rayTraceRange(player.level, player, 75); + BlockHitResult trace = RaycastHelper.rayTraceRange(player.level, player, 75); if (trace != null && trace.getType() == Type.BLOCK) { BlockPos hit = trace.getBlockPos(); boolean replaceable = player.level.getBlockState(hit) - .canBeReplaced(new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, trace))); + .canBeReplaced(new BlockPlaceContext(new UseOnContext(player, InteractionHand.MAIN_HAND, trace))); if (trace.getDirection() .getAxis() .isVertical() && !replaceable) @@ -165,9 +165,9 @@ public class SchematicAndQuillHandler { selectedFace = null; if (secondPos != null) { - AxisAlignedBB bb = new AxisAlignedBB(firstPos, secondPos).expandTowards(1, 1, 1) + AABB bb = new AABB(firstPos, secondPos).expandTowards(1, 1, 1) .inflate(.45f); - Vector3d projectedView = Minecraft.getInstance().gameRenderer.getMainCamera() + Vec3 projectedView = Minecraft.getInstance().gameRenderer.getMainCamera() .getPosition(); boolean inside = bb.contains(projectedView); PredicateTraceResult result = @@ -177,7 +177,7 @@ public class SchematicAndQuillHandler { .getOpposite() : result.getFacing(); } - AxisAlignedBB currentSelectionBox = getCurrentSelectionBox(); + AABB currentSelectionBox = getCurrentSelectionBox(); if (currentSelectionBox != null) outliner().chaseAABB(outlineSlot, currentSelectionBox) .colored(0x6886c5) @@ -186,14 +186,14 @@ public class SchematicAndQuillHandler { .highlightFace(selectedFace); } - private AxisAlignedBB getCurrentSelectionBox() { + private AABB getCurrentSelectionBox() { if (secondPos == null) { if (firstPos == null) - return selectedPos == null ? null : new AxisAlignedBB(selectedPos); - return selectedPos == null ? new AxisAlignedBB(firstPos) - : new AxisAlignedBB(firstPos, selectedPos).expandTowards(1, 1, 1); + return selectedPos == null ? null : new AABB(selectedPos); + return selectedPos == null ? new AABB(firstPos) + : new AABB(firstPos, selectedPos).expandTowards(1, 1, 1); } - return new AxisAlignedBB(firstPos, secondPos).expandTowards(1, 1, 1); + return new AABB(firstPos, secondPos).expandTowards(1, 1, 1); } private boolean isActive() { @@ -206,8 +206,8 @@ public class SchematicAndQuillHandler { } public void saveSchematic(String string, boolean convertImmediately) { - Template t = new Template(); - MutableBoundingBox bb = new MutableBoundingBox(firstPos, secondPos); + StructureTemplate t = new StructureTemplate(); + BoundingBox bb = new BoundingBox(firstPos, secondPos); BlockPos origin = new BlockPos(bb.x0, bb.y0, bb.z0); BlockPos bounds = new BlockPos(bb.getXSpan(), bb.getYSpan(), bb.getZSpan()); @@ -226,9 +226,9 @@ public class SchematicAndQuillHandler { OutputStream outputStream = null; try { outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE); - CompoundNBT nbttagcompound = t.save(new CompoundNBT()); + CompoundTag nbttagcompound = t.save(new CompoundTag()); SchematicAndQuillItem.replaceStructureVoidWithAir(nbttagcompound); - CompressedStreamTools.writeCompressed(nbttagcompound, outputStream); + NbtIo.writeCompressed(nbttagcompound, outputStream); } catch (IOException e) { e.printStackTrace(); } finally { 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 4d2f11747..93b901315 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.schematics.client; import java.util.Collections; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.gui.AbstractSimiScreen; @@ -16,31 +16,31 @@ import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.gen.feature.template.PlacementSettings; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; public class SchematicEditScreen extends AbstractSimiScreen { private AllGuiTextures background; - private TextFieldWidget xInput; - private TextFieldWidget yInput; - private TextFieldWidget zInput; + private EditBox xInput; + private EditBox yInput; + private EditBox zInput; private IconButton confirmButton; - private final List rotationOptions = + private final List rotationOptions = Lang.translatedOptions("schematic.rotation", "none", "cw90", "cw180", "cw270"); - private final List mirrorOptions = + private final List mirrorOptions = Lang.translatedOptions("schematic.mirror", "none", "leftRight", "frontBack"); - private final ITextComponent rotationLabel = Lang.translate("schematic.rotation"); - private final ITextComponent mirrorLabel = Lang.translate("schematic.mirror"); + private final Component rotationLabel = Lang.translate("schematic.rotation"); + private final Component mirrorLabel = Lang.translate("schematic.mirror"); private ScrollInput rotationArea; private ScrollInput mirrorArea; @@ -62,9 +62,9 @@ public class SchematicEditScreen extends AbstractSimiScreen { int x = guiLeft; int y = guiTop; - 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); + xInput = new EditBox(font, x + 50, y + 26, 34, 10, TextComponent.EMPTY); + yInput = new EditBox(font, x + 90, y + 26, 34, 10, TextComponent.EMPTY); + zInput = new EditBox(font, x + 130, y + 26, 34, 10, TextComponent.EMPTY); BlockPos anchor = handler.getTransformation() .getAnchor(); @@ -79,7 +79,7 @@ public class SchematicEditScreen extends AbstractSimiScreen { zInput.setValue("" + alt.getZ()); } - for (TextFieldWidget widget : new TextFieldWidget[] { xInput, yInput, zInput }) { + for (EditBox widget : new EditBox[] { xInput, yInput, zInput }) { widget.setMaxLength(6); widget.setBordered(false); widget.setTextColor(0xFFFFFF); @@ -97,16 +97,16 @@ public class SchematicEditScreen extends AbstractSimiScreen { }); } - PlacementSettings settings = handler.getTransformation() + StructurePlaceSettings settings = handler.getTransformation() .toSettings(); - Label labelR = new Label(x + 50, y + 48, StringTextComponent.EMPTY).withShadow(); + Label labelR = new Label(x + 50, y + 48, TextComponent.EMPTY).withShadow(); rotationArea = new SelectionScrollInput(x + 45, y + 43, 118, 18).forOptions(rotationOptions) .titled(rotationLabel.plainCopy()) .setState(settings.getRotation() .ordinal()) .writingTo(labelR); - Label labelM = new Label(x + 50, y + 70, StringTextComponent.EMPTY).withShadow(); + Label labelM = new Label(x + 50, y + 70, TextComponent.EMPTY).withShadow(); mirrorArea = new SelectionScrollInput(x + 45, y + 65, 118, 18).forOptions(mirrorOptions) .titled(mirrorLabel.plainCopy()) .setState(settings.getMirror() @@ -151,7 +151,7 @@ public class SchematicEditScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int x = guiLeft; int y = guiTop; @@ -176,7 +176,7 @@ public class SchematicEditScreen extends AbstractSimiScreen { validCoords = false; } - PlacementSettings settings = new PlacementSettings(); + StructurePlaceSettings settings = new StructurePlaceSettings(); settings.setRotation(Rotation.values()[rotationArea.getState()]); settings.setMirror(Mirror.values()[mirrorArea.getState()]); @@ -186,7 +186,7 @@ public class SchematicEditScreen extends AbstractSimiScreen { item.getTag() .putBoolean("Deployed", true); item.getTag() - .put("Anchor", NBTUtil.writeBlockPos(newLocation)); + .put("Anchor", NbtUtils.writeBlockPos(newLocation)); } handler.getTransformation() 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 ded000796..5e0da1aa1 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 @@ -4,7 +4,7 @@ import java.util.List; import java.util.Vector; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllKeys; @@ -20,28 +20,28 @@ import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.outliner.AABBOutline; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.Mirror; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.PlacementSettings; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class SchematicHandler { private String displayedSchematic; private SchematicTransformation transformation; - private AxisAlignedBB bounds; + private AABB bounds; private boolean deployed; private boolean active; private Tools currentTool; @@ -68,7 +68,7 @@ public class SchematicHandler { } public void tick() { - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (activeSchematicItem != null && transformation != null) transformation.tick(); @@ -103,7 +103,7 @@ public class SchematicHandler { .updateSelection(); } - private void init(ClientPlayerEntity player, ItemStack stack) { + private void init(LocalPlayer player, ItemStack stack) { loadSettings(stack); displayedSchematic = stack.getTag() .getString("File"); @@ -121,16 +121,16 @@ public class SchematicHandler { } private void setupRenderer() { - Template schematic = SchematicItem.loadSchematic(activeSchematicItem); + StructureTemplate schematic = SchematicItem.loadSchematic(activeSchematicItem); BlockPos size = schematic.getSize(); if (size.equals(BlockPos.ZERO)) return; - World clientWorld = Minecraft.getInstance().level; + Level clientWorld = Minecraft.getInstance().level; SchematicWorld w = new SchematicWorld(clientWorld); SchematicWorld wMirroredFB = new SchematicWorld(clientWorld); SchematicWorld wMirroredLR = new SchematicWorld(clientWorld); - PlacementSettings placementSettings = new PlacementSettings(); + StructurePlaceSettings placementSettings = new StructurePlaceSettings(); schematic.placeInWorldChunk(w, BlockPos.ZERO, placementSettings, w.getRandom()); placementSettings.setMirror(Mirror.FRONT_BACK); @@ -146,7 +146,7 @@ public class SchematicHandler { .display(wMirroredLR); } - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer) { + public void render(PoseStack ms, SuperRenderTypeBuffer buffer) { boolean present = activeSchematicItem != null; if (!active && !present) return; @@ -186,7 +186,7 @@ public class SchematicHandler { } - public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, float partialTicks) { + public void renderOverlay(PoseStack ms, MultiBufferSource buffer, int light, int overlay, float partialTicks) { if (!active) return; if (activeSchematicItem != null) @@ -204,8 +204,8 @@ public class SchematicHandler { Minecraft mc = Minecraft.getInstance(); if (mc.player.isShiftKeyDown()) return; - if (mc.hitResult instanceof BlockRayTraceResult) { - BlockRayTraceResult blockRayTraceResult = (BlockRayTraceResult) mc.hitResult; + if (mc.hitResult instanceof BlockHitResult) { + BlockHitResult blockRayTraceResult = (BlockHitResult) mc.hitResult; BlockState clickedBlock = mc.level.getBlockState(blockRayTraceResult.getBlockPos()); if (AllBlocks.SCHEMATICANNON.has(clickedBlock)) return; @@ -244,7 +244,7 @@ public class SchematicHandler { return false; } - private ItemStack findBlueprintInHand(PlayerEntity player) { + private ItemStack findBlueprintInHand(Player player) { ItemStack stack = player.getMainHandItem(); if (!AllItems.SCHEMATIC.isIn(stack)) return null; @@ -256,8 +256,8 @@ public class SchematicHandler { return stack; } - private boolean itemLost(PlayerEntity player) { - for (int i = 0; i < PlayerInventory.getSelectionSize(); i++) { + private boolean itemLost(Player player) { + for (int i = 0; i < Inventory.getSelectionSize(); i++) { if (!player.inventory.getItem(i) .sameItem(activeSchematicItem)) continue; @@ -285,17 +285,17 @@ public class SchematicHandler { } public void loadSettings(ItemStack blueprint) { - CompoundNBT tag = blueprint.getTag(); + CompoundTag tag = blueprint.getTag(); BlockPos anchor = BlockPos.ZERO; - PlacementSettings settings = SchematicItem.getSettings(blueprint); + StructurePlaceSettings settings = SchematicItem.getSettings(blueprint); transformation = new SchematicTransformation(); deployed = tag.getBoolean("Deployed"); if (deployed) - anchor = NBTUtil.readBlockPos(tag.getCompound("Anchor")); - BlockPos size = NBTUtil.readBlockPos(tag.getCompound("Bounds")); + anchor = NbtUtils.readBlockPos(tag.getCompound("Anchor")); + BlockPos size = NbtUtils.readBlockPos(tag.getCompound("Bounds")); - bounds = new AxisAlignedBB(BlockPos.ZERO, size); + bounds = new AABB(BlockPos.ZERO, size); outline = new AABBOutline(bounds); outline.getParams() .colored(0x6886c5) @@ -318,7 +318,7 @@ public class SchematicHandler { public void printInstantly() { AllPackets.channel.sendToServer(new SchematicPlacePacket(activeSchematicItem.copy())); - CompoundNBT nbt = activeSchematicItem.getTag(); + CompoundTag nbt = activeSchematicItem.getTag(); nbt.putBoolean("Deployed", false); activeSchematicItem.setTag(nbt); SchematicInstances.clearHash(activeSchematicItem); @@ -331,7 +331,7 @@ public class SchematicHandler { return active; } - public AxisAlignedBB getBounds() { + public AABB getBounds() { return bounds; } 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 a5fe5eff7..5eddd779c 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 @@ -1,17 +1,17 @@ package com.simibubi.create.content.schematics.client; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.gui.AllGuiTextures; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.AbstractGui; +import net.minecraft.client.gui.GuiComponent; -public class SchematicHotbarSlotOverlay extends AbstractGui { +public class SchematicHotbarSlotOverlay extends GuiComponent { - public void renderOn(MatrixStack matrixStack, int slot) { - MainWindow mainWindow = Minecraft.getInstance().getWindow(); + public void renderOn(PoseStack matrixStack, int slot) { + Window mainWindow = Minecraft.getInstance().getWindow(); int x = mainWindow.getGuiScaledWidth() / 2 - 88; int y = mainWindow.getGuiScaledHeight() - 19; RenderSystem.enableDepthTest(); 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 c13cc1dc0..d5d9f612c 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 @@ -2,7 +2,7 @@ package com.simibubi.create.content.schematics.client; import org.lwjgl.glfw.GLFW; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.gui.AbstractSimiScreen; @@ -12,19 +12,19 @@ import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class SchematicPromptScreen extends AbstractSimiScreen { private AllGuiTextures background; - private final ITextComponent convertLabel = Lang.translate("schematicAndQuill.convert"); - private final ITextComponent abortLabel = Lang.translate("action.discard"); - private final ITextComponent confirmLabel = Lang.translate("action.saveToFile"); + private final Component convertLabel = Lang.translate("schematicAndQuill.convert"); + private final Component abortLabel = Lang.translate("action.discard"); + private final Component confirmLabel = Lang.translate("action.saveToFile"); - private TextFieldWidget nameField; + private EditBox nameField; private IconButton confirm; private IconButton abort; private IconButton convert; @@ -43,7 +43,7 @@ public class SchematicPromptScreen extends AbstractSimiScreen { int x = guiLeft; int y = guiTop; - nameField = new TextFieldWidget(font, x + 49, y + 26, 131, 10, StringTextComponent.EMPTY); + nameField = new EditBox(font, x + 49, y + 26, 131, 10, TextComponent.EMPTY); nameField.setTextColor(-1); nameField.setTextColorUneditable(-1); nameField.setBordered(false); @@ -69,7 +69,7 @@ public class SchematicPromptScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int x = guiLeft; int y = guiTop; 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 8ec5e3210..43c092361 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 @@ -10,21 +10,21 @@ import java.util.Set; import org.lwjgl.opengl.GL11; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.render.TileEntityRenderHelper; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import com.mojang.blaze3d.vertex.BufferBuilder; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.model.data.EmptyModelData; @@ -68,7 +68,7 @@ public class SchematicRenderer { changed = false; } - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer) { + public void render(PoseStack ms, SuperRenderTypeBuffer buffer) { if (!active) return; buffer.getBuffer(RenderType.solid()); @@ -86,11 +86,11 @@ public class SchematicRenderer { startedBufferBuilders.clear(); final SchematicWorld blockAccess = schematic; - final BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRenderer(); + final BlockRenderDispatcher blockRendererDispatcher = minecraft.getBlockRenderer(); List blockstates = new LinkedList<>(); Map buffers = new HashMap<>(); - MatrixStack ms = new MatrixStack(); + PoseStack ms = new PoseStack(); BlockPos.betweenClosedStream(blockAccess.getBounds()) .forEach(localPos -> { @@ -101,17 +101,17 @@ public class SchematicRenderer { BlockState state = blockAccess.getBlockState(pos); for (RenderType blockRenderLayer : RenderType.chunkBufferLayers()) { - if (!RenderTypeLookup.canRenderInLayer(state, blockRenderLayer)) + if (!ItemBlockRenderTypes.canRenderInLayer(state, blockRenderLayer)) continue; ForgeHooksClient.setRenderLayer(blockRenderLayer); if (!buffers.containsKey(blockRenderLayer)) - buffers.put(blockRenderLayer, new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize())); + buffers.put(blockRenderLayer, new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize())); BufferBuilder bufferBuilder = buffers.get(blockRenderLayer); if (startedBufferBuilders.add(blockRenderLayer)) - bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormat.BLOCK); - TileEntity tileEntity = blockAccess.getBlockEntity(localPos); + BlockEntity tileEntity = blockAccess.getBlockEntity(localPos); if (blockRendererDispatcher.renderModel(state, pos, blockAccess, ms, bufferBuilder, true, minecraft.level.random, 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 2b6db0cf1..42a23fb27 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 @@ -3,19 +3,19 @@ package com.simibubi.create.content.schematics.client; import static java.lang.Math.abs; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingAngle; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.gen.feature.template.PlacementSettings; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; public class SchematicTransformation { @@ -33,7 +33,7 @@ public class SchematicTransformation { rotation = new InterpolatedChasingAngle(); } - public void init(BlockPos anchor, PlacementSettings settings, AxisAlignedBB bounds) { + public void init(BlockPos anchor, StructurePlaceSettings settings, AABB bounds) { int leftRight = settings.getMirror() == Mirror.LEFT_RIGHT ? -1 : 1; int frontBack = settings.getMirror() == Mirror.FRONT_BACK ? -1 : 1; getScaleFB().start(frontBack); @@ -45,18 +45,18 @@ public class SchematicTransformation { .ordinal() * 90); rotation.start(r); - Vector3d vec = fromAnchor(anchor); + Vec3 vec = fromAnchor(anchor); x.start((float) vec.x); y.start((float) vec.y); z.start((float) vec.z); } - public void applyGLTransformations(MatrixStack ms) { + public void applyGLTransformations(PoseStack ms) { float pt = AnimationTickHolder.getPartialTicks(); // Translation ms.translate(x.get(pt), y.get(pt), z.get(pt)); - Vector3d rotationOffset = getRotationOffset(true); + Vec3 rotationOffset = getRotationOffset(true); // Rotation & Mirror float fb = getScaleFB().get(pt); @@ -76,8 +76,8 @@ public class SchematicTransformation { return getMirrorModifier(Axis.X) < 0 != getMirrorModifier(Axis.Z) < 0; } - public Vector3d getRotationOffset(boolean ignoreMirrors) { - Vector3d rotationOffset = Vector3d.ZERO; + public Vec3 getRotationOffset(boolean ignoreMirrors) { + Vec3 rotationOffset = Vec3.ZERO; if ((int) (zOrigin * 2) % 2 != (int) (xOrigin * 2) % 2) { boolean xGreaterZ = xOrigin > zOrigin; float xIn = (xGreaterZ ? 0 : .5f); @@ -86,14 +86,14 @@ public class SchematicTransformation { xIn *= getMirrorModifier(Axis.X); zIn *= getMirrorModifier(Axis.Z); } - rotationOffset = new Vector3d(xIn, 0, zIn); + rotationOffset = new Vec3(xIn, 0, zIn); } return rotationOffset; } - public Vector3d toLocalSpace(Vector3d vec) { + public Vec3 toLocalSpace(Vec3 vec) { float pt = AnimationTickHolder.getPartialTicks(); - Vector3d rotationOffset = getRotationOffset(true); + Vec3 rotationOffset = getRotationOffset(true); vec = vec.subtract(x.get(pt), y.get(pt), z.get(pt)); vec = vec.subtract(xOrigin + rotationOffset.x, 0, zOrigin + rotationOffset.z); @@ -105,8 +105,8 @@ public class SchematicTransformation { return vec; } - public PlacementSettings toSettings() { - PlacementSettings settings = new PlacementSettings(); + public StructurePlaceSettings toSettings() { + StructurePlaceSettings settings = new StructurePlaceSettings(); int i = (int) rotation.getTarget(); @@ -144,8 +144,8 @@ public class SchematicTransformation { } public BlockPos getAnchor() { - Vector3d vec = Vector3d.ZERO.add(.5, 0, .5); - Vector3d rotationOffset = getRotationOffset(false); + Vec3 vec = Vec3.ZERO.add(.5, 0, .5); + Vec3 rotationOffset = getRotationOffset(false); vec = vec.subtract(xOrigin, 0, zOrigin); vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z); vec = vec.multiply(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); @@ -156,16 +156,16 @@ public class SchematicTransformation { return new BlockPos(vec.x, vec.y, vec.z); } - public Vector3d fromAnchor(BlockPos pos) { - Vector3d vec = Vector3d.ZERO.add(.5, 0, .5); - Vector3d rotationOffset = getRotationOffset(false); + public Vec3 fromAnchor(BlockPos pos) { + Vec3 vec = Vec3.ZERO.add(.5, 0, .5); + Vec3 rotationOffset = getRotationOffset(false); vec = vec.subtract(xOrigin, 0, zOrigin); vec = vec.subtract(rotationOffset.x, 0, rotationOffset.z); vec = vec.multiply(getScaleFB().getTarget(), 1, getScaleLR().getTarget()); vec = VecHelper.rotate(vec, rotation.getTarget(), Axis.Y); vec = vec.add(xOrigin, 0, zOrigin); - return Vector3d.atLowerCornerOf(pos.subtract(new BlockPos(vec.x, vec.y, vec.z))); + return Vec3.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 7ac1bc580..b2043d1c3 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 @@ -1,19 +1,19 @@ package com.simibubi.create.content.schematics.client.tools; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllKeys; import com.simibubi.create.content.schematics.client.SchematicTransformation; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.outliner.AABBOutline; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class DeployTool extends PlacementToolBase { @@ -29,14 +29,14 @@ public class DeployTool extends PlacementToolBase { selectionRange = (int) (schematicHandler.getBounds() .getCenter() .length() / 2); - selectionRange = MathHelper.clamp(selectionRange, 1, 100); + selectionRange = Mth.clamp(selectionRange, 1, 100); } selectIgnoreBlocks = AllKeys.ACTIVATE_TOOL.isPressed(); super.updateSelection(); } @Override - public void renderTool(MatrixStack ms, SuperRenderTypeBuffer buffer) { + public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer) { super.renderTool(ms, buffer); if (selectedPos == null) @@ -44,19 +44,19 @@ public class DeployTool extends PlacementToolBase { ms.pushPose(); float pt = AnimationTickHolder.getPartialTicks(); - double x = MathHelper.lerp(pt, lastChasingSelectedPos.x, chasingSelectedPos.x); - double y = MathHelper.lerp(pt, lastChasingSelectedPos.y, chasingSelectedPos.y); - double z = MathHelper.lerp(pt, lastChasingSelectedPos.z, chasingSelectedPos.z); + double x = Mth.lerp(pt, lastChasingSelectedPos.x, chasingSelectedPos.x); + double y = Mth.lerp(pt, lastChasingSelectedPos.y, chasingSelectedPos.y); + double z = Mth.lerp(pt, lastChasingSelectedPos.z, chasingSelectedPos.z); SchematicTransformation transformation = schematicHandler.getTransformation(); - AxisAlignedBB bounds = schematicHandler.getBounds(); - Vector3d center = bounds.getCenter(); - Vector3d rotationOffset = transformation.getRotationOffset(true); + AABB bounds = schematicHandler.getBounds(); + Vec3 center = bounds.getCenter(); + Vec3 rotationOffset = transformation.getRotationOffset(true); int centerX = (int) center.x; int centerZ = (int) center.z; double xOrigin = bounds.getXsize() / 2f; double zOrigin = bounds.getZsize() / 2f; - Vector3d origin = new Vector3d(xOrigin, 0, zOrigin); + Vec3 origin = new Vec3(xOrigin, 0, zOrigin); ms.translate(x - centerX, y, z - centerZ); MatrixTransformStack.of(ms) @@ -78,7 +78,7 @@ public class DeployTool extends PlacementToolBase { if (!selectIgnoreBlocks) return super.handleMouseWheel(delta); selectionRange += delta; - selectionRange = MathHelper.clamp(selectionRange, 1, 100); + selectionRange = Mth.clamp(selectionRange, 1, 100); return true; } @@ -86,7 +86,7 @@ public class DeployTool extends PlacementToolBase { public boolean handleRightClick() { if (selectedPos == null) return super.handleRightClick(); - Vector3d center = schematicHandler.getBounds() + Vec3 center = schematicHandler.getBounds() .getCenter(); BlockPos target = selectedPos.offset(-((int) center.x), 0, -((int) center.z)); @@ -95,7 +95,7 @@ public class DeployTool extends PlacementToolBase { item.getTag() .putBoolean("Deployed", true); item.getTag() - .put("Anchor", NBTUtil.writeBlockPos(target)); + .put("Anchor", NbtUtils.writeBlockPos(target)); } schematicHandler.getTransformation() 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 100dd7a57..96abbd00b 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 @@ -1,20 +1,20 @@ package com.simibubi.create.content.schematics.client.tools; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.outliner.AABBOutline; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class FlipTool extends PlacementToolBase { - private AABBOutline outline = new AABBOutline(new AxisAlignedBB(BlockPos.ZERO)); + private AABBOutline outline = new AABBOutline(new AABB(BlockPos.ZERO)); @Override public void init() { @@ -49,7 +49,7 @@ public class FlipTool extends PlacementToolBase { } @Override - public void renderOnSchematic(MatrixStack ms, SuperRenderTypeBuffer buffer) { + public void renderOnSchematic(PoseStack ms, SuperRenderTypeBuffer buffer) { if (!schematicSelected || !selectedFace.getAxis() .isHorizontal()) { super.renderOnSchematic(ms, buffer); @@ -57,12 +57,12 @@ public class FlipTool extends PlacementToolBase { } Direction facing = selectedFace.getClockWise(); - AxisAlignedBB bounds = schematicHandler.getBounds(); + AABB bounds = schematicHandler.getBounds(); - Vector3d directionVec = Vector3d.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, facing.getAxis()) + Vec3 directionVec = Vec3.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, facing.getAxis()) .getNormal()); - Vector3d boundsSize = new Vector3d(bounds.getXsize(), bounds.getYsize(), bounds.getZsize()); - Vector3d vec = boundsSize.multiply(directionVec); + Vec3 boundsSize = new Vec3(bounds.getXsize(), bounds.getYsize(), bounds.getZsize()); + Vec3 vec = boundsSize.multiply(directionVec); bounds = bounds.contract(vec.x, vec.y, vec.z) .inflate(1 - directionVec.x, 1 - directionVec.y, 1 - directionVec.z); bounds = bounds.move(directionVec.scale(.5f) diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java index cd53c8227..f38e0c9cf 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.schematics.client.tools; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; public interface ISchematicTool { @@ -13,8 +13,8 @@ public interface ISchematicTool { public boolean handleRightClick(); public boolean handleMouseWheel(double delta); - public void renderTool(MatrixStack ms, SuperRenderTypeBuffer buffer); - public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer); - public void renderOnSchematic(MatrixStack ms, SuperRenderTypeBuffer buffer); + public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer); + public void renderOverlay(PoseStack ms, MultiBufferSource buffer); + public void renderOnSchematic(PoseStack ms, SuperRenderTypeBuffer buffer); } 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 f01e87d7c..9f1bc0bba 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 @@ -3,8 +3,8 @@ package com.simibubi.create.content.schematics.client.tools; import com.simibubi.create.content.schematics.client.SchematicTransformation; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.Vec3; public class MoveTool extends PlacementToolBase { @@ -25,7 +25,7 @@ public class MoveTool extends PlacementToolBase { return true; SchematicTransformation transformation = schematicHandler.getTransformation(); - Vector3d vec = Vector3d.atLowerCornerOf(selectedFace.getNormal()).scale(-Math.signum(delta)); + Vec3 vec = Vec3.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); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/PlacementToolBase.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/PlacementToolBase.java index d9960aac6..1dd9d2da8 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/PlacementToolBase.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/PlacementToolBase.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.schematics.client.tools; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; public abstract class PlacementToolBase extends SchematicToolBase { @@ -18,12 +18,12 @@ public abstract class PlacementToolBase extends SchematicToolBase { } @Override - public void renderTool(MatrixStack ms, SuperRenderTypeBuffer buffer) { + public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer) { super.renderTool(ms, buffer); } @Override - public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer) { + public void renderOverlay(PoseStack ms, MultiBufferSource buffer) { super.renderOverlay(ms, buffer); } 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 9287a681b..55b3e3dcc 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 @@ -1,12 +1,12 @@ package com.simibubi.create.content.schematics.client.tools; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.outliner.LineOutline; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; public class RotateTool extends PlacementToolBase { @@ -21,14 +21,14 @@ public class RotateTool extends PlacementToolBase { } @Override - public void renderOnSchematic(MatrixStack ms, SuperRenderTypeBuffer buffer) { - AxisAlignedBB bounds = schematicHandler.getBounds(); + public void renderOnSchematic(PoseStack ms, SuperRenderTypeBuffer buffer) { + AABB bounds = schematicHandler.getBounds(); double height = bounds.getYsize() + Math.max(20, bounds.getYsize()); - Vector3d center = bounds.getCenter() + Vec3 center = bounds.getCenter() .add(schematicHandler.getTransformation() .getRotationOffset(false)); - Vector3d start = center.subtract(0, height / 2, 0); - Vector3d end = center.add(0, height / 2, 0); + Vec3 start = center.subtract(0, height / 2, 0); + Vec3 end = center.add(0, height / 2, 0); line.getParams() .disableCull() 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 a9635e375..f32f28d1b 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 @@ -3,7 +3,7 @@ package com.simibubi.create.content.schematics.client.tools; import java.util.Arrays; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllKeys; import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.CreateClient; @@ -17,22 +17,22 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.outliner.AABBOutline; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.world.phys.Vec3; public abstract class SchematicToolBase implements ISchematicTool { protected SchematicHandler schematicHandler; protected BlockPos selectedPos; - protected Vector3d chasingSelectedPos; - protected Vector3d lastChasingSelectedPos; + protected Vec3 chasingSelectedPos; + protected Vec3 lastChasingSelectedPos; protected boolean selectIgnoreBlocks; protected int selectionRange; @@ -49,8 +49,8 @@ public abstract class SchematicToolBase implements ISchematicTool { selectedPos = null; selectedFace = null; schematicSelected = false; - chasingSelectedPos = Vector3d.ZERO; - lastChasingSelectedPos = Vector3d.ZERO; + chasingSelectedPos = Vec3.ZERO; + lastChasingSelectedPos = Vec3.ZERO; } @Override @@ -60,7 +60,7 @@ public abstract class SchematicToolBase implements ISchematicTool { if (selectedPos == null) return; lastChasingSelectedPos = chasingSelectedPos; - Vector3d target = Vector3d.atLowerCornerOf(selectedPos); + Vec3 target = Vec3.atLowerCornerOf(selectedPos); if (target.distanceTo(chasingSelectedPos) < 1 / 512f) { chasingSelectedPos = target; return; @@ -71,16 +71,16 @@ public abstract class SchematicToolBase implements ISchematicTool { } public void updateTargetPos() { - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; // Select Blueprint if (schematicHandler.isDeployed()) { SchematicTransformation transformation = schematicHandler.getTransformation(); - AxisAlignedBB localBounds = schematicHandler.getBounds(); + AABB localBounds = schematicHandler.getBounds(); - Vector3d traceOrigin = RaycastHelper.getTraceOrigin(player); - Vector3d start = transformation.toLocalSpace(traceOrigin); - Vector3d end = transformation.toLocalSpace(RaycastHelper.getTraceTarget(player, 70, traceOrigin)); + Vec3 traceOrigin = RaycastHelper.getTraceOrigin(player); + Vec3 start = transformation.toLocalSpace(traceOrigin); + Vec3 end = transformation.toLocalSpace(RaycastHelper.getTraceTarget(player, 70, traceOrigin)); PredicateTraceResult result = RaycastHelper.rayTraceUntil(start, end, pos -> localBounds.contains(VecHelper.getCenterOf(pos))); @@ -97,13 +97,13 @@ public abstract class SchematicToolBase implements ISchematicTool { .add(player.getLookAngle() .scale(selectionRange))); if (snap) - lastChasingSelectedPos = chasingSelectedPos = Vector3d.atLowerCornerOf(selectedPos); + lastChasingSelectedPos = chasingSelectedPos = Vec3.atLowerCornerOf(selectedPos); return; } // Select targeted Block selectedPos = null; - BlockRayTraceResult trace = RaycastHelper.rayTraceRange(player.level, player, 75); + BlockHitResult trace = RaycastHelper.rayTraceRange(player.level, player, 75); if (trace == null || trace.getType() != Type.BLOCK) return; @@ -117,17 +117,17 @@ public abstract class SchematicToolBase implements ISchematicTool { hit = hit.relative(trace.getDirection()); selectedPos = hit; if (snap) - lastChasingSelectedPos = chasingSelectedPos = Vector3d.atLowerCornerOf(selectedPos); + lastChasingSelectedPos = chasingSelectedPos = Vec3.atLowerCornerOf(selectedPos); } @Override - public void renderTool(MatrixStack ms, SuperRenderTypeBuffer buffer) {} + public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer) {} @Override - public void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer) {} + public void renderOverlay(PoseStack ms, MultiBufferSource buffer) {} @Override - public void renderOnSchematic(MatrixStack ms, SuperRenderTypeBuffer buffer) { + public void renderOnSchematic(PoseStack ms, SuperRenderTypeBuffer buffer) { if (!schematicHandler.isDeployed()) return; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/Tools.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/Tools.java index 24ce26e67..a29bafe70 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/Tools.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/Tools.java @@ -7,8 +7,8 @@ import java.util.List; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; public enum Tools { @@ -31,7 +31,7 @@ public enum Tools { return tool; } - public TranslationTextComponent getDisplayName() { + public TranslatableComponent getDisplayName() { return Lang.translate("schematic.tool." + Lang.asId(name())); } @@ -47,7 +47,7 @@ public enum Tools { return tools; } - public List getDescription() { + public List getDescription() { return Lang.translatedOptions("schematic.tool." + Lang.asId(name()) + ".description", "0", "1", "2", "3"); } 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 3942a7eb9..2e142fa3c 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 @@ -10,13 +10,13 @@ import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.content.schematics.item.SchematicItem; import com.simibubi.create.foundation.utility.WorldAttached; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.PlacementSettings; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class SchematicInstances { @@ -31,7 +31,7 @@ public class SchematicInstances { public static void register() {} @Nullable - public static SchematicWorld get(World world, ItemStack schematic) { + public static SchematicWorld get(Level world, ItemStack schematic) { Cache map = loadedSchematics.get(world); int hash = getHash(schematic); SchematicWorld ifPresent = map.getIfPresent(hash); @@ -44,23 +44,23 @@ public class SchematicInstances { return loadWorld; } - private static SchematicWorld loadWorld(World wrapped, ItemStack schematic) { + private static SchematicWorld loadWorld(Level wrapped, ItemStack schematic) { if (schematic == null || !schematic.hasTag()) return null; if (!schematic.getTag() .getBoolean("Deployed")) return null; - Template activeTemplate = SchematicItem.loadSchematic(schematic); + StructureTemplate activeTemplate = SchematicItem.loadSchematic(schematic); if (activeTemplate.getSize() .equals(BlockPos.ZERO)) return null; - BlockPos anchor = NBTUtil.readBlockPos(schematic.getTag() + BlockPos anchor = NbtUtils.readBlockPos(schematic.getTag() .getCompound("Anchor")); SchematicWorld world = new SchematicWorld(anchor, wrapped); - PlacementSettings settings = SchematicItem.getSettings(schematic); + StructurePlaceSettings settings = SchematicItem.getSettings(schematic); activeTemplate.placeInWorldChunk(world, anchor, settings, wrapped.getRandom()); return world; @@ -76,7 +76,7 @@ public class SchematicInstances { public static int getHash(ItemStack schematic) { if (schematic == null || !schematic.hasTag()) return -1; - CompoundNBT tag = schematic.getTag(); + CompoundTag tag = schematic.getTag(); if (!tag.contains("SchematicHash")) tag.putInt("SchematicHash", tag.toString() .hashCode()); 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 591208f2d..f01d88ecd 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,9 +2,11 @@ package com.simibubi.create.content.schematics.item; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.block.Blocks; -import net.minecraft.item.Item; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.Item; +import net.minecraft.nbt.CompoundTag; + +import net.minecraft.world.item.Item.Properties; public class SchematicAndQuillItem extends Item { @@ -12,7 +14,7 @@ public class SchematicAndQuillItem extends Item { super(properties); } - public static void replaceStructureVoidWithAir(CompoundNBT nbt) { + public static void replaceStructureVoidWithAir(CompoundTag nbt) { String air = Blocks.AIR.getRegistryName() .toString(); String structureVoid = Blocks.STRUCTURE_VOID.getRegistryName() 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 9c78c265c..a737b9d49 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 @@ -22,34 +22,36 @@ import com.simibubi.create.content.schematics.filtering.SchematicInstances; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTSizeTracker; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.Mirror; -import net.minecraft.util.NonNullList; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.PlacementSettings; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtIo; +import net.minecraft.nbt.NbtAccounter; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.core.NonNullList; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.thread.SidedThreadGroups; +import net.minecraft.world.item.Item.Properties; + public class SchematicItem extends Item { private static final Logger LOGGER = LogManager.getLogger(); @@ -61,11 +63,11 @@ public class SchematicItem extends Item { public static ItemStack create(String schematic, String owner) { ItemStack blueprint = AllItems.SCHEMATIC.asStack(); - CompoundNBT tag = new CompoundNBT(); + CompoundTag tag = new CompoundTag(); tag.putBoolean("Deployed", false); tag.putString("Owner", owner); tag.putString("File", schematic); - tag.put("Anchor", NBTUtil.writeBlockPos(BlockPos.ZERO)); + tag.put("Anchor", NbtUtils.writeBlockPos(BlockPos.ZERO)); tag.putString("Rotation", Rotation.NONE.name()); tag.putString("Mirror", Mirror.NONE.name()); blueprint.setTag(tag); @@ -75,37 +77,37 @@ public class SchematicItem extends Item { } @Override - public void fillItemCategory(ItemGroup group, NonNullList items) {} + public void fillItemCategory(CreativeModeTab group, NonNullList items) {} @Override @OnlyIn(value = Dist.CLIENT) - public void appendHoverText(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + public void appendHoverText(ItemStack stack, Level worldIn, List tooltip, TooltipFlag flagIn) { if (stack.hasTag()) { if (stack.getTag() .contains("File")) - tooltip.add(new StringTextComponent(TextFormatting.GOLD + stack.getTag() + tooltip.add(new TextComponent(ChatFormatting.GOLD + stack.getTag() .getString("File"))); } else { - tooltip.add(Lang.translate("schematic.invalid").withStyle(TextFormatting.RED)); + tooltip.add(Lang.translate("schematic.invalid").withStyle(ChatFormatting.RED)); } super.appendHoverText(stack, worldIn, tooltip, flagIn); } public static void writeSize(ItemStack blueprint) { - CompoundNBT tag = blueprint.getTag(); - Template t = loadSchematic(blueprint); - tag.put("Bounds", NBTUtil.writeBlockPos(t.getSize())); + CompoundTag tag = blueprint.getTag(); + StructureTemplate t = loadSchematic(blueprint); + tag.put("Bounds", NbtUtils.writeBlockPos(t.getSize())); blueprint.setTag(tag); SchematicInstances.clearHash(blueprint); } - public static PlacementSettings getSettings(ItemStack blueprint) { + public static StructurePlaceSettings getSettings(ItemStack blueprint) { return getSettings(blueprint, true); } - public static PlacementSettings getSettings(ItemStack blueprint, boolean processNBT) { - CompoundNBT tag = blueprint.getTag(); - PlacementSettings settings = new PlacementSettings(); + public static StructurePlaceSettings getSettings(ItemStack blueprint, boolean processNBT) { + CompoundTag tag = blueprint.getTag(); + StructurePlaceSettings settings = new StructurePlaceSettings(); settings.setRotation(Rotation.valueOf(tag.getString("Rotation"))); settings.setMirror(Mirror.valueOf(tag.getString("Mirror"))); if (processNBT) @@ -113,8 +115,8 @@ public class SchematicItem extends Item { return settings; } - public static Template loadSchematic(ItemStack blueprint) { - Template t = new Template(); + public static StructureTemplate loadSchematic(ItemStack blueprint) { + StructureTemplate t = new StructureTemplate(); String owner = blueprint.getTag() .getString("Owner"); String schematic = blueprint.getTag() @@ -140,7 +142,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)); + CompoundTag nbt = NbtIo.read(stream, new NbtAccounter(0x20000000L)); t.load(nbt); } catch (IOException e) { LOGGER.warn("Failed to read schematic", e); @@ -151,21 +153,21 @@ public class SchematicItem extends Item { @Nonnull @Override - public ActionResultType useOn(ItemUseContext context) { + public InteractionResult useOn(UseOnContext context) { if (context.getPlayer() != null && !onItemUse(context.getPlayer(), context.getHand())) return super.useOn(context); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public ActionResult use(World worldIn, PlayerEntity playerIn, Hand handIn) { + public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { if (!onItemUse(playerIn, handIn)) return super.use(worldIn, playerIn, handIn); - return new ActionResult<>(ActionResultType.SUCCESS, playerIn.getItemInHand(handIn)); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, playerIn.getItemInHand(handIn)); } - private boolean onItemUse(PlayerEntity player, Hand hand) { - if (!player.isShiftKeyDown() || hand != Hand.MAIN_HAND) + private boolean onItemUse(Player player, InteractionHand hand) { + if (!player.isShiftKeyDown() || hand != InteractionHand.MAIN_HAND) return false; if (!player.getItemInHand(hand) .hasTag()) 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 e53a876db..31926b637 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 @@ -7,8 +7,8 @@ import com.simibubi.create.content.schematics.block.SchematicannonTileEntity; import com.simibubi.create.content.schematics.block.SchematicannonTileEntity.State; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.network.NetworkEvent.Context; public class ConfigureSchematicannonPacket extends SimplePacketBase { @@ -25,18 +25,18 @@ public class ConfigureSchematicannonPacket extends SimplePacketBase { this.set = set; } - public ConfigureSchematicannonPacket(PacketBuffer buffer) { + public ConfigureSchematicannonPacket(FriendlyByteBuf buffer) { this(buffer.readEnum(Option.class), buffer.readBoolean()); } - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeEnum(option); buffer.writeBoolean(set); } public void handle(Supplier context) { context.get().enqueueWork(() -> { - ServerPlayerEntity player = context.get().getSender(); + ServerPlayer player = context.get().getSender(); if (player == null || !(player.containerMenu instanceof SchematicannonContainer)) return; 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 433875cb2..47aef8138 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 @@ -5,9 +5,9 @@ import java.util.function.Supplier; import com.simibubi.create.Create; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; import net.minecraftforge.fml.network.NetworkEvent.Context; public class InstantSchematicPacket extends SimplePacketBase { @@ -22,14 +22,14 @@ public class InstantSchematicPacket extends SimplePacketBase { this.bounds = bounds; } - public InstantSchematicPacket(PacketBuffer buffer) { + public InstantSchematicPacket(FriendlyByteBuf buffer) { name = buffer.readUtf(32767); origin = buffer.readBlockPos(); bounds = buffer.readBlockPos(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeUtf(name); buffer.writeBlockPos(origin); buffer.writeBlockPos(bounds); @@ -39,7 +39,7 @@ public class InstantSchematicPacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity player = context.get() + ServerPlayer player = context.get() .getSender(); if (player == null) return; 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 3331040c2..5ec68a566 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 @@ -7,11 +7,11 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.networking.SimplePacketBase; import com.simibubi.create.foundation.utility.BlockHelper; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.network.NetworkEvent.Context; public class SchematicPlacePacket extends SimplePacketBase { @@ -22,21 +22,21 @@ public class SchematicPlacePacket extends SimplePacketBase { this.stack = stack; } - public SchematicPlacePacket(PacketBuffer buffer) { + public SchematicPlacePacket(FriendlyByteBuf buffer) { stack = buffer.readItem(); } - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeItem(stack); } public void handle(Supplier context) { context.get().enqueueWork(() -> { - ServerPlayerEntity player = context.get().getSender(); + ServerPlayer player = context.get().getSender(); if (player == null) return; - World world = player.getLevel(); + Level world = player.getLevel(); SchematicPrinter printer = new SchematicPrinter(); printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks()); if (!printer.isLoaded()) @@ -53,7 +53,7 @@ public class SchematicPlacePacket extends SimplePacketBase { if (placingAir && !includeAir) return; - CompoundNBT tileData = tile != null ? tile.save(new CompoundNBT()) : null; + CompoundTag tileData = tile != null ? tile.save(new CompoundTag()) : null; BlockHelper.placeSchematicBlock(world, state, pos, null, tileData); }, (pos, 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 f35991b80..50d34d7d6 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 @@ -6,15 +6,15 @@ import com.simibubi.create.AllItems; import com.simibubi.create.content.schematics.filtering.SchematicInstances; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.feature.template.PlacementSettings; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; import net.minecraftforge.fml.network.NetworkEvent.Context; public class SchematicSyncPacket extends SimplePacketBase { @@ -25,7 +25,7 @@ public class SchematicSyncPacket extends SimplePacketBase { public Rotation rotation; public Mirror mirror; - public SchematicSyncPacket(int slot, PlacementSettings settings, + public SchematicSyncPacket(int slot, StructurePlaceSettings settings, BlockPos anchor, boolean deployed) { this.slot = slot; this.deployed = deployed; @@ -34,7 +34,7 @@ public class SchematicSyncPacket extends SimplePacketBase { this.mirror = settings.getMirror(); } - public SchematicSyncPacket(PacketBuffer buffer) { + public SchematicSyncPacket(FriendlyByteBuf buffer) { slot = buffer.readVarInt(); deployed = buffer.readBoolean(); anchor = buffer.readBlockPos(); @@ -43,7 +43,7 @@ public class SchematicSyncPacket extends SimplePacketBase { } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeVarInt(slot); buffer.writeBoolean(deployed); buffer.writeBlockPos(anchor); @@ -54,7 +54,7 @@ public class SchematicSyncPacket extends SimplePacketBase { @Override public void handle(Supplier context) { context.get().enqueueWork(() -> { - ServerPlayerEntity player = context.get().getSender(); + ServerPlayer player = context.get().getSender(); if (player == null) return; ItemStack stack = ItemStack.EMPTY; @@ -66,9 +66,9 @@ public class SchematicSyncPacket extends SimplePacketBase { if (!AllItems.SCHEMATIC.isIn(stack)) { return; } - CompoundNBT tag = stack.getOrCreateTag(); + CompoundTag tag = stack.getOrCreateTag(); tag.putBoolean("Deployed", deployed); - tag.put("Anchor", NBTUtil.writeBlockPos(anchor)); + tag.put("Anchor", NbtUtils.writeBlockPos(anchor)); tag.putString("Rotation", rotation.name()); tag.putString("Mirror", mirror.name()); SchematicInstances.clearHash(stack); 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 3828588c9..1a6dc222c 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 @@ -6,9 +6,9 @@ import com.simibubi.create.Create; import com.simibubi.create.content.schematics.block.SchematicTableContainer; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; import net.minecraftforge.fml.network.NetworkEvent.Context; public class SchematicUploadPacket extends SimplePacketBase { @@ -43,7 +43,7 @@ public class SchematicUploadPacket extends SimplePacketBase { return new SchematicUploadPacket(FINISH, schematic); } - public SchematicUploadPacket(PacketBuffer buffer) { + public SchematicUploadPacket(FriendlyByteBuf buffer) { code = buffer.readInt(); schematic = buffer.readUtf(256); @@ -53,7 +53,7 @@ public class SchematicUploadPacket extends SimplePacketBase { data = buffer.readByteArray(); } - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(code); buffer.writeUtf(schematic); @@ -66,7 +66,7 @@ public class SchematicUploadPacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity player = context.get() + ServerPlayer player = context.get() .getSender(); if (player == null) return; diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 347b8d9ee..d5a7c908e 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -3,7 +3,7 @@ package com.simibubi.create.events; import java.util.ArrayList; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllFluids; import com.simibubi.create.AllItems; @@ -55,20 +55,20 @@ import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.worldWrappers.WrappedClientWorld; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.IRenderTypeBuffer.Impl; +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.MultiBufferSource.BufferSource; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ClientPlayerNetworkEvent; import net.minecraftforge.client.event.EntityViewRenderEvent; @@ -100,7 +100,7 @@ public class ClientEvents { if (!isGameActive()) return; - World world = Minecraft.getInstance().level; + Level world = Minecraft.getInstance().level; if (event.phase == Phase.START) { LinkedControllerClientHandler.tick(); AirCurrent.tickClientPlayerSounds(); @@ -155,8 +155,8 @@ public class ClientEvents { @SubscribeEvent public static void onLoadWorld(WorldEvent.Load event) { - IWorld world = event.getWorld(); - if (world.isClientSide() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) { + LevelAccessor world = event.getWorld(); + if (world.isClientSide() && world instanceof ClientLevel && !(world instanceof WrappedClientWorld)) { CreateClient.invalidateRenderers(); AnimationTickHolder.reset(); } @@ -174,11 +174,11 @@ public class ClientEvents { @SubscribeEvent public static void onRenderWorld(RenderWorldLastEvent event) { - Vector3d cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera() + Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera() .getPosition(); float pt = AnimationTickHolder.getPartialTicks(); - MatrixStack ms = event.getMatrixStack(); + PoseStack ms = event.getMatrixStack(); ms.pushPose(); ms.translate(-cameraPos.x(), -cameraPos.y(), -cameraPos.z()); SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance(); @@ -197,8 +197,8 @@ public class ClientEvents { @SubscribeEvent public static void onRenderOverlay(RenderGameOverlayEvent.Post event) { - MatrixStack ms = event.getMatrixStack(); - Impl buffers = Minecraft.getInstance() + PoseStack ms = event.getMatrixStack(); + BufferSource buffers = Minecraft.getInstance() .renderBuffers() .bufferSource(); int light = 0xF000F0; @@ -213,7 +213,7 @@ public class ClientEvents { onRenderHotbar(ms, buffers, light, overlay, pt); } - public static void onRenderHotbar(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, + public static void onRenderHotbar(PoseStack ms, MultiBufferSource buffer, int light, int overlay, float partialTicks) { CreateClient.SCHEMATIC_HANDLER.renderOverlay(ms, buffer, light, overlay, partialTicks); LinkedControllerClientHandler.renderOverlay(ms, buffer, light, overlay, partialTicks); @@ -240,8 +240,8 @@ public class ClientEvents { if (translationKey.startsWith(ITEM_PREFIX) || translationKey.startsWith(BLOCK_PREFIX)) if (TooltipHelper.hasTooltip(stack, event.getPlayer())) { - List itemTooltip = event.getToolTip(); - List toolTip = new ArrayList<>(); + List itemTooltip = event.getToolTip(); + List toolTip = new ArrayList<>(); toolTip.add(itemTooltip.remove(0)); TooltipHelper.getTooltip(stack) .addInformation(toolTip); @@ -251,10 +251,10 @@ public class ClientEvents { if (stack.getItem() instanceof BlockItem) { BlockItem item = (BlockItem) stack.getItem(); if (item.getBlock() instanceof IRotate || item.getBlock() instanceof EngineBlock) { - List kineticStats = ItemDescription.getKineticStats(item.getBlock()); + List kineticStats = ItemDescription.getKineticStats(item.getBlock()); if (!kineticStats.isEmpty()) { event.getToolTip() - .add(new StringTextComponent("")); + .add(new TextComponent("")); event.getToolTip() .addAll(kineticStats); } @@ -278,7 +278,7 @@ public class ClientEvents { @SubscribeEvent public static void getFogDensity(EntityViewRenderEvent.FogDensity event) { - ActiveRenderInfo info = event.getInfo(); + Camera info = event.getInfo(); FluidState fluidState = info.getFluidInCamera(); if (fluidState.isEmpty()) return; @@ -306,7 +306,7 @@ public class ClientEvents { @SubscribeEvent public static void getFogColor(EntityViewRenderEvent.FogColors event) { - ActiveRenderInfo info = event.getInfo(); + Camera info = event.getInfo(); FluidState fluidState = info.getFluidInCamera(); if (fluidState.isEmpty()) return; diff --git a/src/main/java/com/simibubi/create/events/CommonEvents.java b/src/main/java/com/simibubi/create/events/CommonEvents.java index 0032ead77..a53bfb33e 100644 --- a/src/main/java/com/simibubi/create/events/CommonEvents.java +++ b/src/main/java/com/simibubi/create/events/CommonEvents.java @@ -20,18 +20,18 @@ import com.simibubi.create.foundation.utility.ServerSpeedProvider; import com.simibubi.create.foundation.utility.WorldAttached; import com.simibubi.create.foundation.utility.recipe.RecipeFinder; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.ItemStack; import net.minecraft.tags.FluidTags; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.Level; import net.minecraftforge.event.AddReloadListenerEvent; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.RegisterCommandsEvent; @@ -69,7 +69,7 @@ public class CommonEvents { @SubscribeEvent public static void playerLoggedIn(PlayerLoggedInEvent event) { - PlayerEntity player = event.getPlayer(); + Player player = event.getPlayer(); ToolboxHandler.playerLogin(player); } @@ -78,7 +78,7 @@ public class CommonEvents { BlockState blockState = event.getOriginalState(); FluidState fluidState = blockState.getFluidState(); BlockPos pos = event.getPos(); - IWorld world = event.getWorld(); + LevelAccessor world = event.getWorld(); if (fluidState.isSource() && FluidHelper.isLava(fluidState.getType())) return; @@ -100,7 +100,7 @@ public class CommonEvents { public static void onWorldTick(WorldTickEvent event) { if (event.phase == Phase.START) return; - World world = event.world; + Level world = event.world; ContraptionHandler.tick(world); CapabilityMinecartController.tick(world); CouplingPhysics.tick(world); @@ -110,7 +110,7 @@ public class CommonEvents { @SubscribeEvent public static void onUpdateLivingEntity(LivingUpdateEvent event) { LivingEntity entityLiving = event.getEntityLiving(); - World world = entityLiving.level; + Level world = entityLiving.level; if (world == null) return; ContraptionHandler.entitiesWhoJustDismountedGetSentToTheRightLocation(entityLiving, world); @@ -120,7 +120,7 @@ public class CommonEvents { @SubscribeEvent public static void onEntityAdded(EntityJoinWorldEvent event) { Entity entity = event.getEntity(); - World world = event.getWorld(); + Level world = event.getWorld(); ContraptionHandler.addSpawnedContraptionsToCollisionList(entity, world); } @@ -149,14 +149,14 @@ public class CommonEvents { @SubscribeEvent public static void onLoadWorld(WorldEvent.Load event) { - IWorld world = event.getWorld(); + LevelAccessor world = event.getWorld(); Create.REDSTONE_LINK_NETWORK_HANDLER.onLoadWorld(world); Create.TORQUE_PROPAGATOR.onLoadWorld(world); } @SubscribeEvent public static void onUnloadWorld(WorldEvent.Unload event) { - IWorld world = event.getWorld(); + LevelAccessor world = event.getWorld(); Create.REDSTONE_LINK_NETWORK_HANDLER.onUnloadWorld(world); Create.TORQUE_PROPAGATOR.onUnloadWorld(world); WorldAttached.invalidateWorld(world); @@ -172,7 +172,7 @@ public class CommonEvents { CapabilityMinecartController.startTracking(event); } - public static void leftClickEmpty(ServerPlayerEntity player) { + public static void leftClickEmpty(ServerPlayer player) { ItemStack stack = player.getMainHandItem(); if (stack.getItem() instanceof ZapperItem) { ZapperInteractionHandler.trySelect(stack, player); diff --git a/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java b/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java index b8824cc96..25201260f 100644 --- a/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java +++ b/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java @@ -5,13 +5,13 @@ import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.foundation.sound.SoundScapes; import com.simibubi.create.foundation.utility.ISimpleReloadListener; -import net.minecraft.profiler.IProfiler; -import net.minecraft.resources.IResourceManager; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.server.packs.resources.ResourceManager; public class ClientResourceReloadListener implements ISimpleReloadListener { @Override - public void onReload(IResourceManager resourceManager, IProfiler profiler) { + public void onReload(ResourceManager resourceManager, ProfilerFiller profiler) { CreateClient.invalidateRenderers(); SoundScapes.invalidateAll(); IHaveGoggleInformation.numberFormat.update(); 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 f5e4d5b02..3f69170ef 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java @@ -21,24 +21,24 @@ import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.Advancement.Builder; import net.minecraft.advancements.FrameType; -import net.minecraft.advancements.criterion.InventoryChangeTrigger; -import net.minecraft.advancements.criterion.PlacedBlockTrigger; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; +import net.minecraft.advancements.critereon.InventoryChangeTrigger; +import net.minecraft.advancements.critereon.PlacedBlockTrigger; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.fluid.FlowingFluid; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.data.HashCache; +import net.minecraft.data.DataProvider; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.TranslatableComponent; @SuppressWarnings("unused") // dont warn about unused avancements -public class AllAdvancements implements IDataProvider { +public class AllAdvancements implements DataProvider { static final String LANG = "advancement." + Create.ID + "."; @@ -46,11 +46,11 @@ public class AllAdvancements implements IDataProvider { String id = Create.ID; Advancement root = Advancement.Builder.advancement() - .display(AllItems.BRASS_HAND.asStack(), new TranslationTextComponent(LANG + "root"), - new TranslationTextComponent(LANG + "root.desc"), + .display(AllItems.BRASS_HAND.asStack(), new TranslatableComponent(LANG + "root"), + new TranslatableComponent(LANG + "root.desc"), new ResourceLocation(Create.ID, "textures/block/palettes/gabbro/bricks.png"), FrameType.TASK, false, false, false) - .addCriterion("0", InventoryChangeTrigger.Instance.hasItems(new IItemProvider[] {})) + .addCriterion("0", InventoryChangeTrigger.TriggerInstance.hasItems(new ItemLike[] {})) .save(t, id + ":root"); Advancement andesite_alloy = @@ -446,7 +446,7 @@ public class AllAdvancements implements IDataProvider { } @Override - public void run(DirectoryCache cache) throws IOException { + public void run(HashCache cache) throws IOException { Path path = this.generator.getOutputFolder(); Set set = Sets.newHashSet(); Consumer consumer = (p_204017_3_) -> { @@ -456,7 +456,7 @@ public class AllAdvancements implements IDataProvider { Path path1 = getPath(path, p_204017_3_); try { - IDataProvider.save(GSON, cache, p_204017_3_.deconstruct() + DataProvider.save(GSON, cache, p_204017_3_.deconstruct() .serializeToJson(), path1); } catch (IOException ioexception) { LOGGER.error("Couldn't save advancement {}", path1, ioexception); @@ -479,16 +479,16 @@ public class AllAdvancements implements IDataProvider { return "Create's Advancements"; } - public PlacedBlockTrigger.Instance placeBlock(Block block) { - return PlacedBlockTrigger.Instance.placedBlock(block); + public PlacedBlockTrigger.TriggerInstance placeBlock(Block block) { + return PlacedBlockTrigger.TriggerInstance.placedBlock(block); } public RegistryTrigger.Instance isInfinite(FlowingFluid fluid) { return AllTriggers.INFINITE_FLUID.forEntries(fluid.getSource()); } - public InventoryChangeTrigger.Instance itemGathered(IItemProvider itemprovider) { - return InventoryChangeTrigger.Instance.hasItems(itemprovider); + public InventoryChangeTrigger.TriggerInstance itemGathered(ItemLike itemprovider) { + return InventoryChangeTrigger.TriggerInstance.hasItems(itemprovider); } static enum TaskType { @@ -520,7 +520,7 @@ public class AllAdvancements implements IDataProvider { // .withCriterion("1", isPowered(block)); Duplicate toast } - public Builder advancement(String name, IItemProvider icon, TaskType type) { + public Builder advancement(String name, ItemLike icon, TaskType type) { return advancement(name, new ItemStack(icon), type); } @@ -530,12 +530,12 @@ public class AllAdvancements implements IDataProvider { public Builder advancement(String name, ItemStack icon, TaskType type) { return Advancement.Builder.advancement() - .display(icon, new TranslationTextComponent(LANG + name), - new TranslationTextComponent(LANG + name + ".desc"), null, type.frame, type.toast, type.announce, + .display(icon, new TranslatableComponent(LANG + name), + new TranslatableComponent(LANG + name + ".desc"), null, type.frame, type.toast, type.announce, type.hide); } - public Builder itemAdvancement(String name, Supplier item, TaskType type) { + public Builder itemAdvancement(String name, Supplier item, TaskType type) { 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 d3af35134..7cd2540d5 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java @@ -7,13 +7,13 @@ import java.util.function.Predicate; import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import net.minecraft.advancements.CriteriaTriggers; -import net.minecraft.block.Block; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; import net.minecraftforge.registries.ForgeRegistries; public class AllTriggers { @@ -59,28 +59,28 @@ public class AllTriggers { triggers.forEach(CriteriaTriggers::register); } - public static void triggerFor(ITriggerable trigger, PlayerEntity player) { - if (player instanceof ServerPlayerEntity) - trigger.trigger((ServerPlayerEntity) player); + public static void triggerFor(ITriggerable trigger, Player player) { + if (player instanceof ServerPlayer) + trigger.trigger((ServerPlayer) player); } - public static void triggerForNearbyPlayers(ITriggerable trigger, IWorld world, BlockPos pos, int range) { + public static void triggerForNearbyPlayers(ITriggerable trigger, LevelAccessor world, BlockPos pos, int range) { triggerForNearbyPlayers(trigger, world, pos, range, player -> true); } - public static void triggerForNearbyPlayers(ITriggerable trigger, IWorld world, BlockPos pos, int range, - Predicate playerFilter) { + public static void triggerForNearbyPlayers(ITriggerable trigger, LevelAccessor world, BlockPos pos, int range, + Predicate playerFilter) { if (world == null) return; if (world.isClientSide()) return; - List players = getPlayersInRange(world, pos, range); + List players = getPlayersInRange(world, pos, range); players.stream() .filter(playerFilter) .forEach(trigger::trigger); } - public static List getPlayersInRange(IWorld world, BlockPos pos, int range) { - return world.getEntitiesOfClass(ServerPlayerEntity.class, new AxisAlignedBB(pos).inflate(range)); + public static List getPlayersInRange(LevelAccessor world, BlockPos pos, int range) { + return world.getEntitiesOfClass(ServerPlayer.class, new AABB(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 e3ab6d356..4f3adacd9 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java @@ -14,16 +14,18 @@ import com.google.common.collect.Maps; import com.simibubi.create.Create; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.advancements.ICriterionTrigger; -import net.minecraft.advancements.PlayerAdvancements; -import net.minecraft.advancements.criterion.CriterionInstance; -import net.minecraft.advancements.criterion.EntityPredicate; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.ResourceLocation; +import net.minecraft.advancements.CriterionTrigger; +import net.minecraft.server.PlayerAdvancements; +import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance; +import net.minecraft.advancements.critereon.EntityPredicate; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.resources.ResourceLocation; + +import net.minecraft.advancements.CriterionTrigger.Listener; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public abstract class CriterionTriggerBase implements ICriterionTrigger { +public abstract class CriterionTriggerBase implements CriterionTrigger { public CriterionTriggerBase(String id) { this.id = Create.asResource(id); @@ -60,7 +62,7 @@ public abstract class CriterionTriggerBase> suppliers) { + protected void trigger(ServerPlayer player, @Nullable List> suppliers) { PlayerAdvancements playerAdvancements = player.getAdvancements(); Set> playerListeners = this.listeners.get(playerAdvancements); if (playerListeners != null) { @@ -78,9 +80,9 @@ public abstract class CriterionTriggerBase } @Override - public Instance createInstance(JsonObject json, ConditionArrayParser context) { + public Instance createInstance(JsonObject json, DeserializationContext context) { return new Instance(getId()); } - public void trigger(ServerPlayerEntity player) { + public void trigger(ServerPlayer player) { super.trigger(player, null); } @@ -38,7 +38,7 @@ public class SimpleTrigger extends CriterionTriggerBase public static class Instance extends CriterionTriggerBase.Instance { public Instance(ResourceLocation idIn) { - super(idIn, EntityPredicate.AndPredicate.ANY); // FIXME: Is this right? + super(idIn, EntityPredicate.Composite.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 0c2c3b8fe..6278abc4d 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/StringSerializableTrigger.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/StringSerializableTrigger.java @@ -17,10 +17,10 @@ import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.advancements.criterion.EntityPredicate; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.loot.ConditionArrayParser; -import net.minecraft.loot.ConditionArraySerializer; +import net.minecraft.advancements.critereon.EntityPredicate; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.advancements.critereon.DeserializationContext; +import net.minecraft.advancements.critereon.SerializationContext; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault @@ -39,7 +39,7 @@ public abstract class StringSerializableTrigger extends CriterionTriggerBase< return new Instance<>(this, entries == null ? null : Sets.newHashSet(entries)); } - public void trigger(ServerPlayerEntity player, @Nullable T registryEntry) { + public void trigger(ServerPlayer player, @Nullable T registryEntry) { trigger(player, Collections.singletonList(() -> registryEntry)); } @@ -48,7 +48,7 @@ public abstract class StringSerializableTrigger extends CriterionTriggerBase< } @Override - public Instance createInstance(JsonObject json, ConditionArrayParser context) { + public Instance createInstance(JsonObject json, DeserializationContext 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.ANY); + super(trigger.getId(), EntityPredicate.Composite.ANY); this.trigger = trigger; this.entries = entries; } @@ -91,7 +91,7 @@ public abstract class StringSerializableTrigger extends CriterionTriggerBase< } @Override - public JsonObject serializeToJson(ConditionArraySerializer p_230240_1_) { + public JsonObject serializeToJson(SerializationContext p_230240_1_) { JsonObject jsonobject = super.serializeToJson(p_230240_1_); JsonArray elements = new JsonArray(); diff --git a/src/main/java/com/simibubi/create/foundation/block/BlockStressDefaults.java b/src/main/java/com/simibubi/create/foundation/block/BlockStressDefaults.java index 44f3ba01a..bb01db140 100644 --- a/src/main/java/com/simibubi/create/foundation/block/BlockStressDefaults.java +++ b/src/main/java/com/simibubi/create/foundation/block/BlockStressDefaults.java @@ -6,8 +6,8 @@ import java.util.Map; import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; -import net.minecraft.block.Block; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.resources.ResourceLocation; public class BlockStressDefaults { diff --git a/src/main/java/com/simibubi/create/foundation/block/BlockStressValues.java b/src/main/java/com/simibubi/create/foundation/block/BlockStressValues.java index 6b9b4fe01..682622bf3 100644 --- a/src/main/java/com/simibubi/create/foundation/block/BlockStressValues.java +++ b/src/main/java/com/simibubi/create/foundation/block/BlockStressValues.java @@ -5,8 +5,8 @@ import java.util.Map; import javax.annotation.Nullable; -import net.minecraft.block.Block; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.resources.ResourceLocation; public class BlockStressValues { diff --git a/src/main/java/com/simibubi/create/foundation/block/BreakProgressHook.java b/src/main/java/com/simibubi/create/foundation/block/BreakProgressHook.java index 99d30de2c..d88e6f7ac 100644 --- a/src/main/java/com/simibubi/create/foundation/block/BreakProgressHook.java +++ b/src/main/java/com/simibubi/create/foundation/block/BreakProgressHook.java @@ -4,13 +4,13 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.BlockPos; public class BreakProgressHook { - public static void whenBreaking(ClientWorld world, WorldRenderer renderer, int playerEntityId, BlockPos pos, int progress) { + public static void whenBreaking(ClientLevel world, LevelRenderer renderer, int playerEntityId, BlockPos pos, int progress) { if (AllBlocks.BELT.has(world.getBlockState(pos))) { BeltTileEntity belt = (BeltTileEntity) world.getBlockEntity(pos); diff --git a/src/main/java/com/simibubi/create/foundation/block/DyedBlockList.java b/src/main/java/com/simibubi/create/foundation/block/DyedBlockList.java index ee016e3c7..e0d1d2f54 100644 --- a/src/main/java/com/simibubi/create/foundation/block/DyedBlockList.java +++ b/src/main/java/com/simibubi/create/foundation/block/DyedBlockList.java @@ -5,8 +5,8 @@ import java.util.function.Function; import com.tterrag.registrate.util.entry.BlockEntry; -import net.minecraft.block.Block; -import net.minecraft.item.DyeColor; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.item.DyeColor; public class DyedBlockList { 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 f84a378ae..dd1d9be08 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ITE.java +++ b/src/main/java/com/simibubi/create/foundation/block/ITE.java @@ -6,32 +6,32 @@ import java.util.function.Function; import javax.annotation.Nullable; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; -public interface ITE { +public interface ITE { Class getTileEntityClass(); - default void withTileEntityDo(IBlockReader world, BlockPos pos, Consumer action) { + default void withTileEntityDo(BlockGetter world, BlockPos pos, Consumer action) { getTileEntityOptional(world, pos).ifPresent(action); } - default ActionResultType onTileEntityUse(IBlockReader world, BlockPos pos, Function action) { + default InteractionResult onTileEntityUse(BlockGetter world, BlockPos pos, Function action) { return getTileEntityOptional(world, pos).map(action) - .orElse(ActionResultType.PASS); + .orElse(InteractionResult.PASS); } - default Optional getTileEntityOptional(IBlockReader world, BlockPos pos) { + default Optional getTileEntityOptional(BlockGetter world, BlockPos pos) { return Optional.ofNullable(getTileEntity(world, pos)); } @Nullable @SuppressWarnings("unchecked") - default T getTileEntity(IBlockReader worldIn, BlockPos pos) { - TileEntity tileEntity = worldIn.getBlockEntity(pos); + default T getTileEntity(BlockGetter worldIn, BlockPos pos) { + BlockEntity 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 5dfee53d8..962864e47 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java +++ b/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java @@ -6,11 +6,11 @@ import java.util.Set; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.InteractionResult; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -37,9 +37,9 @@ public class ItemUseOverrides { if (!OVERRIDES.contains(id)) return; - BlockRayTraceResult blockTrace = - new BlockRayTraceResult(VecHelper.getCenterOf(event.getPos()), event.getFace(), event.getPos(), true); - ActionResultType result = state.use(event.getWorld(), event.getPlayer(), event.getHand(), blockTrace); + BlockHitResult blockTrace = + new BlockHitResult(VecHelper.getCenterOf(event.getPos()), event.getFace(), event.getPos(), true); + InteractionResult result = state.use(event.getWorld(), event.getPlayer(), event.getHand(), blockTrace); if (!result.consumesAction()) return; diff --git a/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java b/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java index 8847e125c..b5df44960 100644 --- a/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java +++ b/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java @@ -3,14 +3,16 @@ package com.simibubi.create.foundation.block; import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.utility.DirectionHelper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.DirectionalBlock; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.Direction; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class WrenchableDirectionalBlock extends DirectionalBlock implements IWrenchable { @@ -37,7 +39,7 @@ public class WrenchableDirectionalBlock extends DirectionalBlock implements IWre } @Override - public BlockState getStateForPlacement(BlockItemUseContext context) { + public BlockState getStateForPlacement(BlockPlaceContext context) { return defaultBlockState().setValue(FACING, context.getNearestLookingDirection()); } diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/BakedModelWrapperWithData.java b/src/main/java/com/simibubi/create/foundation/block/connected/BakedModelWrapperWithData.java index 139408fa9..9a1857d56 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/BakedModelWrapperWithData.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/BakedModelWrapperWithData.java @@ -1,29 +1,29 @@ package com.simibubi.create.foundation.block.connected; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.BakedModelWrapper; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelDataMap.Builder; -public abstract class BakedModelWrapperWithData extends BakedModelWrapper { +public abstract class BakedModelWrapperWithData extends BakedModelWrapper { - public BakedModelWrapperWithData(IBakedModel originalModel) { + public BakedModelWrapperWithData(BakedModel originalModel) { super(originalModel); } @Override - public final IModelData getModelData(IBlockDisplayReader world, BlockPos pos, BlockState state, IModelData tileData) { + public final IModelData getModelData(BlockAndTintGetter world, BlockPos pos, BlockState state, IModelData tileData) { Builder builder = new ModelDataMap.Builder(); if (originalModel instanceof BakedModelWrapperWithData) ((BakedModelWrapperWithData) originalModel).gatherModelData(builder, world, pos, state); return gatherModelData(builder, world, pos, state).build(); } - protected abstract ModelDataMap.Builder gatherModelData(ModelDataMap.Builder builder, IBlockDisplayReader world, + protected abstract ModelDataMap.Builder gatherModelData(ModelDataMap.Builder builder, BlockAndTintGetter world, BlockPos pos, BlockState state); } 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 51971939d..5a52c5a49 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 @@ -9,15 +9,15 @@ import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour. import com.simibubi.create.foundation.block.render.QuadHelper; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap.Builder; import net.minecraftforge.client.model.data.ModelProperty; @@ -44,17 +44,17 @@ public class CTModel extends BakedModelWrapperWithData { } } - public CTModel(IBakedModel originalModel, ConnectedTextureBehaviour behaviour) { + public CTModel(BakedModel originalModel, ConnectedTextureBehaviour behaviour) { super(originalModel); this.behaviour = behaviour; } @Override - protected Builder gatherModelData(Builder builder, IBlockDisplayReader world, BlockPos pos, BlockState state) { + protected Builder gatherModelData(Builder builder, BlockAndTintGetter world, BlockPos pos, BlockState state) { return builder.withInitial(CT_PROPERTY, createCTData(world, pos, state)); } - protected CTData createCTData(IBlockDisplayReader world, BlockPos pos, BlockState state) { + protected CTData createCTData(BlockAndTintGetter world, BlockPos pos, BlockState state) { CTData data = new CTData(); for (Direction face : Iterate.directions) { if (!Block.shouldRenderFace(state, world, pos, face) && !behaviour.buildContextForOccludedDirections()) @@ -76,7 +76,7 @@ public class CTModel extends BakedModelWrapperWithData { CTData data = extraData.getData(CT_PROPERTY); quads = new ArrayList<>(quads); - VertexFormat format = DefaultVertexFormats.BLOCK; + VertexFormat format = DefaultVertexFormat.BLOCK; for (int i = 0; i < quads.size(); i++) { BakedQuad quad = quads.get(i); diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShifter.java b/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShifter.java index 588656377..9b9722a67 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShifter.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShifter.java @@ -3,7 +3,7 @@ package com.simibubi.create.foundation.block.connected; import com.simibubi.create.Create; import com.simibubi.create.foundation.block.render.SpriteShifter; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class CTSpriteShifter extends SpriteShifter { 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 e2a8f06ed..6bda49b82 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 @@ -2,12 +2,12 @@ package com.simibubi.create.foundation.block.connected; import com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; public abstract class ConnectedTextureBehaviour { @@ -34,12 +34,12 @@ public abstract class ConnectedTextureBehaviour { return false; } - public boolean connectsTo(BlockState state, BlockState other, IBlockDisplayReader reader, BlockPos pos, BlockPos otherPos, + public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, Direction face) { return !isBeingBlocked(state, reader, pos, otherPos, face) && state.getBlock() == other.getBlock(); } - protected boolean isBeingBlocked(BlockState state, IBlockDisplayReader reader, BlockPos pos, BlockPos otherPos, + protected boolean isBeingBlocked(BlockState state, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, Direction face) { BlockPos blockingPos = otherPos.relative(face); return face.getAxis() @@ -48,7 +48,7 @@ public abstract class ConnectedTextureBehaviour { && connectsTo(state, reader.getBlockState(blockingPos), reader, pos, blockingPos, face); } - public CTContext buildContext(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face) { + public CTContext buildContext(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) { CTContext context = new CTContext(); CTSpriteShiftEntry textureEntry = get(state, face); @@ -94,17 +94,17 @@ public abstract class ConnectedTextureBehaviour { return context; } - protected Direction getUpDirection(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face) { + protected Direction getUpDirection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) { Axis axis = face.getAxis(); return axis.isHorizontal() ? Direction.UP : Direction.NORTH; } - protected Direction getRightDirection(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face) { + protected Direction getRightDirection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) { Axis axis = face.getAxis(); return axis == Axis.X ? Direction.SOUTH : Direction.WEST; } - private boolean testConnection(IBlockDisplayReader reader, BlockPos pos, BlockState state, Direction face, + private boolean testConnection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face, final Direction horizontal, final Direction vertical, int sh, int sv) { BlockPos p = pos.relative(horizontal, sh) .relative(vertical, sv); diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/GlassPaneCTBehaviour.java b/src/main/java/com/simibubi/create/foundation/block/connected/GlassPaneCTBehaviour.java index c07a2811c..037db0b4d 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/GlassPaneCTBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/GlassPaneCTBehaviour.java @@ -1,10 +1,10 @@ package com.simibubi.create.foundation.block.connected; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; public class GlassPaneCTBehaviour extends StandardCTBehaviour { @@ -18,13 +18,13 @@ public class GlassPaneCTBehaviour extends StandardCTBehaviour { } @Override - public boolean connectsTo(BlockState state, BlockState other, IBlockDisplayReader reader, BlockPos pos, BlockPos otherPos, + public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, Direction face) { return state.getBlock() == other.getBlock(); } @Override - protected boolean reverseUVsHorizontally(BlockState state, net.minecraft.util.Direction face) { + protected boolean reverseUVsHorizontally(BlockState state, net.minecraft.core.Direction face) { if (face.getAxisDirection() == AxisDirection.NEGATIVE) return true; return super.reverseUVsHorizontally(state, face); diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/HorizontalCTBehaviour.java b/src/main/java/com/simibubi/create/foundation/block/connected/HorizontalCTBehaviour.java index 45f1ccb88..430938a76 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/HorizontalCTBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/HorizontalCTBehaviour.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.block.connected; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; public class HorizontalCTBehaviour extends ConnectedTextureBehaviour { diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/StandardCTBehaviour.java b/src/main/java/com/simibubi/create/foundation/block/connected/StandardCTBehaviour.java index 54b83d88b..da75ad769 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/StandardCTBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/StandardCTBehaviour.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.block.connected; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; public class StandardCTBehaviour extends ConnectedTextureBehaviour { 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 305e4364d..ab6526c2d 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 @@ -4,32 +4,32 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.VertexFormatElement; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; import net.minecraftforge.client.model.BakedModelWrapper; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelProperty; -public class ColoredVertexModel extends BakedModelWrapper { +public class ColoredVertexModel extends BakedModelWrapper { private static final ModelProperty POSITION_PROPERTY = new ModelProperty<>(); private IBlockVertexColor color; - public ColoredVertexModel(IBakedModel originalModel, IBlockVertexColor color) { + public ColoredVertexModel(BakedModel originalModel, IBlockVertexColor color) { super(originalModel); this.color = color; } @Override - public IModelData getModelData(IBlockDisplayReader world, BlockPos pos, BlockState state, IModelData tileData) { + public IModelData getModelData(BlockAndTintGetter world, BlockPos pos, BlockState state, IModelData tileData) { return new ModelDataMap.Builder().withInitial(POSITION_PROPERTY, pos).build(); } @@ -44,7 +44,7 @@ public class ColoredVertexModel extends BakedModelWrapper { quads = new ArrayList<>(quads); // Optifine might've rejigged vertex data - VertexFormat format = DefaultVertexFormats.BLOCK; + VertexFormat format = DefaultVertexFormat.BLOCK; int colorIndex = 0; for (int elementId = 0; elementId < format.getElements().size(); elementId++) { VertexFormatElement element = format.getElements().get(elementId); diff --git a/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java b/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java index f3414bc10..dc377f4bd 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java @@ -11,13 +11,13 @@ import org.apache.commons.lang3.tuple.Pair; import com.tterrag.registrate.util.nullness.NonNullBiConsumer; import com.tterrag.registrate.util.nullness.NonNullFunction; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.world.level.block.Block; +import net.minecraft.client.resources.model.BakedModel; public class CustomBlockModels { - private List, NonNullFunction>> registered; - private Map> customModels; + private List, NonNullFunction>> registered; + private Map> customModels; public CustomBlockModels() { registered = new ArrayList<>(); @@ -25,11 +25,11 @@ public class CustomBlockModels { } public void register(Supplier entry, - NonNullFunction behaviour) { + NonNullFunction behaviour) { registered.add(Pair.of(entry, behaviour)); } - public void forEach(NonNullBiConsumer> consumer) { + public void forEach(NonNullBiConsumer> consumer) { loadEntriesIfMissing(); customModels.forEach(consumer); } @@ -45,7 +45,7 @@ public class CustomBlockModels { Block key = p.getKey() .get(); - NonNullFunction existingModel = customModels.get(key); + NonNullFunction existingModel = customModels.get(key); if (existingModel != null) { customModels.put(key, p.getValue() .andThen(existingModel)); 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 68dc08dac..c6ce5aa9a 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 @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.block.render; import java.util.Arrays; -import net.minecraft.client.renderer.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BakedQuad; public final class QuadHelper { 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 1dc17a7fc..0f365ba58 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 @@ -1,8 +1,8 @@ package com.simibubi.create.foundation.block.render; -import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class SpriteShiftEntry { protected ResourceLocation originalTextureLocation; @@ -31,7 +31,7 @@ public class SpriteShiftEntry { return target; } - protected void loadTextures(AtlasTexture atlas) { + protected void loadTextures(TextureAtlas atlas) { original = atlas.getSprite(originalTextureLocation); target = atlas.getSprite(targetTextureLocation); } diff --git a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java index f91b80dc3..3b48af830 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java @@ -7,9 +7,9 @@ import java.util.stream.Collectors; import com.simibubi.create.Create; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.inventory.container.PlayerContainer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.event.TextureStitchEvent; public class SpriteShifter { @@ -38,7 +38,7 @@ public class SpriteShifter { public static void onTextureStitchPre(TextureStitchEvent.Pre event) { if (!event.getMap() .location() - .equals(PlayerContainer.BLOCK_ATLAS)) + .equals(InventoryMenu.BLOCK_ATLAS)) return; getAllTargetSprites() @@ -48,10 +48,10 @@ public class SpriteShifter { public static void onTextureStitchPost(TextureStitchEvent.Post event) { if (!event.getMap() .location() - .equals(PlayerContainer.BLOCK_ATLAS)) + .equals(InventoryMenu.BLOCK_ATLAS)) return; - AtlasTexture atlas = event.getMap(); + TextureAtlas atlas = event.getMap(); for (SpriteShiftEntry entry : ENTRY_CACHE.values()) { entry.loadTextures(atlas); } 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 39ff0d745..3f7836c3a 100644 --- a/src/main/java/com/simibubi/create/foundation/collision/ContinuousOBBCollider.java +++ b/src/main/java/com/simibubi/create/foundation/collision/ContinuousOBBCollider.java @@ -3,19 +3,19 @@ package com.simibubi.create.foundation.collision; import static java.lang.Math.abs; import static java.lang.Math.signum; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public class ContinuousOBBCollider extends OBBCollider { - public static ContinuousSeparationManifold separateBBs(Vector3d cA, Vector3d cB, Vector3d eA, Vector3d eB, - Matrix3d m, Vector3d motion) { + public static ContinuousSeparationManifold separateBBs(Vec3 cA, Vec3 cB, Vec3 eA, Vec3 eB, + Matrix3d m, Vec3 motion) { ContinuousSeparationManifold mf = new ContinuousSeparationManifold(); - Vector3d diff = cB.subtract(cA); + Vec3 diff = cB.subtract(cA); m.transpose(); - Vector3d diff2 = m.transform(diff); - Vector3d motion2 = m.transform(motion); + Vec3 diff2 = m.transform(diff); + Vec3 motion2 = m.transform(motion); m.transpose(); double a00 = abs(m.m00); @@ -28,9 +28,9 @@ public class ContinuousOBBCollider extends OBBCollider { double a21 = abs(m.m21); double a22 = abs(m.m22); - Vector3d uB0 = new Vector3d(m.m00, m.m10, m.m20); - Vector3d uB1 = new Vector3d(m.m01, m.m11, m.m21); - Vector3d uB2 = new Vector3d(m.m02, m.m12, m.m22); + Vec3 uB0 = new Vec3(m.m00, m.m10, m.m20); + Vec3 uB1 = new Vec3(m.m01, m.m11, m.m21); + Vec3 uB2 = new Vec3(m.m02, m.m12, m.m22); checkCount = 0; mf.stepSeparationAxis = uB1; @@ -52,7 +52,7 @@ public class ContinuousOBBCollider extends OBBCollider { return null; } - static boolean separate(ContinuousSeparationManifold mf, Vector3d axis, double TL, double rA, double rB, + static boolean separate(ContinuousSeparationManifold mf, Vec3 axis, double TL, double rA, double rB, double projectedMotion, boolean axisOfObjA) { checkCount++; double distance = abs(TL); @@ -79,7 +79,7 @@ public class ContinuousOBBCollider extends OBBCollider { mf.earliestCollisionExitTime = Math.min(exitTime, mf.earliestCollisionExitTime); } - Vector3d normalizedAxis = axis.normalize(); + Vec3 normalizedAxis = axis.normalize(); boolean isBestSeperation = distance != 0 && -(diff) <= abs(mf.separation); // boolean isBestSeperation = discreteCollision && checkCount == 5; // Debug specific separations @@ -91,15 +91,15 @@ public class ContinuousOBBCollider extends OBBCollider { double dot = mf.stepSeparationAxis.dot(axis); if (dot != 0 && discreteCollision) { - Vector3d cross = axis.cross(mf.stepSeparationAxis); + Vec3 cross = axis.cross(mf.stepSeparationAxis); double dotSeparation = signum(dot) * TL - (rA + rB); double stepSeparation = -dotSeparation; - Vector3d stepSeparationVec = axis; + Vec3 stepSeparationVec = axis; - if (!cross.equals(Vector3d.ZERO)) { - Vector3d sepVec = normalizedAxis.scale(dotSeparation); - Vector3d axisPlane = axis.cross(cross); - Vector3d stepPlane = mf.stepSeparationAxis.cross(cross); + if (!cross.equals(Vec3.ZERO)) { + Vec3 sepVec = normalizedAxis.scale(dotSeparation); + Vec3 axisPlane = axis.cross(cross); + Vec3 stepPlane = mf.stepSeparationAxis.cross(cross); stepSeparationVec = sepVec.subtract(axisPlane.scale(sepVec.dot(stepPlane) / axisPlane.dot(stepPlane))); stepSeparation = stepSeparationVec.length(); @@ -128,12 +128,12 @@ public class ContinuousOBBCollider extends OBBCollider { double latestCollisionEntryTime = UNDEFINED; double earliestCollisionExitTime = Double.MAX_VALUE; boolean isDiscreteCollision = true; - Vector3d collisionPosition; + Vec3 collisionPosition; - Vector3d stepSeparationAxis; + Vec3 stepSeparationAxis; double stepSeparation; - Vector3d normalAxis; + Vec3 normalAxis; double normalSeparation; public double getTimeOfImpact() { @@ -148,15 +148,15 @@ public class ContinuousOBBCollider extends OBBCollider { return true; } - public Vector3d getCollisionNormal() { + public Vec3 getCollisionNormal() { return normalAxis == null ? null : createSeparationVec(normalSeparation, normalAxis); } - public Vector3d getCollisionPosition() { + public Vec3 getCollisionPosition() { return collisionPosition; } - public Vector3d asSeparationVec(double obbStepHeight) { + public Vec3 asSeparationVec(double obbStepHeight) { if (isDiscreteCollision) { if (stepSeparation <= obbStepHeight) return createSeparationVec(stepSeparation, stepSeparationAxis); @@ -165,11 +165,11 @@ public class ContinuousOBBCollider extends OBBCollider { double t = getTimeOfImpact(); if (t == UNDEFINED) return null; - return Vector3d.ZERO; + return Vec3.ZERO; } @Override - public Vector3d asSeparationVec() { + public Vec3 asSeparationVec() { return asSeparationVec(0); } diff --git a/src/main/java/com/simibubi/create/foundation/collision/Matrix3d.java b/src/main/java/com/simibubi/create/foundation/collision/Matrix3d.java index 20cbef687..b37a1890d 100644 --- a/src/main/java/com/simibubi/create/foundation/collision/Matrix3d.java +++ b/src/main/java/com/simibubi/create/foundation/collision/Matrix3d.java @@ -1,8 +1,8 @@ package com.simibubi.create.foundation.collision; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.Mth; +import com.mojang.math.Matrix4f; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -23,8 +23,8 @@ public class Matrix3d { if (radians == 0) return this; - double s = MathHelper.sin(radians); - double c = MathHelper.cos(radians); + double s = Mth.sin(radians); + double c = Mth.cos(radians); m22 = m11 = c; m21 = s; m12 = -s; @@ -36,8 +36,8 @@ public class Matrix3d { if (radians == 0) return this; - double s = MathHelper.sin(radians); - double c = MathHelper.cos(radians); + double s = Mth.sin(radians); + double c = Mth.cos(radians); m00 = m22 = c; m20 = s; m02 = -s; @@ -49,8 +49,8 @@ public class Matrix3d { if (radians == 0) return this; - double s = MathHelper.sin(radians); - double c = MathHelper.cos(radians); + double s = Mth.sin(radians); + double c = Mth.cos(radians); m00 = m11 = c; m01 = -s; m10 = s; @@ -112,11 +112,11 @@ public class Matrix3d { return this; } - public Vector3d transform(Vector3d vec) { + public Vec3 transform(Vec3 vec) { double x = vec.x * m00 + vec.y * m01 + vec.z * m02; double y = vec.x * m10 + vec.y * m11 + vec.z * m12; double z = vec.x * m20 + vec.y * m21 + vec.z * m22; - return new Vector3d(x, y, z); + return new Vec3(x, y, z); } public Matrix3d copy() { diff --git a/src/main/java/com/simibubi/create/foundation/collision/OBBCollider.java b/src/main/java/com/simibubi/create/foundation/collision/OBBCollider.java index 29a29474f..5e8f43506 100644 --- a/src/main/java/com/simibubi/create/foundation/collision/OBBCollider.java +++ b/src/main/java/com/simibubi/create/foundation/collision/OBBCollider.java @@ -3,18 +3,18 @@ package com.simibubi.create.foundation.collision; import static java.lang.Math.abs; import static java.lang.Math.signum; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public class OBBCollider { - static final Vector3d uA0 = new Vector3d(1, 0, 0); - static final Vector3d uA1 = new Vector3d(0, 1, 0); - static final Vector3d uA2 = new Vector3d(0, 0, 1); + static final Vec3 uA0 = new Vec3(1, 0, 0); + static final Vec3 uA1 = new Vec3(0, 1, 0); + static final Vec3 uA2 = new Vec3(0, 0, 1); - public static Vector3d separateBBs(Vector3d cA, Vector3d cB, Vector3d eA, Vector3d eB, Matrix3d m) { + public static Vec3 separateBBs(Vec3 cA, Vec3 cB, Vec3 eA, Vec3 eB, Matrix3d m) { SeparationManifold mf = new SeparationManifold(); - Vector3d t = cB.subtract(cA); + Vec3 t = cB.subtract(cA); double a00 = abs(m.m00); double a01 = abs(m.m01); @@ -26,9 +26,9 @@ public class OBBCollider { double a21 = abs(m.m21); double a22 = abs(m.m22); - Vector3d uB0 = new Vector3d(m.m00, m.m10, m.m20); - Vector3d uB1 = new Vector3d(m.m01, m.m11, m.m21); - Vector3d uB2 = new Vector3d(m.m02, m.m12, m.m22); + Vec3 uB0 = new Vec3(m.m00, m.m10, m.m20); + Vec3 uB1 = new Vec3(m.m01, m.m11, m.m21); + Vec3 uB2 = new Vec3(m.m02, m.m12, m.m22); checkCount = 0; @@ -52,7 +52,7 @@ public class OBBCollider { static int checkCount = 0; - static boolean isSeparatedAlong(SeparationManifold mf, Vector3d axis, double TL, double rA, double rB) { + static boolean isSeparatedAlong(SeparationManifold mf, Vec3 axis, double TL, double rA, double rB) { checkCount++; double distance = abs(TL); double diff = distance - (rA + rB); @@ -72,21 +72,21 @@ public class OBBCollider { } static class SeparationManifold { - Vector3d axis; + Vec3 axis; double separation; public SeparationManifold() { - axis = Vector3d.ZERO; + axis = Vec3.ZERO; separation = Double.MAX_VALUE; } - public Vector3d asSeparationVec() { + public Vec3 asSeparationVec() { double sep = separation; - Vector3d axis = this.axis; + Vec3 axis = this.axis; return createSeparationVec(sep, axis); } - protected Vector3d createSeparationVec(double sep, Vector3d axis) { + protected Vec3 createSeparationVec(double sep, Vec3 axis) { return axis.normalize() .scale(signum(sep) * (abs(sep) + 1E-4)); } 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 2fa4c582d..ab5ca4a40 100644 --- a/src/main/java/com/simibubi/create/foundation/collision/OrientedBB.java +++ b/src/main/java/com/simibubi/create/foundation/collision/OrientedBB.java @@ -2,24 +2,24 @@ package com.simibubi.create.foundation.collision; import com.simibubi.create.foundation.collision.ContinuousOBBCollider.ContinuousSeparationManifold; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; public class OrientedBB { - Vector3d center; - Vector3d extents; + Vec3 center; + Vec3 extents; Matrix3d rotation; - public OrientedBB(AxisAlignedBB bb) { + public OrientedBB(AABB bb) { this(bb.getCenter(), extentsFromBB(bb), new Matrix3d().asIdentity()); } public OrientedBB() { - this(Vector3d.ZERO, Vector3d.ZERO, new Matrix3d().asIdentity()); + this(Vec3.ZERO, Vec3.ZERO, new Matrix3d().asIdentity()); } - public OrientedBB(Vector3d center, Vector3d extents, Matrix3d rotation) { + public OrientedBB(Vec3 center, Vec3 extents, Matrix3d rotation) { this.setCenter(center); this.extents = extents; this.setRotation(rotation); @@ -29,19 +29,19 @@ public class OrientedBB { return new OrientedBB(center, extents, rotation); } - public Vector3d intersect(AxisAlignedBB bb) { - Vector3d extentsA = extentsFromBB(bb); - Vector3d intersects = OBBCollider.separateBBs(bb.getCenter(), center, extentsA, extents, rotation); + public Vec3 intersect(AABB bb) { + Vec3 extentsA = extentsFromBB(bb); + Vec3 intersects = OBBCollider.separateBBs(bb.getCenter(), center, extentsA, extents, rotation); return intersects; } - public ContinuousSeparationManifold intersect(AxisAlignedBB bb, Vector3d motion) { - Vector3d extentsA = extentsFromBB(bb); + public ContinuousSeparationManifold intersect(AABB bb, Vec3 motion) { + Vec3 extentsA = extentsFromBB(bb); return ContinuousOBBCollider.separateBBs(bb.getCenter(), center, extentsA, extents, rotation, motion); } - private static Vector3d extentsFromBB(AxisAlignedBB bb) { - return new Vector3d(bb.getXsize() / 2, bb.getYsize() / 2, bb.getZsize() / 2); + private static Vec3 extentsFromBB(AABB bb) { + return new Vec3(bb.getXsize() / 2, bb.getYsize() / 2, bb.getZsize() / 2); } public Matrix3d getRotation() { @@ -52,20 +52,20 @@ public class OrientedBB { this.rotation = rotation; } - public Vector3d getCenter() { + public Vec3 getCenter() { return center; } - public void setCenter(Vector3d center) { + public void setCenter(Vec3 center) { this.center = center; } - public void move(Vector3d offset) { + public void move(Vec3 offset) { setCenter(getCenter().add(offset)); } - public AxisAlignedBB getAsAxisAlignedBB() { - return new AxisAlignedBB(0, 0, 0, 0, 0, 0).move(center) + public AABB getAsAxisAlignedBB() { + return new AABB(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 2e5aa57b7..6885948ed 100644 --- a/src/main/java/com/simibubi/create/foundation/command/AllCommands.java +++ b/src/main/java/com/simibubi/create/foundation/command/AllCommands.java @@ -8,19 +8,19 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.LiteralCommandNode; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.world.entity.player.Player; public class AllCommands { - public static final Predicate SOURCE_IS_PLAYER = cs -> cs.getEntity() instanceof PlayerEntity; + public static final Predicate SOURCE_IS_PLAYER = cs -> cs.getEntity() instanceof Player; - public static void register(CommandDispatcher dispatcher) { + public static void register(CommandDispatcher dispatcher) { - LiteralCommandNode util = buildUtilityCommands(); + LiteralCommandNode util = buildUtilityCommands(); - LiteralCommandNode createRoot = dispatcher.register(Commands.literal("create") + LiteralCommandNode createRoot = dispatcher.register(Commands.literal("create") .requires(cs -> cs.hasPermission(0)) // general purpose .then(new ToggleDebugCommand().register()) @@ -40,7 +40,7 @@ public class AllCommands { createRoot.addChild(buildRedirect("u", util)); - CommandNode c = dispatcher.findNode(Collections.singleton("c")); + CommandNode c = dispatcher.findNode(Collections.singleton("c")); if (c != null) return; @@ -49,7 +49,7 @@ public class AllCommands { } - private static LiteralCommandNode buildUtilityCommands() { + private static LiteralCommandNode buildUtilityCommands() { return Commands.literal("util") .then(ReplaceInCommandBlocksCommand.register()) @@ -74,16 +74,16 @@ public class AllCommands { * * @return the built node */ - public static LiteralCommandNode buildRedirect(final String alias, final LiteralCommandNode destination) { + public static LiteralCommandNode buildRedirect(final String alias, final LiteralCommandNode destination) { // Redirects only work for nodes with children, but break the top argument-less command. // Manually adding the root command after setting the redirect doesn't fix it. // See https://github.com/Mojang/brigadier/issues/46). Manually clone the node instead. - LiteralArgumentBuilder builder = LiteralArgumentBuilder - .literal(alias) + LiteralArgumentBuilder builder = LiteralArgumentBuilder + .literal(alias) .requires(destination.getRequirement()) .forward(destination.getRedirect(), destination.getRedirectModifier(), destination.isFork()) .executes(destination.getCommand()); - for (CommandNode child : destination.getChildren()) { + for (CommandNode child : destination.getChildren()) { builder.then(child); } return builder.build(); 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 af82ccc0a..73a15bb17 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ChunkUtil.java +++ b/src/main/java/com/simibubi/create/foundation/command/ChunkUtil.java @@ -7,18 +7,18 @@ import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.gen.Heightmap; -import net.minecraft.world.server.ChunkHolder; -import net.minecraft.world.server.ServerChunkProvider; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.server.level.ChunkHolder; +import net.minecraft.server.level.ServerChunkCache; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class ChunkUtil { private static final Logger LOGGER = LogManager.getLogger("Create/ChunkUtil"); - final EnumSet POST_FEATURES = EnumSet.of(Heightmap.Type.OCEAN_FLOOR, Heightmap.Type.WORLD_SURFACE, - Heightmap.Type.MOTION_BLOCKING, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES); + final EnumSet POST_FEATURES = EnumSet.of(Heightmap.Types.OCEAN_FLOOR, Heightmap.Types.WORLD_SURFACE, + Heightmap.Types.MOTION_BLOCKING, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES); private final List markedChunks; private final List interestingChunks; @@ -31,7 +31,7 @@ public class ChunkUtil { public void init() { ChunkStatus.FULL = - new ChunkStatus("full", ChunkStatus.HEIGHTMAPS, 0, POST_FEATURES, ChunkStatus.Type.LEVELCHUNK, + new ChunkStatus("full", ChunkStatus.HEIGHTMAPS, 0, POST_FEATURES, ChunkStatus.ChunkType.LEVELCHUNK, (_0, _1, _2, _3, _4, future, _6, chunk) -> future.apply(chunk), (_0, _1, _2, _3, future, chunk) -> { if (markedChunks.contains(chunk.getPos() .toLong())) { @@ -47,7 +47,7 @@ public class ChunkUtil { } - public boolean reloadChunk(ServerChunkProvider provider, ChunkPos pos) { + public boolean reloadChunk(ServerChunkCache provider, ChunkPos pos) { ChunkHolder holder = provider.chunkMap.updatingChunkMap.remove(pos.toLong()); provider.chunkMap.modified = true; if (holder != null) { @@ -59,14 +59,14 @@ public class ChunkUtil { } } - public boolean unloadChunk(ServerChunkProvider provider, ChunkPos pos) { + public boolean unloadChunk(ServerChunkCache provider, ChunkPos pos) { this.interestingChunks.add(pos.toLong()); this.markedChunks.add(pos.toLong()); return this.reloadChunk(provider, pos); } - public int clear(ServerChunkProvider provider) { + public int clear(ServerChunkCache provider) { LinkedList copy = new LinkedList<>(this.markedChunks); int size = this.markedChunks.size(); @@ -77,7 +77,7 @@ public class ChunkUtil { return size; } - public void reForce(ServerChunkProvider provider, ChunkPos pos) { + public void reForce(ServerChunkCache provider, ChunkPos pos) { provider.updateChunkForced(pos, true); provider.updateChunkForced(pos, false); } 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 8179fbbfc..bca1978f4 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java @@ -3,17 +3,17 @@ package com.simibubi.create.foundation.command; import com.mojang.brigadier.builder.ArgumentBuilder; import com.simibubi.create.Create; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.ColumnPosArgument; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.ColumnPos; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.server.ServerChunkProvider; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.coordinates.ColumnPosArgument; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.server.level.ColumnPos; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.server.level.ServerChunkCache; public class ChunkUtilCommand { - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("chunk") .requires(cs -> cs.hasPermission(2)) .then(Commands.literal("reload") @@ -22,7 +22,7 @@ public class ChunkUtilCommand { // chunk reload ColumnPos columnPos = ColumnPosArgument.getColumnPos(ctx, "pos"); ChunkPos chunkPos = new ChunkPos(columnPos.x >> 4, columnPos.z >> 4); - ServerChunkProvider chunkProvider = ctx.getSource() + ServerChunkCache chunkProvider = ctx.getSource() .getLevel() .getChunkSource(); @@ -30,13 +30,13 @@ public class ChunkUtilCommand { if (success) { ctx.getSource() - .sendSuccess(new StringTextComponent("scheduled unload for chunk " + .sendSuccess(new TextComponent("scheduled unload for chunk " + chunkPos.toString() + ", might need to repeat command"), true); return 1; } else { ctx.getSource() .sendSuccess( - new StringTextComponent( + new TextComponent( "unable to schedule unload, is chunk " + chunkPos.toString() + " loaded?"), true); return 0; @@ -48,25 +48,25 @@ public class ChunkUtilCommand { // chunk unload ColumnPos columnPos = ColumnPosArgument.getColumnPos(ctx, "pos"); ChunkPos chunkPos = new ChunkPos(columnPos.x >> 4, columnPos.z >> 4); - ServerChunkProvider chunkProvider = ctx.getSource() + ServerChunkCache chunkProvider = ctx.getSource() .getLevel() .getChunkSource(); boolean success = Create.CHUNK_UTIL.unloadChunk(chunkProvider, chunkPos); ctx.getSource() .sendSuccess( - new StringTextComponent("added chunk " + chunkPos.toString() + " to unload list"), + new TextComponent("added chunk " + chunkPos.toString() + " to unload list"), true); if (success) { ctx.getSource() - .sendSuccess(new StringTextComponent("scheduled unload for chunk " + .sendSuccess(new TextComponent("scheduled unload for chunk " + chunkPos.toString() + ", might need to repeat command"), true); return 1; } else { ctx.getSource() .sendSuccess( - new StringTextComponent( + new TextComponent( "unable to schedule unload, is chunk " + chunkPos.toString() + " loaded?"), true); return 0; @@ -79,7 +79,7 @@ public class ChunkUtilCommand { .getLevel() .getChunkSource()); ctx.getSource() - .sendSuccess(new StringTextComponent("removed " + count + " entries from unload list"), false); + .sendSuccess(new TextComponent("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 6161a973d..34a47169c 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java @@ -3,22 +3,22 @@ package com.simibubi.create.foundation.command; import com.mojang.brigadier.builder.ArgumentBuilder; import com.simibubi.create.CreateClient; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; public class ClearBufferCacheCommand { - static ArgumentBuilder register() { + static ArgumentBuilder register() { return Commands.literal("clearRenderBuffers") .requires(cs -> cs.hasPermission(0)) .executes(ctx -> { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> ClearBufferCacheCommand::execute); ctx.getSource() - .sendSuccess(new StringTextComponent("Cleared rendering buffers."), true); + .sendSuccess(new TextComponent("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 40f3a16ed..95ca6c23d 100644 --- a/src/main/java/com/simibubi/create/foundation/command/CloneCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/CloneCommand.java @@ -10,30 +10,30 @@ import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType; import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.BlockPosArgument; -import net.minecraft.inventory.IClearable; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.CachedBlockInfo; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.gen.feature.template.Template; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.coordinates.BlockPosArgument; +import net.minecraft.world.Clearable; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; +import net.minecraft.server.level.ServerLevel; public class CloneCommand { private static final Dynamic2CommandExceptionType CLONE_TOO_BIG_EXCEPTION = new Dynamic2CommandExceptionType( - (arg1, arg2) -> new TranslationTextComponent("commands.clone.toobig", arg1, arg2)); + (arg1, arg2) -> new TranslatableComponent("commands.clone.toobig", arg1, arg2)); - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("clone") .requires(cs -> cs.hasPermission(2)) .then(Commands.argument("begin", BlockPosArgument.blockPos()) @@ -48,7 +48,7 @@ public class CloneCommand { BlockPosArgument.getLoadedBlockPos(ctx, "destination"), true))))) .executes(ctx -> { ctx.getSource() - .sendSuccess(new StringTextComponent( + .sendSuccess(new TextComponent( "Clones all blocks as well as super glue from the specified area to the target destination"), true); @@ -57,17 +57,17 @@ public class CloneCommand { } - private static int doClone(CommandSource source, BlockPos begin, BlockPos end, BlockPos destination, + private static int doClone(CommandSourceStack source, BlockPos begin, BlockPos end, BlockPos destination, boolean cloneBlocks) throws CommandSyntaxException { - MutableBoundingBox sourceArea = new MutableBoundingBox(begin, end); + BoundingBox sourceArea = new BoundingBox(begin, end); BlockPos destinationEnd = destination.offset(sourceArea.getLength()); - MutableBoundingBox destinationArea = new MutableBoundingBox(destination, destinationEnd); + BoundingBox destinationArea = new BoundingBox(destination, destinationEnd); int i = sourceArea.getXSpan() * sourceArea.getYSpan() * sourceArea.getZSpan(); if (i > 32768) throw CLONE_TOO_BIG_EXCEPTION.create(32768, i); - ServerWorld world = source.getLevel(); + ServerLevel world = source.getLevel(); if (!world.hasChunksAt(begin, end) || !world.hasChunksAt(destination, destinationEnd)) throw BlockPosArgument.ERROR_NOT_LOADED.create(); @@ -79,18 +79,18 @@ public class CloneCommand { int gluePastes = cloneGlue(sourceArea, world, diffToTarget); if (cloneBlocks) - source.sendSuccess(new StringTextComponent("Successfully cloned " + blockPastes + " Blocks"), true); + source.sendSuccess(new TextComponent("Successfully cloned " + blockPastes + " Blocks"), true); - source.sendSuccess(new StringTextComponent("Successfully applied glue " + gluePastes + " times"), true); + source.sendSuccess(new TextComponent("Successfully applied glue " + gluePastes + " times"), true); return blockPastes + gluePastes; } - private static int cloneGlue(MutableBoundingBox sourceArea, ServerWorld world, BlockPos diffToTarget) { + private static int cloneGlue(BoundingBox sourceArea, ServerLevel world, BlockPos diffToTarget) { int gluePastes = 0; List glue = - world.getEntitiesOfClass(SuperGlueEntity.class, AxisAlignedBB.of(sourceArea)); + world.getEntitiesOfClass(SuperGlueEntity.class, AABB.of(sourceArea)); List> newGlue = Lists.newArrayList(); for (SuperGlueEntity g : glue) { @@ -109,49 +109,49 @@ public class CloneCommand { return gluePastes; } - private static int cloneBlocks(MutableBoundingBox sourceArea, ServerWorld world, BlockPos diffToTarget) { + private static int cloneBlocks(BoundingBox sourceArea, ServerLevel world, BlockPos diffToTarget) { int blockPastes = 0; - List blocks = Lists.newArrayList(); - List tileBlocks = Lists.newArrayList(); + List blocks = Lists.newArrayList(); + List tileBlocks = Lists.newArrayList(); 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.offset(diffToTarget); - CachedBlockInfo cached = new CachedBlockInfo(world, currentPos, false); + BlockInWorld cached = new BlockInWorld(world, currentPos, false); BlockState state = cached.getState(); - TileEntity te = world.getBlockEntity(currentPos); + BlockEntity te = world.getBlockEntity(currentPos); if (te != null) { - CompoundNBT nbt = te.save(new CompoundNBT()); - tileBlocks.add(new Template.BlockInfo(newPos, state, nbt)); + CompoundTag nbt = te.save(new CompoundTag()); + tileBlocks.add(new StructureTemplate.StructureBlockInfo(newPos, state, nbt)); } else { - blocks.add(new Template.BlockInfo(newPos, state, null)); + blocks.add(new StructureTemplate.StructureBlockInfo(newPos, state, null)); } } } } - List allBlocks = Lists.newArrayList(); + List allBlocks = Lists.newArrayList(); allBlocks.addAll(blocks); allBlocks.addAll(tileBlocks); - List reverse = Lists.reverse(allBlocks); + List reverse = Lists.reverse(allBlocks); - for (Template.BlockInfo info : reverse) { - TileEntity te = world.getBlockEntity(info.pos); - IClearable.tryClear(te); + for (StructureTemplate.StructureBlockInfo info : reverse) { + BlockEntity te = world.getBlockEntity(info.pos); + Clearable.tryClear(te); world.setBlock(info.pos, Blocks.BARRIER.defaultBlockState(), 2); } - for (Template.BlockInfo info : allBlocks) { + for (StructureTemplate.StructureBlockInfo info : allBlocks) { if (world.setBlock(info.pos, info.state, 2)) blockPastes++; } - for (Template.BlockInfo info : tileBlocks) { - TileEntity te = world.getBlockEntity(info.pos); + for (StructureTemplate.StructureBlockInfo info : tileBlocks) { + BlockEntity 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()); @@ -164,7 +164,7 @@ public class CloneCommand { world.setBlock(info.pos, info.state, 2); } - for (Template.BlockInfo info : reverse) { + for (StructureTemplate.StructureBlockInfo info : reverse) { world.blockUpdated(info.pos, info.state.getBlock()); } 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 2ea2e7971..1e469c705 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java @@ -7,10 +7,10 @@ import com.simibubi.create.Create; import com.simibubi.create.foundation.config.ui.ConfigHelper; import com.simibubi.create.foundation.networking.AllPackets; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.network.PacketDistributor; @@ -22,10 +22,10 @@ import net.minecraftforge.fml.network.PacketDistributor; */ public class ConfigCommand { - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("config") .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource().getPlayerOrException(); + ServerPlayer 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().getPlayerOrException(); + ServerPlayer player = ctx.getSource().getPlayerOrException(); AllPackets.channel.send( PacketDistributor.PLAYER.with(() -> player), new SConfigureConfigPacket(SConfigureConfigPacket.Actions.configScreen.name(), StringArgumentType.getString(ctx, "path")) @@ -55,12 +55,12 @@ public class ConfigCommand { try { configPath = ConfigHelper.ConfigPath.parse(path); } catch (IllegalArgumentException e) { - ctx.getSource().sendFailure(new StringTextComponent(e.getMessage())); + ctx.getSource().sendFailure(new TextComponent(e.getMessage())); return 0; } if (configPath.getType() == ModConfig.Type.CLIENT) { - ServerPlayerEntity player = ctx.getSource().getPlayerOrException(); + ServerPlayer 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().sendSuccess(new StringTextComponent("Great Success!"), false); + ctx.getSource().sendSuccess(new TextComponent("Great Success!"), false); return Command.SINGLE_SUCCESS; } catch (ConfigHelper.InvalidValueException e) { - ctx.getSource().sendFailure(new StringTextComponent("Config could not be set the the specified value!")); + ctx.getSource().sendFailure(new TextComponent("Config could not be set the the specified value!")); return 0; } catch (Exception e) { - ctx.getSource().sendFailure(new StringTextComponent("Something went wrong while trying to set config value. Check the server logs for more information")); + ctx.getSource().sendFailure(new TextComponent("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 31837720d..e35fbfeb4 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigCommand.java @@ -3,9 +3,9 @@ package com.simibubi.create.foundation.command; import com.mojang.brigadier.Command; import com.mojang.brigadier.builder.ArgumentBuilder; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.server.level.ServerPlayer; public abstract class ConfigureConfigCommand { @@ -15,12 +15,12 @@ public abstract class ConfigureConfigCommand { this.commandLiteral = commandLiteral; } - ArgumentBuilder register() { + ArgumentBuilder register() { return Commands.literal(this.commandLiteral) .requires(cs -> cs.hasPermission(0)) .then(Commands.literal("on") .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource() + ServerPlayer player = ctx.getSource() .getPlayerOrException(); sendPacket(player, String.valueOf(true)); @@ -28,14 +28,14 @@ public abstract class ConfigureConfigCommand { })) .then(Commands.literal("off") .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource() + ServerPlayer player = ctx.getSource() .getPlayerOrException(); sendPacket(player, String.valueOf(false)); return Command.SINGLE_SUCCESS; })) .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource() + ServerPlayer player = ctx.getSource() .getPlayerOrException(); sendPacket(player, "info"); @@ -43,5 +43,5 @@ public abstract class ConfigureConfigCommand { }); } - protected abstract void sendPacket(ServerPlayerEntity player, String option); + protected abstract void sendPacket(ServerPlayer player, String option); } 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 38ebe6177..6e60f2205 100644 --- a/src/main/java/com/simibubi/create/foundation/command/CouplingCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/CouplingCommand.java @@ -14,26 +14,26 @@ import com.simibubi.create.content.contraptions.components.structureMovement.tra import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.EntityArgument; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.player.Player; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.common.util.LazyOptional; public class CouplingCommand { public static final SimpleCommandExceptionType ONLY_MINECARTS_ALLOWED = - new SimpleCommandExceptionType(new StringTextComponent("Only Minecarts can be coupled")); + new SimpleCommandExceptionType(new TextComponent("Only Minecarts can be coupled")); public static final SimpleCommandExceptionType SAME_DIMENSION = - new SimpleCommandExceptionType(new StringTextComponent("Minecarts have to be in the same Dimension")); + new SimpleCommandExceptionType(new TextComponent("Minecarts have to be in the same Dimension")); public static final DynamicCommandExceptionType TWO_CARTS = - new DynamicCommandExceptionType(a -> new StringTextComponent( + new DynamicCommandExceptionType(a -> new TextComponent( "Your selector targeted " + a + " entities. You can only couple 2 Minecarts at a time.")); - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("coupling") .requires(cs -> cs.hasPermission(2)) @@ -42,11 +42,11 @@ public class CouplingCommand { .then(Commands.argument("cart2", EntityArgument.entity()) .executes(ctx -> { Entity cart1 = EntityArgument.getEntity(ctx, "cart1"); - if (!(cart1 instanceof AbstractMinecartEntity)) + if (!(cart1 instanceof AbstractMinecart)) throw ONLY_MINECARTS_ALLOWED.create(); Entity cart2 = EntityArgument.getEntity(ctx, "cart2"); - if (!(cart2 instanceof AbstractMinecartEntity)) + if (!(cart2 instanceof AbstractMinecart)) throw ONLY_MINECARTS_ALLOWED.create(); if (!cart1.getCommandSenderWorld() @@ -57,7 +57,7 @@ public class CouplingCommand { .getEntity(); CouplingHandler.tryToCoupleCarts( - source instanceof PlayerEntity ? (PlayerEntity) source : null, cart1.getCommandSenderWorld(), + source instanceof Player ? (Player) source : null, cart1.getCommandSenderWorld(), cart1.getId(), cart2.getId()); return Command.SINGLE_SUCCESS; @@ -70,11 +70,11 @@ public class CouplingCommand { ArrayList eList = Lists.newArrayList(entities); Entity cart1 = eList.get(0); - if (!(cart1 instanceof AbstractMinecartEntity)) + if (!(cart1 instanceof AbstractMinecart)) throw ONLY_MINECARTS_ALLOWED.create(); Entity cart2 = eList.get(1); - if (!(cart2 instanceof AbstractMinecartEntity)) + if (!(cart2 instanceof AbstractMinecart)) throw ONLY_MINECARTS_ALLOWED.create(); if (!cart1.getCommandSenderWorld() @@ -84,7 +84,7 @@ public class CouplingCommand { Entity source = ctx.getSource() .getEntity(); - CouplingHandler.tryToCoupleCarts(source instanceof PlayerEntity ? (PlayerEntity) source : null, + CouplingHandler.tryToCoupleCarts(source instanceof Player ? (Player) source : null, cart1.getCommandSenderWorld(), cart1.getId(), cart2.getId()); return Command.SINGLE_SUCCESS; @@ -94,18 +94,18 @@ public class CouplingCommand { .then(Commands.argument("cart2", EntityArgument.entity()) .executes(ctx -> { Entity cart1 = EntityArgument.getEntity(ctx, "cart1"); - if (!(cart1 instanceof AbstractMinecartEntity)) + if (!(cart1 instanceof AbstractMinecart)) throw ONLY_MINECARTS_ALLOWED.create(); Entity cart2 = EntityArgument.getEntity(ctx, "cart2"); - if (!(cart2 instanceof AbstractMinecartEntity)) + if (!(cart2 instanceof AbstractMinecart)) throw ONLY_MINECARTS_ALLOWED.create(); LazyOptional cart1Capability = cart1.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY); if (!cart1Capability.isPresent()) { ctx.getSource() - .sendSuccess(new StringTextComponent("Minecart has no Couplings Attached"), true); + .sendSuccess(new TextComponent("Minecart has no Couplings Attached"), true); return 0; } @@ -115,7 +115,7 @@ public class CouplingCommand { + (cart1Controller.isLeadingCoupling() ? 1 : 0); if (cart1Couplings == 0) { ctx.getSource() - .sendSuccess(new StringTextComponent("Minecart has no Couplings Attached"), true); + .sendSuccess(new TextComponent("Minecart has no Couplings Attached"), true); return 0; } @@ -138,7 +138,7 @@ public class CouplingCommand { } ctx.getSource() - .sendSuccess(new StringTextComponent("The specified Carts are not coupled"), true); + .sendSuccess(new TextComponent("The specified Carts are not coupled"), true); return 0; })))) @@ -146,14 +146,14 @@ public class CouplingCommand { .then(Commands.argument("cart", EntityArgument.entity()) .executes(ctx -> { Entity cart = EntityArgument.getEntity(ctx, "cart"); - if (!(cart instanceof AbstractMinecartEntity)) + if (!(cart instanceof AbstractMinecart)) throw ONLY_MINECARTS_ALLOWED.create(); LazyOptional capability = cart.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY); if (!capability.isPresent()) { ctx.getSource() - .sendSuccess(new StringTextComponent("Minecart has no Couplings Attached"), true); + .sendSuccess(new TextComponent("Minecart has no Couplings Attached"), true); return 0; } @@ -163,7 +163,7 @@ public class CouplingCommand { (controller.isConnectedToCoupling() ? 1 : 0) + (controller.isLeadingCoupling() ? 1 : 0); if (couplings == 0) { ctx.getSource() - .sendSuccess(new StringTextComponent("Minecart has no Couplings Attached"), true); + .sendSuccess(new TextComponent("Minecart has no Couplings Attached"), true); return 0; } @@ -171,7 +171,7 @@ public class CouplingCommand { ctx.getSource() .sendSuccess( - new StringTextComponent("Removed " + couplings + " couplings from the Minecart"), true); + new TextComponent("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 f8cd53f06..7bd1d8eed 100644 --- a/src/main/java/com/simibubi/create/foundation/command/FabulousWarningCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/FabulousWarningCommand.java @@ -4,18 +4,18 @@ import com.mojang.brigadier.Command; import com.mojang.brigadier.builder.ArgumentBuilder; import com.simibubi.create.foundation.networking.AllPackets; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.fml.network.PacketDistributor; public class FabulousWarningCommand { - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("dismissFabulousWarning") .requires(AllCommands.SOURCE_IS_PLAYER) .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource() + ServerPlayer player = ctx.getSource() .getPlayerOrException(); AllPackets.channel.send( 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 5e11d833d..7e3c4532a 100644 --- a/src/main/java/com/simibubi/create/foundation/command/FixLightingCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/FixLightingCommand.java @@ -3,25 +3,25 @@ package com.simibubi.create.foundation.command; import com.mojang.brigadier.builder.ArgumentBuilder; import com.simibubi.create.foundation.networking.AllPackets; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.fml.network.PacketDistributor; public class FixLightingCommand { - static ArgumentBuilder register() { + static ArgumentBuilder register() { return Commands.literal("fixLighting") .requires(cs -> cs.hasPermission(0)) .executes(ctx -> { - AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource() + AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) ctx.getSource() .getEntity()), new SConfigureConfigPacket(SConfigureConfigPacket.Actions.fixLighting.name(), String.valueOf(true))); ctx.getSource() .sendSuccess( - new StringTextComponent("Forge's experimental block rendering pipeline is now enabled."), true); + new TextComponent("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 a67b5bc19..eed5aca4c 100644 --- a/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/FlySpeedCommand.java @@ -5,17 +5,17 @@ import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.context.CommandContext; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.EntityArgument; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.play.server.SPlayerAbilitiesPacket; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; public class FlySpeedCommand { - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("flySpeed") .requires(cs -> cs.hasPermission(2)) .then(Commands.argument("speed", FloatArgumentType.floatArg(0)) @@ -33,14 +33,14 @@ public class FlySpeedCommand { ); } - private static int sendFlySpeedUpdate(CommandContext ctx, ServerPlayerEntity player, float speed) { - SPlayerAbilitiesPacket packet = new SPlayerAbilitiesPacket(player.abilities); + private static int sendFlySpeedUpdate(CommandContext ctx, ServerPlayer player, float speed) { + ClientboundPlayerAbilitiesPacket packet = new ClientboundPlayerAbilitiesPacket(player.abilities); // packet.setFlySpeed(speed); - ObfuscationReflectionHelper.setPrivateValue(SPlayerAbilitiesPacket.class, packet, speed, "field_149116_e"); // flyingSpeed + ObfuscationReflectionHelper.setPrivateValue(ClientboundPlayerAbilitiesPacket.class, packet, speed, "field_149116_e"); // flyingSpeed player.connection.send(packet); ctx.getSource() - .sendSuccess(new StringTextComponent("Temporarily set " + player.getName() + .sendSuccess(new TextComponent("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 68cc8bc1b..f87f6ed82 100644 --- a/src/main/java/com/simibubi/create/foundation/command/GlueCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/GlueCommand.java @@ -3,15 +3,15 @@ package com.simibubi.create.foundation.command; import com.mojang.brigadier.builder.ArgumentBuilder; import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.BlockPosArgument; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.coordinates.BlockPosArgument; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; public class GlueCommand { - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("glue") .requires(cs -> cs.hasPermission(2)) .then(Commands.argument("pos", BlockPosArgument.blockPos()) @@ -19,7 +19,7 @@ public class GlueCommand { .executes(ctx -> { BlockPos pos = BlockPosArgument.getOrLoadBlockPos(ctx, "pos"); - ServerWorld world = ctx.getSource().getLevel(); + ServerLevel world = ctx.getSource().getLevel(); SuperGlueEntity entity = new SuperGlueEntity(world, pos, Direction.UP); entity.playPlaceSound(); 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 44604195a..dd1c85dd6 100644 --- a/src/main/java/com/simibubi/create/foundation/command/HighlightCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/HighlightCommand.java @@ -8,34 +8,34 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Ass import com.simibubi.create.content.contraptions.components.structureMovement.IDisplayAssemblyExceptions; import com.simibubi.create.foundation.networking.AllPackets; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.BlockPosArgument; -import net.minecraft.command.arguments.EntityArgument; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.World; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.coordinates.BlockPosArgument; +import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.fml.network.PacketDistributor; public class HighlightCommand { - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("highlight") .requires(cs -> cs.hasPermission(2)) .then(Commands.argument("pos", BlockPosArgument.blockPos()) .then(Commands.argument("players", EntityArgument.players()) .executes(ctx -> { - Collection players = EntityArgument.getPlayers(ctx, "players"); + Collection players = EntityArgument.getPlayers(ctx, "players"); BlockPos pos = BlockPosArgument.getOrLoadBlockPos(ctx, "pos"); - for (ServerPlayerEntity p : players) { + for (ServerPlayer p : players) { AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> p), new HighlightPacket(pos)); } @@ -45,43 +45,43 @@ public class HighlightCommand { .executes(ctx -> { BlockPos pos = BlockPosArgument.getLoadedBlockPos(ctx, "pos"); - AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource() + AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) ctx.getSource() .getEntity()), new HighlightPacket(pos)); return Command.SINGLE_SUCCESS; })) // .requires(AllCommands.sourceIsPlayer) .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource() + ServerPlayer player = ctx.getSource() .getPlayerOrException(); return highlightAssemblyExceptionFor(player, ctx.getSource()); }); } - private static void sendMissMessage(CommandSource source) { + private static void sendMissMessage(CommandSourceStack source) { source.sendSuccess( - new StringTextComponent("Try looking at a Block that has failed to assemble a Contraption and try again."), + new TextComponent("Try looking at a Block that has failed to assemble a Contraption and try again."), true); } - private static int highlightAssemblyExceptionFor(ServerPlayerEntity player, CommandSource source) { + private static int highlightAssemblyExceptionFor(ServerPlayer player, CommandSourceStack source) { double distance = player.getAttribute(ForgeMod.REACH_DISTANCE.get()) .getValue(); - Vector3d start = player.getEyePosition(1); - Vector3d look = player.getViewVector(1); - Vector3d end = start.add(look.x * distance, look.y * distance, look.z * distance); - World world = player.level; + Vec3 start = player.getEyePosition(1); + Vec3 look = player.getViewVector(1); + Vec3 end = start.add(look.x * distance, look.y * distance, look.z * distance); + Level world = player.level; - BlockRayTraceResult ray = world.clip( - new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player)); - if (ray.getType() == RayTraceResult.Type.MISS) { + BlockHitResult ray = world.clip( + new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)); + if (ray.getType() == HitResult.Type.MISS) { sendMissMessage(source); return 0; } BlockPos pos = ray.getBlockPos(); - TileEntity te = world.getBlockEntity(pos); + BlockEntity te = world.getBlockEntity(pos); if (!(te instanceof IDisplayAssemblyExceptions)) { sendMissMessage(source); return 0; @@ -95,7 +95,7 @@ public class HighlightCommand { } if (!exception.hasPosition()) { - source.sendSuccess(new StringTextComponent("Can't highlight a specific position for this issue"), true); + source.sendSuccess(new TextComponent("Can't highlight a specific position for this issue"), true); return Command.SINGLE_SUCCESS; } 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 06cfddb9a..c6e62cb99 100644 --- a/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java +++ b/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java @@ -7,9 +7,9 @@ import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.Shapes; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; @@ -23,12 +23,12 @@ public class HighlightPacket extends SimplePacketBase { this.pos = pos; } - public HighlightPacket(PacketBuffer buffer) { + public HighlightPacket(FriendlyByteBuf buffer) { this.pos = buffer.readBlockPos(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBlockPos(pos); } @@ -48,7 +48,7 @@ public class HighlightPacket extends SimplePacketBase { if (Minecraft.getInstance().level == null || !Minecraft.getInstance().level.isLoaded(pos)) return; - CreateClient.OUTLINER.showAABB("highlightCommand", VoxelShapes.block() + CreateClient.OUTLINER.showAABB("highlightCommand", Shapes.block() .bounds() .move(pos), 200) .lineWidth(1 / 32f) 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 366e83196..37fff26e0 100644 --- a/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java @@ -5,12 +5,12 @@ import com.mojang.brigadier.builder.ArgumentBuilder; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; public class KillTPSCommand { - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("killtps") .requires(cs -> cs.hasPermission(2)) .executes(ctx -> { 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 e7479a2a6..72911cc9c 100644 --- a/src/main/java/com/simibubi/create/foundation/command/OverlayConfigCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/OverlayConfigCommand.java @@ -3,17 +3,17 @@ package com.simibubi.create.foundation.command; import com.mojang.brigadier.builder.ArgumentBuilder; import com.simibubi.create.foundation.networking.AllPackets; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.PacketDistributor; public class OverlayConfigCommand { - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("overlay") .requires(cs -> cs.hasPermission(0)) .then(Commands.literal("reset") @@ -22,11 +22,11 @@ public class OverlayConfigCommand { DistExecutor.unsafeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> AllPackets.channel.send( - PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource().getEntity()), + PacketDistributor.PLAYER.with(() -> (ServerPlayer) ctx.getSource().getEntity()), new SConfigureConfigPacket(SConfigureConfigPacket.Actions.overlayReset.name(), ""))); ctx.getSource() - .sendSuccess(new StringTextComponent("reset overlay offset"), true); + .sendSuccess(new TextComponent("reset overlay offset"), true); return 1; }) @@ -36,11 +36,11 @@ public class OverlayConfigCommand { DistExecutor.unsafeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> AllPackets.channel.send( - PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource().getEntity()), + PacketDistributor.PLAYER.with(() -> (ServerPlayer) ctx.getSource().getEntity()), new SConfigureConfigPacket(SConfigureConfigPacket.Actions.overlayScreen.name(), ""))); ctx.getSource() - .sendSuccess(new StringTextComponent("window opened"), true); + .sendSuccess(new TextComponent("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 853de1525..4d9821c2b 100644 --- a/src/main/java/com/simibubi/create/foundation/command/PonderCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/PonderCommand.java @@ -9,21 +9,21 @@ import com.mojang.brigadier.suggestion.SuggestionProvider; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.ponder.PonderRegistry; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.ISuggestionProvider; -import net.minecraft.command.arguments.EntityArgument; -import net.minecraft.command.arguments.ResourceLocationArgument; -import net.minecraft.command.arguments.SuggestionProviders; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.ResourceLocation; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.commands.arguments.ResourceLocationArgument; +import net.minecraft.commands.synchronization.SuggestionProviders; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.resources.ResourceLocation; 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.suggestResource(PonderRegistry.ALL.keySet().stream(), builder)); + public static final SuggestionProvider ITEM_PONDERS = SuggestionProviders.register(new ResourceLocation("all_ponders"), (iSuggestionProviderCommandContext, builder) -> SharedSuggestionProvider.suggestResource(PonderRegistry.ALL.keySet().stream(), builder)); - static ArgumentBuilder register() { + static ArgumentBuilder register() { return Commands.literal("ponder") .requires(cs -> cs.hasPermission(0)) .executes(ctx -> openScene("index", ctx.getSource().getPlayerOrException())) @@ -38,12 +38,12 @@ public class PonderCommand { } - private static int openScene(String sceneId, ServerPlayerEntity player) { + private static int openScene(String sceneId, ServerPlayer player) { return openScene(sceneId, ImmutableList.of(player)); } - private static int openScene(String sceneId, Collection players) { - for (ServerPlayerEntity player : players) { + private static int openScene(String sceneId, Collection players) { + for (ServerPlayer player : players) { if (player instanceof FakePlayer) continue; 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 8bdd9b5ec..66d0a80ca 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ReplaceInCommandBlocksCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ReplaceInCommandBlocksCommand.java @@ -5,21 +5,21 @@ import org.apache.commons.lang3.mutable.MutableInt; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; -import net.minecraft.block.BlockState; -import net.minecraft.block.CommandBlockBlock; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.command.arguments.BlockPosArgument; -import net.minecraft.tileentity.CommandBlockLogic; -import net.minecraft.tileentity.CommandBlockTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.CommandBlock; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.coordinates.BlockPosArgument; +import net.minecraft.world.level.BaseCommandBlock; +import net.minecraft.world.level.block.entity.CommandBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.server.level.ServerLevel; public class ReplaceInCommandBlocksCommand { - public static ArgumentBuilder register() { + public static ArgumentBuilder register() { return Commands.literal("replaceInCommandBlocks") .requires(cs -> cs.hasPermission(2)) .then(Commands.argument("begin", BlockPosArgument.blockPos()) @@ -36,20 +36,20 @@ public class ReplaceInCommandBlocksCommand { } - private static void doReplace(CommandSource source, BlockPos from, BlockPos to, String toReplace, + private static void doReplace(CommandSourceStack source, BlockPos from, BlockPos to, String toReplace, String replaceWith) { - ServerWorld world = source.getLevel(); + ServerLevel world = source.getLevel(); MutableInt blocks = new MutableInt(0); BlockPos.betweenClosedStream(from, to) .forEach(pos -> { BlockState blockState = world.getBlockState(pos); - if (!(blockState.getBlock() instanceof CommandBlockBlock)) + if (!(blockState.getBlock() instanceof CommandBlock)) return; - TileEntity tileEntity = world.getBlockEntity(pos); - if (!(tileEntity instanceof CommandBlockTileEntity)) + BlockEntity tileEntity = world.getBlockEntity(pos); + if (!(tileEntity instanceof CommandBlockEntity)) return; - CommandBlockTileEntity cb = (CommandBlockTileEntity) tileEntity; - CommandBlockLogic commandBlockLogic = cb.getCommandBlock(); + CommandBlockEntity cb = (CommandBlockEntity) tileEntity; + BaseCommandBlock commandBlockLogic = cb.getCommandBlock(); String command = commandBlockLogic.getCommand(); if (command.indexOf(toReplace) != -1) blocks.increment(); @@ -59,10 +59,10 @@ public class ReplaceInCommandBlocksCommand { }); int intValue = blocks.intValue(); if (intValue == 0) { - source.sendSuccess(new StringTextComponent("Couldn't find \"" + toReplace + "\" anywhere."), true); + source.sendSuccess(new TextComponent("Couldn't find \"" + toReplace + "\" anywhere."), true); return; } - source.sendSuccess(new StringTextComponent("Replaced occurrences in " + intValue + " blocks."), true); + source.sendSuccess(new TextComponent("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 489ace535..4fe3f2f45 100644 --- a/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java @@ -18,14 +18,14 @@ import com.simibubi.create.foundation.ponder.PonderUI; import com.simibubi.create.foundation.ponder.content.PonderIndexScreen; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ChatType; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.ChatType; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ForgeConfig; @@ -43,13 +43,13 @@ public class SConfigureConfigPacket extends SimplePacketBase { this.value = value; } - public SConfigureConfigPacket(PacketBuffer buffer) { + public SConfigureConfigPacket(FriendlyByteBuf buffer) { this.option = buffer.readUtf(32767); this.value = buffer.readUtf(32767); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeUtf(option); buffer.writeUtf(value); } @@ -77,7 +77,7 @@ public class SConfigureConfigPacket extends SimplePacketBase { } private static void trySetConfig(String option, String value) { - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (player == null) return; @@ -85,7 +85,7 @@ public class SConfigureConfigPacket extends SimplePacketBase { try { configPath = ConfigHelper.ConfigPath.parse(option); } catch (IllegalArgumentException e) { - player.displayClientMessage(new StringTextComponent(e.getMessage()), false); + player.displayClientMessage(new TextComponent(e.getMessage()), false); return; } @@ -96,11 +96,11 @@ public class SConfigureConfigPacket extends SimplePacketBase { try { ConfigHelper.setConfigValue(configPath, value); - player.displayClientMessage(new StringTextComponent("Great Success!"), false); + player.displayClientMessage(new TextComponent("Great Success!"), false); } catch (ConfigHelper.InvalidValueException e) { - player.displayClientMessage(new StringTextComponent("Config could not be set the the specified value!"), false); + player.displayClientMessage(new TextComponent("Config could not be set the the specified value!"), false); } catch (Exception e) { - player.displayClientMessage(new StringTextComponent("Something went wrong while trying to set config value. Check the client logs for more information"), false); + player.displayClientMessage(new TextComponent("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); } @@ -135,38 +135,38 @@ public class SConfigureConfigPacket extends SimplePacketBase { return; } - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; ConfigHelper.ConfigPath configPath; try { configPath = ConfigHelper.ConfigPath.parse(value); } catch (IllegalArgumentException e) { - player.displayClientMessage(new StringTextComponent(e.getMessage()), false); + player.displayClientMessage(new TextComponent(e.getMessage()), false); return; } try { ScreenOpener.open(SubMenuConfigScreen.find(configPath)); } catch (Exception e) { - player.displayClientMessage(new StringTextComponent("Unable to find the specified config"), false); + player.displayClientMessage(new TextComponent("Unable to find the specified config"), false); } } @OnlyIn(Dist.CLIENT) private static void rainbowDebug(String value) { - ClientPlayerEntity player = Minecraft.getInstance().player; + LocalPlayer player = Minecraft.getInstance().player; if (player == null || "".equals(value)) return; if (value.equals("info")) { - ITextComponent text = new StringTextComponent("Rainbow Debug Utility is currently: ") + Component text = new TextComponent("Rainbow Debug Utility is currently: ") .append(boolToText(AllConfigs.CLIENT.rainbowDebug.get())); 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").withStyle(TextFormatting.WHITE)); + Component text = boolToText(AllConfigs.CLIENT.rainbowDebug.get()) + .append(new TextComponent(" Rainbow Debug Utility").withStyle(ChatFormatting.WHITE)); player.displayClientMessage(text, false); } @@ -208,13 +208,13 @@ public class SConfigureConfigPacket extends SimplePacketBase { private static void fabulousWarning(String value) { AllConfigs.CLIENT.ignoreFabulousWarning.set(true); Minecraft.getInstance().gui.handleChat(ChatType.CHAT, - new StringTextComponent("Disabled Fabulous graphics warning"), + new TextComponent("Disabled Fabulous graphics warning"), Minecraft.getInstance().player.getUUID()); } - private static IFormattableTextComponent boolToText(boolean b) { - return b ? new StringTextComponent("enabled").withStyle(TextFormatting.DARK_GREEN) - : new StringTextComponent("disabled").withStyle(TextFormatting.RED); + private static MutableComponent boolToText(boolean b) { + return b ? new TextComponent("enabled").withStyle(ChatFormatting.DARK_GREEN) + : new TextComponent("disabled").withStyle(ChatFormatting.RED); } } } diff --git a/src/main/java/com/simibubi/create/foundation/command/ToggleDebugCommand.java b/src/main/java/com/simibubi/create/foundation/command/ToggleDebugCommand.java index f5b73ecbb..fc0352e68 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ToggleDebugCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ToggleDebugCommand.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.command; import com.simibubi.create.foundation.networking.AllPackets; -import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.fml.network.PacketDistributor; public class ToggleDebugCommand extends ConfigureConfigCommand { @@ -12,7 +12,7 @@ public class ToggleDebugCommand extends ConfigureConfigCommand { } @Override - protected void sendPacket(ServerPlayerEntity player, String option) { + protected void sendPacket(ServerPlayer player, String option) { AllPackets.channel.send( PacketDistributor.PLAYER.with(() -> player), new SConfigureConfigPacket(SConfigureConfigPacket.Actions.rainbowDebug.name(), option) diff --git a/src/main/java/com/simibubi/create/foundation/config/CStress.java b/src/main/java/com/simibubi/create/foundation/config/CStress.java index 037218a4f..3f1353b49 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CStress.java +++ b/src/main/java/com/simibubi/create/foundation/config/CStress.java @@ -9,8 +9,8 @@ import com.simibubi.create.content.contraptions.components.crank.ValveHandleBloc import com.simibubi.create.foundation.block.BlockStressDefaults; import com.simibubi.create.foundation.block.BlockStressValues.IStressValueProvider; -import net.minecraft.block.Block; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.ForgeConfigSpec.Builder; import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; diff --git a/src/main/java/com/simibubi/create/foundation/config/ContraptionMovementSetting.java b/src/main/java/com/simibubi/create/foundation/config/ContraptionMovementSetting.java index dfe76e50b..071c1c467 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ContraptionMovementSetting.java +++ b/src/main/java/com/simibubi/create/foundation/config/ContraptionMovementSetting.java @@ -6,10 +6,10 @@ import java.util.function.Supplier; import javax.annotation.Nullable; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraftforge.common.extensions.IForgeBlock; public enum ContraptionMovementSetting { @@ -40,11 +40,11 @@ public enum ContraptionMovementSetting { return supplier == null ? null : supplier.get(); } - protected static boolean allAre(Collection blocks, ContraptionMovementSetting are) { + protected static boolean allAre(Collection blocks, ContraptionMovementSetting are) { return blocks.stream().anyMatch(b -> get(b.state.getBlock()) == are); } - public static boolean isNoPickup(Collection blocks) { + public static boolean isNoPickup(Collection blocks) { return allAre(blocks, ContraptionMovementSetting.NO_PICKUP); } 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 a22ddc419..fcf86cdd9 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 @@ -8,7 +8,7 @@ import java.util.function.UnaryOperator; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.Create; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.gui.AllIcons; @@ -21,9 +21,9 @@ import com.simibubi.create.foundation.gui.widgets.BoxWidget; import com.simibubi.create.foundation.item.TooltipHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.config.ModConfig; @@ -146,7 +146,7 @@ public class BaseConfigScreen extends ConfigScreen { super.init(); returnOnClose = true; - TextStencilElement clientText = new TextStencilElement(minecraft.font, new StringTextComponent(clientTile)).centered(true, true); + TextStencilElement clientText = new TextStencilElement(minecraft.font, new TextComponent(clientTile)).centered(true, true); widgets.add(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16).showingElement(clientText)); if (clientSpec != null) { @@ -158,7 +158,7 @@ public class BaseConfigScreen extends ConfigScreen { clientText.withElementRenderer(DISABLED_RENDERER); } - TextStencilElement commonText = new TextStencilElement(minecraft.font, new StringTextComponent(commonTile)).centered(true, true); + TextStencilElement commonText = new TextStencilElement(minecraft.font, new TextComponent(commonTile)).centered(true, true); widgets.add(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 16).showingElement(commonText)); if (commonSpec != null) { @@ -170,7 +170,7 @@ public class BaseConfigScreen extends ConfigScreen { commonText.withElementRenderer(DISABLED_RENDERER); } - TextStencilElement serverText = new TextStencilElement(minecraft.font, new StringTextComponent(serverTile)).centered(true, true); + TextStencilElement serverText = new TextStencilElement(minecraft.font, new TextComponent(serverTile)).centered(true, true); widgets.add(serverConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 + 30, 200, 16).showingElement(serverText)); if (serverSpec == null) { @@ -180,12 +180,12 @@ public class BaseConfigScreen extends ConfigScreen { } else if (Minecraft.getInstance().level == null) { serverText.withElementRenderer(DISABLED_RENDERER); serverConfigWidget.getToolTip() - .add(new StringTextComponent("Stored individually per World")); + .add(new TextComponent("Stored individually per World")); serverConfigWidget.getToolTip() .addAll(TooltipHelper.cutTextComponent( - new StringTextComponent( + new TextComponent( "Gameplay settings can only be accessed from the in-game menu after joining a World or Server."), - TextFormatting.GRAY, TextFormatting.GRAY)); + ChatFormatting.GRAY, ChatFormatting.GRAY)); } else { serverConfigWidget.withCallback(() -> linkTo(new SubMenuConfigScreen(this, ModConfig.Type.SERVER, serverSpec))); serverText.withElementRenderer(BoxWidget.gradientFactory.apply(serverConfigWidget)); @@ -218,10 +218,10 @@ public class BaseConfigScreen extends ConfigScreen { goBack.showingElement(AllIcons.I_CONFIG_BACK.asStencil() .withElementRenderer(BoxWidget.gradientFactory.apply(goBack))); goBack.getToolTip() - .add(new StringTextComponent("Go Back")); + .add(new TextComponent("Go Back")); widgets.add(goBack); - TextStencilElement othersText = new TextStencilElement(minecraft.font, new StringTextComponent("Access Configs of other Mods")).centered(true, true); + TextStencilElement othersText = new TextStencilElement(minecraft.font, new TextComponent("Access Configs of other Mods")).centered(true, true); others = new BoxWidget(width / 2 - 100, height / 2 - 15 + 90, 200, 16).showingElement(othersText); othersText.withElementRenderer(BoxWidget.gradientFactory.apply(others)); others.withCallback(() -> linkTo(new ConfigModListScreen(this))); @@ -230,7 +230,7 @@ public class BaseConfigScreen extends ConfigScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { drawCenteredString(ms, minecraft.font, "Access Configs for Mod:", width / 2, height / 2 - 105, Theme.i(Theme.Key.TEXT_ACCENT_STRONG)); } 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 3def1c55e..387d863a6 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 @@ -6,8 +6,8 @@ import java.util.function.Supplier; import com.simibubi.create.Create; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.network.NetworkEvent; @@ -24,14 +24,14 @@ public class CConfigureConfigPacket extends SimplePacketBase { this.value = serialize(value); } - public CConfigureConfigPacket(PacketBuffer buffer) { + public CConfigureConfigPacket(FriendlyByteBuf buffer) { this.modID = buffer.readUtf(32767); this.path = buffer.readUtf(32767); this.value = buffer.readUtf(32767); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeUtf(modID); buffer.writeUtf(path); buffer.writeUtf(value); @@ -41,7 +41,7 @@ public class CConfigureConfigPacket extends SimplePacketBase { public void handle(Supplier context) { context.get().enqueueWork(() -> { try { - ServerPlayerEntity sender = context.get().getSender(); + ServerPlayer sender = context.get().getSender(); if (sender == null || !sender.hasPermissions(2)) return; diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigModListScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigModListScreen.java index c335618c9..a9c3576d2 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigModListScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigModListScreen.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.gui.DelegatedStencilElement; import com.simibubi.create.foundation.gui.ScreenOpener; @@ -12,9 +12,9 @@ import com.simibubi.create.foundation.gui.Theme; import com.simibubi.create.foundation.gui.widgets.BoxWidget; import com.simibubi.create.foundation.item.TooltipHelper; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; @@ -63,7 +63,7 @@ public class ConfigModListScreen extends ConfigScreen { goBack.showingElement(AllIcons.I_CONFIG_BACK.asStencil() .withElementRenderer(BoxWidget.gradientFactory.apply(goBack))); goBack.getToolTip() - .add(new StringTextComponent("Go Back")); + .add(new TextComponent("Go Back")); widgets.add(goBack); search = new HintableTextFieldWidget(font, width / 2 - listWidth / 2, height - 35, listWidth, 20); @@ -75,7 +75,7 @@ public class ConfigModListScreen extends ConfigScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { list.render(ms, mouseX, mouseY, partialTicks); @@ -121,8 +121,8 @@ public class ConfigModListScreen extends ConfigScreen { button.active = false; button.updateColorsFromState(); button.modifyElement(e -> ((DelegatedStencilElement) e).withElementRenderer(BaseConfigScreen.DISABLED_RENDERER)); - labelTooltip.add(new StringTextComponent(toHumanReadable(id))); - labelTooltip.addAll(TooltipHelper.cutTextComponent(new StringTextComponent("This Mod does not have any configs registered or is not using Forge's config system"), TextFormatting.GRAY, TextFormatting.GRAY)); + labelTooltip.add(new TextComponent(toHumanReadable(id))); + labelTooltip.addAll(TooltipHelper.cutTextComponent(new TextComponent("This Mod does not have any configs registered or is not using Forge's config system"), ChatFormatting.GRAY, ChatFormatting.GRAY)); } listeners.add(button); @@ -139,7 +139,7 @@ public class ConfigModListScreen extends ConfigScreen { } @Override - 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) { + public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); button.x = x + width - 108; 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 194ea921f..cd0da3d20 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 @@ -15,7 +15,7 @@ import org.lwjgl.opengl.GL30; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; @@ -28,12 +28,12 @@ import com.simibubi.create.foundation.gui.mainMenu.CreateMainMenuScreen; import com.simibubi.create.foundation.utility.animation.Force; import com.simibubi.create.foundation.utility.animation.PhysicalFloat; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.client.shader.FramebufferConstants; -import net.minecraft.util.Direction; +import net.minecraft.client.gui.screens.Screen; +import com.mojang.blaze3d.pipeline.RenderTarget; +import com.mojang.blaze3d.platform.GlConst; +import net.minecraft.core.Direction; public abstract class ConfigScreen extends AbstractSimiScreen { @@ -49,7 +49,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { * * */ - public static final Map> backgrounds = new HashMap<>(); + 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().setValue(CogWheelBlock.AXIS, Direction.Axis.Y); public static String modID = null; @@ -66,12 +66,12 @@ public abstract class ConfigScreen extends AbstractSimiScreen { } @Override - public void renderBackground(@Nonnull MatrixStack ms) { + public void renderBackground(@Nonnull PoseStack ms) { net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this, ms)); } @Override - protected void renderWindowBackground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowBackground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { if (this.minecraft != null && this.minecraft.level != null) { //in game fill(ms, 0, 0, this.width, this.height, 0xb0_282c34); @@ -82,12 +82,12 @@ public abstract class ConfigScreen extends AbstractSimiScreen { new StencilElement() { @Override - protected void renderStencil(MatrixStack ms) { + protected void renderStencil(PoseStack ms) { renderCog(ms, partialTicks); } @Override - protected void renderElement(MatrixStack ms) { + protected void renderElement(PoseStack ms) { fill(ms, -200, -200, 200, 200, 0x60_000000); } }.at(width * 0.5f, height * 0.5f, 0).render(ms); @@ -98,15 +98,15 @@ public abstract class ConfigScreen extends AbstractSimiScreen { @Override protected void prepareFrame() { - Framebuffer thisBuffer = UIRenderHelper.framebuffer; - Framebuffer mainBuffer = Minecraft.getInstance().getMainRenderTarget(); + RenderTarget thisBuffer = UIRenderHelper.framebuffer; + RenderTarget mainBuffer = Minecraft.getInstance().getMainRenderTarget(); GlCompat functions = Backend.getInstance().compat; 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.GL_FRAMEBUFFER, thisBuffer.frameBufferId); + functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, thisBuffer.frameBufferId); GL11.glClear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT); } @@ -114,19 +114,19 @@ public abstract class ConfigScreen extends AbstractSimiScreen { @Override protected void endFrame() { - Framebuffer thisBuffer = UIRenderHelper.framebuffer; - Framebuffer mainBuffer = Minecraft.getInstance().getMainRenderTarget(); + RenderTarget thisBuffer = UIRenderHelper.framebuffer; + RenderTarget mainBuffer = Minecraft.getInstance().getMainRenderTarget(); GlCompat functions = Backend.getInstance().compat; 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.GL_FRAMEBUFFER, mainBuffer.frameBufferId); + functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, mainBuffer.frameBufferId); } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { } @Override @@ -154,8 +154,8 @@ public abstract class ConfigScreen extends AbstractSimiScreen { * If your addon wants to render something else, please add to the * backgrounds Map in this Class with your modID as the key. */ - protected void renderMenuBackground(MatrixStack ms, float partialTicks) { - TriConsumer customBackground = backgrounds.get(modID); + protected void renderMenuBackground(PoseStack ms, float partialTicks) { + TriConsumer customBackground = backgrounds.get(modID); if (customBackground != null) { customBackground.accept(this, ms, partialTicks); return; @@ -172,7 +172,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { fill(ms, 0, 0, this.width, this.height, 0x90_282c34); } - protected void renderCog(MatrixStack ms, float partialTicks) { + protected void renderCog(PoseStack ms, float partialTicks) { ms.pushPose(); ms.translate(-100, 100, -100); 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 796a8086b..471c7dd6f 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 @@ -9,7 +9,7 @@ import java.util.Optional; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.config.ui.entries.NumberEntry; import com.simibubi.create.foundation.gui.TextStencilElement; @@ -18,20 +18,20 @@ import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.animation.LerpedFloat; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.IGuiEventListener; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.gui.widget.list.ExtendedList; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; import net.minecraftforge.fml.client.gui.GuiUtils; -public class ConfigScreenList extends ExtendedList { +public class ConfigScreenList extends ObjectSelectionList { - public static TextFieldWidget currentText; + public static EditBox currentText; public ConfigScreenList(Minecraft client, int width, int height, int top, int bottom, int elementHeight) { super(client, width, height, top, bottom, elementHeight); @@ -43,7 +43,7 @@ public class ConfigScreenList extends ExtendedList { } @Override - public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { Color c = new Color(0x60_000000); UIRenderHelper.angledGradient(ms, 90, x0 + width / 2, y0, width, 5, c, Color.TRANSPARENT_BLACK); UIRenderHelper.angledGradient(ms, -90, x0 + width / 2, y1, width, 5, c, Color.TRANSPARENT_BLACK); @@ -54,8 +54,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(); + protected void renderList(PoseStack p_238478_1_, int p_238478_2_, int p_238478_3_, int p_238478_4_, int p_238478_5_, float p_238478_6_) { + Window window = Minecraft.getInstance().getWindow(); 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_); @@ -121,8 +121,8 @@ public class ConfigScreenList extends ExtendedList { ConfigScreen.cogSpin.bump(3, force); } - public static abstract class Entry extends ExtendedList.AbstractListEntry { - protected List listeners; + public static abstract class Entry extends ObjectSelectionList.Entry { + protected List listeners; protected Map annotations; protected String path; @@ -148,7 +148,7 @@ public class ConfigScreenList extends ExtendedList { public void tick() {} - public List getGuiListeners() { + public List getGuiListeners() { return listeners; } @@ -167,7 +167,7 @@ public class ConfigScreenList extends ExtendedList { protected static final float labelWidthMult = 0.4f; protected TextStencilElement label; - protected List labelTooltip; + protected List labelTooltip; protected String unit = null; protected LerpedFloat differenceAnimation = LerpedFloat.linear().startWithValue(0); protected LerpedFloat highlightAnimation = LerpedFloat.linear().startWithValue(0); @@ -191,7 +191,7 @@ public class ConfigScreenList extends ExtendedList { } @Override - 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) { + public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { if (isCurrentValueChanged()) { if (differenceAnimation.getChaseTarget() != 1) differenceAnimation.chase(1, .5f, LerpedFloat.Chaser.EXP); @@ -215,8 +215,8 @@ 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().font; + MutableComponent component = label.getComponent(); + Font font = Minecraft.getInstance().font; if (font.width(component) > getLabelWidth(width) - 10) { label.withText(font.substrByWidth(component, getLabelWidth(width) - 15).getString() + "..."); } @@ -244,7 +244,7 @@ public class ConfigScreenList extends ExtendedList { if (mouseX > x && mouseX < x + getLabelWidth(width) && mouseY > y + 5 && mouseY < y + height - 5) { - List tooltip = getLabelTooltip(); + List tooltip = getLabelTooltip(); if (tooltip.isEmpty()) return; @@ -258,7 +258,7 @@ public class ConfigScreenList extends ExtendedList { } } - public List getLabelTooltip() { + public List getLabelTooltip() { return labelTooltip; } 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 f8e371ca7..7aa402f16 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 @@ -1,10 +1,10 @@ package com.simibubi.create.foundation.config.ui; -import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Font; public class ConfigTextField extends HintableTextFieldWidget { - public ConfigTextField(FontRenderer font, int x, int y, int width, int height) { + public ConfigTextField(Font font, int x, int y, int width, int height) { super(font, x, y, width, height); } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/HintableTextFieldWidget.java b/src/main/java/com/simibubi/create/foundation/config/ui/HintableTextFieldWidget.java index 3be40c309..8ba4d7f79 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/HintableTextFieldWidget.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/HintableTextFieldWidget.java @@ -2,22 +2,22 @@ package com.simibubi.create.foundation.config.ui; import org.lwjgl.glfw.GLFW; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.Theme; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.util.InputMappings; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.components.EditBox; +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.network.chat.TextComponent; -public class HintableTextFieldWidget extends TextFieldWidget { +public class HintableTextFieldWidget extends EditBox { - protected FontRenderer font; + protected Font font; protected String hint; - public HintableTextFieldWidget(FontRenderer font, int x, int y, int width, int height) { - super(font, x, y, width, height, StringTextComponent.EMPTY); + public HintableTextFieldWidget(Font font, int x, int y, int width, int height) { + super(font, x, y, width, height, TextComponent.EMPTY); this.font = font; } @@ -26,7 +26,7 @@ public class HintableTextFieldWidget extends TextFieldWidget { } @Override - public void renderButton(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTicks) { super.renderButton(ms, mouseX, mouseY, partialTicks); if (hint == null || hint.isEmpty()) @@ -52,7 +52,7 @@ public class HintableTextFieldWidget extends TextFieldWidget { @Override public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) { - InputMappings.Input mouseKey = InputMappings.getKey(code, p_keyPressed_2_); + InputConstants.Key mouseKey = InputConstants.getKey(code, p_keyPressed_2_); if (Minecraft.getInstance().options.keyInventory.isActiveAndMatches(mouseKey)) { return true; } 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 bf5593471..cdd9ee716 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 @@ -4,20 +4,20 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.mainMenu.CreateMainMenuScreen; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.IngameMenuScreen; -import net.minecraft.client.gui.screen.MainMenuScreen; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.screens.PauseScreen; +import net.minecraft.client.gui.screens.TitleScreen; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -28,11 +28,11 @@ public class OpenCreateMenuButton extends Button { public static ItemStack icon = AllItems.GOGGLES.asStack(); public OpenCreateMenuButton(int x, int y) { - super(x, y, 20, 20, StringTextComponent.EMPTY, OpenCreateMenuButton::click); + super(x, y, 20, 20, TextComponent.EMPTY, OpenCreateMenuButton::click); } @Override - public void render(MatrixStack mstack, int mouseX, int mouseY, float pticks) { + public void render(PoseStack mstack, int mouseX, int mouseY, float pticks) { super.render(mstack, mouseX, mouseY, pticks); if (!visible) return; @@ -87,11 +87,11 @@ public class OpenCreateMenuButton extends Button { MenuRows menu = null; int rowIdx = 0, offsetX = 0; - if (gui instanceof MainMenuScreen) { + if (gui instanceof TitleScreen) { menu = MenuRows.MAIN_MENU; rowIdx = AllConfigs.CLIENT.mainMenuConfigButtonRow.get(); offsetX = AllConfigs.CLIENT.mainMenuConfigButtonOffsetX.get(); - } else if (gui instanceof IngameMenuScreen) { + } else if (gui instanceof PauseScreen) { menu = MenuRows.INGAME_MENU; rowIdx = AllConfigs.CLIENT.ingameMenuConfigButtonRow.get(); offsetX = AllConfigs.CLIENT.ingameMenuConfigButtonOffsetX.get(); 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 71152af60..7aba4f2bc 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 @@ -19,7 +19,7 @@ import org.lwjgl.glfw.GLFW; import com.electronwill.nightconfig.core.AbstractConfig; import com.electronwill.nightconfig.core.UnmodifiableConfig; import com.google.common.collect.Lists; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.config.ui.ConfigScreenList.LabeledEntry; import com.simibubi.create.foundation.config.ui.entries.BooleanEntry; import com.simibubi.create.foundation.config.ui.entries.EnumEntry; @@ -41,11 +41,11 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Pair; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.IGuiEventListener; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.util.text.ITextProperties; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.config.ModConfig; @@ -184,7 +184,7 @@ public class SubMenuConfigScreen extends ConfigScreen { .withCallback((x, y) -> new ConfirmationScreen() .centered() - .withText(ITextProperties.of("Resetting all settings of the " + type.toString() + " config. Are you sure?")) + .withText(FormattedText.of("Resetting all settings of the " + type.toString() + " config. Are you sure?")) .withAction(success -> { if (success) resetConfig(spec.getValues()); @@ -193,8 +193,8 @@ public class SubMenuConfigScreen extends ConfigScreen { ); resetAll.showingElement(AllIcons.I_CONFIG_RESET.asStencil().withElementRenderer(BoxWidget.gradientFactory.apply(resetAll))); - resetAll.getToolTip().add(new StringTextComponent("Reset All")); - resetAll.getToolTip().addAll(TooltipHelper.cutStringTextComponent("Click here to reset all settings to their default value.", TextFormatting.GRAY, TextFormatting.GRAY)); + resetAll.getToolTip().add(new TextComponent("Reset All")); + resetAll.getToolTip().addAll(TooltipHelper.cutStringTextComponent("Click here to reset all settings to their default value.", ChatFormatting.GRAY, ChatFormatting.GRAY)); saveChanges = new BoxWidget(listL - 30, yCenter - 25, 20, 20) .withPadding(2, 2) @@ -204,7 +204,7 @@ public class SubMenuConfigScreen extends ConfigScreen { ConfirmationScreen confirm = new ConfirmationScreen() .centered() - .withText(ITextProperties.of("Saving " + ConfigHelper.changes.size() + " changed value" + (ConfigHelper.changes.size() != 1 ? "s" : "") + "")) + .withText(FormattedText.of("Saving " + ConfigHelper.changes.size() + " changed value" + (ConfigHelper.changes.size() != 1 ? "s" : "") + "")) .withAction(success -> { if (success) saveChanges(); @@ -213,8 +213,8 @@ public class SubMenuConfigScreen extends ConfigScreen { addAnnotationsToConfirm(confirm).open(this); }); saveChanges.showingElement(AllIcons.I_CONFIG_SAVE.asStencil().withElementRenderer(BoxWidget.gradientFactory.apply(saveChanges))); - saveChanges.getToolTip().add(new StringTextComponent("Save Changes")); - saveChanges.getToolTip().addAll(TooltipHelper.cutStringTextComponent("Click here to save your current changes.", TextFormatting.GRAY, TextFormatting.GRAY)); + saveChanges.getToolTip().add(new TextComponent("Save Changes")); + saveChanges.getToolTip().addAll(TooltipHelper.cutStringTextComponent("Click here to save your current changes.", ChatFormatting.GRAY, ChatFormatting.GRAY)); discardChanges = new BoxWidget(listL - 30, yCenter + 5, 20, 20) .withPadding(2, 2) @@ -224,7 +224,7 @@ public class SubMenuConfigScreen extends ConfigScreen { new ConfirmationScreen() .centered() - .withText(ITextProperties.of("Discarding " + ConfigHelper.changes.size() + " unsaved change" + (ConfigHelper.changes.size() != 1 ? "s" : "") + "")) + .withText(FormattedText.of("Discarding " + ConfigHelper.changes.size() + " unsaved change" + (ConfigHelper.changes.size() != 1 ? "s" : "") + "")) .withAction(success -> { if (success) clearChanges(); @@ -232,14 +232,14 @@ public class SubMenuConfigScreen extends ConfigScreen { .open(this); }); discardChanges.showingElement(AllIcons.I_CONFIG_DISCARD.asStencil().withElementRenderer(BoxWidget.gradientFactory.apply(discardChanges))); - discardChanges.getToolTip().add(new StringTextComponent("Discard Changes")); - discardChanges.getToolTip().addAll(TooltipHelper.cutStringTextComponent("Click here to discard all the changes you made.", TextFormatting.GRAY, TextFormatting.GRAY)); + discardChanges.getToolTip().add(new TextComponent("Discard Changes")); + discardChanges.getToolTip().addAll(TooltipHelper.cutStringTextComponent("Click here to discard all the changes you made.", ChatFormatting.GRAY, ChatFormatting.GRAY)); goBack = new BoxWidget(listL - 30, yCenter + 65, 20, 20) .withPadding(2, 2) .withCallback(this::attemptBackstep); goBack.showingElement(AllIcons.I_CONFIG_BACK.asStencil().withElementRenderer(BoxWidget.gradientFactory.apply(goBack))); - goBack.getToolTip().add(new StringTextComponent("Go Back")); + goBack.getToolTip().add(new TextComponent("Go Back")); widgets.add(resetAll); widgets.add(saveChanges); @@ -333,21 +333,21 @@ 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").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)); + serverLocked.getToolTip().add(new TextComponent("Locked").withStyle(ChatFormatting.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.", ChatFormatting.GRAY, ChatFormatting.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").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)); + serverLocked.getToolTip().add(new TextComponent("Unlocked").withStyle(ChatFormatting.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.", ChatFormatting.GRAY, ChatFormatting.GRAY)); } widgets.add(serverLocked); } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { super.renderWindow(ms, mouseX, mouseY, partialTicks); int x = width / 2; @@ -357,7 +357,7 @@ public class SubMenuConfigScreen extends ConfigScreen { } @Override - protected void renderWindowForeground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { super.renderWindowForeground(ms, mouseX, mouseY, partialTicks); } @@ -370,7 +370,7 @@ public class SubMenuConfigScreen extends ConfigScreen { @Nullable @Override - public IGuiEventListener getFocused() { + public GuiEventListener getFocused() { if (ConfigScreenList.currentText != null) return ConfigScreenList.currentText; @@ -445,7 +445,7 @@ public class SubMenuConfigScreen extends ConfigScreen { ConfirmationScreen screen = new ConfirmationScreen() .centered() .withThreeActions(action) - .addText(ITextProperties.of("Leaving with " + ConfigHelper.changes.size() + " unsaved change" + .addText(FormattedText.of("Leaving with " + ConfigHelper.changes.size() + " unsaved change" + (ConfigHelper.changes.size() != 1 ? "s" : "") + " for this config")); addAnnotationsToConfirm(screen).open(this); @@ -463,13 +463,13 @@ public class SubMenuConfigScreen extends ConfigScreen { }); if (relog.get()) { - screen.addText(ITextProperties.of(" ")); - screen.addText(ITextProperties.of("At least one changed value will require you to relog to take full effect")); + screen.addText(FormattedText.of(" ")); + screen.addText(FormattedText.of("At least one changed value will require you to relog to take full effect")); } if (restart.get()) { - screen.addText(ITextProperties.of(" ")); - screen.addText(ITextProperties.of("At least one changed value will require you to restart your game to take full effect")); + screen.addText(FormattedText.of(" ")); + screen.addText(FormattedText.of("At least one changed value will require you to restart your game to take full effect")); } return screen; diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java index 8cab0fe64..06fa1b0b1 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.config.ui.entries; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.gui.RenderElement; import com.simibubi.create.foundation.gui.Theme; @@ -46,7 +46,7 @@ public class BooleanEntry extends ValueEntry { } @Override - public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, + public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); 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 e72d74552..df1e22d99 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 @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.config.ui.entries; import java.util.Locale; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.config.ui.ConfigScreen; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.gui.BoxElement; @@ -77,7 +77,7 @@ public class EnumEntry extends ValueEntry> { } @Override - public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, + public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); 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 add4c54d2..6fc3f8cc5 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 @@ -6,23 +6,23 @@ import java.util.function.Function; import javax.annotation.Nullable; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.config.ui.ConfigTextField; import com.simibubi.create.foundation.gui.TextStencilElement; import com.simibubi.create.foundation.gui.Theme; import com.simibubi.create.foundation.gui.UIRenderHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.common.ForgeConfigSpec; public abstract class NumberEntry extends ValueEntry { protected int minOffset = 0, maxOffset = 0; protected TextStencilElement minText = null, maxText = null; - protected TextFieldWidget textField; + protected EditBox textField; @Nullable public static NumberEntry create(Object type, String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { @@ -72,15 +72,15 @@ public abstract class NumberEntry extends ValueEntry { T min = (T) minField.get(range); T max = (T) maxField.get(range); - FontRenderer font = Minecraft.getInstance().font; + Font font = Minecraft.getInstance().font; if (min.doubleValue() > getTypeMin().doubleValue()) { - StringTextComponent t = new StringTextComponent(formatBound(min) + " < "); + TextComponent t = new TextComponent(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.width(t); } if (max.doubleValue() < getTypeMax().doubleValue()) { - StringTextComponent t = new StringTextComponent(" < " + formatBound(max)); + TextComponent t = new TextComponent(" < " + 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.width(t); @@ -145,7 +145,7 @@ public abstract class NumberEntry extends ValueEntry { } @Override - 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) { + public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); textField.x = x + width - 82 - resetWidth; diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java index d2812f463..9b7c46470 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.config.ui.entries; import com.electronwill.nightconfig.core.UnmodifiableConfig; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.config.ui.ConfigScreenList; import com.simibubi.create.foundation.config.ui.SubMenuConfigScreen; import com.simibubi.create.foundation.gui.AllIcons; @@ -33,7 +33,7 @@ public class SubMenuEntry extends ConfigScreenList.LabeledEntry { } @Override - 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) { + public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); button.x = x + width - 108; 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 f19d48d7a..f78c72dbc 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 @@ -9,7 +9,7 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import com.google.common.base.Predicates; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.config.ui.ConfigAnnotations; import com.simibubi.create.foundation.config.ui.ConfigHelper; import com.simibubi.create.foundation.config.ui.ConfigScreen; @@ -20,8 +20,8 @@ import com.simibubi.create.foundation.gui.widgets.BoxWidget; import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.common.ForgeConfigSpec; public class ValueEntry extends ConfigScreenList.LabeledEntry { @@ -50,7 +50,7 @@ public class ValueEntry extends ConfigScreenList.LabeledEntry { listeners.add(resetButton); List path = value.getPath(); - labelTooltip.add(new StringTextComponent(label).withStyle(TextFormatting.WHITE)); + labelTooltip.add(new TextComponent(label).withStyle(ChatFormatting.WHITE)); String comment = spec.getComment(); if (comment == null || comment.isEmpty()) return; @@ -68,18 +68,18 @@ public class ValueEntry extends ConfigScreenList.LabeledEntry { // add comment to tooltip labelTooltip.addAll(commentLines.stream() .filter(Predicates.not(s -> s.startsWith("Range"))) - .map(StringTextComponent::new) - .flatMap(stc -> TooltipHelper.cutTextComponent(stc, TextFormatting.GRAY, TextFormatting.GRAY) + .map(TextComponent::new) + .flatMap(stc -> TooltipHelper.cutTextComponent(stc, ChatFormatting.GRAY, ChatFormatting.GRAY) .stream()) .collect(Collectors.toList())); if (annotations.containsKey(ConfigAnnotations.RequiresRelog.TRUE.getName())) - labelTooltip.addAll(TooltipHelper.cutTextComponent(new StringTextComponent("Changing this value will require a _relog_ to take full effect"), TextFormatting.GRAY, TextFormatting.GOLD)); + labelTooltip.addAll(TooltipHelper.cutTextComponent(new TextComponent("Changing this value will require a _relog_ to take full effect"), ChatFormatting.GRAY, ChatFormatting.GOLD)); if (annotations.containsKey(ConfigAnnotations.RequiresRestart.CLIENT.getName())) - labelTooltip.addAll(TooltipHelper.cutTextComponent(new StringTextComponent("Changing this value will require a _restart_ to take full effect"), TextFormatting.GRAY, TextFormatting.RED)); + labelTooltip.addAll(TooltipHelper.cutTextComponent(new TextComponent("Changing this value will require a _restart_ to take full effect"), ChatFormatting.GRAY, ChatFormatting.RED)); - labelTooltip.add(new StringTextComponent(ConfigScreen.modID + ":" + path.get(path.size() - 1)).withStyle(TextFormatting.DARK_GRAY)); + labelTooltip.add(new TextComponent(ConfigScreen.modID + ":" + path.get(path.size() - 1)).withStyle(ChatFormatting.DARK_GRAY)); } @Override @@ -96,7 +96,7 @@ public class ValueEntry extends ConfigScreenList.LabeledEntry { } @Override - 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) { + public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); resetButton.x = x + width - resetWidth + 6; 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 18977afe5..a4bddea0b 100644 --- a/src/main/java/com/simibubi/create/foundation/data/AssetLookup.java +++ b/src/main/java/com/simibubi/create/foundation/data/AssetLookup.java @@ -7,12 +7,12 @@ import com.tterrag.registrate.providers.RegistrateBlockstateProvider; import com.tterrag.registrate.providers.RegistrateItemModelProvider; import com.tterrag.registrate.util.nullness.NonNullBiConsumer; -import net.minecraft.block.BlockState; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.state.IntegerProperty; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.ItemModelBuilder; import net.minecraftforge.client.model.generators.ModelFile; 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 b3bb67a33..a063f8d18 100644 --- a/src/main/java/com/simibubi/create/foundation/data/BlockStateGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/BlockStateGen.java @@ -32,15 +32,15 @@ import com.tterrag.registrate.providers.RegistrateBlockstateProvider; import com.tterrag.registrate.util.nullness.NonNullBiConsumer; import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.RailShape; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder; 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 7f837a738..f0fba401b 100644 --- a/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java +++ b/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java @@ -28,17 +28,17 @@ import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.SoundType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; import net.minecraft.client.renderer.RenderType; -import net.minecraft.item.DyeColor; -import net.minecraft.item.Rarity; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.PistonType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.Rarity; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.PistonType; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; @@ -57,7 +57,7 @@ public class BuilderTransformers { public static NonNullUnaryOperator> encasedShaft(String casing, CTSpriteShiftEntry casingShift) { return builder -> builder.initialProperties(SharedProperties::stone) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(casingShift))) .onRegister(CreateRegistrate.casingConnectivity( (block, cc) -> cc.make(block, casingShift, (s, f) -> f.getAxis() != s.getValue(EncasedShaftBlock.AXIS)))) @@ -99,7 +99,7 @@ public class BuilderTransformers { String type, ResourceLocation particleTexture) { return b -> b.initialProperties(SharedProperties::stone) .addLayer(() -> RenderType::cutoutMipped) - .properties(AbstractBlock.Properties::noOcclusion) + .properties(BlockBehaviour.Properties::noOcclusion) .blockstate((c, p) -> p.getVariantBuilder(c.get()) .forAllStates(state -> { String id = "block/" + type + "_tunnel"; diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateEntityBuilder.java b/src/main/java/com/simibubi/create/foundation/data/CreateEntityBuilder.java index ef35ef8f0..52ac48069 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateEntityBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateEntityBuilder.java @@ -11,9 +11,9 @@ import com.tterrag.registrate.builders.EntityBuilder; import com.tterrag.registrate.util.OneTimeEventReceiver; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.EntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -24,11 +24,11 @@ public class CreateEntityBuilder extends EntityBuilder> instanceFactory; - public static EntityBuilder create(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, EntityType.IFactory factory, EntityClassification classification) { + public static EntityBuilder create(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, EntityType.EntityFactory factory, MobCategory classification) { return (new CreateEntityBuilder<>(owner, parent, name, callback, factory, classification)).defaultLang(); } - public CreateEntityBuilder(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, EntityType.IFactory factory, EntityClassification classification) { + public CreateEntityBuilder(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, EntityType.EntityFactory factory, MobCategory classification) { super(owner, parent, name, callback, factory, classification); } diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java index 67f1e08fb..04b273756 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java @@ -33,18 +33,18 @@ import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; -import net.minecraft.block.AbstractBlock.Properties; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.Item; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; +import net.minecraft.world.level.block.Block; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.Item; import net.minecraft.tags.BlockTags; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.Tags; @@ -116,14 +116,14 @@ public class CreateRegistrate extends AbstractRegistrate { .collect(Collectors.toList()); } - public CreateTileEntityBuilder tileEntity(String name, - NonNullFunction, ? extends T> factory) { + public CreateTileEntityBuilder tileEntity(String name, + NonNullFunction, ? extends T> factory) { return this.tileEntity(this.self(), name, factory); } @Override - public CreateTileEntityBuilder tileEntity(P parent, String name, - NonNullFunction, ? extends T> factory) { + public CreateTileEntityBuilder tileEntity(P parent, String name, + NonNullFunction, ? extends T> factory) { return (CreateTileEntityBuilder) this.entry(name, (callback) -> { return CreateTileEntityBuilder.create(this, parent, name, callback, factory); }); @@ -131,12 +131,12 @@ public class CreateRegistrate extends AbstractRegistrate { @Override public CreateEntityBuilder entity(String name, - EntityType.IFactory factory, EntityClassification classification) { + EntityType.EntityFactory factory, MobCategory classification) { return this.entity(self(), name, factory, classification); } - public CreateEntityBuilder entity(P parent, String name, EntityType.IFactory factory, - EntityClassification classification) { + public CreateEntityBuilder entity(P parent, String name, EntityType.EntityFactory factory, + MobCategory classification) { return (CreateEntityBuilder) this.entry(name, (callback) -> { return CreateEntityBuilder.create(this, parent, name, callback, factory, classification); }); @@ -209,12 +209,12 @@ public class CreateRegistrate extends AbstractRegistrate { } public static NonNullConsumer blockModel( - Supplier> func) { + Supplier> func) { return entry -> onClient(() -> () -> registerBlockModel(entry, func)); } public static NonNullConsumer itemModel( - Supplier> func) { + Supplier> func) { return entry -> onClient(() -> () -> registerItemModel(entry, func)); } @@ -235,7 +235,7 @@ public class CreateRegistrate extends AbstractRegistrate { Supplier>> supplier) { b.properties(p -> p.setISTER(() -> supplier.get()::get)) .onRegister(entry -> { - ItemStackTileEntityRenderer ister = entry.getItemStackTileEntityRenderer(); + BlockEntityWithoutLevelRenderer ister = entry.getItemStackTileEntityRenderer(); if (ister instanceof CustomRenderedItemModelRenderer) registerCustomRenderedItem(entry, (CustomRenderedItemModelRenderer) ister); }); @@ -261,14 +261,14 @@ public class CreateRegistrate extends AbstractRegistrate { @OnlyIn(Dist.CLIENT) private static void registerBlockModel(Block entry, - Supplier> func) { + Supplier> func) { CreateClient.MODEL_SWAPPER.getCustomBlockModels() .register(entry.delegate, func.get()); } @OnlyIn(Dist.CLIENT) private static void registerItemModel(Item entry, - Supplier> func) { + Supplier> func) { CreateClient.MODEL_SWAPPER.getCustomItemModels() .register(entry.delegate, func.get()); } diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateTileEntityBuilder.java b/src/main/java/com/simibubi/create/foundation/data/CreateTileEntityBuilder.java index 38d854f8c..6c8bd0d1d 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateTileEntityBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateTileEntityBuilder.java @@ -11,24 +11,24 @@ import com.tterrag.registrate.util.OneTimeEventReceiver; import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -public class CreateTileEntityBuilder extends TileEntityBuilder { +public class CreateTileEntityBuilder extends TileEntityBuilder { @Nullable private NonNullSupplier> instanceFactory; - public static TileEntityBuilder create(AbstractRegistrate owner, P parent, - String name, BuilderCallback callback, NonNullFunction, ? extends T> factory) { + public static TileEntityBuilder create(AbstractRegistrate owner, P parent, + String name, BuilderCallback callback, NonNullFunction, ? extends T> factory) { return new CreateTileEntityBuilder<>(owner, parent, name, callback, factory); } protected CreateTileEntityBuilder(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, - NonNullFunction, ? extends T> factory) { + NonNullFunction, ? extends T> factory) { super(owner, parent, name, callback, factory); } 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 ec321bd6e..9e68d98d0 100644 --- a/src/main/java/com/simibubi/create/foundation/data/DirectionalAxisBlockStateGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/DirectionalAxisBlockStateGen.java @@ -4,10 +4,10 @@ import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; import net.minecraftforge.client.model.generators.ModelFile; public abstract class DirectionalAxisBlockStateGen extends SpecialBlockStateGen { 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 0b71d5383..900e79e1c 100644 --- a/src/main/java/com/simibubi/create/foundation/data/LangMerger.java +++ b/src/main/java/com/simibubi/create/foundation/data/LangMerger.java @@ -27,11 +27,11 @@ import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.utility.FilesHelper; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.util.JSONUtils; +import net.minecraft.data.HashCache; +import net.minecraft.data.DataProvider; +import net.minecraft.util.GsonHelper; -public class LangMerger implements IDataProvider { +public class LangMerger implements DataProvider { private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting() .disableHtmlEscaping() @@ -76,7 +76,7 @@ public class LangMerger implements IDataProvider { } @Override - public void run(DirectoryCache cache) throws IOException { + public void run(HashCache cache) throws IOException { Path path = this.gen.getOutputFolder() .resolve("assets/" + Create.ID + "/lang/" + "en_us.json"); @@ -125,7 +125,7 @@ public class LangMerger implements IDataProvider { } try (BufferedReader reader = Files.newBufferedReader(path)) { - JsonObject jsonobject = JSONUtils.fromJson(GSON, reader, JsonObject.class); + JsonObject jsonobject = GsonHelper.fromJson(GSON, reader, JsonObject.class); addAll("Game Elements", jsonobject); reader.close(); } @@ -227,12 +227,12 @@ public class LangMerger implements IDataProvider { .getAsJsonObject()); } - private void save(DirectoryCache cache, List dataIn, int missingKeys, Path target, String message) + private void save(HashCache cache, List dataIn, int missingKeys, Path target, String message) throws IOException { String data = createString(dataIn, missingKeys); // data = JavaUnicodeEscaper.outsideOf(0, 0x7f) // .translate(data); - String hash = IDataProvider.SHA1.hashUnencodedChars(data) + String hash = DataProvider.SHA1.hashUnencodedChars(data) .toString(); if (!Objects.equals(cache.getHash(target), hash) || !Files.exists(target)) { Files.createDirectories(target.getParent()); diff --git a/src/main/java/com/simibubi/create/foundation/data/ModelGen.java b/src/main/java/com/simibubi/create/foundation/data/ModelGen.java index b99a63bb1..0b2ab183f 100644 --- a/src/main/java/com/simibubi/create/foundation/data/ModelGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/ModelGen.java @@ -5,9 +5,9 @@ import com.tterrag.registrate.builders.ItemBuilder; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.util.nullness.NonNullFunction; -import net.minecraft.block.Block; -import net.minecraft.item.BlockItem; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.item.BlockItem; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ModelFile; 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 000ff1b05..f3432c9bb 100644 --- a/src/main/java/com/simibubi/create/foundation/data/NamedTag.java +++ b/src/main/java/com/simibubi/create/foundation/data/NamedTag.java @@ -7,16 +7,16 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.tags.ITag; -import net.minecraft.util.ResourceLocation; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public class NamedTag implements ITag.INamedTag { +public class NamedTag implements Tag.Named { private final ResourceLocation id; - private final ITag tag; + private final Tag tag; - public NamedTag(@Nullable ITag tag, ResourceLocation id) { + public NamedTag(@Nullable Tag tag, ResourceLocation id) { this.tag = tag; this.id = id; } 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 c65837850..4e63a424a 100644 --- a/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java +++ b/src/main/java/com/simibubi/create/foundation/data/SharedProperties.java @@ -1,11 +1,11 @@ package com.simibubi.create.foundation.data; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.material.Material; -import net.minecraft.block.material.MaterialColor; -import net.minecraft.block.material.PushReaction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.material.PushReaction; @MethodsReturnNonnullByDefault public class SharedProperties { 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 1529eac07..38bdd9ef8 100644 --- a/src/main/java/com/simibubi/create/foundation/data/SpecialBlockStateGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/SpecialBlockStateGen.java @@ -3,10 +3,10 @@ package com.simibubi.create.foundation.data; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.Property; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.core.Direction; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; diff --git a/src/main/java/com/simibubi/create/foundation/data/VirtualFluidBuilder.java b/src/main/java/com/simibubi/create/foundation/data/VirtualFluidBuilder.java index 916f3eeb9..6e25a7300 100644 --- a/src/main/java/com/simibubi/create/foundation/data/VirtualFluidBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/data/VirtualFluidBuilder.java @@ -8,8 +8,8 @@ import com.tterrag.registrate.builders.FluidBuilder; import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.fluid.Fluid; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.ForgeFlowingFluid; import net.minecraftforge.fluids.ForgeFlowingFluid.Properties; 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 2e3c6dbc6..b5916e839 100644 --- a/src/main/java/com/simibubi/create/foundation/data/WindowGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/WindowGen.java @@ -23,19 +23,19 @@ import com.tterrag.registrate.util.nullness.NonNullBiConsumer; import com.tterrag.registrate.util.nullness.NonNullConsumer; import com.tterrag.registrate.util.nullness.NonNullFunction; -import net.minecraft.block.AbstractBlock.Properties; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.WoodType; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.properties.WoodType; import net.minecraft.client.renderer.RenderType; -import net.minecraft.data.ShapedRecipeBuilder; -import net.minecraft.entity.EntityType; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.world.entity.EntityType; import net.minecraft.tags.BlockTags; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.Tags; @@ -50,11 +50,11 @@ public class WindowGen { .isViewBlocking(WindowGen::never); } - private static boolean never(BlockState p_235436_0_, IBlockReader p_235436_1_, BlockPos p_235436_2_) { + private static boolean never(BlockState p_235436_0_, BlockGetter p_235436_1_, BlockPos p_235436_2_) { return false; } - private static Boolean never(BlockState p_235427_0_, IBlockReader p_235427_1_, BlockPos p_235427_2_, + private static Boolean never(BlockState p_235427_0_, BlockGetter p_235427_1_, BlockPos p_235427_2_, EntityType p_235427_3_) { return false; } @@ -63,7 +63,7 @@ public class WindowGen { return woodenWindowBlock(woodType, planksBlock, () -> RenderType::cutoutMipped); } - public static BlockEntry customWindowBlock(String name, Supplier ingredient, + public static BlockEntry customWindowBlock(String name, Supplier ingredient, CTSpriteShiftEntry ct, Supplier> renderType) { NonNullFunction end_texture = n -> Create.asResource(palettesDir() + name + "_end"); NonNullFunction side_texture = n -> Create.asResource(palettesDir() + n); @@ -81,7 +81,7 @@ public class WindowGen { side_texture); } - public static BlockEntry windowBlock(String name, Supplier ingredient, + public static BlockEntry windowBlock(String name, Supplier ingredient, CTSpriteShiftEntry ct, Supplier> renderType, NonNullFunction endTexture, NonNullFunction sideTexture) { return REGISTRATE.block(name, WindowBlock::new) 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..550bfa95b 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 @@ -6,10 +6,10 @@ import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.AllTags.AllFluidTags; import com.simibubi.create.content.palettes.AllPaletteBlocks; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.Items; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.Items; import net.minecraftforge.common.Tags; public class CompactingRecipeGen extends ProcessingRecipeGen { 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 2e4138cec..b8a5db1d4 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 @@ -10,12 +10,12 @@ import com.simibubi.create.AllTags; import com.simibubi.create.Create; import net.minecraft.data.DataGenerator; -import net.minecraft.data.IFinishedRecipe; -import net.minecraft.data.RecipeProvider; -import net.minecraft.item.Item; -import net.minecraft.tags.ITag; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeProvider; +import net.minecraft.world.item.Item; +import net.minecraft.tags.Tag; import net.minecraft.tags.ItemTags; -import net.minecraft.util.IItemProvider; +import net.minecraft.world.level.ItemLike; import net.minecraftforge.common.Tags; public abstract class CreateRecipeProvider extends RecipeProvider { @@ -27,7 +27,7 @@ public abstract class CreateRecipeProvider extends RecipeProvider { } @Override - protected void buildShapelessRecipes(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")); } @@ -39,7 +39,7 @@ public abstract class CreateRecipeProvider extends RecipeProvider { @FunctionalInterface public interface GeneratedRecipe { - void register(Consumer consumer); + void register(Consumer consumer); } protected static class Marker { @@ -47,127 +47,127 @@ public abstract class CreateRecipeProvider extends RecipeProvider { protected static class I { - static ITag.INamedTag redstone() { + static Tag.Named redstone() { return Tags.Items.DUSTS_REDSTONE; } - static ITag.INamedTag planks() { + static Tag.Named planks() { return ItemTags.PLANKS; } - static ITag.INamedTag woodSlab() { + static Tag.Named woodSlab() { return ItemTags.WOODEN_SLABS; } - static ITag.INamedTag gold() { + static Tag.Named gold() { return AllTags.forgeItemTag("ingots/gold"); } - static ITag.INamedTag goldSheet() { + static Tag.Named goldSheet() { return AllTags.forgeItemTag("plates/gold"); } - static ITag.INamedTag stone() { + static Tag.Named stone() { return Tags.Items.STONE; } - static IItemProvider andesite() { + static ItemLike andesite() { return AllItems.ANDESITE_ALLOY.get(); } - static IItemProvider shaft() { + static ItemLike shaft() { return AllBlocks.SHAFT.get(); } - static IItemProvider cog() { + static ItemLike cog() { return AllBlocks.COGWHEEL.get(); } - static IItemProvider largeCog() { + static ItemLike largeCog() { return AllBlocks.LARGE_COGWHEEL.get(); } - static IItemProvider andesiteCasing() { + static ItemLike andesiteCasing() { return AllBlocks.ANDESITE_CASING.get(); } - static ITag.INamedTag brass() { + static Tag.Named brass() { return AllTags.forgeItemTag("ingots/brass"); } - static ITag.INamedTag brassSheet() { + static Tag.Named brassSheet() { return AllTags.forgeItemTag("plates/brass"); } - static ITag.INamedTag iron() { + static Tag.Named iron() { return Tags.Items.INGOTS_IRON; } - static ITag.INamedTag ironNugget() { + static Tag.Named ironNugget() { return AllTags.forgeItemTag("nuggets/iron"); } - static ITag.INamedTag zinc() { + static Tag.Named zinc() { return AllTags.forgeItemTag("ingots/zinc"); } - static ITag.INamedTag ironSheet() { + static Tag.Named ironSheet() { return AllTags.forgeItemTag("plates/iron"); } - static IItemProvider brassCasing() { + static ItemLike brassCasing() { return AllBlocks.BRASS_CASING.get(); } - static IItemProvider electronTube() { + static ItemLike electronTube() { return AllItems.ELECTRON_TUBE.get(); } - static IItemProvider precisionMechanism() { + static ItemLike precisionMechanism() { return AllItems.PRECISION_MECHANISM.get(); } - static ITag.INamedTag copperBlock() { + static Tag.Named copperBlock() { return AllTags.forgeItemTag("storage_blocks/copper"); } - static ITag.INamedTag brassBlock() { + static Tag.Named brassBlock() { return AllTags.forgeItemTag("storage_blocks/brass"); } - static ITag.INamedTag zincBlock() { + static Tag.Named zincBlock() { return AllTags.forgeItemTag("storage_blocks/zinc"); } - static ITag.INamedTag copper() { + static Tag.Named copper() { return AllTags.forgeItemTag("ingots/copper"); } - static ITag.INamedTag copperSheet() { + static Tag.Named copperSheet() { return AllTags.forgeItemTag("plates/copper"); } - static ITag.INamedTag copperNugget() { + static Tag.Named copperNugget() { return AllTags.forgeItemTag("nuggets/copper"); } - static ITag.INamedTag brassNugget() { + static Tag.Named brassNugget() { return AllTags.forgeItemTag("nuggets/brass"); } - static ITag.INamedTag zincNugget() { + static Tag.Named zincNugget() { return AllTags.forgeItemTag("nuggets/zinc"); } - static IItemProvider copperCasing() { + static ItemLike copperCasing() { return AllBlocks.COPPER_CASING.get(); } - static IItemProvider refinedRadiance() { + static ItemLike refinedRadiance() { return AllItems.REFINED_RADIANCE.get(); } - static IItemProvider shadowSteel() { + static ItemLike shadowSteel() { return AllItems.SHADOW_STEEL.get(); } 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..e01827e73 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 @@ -6,10 +6,10 @@ import com.simibubi.create.AllTags; import com.simibubi.create.content.palettes.AllPaletteBlocks; import com.tterrag.registrate.util.entry.ItemEntry; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.item.Item; -import net.minecraft.item.Items; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraft.tags.ItemTags; import net.minecraftforge.common.crafting.conditions.NotCondition; import net.minecraftforge.common.crafting.conditions.TagEmptyCondition; 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..9c4fc0a2d 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 @@ -3,8 +3,8 @@ package com.simibubi.create.foundation.data.recipe; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllRecipeTypes; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; public class CuttingRecipeGen extends ProcessingRecipeGen { 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 21a31eecd..b2a17979d 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 @@ -5,7 +5,7 @@ import com.simibubi.create.AllItems; import com.simibubi.create.AllRecipeTypes; import net.minecraft.data.DataGenerator; -import net.minecraft.item.Items; +import net.minecraft.world.item.Items; 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 5421db0b5..1ef1a9298 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 @@ -7,9 +7,9 @@ import com.simibubi.create.AllTags.AllFluidTags; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import net.minecraft.data.DataGenerator; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.Items; -import net.minecraft.potion.Potions; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.alchemy.Potions; import net.minecraftforge.common.Tags; public class FillingRecipeGen extends ProcessingRecipeGen { 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 2b75c2f4a..8efdeda6a 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 @@ -15,13 +15,13 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.simibubi.create.AllRecipeTypes; -import net.minecraft.data.IFinishedRecipe; -import net.minecraft.item.Item; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.tags.Tag; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.tags.SetTag; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; public class MechanicalCraftingRecipeBuilder { @@ -32,7 +32,7 @@ public class MechanicalCraftingRecipeBuilder { private final Map key = Maps.newLinkedHashMap(); private boolean acceptMirrored; - public MechanicalCraftingRecipeBuilder(IItemProvider p_i48261_1_, int p_i48261_2_) { + public MechanicalCraftingRecipeBuilder(ItemLike p_i48261_1_, int p_i48261_2_) { result = p_i48261_1_.asItem(); count = p_i48261_2_; acceptMirrored = true; @@ -41,28 +41,28 @@ public class MechanicalCraftingRecipeBuilder { /** * Creates a new builder for a shaped recipe. */ - public static MechanicalCraftingRecipeBuilder shapedRecipe(IItemProvider p_200470_0_) { + public static MechanicalCraftingRecipeBuilder shapedRecipe(ItemLike p_200470_0_) { return shapedRecipe(p_200470_0_, 1); } /** * Creates a new builder for a shaped recipe. */ - public static MechanicalCraftingRecipeBuilder shapedRecipe(IItemProvider p_200468_0_, int p_200468_1_) { + public static MechanicalCraftingRecipeBuilder shapedRecipe(ItemLike p_200468_0_, int p_200468_1_) { return new MechanicalCraftingRecipeBuilder(p_200468_0_, p_200468_1_); } /** * Adds a key to the recipe pattern. */ - public MechanicalCraftingRecipeBuilder key(Character p_200469_1_, Tag p_200469_2_) { + public MechanicalCraftingRecipeBuilder key(Character p_200469_1_, SetTag 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_) { + public MechanicalCraftingRecipeBuilder key(Character p_200462_1_, ItemLike p_200462_2_) { return this.key(p_200462_1_, Ingredient.of(p_200462_2_)); } @@ -104,7 +104,7 @@ public class MechanicalCraftingRecipeBuilder { /** * Builds this recipe into an {@link IFinishedRecipe}. */ - public void build(Consumer p_200464_1_) { + public void build(Consumer p_200464_1_) { this.build(p_200464_1_, ForgeRegistries.ITEMS.getKey(this.result)); } @@ -112,7 +112,7 @@ public class MechanicalCraftingRecipeBuilder { * Builds this recipe into an {@link IFinishedRecipe}. Use * {@link #build(Consumer)} if save is the same as the ID for the result. */ - public void build(Consumer p_200466_1_, String p_200466_2_) { + public void build(Consumer p_200466_1_, String p_200466_2_) { ResourceLocation resourcelocation = ForgeRegistries.ITEMS.getKey(this.result); if ((new ResourceLocation(p_200466_2_)).equals(resourcelocation)) { throw new IllegalStateException("Shaped Recipe " + p_200466_2_ + " should remove its 'save' argument"); @@ -124,7 +124,7 @@ public class MechanicalCraftingRecipeBuilder { /** * Builds this recipe into an {@link IFinishedRecipe}. */ - public void build(Consumer p_200467_1_, ResourceLocation p_200467_2_) { + public void build(Consumer p_200467_1_, ResourceLocation p_200467_2_) { validate(p_200467_2_); p_200467_1_ .accept(new MechanicalCraftingRecipeBuilder.Result(p_200467_2_, result, count, pattern, key, acceptMirrored)); @@ -156,7 +156,7 @@ public class MechanicalCraftingRecipeBuilder { } } - public class Result implements IFinishedRecipe { + public class Result implements FinishedRecipe { private final ResourceLocation id; private final Item result; private final int count; @@ -196,7 +196,7 @@ public class MechanicalCraftingRecipeBuilder { p_218610_1_.addProperty("acceptMirrored", acceptMirrored); } - public IRecipeSerializer getType() { + public RecipeSerializer getType() { return AllRecipeTypes.MECHANICAL_CRAFTING.getSerializer(); } 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 b15d1ac64..ce7f38309 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 @@ -7,12 +7,12 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.Create; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.tags.ItemTags; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags; public class MechanicalCraftingRecipeGen extends CreateRecipeProvider { @@ -72,17 +72,17 @@ public class MechanicalCraftingRecipeGen extends CreateRecipeProvider { super(p_i48262_1_); } - GeneratedRecipeBuilder create(Supplier result) { + GeneratedRecipeBuilder create(Supplier result) { return new GeneratedRecipeBuilder(result); } class GeneratedRecipeBuilder { private String suffix; - private Supplier result; + private Supplier result; private int amount; - public GeneratedRecipeBuilder(Supplier result) { + public GeneratedRecipeBuilder(Supplier result) { this.suffix = ""; this.result = result; this.amount = 1; 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 5a939f2eb..8cdd48bf7 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 @@ -6,10 +6,10 @@ import com.simibubi.create.AllTags; import com.simibubi.create.content.palettes.AllPaletteBlocks; import com.tterrag.registrate.util.entry.ItemEntry; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.item.Item; -import net.minecraft.item.Items; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraft.tags.ItemTags; import net.minecraftforge.common.crafting.conditions.NotCondition; import net.minecraftforge.common.crafting.conditions.TagEmptyCondition; 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..db4b7b849 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 @@ -6,10 +6,10 @@ import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.AllTags; import com.simibubi.create.content.contraptions.processing.HeatCondition; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.Items; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.Items; import net.minecraft.tags.ItemTags; import net.minecraftforge.common.Tags; diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/Mods.java b/src/main/java/com/simibubi/create/foundation/data/recipe/Mods.java index da9d26c03..bfac60a0d 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/Mods.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/Mods.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.data.recipe; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public enum Mods { 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 847efae00..a0a6a05c8 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 @@ -4,8 +4,8 @@ import com.simibubi.create.AllItems; import com.simibubi.create.AllRecipeTypes; import net.minecraft.data.DataGenerator; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.Ingredient; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; public class PressingRecipeGen extends ProcessingRecipeGen { 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 d9b9f2026..e50b7a18a 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 @@ -13,11 +13,11 @@ import com.simibubi.create.content.contraptions.processing.ProcessingRecipeSeria import com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo; import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.data.HashCache; +import net.minecraft.data.DataProvider; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fluids.FluidAttributes; public abstract class ProcessingRecipeGen extends CreateRecipeProvider { @@ -39,7 +39,7 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider { GENERATORS.add(new FillingRecipeGen(gen)); GENERATORS.add(new EmptyingRecipeGen(gen)); - gen.addProvider(new IDataProvider() { + gen.addProvider(new DataProvider() { @Override public String getName() { @@ -47,7 +47,7 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider { } @Override - public void run(DirectoryCache dc) throws IOException { + public void run(HashCache dc) throws IOException { GENERATORS.forEach(g -> { try { g.run(dc); @@ -67,11 +67,11 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider { * Create a processing recipe with a single itemstack ingredient, using its id * as the name of the recipe */ - protected > GeneratedRecipe create(String namespace, Supplier singleIngredient, + protected > GeneratedRecipe create(String namespace, Supplier singleIngredient, UnaryOperator> transform) { ProcessingRecipeSerializer serializer = getSerializer(); GeneratedRecipe generatedRecipe = c -> { - IItemProvider iItemProvider = singleIngredient.get(); + ItemLike iItemProvider = singleIngredient.get(); transform .apply(new ProcessingRecipeBuilder<>(serializer.getFactory(), new ResourceLocation(namespace, iItemProvider.asItem() .getRegistryName() @@ -86,7 +86,7 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider { * Create a processing recipe with a single itemstack ingredient, using its id * as the name of the recipe */ - > GeneratedRecipe create(Supplier singleIngredient, + > GeneratedRecipe create(Supplier singleIngredient, UnaryOperator> transform) { return create(Create.ID, singleIngredient, transform); } 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..75d432678 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 @@ -9,10 +9,10 @@ import com.simibubi.create.content.contraptions.components.deployer.DeployerAppl import com.simibubi.create.content.contraptions.components.saw.CuttingRecipe; import com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRecipeBuilder; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.tags.ItemTags; public class SequencedAssemblyRecipeGen extends CreateRecipeProvider { 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 c959188d0..0640c6853 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 @@ -29,26 +29,26 @@ import com.tterrag.registrate.util.entry.BlockEntry; import com.tterrag.registrate.util.entry.ItemEntry; import com.tterrag.registrate.util.entry.ItemProviderEntry; -import net.minecraft.advancements.criterion.ItemPredicate; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.data.CookingRecipeBuilder; -import net.minecraft.data.CustomRecipeBuilder; +import net.minecraft.advancements.critereon.ItemPredicate; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.data.recipes.SimpleCookingRecipeBuilder; +import net.minecraft.data.recipes.SpecialRecipeBuilder; import net.minecraft.data.DataGenerator; -import net.minecraft.data.IFinishedRecipe; -import net.minecraft.data.ShapedRecipeBuilder; -import net.minecraft.data.ShapelessRecipeBuilder; -import net.minecraft.item.DyeColor; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.CookingRecipeSerializer; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.SpecialRecipeSerializer; -import net.minecraft.tags.ITag; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.data.recipes.ShapelessRecipeBuilder; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.SimpleCookingSerializer; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.SimpleRecipeSerializer; +import net.minecraft.tags.Tag; import net.minecraft.tags.ItemTags; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.conditions.ICondition; @@ -1078,7 +1078,7 @@ public class StandardRecipeGen extends CreateRecipeProvider { return new Marker(); } - GeneratedRecipeBuilder create(Supplier result) { + GeneratedRecipeBuilder create(Supplier result) { return new GeneratedRecipeBuilder(currentFolder, result); } @@ -1086,20 +1086,20 @@ public class StandardRecipeGen extends CreateRecipeProvider { return new GeneratedRecipeBuilder(currentFolder, result); } - GeneratedRecipeBuilder create(ItemProviderEntry result) { + GeneratedRecipeBuilder create(ItemProviderEntry result) { return create(result::get); } - GeneratedRecipe createSpecial(Supplier> serializer, String recipeType, String path) { + GeneratedRecipe createSpecial(Supplier> serializer, String recipeType, String path) { ResourceLocation location = Create.asResource(recipeType + "/" + currentFolder + "/" + path); return register(consumer -> { - CustomRecipeBuilder b = CustomRecipeBuilder.special(serializer.get()); + SpecialRecipeBuilder b = SpecialRecipeBuilder.special(serializer.get()); b.save(consumer, location.toString()); }); } - GeneratedRecipe blastCrushedMetal(Supplier result, - Supplier ingredient) { + GeneratedRecipe blastCrushedMetal(Supplier result, + Supplier ingredient) { return create(result::get).withSuffix("_from_crushed") .viaCooking(ingredient::get) .rewardXP(.1f) @@ -1119,7 +1119,7 @@ public class StandardRecipeGen extends CreateRecipeProvider { return null; } - GeneratedRecipe blastMetalOre(Supplier result, ITag.INamedTag ore) { + GeneratedRecipe blastMetalOre(Supplier result, Tag.Named ore) { return create(result::get).withSuffix("_from_ore") .viaCookingTag(() -> ore) .rewardXP(.1f) @@ -1142,14 +1142,14 @@ public class StandardRecipeGen extends CreateRecipeProvider { .inFurnace(); } - GeneratedRecipe metalCompacting(List> variants, - List>> ingredients) { + GeneratedRecipe metalCompacting(List> variants, + List>> ingredients) { GeneratedRecipe result = null; for (int i = 0; i + 1 < variants.size(); i++) { - ItemProviderEntry currentEntry = variants.get(i); - ItemProviderEntry nextEntry = variants.get(i + 1); - Supplier> currentIngredient = ingredients.get(i); - Supplier> nextIngredient = ingredients.get(i + 1); + ItemProviderEntry currentEntry = variants.get(i); + ItemProviderEntry nextEntry = variants.get(i + 1); + Supplier> currentIngredient = ingredients.get(i); + Supplier> nextIngredient = ingredients.get(i + 1); result = create(nextEntry).withSuffix("_from_compacting") .unlockedBy(currentEntry::get) @@ -1166,11 +1166,11 @@ public class StandardRecipeGen extends CreateRecipeProvider { return result; } - GeneratedRecipe conversionCycle(List> cycle) { + GeneratedRecipe conversionCycle(List> cycle) { GeneratedRecipe result = null; for (int i = 0; i < cycle.size(); i++) { - ItemProviderEntry currentEntry = cycle.get(i); - ItemProviderEntry nextEntry = cycle.get((i + 1) % cycle.size()); + ItemProviderEntry currentEntry = cycle.get(i); + ItemProviderEntry nextEntry = cycle.get((i + 1) % cycle.size()); result = create(nextEntry).withSuffix("from_conversion") .unlockedBy(currentEntry::get) .viaShapeless(b -> b.requires(currentEntry.get())); @@ -1182,7 +1182,7 @@ public class StandardRecipeGen extends CreateRecipeProvider { private String path; private String suffix; - private Supplier result; + private Supplier result; private ResourceLocation compatDatagenOutput; List recipeConditions; @@ -1196,7 +1196,7 @@ public class StandardRecipeGen extends CreateRecipeProvider { this.amount = 1; } - public GeneratedRecipeBuilder(String path, Supplier result) { + public GeneratedRecipeBuilder(String path, Supplier result) { this(path); this.result = result; } @@ -1211,14 +1211,14 @@ public class StandardRecipeGen extends CreateRecipeProvider { return this; } - GeneratedRecipeBuilder unlockedBy(Supplier item) { + GeneratedRecipeBuilder unlockedBy(Supplier item) { this.unlockedBy = () -> ItemPredicate.Builder.item() .of(item.get()) .build(); return this; } - GeneratedRecipeBuilder unlockedByTag(Supplier> tag) { + GeneratedRecipeBuilder unlockedByTag(Supplier> tag) { this.unlockedBy = () -> ItemPredicate.Builder.item() .of(tag.get()) .build(); @@ -1275,11 +1275,11 @@ public class StandardRecipeGen extends CreateRecipeProvider { .getRegistryName() : compatDatagenOutput; } - GeneratedCookingRecipeBuilder viaCooking(Supplier item) { + GeneratedCookingRecipeBuilder viaCooking(Supplier item) { return unlockedBy(item).viaCookingIngredient(() -> Ingredient.of(item.get())); } - GeneratedCookingRecipeBuilder viaCookingTag(Supplier> tag) { + GeneratedCookingRecipeBuilder viaCookingTag(Supplier> tag) { return unlockedByTag(tag).viaCookingIngredient(() -> Ingredient.of(tag.get())); } @@ -1293,9 +1293,9 @@ public class StandardRecipeGen extends CreateRecipeProvider { private float exp; private int cookingTime; - private final CookingRecipeSerializer FURNACE = IRecipeSerializer.SMELTING_RECIPE, - SMOKER = IRecipeSerializer.SMOKING_RECIPE, BLAST = IRecipeSerializer.BLASTING_RECIPE, - CAMPFIRE = IRecipeSerializer.CAMPFIRE_COOKING_RECIPE; + private final SimpleCookingSerializer FURNACE = RecipeSerializer.SMELTING_RECIPE, + SMOKER = RecipeSerializer.SMOKING_RECIPE, BLAST = RecipeSerializer.BLASTING_RECIPE, + CAMPFIRE = RecipeSerializer.CAMPFIRE_COOKING_RECIPE; GeneratedCookingRecipeBuilder(Supplier ingredient) { this.ingredient = ingredient; @@ -1317,7 +1317,7 @@ public class StandardRecipeGen extends CreateRecipeProvider { return inFurnace(b -> b); } - GeneratedRecipe inFurnace(UnaryOperator builder) { + GeneratedRecipe inFurnace(UnaryOperator builder) { return create(FURNACE, builder, 1); } @@ -1325,7 +1325,7 @@ public class StandardRecipeGen extends CreateRecipeProvider { return inSmoker(b -> b); } - GeneratedRecipe inSmoker(UnaryOperator builder) { + GeneratedRecipe inSmoker(UnaryOperator builder) { create(FURNACE, builder, 1); create(CAMPFIRE, builder, 3); return create(SMOKER, builder, .5f); @@ -1335,18 +1335,18 @@ public class StandardRecipeGen extends CreateRecipeProvider { return inBlastFurnace(b -> b); } - GeneratedRecipe inBlastFurnace(UnaryOperator builder) { + GeneratedRecipe inBlastFurnace(UnaryOperator builder) { create(FURNACE, builder, 1); return create(BLAST, builder, .5f); } - private GeneratedRecipe create(CookingRecipeSerializer serializer, - UnaryOperator builder, float cookingTimeModifier) { + private GeneratedRecipe create(SimpleCookingSerializer serializer, + UnaryOperator builder, float cookingTimeModifier) { return register(consumer -> { boolean isOtherMod = compatDatagenOutput != null; - CookingRecipeBuilder b = builder - .apply(CookingRecipeBuilder.cooking(ingredient.get(), isOtherMod ? Items.DIRT : result.get(), + SimpleCookingRecipeBuilder b = builder + .apply(SimpleCookingRecipeBuilder.cooking(ingredient.get(), isOtherMod ? Items.DIRT : result.get(), exp, (int) (cookingTime * cookingTimeModifier), serializer)); if (unlockedBy != null) b.unlockedBy("has_item", inventoryTrigger(unlockedBy.get())); @@ -1370,13 +1370,13 @@ public class StandardRecipeGen extends CreateRecipeProvider { super(p_i48262_1_); } - private static class ModdedCookingRecipeResult implements IFinishedRecipe { + private static class ModdedCookingRecipeResult implements FinishedRecipe { - private IFinishedRecipe wrapped; + private FinishedRecipe wrapped; private ResourceLocation outputOverride; private List conditions; - public ModdedCookingRecipeResult(IFinishedRecipe wrapped, ResourceLocation outputOverride, + public ModdedCookingRecipeResult(FinishedRecipe wrapped, ResourceLocation outputOverride, List conditions) { this.wrapped = wrapped; this.outputOverride = outputOverride; @@ -1389,7 +1389,7 @@ public class StandardRecipeGen extends CreateRecipeProvider { } @Override - public IRecipeSerializer getType() { + public RecipeSerializer getType() { return wrapped.getType(); } 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 54acfecce..15b74e25d 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 @@ -15,15 +15,15 @@ import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.content.palettes.AllPaletteBlocks; import com.tterrag.registrate.util.entry.ItemEntry; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.data.DataGenerator; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.Ingredient; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.tags.ItemTags; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.Tags; public class WashingRecipeGen extends ProcessingRecipeGen { @@ -90,7 +90,7 @@ public class WashingRecipeGen extends ProcessingRecipeGen { return create(() -> block, b -> b.output(result)); } - public GeneratedRecipe crushedOre(ItemEntry crushed, Supplier nugget) { + public GeneratedRecipe crushedOre(ItemEntry crushed, Supplier nugget) { return create(crushed::get, b -> b.output(nugget.get(), 10) .output(.5f, nugget.get(), 5)); } 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 744b45325..7c34823c6 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java @@ -13,17 +13,17 @@ import com.simibubi.create.content.contraptions.processing.EmptyingByBasin; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.util.Hand; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.TagParser; +import net.minecraft.world.InteractionHand; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.ForgeFlowingFluid; @@ -96,11 +96,11 @@ public class FluidHelper { } public static FluidStack deserializeFluidStack(JsonObject json) { - ResourceLocation id = new ResourceLocation(JSONUtils.getAsString(json, "fluid")); + ResourceLocation id = new ResourceLocation(GsonHelper.getAsString(json, "fluid")); Fluid fluid = ForgeRegistries.FLUIDS.getValue(id); if (fluid == null) throw new JsonSyntaxException("Unknown fluid '" + id + "'"); - int amount = JSONUtils.getAsInt(json, "amount"); + int amount = GsonHelper.getAsInt(json, "amount"); FluidStack stack = new FluidStack(fluid, amount); if (!json.has("nbt")) @@ -108,8 +108,8 @@ public class FluidHelper { try { JsonElement element = json.get("nbt"); - stack.setTag(JsonToNBT.parseTag( - element.isJsonObject() ? Create.GSON.toJson(element) : JSONUtils.convertToString(element, "nbt"))); + stack.setTag(TagParser.parseTag( + element.isJsonObject() ? Create.GSON.toJson(element) : GsonHelper.convertToString(element, "nbt"))); } catch (CommandSyntaxException e) { e.printStackTrace(); @@ -118,7 +118,7 @@ public class FluidHelper { return stack; } - public static boolean tryEmptyItemIntoTE(World worldIn, PlayerEntity player, Hand handIn, ItemStack heldItem, + public static boolean tryEmptyItemIntoTE(Level worldIn, Player player, InteractionHand handIn, ItemStack heldItem, SmartTileEntity te) { if (!EmptyingByBasin.canItemBeEmptied(worldIn, heldItem)) return false; @@ -148,7 +148,7 @@ public class FluidHelper { return true; } - public static boolean tryFillItemFromTE(World world, PlayerEntity player, Hand handIn, ItemStack heldItem, + public static boolean tryFillItemFromTE(Level world, Player player, InteractionHand handIn, ItemStack heldItem, SmartTileEntity te) { if (!GenericItemFilling.canItemBeFilled(world, heldItem)) return false; 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 65e9d416a..ebac95770 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidIngredient.java @@ -15,14 +15,14 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; -import net.minecraft.fluid.FlowingFluid; -import net.minecraft.fluid.Fluid; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; import net.minecraft.tags.FluidTags; -import net.minecraft.tags.ITag; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.tags.Tag; +import net.minecraft.util.GsonHelper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fluids.FluidStack; public abstract class FluidIngredient implements Predicate { @@ -31,7 +31,7 @@ public abstract class FluidIngredient implements Predicate { public List matchingFluidStacks; - public static FluidIngredient fromTag(ITag.INamedTag tag, int amount) { + public static FluidIngredient fromTag(Tag.Named tag, int amount) { FluidTagIngredient ingredient = new FluidTagIngredient(); ingredient.tag = tag; ingredient.amountRequired = amount; @@ -60,9 +60,9 @@ public abstract class FluidIngredient implements Predicate { protected abstract boolean testInternal(FluidStack t); - protected abstract void readInternal(PacketBuffer buffer); + protected abstract void readInternal(FriendlyByteBuf buffer); - protected abstract void writeInternal(PacketBuffer buffer); + protected abstract void writeInternal(FriendlyByteBuf buffer); protected abstract void readInternal(JsonObject json); @@ -87,13 +87,13 @@ public abstract class FluidIngredient implements Predicate { return testInternal(t); } - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBoolean(this instanceof FluidTagIngredient); buffer.writeVarInt(amountRequired); writeInternal(buffer); } - public static FluidIngredient read(PacketBuffer buffer) { + public static FluidIngredient read(FriendlyByteBuf buffer) { boolean isTagIngredient = buffer.readBoolean(); FluidIngredient ingredient = isTagIngredient ? new FluidTagIngredient() : new FluidStackIngredient(); ingredient.amountRequired = buffer.readVarInt(); @@ -131,17 +131,17 @@ public abstract class FluidIngredient implements Predicate { if (!json.has("amount")) throw new JsonSyntaxException("Fluid ingredient has to define an amount"); - ingredient.amountRequired = JSONUtils.getAsInt(json, "amount"); + ingredient.amountRequired = GsonHelper.getAsInt(json, "amount"); return ingredient; } public static class FluidStackIngredient extends FluidIngredient { protected Fluid fluid; - protected CompoundNBT tagToMatch; + protected CompoundTag tagToMatch; public FluidStackIngredient() { - tagToMatch = new CompoundNBT(); + tagToMatch = new CompoundTag(); } void fixFlowing() { @@ -156,20 +156,20 @@ public abstract class FluidIngredient implements Predicate { return false; if (tagToMatch.isEmpty()) return true; - CompoundNBT tag = t.getOrCreateTag(); + CompoundTag tag = t.getOrCreateTag(); return tag.copy() .merge(tagToMatch) .equals(tag); } @Override - protected void readInternal(PacketBuffer buffer) { + protected void readInternal(FriendlyByteBuf buffer) { fluid = buffer.readRegistryId(); tagToMatch = buffer.readNbt(); } @Override - protected void writeInternal(PacketBuffer buffer) { + protected void writeInternal(FriendlyByteBuf buffer) { buffer.writeRegistryId(fluid); buffer.writeNbt(tagToMatch); } @@ -198,7 +198,7 @@ public abstract class FluidIngredient implements Predicate { public static class FluidTagIngredient extends FluidIngredient { - protected ITag.INamedTag tag; + protected Tag.Named tag; @Override protected boolean testInternal(FluidStack t) { @@ -212,7 +212,7 @@ public abstract class FluidIngredient implements Predicate { } @Override - protected void readInternal(PacketBuffer buffer) { + protected void readInternal(FriendlyByteBuf buffer) { int size = buffer.readVarInt(); matchingFluidStacks = new ArrayList<>(size); for (int i = 0; i < size; i++) @@ -220,7 +220,7 @@ public abstract class FluidIngredient implements Predicate { } @Override - protected void writeInternal(PacketBuffer buffer) { + protected void writeInternal(FriendlyByteBuf buffer) { // Tag has to be resolved on the server before sending List matchingFluidStacks = getMatchingFluidStacks(); buffer.writeVarInt(matchingFluidStacks.size()); @@ -230,8 +230,8 @@ public abstract class FluidIngredient implements Predicate { @Override protected void readInternal(JsonObject json) { - ResourceLocation id = new ResourceLocation(JSONUtils.getAsString(json, "fluidTag")); - Optional> optionalINamedTag = FluidTags.getWrappers() + ResourceLocation id = new ResourceLocation(GsonHelper.getAsString(json, "fluidTag")); + Optional> optionalINamedTag = FluidTags.getWrappers() .stream() .filter(fluidINamedTag -> fluidINamedTag.getName() .equals(id)) 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 7fae09669..c95367d33 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java @@ -3,27 +3,27 @@ package com.simibubi.create.foundation.fluid; import java.util.function.Function; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.matrix.MatrixStack.Entry; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.PoseStack.Pose; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.fluid.Fluid; -import net.minecraft.inventory.container.PlayerContainer; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidAttributes; @@ -32,21 +32,21 @@ import net.minecraftforge.fluids.FluidStack; @OnlyIn(Dist.CLIENT) public class FluidRenderer { - public static IVertexBuilder getFluidBuilder(IRenderTypeBuffer buffer) { + public static VertexConsumer getFluidBuilder(MultiBufferSource buffer) { return buffer.getBuffer(RenderTypes.getFluid()); } public static void renderFluidStream(FluidStack fluidStack, Direction direction, float radius, float progress, - boolean inbound, IRenderTypeBuffer buffer, MatrixStack ms, int light) { + boolean inbound, MultiBufferSource buffer, PoseStack ms, int light) { renderFluidStream(fluidStack, direction, radius, progress, inbound, getFluidBuilder(buffer), ms, light); } public static void renderFluidStream(FluidStack fluidStack, Direction direction, float radius, float progress, - boolean inbound, IVertexBuilder builder, MatrixStack ms, int light) { + boolean inbound, VertexConsumer builder, PoseStack ms, int light) { Fluid fluid = fluidStack.getFluid(); FluidAttributes fluidAttributes = fluid.getAttributes(); Function spriteAtlas = Minecraft.getInstance() - .getTextureAtlas(PlayerContainer.BLOCK_ATLAS); + .getTextureAtlas(InventoryMenu.BLOCK_ATLAS); TextureAtlasSprite flowTexture = spriteAtlas.apply(fluidAttributes.getFlowingTexture(fluidStack)); TextureAtlasSprite stillTexture = spriteAtlas.apply(fluidAttributes.getStillTexture(fluidStack)); @@ -71,7 +71,7 @@ public class FluidRenderer { float hMax = (float) (radius); float y = inbound ? 0 : .5f; float yMin = y; - float yMax = y + MathHelper.clamp(progress * .5f - 1e-6f, 0, 1); + float yMax = y + Mth.clamp(progress * .5f - 1e-6f, 0, 1); for (int i = 0; i < 4; i++) { ms.pushPose(); @@ -89,16 +89,16 @@ public class FluidRenderer { } public static void renderTiledFluidBB(FluidStack fluidStack, float xMin, float yMin, float zMin, float xMax, - float yMax, float zMax, IRenderTypeBuffer buffer, MatrixStack ms, int light, boolean renderBottom) { + float yMax, float zMax, MultiBufferSource buffer, PoseStack ms, int light, boolean renderBottom) { renderTiledFluidBB(fluidStack, xMin, yMin, zMin, xMax, yMax, zMax, getFluidBuilder(buffer), ms, light, renderBottom); } public static void renderTiledFluidBB(FluidStack fluidStack, float xMin, float yMin, float zMin, float xMax, - float yMax, float zMax, IVertexBuilder builder, MatrixStack ms, int light, boolean renderBottom) { + float yMax, float zMax, VertexConsumer builder, PoseStack ms, int light, boolean renderBottom) { Fluid fluid = fluidStack.getFluid(); FluidAttributes fluidAttributes = fluid.getAttributes(); TextureAtlasSprite fluidTexture = Minecraft.getInstance() - .getTextureAtlas(PlayerContainer.BLOCK_ATLAS) + .getTextureAtlas(InventoryMenu.BLOCK_ATLAS) .apply(fluidAttributes.getStillTexture(fluidStack)); int color = fluidAttributes.getColor(fluidStack); @@ -106,7 +106,7 @@ public class FluidRenderer { int luminosity = Math.max(blockLightIn, fluidAttributes.getLuminosity(fluidStack)); light = (light & 0xF00000) | luminosity << 4; - Vector3d center = new Vector3d(xMin + (xMax - xMin) / 2, yMin + (yMax - yMin) / 2, zMin + (zMax - zMin) / 2); + Vec3 center = new Vec3(xMin + (xMax - xMin) / 2, yMin + (yMax - yMin) / 2, zMin + (zMax - zMin) / 2); MatrixTransformStack msr = MatrixTransformStack.of(ms); ms.pushPose(); if (fluidStack.getFluid() @@ -148,7 +148,7 @@ public class FluidRenderer { } private static void renderTiledVerticalFace(float y, Direction face, float xMin, float zMin, float xMax, float zMax, - IVertexBuilder builder, MatrixStack ms, int light, int color, TextureAtlasSprite texture) { + VertexConsumer builder, PoseStack ms, int light, int color, TextureAtlasSprite texture) { float x2 = 0; float z2 = 0; for (float x1 = xMin; x1 < xMax; x1 = x2) { @@ -170,7 +170,7 @@ public class FluidRenderer { } private static void renderTiledHorizontalFace(float h, Direction face, float hMin, float yMin, float hMax, - float yMax, IVertexBuilder builder, MatrixStack ms, int light, int color, TextureAtlasSprite texture) { + float yMax, VertexConsumer builder, PoseStack ms, int light, int color, TextureAtlasSprite texture) { boolean X = face.getAxis() == Axis.X; float h2 = 0; @@ -206,11 +206,11 @@ public class FluidRenderer { return f - ((int) f); } - private static void putVertex(IVertexBuilder builder, MatrixStack ms, float x, float y, float z, int color, float u, + private static void putVertex(VertexConsumer builder, PoseStack ms, float x, float y, float z, int color, float u, float v, Direction face, int light) { - Vector3i n = face.getNormal(); - Entry peek = ms.last(); + Vec3i n = face.getNormal(); + Pose peek = ms.last(); int ff = 0xff; int a = color >> 24 & ff; int r = color >> 16 & ff; 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 acc765909..101af50d5 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiContainerScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiContainerScreen.java @@ -9,36 +9,36 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.screen.inventory.ContainerScreen; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.util.InputMappings; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.components.AbstractWidget; +import com.mojang.blaze3d.vertex.BufferBuilder; +import net.minecraft.client.renderer.Rect2i; +import com.mojang.blaze3d.platform.Lighting; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) @ParametersAreNonnullByDefault -public abstract class AbstractSimiContainerScreen extends ContainerScreen { +public abstract class AbstractSimiContainerScreen extends AbstractContainerScreen { - protected List widgets; + protected List widgets; protected int windowXOffset; protected int windowYOffset; - public AbstractSimiContainerScreen(T container, PlayerInventory inv, ITextComponent title) { + public AbstractSimiContainerScreen(T container, Inventory inv, Component title) { super(container, inv, title); widgets = new ArrayList<>(); } @@ -61,19 +61,19 @@ public abstract class AbstractSimiContainerScreen extends C } @Override - protected void renderLabels(MatrixStack p_230451_1_, int p_230451_2_, int p_230451_3_) { + protected void renderLabels(PoseStack 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 } @Override - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { partialTicks = Minecraft.getInstance() .getFrameTime(); renderBackground(matrixStack); renderWindow(matrixStack, mouseX, mouseY, partialTicks); - for (Widget widget : widgets) + for (AbstractWidget widget : widgets) widget.render(matrixStack, mouseX, mouseY, partialTicks); super.render(matrixStack, mouseX, mouseY, partialTicks); @@ -81,7 +81,7 @@ public abstract class AbstractSimiContainerScreen extends C RenderSystem.enableAlphaTest(); RenderSystem.enableBlend(); RenderSystem.disableRescaleNormal(); - RenderHelper.turnOff(); + Lighting.turnOff(); RenderSystem.disableLighting(); RenderSystem.disableDepthTest(); renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks); @@ -90,7 +90,7 @@ public abstract class AbstractSimiContainerScreen extends C @Override public boolean mouseClicked(double x, double y, int button) { boolean result = false; - for (Widget widget : widgets) { + for (AbstractWidget widget : widgets) { if (widget.mouseClicked(x, y, button)) result = true; } @@ -99,7 +99,7 @@ public abstract class AbstractSimiContainerScreen extends C @Override public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) { - for (Widget widget : widgets) { + for (AbstractWidget widget : widgets) { if (widget.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_)) return true; } @@ -107,7 +107,7 @@ public abstract class AbstractSimiContainerScreen extends C if (super.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_)) return true; - InputMappings.Input mouseKey = InputMappings.getKey(code, p_keyPressed_2_); + InputConstants.Key mouseKey = InputConstants.getKey(code, p_keyPressed_2_); if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { this.onClose(); return true; @@ -117,7 +117,7 @@ public abstract class AbstractSimiContainerScreen extends C @Override public boolean charTyped(char character, int code) { - for (Widget widget : widgets) { + for (AbstractWidget widget : widgets) { if (widget.charTyped(character, code)) return true; } @@ -126,7 +126,7 @@ public abstract class AbstractSimiContainerScreen extends C @Override public boolean mouseScrolled(double mouseX, double mouseY, double delta) { - for (Widget widget : widgets) { + for (AbstractWidget widget : widgets) { if (widget.mouseScrolled(mouseX, mouseY, delta)) return true; } @@ -136,22 +136,22 @@ public abstract class AbstractSimiContainerScreen extends C @Override public boolean mouseReleased(double x, double y, int button) { boolean result = false; - for (Widget widget : widgets) { + for (AbstractWidget widget : widgets) { if (widget.mouseReleased(x, y, button)) result = true; } return result | super.mouseReleased(x, y, button); } - protected abstract void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks); + protected abstract void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks); @Override - protected void renderBg(MatrixStack p_230450_1_, float p_230450_2_, int p_230450_3_, int p_230450_4_) { + protected void renderBg(PoseStack 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) { + protected void renderWindowForeground(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { renderTooltip(matrixStack, mouseX, mouseY); - for (Widget widget : widgets) { + for (AbstractWidget widget : widgets) { if (!widget.isHovered()) continue; @@ -192,7 +192,7 @@ public abstract class AbstractSimiContainerScreen extends C return (width - textureWidth) / 2; } - public void renderPlayerInventory(MatrixStack ms, int x, int y) { + public void renderPlayerInventory(PoseStack ms, int x, int y) { AllGuiTextures.PLAYER_INVENTORY.draw(ms, this, x, y); font.draw(ms, inventory.getDisplayName(), x + 8, y + 6, 0x404040); } @@ -204,13 +204,13 @@ public abstract class AbstractSimiContainerScreen extends C * * @return the space that the gui takes up besides the normal rectangle defined by {@link ContainerScreen}. */ - public List getExtraAreas() { + public List getExtraAreas() { return Collections.emptyList(); } // Not up to date with ItemRenderer @Deprecated - protected void renderItemOverlayIntoGUI(MatrixStack matrixStack, FontRenderer fr, ItemStack stack, int xPosition, + protected void renderItemOverlayIntoGUI(PoseStack matrixStack, Font fr, ItemStack stack, int xPosition, int yPosition, @Nullable String text, int textColor) { if (!stack.isEmpty()) { if (stack.getItem() @@ -220,7 +220,7 @@ public abstract class AbstractSimiContainerScreen extends C RenderSystem.disableTexture(); RenderSystem.disableAlphaTest(); RenderSystem.disableBlend(); - Tessellator tessellator = Tessellator.getInstance(); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuilder(); double health = stack.getItem() .getDurabilityForDisplay(stack); @@ -266,7 +266,7 @@ public abstract class AbstractSimiContainerScreen extends C @Deprecated private void draw(BufferBuilder renderer, int x, int y, int width, int height, int red, int green, int blue, int alpha) { - renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + renderer.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION_COLOR); renderer.vertex((double) (x + 0), (double) (y + 0), 0.0D) .color(red, green, blue, alpha) .endVertex(); @@ -279,18 +279,18 @@ public abstract class AbstractSimiContainerScreen extends C renderer.vertex((double) (x + width), (double) (y + 0), 0.0D) .color(red, green, blue, alpha) .endVertex(); - Tessellator.getInstance() + Tesselator.getInstance() .end(); } @Deprecated - protected void debugWindowArea(MatrixStack matrixStack) { + protected void debugWindowArea(PoseStack matrixStack) { fill(matrixStack, leftPos + imageWidth, topPos + imageHeight, leftPos, topPos, 0xD3D3D3D3); } @Deprecated - protected void debugExtraAreas(MatrixStack matrixStack) { - for (Rectangle2d area : getExtraAreas()) { + protected void debugExtraAreas(PoseStack matrixStack) { + for (Rect2i area : getExtraAreas()) { fill(matrixStack, area.getX() + area.getWidth(), area.getY() + area.getHeight(), area.getX(), area.getY(), 0xd3d3d3d3); } } 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 84689cf0b..dbf202293 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java @@ -3,15 +3,15 @@ package com.simibubi.create.foundation.gui; import java.util.ArrayList; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.client.util.InputMappings; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.components.AbstractWidget; +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -21,15 +21,15 @@ public abstract class AbstractSimiScreen extends Screen { protected int windowWidth, windowHeight; protected int windowXOffset, windowYOffset; protected int guiLeft, guiTop; - protected List widgets; + protected List widgets; - protected AbstractSimiScreen(ITextComponent title) { + protected AbstractSimiScreen(Component title) { super(title); widgets = new ArrayList<>(); } protected AbstractSimiScreen() { - this(new StringTextComponent("")); + this(new TextComponent("")); } protected void setWindowSize(int width, int height) { @@ -59,7 +59,7 @@ public abstract class AbstractSimiScreen extends Screen { } @Override - public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { partialTicks = partialTicks == 10 ? 0 : Minecraft.getInstance() .getFrameTime(); @@ -70,7 +70,7 @@ public abstract class AbstractSimiScreen extends Screen { renderWindowBackground(ms, mouseX, mouseY, partialTicks); renderWindow(ms, mouseX, mouseY, partialTicks); - for (Widget widget : widgets) + for (AbstractWidget widget : widgets) widget.render(ms, mouseX, mouseY, partialTicks); renderWindowForeground(ms, mouseX, mouseY, partialTicks); @@ -85,14 +85,14 @@ public abstract class AbstractSimiScreen extends Screen { protected void endFrame() { } - protected void renderWindowBackground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowBackground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { renderBackground(ms); } @Override public boolean mouseClicked(double x, double y, int button) { boolean result = false; - for (Widget widget : widgets) + for (AbstractWidget widget : widgets) if (widget.mouseClicked(x, y, button)) result = true; @@ -104,14 +104,14 @@ public abstract class AbstractSimiScreen extends Screen { @Override public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) { - for (Widget widget : widgets) + for (AbstractWidget widget : widgets) if (widget.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_)) return true; if (super.keyPressed(code, p_keyPressed_2_, p_keyPressed_3_)) return true; - InputMappings.Input mouseKey = InputMappings.getKey(code, p_keyPressed_2_); + InputConstants.Key mouseKey = InputConstants.getKey(code, p_keyPressed_2_); if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) { this.onClose(); return true; @@ -121,7 +121,7 @@ public abstract class AbstractSimiScreen extends Screen { @Override public boolean charTyped(char character, int code) { - for (Widget widget : widgets) { + for (AbstractWidget widget : widgets) { if (widget.charTyped(character, code)) return true; } @@ -130,7 +130,7 @@ public abstract class AbstractSimiScreen extends Screen { @Override public boolean mouseScrolled(double mouseX, double mouseY, double delta) { - for (Widget widget : widgets) { + for (AbstractWidget widget : widgets) { if (widget.mouseScrolled(mouseX, mouseY, delta)) return true; } @@ -140,7 +140,7 @@ public abstract class AbstractSimiScreen extends Screen { @Override public boolean mouseReleased(double x, double y, int button) { boolean result = false; - for (Widget widget : widgets) { + for (AbstractWidget widget : widgets) { if (widget.mouseReleased(x, y, button)) result = true; } @@ -157,10 +157,10 @@ public abstract class AbstractSimiScreen extends Screen { return false; } - protected abstract void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks); + protected abstract void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks); - protected void renderWindowForeground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - for (Widget widget : widgets) { + protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { + for (AbstractWidget widget : widgets) { if (!widget.isHovered()) continue; @@ -175,11 +175,11 @@ public abstract class AbstractSimiScreen extends Screen { } @Deprecated - protected void debugWindowArea(MatrixStack matrixStack) { + protected void debugWindowArea(PoseStack matrixStack) { fill(matrixStack, guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3); } - public List getWidgets() { + public List getWidgets() { return widgets; } 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 67b52074c..58699bed2 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java @@ -1,12 +1,12 @@ package com.simibubi.create.foundation.gui; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.Color; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -152,12 +152,12 @@ public enum AllGuiTextures implements IScreenRenderable { @Override @OnlyIn(Dist.CLIENT) - public void draw(MatrixStack ms, AbstractGui screen, int x, int y) { + public void draw(PoseStack ms, GuiComponent screen, int x, int y) { bind(); screen.blit(ms, x, y, startX, startY, width, height); } - public void draw(MatrixStack ms, int x, int y, Color c) { + public void draw(PoseStack ms, int x, int y, Color c) { bind(); UIRenderHelper.drawColoredTexture(ms, c, x, y, startX, startY, width, height); } 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 6a07a5f57..cb5755296 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java @@ -1,17 +1,17 @@ package com.simibubi.create.foundation.gui; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.matrix.MatrixStack.Entry; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.PoseStack.Pose; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.Color; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -169,25 +169,25 @@ public class AllIcons implements IScreenRenderable { @Override @OnlyIn(Dist.CLIENT) - public void draw(MatrixStack matrixStack, AbstractGui screen, int x, int y) { + public void draw(PoseStack matrixStack, GuiComponent screen, int x, int y) { bind(); 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.textSeeThrough(ICON_ATLAS)); + public void draw(PoseStack ms, MultiBufferSource buffer, int color) { + VertexConsumer 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.last(); - Vector3d rgb = Color.vectorFromRGB(color); + Pose peek = ms.last(); + Vec3 rgb = Color.vectorFromRGB(color); - Vector3d vec4 = new Vector3d(1, 1, 0); - Vector3d vec3 = new Vector3d(0, 1, 0); - Vector3d vec2 = new Vector3d(0, 0, 0); - Vector3d vec1 = new Vector3d(1, 0, 0); + Vec3 vec4 = new Vec3(1, 1, 0); + Vec3 vec3 = new Vec3(0, 1, 0); + Vec3 vec2 = new Vec3(0, 0, 0); + Vec3 vec1 = new Vec3(1, 0, 0); float u1 = (iconX + 16) / sheetSize; float u2 = iconX / sheetSize; @@ -206,7 +206,7 @@ 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) { + private void vertex(Pose peek, VertexConsumer builder, int j, int k, Vec3 rgb, Vec3 vec, float u, float v) { builder.vertex(peek.pose(), (float) vec.x, (float) vec.y, (float) vec.z) .color((float) rgb.x, (float) rgb.y, (float) rgb.z, 1) .uv(u, v) 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 61c46d231..1b2af4cd5 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/BoxElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/BoxElement.java @@ -2,15 +2,15 @@ package com.simibubi.create.foundation.gui; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Couple; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.math.vector.Matrix4f; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.math.Matrix4f; public class BoxElement extends RenderElement { @@ -65,14 +65,14 @@ public class BoxElement extends RenderElement { } @Override - public void render(MatrixStack ms) { + public void render(PoseStack ms) { renderBox(ms); } //total box width = 1 * 2 (outer border) + 1 * 2 (inner color border) + 2 * borderOffset + width //defaults to 2 + 2 + 4 + 16 = 24px //batch everything together to save a bunch of gl calls over GuiUtils - protected void renderBox(MatrixStack ms) { + protected void renderBox(PoseStack ms) { /* * _____________ * _|_____________|_ @@ -97,10 +97,10 @@ public class BoxElement extends RenderElement { Color c1 = background.copy().scaleAlpha(alpha); Color c2 = borderTop.copy().scaleAlpha(alpha); Color c3 = borderBot.copy().scaleAlpha(alpha); - Tessellator tessellator = Tessellator.getInstance(); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder b = tessellator.getBuilder(); Matrix4f model = ms.last().pose(); - b.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + b.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION_COLOR); //outer top b.vertex(model, x - f - 1 , y - f - 2 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex(); b.vertex(model, x - f - 1 , y - f - 1 , z).color(c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha()).endVertex(); @@ -127,7 +127,7 @@ public class BoxElement extends RenderElement { 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.end(); - b.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + b.begin(GL11.GL_QUADS, DefaultVertexFormat.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(); b.vertex(model, x - f - 1 , y - f , z).color(c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha()).endVertex(); 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 24b961302..d762dd614 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java @@ -4,24 +4,24 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.network.NetworkEvent.Context; public class ClearContainerPacket extends SimplePacketBase { public ClearContainerPacket() {} - public ClearContainerPacket(PacketBuffer buffer) {} + public ClearContainerPacket(FriendlyByteBuf buffer) {} @Override - public void write(PacketBuffer buffer) {} + public void write(FriendlyByteBuf buffer) {} @Override public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity player = context.get() + ServerPlayer player = context.get() .getSender(); if (player == null) return; 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 6382dce01..f042e264e 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/CombinedStencilElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/CombinedStencilElement.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.gui; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; public class CombinedStencilElement extends StencilElement { @@ -43,7 +43,7 @@ public class CombinedStencilElement extends StencilElement { } @Override - protected void renderStencil(MatrixStack ms) { + protected void renderStencil(PoseStack ms) { ms.pushPose(); element1.transform(ms); element1.withBounds(width, height); @@ -57,7 +57,7 @@ public class CombinedStencilElement extends StencilElement { } @Override - protected void renderElement(MatrixStack ms) { + protected void renderElement(PoseStack ms) { if (mode.rendersFirst()) element1.withBounds(width, height).renderElement(ms); 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 849c1ff51..43bc17ba7 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java @@ -12,22 +12,22 @@ import org.lwjgl.opengl.GL30; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.widgets.BoxWidget; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.client.shader.FramebufferConstants; -import net.minecraft.util.text.ITextProperties; -import net.minecraft.util.text.Style; +import net.minecraft.client.gui.screens.Screen; +import com.mojang.blaze3d.pipeline.RenderTarget; +import com.mojang.blaze3d.platform.GlConst; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.network.chat.Style; public class ConfirmationScreen extends AbstractSimiScreen { private Screen source; private Consumer action = _success -> { }; - private List text = new ArrayList<>(); + private List text = new ArrayList<>(); private boolean centered = false; private int x; private int y; @@ -60,12 +60,12 @@ public class ConfirmationScreen extends AbstractSimiScreen { return this; } - public ConfirmationScreen addText(ITextProperties text) { + public ConfirmationScreen addText(FormattedText text) { this.text.add(text); return this; } - public ConfirmationScreen withText(ITextProperties text) { + public ConfirmationScreen withText(FormattedText text) { return clearText().addText(text); } @@ -110,7 +110,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { protected void init() { widgets.clear(); - ArrayList copy = new ArrayList<>(text); + ArrayList copy = new ArrayList<>(text); text.clear(); copy.forEach(t -> text.addAll(minecraft.font.getSplitter().splitLines(t, 300, Style.EMPTY))); @@ -178,7 +178,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { textBackground.render(ms); int offset = minecraft.font.lineHeight + 1; @@ -187,7 +187,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { ms.pushPose(); ms.translate(0, 0, 200); - for (ITextProperties line : text) { + for (FormattedText line : text) { lineY = lineY + offset; if (line == null) continue; @@ -202,7 +202,7 @@ public class ConfirmationScreen extends AbstractSimiScreen { } @Override - protected void renderWindowBackground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowBackground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { endFrame(); source.render(ms, 0, 0, 10); // zero mouse coords to prevent further tooltips @@ -214,15 +214,15 @@ public class ConfirmationScreen extends AbstractSimiScreen { @Override protected void prepareFrame() { - Framebuffer thisBuffer = UIRenderHelper.framebuffer; - Framebuffer mainBuffer = Minecraft.getInstance().getMainRenderTarget(); + RenderTarget thisBuffer = UIRenderHelper.framebuffer; + RenderTarget mainBuffer = Minecraft.getInstance().getMainRenderTarget(); GlCompat functions = Backend.getInstance().compat; 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.GL_FRAMEBUFFER, thisBuffer.frameBufferId); + functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, thisBuffer.frameBufferId); GL11.glClear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT); } @@ -230,15 +230,15 @@ public class ConfirmationScreen extends AbstractSimiScreen { @Override protected void endFrame() { - Framebuffer thisBuffer = UIRenderHelper.framebuffer; - Framebuffer mainBuffer = Minecraft.getInstance().getMainRenderTarget(); + RenderTarget thisBuffer = UIRenderHelper.framebuffer; + RenderTarget mainBuffer = Minecraft.getInstance().getMainRenderTarget(); GlCompat functions = Backend.getInstance().compat; 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.GL_FRAMEBUFFER, mainBuffer.frameBufferId); + functions.fbo.bindFramebuffer(GlConst.GL_FRAMEBUFFER, mainBuffer.frameBufferId); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/gui/ContainerBase.java b/src/main/java/com/simibubi/create/foundation/gui/ContainerBase.java index fff1ae447..02968c9d6 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ContainerBase.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ContainerBase.java @@ -1,31 +1,31 @@ package com.simibubi.create.foundation.gui; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.Slot; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public abstract class ContainerBase extends Container { +public abstract class ContainerBase extends AbstractContainerMenu { - public PlayerEntity player; - public PlayerInventory playerInventory; + public Player player; + public Inventory playerInventory; public T contentHolder; - protected ContainerBase(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + protected ContainerBase(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { super(type, id); init(inv, createOnClient(extraData)); } - protected ContainerBase(ContainerType type, int id, PlayerInventory inv, T contentHolder) { + protected ContainerBase(MenuType type, int id, Inventory inv, T contentHolder) { super(type, id); init(inv, contentHolder); } - protected void init(PlayerInventory inv, T contentHolderIn) { + protected void init(Inventory inv, T contentHolderIn) { player = inv.player; playerInventory = inv; contentHolder = contentHolderIn; @@ -35,7 +35,7 @@ public abstract class ContainerBase extends Container { } @OnlyIn(Dist.CLIENT) - protected abstract T createOnClient(PacketBuffer extraData); + protected abstract T createOnClient(FriendlyByteBuf extraData); protected abstract void addSlots(); @@ -52,13 +52,13 @@ public abstract class ContainerBase extends Container { } @Override - public void removed(PlayerEntity playerIn) { + public void removed(Player playerIn) { super.removed(playerIn); saveData(contentHolder); } @Override - public boolean stillValid(PlayerEntity player) { + public boolean stillValid(Player player) { if (contentHolder == null) return false; if (contentHolder instanceof IInteractionChecker) 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 392dc76fa..cc407fdeb 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java +++ b/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java @@ -3,8 +3,8 @@ package com.simibubi.create.foundation.gui; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3f; +import com.mojang.math.Matrix4f; +import com.mojang.math.Vector3f; public class CustomLightingSettings implements ILightingSettings { diff --git a/src/main/java/com/simibubi/create/foundation/gui/DelegatedStencilElement.java b/src/main/java/com/simibubi/create/foundation/gui/DelegatedStencilElement.java index 8093c9e7e..5b87d81ff 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/DelegatedStencilElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/DelegatedStencilElement.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.gui; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.Color; public class DelegatedStencilElement extends StencilElement { @@ -34,18 +34,18 @@ public class DelegatedStencilElement extends StencilElement { } @Override - protected void renderStencil(MatrixStack ms) { + protected void renderStencil(PoseStack ms) { stencil.render(ms, width, height, 1); } @Override - protected void renderElement(MatrixStack ms) { + protected void renderElement(PoseStack ms) { element.render(ms, width, height, alpha); } @FunctionalInterface public interface ElementRenderer { - void render(MatrixStack ms, int width, int height, float alpha); + void render(PoseStack ms, int width, int height, float alpha); } } 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 7b7f1903c..e140a57df 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GhostItemContainer.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GhostItemContainer.java @@ -1,12 +1,12 @@ package com.simibubi.create.foundation.gui; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.ClickType; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; @@ -14,11 +14,11 @@ public abstract class GhostItemContainer extends ContainerBase implements public ItemStackHandler ghostInventory; - protected GhostItemContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + protected GhostItemContainer(MenuType type, int id, Inventory inv, FriendlyByteBuf extraData) { super(type, id, inv, extraData); } - protected GhostItemContainer(ContainerType type, int id, PlayerInventory inv, T contentHolder) { + protected GhostItemContainer(MenuType type, int id, Inventory inv, T contentHolder) { super(type, id, inv, contentHolder); } @@ -50,7 +50,7 @@ public abstract class GhostItemContainer extends ContainerBase implements } @Override - public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { + public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) { ItemStack held = playerInventory.getCarried(); if (slotId < 36) return super.clicked(slotId, dragType, clickTypeIn, player); @@ -83,7 +83,7 @@ public abstract class GhostItemContainer extends ContainerBase implements } @Override - public ItemStack quickMoveStack(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(Player playerIn, int index) { if (index < 36) { ItemStack stackToInsert = playerInventory.getItem(index); for (int i = 0; i < ghostInventory.getSlots(); i++) { 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 3245586b6..76ee8d466 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GhostItemSubmitPacket.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GhostItemSubmitPacket.java @@ -4,9 +4,9 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.networking.SimplePacketBase; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.network.NetworkEvent.Context; public class GhostItemSubmitPacket extends SimplePacketBase { @@ -19,13 +19,13 @@ public class GhostItemSubmitPacket extends SimplePacketBase { this.slot = slot; } - public GhostItemSubmitPacket(PacketBuffer buffer) { + public GhostItemSubmitPacket(FriendlyByteBuf buffer) { item = buffer.readItem(); slot = buffer.readInt(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeItem(item); buffer.writeInt(slot); } @@ -34,7 +34,7 @@ public class GhostItemSubmitPacket extends SimplePacketBase { public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity player = context.get() + ServerPlayer player = context.get() .getSender(); if (player == null) return; 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 2f2563f97..868aff75f 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java @@ -4,39 +4,39 @@ import javax.annotation.Nullable; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.util.VirtualEmptyModelData; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager.DestFactor; import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FireBlock; -import net.minecraft.block.FlowingFluidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FireBlock; +import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Atlases; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Sheets; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; +import com.mojang.blaze3d.platform.Lighting; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.fluid.Fluid; -import net.minecraft.inventory.container.PlayerContainer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ItemLike; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; import net.minecraftforge.fluids.FluidStack; public class GuiGameElement { @@ -45,7 +45,7 @@ public class GuiGameElement { return new GuiItemRenderBuilder(stack); } - public static GuiRenderBuilder of(IItemProvider itemProvider) { + public static GuiRenderBuilder of(ItemLike itemProvider) { return new GuiItemRenderBuilder(itemProvider); } @@ -60,7 +60,7 @@ public class GuiGameElement { public static GuiRenderBuilder of(Fluid fluid) { return new GuiBlockStateRenderBuilder(fluid.defaultFluidState() .createLegacyBlock() - .setValue(FlowingFluidBlock.LEVEL, 0)); + .setValue(LiquidBlock.LEVEL, 0)); } public static abstract class GuiRenderBuilder extends RenderElement { @@ -68,7 +68,7 @@ public class GuiGameElement { protected double xRot, yRot, zRot; protected double scale = 1; protected int color = 0xFFFFFF; - protected Vector3d rotationOffset = Vector3d.ZERO; + protected Vec3 rotationOffset = Vec3.ZERO; protected ILightingSettings customLighting = null; public GuiRenderBuilder atLocal(double x, double y, double z) { @@ -100,7 +100,7 @@ public class GuiGameElement { return this; } - public GuiRenderBuilder withRotationOffset(Vector3d offset) { + public GuiRenderBuilder withRotationOffset(Vec3 offset) { this.rotationOffset = offset; return this; } @@ -110,7 +110,7 @@ public class GuiGameElement { return this; } - protected void prepareMatrix(MatrixStack matrixStack) { + protected void prepareMatrix(PoseStack matrixStack) { matrixStack.pushPose(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.alphaFunc(516, 0.1F); @@ -122,7 +122,7 @@ public class GuiGameElement { prepareLighting(matrixStack); } - protected void transformMatrix(MatrixStack matrixStack) { + protected void transformMatrix(PoseStack matrixStack) { matrixStack.translate(x, y, z); matrixStack.scale((float) scale, (float) scale, (float) scale); matrixStack.translate(xLocal, yLocal, zLocal); @@ -134,65 +134,65 @@ public class GuiGameElement { matrixStack.translate(-rotationOffset.x, -rotationOffset.y, -rotationOffset.z); } - protected void cleanUpMatrix(MatrixStack matrixStack) { + protected void cleanUpMatrix(PoseStack matrixStack) { matrixStack.popPose(); RenderSystem.disableRescaleNormal(); RenderSystem.disableAlphaTest(); cleanUpLighting(matrixStack); } - protected void prepareLighting(MatrixStack matrixStack) { + protected void prepareLighting(PoseStack matrixStack) { if (customLighting != null) { customLighting.applyLighting(); } else { - RenderHelper.setupFor3DItems(); + Lighting.setupFor3DItems(); } } - protected void cleanUpLighting(MatrixStack matrixStack) { + protected void cleanUpLighting(PoseStack matrixStack) { if (customLighting != null) { - RenderHelper.setupFor3DItems(); + Lighting.setupFor3DItems(); } } } private static class GuiBlockModelRenderBuilder extends GuiRenderBuilder { - protected IBakedModel blockModel; + protected BakedModel blockModel; protected BlockState blockState; - public GuiBlockModelRenderBuilder(IBakedModel blockmodel, @Nullable BlockState blockState) { + public GuiBlockModelRenderBuilder(BakedModel blockmodel, @Nullable BlockState blockState) { this.blockState = blockState == null ? Blocks.AIR.defaultBlockState() : blockState; this.blockModel = blockmodel; } @Override - public void render(MatrixStack matrixStack) { + public void render(PoseStack matrixStack) { prepareMatrix(matrixStack); Minecraft mc = Minecraft.getInstance(); - BlockRendererDispatcher blockRenderer = mc.getBlockRenderer(); - IRenderTypeBuffer.Impl buffer = mc.renderBuffers() + BlockRenderDispatcher blockRenderer = mc.getBlockRenderer(); + MultiBufferSource.BufferSource buffer = mc.renderBuffers() .bufferSource(); - RenderType renderType = blockState.getBlock() == Blocks.AIR ? Atlases.translucentCullBlockSheet() - : RenderTypeLookup.getRenderType(blockState, true); - IVertexBuilder vb = buffer.getBuffer(renderType); + RenderType renderType = blockState.getBlock() == Blocks.AIR ? Sheets.translucentCullBlockSheet() + : ItemBlockRenderTypes.getRenderType(blockState, true); + VertexConsumer vb = buffer.getBuffer(renderType); transformMatrix(matrixStack); mc.getTextureManager() - .bind(PlayerContainer.BLOCK_ATLAS); + .bind(InventoryMenu.BLOCK_ATLAS); renderModel(blockRenderer, buffer, renderType, vb, matrixStack); cleanUpMatrix(matrixStack); } - protected void renderModel(BlockRendererDispatcher blockRenderer, IRenderTypeBuffer.Impl buffer, - RenderType renderType, IVertexBuilder vb, MatrixStack ms) { + protected void renderModel(BlockRenderDispatcher blockRenderer, MultiBufferSource.BufferSource buffer, + RenderType renderType, VertexConsumer vb, PoseStack ms) { int color = Minecraft.getInstance() .getBlockColors() .getColor(blockState, null, null, 0); - Vector3d rgb = Color.vectorFromRGB(color == -1 ? this.color : color); + Vec3 rgb = Color.vectorFromRGB(color == -1 ? this.color : color); blockRenderer.getModelRenderer() .renderModel(ms.last(), vb, blockState, blockModel, (float) rgb.x, (float) rgb.y, (float) rgb.z, 0xF000F0, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); @@ -210,14 +210,14 @@ public class GuiGameElement { } @Override - protected void renderModel(BlockRendererDispatcher blockRenderer, IRenderTypeBuffer.Impl buffer, - RenderType renderType, IVertexBuilder vb, MatrixStack ms) { + protected void renderModel(BlockRenderDispatcher blockRenderer, MultiBufferSource.BufferSource buffer, + RenderType renderType, VertexConsumer vb, PoseStack ms) { if (blockState.getBlock() instanceof FireBlock) { - RenderHelper.setupForFlatItems(); + Lighting.setupForFlatItems(); blockRenderer.renderBlock(blockState, ms, buffer, 0xF000F0, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); buffer.endBatch(); - RenderHelper.setupFor3DItems(); + Lighting.setupFor3DItems(); return; } @@ -249,25 +249,25 @@ public class GuiGameElement { this.stack = stack; } - public GuiItemRenderBuilder(IItemProvider provider) { + public GuiItemRenderBuilder(ItemLike provider) { this(new ItemStack(provider)); } @Override - public void render(MatrixStack matrixStack) { + public void render(PoseStack matrixStack) { prepareMatrix(matrixStack); transformMatrix(matrixStack); renderItemIntoGUI(matrixStack, stack, customLighting == null); cleanUpMatrix(matrixStack); } - public static void renderItemIntoGUI(MatrixStack matrixStack, ItemStack stack, boolean useDefaultLighting) { + public static void renderItemIntoGUI(PoseStack matrixStack, ItemStack stack, boolean useDefaultLighting) { ItemRenderer renderer = Minecraft.getInstance().getItemRenderer(); - IBakedModel bakedModel = renderer.getModel(stack, null, null); + BakedModel bakedModel = renderer.getModel(stack, null, null); matrixStack.pushPose(); - renderer.textureManager.bind(AtlasTexture.LOCATION_BLOCKS); - renderer.textureManager.getTexture(AtlasTexture.LOCATION_BLOCKS).setFilter(false, false); + renderer.textureManager.bind(TextureAtlas.LOCATION_BLOCKS); + renderer.textureManager.getTexture(TextureAtlas.LOCATION_BLOCKS).setFilter(false, false); RenderSystem.enableRescaleNormal(); RenderSystem.enableAlphaTest(); RenderSystem.enableCull(); @@ -278,20 +278,20 @@ public class GuiGameElement { 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().renderBuffers().bufferSource(); + MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource(); boolean flatLighting = !bakedModel.usesBlockLight(); if (useDefaultLighting) { if (flatLighting) { - RenderHelper.setupForFlatItems(); + Lighting.setupForFlatItems(); } } - renderer.render(stack, ItemCameraTransforms.TransformType.GUI, false, matrixStack, buffer, 0xF000F0, OverlayTexture.NO_OVERLAY, bakedModel); + renderer.render(stack, ItemTransforms.TransformType.GUI, false, matrixStack, buffer, 0xF000F0, OverlayTexture.NO_OVERLAY, bakedModel); buffer.endBatch(); RenderSystem.enableDepthTest(); if (useDefaultLighting) { if (flatLighting) { - RenderHelper.setupFor3DItems(); + Lighting.setupFor3DItems(); } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/IInteractionChecker.java b/src/main/java/com/simibubi/create/foundation/gui/IInteractionChecker.java index 9aca72ac4..1c7c2498f 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/IInteractionChecker.java +++ b/src/main/java/com/simibubi/create/foundation/gui/IInteractionChecker.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.gui; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.Player; public interface IInteractionChecker { - boolean canPlayerUse(PlayerEntity player); + boolean canPlayerUse(Player player); } 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 4248e4de2..045d6c97e 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ILightingSettings.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ILightingSettings.java @@ -1,12 +1,12 @@ package com.simibubi.create.foundation.gui; -import net.minecraft.client.renderer.RenderHelper; +import com.mojang.blaze3d.platform.Lighting; public interface ILightingSettings { void applyLighting(); - static final ILightingSettings DEFAULT_3D = () -> RenderHelper.setupFor3DItems(); - static final ILightingSettings DEFAULT_FLAT = () -> RenderHelper.setupForFlatItems(); + static final ILightingSettings DEFAULT_3D = () -> Lighting.setupFor3DItems(); + static final ILightingSettings DEFAULT_FLAT = () -> Lighting.setupForFlatItems(); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/IScreenRenderable.java b/src/main/java/com/simibubi/create/foundation/gui/IScreenRenderable.java index ea8a9977c..2ed4f9707 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/IScreenRenderable.java +++ b/src/main/java/com/simibubi/create/foundation/gui/IScreenRenderable.java @@ -1,19 +1,19 @@ package com.simibubi.create.foundation.gui; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.CreateClient; -import net.minecraft.client.gui.AbstractGui; +import net.minecraft.client.gui.GuiComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public interface IScreenRenderable { @OnlyIn(Dist.CLIENT) - void draw(MatrixStack ms, AbstractGui screen, int x, int y); + void draw(PoseStack ms, GuiComponent screen, int x, int y); @OnlyIn(Dist.CLIENT) - default void draw(MatrixStack ms, int x, int y) { + default void draw(PoseStack ms, int x, int y) { draw(ms, CreateClient.EMPTY_SCREEN, x, y); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/RenderElement.java b/src/main/java/com/simibubi/create/foundation/gui/RenderElement.java index dcc6a3a0d..55b0eb1c1 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/RenderElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/RenderElement.java @@ -1,12 +1,12 @@ package com.simibubi.create.foundation.gui; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.gui.AbstractGui; +import net.minecraft.client.gui.GuiComponent; public abstract class RenderElement implements IScreenRenderable { - public static RenderElement EMPTY = new RenderElement() {@Override public void render(MatrixStack ms) {}}; + public static RenderElement EMPTY = new RenderElement() {@Override public void render(PoseStack ms) {}}; public static RenderElement of(IScreenRenderable renderable) { return new SimpleRenderElement(renderable); @@ -64,15 +64,15 @@ public abstract class RenderElement implements IScreenRenderable { return z; } - public abstract void render(MatrixStack ms); + public abstract void render(PoseStack ms); @Override - public void draw(MatrixStack ms, AbstractGui screen, int x, int y) { + public void draw(PoseStack ms, GuiComponent screen, int x, int y) { this.at(x, y).render(ms); } @Override - public void draw(MatrixStack ms, int x, int y) { + public void draw(PoseStack ms, int x, int y) { this.at(x, y).render(ms); } @@ -85,7 +85,7 @@ public abstract class RenderElement implements IScreenRenderable { } @Override - public void render(MatrixStack ms) { + public void render(PoseStack ms) { renderable.draw(ms, (int) x, (int) y); } } 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 d28fa2eb4..cacfa89b9 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ScreenOpener.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ScreenOpener.java @@ -12,7 +12,7 @@ import com.simibubi.create.foundation.ponder.NavigatableSimiScreen; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screens.Screen; public class ScreenOpener { 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 6bbdeae75..bb7cd6393 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.gui; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; @@ -10,7 +10,7 @@ import net.minecraft.client.Minecraft; public abstract class StencilElement extends RenderElement { @Override - public void render(MatrixStack ms) { + public void render(PoseStack ms) { ms.pushPose(); transform(ms); prepareStencil(ms); @@ -21,15 +21,15 @@ public abstract class StencilElement extends RenderElement { ms.popPose(); } - protected abstract void renderStencil(MatrixStack ms); + protected abstract void renderStencil(PoseStack ms); - protected abstract void renderElement(MatrixStack ms); + protected abstract void renderElement(PoseStack ms); - protected void transform(MatrixStack ms) { + protected void transform(PoseStack ms) { ms.translate(x, y, z); } - protected void prepareStencil(MatrixStack ms) { + protected void prepareStencil(PoseStack ms) { GL11.glDisable(GL11.GL_STENCIL_TEST); RenderSystem.stencilMask(~0); RenderSystem.clear(GL11.GL_STENCIL_BUFFER_BIT, Minecraft.ON_OSX); @@ -39,13 +39,13 @@ public abstract class StencilElement extends RenderElement { RenderSystem.stencilFunc(GL11.GL_NEVER, 1, 0xFF); } - protected void prepareElement(MatrixStack ms) { + protected void prepareElement(PoseStack ms) { GL11.glEnable(GL11.GL_STENCIL_TEST); RenderSystem.stencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); RenderSystem.stencilFunc(GL11.GL_EQUAL, 1, 0xFF); } - protected void cleanUp(MatrixStack ms) { + protected void cleanUp(PoseStack ms) { GL11.glDisable(GL11.GL_STENCIL_TEST); } 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 9ede69764..add2c71bc 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/TextStencilElement.java @@ -1,40 +1,40 @@ package com.simibubi.create.foundation.gui; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.TextComponent; public class TextStencilElement extends DelegatedStencilElement { - protected FontRenderer font; - protected IFormattableTextComponent component; + protected Font font; + protected MutableComponent component; protected boolean centerVertically = false; protected boolean centerHorizontally = false; - public TextStencilElement(FontRenderer font) { + public TextStencilElement(Font font) { super(); this.font = font; height = 10; } - public TextStencilElement(FontRenderer font, String text) { + public TextStencilElement(Font font, String text) { this(font); - component = new StringTextComponent(text); + component = new TextComponent(text); } - public TextStencilElement(FontRenderer font, IFormattableTextComponent component) { + public TextStencilElement(Font font, MutableComponent component) { this(font); this.component = component; } public TextStencilElement withText(String text) { - component = new StringTextComponent(text); + component = new TextComponent(text); return this; } - public TextStencilElement withText(IFormattableTextComponent component) { + public TextStencilElement withText(MutableComponent component) { this.component = component; return this; } @@ -46,7 +46,7 @@ public class TextStencilElement extends DelegatedStencilElement { } @Override - protected void renderStencil(MatrixStack ms) { + protected void renderStencil(PoseStack ms) { float x = 0, y = 0; if (centerHorizontally) @@ -59,7 +59,7 @@ public class TextStencilElement extends DelegatedStencilElement { } @Override - protected void renderElement(MatrixStack ms) { + protected void renderElement(PoseStack ms) { float x = 0, y = 0; if (centerHorizontally) x = width / 2f - font.width(component) / 2f; @@ -73,7 +73,7 @@ public class TextStencilElement extends DelegatedStencilElement { ms.popPose(); } - public IFormattableTextComponent getComponent() { + public MutableComponent getComponent() { return component; } } 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 4748a8742..6c023190c 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java @@ -3,17 +3,17 @@ package com.simibubi.create.foundation.gui; import java.util.List; import java.util.function.Consumer; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllKeys; import com.simibubi.create.content.schematics.client.tools.Tools; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class ToolSelectionScreen extends Screen { @@ -32,7 +32,7 @@ public class ToolSelectionScreen extends Screen { protected int h; public ToolSelectionScreen(List tools, Consumer callback) { - super(new StringTextComponent("Tool Selection")); + super(new TextComponent("Tool Selection")); this.minecraft = Minecraft.getInstance(); this.tools = tools; this.callback = callback; @@ -58,9 +58,9 @@ public class ToolSelectionScreen extends Screen { selection = (selection + tools.size()) % tools.size(); } - private void draw(MatrixStack matrixStack, float partialTicks) { + private void draw(PoseStack matrixStack, float partialTicks) { Minecraft mc = Minecraft.getInstance(); - MainWindow mainWindow = mc.getWindow(); + Window mainWindow = mc.getWindow(); if (!initialized) init(mc, mainWindow.getGuiScaledWidth(), mainWindow.getGuiScaledHeight()); @@ -80,7 +80,7 @@ public class ToolSelectionScreen extends Screen { blit(matrixStack, x - 15, y, gray.startX, gray.startY, w, h, gray.width, gray.height); float toolTipAlpha = yOffset / 10; - List toolTip = tools.get(selection) + List toolTip = tools.get(selection) .getDescription(); int stringAlphaComponent = ((int) (toolTipAlpha * 0xFF)) << 24; @@ -147,7 +147,7 @@ public class ToolSelectionScreen extends Screen { yOffset *= .9f; } - public void renderPassive(MatrixStack matrixStack, float partialTicks) { + public void renderPassive(PoseStack matrixStack, float partialTicks) { draw(matrixStack, partialTicks); } 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 fa35d9228..8d89638f2 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java @@ -4,20 +4,20 @@ import javax.annotation.Nonnull; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Couple; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldVertexBufferUploader; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3f; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.BufferUploader; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.pipeline.RenderTarget; +import com.mojang.math.Matrix4f; +import com.mojang.math.Vector3f; import net.minecraftforge.fml.client.gui.GuiUtils; public class UIRenderHelper { @@ -26,23 +26,23 @@ public class UIRenderHelper { * An FBO that has a stencil buffer for use wherever stencil are necessary. Forcing the main FBO to have a stencil * buffer will cause GL error spam when using fabulous graphics. */ - public static Framebuffer framebuffer; + public static RenderTarget framebuffer; - public static void updateWindowSize(MainWindow mainWindow) { + public static void updateWindowSize(Window mainWindow) { if (framebuffer != null) framebuffer.resize(mainWindow.getWidth(), mainWindow.getHeight(), Minecraft.ON_OSX); } public static void init() { RenderSystem.recordRenderCall(() -> { - MainWindow mainWindow = Minecraft.getInstance() + Window mainWindow = Minecraft.getInstance() .getWindow(); framebuffer = createFramebuffer(mainWindow); }); } - private static Framebuffer createFramebuffer(MainWindow mainWindow) { - Framebuffer framebuffer = new Framebuffer(mainWindow.getWidth(), mainWindow.getHeight(), true, + private static RenderTarget createFramebuffer(Window mainWindow) { + RenderTarget framebuffer = new RenderTarget(mainWindow.getWidth(), mainWindow.getHeight(), true, Minecraft.ON_OSX); framebuffer.setClearColor(0, 0, 0, 0); framebuffer.enableStencil(); @@ -50,7 +50,7 @@ public class UIRenderHelper { } public static void drawFramebuffer(float alpha) { - MainWindow window = Minecraft.getInstance() + Window window = Minecraft.getInstance() .getWindow(); float vx = (float) window.getGuiScaledWidth(); @@ -63,9 +63,9 @@ public class UIRenderHelper { framebuffer.bindRead(); - Tessellator tessellator = Tessellator.getInstance(); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuilder(); - bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX); + bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION_COLOR_TEX); 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(); @@ -76,12 +76,12 @@ public class UIRenderHelper { 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));} + public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length) {streak(ms, angle, x, y, breadth, length, Theme.i(Theme.Key.STREAK));} // angle in degrees; 0° -> fading to the right // x and y specify the middle point of the starting edge // breadth is the total width of the streak - public static void streak(MatrixStack ms, float angle, int x, int y, int breadth, int length, int color) { + public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length, int color) { int a1 = 0xa0 << 24; int a2 = 0x80 << 24; int a3 = 0x10 << 24; @@ -102,7 +102,7 @@ public class UIRenderHelper { ms.popPose(); } - public static void streak(MatrixStack ms, float angle, int x, int y, int breadth, int length, Color c) { + public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length, Color c) { Color color = c.copy().setImmutable(); int c1 = color.scaleAlpha(0.625f).getRGB(); int c2 = color.scaleAlpha(0.5f).getRGB(); @@ -118,7 +118,7 @@ public class UIRenderHelper { ms.popPose(); } - private static void streak(MatrixStack ms, int width, int height, int c1, int c2, int c3, int c4) { + private static void streak(PoseStack ms, int width, int height, int c1, int c2, int c3, int c4) { double split1 = .5; double split2 = .75; Matrix4f model = ms.last().pose(); @@ -132,21 +132,21 @@ public class UIRenderHelper { /** * @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color) */ - public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int breadth, int length, Couple c) { + public static void angledGradient(@Nonnull PoseStack ms, float angle, int x, int y, int breadth, int length, Couple c) { angledGradient(ms, angle, x, y, 0, breadth, length, c); } /** * @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color) */ - public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int z, int breadth, int length, Couple c) { + public static void angledGradient(@Nonnull PoseStack ms, float angle, int x, int y, int z, int breadth, int length, Couple c) { angledGradient(ms, angle, x, y, z, breadth, length, c.getFirst(), c.getSecond()); } /** * @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color) */ - public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int breadth, int length, Color color1, Color color2) { + public static void angledGradient(@Nonnull PoseStack ms, float angle, int x, int y, int breadth, int length, Color color1, Color color2) { angledGradient(ms, angle, x, y, 0, breadth, length, color1, color2); } @@ -158,7 +158,7 @@ public class UIRenderHelper { * @param color2 the color at the ending edge * @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, Color color1, Color color2) { + public static void angledGradient(@Nonnull PoseStack ms, float angle, int x, int y, int z, int breadth, int length, Color color1, Color color2) { ms.pushPose(); ms.translate(x, y, z); ms.mulPose(Vector3f.ZP.rotationDegrees(angle - 90)); @@ -170,10 +170,10 @@ public class UIRenderHelper { 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(), colors.getSecond());} + public static void breadcrumbArrow(PoseStack 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(), colors.getSecond());} // 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, Color startColor, Color endColor) { + public static void breadcrumbArrow(PoseStack matrixStack, int x, int y, int z, int width, int height, int indent, Color startColor, Color endColor) { matrixStack.pushPose(); matrixStack.translate(x - indent, y, z); @@ -182,7 +182,7 @@ public class UIRenderHelper { matrixStack.popPose(); } - private static void breadcrumbArrow(MatrixStack ms, int width, int height, int indent, Color c1, Color c2) { + private static void breadcrumbArrow(PoseStack ms, int width, int height, int indent, Color c1, Color c2) { /* * 0,0 x1,y1 ********************* x4,y4 ***** x7,y7 @@ -219,10 +219,10 @@ public class UIRenderHelper { RenderSystem.defaultBlendFunc(); RenderSystem.shadeModel(GL11.GL_SMOOTH); - Tessellator tessellator = Tessellator.getInstance(); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuilder(); Matrix4f model = ms.last().pose(); - bufferbuilder.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); + bufferbuilder.begin(GL11.GL_TRIANGLES, DefaultVertexFormat.POSITION_COLOR); bufferbuilder.vertex(model, x0, y0, 0).color(fc1.getRed(), fc1.getGreen(), fc1.getBlue(), fc1.getAlpha()).endVertex(); bufferbuilder.vertex(model, x1, y1, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex(); @@ -257,29 +257,29 @@ public class UIRenderHelper { } //just like AbstractGui#drawTexture, but with a color at every vertex - public static void drawColoredTexture(MatrixStack ms, Color c, int x, int y, int tex_left, int tex_top, int width, int height) { + public static void drawColoredTexture(PoseStack ms, Color c, int x, int y, int tex_left, int tex_top, int width, int height) { drawColoredTexture(ms, c, x, y, 0, (float) tex_left, (float) tex_top, width, height, 256, 256); } - public static void drawColoredTexture(MatrixStack ms, Color c, int x, int y, int z, float tex_left, float tex_top, int width, int height, int sheet_width, int sheet_height) { + public static void drawColoredTexture(PoseStack ms, Color c, int x, int y, int z, float tex_left, float tex_top, int width, int height, int sheet_width, int sheet_height) { drawColoredTexture(ms, c, x, x + width, y, y + height, z, width, height, tex_left, tex_top, sheet_width, sheet_height); } - 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) { + private static void drawColoredTexture(PoseStack 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.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().getBuilder(); - bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX); + BufferBuilder bufferbuilder = Tesselator.getInstance().getBuilder(); + bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormat.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.end(bufferbuilder); + BufferUploader.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 43c25db2a..1c29d0514 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 @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.gui.mainMenu; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; @@ -18,17 +18,17 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.gui.screen.ConfirmOpenLinkScreen; -import net.minecraft.client.gui.screen.MainMenuScreen; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.button.Button; -import net.minecraft.client.renderer.RenderSkybox; -import net.minecraft.client.renderer.RenderSkyboxCube; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.Util; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.gui.screens.ConfirmLinkScreen; +import net.minecraft.client.gui.screens.TitleScreen; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.renderer.PanoramaRenderer; +import net.minecraft.client.renderer.CubeMap; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.Util; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; public class CreateMainMenuScreen extends AbstractSimiScreen { @@ -36,37 +36,37 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { protected final Screen parent; protected boolean returnOnClose; - public static final RenderSkyboxCube PANORAMA_RESOURCES = - new RenderSkyboxCube(Create.asResource("textures/gui/title/background/panorama")); + public static final CubeMap PANORAMA_RESOURCES = + new CubeMap(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.CUBE_MAP); - public static RenderSkybox panorama = new RenderSkybox(PANORAMA_RESOURCES); + private PanoramaRenderer vanillaPanorama = new PanoramaRenderer(TitleScreen.CUBE_MAP); + public static PanoramaRenderer panorama = new PanoramaRenderer(PANORAMA_RESOURCES); private long firstRenderTime; private Button gettingStarted; public CreateMainMenuScreen(Screen parent) { this.parent = parent; returnOnClose = true; - if (parent instanceof MainMenuScreen) - vanillaPanorama = ObfuscationReflectionHelper.getPrivateValue(MainMenuScreen.class, (MainMenuScreen) parent, + if (parent instanceof TitleScreen) + vanillaPanorama = ObfuscationReflectionHelper.getPrivateValue(TitleScreen.class, (TitleScreen) parent, "field_209101_K"); } @Override - public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { if (firstRenderTime == 0L) this.firstRenderTime = Util.getMillis(); super.render(ms, mouseX, mouseY, partialTicks); } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { float f = (float) (Util.getMillis() - this.firstRenderTime) / 1000.0F; - float alpha = MathHelper.clamp(f, 0.0F, 1.0F); + float alpha = Mth.clamp(f, 0.0F, 1.0F); float elapsedPartials = minecraft.getDeltaFrameTime(); - if (parent instanceof MainMenuScreen) { + if (parent instanceof TitleScreen) { if (alpha < 1) vanillaPanorama.render(elapsedPartials, 1); panorama.render(elapsedPartials, alpha); @@ -113,9 +113,9 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { ms.pushPose(); ms.translate(0, 0, 200); - drawCenteredString(ms, font, new StringTextComponent(Create.NAME).withStyle(TextFormatting.BOLD) + drawCenteredString(ms, font, new TextComponent(Create.NAME).withStyle(ChatFormatting.BOLD) .append( - new StringTextComponent(" v" + Create.VERSION).withStyle(TextFormatting.BOLD, TextFormatting.WHITE)), + new TextComponent(" v" + Create.VERSION).withStyle(ChatFormatting.BOLD, ChatFormatting.WHITE)), width / 2, 89, 0xff_E4BB67); ms.popPose(); @@ -131,7 +131,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { private void addButtons() { buttons.clear(); - int yStart = height / 4 + (parent instanceof MainMenuScreen ? 40 : 40); + int yStart = height / 4 + (parent instanceof TitleScreen ? 40 : 40); int center = width / 2; int bHeight = 20; int bShortWidth = 98; @@ -144,7 +144,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { gettingStarted = new Button(center + 2, yStart + 48 + -16, bShortWidth, bHeight, Lang.translate("menu.ponder_index"), $ -> linkTo(new PonderTagIndexScreen())); - gettingStarted.active = !(parent instanceof MainMenuScreen); + gettingStarted.active = !(parent instanceof TitleScreen); addButton(gettingStarted); String projectLink = "https://www.curseforge.com/minecraft/mc-mods/create"; @@ -160,17 +160,17 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { } @Override - protected void renderWindowForeground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { super.renderWindowForeground(ms, mouseX, mouseY, partialTicks); buttons.forEach(w -> w.render(ms, mouseX, mouseY, partialTicks)); - if (parent instanceof MainMenuScreen) { + if (parent instanceof TitleScreen) { if (mouseX < gettingStarted.x || mouseX > gettingStarted.x + 98) return; if (mouseY < gettingStarted.y || mouseY > gettingStarted.y + 20) return; - renderComponentTooltip(ms, TooltipHelper.cutTextComponent(Lang.translate("menu.only_ingame"), TextFormatting.GRAY, - TextFormatting.GRAY), mouseX, mouseY); + renderComponentTooltip(ms, TooltipHelper.cutTextComponent(Lang.translate("menu.only_ingame"), ChatFormatting.GRAY, + ChatFormatting.GRAY), mouseX, mouseY); } } @@ -185,7 +185,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { private void linkTo(String url) { returnOnClose = false; - ScreenOpener.open(new ConfirmOpenLinkScreen((p_213069_2_) -> { + ScreenOpener.open(new ConfirmLinkScreen((p_213069_2_) -> { if (p_213069_2_) Util.getPlatform() .openUri(url); 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 48e73d983..7ef91160b 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 @@ -6,17 +6,17 @@ import java.util.function.BiConsumer; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; -public abstract class AbstractSimiWidget extends Widget { +public abstract class AbstractSimiWidget extends AbstractWidget { protected float z; protected boolean wasHovered = false; - protected List toolTip = new LinkedList<>(); + protected List toolTip = new LinkedList<>(); protected BiConsumer onClick = (_$, _$$) -> {}; protected AbstractSimiWidget() { @@ -28,7 +28,7 @@ public abstract class AbstractSimiWidget extends Widget { } protected AbstractSimiWidget(int x, int y, int width, int height) { - super(x, y, width, height, StringTextComponent.EMPTY); + super(x, y, width, height, TextComponent.EMPTY); } public T withCallback(BiConsumer cb) { @@ -47,14 +47,14 @@ public abstract class AbstractSimiWidget extends Widget { return (T) this; } - public List getToolTip() { + public List getToolTip() { return toolTip; } public void tick() {} @Override - public void render(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void render(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { if (visible) { isHovered = isMouseOver(mouseX, mouseY); beforeRender(ms, mouseX, mouseY, partialTicks); @@ -65,18 +65,18 @@ public abstract class AbstractSimiWidget extends Widget { } @Override - public void renderButton(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) {} + public void renderButton(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {} @Override protected boolean clicked(double mouseX, double mouseY) { return active && visible && isMouseOver(mouseX, mouseY); } - protected void beforeRender(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void beforeRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { ms.pushPose(); } - protected void afterRender(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void afterRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { ms.popPose(); } 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 6c9a844f5..980d55250 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 @@ -4,7 +4,7 @@ import java.util.function.Function; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.BoxElement; import com.simibubi.create.foundation.gui.DelegatedStencilElement; import com.simibubi.create.foundation.gui.Theme; @@ -99,7 +99,7 @@ public class BoxWidget extends ElementWidget { } @Override - protected void beforeRender(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void beforeRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { super.beforeRender(ms, mouseX, mouseY, partialTicks); if (isHovered != wasHovered) { @@ -122,7 +122,7 @@ public class BoxWidget extends ElementWidget { } @Override - public void renderButton(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void renderButton(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { float fadeValue = fade.getValue(partialTicks); if (fadeValue < .1f) return; 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 6bb91486d..09c63de85 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 @@ -5,7 +5,7 @@ import java.util.function.UnaryOperator; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.IScreenRenderable; import com.simibubi.create.foundation.gui.RenderElement; import com.simibubi.create.foundation.utility.animation.LerpedFloat; @@ -118,7 +118,7 @@ public class ElementWidget extends AbstractSimiWidget { } @Override - protected void beforeRender(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void beforeRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { super.beforeRender(ms, mouseX, mouseY, partialTicks); float fadeValue = fade.getValue(partialTicks); @@ -129,7 +129,7 @@ public class ElementWidget extends AbstractSimiWidget { } @Override - public void renderButton(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void renderButton(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { ms.pushPose(); ms.translate(x + paddingX, y + paddingY, z); float innerWidth = width - 2 * paddingX; 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 8209c907a..f7661b3dc 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 @@ -2,12 +2,12 @@ package com.simibubi.create.foundation.gui.widgets; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.AllIcons; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.network.chat.Component; public class IconButton extends AbstractSimiWidget { @@ -20,7 +20,7 @@ public class IconButton extends AbstractSimiWidget { } @Override - public void renderButton(@Nonnull MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + public void renderButton(@Nonnull PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { if (this.visible) { this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; @@ -47,7 +47,7 @@ public class IconButton extends AbstractSimiWidget { this.pressed = false; } - public void setToolTip(ITextComponent text) { + public void setToolTip(Component text) { toolTip.clear(); toolTip.add(text); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/Indicator.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/Indicator.java index 627d6b017..739e7a6f8 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/Indicator.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/Indicator.java @@ -3,10 +3,10 @@ package com.simibubi.create.foundation.gui.widgets; import javax.annotation.Nonnull; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.AllGuiTextures; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.network.chat.Component; public class Indicator extends AbstractSimiWidget { @@ -17,14 +17,14 @@ public class Indicator extends AbstractSimiWidget { public State state; - public Indicator(int x, int y, ITextComponent tooltip) { + public Indicator(int x, int y, Component tooltip) { super(x, y, AllGuiTextures.INDICATOR.width, AllGuiTextures.INDICATOR.height); this.toolTip = ImmutableList.of(tooltip); this.state = State.OFF; } @Override - public void render(@Nonnull MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks ) { + public void render(@Nonnull PoseStack matrixStack, int mouseX, int mouseY, float partialTicks ) { AllGuiTextures toDraw; switch(state) { case ON: toDraw = AllGuiTextures.INDICATOR_WHITE; break; diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/InterpolatedValue.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/InterpolatedValue.java index 65f459580..3f4c193ab 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/InterpolatedValue.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/InterpolatedValue.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.gui.widgets; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; public class InterpolatedValue { @@ -19,7 +19,7 @@ public class InterpolatedValue { } public float get(float partialTicks) { - return MathHelper.lerp(partialTicks, lastValue, value); + return Mth.lerp(partialTicks, lastValue, value); } public boolean settled() { 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 1fc0a881d..e9888e290 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 @@ -2,27 +2,27 @@ package com.simibubi.create.foundation.gui.widgets; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class Label extends AbstractSimiWidget { - public ITextComponent text; + public Component text; public String suffix; protected boolean hasShadow; protected int color; - protected FontRenderer font; + protected Font font; - public Label(int x, int y, ITextComponent text) { + public Label(int x, int y, Component text) { super(x, y, Minecraft.getInstance().font.width(text), 10); font = Minecraft.getInstance().font; - this.text = new StringTextComponent("Label"); + this.text = new TextComponent("Label"); color = 0xFFFFFF; hasShadow = false; suffix = ""; @@ -43,8 +43,8 @@ public class Label extends AbstractSimiWidget { return this; } - public void setTextAndTrim(ITextComponent newText, boolean trimFront, int maxWidthPx) { - FontRenderer fontRenderer = Minecraft.getInstance().font; + public void setTextAndTrim(Component newText, boolean trimFront, int maxWidthPx) { + Font fontRenderer = Minecraft.getInstance().font; if (fontRenderer.width(newText) <= maxWidthPx) { text = newText; @@ -62,8 +62,8 @@ 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.width(new StringTextComponent(sub).setStyle(newText.getStyle())) + trimWidth <= maxWidthPx) { - text = new StringTextComponent(trimFront ? trim + sub : sub + trim).setStyle(newText.getStyle()); + if (fontRenderer.width(new TextComponent(sub).setStyle(newText.getStyle())) + trimWidth <= maxWidthPx) { + text = new TextComponent(trimFront ? trim + sub : sub + trim).setStyle(newText.getStyle()); return; } } @@ -71,14 +71,14 @@ public class Label extends AbstractSimiWidget { } @Override - public void render(@Nonnull MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + public void render(@Nonnull PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { if (!visible) return; if (text == null || text.getString().isEmpty()) return; RenderSystem.color4f(1, 1, 1, 1); - IFormattableTextComponent copy = text.plainCopy(); + MutableComponent copy = text.plainCopy(); if (suffix != null && !suffix.isEmpty()) copy.append(suffix); 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 8329c530c..37d62fe1f 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 @@ -7,18 +7,18 @@ import com.simibubi.create.AllKeys; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; public class ScrollInput extends AbstractSimiWidget { protected Consumer onScroll; protected int state; - protected ITextComponent title = Lang.translate("gui.scrollInput.defaultTitle"); - protected final ITextComponent scrollToModify = Lang.translate("gui.scrollInput.scrollToModify"); - protected final ITextComponent shiftScrollsFaster = Lang.translate("gui.scrollInput.shiftScrollsFaster"); + protected Component title = Lang.translate("gui.scrollInput.defaultTitle"); + protected final Component scrollToModify = Lang.translate("gui.scrollInput.scrollToModify"); + protected final Component shiftScrollsFaster = Lang.translate("gui.scrollInput.shiftScrollsFaster"); protected Label displayLabel; protected int min, max; @@ -54,7 +54,7 @@ public class ScrollInput extends AbstractSimiWidget { return this; } - public ScrollInput titled(IFormattableTextComponent title) { + public ScrollInput titled(MutableComponent title) { this.title = title; updateTooltip(); return this; @@ -132,14 +132,14 @@ public class ScrollInput extends AbstractSimiWidget { } protected void writeToLabel() { - displayLabel.text = new StringTextComponent(String.valueOf(state)); + displayLabel.text = new TextComponent(String.valueOf(state)); } protected void updateTooltip() { toolTip.clear(); - 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)); + toolTip.add(title.plainCopy().withStyle(ChatFormatting.BLUE)); + toolTip.add(scrollToModify.plainCopy().withStyle(ChatFormatting.ITALIC, ChatFormatting.DARK_GRAY)); + toolTip.add(shiftScrollsFaster.plainCopy().withStyle(ChatFormatting.ITALIC, ChatFormatting.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 4fb8329b7..00edb6aa6 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 @@ -5,22 +5,22 @@ import java.util.List; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; public class SelectionScrollInput extends ScrollInput { - private final IFormattableTextComponent scrollToSelect = Lang.translate("gui.scrollInput.scrollToSelect"); - protected List options; + private final MutableComponent scrollToSelect = Lang.translate("gui.scrollInput.scrollToSelect"); + protected List options; public SelectionScrollInput(int xIn, int yIn, int widthIn, int heightIn) { super(xIn, yIn, widthIn, heightIn); options = new ArrayList<>(); } - public ScrollInput forOptions(List options) { + public ScrollInput forOptions(List options) { this.options = options; this.max = options.size(); updateTooltip(); @@ -40,7 +40,7 @@ public class SelectionScrollInput extends ScrollInput { @Override protected void updateTooltip() { toolTip.clear(); - toolTip.add(title.plainCopy().withStyle(TextFormatting.BLUE)); + toolTip.add(title.plainCopy().withStyle(ChatFormatting.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("> ...").withStyle(TextFormatting.GRAY)); + toolTip.add(new TextComponent("> ...").withStyle(ChatFormatting.GRAY)); if (this.max - 1 == max) max++; for (int i = min; i < max; i++) { if (i == state) - toolTip.add(StringTextComponent.EMPTY.plainCopy().append("-> ").append(options.get(i)).withStyle(TextFormatting.WHITE)); + toolTip.add(TextComponent.EMPTY.plainCopy().append("-> ").append(options.get(i)).withStyle(ChatFormatting.WHITE)); else - toolTip.add(StringTextComponent.EMPTY.plainCopy().append("> ").append(options.get(i)).withStyle(TextFormatting.GRAY)); + toolTip.add(TextComponent.EMPTY.plainCopy().append("> ").append(options.get(i)).withStyle(ChatFormatting.GRAY)); } if (max < this.max) - toolTip.add(new StringTextComponent("> ...").withStyle(TextFormatting.GRAY)); + toolTip.add(new TextComponent("> ...").withStyle(ChatFormatting.GRAY)); - toolTip.add(scrollToSelect.plainCopy().withStyle(TextFormatting.DARK_GRAY, TextFormatting.ITALIC)); + toolTip.add(scrollToSelect.plainCopy().withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.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 1b354c712..949a3c586 100644 --- a/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java +++ b/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java @@ -8,21 +8,21 @@ import com.simibubi.create.Create; import com.simibubi.create.content.AllSections; import com.tterrag.registrate.util.entry.RegistryEntry; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.NonNullList; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.NonNullList; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public abstract class CreateItemGroupBase extends ItemGroup { +public abstract class CreateItemGroupBase extends CreativeModeTab { public CreateItemGroupBase(String id) { super(getGroupCountSafe(), Create.ID + "." + id); @@ -50,14 +50,14 @@ public abstract class CreateItemGroupBase extends ItemGroup { public void addItems(NonNullList items, boolean specialItems) { Minecraft mc = Minecraft.getInstance(); ItemRenderer itemRenderer = mc.getItemRenderer(); - ClientWorld world = mc.level; + ClientLevel world = mc.level; for (RegistryEntry entry : getItems()) { Item item = entry.get(); if (item instanceof BlockItem) continue; ItemStack stack = new ItemStack(item); - IBakedModel model = itemRenderer.getModel(stack, world, null); + BakedModel model = itemRenderer.getModel(stack, world, null); if (model.isGui3d() != specialItems) continue; 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 899dcce8e..268895e08 100644 --- a/src/main/java/com/simibubi/create/foundation/item/HiddenIngredientItem.java +++ b/src/main/java/com/simibubi/create/foundation/item/HiddenIngredientItem.java @@ -1,9 +1,11 @@ package com.simibubi.create.foundation.item; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.NonNullList; + +import net.minecraft.world.item.Item.Properties; public class HiddenIngredientItem extends Item { @@ -12,8 +14,8 @@ public class HiddenIngredientItem extends Item { } @Override - public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { - if (p_150895_1_ != ItemGroup.TAB_SEARCH) + public void fillItemCategory(CreativeModeTab p_150895_1_, NonNullList p_150895_2_) { + if (p_150895_1_ != CreativeModeTab.TAB_SEARCH) return; super.fillItemCategory(p_150895_1_, p_150895_2_); } diff --git a/src/main/java/com/simibubi/create/foundation/item/IItemHandlerModifiableIntermediate.java b/src/main/java/com/simibubi/create/foundation/item/IItemHandlerModifiableIntermediate.java index e45744b0d..8b5545a48 100644 --- a/src/main/java/com/simibubi/create/foundation/item/IItemHandlerModifiableIntermediate.java +++ b/src/main/java/com/simibubi/create/foundation/item/IItemHandlerModifiableIntermediate.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; interface IItemHandlerModifiableIntermediate extends IItemHandlerModifiable { 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 2b8bac433..6080b84e1 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java @@ -3,19 +3,19 @@ package com.simibubi.create.foundation.item; import static com.simibubi.create.foundation.item.TooltipHelper.cutStringTextComponent; import static com.simibubi.create.foundation.item.TooltipHelper.cutTextComponent; import static net.minecraft.util.text.TextFormatting.AQUA; -import static net.minecraft.util.text.TextFormatting.BLUE; +import staticnet.minecraft.ChatFormattingg.BLUE; import static net.minecraft.util.text.TextFormatting.DARK_GRAY; -import static net.minecraft.util.text.TextFormatting.DARK_GREEN; +import staticnet.minecraft.ChatFormattingg.DARK_GREEN; import static net.minecraft.util.text.TextFormatting.DARK_PURPLE; -import static net.minecraft.util.text.TextFormatting.DARK_RED; +import staticnet.minecraft.ChatFormattingg.DARK_RED; import static net.minecraft.util.text.TextFormatting.GOLD; -import static net.minecraft.util.text.TextFormatting.GRAY; +import staticnet.minecraft.ChatFormattingg.GRAY; import static net.minecraft.util.text.TextFormatting.GREEN; -import static net.minecraft.util.text.TextFormatting.LIGHT_PURPLE; +import staticnet.minecraft.ChatFormattingg.LIGHT_PURPLE; import static net.minecraft.util.text.TextFormatting.RED; -import static net.minecraft.util.text.TextFormatting.STRIKETHROUGH; +import staticnet.minecraft.ChatFormattingg.STRIKETHROUGH; import static net.minecraft.util.text.TextFormatting.WHITE; -import static net.minecraft.util.text.TextFormatting.YELLOW; +import staticnet.minecraft.ChatFormattingg.YELLOW; import java.util.ArrayList; import java.util.Arrays; @@ -33,20 +33,20 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.CKinetics; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraft.util.text.TextFormatting; public class ItemDescription { public static final ItemDescription MISSING = new ItemDescription(null); - public static ITextComponent trim = - new StringTextComponent(" ").withStyle(WHITE, STRIKETHROUGH); + public static Component trim = + new TextComponent(" ").withStyle(WHITE, STRIKETHROUGH); public enum Palette { @@ -59,18 +59,18 @@ public class ItemDescription { ; - private Palette(TextFormatting primary, TextFormatting highlight) { + private Palette(ChatFormatting primary, ChatFormatting highlight) { color = primary; hColor = highlight; } - public TextFormatting color; - public TextFormatting hColor; + public ChatFormatting color; + public ChatFormatting hColor; } - private List lines; - private List linesOnShift; - private List linesOnCtrl; + private List lines; + private List linesOnShift; + private List linesOnCtrl; private Palette palette; public ItemDescription(Palette palette) { @@ -80,19 +80,19 @@ public class ItemDescription { linesOnCtrl = new ArrayList<>(); } - public ItemDescription withSummary(ITextComponent summary) { + public ItemDescription withSummary(Component summary) { addStrings(linesOnShift, cutTextComponent(summary, palette.color, palette.hColor)); return this; } - public static List getKineticStats(Block block) { - List list = new ArrayList<>(); + public static List getKineticStats(Block block) { + List list = new ArrayList<>(); CKinetics config = AllConfigs.SERVER.kinetics; - ITextComponent rpmUnit = Lang.translate("generic.unit.rpm"); + Component rpmUnit = Lang.translate("generic.unit.rpm"); boolean hasGoggles = - AllItems.GOGGLES.isIn(Minecraft.getInstance().player.getItemBySlot(EquipmentSlotType.HEAD)); + AllItems.GOGGLES.isIn(Minecraft.getInstance().player.getItemBySlot(EquipmentSlot.HEAD)); SpeedLevel minimumRequiredSpeedLevel; boolean showStressImpact; @@ -109,11 +109,11 @@ public class ItemDescription { boolean hasStressCapacity = StressImpact.isEnabled() && BlockStressValues.hasCapacity(block); if (hasSpeedRequirement) { - List speedLevels = + List speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high"); int index = minimumRequiredSpeedLevel.ordinal(); - IFormattableTextComponent level = - new StringTextComponent(makeProgressBar(3, index)).withStyle(minimumRequiredSpeedLevel.getTextColor()); + MutableComponent level = + new TextComponent(makeProgressBar(3, index)).withStyle(minimumRequiredSpeedLevel.getTextColor()); if (hasGoggles) level.append(String.valueOf(minimumRequiredSpeedLevel.getSpeedValue())) @@ -128,13 +128,13 @@ public class ItemDescription { } if (hasStressImpact) { - List stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high"); + List stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high"); double impact = BlockStressValues.getImpact(block); StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH : (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW); int index = impactId.ordinal(); - IFormattableTextComponent level = - new StringTextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor()); + MutableComponent level = + new TextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor()); if (hasGoggles) level.append(impact + "x ") @@ -148,14 +148,14 @@ public class ItemDescription { } if (hasStressCapacity) { - List stressCapacityLevels = + List stressCapacityLevels = Lang.translatedOptions("tooltip.capacityProvided", "low", "medium", "high"); double capacity = BlockStressValues.getCapacity(block); StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.LOW : (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH); int index = StressImpact.values().length - 2 - impactId.ordinal(); - IFormattableTextComponent level = - new StringTextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor()); + MutableComponent level = + new TextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor()); if (hasGoggles) level.append(capacity + "x ") @@ -171,10 +171,10 @@ public class ItemDescription { .withStyle(GRAY)); list.add(level); - IFormattableTextComponent genSpeed = generatorSpeed(block, rpmUnit); + MutableComponent genSpeed = generatorSpeed(block, rpmUnit); if (!genSpeed.getString() .isEmpty()) - list.add(new StringTextComponent(" ").append(genSpeed) + list.add(new TextComponent(" ").append(genSpeed) .withStyle(DARK_GRAY)); } @@ -194,13 +194,13 @@ public class ItemDescription { } public ItemDescription withBehaviour(String condition, String behaviour) { - add(linesOnShift, new StringTextComponent(condition).withStyle(GRAY)); + add(linesOnShift, new TextComponent(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).withStyle(GRAY)); + add(linesOnCtrl, new TextComponent(condition).withStyle(GRAY)); addStrings(linesOnCtrl, cutStringTextComponent(action, palette.color, palette.hColor, 1)); return this; } @@ -212,37 +212,37 @@ public class ItemDescription { if (hasDescription || hasControls) { String[] holdDesc = Lang.translate("tooltip.holdForDescription", "$").getString().split("\\$"); String[] holdCtrl = Lang.translate("tooltip.holdForControls", "$").getString().split("\\$"); - IFormattableTextComponent keyShift = Lang.translate("tooltip.keyShift"); - IFormattableTextComponent keyCtrl = Lang.translate("tooltip.keyCtrl"); - for (List list : Arrays.asList(lines, linesOnShift, linesOnCtrl)) { + MutableComponent keyShift = Lang.translate("tooltip.keyShift"); + MutableComponent keyCtrl = Lang.translate("tooltip.keyCtrl"); + for (List list : Arrays.asList(lines, linesOnShift, linesOnCtrl)) { boolean shift = list == linesOnShift; boolean ctrl = list == linesOnCtrl; if (holdDesc.length != 2 || holdCtrl.length != 2) { - list.add(0, new StringTextComponent("Invalid lang formatting!")); + list.add(0, new TextComponent("Invalid lang formatting!")); continue; } if (hasControls) { - IFormattableTextComponent tabBuilder = new StringTextComponent(""); - tabBuilder.append(new StringTextComponent(holdCtrl[0]).withStyle(DARK_GRAY)); + MutableComponent tabBuilder = new TextComponent(""); + tabBuilder.append(new TextComponent(holdCtrl[0]).withStyle(DARK_GRAY)); tabBuilder.append(keyCtrl.plainCopy() .withStyle(ctrl ? WHITE : GRAY)); - tabBuilder.append(new StringTextComponent(holdCtrl[1]).withStyle(DARK_GRAY)); + tabBuilder.append(new TextComponent(holdCtrl[1]).withStyle(DARK_GRAY)); list.add(0, tabBuilder); } if (hasDescription) { - IFormattableTextComponent tabBuilder = new StringTextComponent(""); - tabBuilder.append(new StringTextComponent(holdDesc[0]).withStyle(DARK_GRAY)); + MutableComponent tabBuilder = new TextComponent(""); + tabBuilder.append(new TextComponent(holdDesc[0]).withStyle(DARK_GRAY)); tabBuilder.append(keyShift.plainCopy() .withStyle(shift ? WHITE : GRAY)); - tabBuilder.append(new StringTextComponent(holdDesc[1]).withStyle(DARK_GRAY)); + tabBuilder.append(new TextComponent(holdDesc[1]).withStyle(DARK_GRAY)); list.add(0, tabBuilder); } if (shift || ctrl) - list.add(hasDescription && hasControls ? 2 : 1, new StringTextComponent("")); + list.add(hasDescription && hasControls ? 2 : 1, new TextComponent("")); } } @@ -258,15 +258,15 @@ public class ItemDescription { return palette.hColor + s + palette.color; } - public static void addStrings(List infoList, List textLines) { + public static void addStrings(List infoList, List textLines) { textLines.forEach(s -> add(infoList, s)); } - public static void add(List infoList, List textLines) { + public static void add(List infoList, List textLines) { infoList.addAll(textLines); } - public static void add(List infoList, ITextComponent line) { + public static void add(List infoList, Component line) { infoList.add(line); } @@ -274,7 +274,7 @@ public class ItemDescription { return palette; } - public List addInformation(List tooltip) { + public List addInformation(List tooltip) { if (Screen.hasShiftDown()) { tooltip.addAll(linesOnShift); return tooltip; @@ -289,19 +289,19 @@ public class ItemDescription { return tooltip; } - public List getLines() { + public List getLines() { return lines; } - public List getLinesOnCtrl() { + public List getLinesOnCtrl() { return linesOnCtrl; } - public List getLinesOnShift() { + public List getLinesOnShift() { return linesOnShift; } - private static IFormattableTextComponent generatorSpeed(Block block, ITextComponent unitRPM) { + private static MutableComponent generatorSpeed(Block block, Component unitRPM) { String value = ""; if (block instanceof WaterWheelBlock) { @@ -320,7 +320,7 @@ public class ItemDescription { } return !value.equals("") ? Lang.translate("tooltip.generationSpeed", value, unitRPM) - : StringTextComponent.EMPTY.plainCopy(); + : TextComponent.EMPTY.plainCopy(); } } diff --git a/src/main/java/com/simibubi/create/foundation/item/ItemHandlerWrapper.java b/src/main/java/com/simibubi/create/foundation/item/ItemHandlerWrapper.java index 2b2c6b4a0..923cf01f4 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemHandlerWrapper.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemHandlerWrapper.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; public class ItemHandlerWrapper implements IItemHandlerModifiable { 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 fdcdbb801..6c9ff1cec 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemHelper.java @@ -12,21 +12,21 @@ import org.apache.commons.lang3.mutable.MutableInt; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.inventory.InventoryHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.world.Containers; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.core.NonNullList; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; public class ItemHelper { - public static void dropContents(World world, BlockPos pos, IItemHandler inv) { + public static void dropContents(Level world, BlockPos pos, IItemHandler inv) { for (int slot = 0; slot < inv.getSlots(); slot++) - InventoryHelper.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), inv.getStackInSlot(slot)); + Containers.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), inv.getStackInSlot(slot)); } public static List multipliedOutput(ItemStack in, ItemStack out) { @@ -90,7 +90,7 @@ public class ItemHelper { return 0; f = f / totalSlots; - return MathHelper.floor(f * 14.0F) + (i > 0 ? 1 : 0); + return Mth.floor(f * 14.0F) + (i > 0 ? 1 : 0); } public static List> condenseIngredients(NonNullList recipeIngredients) { 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 f8ab9b2f7..7b394d747 100644 --- a/src/main/java/com/simibubi/create/foundation/item/SmartInventory.java +++ b/src/main/java/com/simibubi/create/foundation/item/SmartInventory.java @@ -6,14 +6,14 @@ import javax.annotation.Nonnull; import com.simibubi.create.foundation.tileEntity.SyncedTileEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.wrapper.RecipeWrapper; public class SmartInventory extends RecipeWrapper - implements IItemHandlerModifiableIntermediate, INBTSerializable { + implements IItemHandlerModifiableIntermediate, INBTSerializable { protected boolean extractionAllowed; protected boolean insertionAllowed; @@ -114,12 +114,12 @@ public class SmartInventory extends RecipeWrapper } @Override - public CompoundNBT serializeNBT() { + public CompoundTag serializeNBT() { return getInv().serializeNBT(); } @Override - public void deserializeNBT(CompoundNBT nbt) { + public void deserializeNBT(CompoundTag nbt) { getInv().deserializeNBT(nbt); } 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 0b10e3196..5b0b9699a 100644 --- a/src/main/java/com/simibubi/create/foundation/item/TagDependentIngredientItem.java +++ b/src/main/java/com/simibubi/create/foundation/item/TagDependentIngredientItem.java @@ -1,12 +1,14 @@ package com.simibubi.create.foundation.item; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.tags.ITag; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.tags.Tag; import net.minecraft.tags.ItemTags; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; + +import net.minecraft.world.item.Item.Properties; public class TagDependentIngredientItem extends Item { @@ -18,13 +20,13 @@ public class TagDependentIngredientItem extends Item { } @Override - public void fillItemCategory(ItemGroup p_150895_1_, NonNullList p_150895_2_) { + public void fillItemCategory(CreativeModeTab p_150895_1_, NonNullList p_150895_2_) { if (!shouldHide()) super.fillItemCategory(p_150895_1_, p_150895_2_); } public boolean shouldHide() { - ITag tag = ItemTags.getAllTags() + Tag 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 5b1704b5d..fc1a608e4 100644 --- a/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.item; import static net.minecraft.util.text.TextFormatting.GOLD; -import static net.minecraft.util.text.TextFormatting.GRAY; +import staticnet.minecraft.ChatFormattingg.GRAY; import java.text.BreakIterator; import java.util.ArrayList; @@ -22,16 +22,16 @@ import com.simibubi.create.foundation.utility.FontHelper; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ItemLike; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.client.MinecraftForgeClient; @@ -43,41 +43,41 @@ public class TooltipHelper { private static boolean gogglesMode; private static final Map> tooltipReferrals = new HashMap<>(); - public static IFormattableTextComponent holdShift(Palette color, boolean highlighted) { + public static MutableComponent holdShift(Palette color, boolean highlighted) { return Lang.translate("tooltip.holdForDescription", Lang.translate("tooltip.keyShift") - .withStyle(TextFormatting.GRAY)) - .withStyle(TextFormatting.DARK_GRAY); + .withStyle(ChatFormatting.GRAY)) + .withStyle(ChatFormatting.DARK_GRAY); } - public static void addHint(List tooltip, String hintKey, Object... messageParams) { - ITextComponent spacing = IHaveGoggleInformation.componentSpacing; + public static void addHint(List tooltip, String hintKey, Object... messageParams) { + Component spacing = IHaveGoggleInformation.componentSpacing; tooltip.add(spacing.plainCopy() .append(Lang.translate(hintKey + ".title")) .withStyle(GOLD)); - ITextComponent hint = Lang.translate(hintKey); - List cutComponent = TooltipHelper.cutTextComponent(hint, GRAY, TextFormatting.WHITE); - for (ITextComponent component : cutComponent) + Component hint = Lang.translate(hintKey); + List cutComponent = TooltipHelper.cutTextComponent(hint, GRAY, ChatFormatting.WHITE); + for (Component component : cutComponent) tooltip.add(spacing.plainCopy() .append(component)); } - public static void referTo(IItemProvider item, Supplier itemWithTooltip) { + public static void referTo(ItemLike item, Supplier itemWithTooltip) { tooltipReferrals.put(item.asItem(), () -> itemWithTooltip.get() .asItem() .getDescriptionId()); } - public static void referTo(IItemProvider item, String string) { + public static void referTo(ItemLike item, String string) { tooltipReferrals.put(item.asItem(), () -> string); } @Deprecated - public static List cutString(ITextComponent s, TextFormatting defaultColor, TextFormatting highlightColor) { + public static List cutString(Component s, ChatFormatting defaultColor, ChatFormatting highlightColor) { return cutString(s.getContents(), defaultColor, highlightColor, 0); } @Deprecated - public static List cutString(String s, TextFormatting defaultColor, TextFormatting highlightColor, + public static List cutString(String s, ChatFormatting defaultColor, ChatFormatting highlightColor, int indent) { // Apply markup String markedUp = s.replaceAll("_([^_]+)_", highlightColor + "$1" + defaultColor); @@ -92,7 +92,7 @@ public class TooltipHelper { words.add(word); } - FontRenderer font = Minecraft.getInstance().font; + Font font = Minecraft.getInstance().font; List lines = FontHelper.cutString(font, markedUp, maxWidthPerLine); // Format @@ -107,23 +107,23 @@ public class TooltipHelper { return formattedLines; } - public static List cutStringTextComponent(String c, TextFormatting defaultColor, - TextFormatting highlightColor) { - return cutTextComponent(new StringTextComponent(c), defaultColor, highlightColor, 0); + public static List cutStringTextComponent(String c, ChatFormatting defaultColor, + ChatFormatting highlightColor) { + return cutTextComponent(new TextComponent(c), defaultColor, highlightColor, 0); } - public static List cutTextComponent(ITextComponent c, TextFormatting defaultColor, - TextFormatting highlightColor) { + public static List cutTextComponent(Component c, ChatFormatting defaultColor, + ChatFormatting highlightColor) { return cutTextComponent(c, defaultColor, highlightColor, 0); } - public static List cutStringTextComponent(String c, TextFormatting defaultColor, - TextFormatting highlightColor, int indent) { - return cutTextComponent(new StringTextComponent(c), defaultColor, highlightColor, indent); + public static List cutStringTextComponent(String c, ChatFormatting defaultColor, + ChatFormatting highlightColor, int indent) { + return cutTextComponent(new TextComponent(c), defaultColor, highlightColor, indent); } - public static List cutTextComponent(ITextComponent c, TextFormatting defaultColor, - TextFormatting highlightColor, int indent) { + public static List cutTextComponent(Component c, ChatFormatting defaultColor, + ChatFormatting highlightColor, int indent) { String s = c.getString(); // Apply markup @@ -140,7 +140,7 @@ public class TooltipHelper { } // Apply hard wrap - FontRenderer font = Minecraft.getInstance().font; + Font font = Minecraft.getInstance().font; List lines = new LinkedList<>(); StringBuilder currentLine = new StringBuilder(); int width = 0; @@ -165,17 +165,17 @@ public class TooltipHelper { } // Format - IFormattableTextComponent lineStart = new StringTextComponent(Strings.repeat(" ", indent)); + MutableComponent lineStart = new TextComponent(Strings.repeat(" ", indent)); lineStart.withStyle(defaultColor); - List formattedLines = new ArrayList<>(lines.size()); - Couple f = Couple.create(highlightColor, defaultColor); + List formattedLines = new ArrayList<>(lines.size()); + Couple f = Couple.create(highlightColor, defaultColor); boolean currentlyHighlighted = false; for (String string : lines) { - IFormattableTextComponent currentComponent = lineStart.plainCopy(); + MutableComponent currentComponent = lineStart.plainCopy(); String[] split = string.split("_"); for (String part : split) { - currentComponent.append(new StringTextComponent(part).withStyle(f.get(currentlyHighlighted))); + currentComponent.append(new TextComponent(part).withStyle(f.get(currentlyHighlighted))); currentlyHighlighted = !currentlyHighlighted; } @@ -235,10 +235,10 @@ public class TooltipHelper { } } - public static boolean hasTooltip(ItemStack stack, PlayerEntity player) { + public static boolean hasTooltip(ItemStack stack, Player player) { checkLocale(); - boolean hasGlasses = AllItems.GOGGLES.isIn(player.getItemBySlot(EquipmentSlotType.HEAD)); + boolean hasGlasses = AllItems.GOGGLES.isIn(player.getItemBySlot(EquipmentSlot.HEAD)); if (hasGlasses != gogglesMode) { gogglesMode = hasGlasses; @@ -279,7 +279,7 @@ public class TooltipHelper { // Summary if (I18n.exists(summaryKey)) - tooltip = tooltip.withSummary(new StringTextComponent(I18n.get(summaryKey))); + tooltip = tooltip.withSummary(new TextComponent(I18n.get(summaryKey))); // Requirements // if (stack.getItem() instanceof BlockItem) { @@ -297,7 +297,7 @@ public class TooltipHelper { break; if (i == 1) tooltip.getLinesOnShift() - .add(new StringTextComponent("")); + .add(new TextComponent("")); tooltip.withBehaviour(I18n.get(conditionKey), I18n.get(behaviourKey)); } diff --git a/src/main/java/com/simibubi/create/foundation/item/render/CreateCustomRenderedItemModel.java b/src/main/java/com/simibubi/create/foundation/item/render/CreateCustomRenderedItemModel.java index e5e128ca6..b87d39b5e 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/CreateCustomRenderedItemModel.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/CreateCustomRenderedItemModel.java @@ -2,11 +2,11 @@ package com.simibubi.create.foundation.item.render; import com.simibubi.create.Create; -import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.resources.model.BakedModel; public abstract class CreateCustomRenderedItemModel extends CustomRenderedItemModel { - public CreateCustomRenderedItemModel(IBakedModel template, String basePath) { + public CreateCustomRenderedItemModel(BakedModel template, String basePath) { super(template, Create.ID, basePath); } diff --git a/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java b/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java index 121bfa895..6e1c5d808 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java @@ -11,13 +11,13 @@ import org.apache.commons.lang3.tuple.Pair; import com.tterrag.registrate.util.nullness.NonNullBiConsumer; import com.tterrag.registrate.util.nullness.NonNullFunction; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.item.Item; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.world.item.Item; public class CustomItemModels { - private List, NonNullFunction>> registered; - private Map> customModels; + private List, NonNullFunction>> registered; + private Map> customModels; public CustomItemModels() { registered = new ArrayList<>(); @@ -25,11 +25,11 @@ public class CustomItemModels { } public void register(Supplier entry, - NonNullFunction behaviour) { + NonNullFunction behaviour) { registered.add(Pair.of(entry, behaviour)); } - public void forEach(NonNullBiConsumer> consumer) { + public void forEach(NonNullBiConsumer> consumer) { loadEntriesIfMissing(); customModels.forEach(consumer); } 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 fca2995ab..9380ff407 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 @@ -5,23 +5,23 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.model.ModelRotation; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.BlockModelRotation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.model.BakedModelWrapper; import net.minecraftforge.client.model.ModelLoader; -public abstract class CustomRenderedItemModel extends BakedModelWrapper { +public abstract class CustomRenderedItemModel extends BakedModelWrapper { protected String namespace; protected String basePath; - protected Map partials = new HashMap<>(); + protected Map partials = new HashMap<>(); - public CustomRenderedItemModel(IBakedModel template, String namespace, String basePath) { + public CustomRenderedItemModel(BakedModel template, String namespace, String basePath) { super(template); this.namespace = namespace; this.basePath = basePath; @@ -33,18 +33,18 @@ public abstract class CustomRenderedItemModel extends BakedModelWrapper extends ItemStackTileEntityRenderer { +public abstract class CustomRenderedItemModelRenderer extends BlockEntityWithoutLevelRenderer { @Override @SuppressWarnings("unchecked") - public void renderByItem(ItemStack stack, ItemCameraTransforms.TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + public void renderByItem(ItemStack stack, ItemTransforms.TransformType transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { M mainModel = (M) Minecraft.getInstance() .getItemRenderer() .getModel(stack, null, null); @@ -25,9 +25,9 @@ public abstract class CustomRenderedItemModelRenderer, NonNullFunction>> registered; - private Map> customModels; + private List, NonNullFunction>> registered; + private Map> customModels; public CustomRenderedItems() { registered = new ArrayList<>(); @@ -25,12 +25,12 @@ public class CustomRenderedItems { } public void register(Supplier entry, - NonNullFunction behaviour) { + NonNullFunction behaviour) { registered.add(Pair.of(entry, behaviour)); } public void forEach( - NonNullBiConsumer> consumer) { + NonNullBiConsumer> consumer) { loadEntriesIfMissing(); customModels.forEach(consumer); } diff --git a/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java b/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java index 32cf9b714..fcc584e6e 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java @@ -2,19 +2,19 @@ package com.simibubi.create.foundation.item.render; import java.util.Random; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; @@ -25,13 +25,13 @@ public class PartialItemModelRenderer { private final Random random = new Random(); private ItemStack stack; - private ItemCameraTransforms.TransformType transformType; - private MatrixStack ms; - private IRenderTypeBuffer buffer; + private ItemTransforms.TransformType transformType; + private PoseStack ms; + private MultiBufferSource buffer; private int overlay; - public static PartialItemModelRenderer of(ItemStack stack, ItemCameraTransforms.TransformType transformType, - MatrixStack ms, IRenderTypeBuffer buffer, int overlay) { + public static PartialItemModelRenderer of(ItemStack stack, ItemTransforms.TransformType transformType, + PoseStack ms, MultiBufferSource buffer, int overlay) { PartialItemModelRenderer instance = INSTANCE; instance.stack = stack; instance.transformType = transformType; @@ -41,23 +41,23 @@ public class PartialItemModelRenderer { return instance; } - public void render(IBakedModel model, int light) { + public void render(BakedModel model, int light) { render(model, RenderTypes.getItemPartialTranslucent(), light); } - public void renderSolid(IBakedModel model, int light) { + public void renderSolid(BakedModel model, int light) { render(model, RenderTypes.getItemPartialSolid(), light); } - public void renderSolidGlowing(IBakedModel model, int light) { + public void renderSolidGlowing(BakedModel model, int light) { render(model, RenderTypes.getGlowingSolid(), light); } - public void renderGlowing(IBakedModel model, int light) { + public void renderGlowing(BakedModel model, int light) { render(model, RenderTypes.getGlowingTranslucent(), light); } - public void render(IBakedModel model, RenderType type, int light) { + public void render(BakedModel model, RenderType type, int light) { if (stack.isEmpty()) return; @@ -75,7 +75,7 @@ public class PartialItemModelRenderer { ms.popPose(); } - private void renderBakedItemModel(IBakedModel model, int light, MatrixStack ms, IVertexBuilder buffer) { + private void renderBakedItemModel(BakedModel model, int light, PoseStack ms, VertexConsumer buffer) { ItemRenderer ir = Minecraft.getInstance() .getItemRenderer(); IModelData data = EmptyModelData.INSTANCE; 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 4ff137f5a..d19654cef 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java @@ -9,16 +9,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.simibubi.create.foundation.block.BreakProgressHook; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.BlockPos; -@Mixin(ClientWorld.class) +@Mixin(ClientLevel.class) public class BreakProgressMixin { @Shadow @Final - private WorldRenderer levelRenderer; // levelRenderer - private final ClientWorld self = (ClientWorld) (Object) this; + private LevelRenderer levelRenderer; // levelRenderer + private final ClientLevel self = (ClientLevel) (Object) this; @Inject(at = @At("HEAD"), method = "destroyBlockProgress") private void onBreakProgress(int playerEntityId, BlockPos pos, int progress, CallbackInfo ci) { 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 ee082eac3..ff16e82ca 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java @@ -19,17 +19,17 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionCollider; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.MoverType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.particles.BlockParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraftforge.common.capabilities.CapabilityProvider; @Mixin(Entity.class) @@ -68,15 +68,15 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid return contraptions; } - private void forCollision(Vector3d anchorPos, TriConsumer action) { + private void forCollision(Vec3 anchorPos, TriConsumer action) { getIntersectingContraptions().forEach(cEntity -> { - Vector3d localPos = ContraptionCollider.getWorldToLocalTranslation(anchorPos, cEntity); + Vec3 localPos = ContraptionCollider.getWorldToLocalTranslation(anchorPos, cEntity); localPos = anchorPos.add(localPos); BlockPos blockPos = new BlockPos(localPos); Contraption contraption = cEntity.getContraption(); - Template.BlockInfo info = contraption.getBlocks() + StructureTemplate.StructureBlockInfo info = contraption.getBlocks() .get(blockPos); if (info != null) { @@ -88,8 +88,8 @@ 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") - private void movementMixin(MoverType mover, Vector3d movement, CallbackInfo ci) { - Vector3d worldPos = self.position() + private void movementMixin(MoverType mover, Vec3 movement, CallbackInfo ci) { + Vec3 worldPos = self.position() .add(0, -0.2, 0); AtomicBoolean stepped = new AtomicBoolean(false); @@ -106,15 +106,15 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid @Inject(method = { "spawnSprintParticle" }, at = @At(value = "TAIL")) private void createRunningParticlesMixin(CallbackInfo ci) { - Vector3d worldPos = self.position() + Vec3 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.level, blockpos, self) - && blockstate.getRenderShape() != BlockRenderType.INVISIBLE) { - Vector3d vec3d = self.getDeltaMovement(); - self.level.addParticle(new BlockParticleData(ParticleTypes.BLOCK, blockstate).setPos(pos), + && blockstate.getRenderShape() != RenderShape.INVISIBLE) { + Vec3 vec3d = self.getDeltaMovement(); + self.level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, blockstate).setPos(pos), 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); @@ -124,11 +124,11 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid @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)) { + if (this.contraption != null && (!self.isSilent() || self instanceof Player)) { double x = self.getX(); double y = self.getY(); double z = self.getZ(); - Vector3d worldPos = ContraptionCollider.getWorldToLocalTranslation(new Vector3d(x, y, z), this.contraption); + Vec3 worldPos = ContraptionCollider.getWorldToLocalTranslation(new Vec3(x, y, z), this.contraption); worldPos = worldPos.add(x, y, z); 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 b76f2ab3e..aed4283f2 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java @@ -7,9 +7,9 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -@Mixin(MatrixStack.class) +@Mixin(PoseStack.class) public class FixNormalScalingMixin { /** * Minecraft negates the normal matrix if all scales are equal and negative, but 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 8561b404a..9773deee7 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java @@ -7,24 +7,24 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.mojang.authlib.GameProfile; -import net.minecraft.client.entity.player.AbstractClientPlayerEntity; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.nbt.CompoundTag; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -@Mixin(ClientPlayerEntity.class) -public abstract class HeavyBootsOnPlayerMixin extends AbstractClientPlayerEntity { +@Mixin(LocalPlayer.class) +public abstract class HeavyBootsOnPlayerMixin extends AbstractClientPlayer { - public HeavyBootsOnPlayerMixin(ClientWorld p_i50991_1_, GameProfile p_i50991_2_) { + public HeavyBootsOnPlayerMixin(ClientLevel p_i50991_1_, GameProfile p_i50991_2_) { super(p_i50991_1_, p_i50991_2_); } @Inject(at = @At("HEAD"), method = "isUnderWater", cancellable = true) public void noSwimmingWithHeavyBootsOn(CallbackInfoReturnable cir) { - CompoundNBT persistentData = getPersistentData(); + CompoundTag persistentData = getPersistentData(); if (persistentData.contains("HeavyBoots")) cir.setReturnValue(false); } 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 a7857c1b0..870157e2a 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java @@ -8,8 +8,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.simibubi.create.content.schematics.SchematicWorld; import net.minecraft.client.Minecraft; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.ModelDataManager; @@ -25,9 +25,9 @@ public class ModelDataRefreshMixin { * worlds, so in those cases just do nothing instead. */ @Inject(at = @At("HEAD"), method = "requestModelDataRefresh", cancellable = true, remap = false) - private static void requestModelDataRefresh(TileEntity te, CallbackInfo ci) { + private static void requestModelDataRefresh(BlockEntity te, CallbackInfo ci) { if (te != null) { - World world = te.getLevel(); + Level world = te.getLevel(); if (world != Minecraft.getInstance().level && world instanceof SchematicWorld) ci.cancel(); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/PlayerListMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/PlayerListMixin.java index acc2a16dc..73227362b 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/PlayerListMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/PlayerListMixin.java @@ -7,14 +7,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.simibubi.create.content.curiosities.weapons.PotatoProjectileTypeManager; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.NetworkManager; -import net.minecraft.server.management.PlayerList; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.Connection; +import net.minecraft.server.players.PlayerList; @Mixin(PlayerList.class) public class PlayerListMixin { @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/crafting/ServerRecipeBook;sendInitialRecipeBook(Lnet/minecraft/entity/player/ServerPlayerEntity;)V", shift = At.Shift.AFTER), method = "placeNewPlayer(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/ServerPlayerEntity;)V") - private void afterSendRecipeBookOnPlaceNewPlayer(NetworkManager networkManager, ServerPlayerEntity player, CallbackInfo ci) { + private void afterSendRecipeBookOnPlaceNewPlayer(Connection networkManager, ServerPlayer player, CallbackInfo ci) { PotatoProjectileTypeManager.syncTo(player); } 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 4af9f1243..1de90110b 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.simibubi.create.foundation.gui.UIRenderHelper; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -18,7 +18,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; @Mixin(Minecraft.class) public class WindowResizeMixin { - @Shadow @Final private MainWindow window; + @Shadow @Final private Window window; @Inject(at = @At("TAIL"), method = "resizeDisplay") private void updateWindowSize(CallbackInfo ci) { 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 47b63dbfc..1a6f29d4a 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java +++ b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java @@ -58,10 +58,10 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringCo import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueUpdatePacket; import com.simibubi.create.foundation.utility.ServerSpeedProvider; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.network.NetworkDirection; import net.minecraftforge.fml.network.NetworkEvent.Context; import net.minecraftforge.fml.network.NetworkRegistry; @@ -135,7 +135,7 @@ public enum AllPackets { private LoadedPacket packet; - AllPackets(Class type, Function factory, + AllPackets(Class type, Function factory, NetworkDirection direction) { packet = new LoadedPacket<>(type, factory, direction); } @@ -150,20 +150,20 @@ public enum AllPackets { packet.packet.register(); } - public static void sendToNear(World world, BlockPos pos, int range, Object message) { + public static void sendToNear(Level world, BlockPos pos, int range, Object message) { channel.send(PacketDistributor.NEAR .with(TargetPoint.p(pos.getX(), pos.getY(), pos.getZ(), range, world.dimension())), message); } private static class LoadedPacket { private static int index = 0; - BiConsumer encoder; - Function decoder; + BiConsumer encoder; + Function decoder; BiConsumer> handler; Class type; NetworkDirection direction; - private LoadedPacket(Class type, Function factory, NetworkDirection direction) { + private LoadedPacket(Class type, Function factory, NetworkDirection direction) { encoder = T::write; decoder = factory; handler = T::handle; 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 1226eaabd..bef0c708f 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/ISyncPersistentData.java +++ b/src/main/java/com/simibubi/create/foundation/networking/ISyncPersistentData.java @@ -4,9 +4,9 @@ import java.util.HashSet; import java.util.function.Supplier; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; +import net.minecraft.world.entity.Entity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.network.NetworkEvent.Context; import net.minecraftforge.fml.network.PacketDistributor; @@ -22,20 +22,20 @@ public interface ISyncPersistentData { private int entityId; private Entity entity; - private CompoundNBT readData; + private CompoundTag readData; public Packet(Entity entity) { this.entity = entity; this.entityId = entity.getId(); } - public Packet(PacketBuffer buffer) { + public Packet(FriendlyByteBuf buffer) { entityId = buffer.readInt(); readData = buffer.readNbt(); } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeInt(entityId); buffer.writeNbt(entity.getPersistentData()); } @@ -45,7 +45,7 @@ public interface ISyncPersistentData { context.get() .enqueueWork(() -> { Entity entityByID = Minecraft.getInstance().level.getEntity(entityId); - CompoundNBT data = entityByID.getPersistentData(); + CompoundTag data = entityByID.getPersistentData(); new HashSet<>(data.getAllKeys()).forEach(data::remove); data.merge(readData); if (!(entityByID instanceof ISyncPersistentData)) diff --git a/src/main/java/com/simibubi/create/foundation/networking/LeftClickPacket.java b/src/main/java/com/simibubi/create/foundation/networking/LeftClickPacket.java index 57597dbb7..416317b79 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/LeftClickPacket.java +++ b/src/main/java/com/simibubi/create/foundation/networking/LeftClickPacket.java @@ -4,7 +4,7 @@ import java.util.function.Supplier; import com.simibubi.create.events.CommonEvents; -import net.minecraft.network.PacketBuffer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.network.NetworkDirection; import net.minecraftforge.fml.network.NetworkEvent.Context; @@ -12,10 +12,10 @@ public class LeftClickPacket extends SimplePacketBase { public LeftClickPacket() {} - LeftClickPacket(PacketBuffer buffer) {} + LeftClickPacket(FriendlyByteBuf buffer) {} @Override - public void write(PacketBuffer buffer) {} + public void write(FriendlyByteBuf buffer) {} @Override public void handle(Supplier context) { diff --git a/src/main/java/com/simibubi/create/foundation/networking/SimplePacketBase.java b/src/main/java/com/simibubi/create/foundation/networking/SimplePacketBase.java index 6285599fd..f26741675 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/SimplePacketBase.java +++ b/src/main/java/com/simibubi/create/foundation/networking/SimplePacketBase.java @@ -2,12 +2,12 @@ package com.simibubi.create.foundation.networking; import java.util.function.Supplier; -import net.minecraft.network.PacketBuffer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.network.NetworkEvent.Context; public abstract class SimplePacketBase { - public abstract void write(PacketBuffer buffer); + public abstract void write(FriendlyByteBuf buffer); public abstract void handle(Supplier context); 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 9f0ca903d..90e0f9710 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/TileEntityConfigurationPacket.java +++ b/src/main/java/com/simibubi/create/foundation/networking/TileEntityConfigurationPacket.java @@ -4,18 +4,18 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.tileEntity.SyncedTileEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.network.NetworkEvent.Context; public abstract class TileEntityConfigurationPacket extends SimplePacketBase { protected BlockPos pos; - public TileEntityConfigurationPacket(PacketBuffer buffer) { + public TileEntityConfigurationPacket(FriendlyByteBuf buffer) { pos = buffer.readBlockPos(); readSettings(buffer); } @@ -25,7 +25,7 @@ public abstract class TileEntityConfigurationPacket } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBlockPos(pos); writeSettings(buffer); } @@ -35,15 +35,15 @@ public abstract class TileEntityConfigurationPacket public void handle(Supplier context) { context.get() .enqueueWork(() -> { - ServerPlayerEntity player = context.get() + ServerPlayer player = context.get() .getSender(); if (player == null) return; - World world = player.level; + Level world = player.level; if (world == null || !world.isLoaded(pos)) return; - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity tileEntity = world.getBlockEntity(pos); if (tileEntity instanceof SyncedTileEntity) { applySettings((TE) tileEntity); ((SyncedTileEntity) tileEntity).sendData(); @@ -55,9 +55,9 @@ public abstract class TileEntityConfigurationPacket } - protected abstract void writeSettings(PacketBuffer buffer); + protected abstract void writeSettings(FriendlyByteBuf buffer); - protected abstract void readSettings(PacketBuffer buffer); + protected abstract void readSettings(FriendlyByteBuf buffer); protected abstract void applySettings(TE te); 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 4e8acd5f7..8dec9e270 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/TileEntityDataPacket.java +++ b/src/main/java/com/simibubi/create/foundation/networking/TileEntityDataPacket.java @@ -5,10 +5,10 @@ import java.util.function.Supplier; import com.simibubi.create.foundation.tileEntity.SyncedTileEntity; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; import net.minecraftforge.fml.network.NetworkEvent; /** @@ -20,7 +20,7 @@ public abstract class TileEntityDataPacket extends protected BlockPos tilePos; - public TileEntityDataPacket(PacketBuffer buffer) { + public TileEntityDataPacket(FriendlyByteBuf buffer) { tilePos = buffer.readBlockPos(); } @@ -29,7 +29,7 @@ public abstract class TileEntityDataPacket extends } @Override - public void write(PacketBuffer buffer) { + public void write(FriendlyByteBuf buffer) { buffer.writeBlockPos(tilePos); writeData(buffer); } @@ -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().level; + ClientLevel world = Minecraft.getInstance().level; if (world == null) return; - TileEntity tile = world.getBlockEntity(tilePos); + BlockEntity tile = world.getBlockEntity(tilePos); if (tile instanceof SyncedTileEntity) { handlePacket((TE) tile); @@ -52,7 +52,7 @@ public abstract class TileEntityDataPacket extends ctx.setPacketHandled(true); } - protected abstract void writeData(PacketBuffer buffer); + protected abstract void writeData(FriendlyByteBuf buffer); protected abstract void 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 0e334bed3..29cd63870 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/NavigatableSimiScreen.java @@ -8,7 +8,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.lang3.mutable.MutableInt; import org.lwjgl.glfw.GLFW; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.gui.AbstractSimiScreen; @@ -23,12 +23,12 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.animation.LerpedFloat; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.TranslatableComponent; public abstract class NavigatableSimiScreen extends AbstractSimiScreen { @@ -44,7 +44,7 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { protected PonderButton backTrack; public NavigatableSimiScreen() { - MainWindow window = Minecraft.getInstance() + Window window = Minecraft.getInstance() .getWindow(); depthPointX = window.getGuiScaledWidth() / 2; depthPointY = window.getGuiScaledHeight() / 2; @@ -95,7 +95,7 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { } @Override - public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { super.render(ms, mouseX, mouseY, partialTicks); // renderZeloBreadcrumbs(ms, mouseX, mouseY, partialTicks); if (backTrack == null) @@ -104,10 +104,10 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { ms.pushPose(); ms.translate(0, 0, 500); if (backTrack.isHovered()) { - TranslationTextComponent translate = Lang.translate(backTrackingLangKey()); + TranslatableComponent translate = Lang.translate(backTrackingLangKey()); font.draw(ms, translate, 41 - font.width(translate) / 2, height - 16, Theme.i(Theme.Key.TEXT_DARKER)); - if (MathHelper.equal(arrowAnimation.getValue(), arrowAnimation.getChaseTarget())) { + if (Mth.equal(arrowAnimation.getValue(), arrowAnimation.getChaseTarget())) { arrowAnimation.setValue(1); arrowAnimation.setValue(1);// called twice to also set the previous value to 1 } @@ -120,9 +120,9 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { } @Override - protected void renderWindowBackground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowBackground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { if (backTrack != null) { - int x = (int) MathHelper.lerp(arrowAnimation.getValue(partialTicks), -9, 21); + int x = (int) Mth.lerp(arrowAnimation.getValue(partialTicks), -9, 21); int maxX = backTrack.x + backTrack.getWidth(); if (x + 30 < backTrack.x) @@ -160,7 +160,7 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { .getMainRenderTarget() .bindWrite(true); - MainWindow window = Minecraft.getInstance() + Window window = Minecraft.getInstance() .getWindow(); int dpx = window.getGuiScaledWidth() / 2; int dpy = window.getGuiScaledHeight() / 2; @@ -203,7 +203,7 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { } public void centerScalingOnMouse() { - MainWindow w = minecraft.getWindow(); + Window 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); @@ -215,7 +215,7 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen { public void shareContextWith(NavigatableSimiScreen other) {} - protected void renderZeloBreadcrumbs(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderZeloBreadcrumbs(PoseStack ms, int mouseX, int mouseY, float partialTicks) { List history = ScreenOpener.getScreenHistory(); if (history.isEmpty()) return; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderLocalization.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderLocalization.java index 9201555e2..f9663a576 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderLocalization.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderLocalization.java @@ -14,8 +14,8 @@ import com.simibubi.create.foundation.ponder.content.SharedText; import com.simibubi.create.foundation.utility.Couple; import com.tterrag.registrate.AbstractRegistrate; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.resources.ResourceLocation; public class PonderLocalization { 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 b85cbb1db..aeacb4eb3 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.ponder; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.BoxElement; import com.simibubi.create.foundation.gui.Theme; import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget; @@ -10,8 +10,8 @@ import com.simibubi.create.foundation.utility.animation.LerpedFloat; import it.unimi.dsi.fastutil.ints.IntList; import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.SoundHandler; -import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.sounds.SoundManager; +import net.minecraft.client.gui.Font; import net.minecraftforge.fml.client.gui.GuiUtils; public class PonderProgressBar extends AbstractSimiWidget { @@ -88,7 +88,7 @@ public class PonderProgressBar extends AbstractSimiWidget { } @Override - public void renderButton(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void renderButton(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { isHovered = clicked(mouseX, mouseY); @@ -115,7 +115,7 @@ public class PonderProgressBar extends AbstractSimiWidget { ms.popPose(); } - private void renderKeyframes(MatrixStack ms, int mouseX, float partialTicks) { + private void renderKeyframes(PoseStack ms, int mouseX, float partialTicks) { PonderScene activeScene = ponder.getActiveScene(); int hoverStartColor = Theme.i(Theme.Key.PONDER_HOVER, true) | 0xa0_000000; @@ -150,9 +150,9 @@ public class PonderProgressBar extends AbstractSimiWidget { } } - private void drawKeyframe(MatrixStack ms, PonderScene activeScene, boolean selected, int keyframeTime, int keyframePos, int startColor, int endColor, int height) { + private void drawKeyframe(PoseStack ms, PonderScene activeScene, boolean selected, int keyframeTime, int keyframePos, int startColor, int endColor, int height) { if (selected) { - FontRenderer font = Minecraft.getInstance().font; + Font font = Minecraft.getInstance().font; GuiUtils.drawGradientRect(ms.last() .pose(), 100, keyframePos, 10, keyframePos + 1, 10 + height, endColor, startColor); ms.pushPose(); @@ -175,7 +175,7 @@ public class PonderProgressBar extends AbstractSimiWidget { } @Override - public void playDownSound(SoundHandler handler) { + public void playDownSound(SoundManager handler) { } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistrationHelper.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistrationHelper.java index 39b97dc8c..fb6758c31 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistrationHelper.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistrationHelper.java @@ -8,7 +8,7 @@ import com.simibubi.create.foundation.ponder.content.PonderChapter; import com.simibubi.create.foundation.ponder.content.PonderTag; import com.tterrag.registrate.util.entry.ItemProviderEntry; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class PonderRegistrationHelper { 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 9864d53f0..fce5f0434 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java @@ -20,15 +20,15 @@ import com.simibubi.create.foundation.ponder.content.PonderTagRegistry; import com.simibubi.create.foundation.ponder.content.SharedText; import net.minecraft.client.Minecraft; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTSizeTracker; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.feature.template.PlacementSettings; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtIo; +import net.minecraft.nbt.NbtAccounter; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class PonderRegistry { @@ -72,9 +72,9 @@ public class PonderRegistry { for (int i = 0; i < entries.size(); i++) { PonderStoryBoardEntry sb = entries.get(i); - Template activeTemplate = loadSchematic(sb.getSchematicLocation()); + StructureTemplate activeTemplate = loadSchematic(sb.getSchematicLocation()); PonderWorld world = new PonderWorld(BlockPos.ZERO, Minecraft.getInstance().level); - activeTemplate.placeInWorld(world, BlockPos.ZERO, new PlacementSettings(), world.random); + activeTemplate.placeInWorld(world, BlockPos.ZERO, new StructurePlaceSettings(), world.random); world.createBackup(); PonderScene scene = compileScene(i, sb, world); scene.begin(); @@ -92,30 +92,30 @@ public class PonderRegistry { return scene; } - public static Template loadSchematic(ResourceLocation location) { + public static StructureTemplate loadSchematic(ResourceLocation location) { return loadSchematic(Minecraft.getInstance().getResourceManager(), location); } - public static Template loadSchematic(IResourceManager resourceManager, ResourceLocation location) { + public static StructureTemplate loadSchematic(ResourceManager resourceManager, ResourceLocation location) { String namespace = location.getNamespace(); String path = "ponder/" + location.getPath() + ".nbt"; ResourceLocation location1 = new ResourceLocation(namespace, path); - try (IResource resource = resourceManager.getResource(location1)) { + try (Resource resource = resourceManager.getResource(location1)) { return loadSchematic(resource.getInputStream()); } catch (FileNotFoundException e) { Create.LOGGER.error("Ponder schematic missing: " + location1, e); } catch (IOException e) { Create.LOGGER.error("Failed to read ponder schematic: " + location1, e); } - return new Template(); + return new StructureTemplate(); } - public static Template loadSchematic(InputStream resourceStream) throws IOException { - Template t = new Template(); + public static StructureTemplate loadSchematic(InputStream resourceStream) throws IOException { + StructureTemplate t = new StructureTemplate(); DataInputStream stream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(resourceStream))); - CompoundNBT nbt = CompressedStreamTools.read(stream, new NBTSizeTracker(0x20000000L)); + CompoundTag nbt = NbtIo.read(stream, new NbtAccounter(0x20000000L)); t.load(nbt); return t; } 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 4f2ab9a83..568450d8f 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java @@ -19,7 +19,7 @@ import org.apache.commons.lang3.mutable.MutableDouble; import org.apache.commons.lang3.mutable.MutableObject; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.ponder.content.PonderIndex; import com.simibubi.create.foundation.ponder.content.PonderTag; import com.simibubi.create.foundation.ponder.elements.PonderOverlayElement; @@ -35,24 +35,24 @@ import com.simibubi.create.foundation.utility.outliner.Outliner; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.Camera; import net.minecraft.client.renderer.RenderType; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ArmorStandEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector2f; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.util.math.vector.Vector4f; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.decoration.ArmorStand; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import com.mojang.math.Matrix4f; +import net.minecraft.world.phys.Vec2; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; +import com.mojang.math.Vector4f; public class PonderScene { @@ -78,8 +78,8 @@ public class PonderScene { Outliner outliner; String defaultTitle; - Vector3d pointOfInterest; - Vector3d chasingPointOfInterest; + Vec3 pointOfInterest; + Vec3 chasingPointOfInterest; WorldSectionElement baseWorldSection; @Nullable Entity renderViewEntity; @@ -98,7 +98,7 @@ public class PonderScene { if (world != null) world.scene = this; - pointOfInterest = Vector3d.ZERO; + pointOfInterest = Vec3.ZERO; textIndex = 1; this.world = world; @@ -115,19 +115,19 @@ public class PonderScene { basePlateSize = getBounds().getXSpan(); info = new SceneRenderInfo(); baseWorldSection = new WorldSectionElement(); - renderViewEntity = world != null ? new ArmorStandEntity(world, 0, 0, 0) : null; + renderViewEntity = world != null ? new ArmorStand(world, 0, 0, 0) : null; keyframeTimes = new IntArrayList(4); scaleFactor = 1; yOffset = 0; - setPointOfInterest(new Vector3d(0, 4, 0)); + setPointOfInterest(new Vec3(0, 4, 0)); } public void deselect() { forEach(WorldSectionElement.class, WorldSectionElement::resetSelectedBlock); } - public Pair rayTraceScene(Vector3d from, Vector3d to) { + public Pair rayTraceScene(Vec3 from, Vec3 to) { MutableObject> nearestHit = new MutableObject<>(); MutableDouble bestDistance = new MutableDouble(0); @@ -135,7 +135,7 @@ public class PonderScene { wse.resetSelectedBlock(); if (!wse.isVisible()) return; - Pair rayTrace = wse.rayTrace(world, from, to); + Pair rayTrace = wse.rayTrace(world, from, to); if (rayTrace == null) return; double distanceTo = rayTrace.getFirst() @@ -157,7 +157,7 @@ public class PonderScene { if (!world.getBounds() .isInside(selectedPos)) return Pair.of(ItemStack.EMPTY, null); - if (new MutableBoundingBox(origin, origin.offset(new Vector3i(basePlateSize - 1, 0, basePlateSize - 1))) + if (new BoundingBox(origin, origin.offset(new Vec3i(basePlateSize - 1, 0, basePlateSize - 1))) .isInside(selectedPos)) { if (PonderIndex.EDITOR_MODE) nearestHit.getValue() @@ -171,7 +171,7 @@ public class PonderScene { .selectBlock(selectedPos); BlockState blockState = world.getBlockState(selectedPos); ItemStack pickBlock = blockState.getPickBlock( - new BlockRayTraceResult(VecHelper.getCenterOf(selectedPos), Direction.UP, selectedPos, true), world, + new BlockHitResult(VecHelper.getCenterOf(selectedPos), Direction.UP, selectedPos, true), world, selectedPos, Minecraft.getInstance().player); return Pair.of(pickBlock, selectedPos); @@ -202,7 +202,7 @@ public class PonderScene { transform = new SceneTransform(); finished = false; - setPointOfInterest(new Vector3d(0, 4, 0)); + setPointOfInterest(new Vec3(0, 4, 0)); baseWorldSection.setEmpty(); baseWorldSection.forceApplyFade(1); @@ -227,7 +227,7 @@ public class PonderScene { activeSchedule.add(new HideAllInstruction(10, null)); } - public void renderScene(SuperRenderTypeBuffer buffer, MatrixStack ms, float pt) { + public void renderScene(SuperRenderTypeBuffer buffer, PoseStack ms, float pt) { ms.pushPose(); Minecraft mc = Minecraft.getInstance(); Entity prevRVE = mc.cameraEntity; @@ -248,19 +248,19 @@ public class PonderScene { ms.popPose(); } - public void renderOverlay(PonderUI screen, MatrixStack ms, float partialTicks) { + public void renderOverlay(PonderUI screen, PoseStack ms, float partialTicks) { ms.pushPose(); forEachVisible(PonderOverlayElement.class, e -> e.render(this, screen, ms, partialTicks)); ms.popPose(); } - public void setPointOfInterest(Vector3d poi) { + public void setPointOfInterest(Vec3 poi) { if (chasingPointOfInterest == null) pointOfInterest = poi; chasingPointOfInterest = poi; } - public Vector3d getPointOfInterest() { + public Vec3 getPointOfInterest() { return pointOfInterest; } @@ -377,8 +377,8 @@ public class PonderScene { function.accept(type.cast(element)); } - public MutableBoundingBox getBounds() { - return world == null ? new MutableBoundingBox() : world.getBounds(); + public BoundingBox getBounds() { + return world == null ? new BoundingBox() : world.getBounds(); } public Supplier registerText(String defaultText) { @@ -449,11 +449,11 @@ public class PonderScene { cachedMat = null; } - public MatrixStack apply(MatrixStack ms) { + public PoseStack apply(PoseStack ms) { return apply(ms, AnimationTickHolder.getPartialTicks(world), false); } - public MatrixStack apply(MatrixStack ms, float pt, boolean overlayCompatible) { + public PoseStack apply(PoseStack ms, float pt, boolean overlayCompatible) { ms.translate(width / 2, height / 2, 200 + offset); MatrixTransformStack.of(ms) @@ -488,14 +488,14 @@ public class PonderScene { } public void updateSceneRVE(float pt) { - Vector3d v = screenToScene(width / 2, height / 2, 500, pt); + Vec3 v = screenToScene(width / 2, height / 2, 500, pt); if (renderViewEntity != null) renderViewEntity.setPos(v.x, v.y, v.z); } - public Vector3d screenToScene(double x, double y, int depth, float pt) { + public Vec3 screenToScene(double x, double y, int depth, float pt) { refreshMatrix(pt); - Vector3d vec = new Vector3d(x, y, depth); + Vec3 vec = new Vec3(x, y, depth); vec = vec.subtract(width / 2, height / 2, 200 + offset); vec = VecHelper.rotate(vec, 35, Axis.X); @@ -515,23 +515,23 @@ public class PonderScene { return vec; } - public Vector2f sceneToScreen(Vector3d vec, float pt) { + public Vec2 sceneToScreen(Vec3 vec, float pt) { refreshMatrix(pt); Vector4f vec4 = new Vector4f((float) vec.x, (float) vec.y, (float) vec.z, 1); vec4.transform(cachedMat); - return new Vector2f(vec4.x(), vec4.y()); + return new Vec2(vec4.x(), vec4.y()); } protected void refreshMatrix(float pt) { if (cachedMat != null) return; - cachedMat = apply(new MatrixStack(), pt, false).last() + cachedMat = apply(new PoseStack(), pt, false).last() .pose(); } } - public class SceneRenderInfo extends ActiveRenderInfo { + public class SceneRenderInfo extends Camera { public void set(float xRotation, float yRotation) { setRotation(yRotation, xRotation); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderStoryBoardEntry.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderStoryBoardEntry.java index aa6ec545e..b801539f9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderStoryBoardEntry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderStoryBoardEntry.java @@ -7,7 +7,7 @@ import java.util.List; import com.simibubi.create.foundation.ponder.content.PonderChapter; import com.simibubi.create.foundation.ponder.content.PonderTag; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class PonderStoryBoardEntry { 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 1177ffdc9..fc15b3f34 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java @@ -9,15 +9,15 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.client.util.InputMappings; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.KeyMapping; +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.world.item.ItemStack; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.client.event.RenderTooltipEvent; public class PonderTooltipHandler { @@ -52,7 +52,7 @@ public class PonderTooltipHandler { long window = instance.getWindow() .getWindow(); - if (!subject && InputMappings.isKeyDown(window, keyCode)) { + if (!subject && InputConstants.isKeyDown(window, keyCode)) { if (value >= 1) { if (currentScreen instanceof NavigatableSimiScreen) ((NavigatableSimiScreen) currentScreen).centerScalingOnMouse(); @@ -67,7 +67,7 @@ public class PonderTooltipHandler { hoveredStack = ItemStack.EMPTY; } - public static void addToTooltip(List toolTip, ItemStack stack) { + public static void addToTooltip(List toolTip, ItemStack stack) { updateHovered(stack); if (deferTick) @@ -78,8 +78,8 @@ public class PonderTooltipHandler { float renderPartialTicks = Minecraft.getInstance() .getFrameTime(); - ITextComponent component = subject ? Lang.createTranslationTextComponent(SUBJECT) - .withStyle(TextFormatting.GREEN) + Component component = subject ? Lang.createTranslationTextComponent(SUBJECT) + .withStyle(ChatFormatting.GREEN) : makeProgressBar(Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f)); if (toolTip.size() < 2) toolTip.add(component); @@ -137,13 +137,13 @@ public class PonderTooltipHandler { return Color.mixColors(5592575, 0xffffff, (progress - .5f) * 2); } - private static ITextComponent makeProgressBar(float progress) { - IFormattableTextComponent holdW = Lang + private static Component makeProgressBar(float progress) { + MutableComponent holdW = Lang .translate(HOLD_TO_PONDER, - ((IFormattableTextComponent) ponderKeybind().getTranslatedKeyMessage()).withStyle(TextFormatting.GRAY)) - .withStyle(TextFormatting.DARK_GRAY); + ((MutableComponent) ponderKeybind().getTranslatedKeyMessage()).withStyle(ChatFormatting.GRAY)) + .withStyle(ChatFormatting.DARK_GRAY); - FontRenderer fontRenderer = Minecraft.getInstance().font; + Font fontRenderer = Minecraft.getInstance().font; float charWidth = fontRenderer.width("|"); float tipWidth = fontRenderer.width(holdW); @@ -152,16 +152,16 @@ public class PonderTooltipHandler { if (progress > 0) { String bars = ""; - bars += TextFormatting.GRAY + Strings.repeat("|", current); + bars += ChatFormatting.GRAY + Strings.repeat("|", current); if (progress < 1) - bars += TextFormatting.DARK_GRAY + Strings.repeat("|", total - current); - return new StringTextComponent(bars); + bars += ChatFormatting.DARK_GRAY + Strings.repeat("|", total - current); + return new TextComponent(bars); } return holdW; } - protected static KeyBinding ponderKeybind() { + protected static KeyMapping ponderKeybind() { 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 248104947..b442734d2 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java @@ -10,7 +10,7 @@ import java.util.stream.IntStream; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.Create; import com.simibubi.create.foundation.config.AllConfigs; @@ -40,26 +40,26 @@ import com.simibubi.create.foundation.utility.Pointing; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; -import net.minecraft.client.ClipboardHelper; -import net.minecraft.client.GameSettings; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.platform.ClipboardManager; +import net.minecraft.client.Options; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.Style; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.gen.feature.template.PlacementSettings; -import net.minecraft.world.gen.feature.template.Template; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Style; +import net.minecraft.ChatFormatting; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraftforge.fml.client.gui.GuiUtils; import net.minecraftforge.registries.ForgeRegistries; @@ -91,7 +91,7 @@ public class PonderUI extends NavigatableSimiScreen { private ItemStack hoveredTooltipItem; private BlockPos hoveredBlockPos; - private ClipboardHelper clipboardHelper; + private ClipboardManager clipboardHelper; private BlockPos copiedBlockPos; private LerpedFloat finishingFlash; @@ -149,7 +149,7 @@ public class PonderUI extends NavigatableSimiScreen { fadeIn = LerpedFloat.linear() .startWithValue(0) .chase(1, .1f, Chaser.EXP); - clipboardHelper = new ClipboardHelper(); + clipboardHelper = new ClipboardManager(); finishingFlash = LerpedFloat.linear() .startWithValue(0) .chase(0, .1f, Chaser.EXP); @@ -190,7 +190,7 @@ public class PonderUI extends NavigatableSimiScreen { }).showing(chapter)); }*/ - GameSettings bindings = minecraft.options; + Options bindings = minecraft.options; int spacing = 8; int bX = (width - 20) / 2 - (70 + 2 * spacing); int bY = height - 20 - 31; @@ -342,12 +342,12 @@ public class PonderUI extends NavigatableSimiScreen { if (!identifyMode) return; - MainWindow w = minecraft.getWindow(); + Window 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); + Vec3 vec1 = t.screenToScene(mouseX, mouseY, 1000, 0); + Vec3 vec2 = t.screenToScene(mouseX, mouseY, -100, 0); Pair pair = activeScene.rayTraceScene(vec1, vec2); hoveredTooltipItem = pair.getFirst(); hoveredBlockPos = pair.getSecond(); @@ -367,9 +367,9 @@ public class PonderUI extends NavigatableSimiScreen { if (hasShiftDown()) { List list = PonderRegistry.ALL.get(scene.component); PonderStoryBoardEntry sb = list.get(index); - Template activeTemplate = PonderRegistry.loadSchematic(sb.getSchematicLocation()); + StructureTemplate activeTemplate = PonderRegistry.loadSchematic(sb.getSchematicLocation()); PonderWorld world = new PonderWorld(BlockPos.ZERO, Minecraft.getInstance().level); - activeTemplate.placeInWorld(world, BlockPos.ZERO, new PlacementSettings(), new Random()); + activeTemplate.placeInWorld(world, BlockPos.ZERO, new StructurePlaceSettings(), new Random()); world.createBackup(); scene = PonderRegistry.compileScene(index, sb, world); scene.begin(); @@ -382,7 +382,7 @@ public class PonderUI extends NavigatableSimiScreen { protected boolean scroll(boolean forward) { int prevIndex = index; index = forward ? index + 1 : index - 1; - index = MathHelper.clamp(index, 0, scenes.size() - 1); + index = Mth.clamp(index, 0, scenes.size() - 1); if (prevIndex != index) {// && Math.abs(index - lazyIndex.getValue()) < 1.5f) { scenes.get(prevIndex) .fadeOut(); @@ -397,7 +397,7 @@ public class PonderUI extends NavigatableSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { partialTicks = getPartialTicks(); RenderSystem.enableBlend(); renderVisibleScenes(ms, mouseX, mouseY, @@ -406,23 +406,23 @@ public class PonderUI extends NavigatableSimiScreen { } @Override - public void renderBackground(MatrixStack ms) { + public void renderBackground(PoseStack ms) { super.renderBackground(ms); } - protected void renderVisibleScenes(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderVisibleScenes(PoseStack ms, int mouseX, int mouseY, float partialTicks) { renderScene(ms, mouseX, mouseY, index, partialTicks); float lazyIndexValue = lazyIndex.getValue(partialTicks); if (Math.abs(lazyIndexValue - index) > 1 / 512f) renderScene(ms, mouseX, mouseY, lazyIndexValue < index ? index - 1 : index + 1, partialTicks); } - protected void renderScene(MatrixStack ms, int mouseX, int mouseY, int i, float partialTicks) { + protected void renderScene(PoseStack ms, int mouseX, int mouseY, int i, float partialTicks) { SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance(); PonderScene story = scenes.get(i); double value = lazyIndex.getValue(minecraft.getFrameTime()); double diff = i - value; - double slide = MathHelper.lerp(diff * diff, 200, 600) * diff; + double slide = Mth.lerp(diff * diff, 200, 600) * diff; RenderSystem.enableAlphaTest(); RenderSystem.enableBlend(); @@ -441,7 +441,7 @@ public class PonderUI extends NavigatableSimiScreen { story.renderScene(buffer, ms, partialTicks); buffer.draw(); - MutableBoundingBox bounds = story.getBounds(); + BoundingBox bounds = story.getBounds(); ms.pushPose(); // kool shadow fx @@ -535,7 +535,7 @@ public class PonderUI extends NavigatableSimiScreen { RenderSystem.popMatrix(); } - protected void renderWidgets(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWidgets(PoseStack ms, int mouseX, int mouseY, float partialTicks) { RenderSystem.disableDepthTest(); float fade = fadeIn.getValue(partialTicks); @@ -544,7 +544,7 @@ public class PonderUI extends NavigatableSimiScreen { PonderScene activeScene = scenes.get(index); boolean noWidgetsHovered = true; - for (Widget widget : widgets) + for (AbstractWidget widget : widgets) noWidgetsHovered &= !widget.isMouseOver(mouseX, mouseY); int tooltipColor = Theme.i(Theme.Key.TEXT_DARKER); @@ -610,10 +610,10 @@ public class PonderUI extends NavigatableSimiScreen { ms.pushPose(); ms.translate(mouseX, mouseY, 100); if (hoveredTooltipItem.isEmpty()) { - IFormattableTextComponent text = Lang.translate( + MutableComponent text = Lang.translate( IDENTIFY_MODE, - ((IFormattableTextComponent) minecraft.options.keyDrop.getTranslatedKeyMessage()).withStyle(TextFormatting.WHITE) - ).withStyle(TextFormatting.GRAY); + ((MutableComponent) minecraft.options.keyDrop.getTranslatedKeyMessage()).withStyle(ChatFormatting.WHITE) + ).withStyle(ChatFormatting.GRAY); //renderOrderedTooltip(ms, textRenderer.wrapLines(text, width / 3), 0, 0); renderWrappedToolTip(ms, font.getSplitter().splitLines(text, width / 3, Style.EMPTY), 0, 0, font); @@ -627,8 +627,8 @@ public class PonderUI extends NavigatableSimiScreen { if (hoveredBlockPos != null && PonderIndex.EDITOR_MODE && !userViewMode) { ms.translate(0, -15, 0); boolean copied = copiedBlockPos != null && hoveredBlockPos.equals(copiedBlockPos); - IFormattableTextComponent coords = new StringTextComponent(hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ()) - .withStyle(copied ? TextFormatting.GREEN : TextFormatting.GOLD); + MutableComponent coords = new TextComponent(hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ()) + .withStyle(copied ? ChatFormatting.GREEN : ChatFormatting.GOLD); renderTooltip(ms, coords, 0, 0); } ms.popPose(); @@ -743,7 +743,7 @@ public class PonderUI extends NavigatableSimiScreen { RenderSystem.enableDepthTest(); } - private void renderOverlay(MatrixStack ms, int i, float partialTicks) { + private void renderOverlay(PoseStack ms, int i, float partialTicks) { if (identifyMode) return; ms.pushPose(); @@ -781,7 +781,7 @@ public class PonderUI extends NavigatableSimiScreen { @Override public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) { - GameSettings settings = Minecraft.getInstance().options; + Options settings = Minecraft.getInstance().options; int sCode = settings.keyDown.getKey() .getValue(); int aCode = settings.keyLeft.getKey() @@ -827,7 +827,7 @@ public class PonderUI extends NavigatableSimiScreen { .getString(); } - public FontRenderer getFontRenderer() { + public Font getFontRenderer() { return font; } @@ -837,7 +837,7 @@ public class PonderUI extends NavigatableSimiScreen { return hovered; } - public static void renderSpeechBox(MatrixStack ms, int x, int y, int w, int h, boolean highlighted, Pointing pointing, + public static void renderSpeechBox(PoseStack ms, int x, int y, int w, int h, boolean highlighted, Pointing pointing, boolean returnWithLocalTransform) { if (!returnWithLocalTransform) ms.pushPose(); @@ -966,7 +966,7 @@ public class PonderUI extends NavigatableSimiScreen { hoveredTooltipItem = ItemStack.EMPTY; } - public void drawRightAlignedString(FontRenderer fontRenderer, MatrixStack ms, String string, int x, int y, + public void drawRightAlignedString(Font fontRenderer, PoseStack ms, String string, int x, int y, int color) { fontRenderer.draw(ms, string, (float) (x - fontRenderer.width(string)), (float) y, color); } 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 b3b1e7bd1..9a2db73cf 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java @@ -8,7 +8,7 @@ import java.util.Map; import javax.annotation.Nullable; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; @@ -18,35 +18,35 @@ import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.utility.worldWrappers.WrappedClientWorld; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.IParticleFactory; +import net.minecraft.client.particle.ParticleProvider; import net.minecraft.client.particle.Particle; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.inventory.container.PlayerContainer; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.BlockParticleData; -import net.minecraft.particles.IParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.LazyValue; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.LightType; -import net.minecraft.world.World; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.util.LazyLoadedValue; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.Level; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.registries.ForgeRegistries; @@ -55,18 +55,18 @@ public class PonderWorld extends SchematicWorld { public PonderScene scene; protected Map originalBlocks; - protected Map originalTileEntities; + protected Map originalTileEntities; protected Map blockBreakingProgressions; protected List originalEntities; - private LazyValue asClientWorld = new LazyValue<>(() -> WrappedClientWorld.of(this)); + private LazyLoadedValue asClientWorld = new LazyLoadedValue<>(() -> WrappedClientWorld.of(this)); protected PonderWorldParticles particles; - private final Map> particleFactories; + private final Map> particleFactories; int overrideLight; Selection mask; - public PonderWorld(BlockPos anchor, World original) { + public PonderWorld(BlockPos anchor, Level original) { super(anchor, original); originalBlocks = new HashMap<>(); originalTileEntities = new HashMap<>(); @@ -75,7 +75,7 @@ public class PonderWorld extends SchematicWorld { particles = new PonderWorldParticles(this); // ParticleManager.factories - ATs don't seem to like this one - particleFactories = ObfuscationReflectionHelper.getPrivateValue(ParticleManager.class, + particleFactories = ObfuscationReflectionHelper.getPrivateValue(ParticleEngine.class, Minecraft.getInstance().particleEngine, "field_178932_g"); } @@ -84,7 +84,7 @@ public class PonderWorld extends SchematicWorld { originalTileEntities.clear(); blocks.forEach((k, v) -> originalBlocks.put(k, v)); tileEntities.forEach( - (k, v) -> originalTileEntities.put(k, TileEntity.loadStatic(blocks.get(k), v.save(new CompoundNBT())))); + (k, v) -> originalTileEntities.put(k, BlockEntity.loadStatic(blocks.get(k), v.save(new CompoundTag())))); entities.forEach(e -> EntityType.create(e.serializeNBT(), this) .ifPresent(originalEntities::add)); } @@ -97,7 +97,7 @@ public class PonderWorld extends SchematicWorld { renderedTileEntities.clear(); originalBlocks.forEach((k, v) -> blocks.put(k, v)); originalTileEntities.forEach((k, v) -> { - TileEntity te = TileEntity.loadStatic(originalBlocks.get(k), v.save(new CompoundNBT())); + BlockEntity te = BlockEntity.loadStatic(originalBlocks.get(k), v.save(new CompoundTag())); onTEadded(te, te.getBlockPos()); tileEntities.put(k, te); renderedTileEntities.add(te); @@ -113,8 +113,8 @@ public class PonderWorld extends SchematicWorld { if (originalBlocks.containsKey(p)) blocks.put(p, originalBlocks.get(p)); if (originalTileEntities.containsKey(p)) { - TileEntity te = TileEntity.loadStatic(originalBlocks.get(p), originalTileEntities.get(p) - .save(new CompoundNBT())); + BlockEntity te = BlockEntity.loadStatic(originalBlocks.get(p), originalTileEntities.get(p) + .save(new CompoundTag())); onTEadded(te, te.getBlockPos()); tileEntities.put(p, te); } @@ -136,7 +136,7 @@ public class PonderWorld extends SchematicWorld { } @Override - public int getBrightness(LightType p_226658_1_, BlockPos p_226658_2_) { + public int getBrightness(LightLayer p_226658_1_, BlockPos p_226658_2_) { return overrideLight == -1 ? 15 : overrideLight; } @@ -156,12 +156,12 @@ public class PonderWorld extends SchematicWorld { } @Override // For particle collision - public IBlockReader getChunkForCollisions(int p_225522_1_, int p_225522_2_) { + public BlockGetter 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.getPosition(); + public void renderEntities(PoseStack ms, SuperRenderTypeBuffer buffer, Camera ari, float pt) { + Vec3 Vector3d = ari.getPosition(); double d0 = Vector3d.x(); double d1 = Vector3d.y(); double d2 = Vector3d.z(); @@ -175,26 +175,26 @@ public class PonderWorld extends SchematicWorld { renderEntity(entity, d0, d1, d2, pt, ms, buffer); } - 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)); + buffer.draw(RenderType.entitySolid(InventoryMenu.BLOCK_ATLAS)); + buffer.draw(RenderType.entityCutout(InventoryMenu.BLOCK_ATLAS)); + buffer.draw(RenderType.entityCutoutNoCull(InventoryMenu.BLOCK_ATLAS)); + buffer.draw(RenderType.entitySmoothCutout(InventoryMenu.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.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() + private void renderEntity(Entity entity, double x, double y, double z, float pt, PoseStack ms, + MultiBufferSource buffer) { + double d0 = Mth.lerp((double) pt, entity.xOld, entity.getX()); + double d1 = Mth.lerp((double) pt, entity.yOld, entity.getY()); + double d2 = Mth.lerp((double) pt, entity.zOld, entity.getZ()); + float f = Mth.lerp(pt, entity.yRotO, entity.yRot); + EntityRenderDispatcher renderManager = Minecraft.getInstance() .getEntityRenderDispatcher(); int light = renderManager.getRenderer(entity) .getPackedLightCoords(entity, pt); renderManager.render(entity, d0 - x, d1 - y, d2 - z, f, pt, ms, buffer, light); } - public void renderParticles(MatrixStack ms, IRenderTypeBuffer buffer, ActiveRenderInfo ari, float pt) { + public void renderParticles(PoseStack ms, MultiBufferSource buffer, Camera ari, float pt) { particles.renderParticles(ms, buffer, ari, pt); } @@ -219,21 +219,21 @@ public class PonderWorld extends SchematicWorld { } @Override - public void addParticle(IParticleData data, double x, double y, double z, double mx, double my, double mz) { + public void addParticle(ParticleOptions data, double x, double y, double z, double mx, double my, double mz) { addParticle(makeParticle(data, x, y, z, mx, my, mz)); } @Override - public void addAlwaysVisibleParticle(IParticleData data, double x, double y, double z, double mx, double my, double mz) { + public void addAlwaysVisibleParticle(ParticleOptions data, double x, double y, double z, double mx, double my, double mz) { addParticle(data, x, y, z, mx, my, mz); } @Nullable @SuppressWarnings("unchecked") - private Particle makeParticle(T data, double x, double y, double z, double mx, double my, + private Particle makeParticle(T data, double x, double y, double z, double mx, double my, double mz) { ResourceLocation key = ForgeRegistries.PARTICLE_TYPES.getKey(data.getType()); - IParticleFactory iparticlefactory = (IParticleFactory) particleFactories.get(key); + ParticleProvider iparticlefactory = (ParticleProvider) particleFactories.get(key); return iparticlefactory == null ? null : iparticlefactory.createParticle(data, asClientWorld.get(), x, y, z, mx, my, mz); } @@ -249,7 +249,7 @@ public class PonderWorld extends SchematicWorld { } @Override - protected void onTEadded(TileEntity tileEntity, BlockPos pos) { + protected void onTEadded(BlockEntity tileEntity, BlockPos pos) { super.onTEadded(tileEntity, pos); if (!(tileEntity instanceof SmartTileEntity)) return; @@ -258,14 +258,14 @@ public class PonderWorld extends SchematicWorld { } public void fixControllerTileEntities() { - for (TileEntity tileEntity : tileEntities.values()) { + for (BlockEntity tileEntity : tileEntities.values()) { if (tileEntity instanceof BeltTileEntity) { BeltTileEntity beltTileEntity = (BeltTileEntity) tileEntity; if (!beltTileEntity.isController()) continue; BlockPos controllerPos = tileEntity.getBlockPos(); for (BlockPos blockPos : BeltBlock.getBeltChain(this, controllerPos)) { - TileEntity tileEntity2 = getBlockEntity(blockPos); + BlockEntity tileEntity2 = getBlockEntity(blockPos); if (!(tileEntity2 instanceof BeltTileEntity)) continue; BeltTileEntity belt2 = (BeltTileEntity) tileEntity2; @@ -305,13 +305,13 @@ public class PonderWorld extends SchematicWorld { if (voxelshape.isEmpty()) return; - AxisAlignedBB bb = voxelshape.bounds(); + AABB 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); - int i = Math.max(2, MathHelper.ceil(d1 / 0.25D)); - int j = Math.max(2, MathHelper.ceil(d2 / 0.25D)); - int k = Math.max(2, MathHelper.ceil(d3 / 0.25D)); + int i = Math.max(2, Mth.ceil(d1 / 0.25D)); + int j = Math.max(2, Mth.ceil(d2 / 0.25D)); + int k = Math.max(2, Mth.ceil(d3 / 0.25D)); for (int l = 0; l < i; ++l) { for (int i1 = 0; i1 < j; ++i1) { @@ -322,7 +322,7 @@ public class PonderWorld extends SchematicWorld { double d7 = d4 * d1 + bb.minX; double d8 = d5 * d2 + bb.minY; double d9 = d6 * d3 + bb.minZ; - addParticle(new BlockParticleData(ParticleTypes.BLOCK, state), pos.getX() + d7, pos.getY() + d8, + addParticle(new BlockParticleOption(ParticleTypes.BLOCK, state), pos.getX() + d7, pos.getY() + d8, pos.getZ() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D); } } 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 79ce37930..0b19f40ab 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderWorldParticles.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderWorldParticles.java @@ -8,21 +8,21 @@ import java.util.Queue; import com.google.common.collect.EvictingQueue; import com.google.common.collect.Maps; import com.google.common.collect.Queues; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.IParticleRenderType; +import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.Particle; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.Camera; +import com.mojang.blaze3d.vertex.BufferBuilder; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.Tessellator; +import com.mojang.blaze3d.vertex.Tesselator; public class PonderWorldParticles { - private final Map> byType = Maps.newIdentityHashMap(); + private final Map> byType = Maps.newIdentityHashMap(); private final Queue queue = Queues.newArrayDeque(); PonderWorld world; @@ -59,7 +59,7 @@ public class PonderWorldParticles { } } - public void renderParticles(MatrixStack ms, IRenderTypeBuffer buffer, ActiveRenderInfo renderInfo, float pt) { + public void renderParticles(PoseStack ms, MultiBufferSource buffer, Camera renderInfo, float pt) { Minecraft mc = Minecraft.getInstance(); LightTexture lightTexture = mc.gameRenderer.lightTexture(); @@ -74,14 +74,14 @@ public class PonderWorldParticles { RenderSystem.multMatrix(ms.last() .pose()); - for (IParticleRenderType iparticlerendertype : this.byType.keySet()) { - if (iparticlerendertype == IParticleRenderType.NO_RENDER) + for (ParticleRenderType iparticlerendertype : this.byType.keySet()) { + if (iparticlerendertype == ParticleRenderType.NO_RENDER) continue; enable.run(); Iterable iterable = this.byType.get(iparticlerendertype); if (iterable != null) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - Tessellator tessellator = Tessellator.getInstance(); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuilder(); iparticlerendertype.begin(bufferbuilder, mc.textureManager); 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 2415e6fcf..ff3579044 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java @@ -63,25 +63,27 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.RedstoneTorchBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.RedstoneParticleData; -import net.minecraft.state.Property; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.RedstoneTorchBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; + +import com.simibubi.create.foundation.ponder.elements.TextWindowElement.Builder; /** * Enqueue instructions to the schedule via this object's methods. @@ -188,7 +190,7 @@ public class SceneBuilder { public void showBasePlate() { world.showSection( scene.getSceneBuildingUtil().select.cuboid(new BlockPos(scene.basePlateOffsetX, 0, scene.basePlateOffsetZ), - new Vector3i(scene.basePlateSize - 1, 0, scene.basePlateSize - 1)), + new Vec3i(scene.basePlateSize - 1, 0, scene.basePlateSize - 1)), Direction.UP); } @@ -272,7 +274,7 @@ public class SceneBuilder { public class EffectInstructions { - public void emitParticles(Vector3d location, Emitter emitter, float amountPerCycle, int cycles) { + public void emitParticles(Vec3 location, Emitter emitter, float amountPerCycle, int cycles) { addInstruction(new EmitParticlesInstruction(location, emitter, amountPerCycle, cycles)); } @@ -283,7 +285,7 @@ public class SceneBuilder { private void rotationIndicator(BlockPos pos, boolean direction) { addInstruction(scene -> { BlockState blockState = scene.world.getBlockState(pos); - TileEntity tileEntity = scene.world.getBlockEntity(pos); + BlockEntity tileEntity = scene.world.getBlockEntity(pos); if (!(blockState.getBlock() instanceof KineticBlock)) return; @@ -300,7 +302,7 @@ public class SceneBuilder { int particleSpeed = speedLevel.getParticleSpeed(); particleSpeed *= Math.signum(speed); - Vector3d location = VecHelper.getCenterOf(pos); + Vec3 location = VecHelper.getCenterOf(pos); RotationIndicatorParticleData particleData = new RotationIndicatorParticleData(color, particleSpeed, kb.getParticleInitialRadius(), kb.getParticleTargetRadius(), 20, rotationAxis.name() .charAt(0)); @@ -327,9 +329,9 @@ public class SceneBuilder { } public void createRedstoneParticles(BlockPos pos, int color, int amount) { - Vector3d rgb = Color.vectorFromRGB(color); + Vec3 rgb = Color.vectorFromRGB(color); addInstruction(new EmitParticlesInstruction(VecHelper.getCenterOf(pos), Emitter.withinBlockSpace( - new RedstoneParticleData((float) rgb.x, (float) rgb.y, (float) rgb.z, 1), Vector3d.ZERO), amount, 2)); + new DustParticleOptions((float) rgb.x, (float) rgb.y, (float) rgb.z, 1), Vec3.ZERO), amount, 2)); } } @@ -352,7 +354,7 @@ public class SceneBuilder { addInstruction(new ShowInputInstruction(element.clone(), duration)); } - public void chaseBoundingBoxOutline(PonderPalette color, Object slot, AxisAlignedBB boundingBox, int duration) { + public void chaseBoundingBoxOutline(PonderPalette color, Object slot, AABB boundingBox, int duration) { addInstruction(new ChaseAABBInstruction(color, slot, boundingBox, duration)); } @@ -360,30 +362,30 @@ public class SceneBuilder { showScrollInput(scene.getSceneBuildingUtil().vector.blockSurface(pos, side), side, duration); } - public void showScrollInput(Vector3d location, Direction side, int duration) { + public void showScrollInput(Vec3 location, Direction side, int duration) { Axis axis = side.getAxis(); float s = 1 / 16f; float q = 1 / 4f; - Vector3d expands = new Vector3d(axis == Axis.X ? s : q, axis == Axis.Y ? s : q, axis == Axis.Z ? s : q); + Vec3 expands = new Vec3(axis == Axis.X ? s : q, axis == Axis.Y ? s : q, axis == Axis.Z ? s : q); addInstruction(new HighlightValueBoxInstruction(location, expands, duration)); } public void showRepeaterScrollInput(BlockPos pos, int duration) { float s = 1 / 16f; float q = 1 / 6f; - Vector3d expands = new Vector3d(q, s, q); + Vec3 expands = new Vec3(q, s, q); addInstruction( new HighlightValueBoxInstruction(scene.getSceneBuildingUtil().vector.blockSurface(pos, Direction.DOWN) .add(0, 3 / 16f, 0), expands, duration)); } - public void showFilterSlotInput(Vector3d location, int duration) { + public void showFilterSlotInput(Vec3 location, int duration) { float s = .1f; - Vector3d expands = new Vector3d(s, s, s); + Vec3 expands = new Vec3(s, s, s); addInstruction(new HighlightValueBoxInstruction(location, expands, duration)); } - public void showLine(PonderPalette color, Vector3d start, Vector3d end, int duration) { + public void showLine(PonderPalette color, Vec3 start, Vec3 end, int duration) { addInstruction(new LineInstruction(color, start, end, duration)); } @@ -404,7 +406,7 @@ public class SceneBuilder { .add(0, 0.5, 0), () -> new SpinOnComponentPose(pos)); } - public ElementLink createBirb(Vector3d location, Supplier pose) { + public ElementLink createBirb(Vec3 location, Supplier pose) { ElementLink link = new ElementLink<>(ParrotElement.class); ParrotElement parrot = ParrotElement.create(location, pose); addInstruction(new CreateParrotInstruction(10, Direction.DOWN, parrot)); @@ -417,7 +419,7 @@ public class SceneBuilder { .setPose(pose.get())); } - public void movePointOfInterest(Vector3d location) { + public void movePointOfInterest(Vec3 location) { addInstruction(new MovePoiInstruction(location)); } @@ -428,14 +430,14 @@ public class SceneBuilder { public void rotateParrot(ElementLink link, double xRotation, double yRotation, double zRotation, int duration) { addInstruction( - AnimateParrotInstruction.rotate(link, new Vector3d(xRotation, yRotation, zRotation), duration)); + AnimateParrotInstruction.rotate(link, new Vec3(xRotation, yRotation, zRotation), duration)); } - public void moveParrot(ElementLink link, Vector3d offset, int duration) { + public void moveParrot(ElementLink link, Vec3 offset, int duration) { addInstruction(AnimateParrotInstruction.move(link, offset, duration)); } - public ElementLink createCart(Vector3d location, float angle, MinecartConstructor type) { + public ElementLink createCart(Vec3 location, float angle, MinecartConstructor type) { ElementLink link = new ElementLink<>(MinecartElement.class); MinecartElement cart = new MinecartElement(location, angle, type); addInstruction(new CreateMinecartInstruction(10, Direction.DOWN, cart)); @@ -447,7 +449,7 @@ public class SceneBuilder { addInstruction(AnimateMinecartInstruction.rotate(link, yRotation, duration)); } - public void moveCart(ElementLink link, Vector3d offset, int duration) { + public void moveCart(ElementLink link, Vec3 offset, int duration) { addInstruction(AnimateMinecartInstruction.move(link, offset, duration)); } @@ -549,20 +551,20 @@ public class SceneBuilder { public void rotateSection(ElementLink link, double xRotation, double yRotation, double zRotation, int duration) { addInstruction( - AnimateWorldSectionInstruction.rotate(link, new Vector3d(xRotation, yRotation, zRotation), duration)); + AnimateWorldSectionInstruction.rotate(link, new Vec3(xRotation, yRotation, zRotation), duration)); } - public void configureCenterOfRotation(ElementLink link, Vector3d anchor) { + public void configureCenterOfRotation(ElementLink link, Vec3 anchor) { addInstruction(scene -> scene.resolve(link) .setCenterOfRotation(anchor)); } - public void configureStabilization(ElementLink link, Vector3d anchor) { + public void configureStabilization(ElementLink link, Vec3 anchor) { addInstruction(scene -> scene.resolve(link) .stabilizeRotation(anchor)); } - public void moveSection(ElementLink link, Vector3d offset, int duration) { + public void moveSection(ElementLink link, Vec3 offset, int duration) { addInstruction(AnimateWorldSectionInstruction.move(link, offset, duration)); } @@ -639,7 +641,7 @@ public class SceneBuilder { }); } - public ElementLink createEntity(Function factory) { + public ElementLink createEntity(Function factory) { ElementLink link = new ElementLink<>(EntityElement.class, UUID.randomUUID()); addInstruction(scene -> { PonderWorld world = scene.getWorld(); @@ -652,7 +654,7 @@ public class SceneBuilder { return link; } - public ElementLink createItemEntity(Vector3d location, Vector3d motion, ItemStack stack) { + public ElementLink createItemEntity(Vec3 location, Vec3 motion, ItemStack stack) { return createEntity(world -> { ItemEntity itemEntity = new ItemEntity(world, location.x, location.y, location.z, stack); itemEntity.setDeltaMovement(motion); @@ -668,7 +670,7 @@ public class SceneBuilder { public void createItemOnBeltLike(BlockPos location, Direction insertionSide, ItemStack stack) { addInstruction(scene -> { PonderWorld world = scene.getWorld(); - TileEntity tileEntity = world.getBlockEntity(location); + BlockEntity tileEntity = world.getBlockEntity(location); if (!(tileEntity instanceof SmartTileEntity)) return; SmartTileEntity beltTileEntity = (SmartTileEntity) tileEntity; @@ -685,7 +687,7 @@ public class SceneBuilder { ElementLink link = new ElementLink<>(BeltItemElement.class); addInstruction(scene -> { PonderWorld world = scene.getWorld(); - TileEntity tileEntity = world.getBlockEntity(beltLocation); + BlockEntity tileEntity = world.getBlockEntity(beltLocation); if (!(tileEntity instanceof BeltTileEntity)) return; @@ -713,7 +715,7 @@ public class SceneBuilder { public void removeItemsFromBelt(BlockPos beltLocation) { addInstruction(scene -> { PonderWorld world = scene.getWorld(); - TileEntity tileEntity = world.getBlockEntity(beltLocation); + BlockEntity tileEntity = world.getBlockEntity(beltLocation); if (!(tileEntity instanceof SmartTileEntity)) return; SmartTileEntity beltTileEntity = (SmartTileEntity) tileEntity; @@ -763,27 +765,27 @@ public class SceneBuilder { modifyTileEntity(pos, PumpTileEntity.class, te -> te.onSpeedChanged(0)); } - public void setFilterData(Selection selection, Class teType, ItemStack filter) { + public void setFilterData(Selection selection, Class teType, ItemStack filter) { modifyTileNBT(selection, teType, nbt -> { nbt.put("Filter", filter.serializeNBT()); }); } - public void modifyTileNBT(Selection selection, Class teType, - Consumer consumer) { + public void modifyTileNBT(Selection selection, Class teType, + Consumer consumer) { modifyTileNBT(selection, teType, consumer, false); } - public void modifyTileEntity(BlockPos position, Class teType, Consumer consumer) { + public void modifyTileEntity(BlockPos position, Class teType, Consumer consumer) { addInstruction(scene -> { - TileEntity tileEntity = scene.world.getBlockEntity(position); + BlockEntity tileEntity = scene.world.getBlockEntity(position); if (teType.isInstance(tileEntity)) consumer.accept(teType.cast(tileEntity)); }); } - public void modifyTileNBT(Selection selection, Class teType, - Consumer consumer, boolean reDrawBlocks) { + public void modifyTileNBT(Selection selection, Class teType, + Consumer consumer, boolean reDrawBlocks) { addInstruction(new TileEntityDataInstruction(selection, teType, nbt -> { consumer.accept(nbt); return nbt; 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 3af92af68..1b61211d1 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuildingUtil.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuildingUtil.java @@ -2,11 +2,11 @@ package com.simibubi.create.foundation.ponder; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; /** * Helpful shortcuts for marking boundaries, points or sections inside the scene @@ -17,9 +17,9 @@ public class SceneBuildingUtil { public final VectorUtil vector; public final PositionUtil grid; - private final MutableBoundingBox sceneBounds; + private final BoundingBox sceneBounds; - SceneBuildingUtil(MutableBoundingBox sceneBounds) { + SceneBuildingUtil(BoundingBox sceneBounds) { this.sceneBounds = sceneBounds; this.select = new SelectionUtil(); this.vector = new VectorUtil(); @@ -40,33 +40,33 @@ public class SceneBuildingUtil { public class VectorUtil { - public Vector3d centerOf(int x, int y, int z) { + public Vec3 centerOf(int x, int y, int z) { return centerOf(grid.at(x, y, z)); } - public Vector3d centerOf(BlockPos pos) { + public Vec3 centerOf(BlockPos pos) { return VecHelper.getCenterOf(pos); } - public Vector3d topOf(int x, int y, int z) { + public Vec3 topOf(int x, int y, int z) { return blockSurface(grid.at(x, y, z), Direction.UP); } - public Vector3d topOf(BlockPos pos) { + public Vec3 topOf(BlockPos pos) { return blockSurface(pos, Direction.UP); } - public Vector3d blockSurface(BlockPos pos, Direction face) { + public Vec3 blockSurface(BlockPos pos, Direction face) { return blockSurface(pos, face, 0); } - public Vector3d blockSurface(BlockPos pos, Direction face, float margin) { - return centerOf(pos).add(Vector3d.atLowerCornerOf(face.getNormal()) + public Vec3 blockSurface(BlockPos pos, Direction face, float margin) { + return centerOf(pos).add(Vec3.atLowerCornerOf(face.getNormal()) .scale(.5f + margin)); } - public Vector3d of(double x, double y, double z) { - return new Vector3d(x, y, z); + public Vec3 of(double x, double y, double z) { + return new Vec3(x, y, z); } } @@ -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.getYSpan(), 0)); + return cuboid(new BlockPos(x, 1, z), new Vec3i(0, sceneBounds.getYSpan(), 0)); } public Selection layer(int y) { @@ -106,12 +106,12 @@ public class SceneBuildingUtil { } public Selection layers(int y, int height) { - return cuboid(new BlockPos(0, y, 0), new Vector3i(sceneBounds.getXSpan() - 1, + return cuboid(new BlockPos(0, y, 0), new Vec3i(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.offset(size))); + public Selection cuboid(BlockPos origin, Vec3i size) { + return Selection.of(new BoundingBox(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 f0885bce1..3d931bb55 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/Selection.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/Selection.java @@ -8,14 +8,14 @@ import java.util.function.Predicate; import com.simibubi.create.foundation.utility.outliner.Outline.OutlineParams; import com.simibubi.create.foundation.utility.outliner.Outliner; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.phys.Vec3; public abstract class Selection implements Predicate { - public static Selection of(MutableBoundingBox bb) { + public static Selection of(BoundingBox bb) { return new Simple(bb); } @@ -25,7 +25,7 @@ public abstract class Selection implements Predicate { public abstract Selection copy(); - public abstract Vector3d getCenter(); + public abstract Vec3 getCenter(); public abstract void forEach(Consumer callback); @@ -38,7 +38,7 @@ public abstract class Selection implements Predicate { private static class Compound extends Selection { Set posSet; - Vector3d center; + Vec3 center; public Compound(Simple initial) { posSet = new HashSet<>(); @@ -79,18 +79,18 @@ public abstract class Selection implements Predicate { } @Override - public Vector3d getCenter() { + public Vec3 getCenter() { return center == null ? center = evalCenter() : center; } - private Vector3d evalCenter() { - Vector3d center = Vector3d.ZERO; + private Vec3 evalCenter() { + Vec3 center = Vec3.ZERO; if (posSet.isEmpty()) return center; for (BlockPos blockPos : posSet) - center = center.add(Vector3d.atLowerCornerOf(blockPos)); + center = center.add(Vec3.atLowerCornerOf(blockPos)); center = center.scale(1f / posSet.size()); - return center.add(new Vector3d(.5, .5, .5)); + return center.add(new Vec3(.5, .5, .5)); } @Override @@ -102,10 +102,10 @@ public abstract class Selection implements Predicate { private static class Simple extends Selection { - private MutableBoundingBox bb; - private AxisAlignedBB aabb; + private BoundingBox bb; + private AABB aabb; - public Simple(MutableBoundingBox bb) { + public Simple(BoundingBox bb) { this.bb = bb; this.aabb = getAABB(); } @@ -132,7 +132,7 @@ public abstract class Selection implements Predicate { } @Override - public Vector3d getCenter() { + public Vec3 getCenter() { return aabb.getCenter(); } @@ -141,13 +141,13 @@ public abstract class Selection implements Predicate { return outliner.showAABB(slot, aabb); } - private AxisAlignedBB getAABB() { - return new AxisAlignedBB(bb.x0, bb.y0, bb.z0, bb.x1 + 1, bb.y1 + 1, bb.z1 + 1); + private AABB getAABB() { + return new AABB(bb.x0, bb.y0, bb.z0, bb.x1 + 1, bb.y1 + 1, bb.z1 + 1); } @Override public Selection copy() { - return new Simple(new MutableBoundingBox(bb)); + return new Simple(new BoundingBox(bb)); } } 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 4ba0e1116..639b6403f 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 @@ -14,13 +14,13 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class ArmScenes { @@ -33,8 +33,8 @@ public class ArmScenes { BlockPos armPos = util.grid.at(2, 1, 2); Selection armSel = util.select.position(armPos); BlockPos inputDepot = util.grid.at(4, 2, 1); - Vector3d depotSurface = util.vector.blockSurface(inputDepot, Direction.NORTH); - Vector3d armSurface = util.vector.blockSurface(armPos, Direction.WEST); + Vec3 depotSurface = util.vector.blockSurface(inputDepot, Direction.NORTH); + Vec3 armSurface = util.vector.blockSurface(armPos, Direction.WEST); scene.idle(20); @@ -56,7 +56,7 @@ public class ArmScenes { scene.overlay.showControls(new InputWindowElement(depotSurface, Pointing.RIGHT).rightClick() .withItem(armItem), 50); scene.idle(7); - AxisAlignedBB depotBounds = AllShapes.DEPOT.bounds(); + AABB depotBounds = AllShapes.DEPOT.bounds(); scene.overlay.chaseBoundingBoxOutline(PonderPalette.INPUT, new Object(), depotBounds.move(4, 2, 1), 400); scene.overlay.showText(70) @@ -104,7 +104,7 @@ public class ArmScenes { scene.world.showSection(armSel, Direction.DOWN); scene.idle(10); - Vector3d armTop = armSurface.add(0.5, 1.5, 0); + Vec3 armTop = armSurface.add(0.5, 1.5, 0); scene.overlay.showText(70) .attachKeyFrame() .colored(PonderPalette.GREEN) @@ -188,8 +188,8 @@ public class ArmScenes { Object in = new Object(); Object out = new Object(); - 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); + AABB chestBounds = new AABB(1 / 16f, 0, 1 / 16f, 15 / 16f, 14 / 16f, 15 / 16f); + AABB funnelBounds = new AABB(0, 0, 8 / 16f, 16 / 16f, 16 / 16f, 16 / 16f); scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, in, chestBounds.move(4, 2, 3), 120); scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, out, chestBounds.move(0, 2, 3), 120); @@ -302,7 +302,7 @@ public class ArmScenes { scene.idle(2); } - Vector3d filterSlot = util.vector.of(3.5, 3.75, 2.6); + Vec3 filterSlot = util.vector.of(3.5, 3.75, 2.6); scene.overlay.showFilterSlotInput(filterSlot, 80); scene.idle(10); scene.overlay.showText(80) @@ -392,8 +392,8 @@ public class ArmScenes { scene.world.showSection(util.select.fromTo(1, 1, 1, 5, 1, 2), Direction.SOUTH); scene.idle(10); - AxisAlignedBB depotBox = AllShapes.DEPOT.bounds(); - AxisAlignedBB beltBox = depotBox.contract(0, -3 / 16f, 0) + AABB depotBox = AllShapes.DEPOT.bounds(); + AABB beltBox = depotBox.contract(0, -3 / 16f, 0) .inflate(1, 0, 0); BlockPos depotPos = util.grid.at(1, 1, 4); BlockPos armPos = util.grid.at(3, 1, 4); @@ -424,7 +424,7 @@ public class ArmScenes { .colored(PonderPalette.OUTPUT); scene.idle(70); - Vector3d scrollSlot = util.vector.of(3.5, 1.25, 4); + Vec3 scrollSlot = util.vector.of(3.5, 1.25, 4); scene.overlay.showFilterSlotInput(scrollSlot, 120); scene.overlay.showText(50) .text("...it will act according to its setting") 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 394241ae8..682987bfd 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 @@ -13,14 +13,14 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.entity.Entity; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class BearingScenes { @@ -122,7 +122,7 @@ public class BearingScenes { .text("The Amount of Sail Blocks determine its Rotation Speed"); scene.idle(90); - Vector3d surface = util.vector.blockSurface(windmill, Direction.WEST); + Vec3 surface = util.vector.blockSurface(windmill, Direction.WEST); scene.overlay.showControls(new InputWindowElement(surface, Pointing.DOWN).scroll() .withWrench(), 60); scene.overlay.showCenteredScrollInput(windmill, Direction.WEST, 50); @@ -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.below()); + Vec3 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); 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 aabb1480d..0f6e1779d 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 @@ -27,17 +27,17 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class BeltScenes { @@ -58,9 +58,9 @@ public class BeltScenes { BlockPos backEnd = util.grid.at(4, 1, 2); BlockPos frontEnd = util.grid.at(0, 1, 2); ItemStack beltItem = AllItems.BELT_CONNECTOR.asStack(); - Vector3d backEndCenter = util.vector.centerOf(backEnd); - AxisAlignedBB connectBB = new AxisAlignedBB(backEndCenter, backEndCenter); - AxisAlignedBB shaftBB = AllBlocks.SHAFT.getDefaultState() + Vec3 backEndCenter = util.vector.centerOf(backEnd); + AABB connectBB = new AABB(backEndCenter, backEndCenter); + AABB shaftBB = AllBlocks.SHAFT.getDefaultState() .setValue(ShaftBlock.AXIS, Axis.Z) .getShape(null, null) .bounds(); @@ -92,7 +92,7 @@ public class BeltScenes { .pointAt(util.vector.topOf(2, 1, 2)); scene.idle(90); - Vector3d falseSelection = util.vector.topOf(backEnd.south(1)); + Vec3 falseSelection = util.vector.topOf(backEnd.south(1)); scene.overlay.showControls(new InputWindowElement(falseSelection, Pointing.DOWN).rightClick() .withItem(beltItem), 37); scene.idle(7); @@ -188,8 +188,8 @@ public class BeltScenes { scene.idle(20); - Vector3d from = util.vector.centerOf(3, 1, 2); - Vector3d to = util.vector.centerOf(1, 2, 2); + Vec3 from = util.vector.centerOf(3, 1, 2); + Vec3 to = util.vector.centerOf(1, 2, 2); scene.overlay.showLine(PonderPalette.RED, from, to, 70); scene.idle(10); @@ -376,7 +376,7 @@ public class BeltScenes { scene.world.modifyEntities(ItemEntity.class, Entity::remove); scene.special.movePointOfInterest(util.grid.at(2, 5, 4)); - Vector3d topOf = util.vector.topOf(util.grid.at(3, 2, 2)) + Vec3 topOf = util.vector.topOf(util.grid.at(3, 2, 2)) .add(-0.1, 0.3, 0); scene.overlay.showControls(new InputWindowElement(topOf, Pointing.DOWN).rightClick(), 60); scene.idle(10); @@ -487,7 +487,7 @@ public class BeltScenes { BlockPos depotPos = util.grid.at(2, 1, 2); scene.world.showSection(util.select.position(2, 1, 2), Direction.DOWN); - Vector3d topOf = util.vector.topOf(depotPos); + Vec3 topOf = util.vector.topOf(depotPos); scene.overlay.showText(60) .attachKeyFrame() .text("Depots can serve as 'stationary' belt elements") @@ -541,7 +541,7 @@ public class BeltScenes { .west(); ItemStack copper = AllItems.COPPER_INGOT.asStack(); scene.world.createItemOnBeltLike(depotPos, Direction.NORTH, copper); - Vector3d depotCenter = util.vector.centerOf(depotPos); + Vec3 depotCenter = util.vector.centerOf(depotPos); scene.idle(10); Class type = MechanicalPressTileEntity.class; 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 046cde559..c691dedbe 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 @@ -15,18 +15,18 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.ponder.instructions.EmitParticlesInstruction.Emitter; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.minecart.ChestMinecartEntity; -import net.minecraft.entity.item.minecart.FurnaceMinecartEntity; -import net.minecraft.entity.item.minecart.MinecartEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.state.properties.RailShape; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.vehicle.MinecartChest; +import net.minecraft.world.entity.vehicle.MinecartFurnace; +import net.minecraft.world.entity.vehicle.Minecart; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class CartAssemblerScenes { @@ -71,7 +71,7 @@ public class CartAssemblerScenes { scene.idle(80); ElementLink cart = - scene.special.createCart(util.vector.topOf(2, 0, 4), 90, MinecartEntity::new); + scene.special.createCart(util.vector.topOf(2, 0, 4), 90, Minecart::new); scene.world.showSection(util.select.position(assemblerPos.above()), Direction.DOWN); scene.idle(10); scene.special.moveCart(cart, util.vector.of(0, 0, -2), 20); @@ -138,7 +138,7 @@ public class CartAssemblerScenes { scene.special.moveCart(cart, util.vector.of(0, 0, -2), 20); scene.idle(25); - Vector3d cartCenter = util.vector.centerOf(assemblerPos.north(2)); + Vec3 cartCenter = util.vector.centerOf(assemblerPos.north(2)); scene.overlay.showControls(new InputWindowElement(cartCenter, Pointing.LEFT).rightClick() .withWrench(), 40); scene.idle(7); @@ -200,7 +200,7 @@ public class CartAssemblerScenes { scene.idle(10); ElementLink cart = - scene.special.createCart(util.vector.topOf(util.grid.at(4, 0, 3)), 0, MinecartEntity::new); + scene.special.createCart(util.vector.topOf(util.grid.at(4, 0, 3)), 0, Minecart::new); scene.idle(20); scene.special.moveCart(cart, util.vector.of(-1, 0, 0), 10); scene.idle(10); @@ -247,7 +247,7 @@ public class CartAssemblerScenes { scene.special.hideElement(cart, Direction.UP); scene.idle(25); - Vector3d blockSurface = util.vector.blockSurface(assemblerPos, Direction.NORTH) + Vec3 blockSurface = util.vector.blockSurface(assemblerPos, Direction.NORTH) .add(0, 0, -2 / 16f); scene.overlay.showScrollInput(blockSurface, Direction.NORTH, 60); scene.overlay.showControls(new InputWindowElement(blockSurface, Pointing.DOWN).scroll() @@ -260,7 +260,7 @@ public class CartAssemblerScenes { scene.idle(70); contraption = scene.world.showIndependentSection(util.select.fromTo(3, 2, 3, 2, 2, 3), Direction.DOWN); - cart = scene.special.createCart(util.vector.topOf(util.grid.at(4, 0, 3)), 0, MinecartEntity::new); + cart = scene.special.createCart(util.vector.topOf(util.grid.at(4, 0, 3)), 0, Minecart::new); scene.idle(10); scene.special.moveCart(cart, util.vector.of(-1, 0, 0), 10); scene.idle(10); @@ -317,9 +317,9 @@ 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.below()), 0, MinecartEntity::new); + scene.special.createCart(util.vector.topOf(assembler1.below()), 0, Minecart::new); ElementLink cart2 = - scene.special.createCart(util.vector.topOf(assembler2.below()), 0, ChestMinecartEntity::new); + scene.special.createCart(util.vector.topOf(assembler2.below()), 0, MinecartChest::new); scene.idle(15); scene.world.setBlock(assembler1, AllBlocks.CART_ASSEMBLER.getDefaultState() .setValue(CartAssemblerBlock.RAIL_SHAPE, RailShape.EAST_WEST) @@ -356,7 +356,7 @@ public class CartAssemblerScenes { scene.world.configureCenterOfRotation(contraption, util.vector.centerOf(util.grid.at(2, 2, 4))); scene.idle(5); - Vector3d m = util.vector.of(-0.5, 0, 0); + Vec3 m = util.vector.of(-0.5, 0, 0); scene.special.moveCart(cart, m, 5); scene.special.moveCart(cart2, m, 5); scene.world.moveSection(contraption, m, 5); @@ -434,7 +434,7 @@ public class CartAssemblerScenes { scene.idle(70); ElementLink cart = scene.special.createCart(util.vector.topOf(assembler.east(2) - .below()), 0, MinecartEntity::new); + .below()), 0, Minecart::new); ElementLink anchor = scene.world.showIndependentSection(util.select.position(assembler.south()), Direction.DOWN); ElementLink contraption = @@ -467,7 +467,7 @@ public class CartAssemblerScenes { scene.world.hideIndependentSection(anchor, Direction.DOWN); cart = scene.special.createCart(util.vector.topOf(assembler.east(2) - .below()), 0, MinecartEntity::new); + .below()), 0, Minecart::new); anchor = scene.world.showIndependentSection(util.select.position(assembler.south()), Direction.DOWN); contraption = scene.world.showIndependentSection(util.select.position(assembler.south() .above()), Direction.DOWN); @@ -495,7 +495,7 @@ public class CartAssemblerScenes { scene.idle(20); cart = scene.special.createCart(util.vector.topOf(assembler.east(2) - .below()), 0, FurnaceMinecartEntity::new); + .below()), 0, MinecartFurnace::new); scene.idle(10); scene.overlay.showText(50) .attachKeyFrame() @@ -528,7 +528,7 @@ public class CartAssemblerScenes { scene.world.moveSection(contraption, util.vector.of(-3, 0, 0), 30); scene.world.moveSection(anchor, util.vector.of(-3, 0, 0), 30); - Vector3d vec = util.vector.centerOf(assembler) + Vec3 vec = util.vector.centerOf(assembler) .add(.25, .25, -0.5); for (int i = 0; i < 7; i++) { scene.effects.emitParticles(vec = vec.add(-.5, 0, 0), smoke, 2, 1); 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 8ece78aac..28574d13f 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 @@ -11,11 +11,11 @@ import com.simibubi.create.foundation.ponder.elements.TextWindowElement.Builder; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; public class ChainDriveScenes { @@ -149,7 +149,7 @@ public class ChainDriveScenes { scene.idle(10); - AxisAlignedBB bb = new AxisAlignedBB(eastDrive); + AABB bb = new AABB(eastDrive); scene.overlay.chaseBoundingBoxOutline(PonderPalette.MEDIUM, eastDrive, bb, 160); scene.overlay.chaseBoundingBoxOutline(PonderPalette.FAST, eastDrive.west(), bb.move(-2, 0, 0) .expandTowards(15 / 16f, 0, 0), 160); @@ -195,7 +195,7 @@ public class ChainDriveScenes { scene.idle(10); - bb = new AxisAlignedBB(eastDrive); + bb = new AABB(eastDrive); 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); @@ -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.setValue(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 831e857a8..61ee38a72 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 @@ -14,13 +14,13 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class ChassisScenes { @@ -179,7 +179,7 @@ public class ChassisScenes { scene.world.rotateSection(topGlassSection, 0, 180, 0, 40); scene.idle(50); - Vector3d blockSurface = util.vector.blockSurface(chassisPos, Direction.NORTH); + Vec3 blockSurface = util.vector.blockSurface(chassisPos, Direction.NORTH); scene.overlay.showCenteredScrollInput(chassisPos, Direction.NORTH, 50); scene.overlay.showControls(new InputWindowElement(blockSurface, Pointing.UP).scroll() .withWrench(), 50); @@ -242,7 +242,7 @@ public class ChassisScenes { scene.world.rotateSection(topGlassSection, 0, 180, 0, 40); scene.idle(50); - Vector3d glueSurface = util.vector.blockSurface(chassisPos.west(), Direction.NORTH); + Vec3 glueSurface = util.vector.blockSurface(chassisPos.west(), Direction.NORTH); scene.overlay.showText(80) .attachKeyFrame() .pointAt(glueSurface) @@ -406,8 +406,8 @@ public class ChassisScenes { .substract(r1), Direction.DOWN); 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).inflate(.501, .501, 0); + Vec3 blockSurface = util.vector.blockSurface(chassisPos, Direction.NORTH); + AABB bb = new AABB(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) @@ -494,7 +494,7 @@ public class ChassisScenes { ElementLink plank = scene.world.showIndependentSection(util.select.position(central), Direction.DOWN); scene.idle(15); - Vector3d blockSurface = util.vector.blockSurface(central, Direction.NORTH); + Vec3 blockSurface = util.vector.blockSurface(central, Direction.NORTH); scene.overlay.showControls(new InputWindowElement(blockSurface, Pointing.DOWN).rightClick() .withItem(AllItems.SUPER_GLUE.asStack()), 40); scene.idle(7); 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 766f6beb5..ce1fa9973 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 @@ -16,14 +16,14 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class ChuteScenes { @@ -121,7 +121,7 @@ public class ChuteScenes { for (int i = 0; i < 3; i++) { remove = scene.world.createItemEntity(util.vector.centerOf(util.grid.at(2, 6, 3) .relative(offset)), util.vector.of(0, 0.1, 0) - .add(Vector3d.atLowerCornerOf(offset.getNormal()).scale(-.1)), + .add(Vec3.atLowerCornerOf(offset.getNormal()).scale(-.1)), stack); scene.idle(12); scene.world.createItemOnBeltLike(util.grid.at(2, 4, 3), Direction.UP, stack); @@ -151,7 +151,7 @@ public class ChuteScenes { scene.world.showSection(chute, Direction.DOWN); scene.idle(20); scene.world.setKineticSpeed(util.select.position(1, 1, 2), 0); - Vector3d surface = util.vector.blockSurface(util.grid.at(1, 2, 2), Direction.WEST); + Vec3 surface = util.vector.blockSurface(util.grid.at(1, 2, 2), Direction.WEST); scene.overlay.showText(70) .text("Using Encased Fans at the top or bottom, a Chute can move items upward") .attachKeyFrame() @@ -210,7 +210,7 @@ public class ChuteScenes { .placeNearTarget(); scene.idle(70); - Vector3d filter = util.vector.blockSurface(smarty, Direction.NORTH) + Vec3 filter = util.vector.blockSurface(smarty, Direction.NORTH) .add(0, 0.25, 0); scene.overlay.showFilterSlotInput(filter, 60); ItemStack copper = new ItemStack(Items.IRON_INGOT); 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 14a0e2cf9..4b8647583 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 @@ -16,14 +16,14 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.items.ItemHandlerHelper; public class CrafterScenes { @@ -105,12 +105,12 @@ public class CrafterScenes { for (Couple c : couples) { scene.idle(5); - Vector3d p1 = util.vector.blockSurface(c.getFirst(), Direction.NORTH) + Vec3 p1 = util.vector.blockSurface(c.getFirst(), Direction.NORTH) .add(0, 0, -0.125); - Vector3d p2 = util.vector.blockSurface(c.getSecond(), Direction.NORTH) + Vec3 p2 = util.vector.blockSurface(c.getSecond(), Direction.NORTH) .add(0, 0, -0.125); - AxisAlignedBB point = new AxisAlignedBB(p1, p1); - AxisAlignedBB line = new AxisAlignedBB(p1, p2); + AABB point = new AABB(p1, p1); + AABB line = new AABB(p1, p2); scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, p1, point, 2); scene.idle(1); scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, p1, line, 30); @@ -279,8 +279,8 @@ public class CrafterScenes { scene.rotateCameraY(-60 - 90 - 30); scene.idle(40); - Vector3d v = util.vector.blockSurface(util.grid.at(2, 2, 2), Direction.WEST); - AxisAlignedBB bb = new AxisAlignedBB(v, v).inflate(.125f, .5, .5); + Vec3 v = util.vector.blockSurface(util.grid.at(2, 2, 2), Direction.WEST); + AABB bb = new AABB(v, v).inflate(.125f, .5, .5); v = v.add(0, 0, .5); scene.overlay.chaseBoundingBoxOutline(PonderPalette.WHITE, new Object(), bb, 45); 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 d682bb774..62590fe8d 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 @@ -18,16 +18,16 @@ import com.simibubi.create.foundation.ponder.instructions.EmitParticlesInstructi import com.simibubi.create.foundation.utility.Pointing; import com.tterrag.registrate.util.entry.ItemEntry; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class DebugScenes { @@ -108,24 +108,24 @@ public class DebugScenes { scene.title("debug_fluids", "Showing Fluids"); scene.showBasePlate(); scene.idle(10); - Vector3d parrotPos = util.vector.topOf(1, 0, 1); + Vec3 parrotPos = util.vector.topOf(1, 0, 1); scene.special.createBirb(parrotPos, FacePointOfInterestPose::new); scene.world.showSection(util.select.layersFrom(1), Direction.DOWN); scene.overlay.showText(1000) .text("Fluid rendering test.") - .pointAt(new Vector3d(1, 2.5, 4.5)); + .pointAt(new Vec3(1, 2.5, 4.5)); scene.markAsFinished(); Object outlineSlot = new Object(); - Vector3d vec1 = util.vector.topOf(1, 0, 0); - Vector3d vec2 = util.vector.topOf(0, 0, 1); - AxisAlignedBB boundingBox1 = new AxisAlignedBB(vec1, vec1).expandTowards(0, 2.5, 0) + Vec3 vec1 = util.vector.topOf(1, 0, 0); + Vec3 vec2 = util.vector.topOf(0, 0, 1); + AABB boundingBox1 = new AABB(vec1, vec1).expandTowards(0, 2.5, 0) .inflate(.15, 0, .15); - AxisAlignedBB boundingBox2 = new AxisAlignedBB(vec2, vec2).expandTowards(0, .125, 0) + AABB boundingBox2 = new AABB(vec2, vec2).expandTowards(0, .125, 0) .inflate(.45, 0, .45); - Vector3d poi1 = boundingBox1.getCenter(); - Vector3d poi2 = boundingBox2.getCenter(); + Vec3 poi1 = boundingBox1.getCenter(); + Vec3 poi2 = boundingBox2.getCenter(); for (int i = 0; i < 10; i++) { scene.overlay.chaseBoundingBoxOutline(PonderPalette.RED, outlineSlot, @@ -175,7 +175,7 @@ public class DebugScenes { scene.world.showSection(util.select.layersFrom(1), Direction.DOWN); scene.idle(10); - Vector3d emitterPos = util.vector.of(2.5, 2.25, 2.5); + Vec3 emitterPos = util.vector.of(2.5, 2.25, 2.5); Emitter emitter = Emitter.simple(ParticleTypes.LAVA, util.vector.of(0, .1, 0)); Emitter rotation = Emitter.simple(new RotationIndicatorParticleData(SpeedLevel.MEDIUM.getColor(), 12, 1, 1, 20, 'Y'), @@ -222,13 +222,13 @@ public class DebugScenes { scene.idle(40); BlockPos chassis = util.grid.at(1, 1, 3); - Vector3d chassisSurface = util.vector.blockSurface(chassis, Direction.NORTH); + Vec3 chassisSurface = util.vector.blockSurface(chassis, Direction.NORTH); Object chassisValueBoxHighlight = new Object(); Object chassisEffectHighlight = new Object(); - AxisAlignedBB point = new AxisAlignedBB(chassisSurface, chassisSurface); - AxisAlignedBB expanded = point.inflate(1 / 4f, 1 / 4f, 1 / 16f); + AABB point = new AABB(chassisSurface, chassisSurface); + AABB 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); @@ -398,7 +398,7 @@ public class DebugScenes { ItemStack copperItem = AllItems.COPPER_INGOT.asStack(); for (int z = 4; z >= 2; z--) { - scene.world.createItemEntity(util.vector.centerOf(0, 4, z), Vector3d.ZERO, brassItem.copy()); + scene.world.createItemEntity(util.vector.centerOf(0, 4, z), Vec3.ZERO, brassItem.copy()); scene.idle(10); } 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 543cef424..311ecca30 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 @@ -14,18 +14,18 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.ponder.instructions.EmitParticlesInstruction.Emitter; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.passive.SheepEntity; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.particles.BlockParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.animal.Sheep; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class DeployerScenes { @@ -102,7 +102,7 @@ public class DeployerScenes { scene.idle(50); ItemStack pot = new ItemStack(Items.FLOWER_POT); - Vector3d frontVec = util.vector.blockSurface(deployerPos, Direction.WEST) + Vec3 frontVec = util.vector.blockSurface(deployerPos, Direction.WEST) .add(-.125, 0, 0); scene.overlay.showControls(new InputWindowElement(frontVec, Pointing.DOWN).rightClick() @@ -129,7 +129,7 @@ public class DeployerScenes { scene.world.showSection(util.select.position(deployerPos.above()), Direction.DOWN); ItemStack tulip = new ItemStack(Items.RED_TULIP); - Vector3d entitySpawn = util.vector.topOf(deployerPos.above(3)); + Vec3 entitySpawn = util.vector.topOf(deployerPos.above(3)); ElementLink entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), tulip); @@ -153,7 +153,7 @@ public class DeployerScenes { scene.world.hideSection(util.select.position(deployerPos.above()), Direction.EAST); scene.idle(20); - Vector3d filterSlot = frontVec.add(0.375, 0.25, 0); + Vec3 filterSlot = frontVec.add(0.375, 0.25, 0); scene.overlay.showFilterSlotInput(filterSlot, 80); scene.overlay.showText(40) .attachKeyFrame() @@ -175,9 +175,9 @@ public class DeployerScenes { scene.idle(70); ElementLink sheep = scene.world.createEntity(w -> { - SheepEntity entity = EntityType.SHEEP.create(w); + Sheep entity = EntityType.SHEEP.create(w); entity.setColor(DyeColor.PINK); - Vector3d p = util.vector.topOf(util.grid.at(1, 0, 2)); + Vec3 p = util.vector.topOf(util.grid.at(1, 0, 2)); entity.setPos(p.x, p.y, p.z); entity.xo = p.x; entity.yo = p.y; @@ -205,10 +205,10 @@ public class DeployerScenes { scene.idle(70); scene.world.moveDeployer(deployerPos, 1, 25); scene.idle(26); - scene.world.modifyEntity(sheep, e -> ((SheepEntity) e).setSheared(true)); + scene.world.modifyEntity(sheep, e -> ((Sheep) 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.defaultBlockState()), + Emitter.withinBlockSpace(new BlockParticleOption(ParticleTypes.BLOCK, Blocks.PINK_WOOL.defaultBlockState()), util.vector.of(0, 0, 0)), 25, 1); scene.world.moveDeployer(deployerPos, -1, 25); @@ -242,7 +242,7 @@ public class DeployerScenes { scene.idle(10); BlockPos deployerPos = util.grid.at(3, 1, 2); - Vector3d frontVec = util.vector.blockSurface(deployerPos, Direction.WEST) + Vec3 frontVec = util.vector.blockSurface(deployerPos, Direction.WEST) .add(-.125, 0, 0); Selection grassBlock = util.select.position(1, 1, 2); @@ -340,7 +340,7 @@ public class DeployerScenes { scene.world.modifyTileNBT(pressS, DeployerTileEntity.class, nbt -> nbt.put("HeldItem", tool.serializeNBT())); scene.idle(25); - Vector3d pressSide = util.vector.blockSurface(pressPos, Direction.WEST); + Vec3 pressSide = util.vector.blockSurface(pressPos, Direction.WEST); scene.overlay.showText(60) .pointAt(pressSide) .placeNearTarget() @@ -355,11 +355,11 @@ public class DeployerScenes { scene.idle(50); ItemStack quartz = AllItems.ROSE_QUARTZ.asStack(); scene.world.createItemOnBeltLike(depotPos, Direction.NORTH, quartz); - Vector3d depotCenter = util.vector.centerOf(depotPos.south()); + Vec3 depotCenter = util.vector.centerOf(depotPos.south()); scene.overlay.showControls(new InputWindowElement(depotCenter, Pointing.UP).withItem(quartz), 30); scene.idle(10); - Vector3d targetV = util.vector.centerOf(pressPos) + Vec3 targetV = util.vector.centerOf(pressPos) .subtract(0, 1.65, 0); scene.world.moveDeployer(pressPos, 1, 30); @@ -544,9 +544,9 @@ public class DeployerScenes { scene.world.replaceBlocks(flowers, Blocks.AIR.defaultBlockState(), false); scene.world.showSection(flowers, Direction.UP); - Vector3d frontVec = util.vector.blockSurface(deployerPos.west(3), Direction.NORTH) + Vec3 frontVec = util.vector.blockSurface(deployerPos.west(3), Direction.NORTH) .add(0, 0, -.125); - Vector3d filterSlot = frontVec.add(0, 0.25, 0.375); + Vec3 filterSlot = frontVec.add(0, 0.25, 0.375); scene.overlay.showFilterSlotInput(filterSlot, 80); scene.overlay.showText(60) .attachKeyFrame() 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 2ae78d4a9..e90cbe235 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 @@ -14,13 +14,13 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.items.ItemHandlerHelper; public class EjectorScenes { @@ -46,7 +46,7 @@ public class EjectorScenes { .withItem(asStack), 50); scene.idle(7); Object slot = new Object(); - scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, slot, new AxisAlignedBB(targetPos), 160); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, slot, new AABB(targetPos), 160); scene.overlay.showText(70) .attachKeyFrame() @@ -74,7 +74,7 @@ public class EjectorScenes { scene.idle(70); slot = new Object(); - AxisAlignedBB bb = new AxisAlignedBB(ejectorPos.west()); + AABB bb = new AABB(ejectorPos.west()); scene.overlay.chaseBoundingBoxOutline(PonderPalette.OUTPUT, slot, bb, 20); scene.idle(10); scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, slot, bb.expandTowards(-15, 15, 0), 100); @@ -150,8 +150,8 @@ public class EjectorScenes { scene.world.setBlock(targetPos, AllBlocks.ANDESITE_CASING.getDefaultState(), false); scene.world.showSection(targetS, Direction.NORTH); - Vector3d input = util.vector.of(4.8, 1 + 12 / 16f, 2.5); - Vector3d topOfSlot = input.add(0, 2 / 16f, 0); + Vec3 input = util.vector.of(4.8, 1 + 12 / 16f, 2.5); + Vec3 topOfSlot = input.add(0, 2 / 16f, 0); scene.overlay.showControls(new InputWindowElement(topOfSlot, Pointing.DOWN).scroll() .withWrench(), 60); scene.overlay.showFilterSlotInput(input, 80); @@ -252,8 +252,8 @@ public class EjectorScenes { .placeNearTarget(); scene.idle(110); - Vector3d input = util.vector.of(2.5, 1 + 12 / 16f, 2.8); - Vector3d topOfSlot = input.add(0, 2 / 16f, 0); + Vec3 input = util.vector.of(2.5, 1 + 12 / 16f, 2.8); + Vec3 topOfSlot = input.add(0, 2 / 16f, 0); scene.overlay.showControls(new InputWindowElement(topOfSlot, Pointing.DOWN).scroll() .withWrench(), 60); scene.overlay.showFilterSlotInput(input, 80); @@ -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.above(2)); + Vec3 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 cbdf38ea6..04726ca95 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 @@ -16,16 +16,16 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.ponder.instructions.EmitParticlesInstruction.Emitter; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class FanScenes { @@ -118,11 +118,11 @@ public class FanScenes { .above(2)), util.vector.of(0, 0.1, 0), stack); scene.idle(15); scene.world.modifyEntity(entityLink, e -> e.setDeltaMovement(-0.2f, 0, 0)); - Vector3d itemVec = util.vector.blockSurface(util.grid.at(1, 1, 2), Direction.EAST) + Vec3 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); scene.idle(20); - scene.effects.emitParticles(itemVec.add(0, 0.2f, 0), Emitter.simple(ParticleTypes.LARGE_SMOKE, Vector3d.ZERO), 1, + scene.effects.emitParticles(itemVec.add(0, 0.2f, 0), Emitter.simple(ParticleTypes.LARGE_SMOKE, Vec3.ZERO), 1, 60); scene.overlay.showText(80) @@ -190,7 +190,7 @@ public class FanScenes { 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); + scene.effects.emitParticles(itemVec.add(0, 0.2f, 0), Emitter.simple(ParticleTypes.SPIT, Vec3.ZERO), 1, 60); scene.overlay.showText(50) .colored(PonderPalette.WHITE) @@ -234,13 +234,13 @@ public class FanScenes { scene.world.moveSection(depot, util.vector.of(-1, -3, 0), 0); scene.world.createItemOnBeltLike(depos, Direction.NORTH, sand); scene.idle(10); - Vector3d depotTop = util.vector.topOf(2, 1, 2) + Vec3 depotTop = util.vector.topOf(2, 1, 2) .add(0, 0.25, 0); - scene.effects.emitParticles(depotTop, Emitter.simple(ParticleTypes.SPIT, Vector3d.ZERO), .5f, 30); + scene.effects.emitParticles(depotTop, Emitter.simple(ParticleTypes.SPIT, Vec3.ZERO), .5f, 30); scene.idle(30); scene.world.modifyTileNBT(util.select.position(depos), DepotTileEntity.class, nbt -> nbt.put("HeldItem", new TransportedItemStack(clay).serializeNBT())); - scene.effects.emitParticles(depotTop, Emitter.simple(ParticleTypes.SPIT, Vector3d.ZERO), .5f, 30); + scene.effects.emitParticles(depotTop, Emitter.simple(ParticleTypes.SPIT, Vec3.ZERO), .5f, 30); scene.overlay.showText(90) .pointAt(depotTop) .attachKeyFrame() @@ -258,10 +258,10 @@ public class FanScenes { ElementLink transported = scene.world.createItemOnBelt(util.grid.at(3, 3, 3), Direction.SOUTH, sand); scene.idle(60); - scene.effects.emitParticles(depotTop, Emitter.simple(ParticleTypes.SPIT, Vector3d.ZERO), .5f, 25); + scene.effects.emitParticles(depotTop, Emitter.simple(ParticleTypes.SPIT, Vec3.ZERO), .5f, 25); scene.idle(25); scene.world.changeBeltItemTo(transported, new ItemStack(Items.CLAY_BALL)); - scene.effects.emitParticles(depotTop, Emitter.simple(ParticleTypes.SPIT, Vector3d.ZERO), .5f, 25); + scene.effects.emitParticles(depotTop, Emitter.simple(ParticleTypes.SPIT, Vec3.ZERO), .5f, 25); scene.idle(60); scene.world.setKineticSpeed(util.select.position(1, 2, 4) 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 069484e61..751f537d4 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 @@ -14,18 +14,18 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeverBlock; -import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LeverBlock; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.items.ItemHandlerHelper; public class FunnelScenes { @@ -72,8 +72,8 @@ public class FunnelScenes { ElementLink independentSection = scene.world.showIndependentSection(verticalFunnel, Direction.UP); - Vector3d topItemSpawn = util.vector.centerOf(2, 6, 4); - Vector3d sideItemSpawn = util.vector.centerOf(1, 3, 4) + Vec3 topItemSpawn = util.vector.centerOf(2, 6, 4); + Vec3 sideItemSpawn = util.vector.centerOf(1, 3, 4) .add(0.15f, -0.45f, 0); ElementLink lastItemEntity = null; @@ -120,8 +120,8 @@ public class FunnelScenes { scene.idle(15); ItemStack itemStack = AllBlocks.BRASS_BLOCK.asStack(); - Vector3d topCenter = util.vector.centerOf(topFunnel); - Vector3d topSide = util.vector.blockSurface(topFunnel, Direction.EAST); + Vec3 topCenter = util.vector.centerOf(topFunnel); + Vec3 topSide = util.vector.blockSurface(topFunnel, Direction.EAST); InputWindowElement controlsSneak = new InputWindowElement(topCenter, Pointing.DOWN).rightClick() .whileSneaking(); @@ -189,7 +189,7 @@ public class FunnelScenes { // Side funnel BlockPos sideFunnel = util.grid.at(3, 2, 1); Selection sideFunnelSelection = util.select.fromTo(sideFunnel.below(), sideFunnel); - Vector3d sideCenter = util.vector.centerOf(sideFunnel); + Vec3 sideCenter = util.vector.centerOf(sideFunnel); scene.world.modifyBlock(sideFunnel, s -> s.cycle(FunnelBlock.EXTRACTING), false); scene.world.showSection(sideFunnelSelection, Direction.DOWN); @@ -212,7 +212,7 @@ public class FunnelScenes { Selection beltFunnelSetup = util.select.fromTo(0, 1, 0, 2, 2, 5); Selection gearshiftAndLever = util.select.fromTo(1, 1, 4, 1, 2, 4); Selection gearshiftedKinetics = util.select.fromTo(1, 1, 2, 2, 1, 4); - Vector3d topOfBeltFunnel = util.vector.topOf(2, 2, 2); + Vec3 topOfBeltFunnel = util.vector.topOf(2, 2, 2); BlockPos beltPos = util.grid.at(2, 1, 2); BlockPos cogPos = util.grid.at(1, 1, 3); @@ -312,14 +312,14 @@ public class FunnelScenes { scene.world.showSection(util.select.layersFrom(1), Direction.DOWN); ItemStack itemStack = AllBlocks.BRASS_BLOCK.asStack(); - Vector3d topItemSpawn = util.vector.centerOf(3, 6, 2); + Vec3 topItemSpawn = util.vector.centerOf(3, 6, 2); ElementLink lastItemEntity = null; BlockPos lever = util.grid.at(1, 2, 2); BlockPos redstone = util.grid.at(2, 2, 2); BlockPos funnel = util.grid.at(3, 2, 2); - AxisAlignedBB redstoneBB = new AxisAlignedBB(funnel).inflate(-1 / 16f, -6 / 16f, -1 / 16f) + AABB redstoneBB = new AABB(funnel).inflate(-1 / 16f, -6 / 16f, -1 / 16f) .move(0, -5 / 16f, 0); for (int i = 0; i < 4; i++) { @@ -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.setValue(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); @@ -393,7 +393,7 @@ public class FunnelScenes { scene.world.flapFunnel(brassFunnel, true); scene.idle(60); - AxisAlignedBB filterSlot = new AxisAlignedBB(brassFunnel).inflate(-.35, -.35, -.35) + AABB filterSlot = new AABB(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); 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 64e0bd06f..c512892d9 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 @@ -7,11 +7,11 @@ import com.simibubi.create.foundation.ponder.Selection; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class GantryScenes { @@ -54,7 +54,7 @@ public class GantryScenes { scene.world.hideIndependentSection(gantry, Direction.UP); scene.idle(10); gantry = scene.world.showIndependentSection(util.select.layer(2), Direction.DOWN); - Vector3d gantryTop = util.vector.topOf(4, 2, 2); + Vec3 gantryTop = util.vector.topOf(4, 2, 2); scene.world.modifyKineticSpeed(util.select.everywhere(), f -> 0f); scene.overlay.showText(40) .attachKeyFrame() @@ -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.hasProperty(RedstoneWireBlock.POWER) ? s.setValue(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 427b31083..16665b1dd 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 @@ -22,20 +22,20 @@ import com.simibubi.create.foundation.ponder.instructions.EmitParticlesInstructi import com.simibubi.create.foundation.utility.Pointing; import com.tterrag.registrate.util.entry.BlockEntry; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FurnaceBlock; -import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FurnaceBlock; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; public class KineticsScenes { @@ -76,7 +76,7 @@ public class KineticsScenes { scene.configureBasePlate(0, 0, 5); scene.showBasePlate(); - Selection shaft = util.select.cuboid(new BlockPos(0, 1, 2), new Vector3i(5, 0, 2)); + Selection shaft = util.select.cuboid(new BlockPos(0, 1, 2), new Vec3i(5, 0, 2)); Selection andesite = util.select.position(3, 1, 2); Selection brass = util.select.position(1, 1, 2); @@ -496,9 +496,9 @@ public class KineticsScenes { scene.rotateCameraY(90); scene.idle(20); - Vector3d blockSurface = util.vector.blockSurface(motor, Direction.EAST); - AxisAlignedBB point = new AxisAlignedBB(blockSurface, blockSurface); - AxisAlignedBB expanded = point.inflate(1 / 16f, 1 / 5f, 1 / 5f); + Vec3 blockSurface = util.vector.blockSurface(motor, Direction.EAST); + AABB point = new AABB(blockSurface, blockSurface); + AABB expanded = point.inflate(1 / 16f, 1 / 5f, 1 / 5f); scene.overlay.chaseBoundingBoxOutline(PonderPalette.WHITE, blockSurface, point, 1); scene.idle(1); @@ -557,7 +557,7 @@ public class KineticsScenes { .pointAt(util.vector.topOf(wheel)); scene.idle(50); - AxisAlignedBB bb = new AxisAlignedBB(wheel).inflate(.125f, 0, 0); + AABB bb = new AABB(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); @@ -636,7 +636,7 @@ public class KineticsScenes { manualSource(scene, util, false); scene.world.setKineticSpeed(util.select.everywhere(), 0); scene.idle(20); - Vector3d centerOf = util.vector.centerOf(2, 2, 2); + Vec3 centerOf = util.vector.centerOf(2, 2, 2); scene.overlay.showControls(new InputWindowElement(centerOf, Pointing.DOWN).rightClick() .withItem(new ItemStack(Items.BLUE_DYE)), 40); scene.idle(7); @@ -666,7 +666,7 @@ public class KineticsScenes { scene.world.showSection(handleSelect, Direction.DOWN); scene.idle(20); - Vector3d centerOf = util.vector.centerOf(handlePos); + Vec3 centerOf = util.vector.centerOf(handlePos); scene.overlay.showText(70) .text(name + " can be used by players to apply rotational force manually") .placeNearTarget() @@ -739,7 +739,7 @@ public class KineticsScenes { scene.world.showSection(util.select.fromTo(2, 1, 2, 1, 1, 2), Direction.EAST); scene.idle(10); - Vector3d top = util.vector.topOf(gearshiftPos); + Vec3 top = util.vector.topOf(gearshiftPos); scene.overlay.showText(60) .text("Seq. Gearshifts relay rotation by following a timed list of instructions") .attachKeyFrame() @@ -830,7 +830,7 @@ public class KineticsScenes { scene.world.showIndependentSection(util.select.fromTo(5, 1, 1, 4, 1, 0), Direction.SOUTH); scene.world.moveSection(comparator, util.vector.of(-2, 0, 0), 0); scene.world.toggleRedstonePower(util.select.position(5, 1, 1)); - scene.world.cycleBlockProperty(wire, RedstoneWireBlock.POWER); + scene.world.cycleBlockProperty(wire, RedStoneWireBlock.POWER); scene.world.modifyTileNBT(nixie, NixieTubeTileEntity.class, nbt -> nbt.putInt("RedstoneStrength", 1)); scene.idle(5); @@ -840,13 +840,13 @@ public class KineticsScenes { scene.world.rotateBearing(bearingPos, -180, 40); scene.world.rotateSection(contraption, -180, 0, 0, 40); scene.effects.rotationDirectionIndicator(gearshiftPos.west()); - scene.world.cycleBlockProperty(wire, RedstoneWireBlock.POWER); + scene.world.cycleBlockProperty(wire, RedStoneWireBlock.POWER); scene.world.modifyTileNBT(nixie, NixieTubeTileEntity.class, nbt -> nbt.putInt("RedstoneStrength", 2)); scene.idle(40); scene.world.cycleBlockProperty(gearshiftPos, SequencedGearshiftBlock.STATE); scene.world.setKineticSpeed(outputKinetics, 0); - scene.world.cycleBlockProperty(wire, RedstoneWireBlock.POWER); + scene.world.cycleBlockProperty(wire, RedStoneWireBlock.POWER); scene.world.modifyTileNBT(nixie, NixieTubeTileEntity.class, nbt -> nbt.putInt("RedstoneStrength", 3)); scene.idle(20); @@ -855,13 +855,13 @@ public class KineticsScenes { scene.world.rotateBearing(bearingPos, 90, 40); scene.world.rotateSection(contraption, 90, 0, 0, 40); scene.effects.rotationDirectionIndicator(gearshiftPos.west()); - scene.world.cycleBlockProperty(wire, RedstoneWireBlock.POWER); + scene.world.cycleBlockProperty(wire, RedStoneWireBlock.POWER); scene.world.modifyTileNBT(nixie, NixieTubeTileEntity.class, nbt -> nbt.putInt("RedstoneStrength", 4)); scene.idle(40); scene.world.cycleBlockProperty(gearshiftPos, SequencedGearshiftBlock.STATE); scene.world.cycleBlockProperty(gearshiftPos, SequencedGearshiftBlock.STATE); - scene.world.modifyBlock(wire, s -> s.setValue(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); @@ -912,7 +912,7 @@ public class KineticsScenes { .withItem(new ItemStack(Items.COAL)), 30); scene.idle(7); scene.world.cycleBlockProperty(furnacePos, FurnaceBlock.LIT); - scene.effects.emitParticles(util.vector.of(4.5, 1.2, 2.9), Emitter.simple(ParticleTypes.LAVA, Vector3d.ZERO), 4, + scene.effects.emitParticles(util.vector.of(4.5, 1.2, 2.9), Emitter.simple(ParticleTypes.LAVA, Vec3.ZERO), 4, 1); scene.world.setKineticSpeed(util.select.fromTo(1, 1, 3, 1, 1, 1), 16); scene.idle(40); @@ -995,7 +995,7 @@ public class KineticsScenes { .text("Rot. Speed Controllers relay rotation from their axis to a Large Cogwheel above them"); scene.idle(100); - Vector3d inputVec = util.vector.of(1.5, 1.75, 1); + Vec3 inputVec = util.vector.of(1.5, 1.75, 1); scene.overlay.showFilterSlotInput(inputVec, 60); scene.overlay.showText(70) @@ -1089,7 +1089,7 @@ public class KineticsScenes { scene.idle(30); - Vector3d blockSurface = util.vector.blockSurface(gaugePos, Direction.NORTH); + Vec3 blockSurface = util.vector.blockSurface(gaugePos, Direction.NORTH); scene.overlay.showControls( new InputWindowElement(blockSurface, Pointing.RIGHT).withItem(AllItems.GOGGLES.asStack()), 40); scene.idle(7); 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 6d17ab6cb..fe26ac5fe 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 @@ -9,14 +9,14 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class MechanicalDrillScenes { @@ -141,7 +141,7 @@ public class MechanicalDrillScenes { } } - Vector3d m = util.vector.of(-.1, 0, 0); + Vec3 m = util.vector.of(-.1, 0, 0); ItemStack item = new ItemStack(Items.OAK_PLANKS); scene.world.createItemEntity(util.vector.centerOf(p1), m, item); scene.world.createItemEntity(util.vector.centerOf(p2), m, item); 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 6c254844e..f452026bb 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 @@ -12,15 +12,15 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class MechanicalSawScenes { @@ -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.above() + Vec3 itemSpawn = util.vector.centerOf(sawPos.above() .west()); ElementLink logItem = scene.world.createItemEntity(itemSpawn, util.vector.of(0, 0, 0), log); scene.idle(12); @@ -140,7 +140,7 @@ public class MechanicalSawScenes { scene.rotateCameraY(-90); scene.idle(20); - Vector3d filter = util.vector.of(2.5, 1 + 13 / 16f, 2.75); + Vec3 filter = util.vector.of(2.5, 1 + 13 / 16f, 2.75); scene.overlay.showFilterSlotInput(filter, 80); ItemStack bricks = new ItemStack(Blocks.STONE_BRICKS); scene.overlay.showControls(new InputWindowElement(filter, Pointing.DOWN).withItem(bricks), 80); @@ -218,7 +218,7 @@ public class MechanicalSawScenes { scene.world.replaceBlocks(util.select.layersFrom(4), Blocks.AIR.defaultBlockState(), false); for (int i = 0; i < 5; i++) { - Vector3d dropPos = util.vector.centerOf(breakingPos.above(i)); + Vec3 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)); } @@ -253,7 +253,7 @@ public class MechanicalSawScenes { 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); + Vec3 dropPos = util.vector.centerOf(x, i + 1, z); float distance = (float) dropPos.distanceTo(util.vector.centerOf(breakingPos)); scene.world.createItemEntity(dropPos, util.vector.of(-distance / 20, 0, 0), new ItemStack(Items.JUNGLE_LOG)); @@ -332,7 +332,7 @@ public class MechanicalSawScenes { scene.world.replaceBlocks(util.select.layersFrom(4), Blocks.AIR.defaultBlockState(), false); for (int i = 0; i < 5; i++) { - Vector3d dropPos = util.vector.centerOf(breakingPos.above(i)); + Vec3 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)); } 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 db1125dbe..c9747e236 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 @@ -16,16 +16,16 @@ import com.simibubi.create.foundation.ponder.elements.ParrotElement.FlappyPose; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.CropsBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class MovementActorScenes { @@ -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.above(3)); + Vec3 entitySpawn = util.vector.topOf(hopper.above(3)); ElementLink entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), itemStack); @@ -214,7 +214,7 @@ public class MovementActorScenes { .add(util.select.position(1, 1, 2))); scene.world.setBlocks(crops, Blocks.WHEAT.defaultBlockState() - .setValue(CropsBlock.AGE, 7), false); + .setValue(CropBlock.AGE, 7), false); scene.world.showSection(util.select.layer(0), Direction.UP); BlockPos bearingPos = util.grid.at(4, 1, 4); @@ -284,7 +284,7 @@ public class MovementActorScenes { scene.idle(15); scene.world.modifyEntities(ItemEntity.class, Entity::remove); scene.world.setBlocks(crops, Blocks.WHEAT.defaultBlockState() - .setValue(CropsBlock.AGE, 7), false); + .setValue(CropBlock.AGE, 7), false); scene.world.showSection(crops, Direction.UP); for (int i = 0; i < 3; i++) @@ -375,7 +375,7 @@ public class MovementActorScenes { scene.world.moveSection(contraption, util.vector.of(-2, 0, 0), 60); scene.idle(15); - Vector3d m = util.vector.of(-0.1, .2, 0); + Vec3 m = util.vector.of(-0.1, .2, 0); scene.world.destroyBlock(util.grid.at(2, 1, 3)); scene.world.createItemEntity(util.vector.centerOf(2, 1, 3), m, new ItemStack(Items.LEVER)); scene.world.destroyBlock(util.grid.at(2, 1, 2)); 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 8994e1667..42afd0015 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 @@ -11,14 +11,14 @@ import com.simibubi.create.foundation.ponder.elements.ParrotElement.FaceCursorPo import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.block.DoublePlantBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.state.properties.PistonType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DoublePlantBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.PistonType; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; public class PistonScenes { 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 299f81fc5..d4954fc2b 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 @@ -2,14 +2,14 @@ package com.simibubi.create.foundation.ponder.content; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.IScreenRenderable; import com.simibubi.create.foundation.ponder.PonderLocalization; import com.simibubi.create.foundation.ponder.PonderRegistry; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.resources.ResourceLocation; public class PonderChapter implements IScreenRenderable { @@ -36,12 +36,12 @@ public class PonderChapter implements IScreenRenderable { } @Override - public void draw(MatrixStack ms, AbstractGui screen, int x, int y) { + public void draw(PoseStack ms, GuiComponent screen, int x, int y) { 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.blit(ms, x, y, 0, 0, 0, 64, 64, 64, 64); + GuiComponent.blit(ms, x, y, 0, 0, 0, 64, 64, 64, 64); ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapterRegistry.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapterRegistry.java index f1464ead4..714a7c20b 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapterRegistry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapterRegistry.java @@ -13,7 +13,7 @@ import javax.annotation.Nullable; import com.simibubi.create.foundation.ponder.PonderStoryBoardEntry; import com.simibubi.create.foundation.utility.Pair; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class PonderChapterRegistry { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java index be1232eb9..26630a692 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java @@ -13,8 +13,8 @@ import com.simibubi.create.foundation.ponder.content.fluid.PipeScenes; import com.simibubi.create.foundation.ponder.content.fluid.PumpScenes; import com.simibubi.create.foundation.ponder.content.fluid.SpoutScenes; -import net.minecraft.block.Blocks; -import net.minecraft.item.DyeColor; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.DyeColor; public class PonderIndex { 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 f86073956..d31e3a485 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 @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.crank.ValveHandleBlock; import com.simibubi.create.foundation.gui.ScreenOpener; @@ -17,14 +17,14 @@ import com.simibubi.create.foundation.ponder.ui.ChapterLabel; import com.simibubi.create.foundation.ponder.ui.LayoutHelper; import com.simibubi.create.foundation.ponder.ui.PonderButton; -import net.minecraft.block.Block; -import net.minecraft.client.MainWindow; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.level.block.Block; +import com.mojang.blaze3d.platform.Window; +import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.Mth; import net.minecraftforge.registries.ForgeRegistries; public class PonderIndexScreen extends NavigatableSimiScreen { @@ -32,12 +32,12 @@ public class PonderIndexScreen extends NavigatableSimiScreen { protected final List chapters; private final double chapterXmult = 0.5; private final double chapterYmult = 0.3; - protected Rectangle2d chapterArea; + protected Rect2i chapterArea; protected final List items; private final double itemXmult = 0.5; private double itemYmult = 0.75; - protected Rectangle2d itemArea; + protected Rect2i itemArea; private ItemStack hoveredItem = ItemStack.EMPTY; @@ -74,7 +74,7 @@ public class PonderIndexScreen extends NavigatableSimiScreen { // setup chapters LayoutHelper layout = LayoutHelper.centeredHorizontal(chapters.size(), - MathHelper.clamp((int) Math.ceil(chapters.size() / 4f), 1, 4), 200, 38, 16); + Mth.clamp((int) Math.ceil(chapters.size() / 4f), 1, 4), 200, 38, 16); chapterArea = layout.getArea(); int chapterCenterX = (int) (width * chapterXmult); int chapterCenterY = (int) (height * chapterYmult); @@ -99,7 +99,7 @@ public class PonderIndexScreen extends NavigatableSimiScreen { int maxItemRows = hasChapters ? 4 : 7; layout = LayoutHelper.centeredHorizontal(items.size(), - MathHelper.clamp((int) Math.ceil(items.size() / 11f), 1, maxItemRows), 28, 28, 8); + Mth.clamp((int) Math.ceil(items.size() / 11f), 1, maxItemRows), 28, 28, 8); itemArea = layout.getArea(); int itemCenterX = (int) (width * itemXmult); int itemCenterY = (int) (height * itemYmult); @@ -137,10 +137,10 @@ public class PonderIndexScreen extends NavigatableSimiScreen { PonderUI.ponderTicks++; hoveredItem = ItemStack.EMPTY; - MainWindow w = minecraft.getWindow(); + Window 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) { + for (AbstractWidget widget : widgets) { if (widget instanceof PonderButton) if (widget.isMouseOver(mouseX, mouseY)) { hoveredItem = ((PonderButton) widget).getItem(); @@ -149,7 +149,7 @@ public class PonderIndexScreen extends NavigatableSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int x = (int) (width * chapterXmult); int y = (int) (height * chapterYmult); @@ -176,7 +176,7 @@ public class PonderIndexScreen extends NavigatableSimiScreen { } @Override - protected void renderWindowForeground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { if (hoveredItem.isEmpty()) return; 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 e9f266ec9..d5d219071 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 @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.ponder.content; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.Create; @@ -9,13 +9,13 @@ import com.simibubi.create.foundation.gui.IScreenRenderable; import com.simibubi.create.foundation.ponder.PonderLocalization; import com.simibubi.create.foundation.ponder.PonderRegistry; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.AbstractGui; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -132,7 +132,7 @@ public class PonderTag implements IScreenRenderable { return icon(id); } - public PonderTag item(IItemProvider item, boolean useAsIcon, boolean useAsMainItem) { + public PonderTag item(ItemLike item, boolean useAsIcon, boolean useAsMainItem) { if (useAsIcon) this.itemIcon = new ItemStack(item); if (useAsMainItem) @@ -140,13 +140,13 @@ public class PonderTag implements IScreenRenderable { return this; } - public PonderTag item(IItemProvider item) { + public PonderTag item(ItemLike item) { return this.item(item, true, true); } @Override @OnlyIn(Dist.CLIENT) - public void draw(MatrixStack ms, AbstractGui screen, int x, int y) { + public void draw(PoseStack ms, GuiComponent screen, int x, int y) { ms.pushPose(); ms.translate(x, y, 0); if (icon != null) { @@ -156,7 +156,7 @@ public class PonderTag implements IScreenRenderable { 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.blit(ms, 0, 0, 0, 0, 0, 64, 64, 64, 64); + GuiComponent.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); 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 1cccb7e4e..206b5b6a8 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 @@ -3,7 +3,7 @@ package com.simibubi.create.foundation.ponder.content; import java.util.List; import java.util.Optional; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.gui.AllIcons; @@ -22,13 +22,13 @@ import com.simibubi.create.foundation.ponder.ui.PonderButton; import com.simibubi.create.foundation.utility.FontHelper; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.MainWindow; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import com.mojang.blaze3d.platform.Window; +import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.util.Mth; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; public class PonderTagIndexScreen extends NavigatableSimiScreen { @@ -39,8 +39,8 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { public static final String DESCRIPTION = PonderLocalization.LANG_PREFIX + "index_description"; private final double itemXmult = 0.5; - protected Rectangle2d itemArea; - protected Rectangle2d chapterArea; + protected Rect2i itemArea; + protected Rect2i chapterArea; private final double mainYmult = 0.15; private PonderTag hoveredItem = null; @@ -55,7 +55,7 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { super.init(); List tags = PonderRegistry.TAGS.getListedTags(); - int rowCount = MathHelper.clamp((int) Math.ceil(tags.size() / 11d), 1, 3); + int rowCount = Mth.clamp((int) Math.ceil(tags.size() / 11d), 1, 3); LayoutHelper layout = LayoutHelper.centeredHorizontal(tags.size(), rowCount, 28, 28, 8); itemArea = layout.getArea(); int itemCenterX = (int) (width * itemXmult); @@ -84,10 +84,10 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { PonderUI.ponderTicks++; hoveredItem = null; - MainWindow w = minecraft.getWindow(); + Window 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) { + for (AbstractWidget widget : widgets) { if (widget == backTrack) continue; if (widget instanceof PonderButton) @@ -102,7 +102,7 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { renderItems(ms, mouseX, mouseY, partialTicks); ms.pushPose(); @@ -164,7 +164,7 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { ms.popPose(); } - protected void renderItems(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderItems(PoseStack ms, int mouseX, int mouseY, float partialTicks) { List tags = PonderRegistry.TAGS.getListedTags(); if (tags.isEmpty()) return; @@ -205,16 +205,16 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { } @Override - protected void renderWindowForeground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { ms.pushPose(); RenderSystem.disableRescaleNormal(); RenderSystem.disableDepthTest(); ms.translate(0, 0, 200); if (hoveredItem != null) { - List list = TooltipHelper.cutStringTextComponent(hoveredItem.getDescription(), - TextFormatting.GRAY, TextFormatting.GRAY); - list.add(0, new StringTextComponent(hoveredItem.getTitle())); + List list = TooltipHelper.cutStringTextComponent(hoveredItem.getDescription(), + ChatFormatting.GRAY, ChatFormatting.GRAY); + list.add(0, new TextComponent(hoveredItem.getTitle())); renderComponentTooltip(ms, list, mouseX, mouseY); } RenderSystem.enableDepthTest(); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagRegistry.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagRegistry.java index 8d0da42a2..aabfe9998 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagRegistry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagRegistry.java @@ -12,8 +12,8 @@ import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; import com.tterrag.registrate.util.entry.ItemProviderEntry; -import net.minecraft.util.IItemProvider; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.ItemLike; +import net.minecraft.resources.ResourceLocation; public class PonderTagRegistry { @@ -108,7 +108,7 @@ public class PonderTagRegistry { return this; } - public TagBuilder add(IItemProvider item) { + public TagBuilder add(ItemLike item) { return add(item.asItem() .getRegistryName()); } 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 203c4890f..bff7d49dc 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 @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.Create; import com.simibubi.create.foundation.gui.BoxElement; @@ -21,14 +21,14 @@ import com.simibubi.create.foundation.ponder.ui.PonderButton; import com.simibubi.create.foundation.utility.FontHelper; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.block.Block; -import net.minecraft.client.MainWindow; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.client.renderer.Rectangle2d; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.level.block.Block; +import com.mojang.blaze3d.platform.Window; +import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import net.minecraftforge.registries.ForgeRegistries; public class PonderTagScreen extends NavigatableSimiScreen { @@ -38,11 +38,11 @@ public class PonderTagScreen extends NavigatableSimiScreen { private final PonderTag tag; protected final List items; private final double itemXmult = 0.5; - protected Rectangle2d itemArea; + protected Rect2i itemArea; protected final List chapters; private final double chapterXmult = 0.5; private final double chapterYmult = 0.75; - protected Rectangle2d chapterArea; + protected Rect2i chapterArea; private final double mainYmult = 0.15; private ItemStack hoveredItem = ItemStack.EMPTY; @@ -77,7 +77,7 @@ public class PonderTagScreen extends NavigatableSimiScreen { if (!tag.getMainItem().isEmpty()) items.remove(tag.getMainItem().getItem()); - int rowCount = MathHelper.clamp((int) Math.ceil(items.size() / 11d), 1, 3); + int rowCount = Mth.clamp((int) Math.ceil(items.size() / 11d), 1, 3); LayoutHelper layout = LayoutHelper.centeredHorizontal(items.size(), rowCount, 28, 28, 8); itemArea = layout.getArea(); int itemCenterX = (int) (width * itemXmult); @@ -137,7 +137,7 @@ public class PonderTagScreen extends NavigatableSimiScreen { chapters.clear(); chapters.addAll(PonderRegistry.TAGS.getChapters(tag)); - rowCount = MathHelper.clamp((int) Math.ceil(chapters.size() / 3f), 1, 3); + rowCount = Mth.clamp((int) Math.ceil(chapters.size() / 3f), 1, 3); layout = LayoutHelper.centeredHorizontal(chapters.size(), rowCount, 200, 38, 16); chapterArea = layout.getArea(); int chapterCenterX = (int) (width * chapterXmult); @@ -162,10 +162,10 @@ public class PonderTagScreen extends NavigatableSimiScreen { PonderUI.ponderTicks++; hoveredItem = ItemStack.EMPTY; - MainWindow w = minecraft.getWindow(); + Window 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) { + for (AbstractWidget widget : widgets) { if (widget == backTrack) continue; if (widget instanceof PonderButton) @@ -176,7 +176,7 @@ public class PonderTagScreen extends NavigatableSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) { renderItems(ms, mouseX, mouseY, partialTicks); renderChapters(ms, mouseX, mouseY, partialTicks); @@ -238,7 +238,7 @@ public class PonderTagScreen extends NavigatableSimiScreen { ms.popPose(); } - protected void renderItems(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderItems(PoseStack ms, int mouseX, int mouseY, float partialTicks) { if (items.isEmpty()) return; @@ -276,7 +276,7 @@ public class PonderTagScreen extends NavigatableSimiScreen { return (int) (mainYmult * height + 85); } - protected void renderChapters(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderChapters(PoseStack ms, int mouseX, int mouseY, float partialTicks) { if (chapters.isEmpty()) return; @@ -293,7 +293,7 @@ public class PonderTagScreen extends NavigatableSimiScreen { } @Override - protected void renderWindowForeground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) { ms.pushPose(); RenderSystem.disableRescaleNormal(); RenderSystem.disableDepthTest(); 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 342b530f8..c928b0a03 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 @@ -27,18 +27,18 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.monster.BlazeEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.particles.ItemParticleData; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.monster.Blaze; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class ProcessingScenes { @@ -64,7 +64,7 @@ public class ProcessingScenes { scene.idle(10); scene.world.showSection(util.select.position(millstone), Direction.DOWN); scene.idle(10); - Vector3d millstoneTop = util.vector.topOf(millstone); + Vec3 millstoneTop = util.vector.topOf(millstone); scene.overlay.showText(60) .attachKeyFrame() .text("Millstones process items by grinding them") @@ -87,7 +87,7 @@ public class ProcessingScenes { scene.idle(70); ItemStack itemStack = new ItemStack(Items.WHEAT); - Vector3d entitySpawn = util.vector.topOf(millstone.above(3)); + Vec3 entitySpawn = util.vector.topOf(millstone.above(3)); ElementLink entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), itemStack); @@ -173,7 +173,7 @@ public class ProcessingScenes { scene.world.showSection(eWheel, Direction.SOUTH); scene.idle(10); - Vector3d centerTop = util.vector.topOf(center); + Vec3 centerTop = util.vector.topOf(center); scene.overlay.showText(60) .attachKeyFrame() .text("A pair of Crushing Wheels can grind items very effectively") @@ -203,14 +203,14 @@ public class ProcessingScenes { ItemStack input = new ItemStack(Items.GOLD_ORE); ItemStack output = AllItems.CRUSHED_GOLD.asStack(); - Vector3d entitySpawn = util.vector.topOf(center.above(2)); + Vec3 entitySpawn = util.vector.topOf(center.above(2)); ElementLink entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), input); scene.idle(18); scene.world.modifyEntity(entity1, Entity::remove); Emitter blockSpace = - Emitter.withinBlockSpace(new ItemParticleData(ParticleTypes.ITEM, input), util.vector.of(0, 0, 0)); + Emitter.withinBlockSpace(new ItemParticleOption(ParticleTypes.ITEM, input), util.vector.of(0, 0, 0)); scene.effects.emitParticles(util.vector.centerOf(center) .add(0, -0.2, 0), blockSpace, 3, 40); scene.idle(10); @@ -294,7 +294,7 @@ public class ProcessingScenes { scene.effects.indicateSuccess(pressPos); scene.idle(10); - Vector3d pressSide = util.vector.blockSurface(pressPos, Direction.WEST); + Vec3 pressSide = util.vector.blockSurface(pressPos, Direction.WEST); scene.overlay.showText(60) .pointAt(pressSide) .placeNearTarget() @@ -308,7 +308,7 @@ public class ProcessingScenes { scene.idle(50); ItemStack copper = AllItems.COPPER_INGOT.asStack(); scene.world.createItemOnBeltLike(depotPos, Direction.NORTH, copper); - Vector3d depotCenter = util.vector.centerOf(depotPos.south()); + Vec3 depotCenter = util.vector.centerOf(depotPos.south()); scene.overlay.showControls(new InputWindowElement(depotCenter, Pointing.UP).withItem(copper), 30); scene.idle(10); @@ -393,7 +393,7 @@ public class ProcessingScenes { BlockPos basin = util.grid.at(1, 2, 2); BlockPos pressPos = util.grid.at(1, 4, 2); - Vector3d basinSide = util.vector.blockSurface(basin, Direction.WEST); + Vec3 basinSide = util.vector.blockSurface(basin, Direction.WEST); ItemStack blue = new ItemStack(Items.BLUE_DYE); ItemStack red = new ItemStack(Items.RED_DYE); @@ -445,7 +445,7 @@ public class ProcessingScenes { scene.rotateCameraY(30); scene.idle(60); - Vector3d filterPos = util.vector.of(1, 2.75f, 2.5f); + Vec3 filterPos = util.vector.of(1, 2.75f, 2.5f); scene.overlay.showFilterSlotInput(filterPos, 100); scene.overlay.showText(120) .pointAt(filterPos) @@ -475,7 +475,7 @@ public class ProcessingScenes { BlockPos basin = util.grid.at(1, 2, 2); BlockPos pressPos = util.grid.at(1, 4, 2); - Vector3d basinSide = util.vector.blockSurface(basin, Direction.WEST); + Vec3 basinSide = util.vector.blockSurface(basin, Direction.WEST); ItemStack copper = AllItems.COPPER_INGOT.asStack(); ItemStack copperBlock = AllBlocks.COPPER_BLOCK.asStack(); @@ -544,7 +544,7 @@ public class ProcessingScenes { scene.rotateCameraY(30); scene.idle(60); - Vector3d filterPos = util.vector.of(1, 2.75f, 2.5f); + Vec3 filterPos = util.vector.of(1, 2.75f, 2.5f); scene.overlay.showFilterSlotInput(filterPos, 100); scene.overlay.showText(120) .pointAt(filterPos) @@ -562,8 +562,8 @@ public class ProcessingScenes { BlockPos center = util.grid.at(2, 0, 2); scene.world.createEntity(w -> { - BlazeEntity blazeEntity = EntityType.BLAZE.create(w); - Vector3d v = util.vector.topOf(center); + Blaze blazeEntity = EntityType.BLAZE.create(w); + Vec3 v = util.vector.topOf(center); blazeEntity.setPosRaw(v.x, v.y, v.z); blazeEntity.yRotO = blazeEntity.yRot = 180; return blazeEntity; @@ -581,7 +581,7 @@ public class ProcessingScenes { .placeNearTarget(); scene.idle(50); - scene.world.modifyEntities(BlazeEntity.class, Entity::remove); + scene.world.modifyEntities(Blaze.class, Entity::remove); scene.idle(20); scene.world.showSection(util.select.position(2, 1, 2), Direction.DOWN); @@ -734,7 +734,7 @@ public class ProcessingScenes { 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); + Vec3 basinSide = util.vector.blockSurface(basinPos, Direction.WEST); scene.overlay.showText(80) .attachKeyFrame() .text("A Basin can hold Items and Fluids for Processing") @@ -896,7 +896,7 @@ public class ProcessingScenes { .placeNearTarget(); scene.idle(80); - Vector3d filter = util.vector.of(2.5, 2.85, 2.5); + Vec3 filter = util.vector.of(2.5, 2.85, 2.5); scene.overlay.showFilterSlotInput(filter, 80); scene.overlay.showText(70) .text("A Filter might be necessary to avoid pulling out un-processed items") 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 8cc9fff31..2485047df 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 @@ -8,9 +8,9 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.Blocks; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; public class PulleyScenes { 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 b77a3fc5b..8782bab08 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 @@ -23,18 +23,18 @@ import com.simibubi.create.foundation.ponder.elements.ParrotElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.item.DyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.state.IntegerProperty; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class RedstoneScenes { @@ -249,7 +249,7 @@ public class RedstoneScenes { scene.world.showSection(util.select.position(circuitPos), Direction.DOWN); scene.idle(20); - Vector3d circuitTop = util.vector.blockSurface(circuitPos, Direction.DOWN) + Vec3 circuitTop = util.vector.blockSurface(circuitPos, Direction.DOWN) .add(0, 3 / 16f, 0); scene.overlay.showText(70) .text("Adjustable Repeaters behave similarly to regular Repeaters") @@ -326,7 +326,7 @@ public class RedstoneScenes { scene.world.showSection(util.select.position(circuitPos), Direction.DOWN); scene.idle(20); - Vector3d circuitTop = util.vector.blockSurface(circuitPos, Direction.DOWN) + Vec3 circuitTop = util.vector.blockSurface(circuitPos, Direction.DOWN) .add(0, 3 / 16f, 0); scene.effects.indicateRedstone(leverPos); @@ -380,7 +380,7 @@ public class RedstoneScenes { BlockPos circuitPos = util.grid.at(2, 1, 2); BlockPos buttonPos = util.grid.at(4, 1, 2); - Vector3d circuitTop = util.vector.blockSurface(circuitPos, Direction.DOWN) + Vec3 circuitTop = util.vector.blockSurface(circuitPos, Direction.DOWN) .add(0, 3 / 16f, 0); scene.world.showSection(util.select.layersFrom(1) @@ -402,7 +402,7 @@ public class RedstoneScenes { scene.idle(30); scene.world.toggleRedstonePower(util.select.fromTo(4, 1, 2, 3, 1, 2)); - AxisAlignedBB bb = new AxisAlignedBB(circuitPos).inflate(-.48f, -.45f, -.05f) + AABB bb = new AABB(circuitPos).inflate(-.48f, -.45f, -.05f) .move(.575, -.45, 0); scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, bb, bb, 40); scene.overlay.showText(40) @@ -419,9 +419,9 @@ public class RedstoneScenes { scene.idle(30); scene.world.toggleRedstonePower(util.select.fromTo(2, 1, 0, 2, 1, 1)); - bb = new AxisAlignedBB(circuitPos).inflate(-.05f, -.45f, -.48f) + bb = new AABB(circuitPos).inflate(-.05f, -.45f, -.48f) .move(0, -.45, .575); - AxisAlignedBB bb2 = new AxisAlignedBB(circuitPos).inflate(-.05f, -.45f, -.48f) + AABB bb2 = new AABB(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); @@ -460,7 +460,7 @@ public class RedstoneScenes { BlockPos circuitPos = util.grid.at(2, 1, 2); BlockPos buttonPos = util.grid.at(4, 1, 2); - Vector3d circuitTop = util.vector.blockSurface(circuitPos, Direction.DOWN) + Vec3 circuitTop = util.vector.blockSurface(circuitPos, Direction.DOWN) .add(0, 3 / 16f, 0); scene.world.showSection(util.select.layersFrom(1) @@ -482,7 +482,7 @@ public class RedstoneScenes { scene.idle(30); scene.world.toggleRedstonePower(util.select.fromTo(4, 1, 2, 3, 1, 2)); - AxisAlignedBB bb = new AxisAlignedBB(circuitPos).inflate(-.48f, -.45f, -.05f) + AABB bb = new AABB(circuitPos).inflate(-.48f, -.45f, -.05f) .move(.575, -.45, 0); scene.overlay.chaseBoundingBoxOutline(PonderPalette.GREEN, bb, bb, 40); scene.overlay.showText(40) @@ -538,7 +538,7 @@ public class RedstoneScenes { Selection leverSelection = util.select.fromTo(2, 1, 2, 2, 2, 2); Selection lamp = util.select.position(4, 1, 0); BlockPos leverPos = util.grid.at(2, 2, 2); - Vector3d leverVec = util.vector.centerOf(leverPos) + Vec3 leverVec = util.vector.centerOf(leverPos) .add(0, -.25, 0); scene.world.showSection(util.select.layersFrom(0) @@ -558,7 +558,7 @@ public class RedstoneScenes { .pointAt(leverVec); scene.idle(70); - IntegerProperty power = RedstoneWireBlock.POWER; + IntegerProperty power = RedStoneWireBlock.POWER; scene.overlay.showControls(new InputWindowElement(leverVec, Pointing.DOWN).rightClick(), 40); scene.idle(7); for (int i = 0; i < 7; i++) { @@ -633,11 +633,11 @@ 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.setValue(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); - Vector3d centerTube = util.vector.centerOf(2, 1, 3); + Vec3 centerTube = util.vector.centerOf(2, 1, 3); scene.overlay.showText(60) .attachKeyFrame() @@ -658,12 +658,12 @@ public class RedstoneScenes { .withItem(new ItemStack(Items.NAME_TAG)), 40); scene.idle(7); - ITextComponent component = new StringTextComponent("CREATE"); + Component component = new TextComponent("CREATE"); for (int i = 0; i < 3; i++) { final int index = i; scene.world.modifyTileNBT(util.select.position(3 - i, 1, 3), NixieTubeTileEntity.class, nbt -> { nbt.putString("RawCustomText", component.getString()); - nbt.putString("CustomText", ITextComponent.Serializer.toJson(component)); + nbt.putString("CustomText", Component.Serializer.toJson(component)); nbt.putInt("CustomTextIndex", index); }); } @@ -718,11 +718,11 @@ public class RedstoneScenes { Selection link1Select = util.select.position(link1Pos); Selection link2Select = util.select.position(link2Pos); Selection link3Select = util.select.position(link3Pos); - Vector3d link1Vec = util.vector.blockSurface(link1Pos, Direction.DOWN) + Vec3 link1Vec = util.vector.blockSurface(link1Pos, Direction.DOWN) .add(0, 3 / 16f, 0); - Vector3d link2Vec = util.vector.blockSurface(link2Pos, Direction.SOUTH) + Vec3 link2Vec = util.vector.blockSurface(link2Pos, Direction.SOUTH) .add(0, 0, -3 / 16f); - Vector3d link3Vec = util.vector.blockSurface(link3Pos, Direction.SOUTH) + Vec3 link3Vec = util.vector.blockSurface(link3Pos, Direction.SOUTH) .add(0, 0, -3 / 16f); scene.world.showSection(link1Select, Direction.DOWN); @@ -782,12 +782,12 @@ public class RedstoneScenes { scene.world.toggleRedstonePower(util.select.fromTo(3, 2, 3, 1, 2, 2)); scene.idle(20); - Vector3d frontSlot = link1Vec.add(.18, -.05, -.15); - Vector3d backSlot = link1Vec.add(.18, -.05, .15); - Vector3d top2Slot = link2Vec.add(-.09, .15, 0); - Vector3d bottom2Slot = link2Vec.add(-.09, -.2, 0); - Vector3d top3Slot = link3Vec.add(-.09, .15, 0); - Vector3d bottom3Slot = link3Vec.add(-.09, -.2, 0); + Vec3 frontSlot = link1Vec.add(.18, -.05, -.15); + Vec3 backSlot = link1Vec.add(.18, -.05, .15); + Vec3 top2Slot = link2Vec.add(-.09, .15, 0); + Vec3 bottom2Slot = link2Vec.add(-.09, -.2, 0); + Vec3 top3Slot = link3Vec.add(-.09, .15, 0); + Vec3 bottom3Slot = link3Vec.add(-.09, -.2, 0); scene.addKeyframe(); scene.idle(10); @@ -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.save(new CompoundNBT()))); + nbt -> nbt.put("FrequencyLast", iron.save(new CompoundTag()))); scene.idle(7); scene.world.modifyTileNBT(link1Select, RedstoneLinkTileEntity.class, - nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundNBT()))); + nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundTag()))); 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.save(new CompoundNBT()))); + nbt -> nbt.put("FrequencyLast", iron.save(new CompoundTag()))); scene.idle(7); scene.world.modifyTileNBT(link2Select, RedstoneLinkTileEntity.class, - nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundNBT()))); + nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundTag()))); 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.save(new CompoundNBT()))); + nbt -> nbt.put("FrequencyLast", gold.save(new CompoundTag()))); scene.idle(7); scene.world.modifyTileNBT(link3Select, RedstoneLinkTileEntity.class, - nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundNBT()))); + nbt -> nbt.put("FrequencyFirst", sapling.save(new CompoundTag()))); scene.idle(20); scene.world.toggleRedstonePower(redstone); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/SharedText.java b/src/main/java/com/simibubi/create/foundation/ponder/content/SharedText.java index 7875705ac..5542b4a69 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/SharedText.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/SharedText.java @@ -3,7 +3,7 @@ package com.simibubi.create.foundation.ponder.content; import com.simibubi.create.Create; import com.simibubi.create.foundation.ponder.PonderLocalization; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class SharedText { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/TemplateScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/TemplateScenes.java index 72fc1b7e5..714a9b8e9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/TemplateScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/TemplateScenes.java @@ -3,7 +3,7 @@ package com.simibubi.create.foundation.ponder.content; import com.simibubi.create.foundation.ponder.SceneBuilder; import com.simibubi.create.foundation.ponder.SceneBuildingUtil; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; public class TemplateScenes { 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 28874b1b0..ad3a13fc2 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 @@ -19,15 +19,15 @@ import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.Pointing; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class TunnelScenes { @@ -154,7 +154,7 @@ public class TunnelScenes { for (Direction d : Iterate.horizontalDirections) { if (d == Direction.SOUTH) continue; - Vector3d filter = getTunnelFilterVec(tunnelPos, d); + Vec3 filter = getTunnelFilterVec(tunnelPos, d); scene.overlay.showFilterSlotInput(filter, 40); scene.idle(3); } @@ -169,7 +169,7 @@ public class TunnelScenes { scene.rotateCameraY(70); scene.idle(20); - Vector3d tunnelFilterVec = getTunnelFilterVec(tunnelPos, Direction.EAST); + Vec3 tunnelFilterVec = getTunnelFilterVec(tunnelPos, Direction.EAST); scene.overlay.showFilterSlotInput(tunnelFilterVec, 40); scene.overlay.showText(60) .attachKeyFrame() @@ -225,7 +225,7 @@ public class TunnelScenes { .setFilter(Direction.WEST, ItemStack.EMPTY)); scene.idle(10); - Vector3d tunnelTop = util.vector.topOf(tunnelPos); + Vec3 tunnelTop = util.vector.topOf(tunnelPos); scene.overlay.showControls(new InputWindowElement(tunnelTop, Pointing.DOWN).scroll() .withWrench(), 80); scene.idle(7); @@ -294,8 +294,8 @@ public class TunnelScenes { scene.idle(90); BlockPos beltPos = util.grid.at(5, 3, 3); - Vector3d m = util.vector.of(0, 0.1, 0); - Vector3d spawn = util.vector.centerOf(util.grid.at(5, 3, 2)); + Vec3 m = util.vector.of(0, 0.1, 0); + Vec3 spawn = util.vector.centerOf(util.grid.at(5, 3, 2)); scene.world.createItemEntity(spawn, m, item1); scene.idle(12); scene.world.createItemOnBelt(beltPos, Direction.UP, item1); @@ -337,9 +337,9 @@ public class TunnelScenes { } - protected static Vector3d getTunnelFilterVec(BlockPos pos, Direction d) { + protected static Vec3 getTunnelFilterVec(BlockPos pos, Direction d) { return VecHelper.getCenterOf(pos) - .add(Vector3d.atLowerCornerOf(d.getNormal()).scale(.5)) + .add(Vec3.atLowerCornerOf(d.getNormal()).scale(.5)) .add(0, 0.3, 0); } @@ -358,7 +358,7 @@ public class TunnelScenes { scene.idle(4); } - Vector3d tunnelTop = util.vector.topOf(util.grid.at(2, 2, 3)); + Vec3 tunnelTop = util.vector.topOf(util.grid.at(2, 2, 3)); scene.overlay.showControls(new InputWindowElement(tunnelTop, Pointing.DOWN).scroll() .withWrench(), 80); scene.idle(7); @@ -375,7 +375,7 @@ public class TunnelScenes { scene.world.showIndependentSection(util.select.position(4, 1, 0), Direction.UP); scene.world.moveSection(blockage, util.vector.of(-3, 0, 0), 0); - Vector3d modeVec = util.vector.of(4, 2.5, 3); + Vec3 modeVec = util.vector.of(4, 2.5, 3); scene.overlay.showControls(new InputWindowElement(modeVec, Pointing.RIGHT).showing(AllIcons.I_TUNNEL_SPLIT), 140); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/DrainScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/DrainScenes.java index 018d82422..f59bf8d27 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/DrainScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/fluid/DrainScenes.java @@ -10,11 +10,11 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; 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 a98b6e93c..9d283a49f 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 @@ -13,9 +13,9 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; 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 10a6f4b9b..14fd53b1b 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 @@ -23,12 +23,12 @@ import com.simibubi.create.foundation.ponder.instructions.EmitParticlesInstructi import com.simibubi.create.foundation.utility.Pointing; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; @@ -210,7 +210,7 @@ public class FluidTankScenes { scene.effects.emitParticles(util.vector.topOf(3, 1, 1) .add(0, 1 / 16f, 0), Emitter.simple(FluidFX.getFluidParticle(content), - VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .1f)), + VecHelper.offsetRandomly(Vec3.ZERO, Create.RANDOM, .1f)), 1, 1); } @@ -323,7 +323,7 @@ public class FluidTankScenes { scene.world.showSection(full3, Direction.DOWN); scene.idle(10); - Vector3d blockSurface = util.vector.blockSurface(util.grid.at(3, 3, 1), Direction.WEST); + Vec3 blockSurface = util.vector.blockSurface(util.grid.at(3, 3, 1), Direction.WEST); scene.overlay.showText(60) .text("...and grow in height by more than 30 additional layers") .attachKeyFrame() 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 a8cacb2f6..935ee0c8f 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 @@ -13,12 +13,12 @@ import com.simibubi.create.foundation.ponder.Selection; import com.simibubi.create.foundation.ponder.content.PonderPalette; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; -import net.minecraft.block.Blocks; -import net.minecraft.fluid.Fluids; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; @@ -44,7 +44,7 @@ public class HosePulleyScenes { scene.world.moveSection(hoselink, util.vector.of(0, -1, 0), 0); scene.idle(10); - Vector3d shaftInput = util.vector.blockSurface(hosePos.below(), Direction.WEST); + Vec3 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() @@ -226,9 +226,9 @@ public class HosePulleyScenes { ifh -> ((HosePulleyFluidHandler) ifh).fill(new FluidStack(Fluids.WATER, 100), FluidAction.EXECUTE))); scene.world.propagatePipeChange(util.grid.at(3, 2, 1)); - Vector3d surface = util.vector.topOf(1, 3, 1) + Vec3 surface = util.vector.topOf(1, 3, 1) .subtract(0, 2 / 8f, 0); - AxisAlignedBB bb = new AxisAlignedBB(surface, surface).inflate(1.5, 0, 1.5); + AABB bb = new AABB(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.expandTowards(0, -2, 0), 70); @@ -324,7 +324,7 @@ public class HosePulleyScenes { scene.world.setKineticSpeed(hose, 32); scene.idle(10); - Vector3d entryPoint = util.vector.topOf(1, 0, 2); + Vec3 entryPoint = util.vector.topOf(1, 0, 2); scene.overlay.showText(60) .text("When deploying the Hose Pulley into a large enough ocean...") .attachKeyFrame() 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 8f84ac781..be2689efc 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 @@ -23,18 +23,18 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.BeehiveBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.BooleanProperty; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.BeehiveBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -108,10 +108,10 @@ public class PipeScenes { scene.world.restoreBlocks(util.select.position(1, 1, 2)); scene.idle(40); - Vector3d center = util.vector.centerOf(2, 1, 2); - 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); + Vec3 center = util.vector.centerOf(2, 1, 2); + AABB bb = new AABB(center, center).inflate(1 / 6f); + AABB bb1 = bb.move(-0.5, 0, 0); + AABB bb2 = bb.move(0, 0, -0.5); scene.world.showSection(strayPipes, Direction.DOWN); scene.idle(10); @@ -508,7 +508,7 @@ public class PipeScenes { scene.world.destroyBlock(smartPos); scene.world.restoreBlocks(util.select.position(smartPos)); - Vector3d filterVec = util.vector.topOf(smartPos) + Vec3 filterVec = util.vector.topOf(smartPos) .subtract(0.25, 0, 0); scene.overlay.showText(50) .placeNearTarget() 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 6c1a89f4f..f62c2452d 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 @@ -15,13 +15,13 @@ import com.simibubi.create.foundation.ponder.elements.InputWindowElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; public class PumpScenes { @@ -82,9 +82,9 @@ public class PumpScenes { .pointAt(util.vector.topOf(pumpPos) .subtract(0.5f, 0.125f, 0)); - AxisAlignedBB bb1 = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).inflate(.25, .25, 0) + AABB bb1 = new AABB(Vec3.ZERO, Vec3.ZERO).inflate(.25, .25, 0) .move(0, 0, .25); - AxisAlignedBB bb2 = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).inflate(.25, .25, 1.25); + AABB bb2 = new AABB(Vec3.ZERO, Vec3.ZERO).inflate(.25, .25, 1.25); scene.idle(65); Object in = new Object(); 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 e28dbe06d..3e2c7c28b 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 @@ -18,12 +18,12 @@ import com.simibubi.create.foundation.ponder.instructions.EmitParticlesInstructi import com.simibubi.create.foundation.utility.Pointing; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.particles.IParticleData; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.FluidStack; public class SpoutScenes { @@ -50,7 +50,7 @@ public class SpoutScenes { scene.world.showSection(spoutS, Direction.DOWN); scene.idle(10); - Vector3d spoutSide = util.vector.blockSurface(spoutPos, Direction.WEST); + Vec3 spoutSide = util.vector.blockSurface(spoutPos, Direction.WEST); scene.overlay.showText(60) .pointAt(spoutSide) .placeNearTarget() @@ -98,7 +98,7 @@ public class SpoutScenes { scene.idle(50); ItemStack bottle = new ItemStack(Items.GLASS_BOTTLE); scene.world.createItemOnBeltLike(depotPos, Direction.NORTH, bottle); - Vector3d depotCenter = util.vector.centerOf(depotPos.south()); + Vec3 depotCenter = util.vector.centerOf(depotPos.south()); scene.overlay.showControls(new InputWindowElement(depotCenter, Pointing.UP).withItem(bottle), 30); scene.idle(10); @@ -108,11 +108,11 @@ public class SpoutScenes { scene.world.removeItemsFromBelt(depotPos); ItemStack potion = new ItemStack(Items.HONEY_BOTTLE); scene.world.createItemOnBeltLike(depotPos, Direction.UP, potion); - IParticleData fluidParticle = FluidFX.getFluidParticle(new FluidStack(AllFluids.HONEY.get(), 1000)); + ParticleOptions fluidParticle = FluidFX.getFluidParticle(new FluidStack(AllFluids.HONEY.get(), 1000)); for (int i = 0; i < 10; i++) { scene.effects.emitParticles(util.vector.topOf(depotPos.south()) .add(0, 1 / 16f, 0), - Emitter.simple(fluidParticle, VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .1f)), 1, 1); + Emitter.simple(fluidParticle, VecHelper.offsetRandomly(Vec3.ZERO, Create.RANDOM, .1f)), 1, 1); } scene.idle(10); scene.overlay.showControls(new InputWindowElement(depotCenter, Pointing.UP).withItem(potion), 50); @@ -149,7 +149,7 @@ public class SpoutScenes { for (int i = 0; i < 10; i++) { scene.effects.emitParticles(util.vector.topOf(depotPos.south()) .add(0, 1 / 16f, 0), - Emitter.simple(fluidParticle, VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .1f)), 1, 1); + Emitter.simple(fluidParticle, VecHelper.offsetRandomly(Vec3.ZERO, Create.RANDOM, .1f)), 1, 1); } scene.world.removeItemsFromBelt(spoutPos.below(2)); ingot = scene.world.createItemOnBelt(spoutPos.below(2), Direction.UP, potion); @@ -163,7 +163,7 @@ public class SpoutScenes { for (int i = 0; i < 10; i++) { scene.effects.emitParticles(util.vector.topOf(depotPos.south()) .add(0, 1 / 16f, 0), - Emitter.simple(fluidParticle, VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .1f)), 1, 1); + Emitter.simple(fluidParticle, VecHelper.offsetRandomly(Vec3.ZERO, Create.RANDOM, .1f)), 1, 1); } scene.world.removeItemsFromBelt(spoutPos.below(2)); ingot2 = scene.world.createItemOnBelt(spoutPos.below(2), Direction.UP, potion); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/AnimatedOverlayElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/AnimatedOverlayElement.java index 8f2fc1375..19bbd1334 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/AnimatedOverlayElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/AnimatedOverlayElement.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.ponder.elements; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderUI; import com.simibubi.create.foundation.utility.animation.LerpedFloat; @@ -19,11 +19,11 @@ public abstract class AnimatedOverlayElement extends PonderOverlayElement { } @Override - public final void render(PonderScene scene, PonderUI screen, MatrixStack ms, float partialTicks) { + public final void render(PonderScene scene, PonderUI screen, PoseStack ms, float partialTicks) { float currentFade = fade.getValue(partialTicks); render(scene, screen, ms, partialTicks, currentFade); } - protected abstract void render(PonderScene scene, PonderUI screen, MatrixStack ms, float partialTicks, float fade); + protected abstract void render(PonderScene scene, PonderUI screen, PoseStack ms, float partialTicks, float fade); } 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 3adc64113..529086cb6 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 @@ -1,18 +1,18 @@ package com.simibubi.create.foundation.ponder.elements; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.utility.animation.LerpedFloat; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public abstract class AnimatedSceneElement extends PonderSceneElement { - protected Vector3d fadeVec; + protected Vec3 fadeVec; protected LerpedFloat fade; public AnimatedSceneElement() { @@ -28,12 +28,12 @@ public abstract class AnimatedSceneElement extends PonderSceneElement { this.fade.setValue(fade); } - public void setFadeVec(Vector3d fadeVec) { + public void setFadeVec(Vec3 fadeVec) { this.fadeVec = fadeVec; } @Override - public final void renderFirst(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float pt) { + public final void renderFirst(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float pt) { ms.pushPose(); float currentFade = applyFade(ms, pt); renderFirst(world, buffer, ms, currentFade, pt); @@ -41,7 +41,7 @@ public abstract class AnimatedSceneElement extends PonderSceneElement { } @Override - public final void renderLayer(PonderWorld world, IRenderTypeBuffer buffer, RenderType type, MatrixStack ms, + public final void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float pt) { ms.pushPose(); float currentFade = applyFade(ms, pt); @@ -50,14 +50,14 @@ public abstract class AnimatedSceneElement extends PonderSceneElement { } @Override - public final void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float pt) { + public final void renderLast(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float pt) { ms.pushPose(); float currentFade = applyFade(ms, pt); renderLast(world, buffer, ms, currentFade, pt); ms.popPose(); } - protected float applyFade(MatrixStack ms, float pt) { + protected float applyFade(PoseStack ms, float pt) { float currentFade = fade.getValue(pt); if (fadeVec != null) MatrixTransformStack.of(ms) @@ -65,17 +65,17 @@ public abstract class AnimatedSceneElement extends PonderSceneElement { return currentFade; } - protected void renderLayer(PonderWorld world, IRenderTypeBuffer buffer, RenderType type, MatrixStack ms, float fade, + protected void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float fade, float pt) {} - protected void renderFirst(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float fade, float pt) {} + protected void renderFirst(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) {} - protected void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float fade, float pt) {} + protected void renderLast(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) {} protected int lightCoordsFromFade(float fade) { int light = 0xF000F0; if (fade != 1) { - light = (int) (MathHelper.lerp(fade, 5, 0xF)); + light = (int) (Mth.lerp(fade, 5, 0xF)); light = light << 4 | light << 20; } return light; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/EntityElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/EntityElement.java index 556d300a4..317c2a9e6 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/EntityElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/EntityElement.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.ponder.elements; -import net.minecraft.entity.Entity; +import net.minecraft.world.entity.Entity; public class EntityElement extends TrackedElement { 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 efcfbeaab..401a05510 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 @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.ponder.elements; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; import com.simibubi.create.Create; @@ -12,11 +12,11 @@ import com.simibubi.create.foundation.ponder.PonderUI; import com.simibubi.create.foundation.ponder.content.PonderPalette; import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.vector.Vector2f; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.gui.Font; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.Vec2; +import net.minecraft.world.phys.Vec3; public class InputWindowElement extends AnimatedOverlayElement { @@ -24,7 +24,7 @@ public class InputWindowElement extends AnimatedOverlayElement { ResourceLocation key; AllIcons icon; ItemStack item = ItemStack.EMPTY; - private Vector3d sceneSpace; + private Vec3 sceneSpace; public InputWindowElement clone() { InputWindowElement inputWindowElement = new InputWindowElement(sceneSpace, direction); @@ -34,7 +34,7 @@ public class InputWindowElement extends AnimatedOverlayElement { return inputWindowElement; } - public InputWindowElement(Vector3d sceneSpace, Pointing direction) { + public InputWindowElement(Vec3 sceneSpace, Pointing direction) { this.sceneSpace = sceneSpace; this.direction = direction; } @@ -80,8 +80,8 @@ public class InputWindowElement extends AnimatedOverlayElement { } @Override - protected void render(PonderScene scene, PonderUI screen, MatrixStack ms, float partialTicks, float fade) { - FontRenderer font = screen.getFontRenderer(); + protected void render(PonderScene scene, PonderUI screen, PoseStack ms, float partialTicks, float fade) { + Font font = screen.getFontRenderer(); int width = 0; int height = 0; @@ -98,7 +98,7 @@ public class InputWindowElement extends AnimatedOverlayElement { if (fade < 1 / 16f) return; - Vector2f sceneToScreen = scene.getTransform() + Vec2 sceneToScreen = scene.getTransform() .sceneToScreen(sceneSpace, partialTicks); if (hasIcon) { 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 d088ba165..504bd8c37 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 @@ -1,32 +1,32 @@ package com.simibubi.create.foundation.ponder.elements; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; public class MinecartElement extends AnimatedSceneElement { - private Vector3d location; + private Vec3 location; private LerpedFloat rotation; - private AbstractMinecartEntity entity; + private AbstractMinecart entity; private MinecartConstructor constructor; private float initialRotation; public interface MinecartConstructor { - AbstractMinecartEntity create(World w, double x, double y, double z); + AbstractMinecart create(Level w, double x, double y, double z); } - public MinecartElement(Vector3d location, float rotation, MinecartConstructor constructor) { + public MinecartElement(Vec3 location, float rotation, MinecartConstructor constructor) { initialRotation = rotation; this.location = location.add(0, 1 / 16f, 0); this.constructor = constructor; @@ -63,7 +63,7 @@ public class MinecartElement extends AnimatedSceneElement { entity.zOld = entity.getZ(); } - public void setPositionOffset(Vector3d position, boolean immediate) { + public void setPositionOffset(Vec3 position, boolean immediate) { if (entity == null) return; entity.setPos(position.x, position.y, position.z); @@ -83,25 +83,25 @@ public class MinecartElement extends AnimatedSceneElement { rotation.startWithValue(angle); } - public Vector3d getPositionOffset() { - return entity != null ? entity.position() : Vector3d.ZERO; + public Vec3 getPositionOffset() { + return entity != null ? entity.position() : Vec3.ZERO; } - public Vector3d getRotation() { - return new Vector3d(0, rotation.getValue(), 0); + public Vec3 getRotation() { + return new Vec3(0, rotation.getValue(), 0); } @Override - protected void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float fade, float pt) { - EntityRendererManager entityrenderermanager = Minecraft.getInstance() + protected void renderLast(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) { + EntityRenderDispatcher entityrenderermanager = Minecraft.getInstance() .getEntityRenderDispatcher(); if (entity == null) entity = constructor.create(world, 0, 0, 0); ms.pushPose(); ms.translate(location.x, location.y, location.z); - ms.translate(MathHelper.lerp(pt, entity.xo, entity.getX()), - MathHelper.lerp(pt, entity.yo, entity.getY()), MathHelper.lerp(pt, entity.zo, entity.getZ())); + ms.translate(Mth.lerp(pt, entity.xo, entity.getX()), + Mth.lerp(pt, entity.yo, entity.getY()), Mth.lerp(pt, entity.zo, entity.getZ())); MatrixTransformStack.of(ms) .rotateY(rotation.getValue(pt)); 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 9b07cc2ec..c83d0c513 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 @@ -3,7 +3,7 @@ package com.simibubi.create.foundation.ponder.elements; import java.util.function.Supplier; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.ponder.PonderScene; @@ -11,29 +11,29 @@ import com.simibubi.create.foundation.ponder.PonderUI; import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.client.MainWindow; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.passive.ParrotEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.animal.Parrot; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class ParrotElement extends AnimatedSceneElement { - private Vector3d location; - private ParrotEntity entity; + private Vec3 location; + private Parrot entity; private ParrotPose pose; private Supplier initialPose; - public static ParrotElement create(Vector3d location, Supplier pose) { + public static ParrotElement create(Vec3 location, Supplier pose) { return new ParrotElement(location, pose); } - protected ParrotElement(Vector3d location, Supplier pose) { + protected ParrotElement(Vec3 location, Supplier pose) { this.location = location; initialPose = pose; setPose(initialPose.get()); @@ -81,7 +81,7 @@ public class ParrotElement extends AnimatedSceneElement { entity.zOld = entity.getZ(); } - public void setPositionOffset(Vector3d position, boolean immediate) { + public void setPositionOffset(Vec3 position, boolean immediate) { if (entity == null) return; entity.setPos(position.x, position.y, position.z); @@ -92,7 +92,7 @@ public class ParrotElement extends AnimatedSceneElement { entity.zo = position.z; } - public void setRotation(Vector3d eulers, boolean immediate) { + public void setRotation(Vec3 eulers, boolean immediate) { if (entity == null) return; entity.xRot = (float) eulers.x; @@ -103,17 +103,17 @@ public class ParrotElement extends AnimatedSceneElement { entity.yRotO = entity.yRot; } - public Vector3d getPositionOffset() { - return entity != null ? entity.position() : Vector3d.ZERO; + public Vec3 getPositionOffset() { + return entity != null ? entity.position() : Vec3.ZERO; } - public Vector3d getRotation() { - return entity != null ? new Vector3d(entity.xRot, entity.yRot, 0) : Vector3d.ZERO; + public Vec3 getRotation() { + return entity != null ? new Vec3(entity.xRot, entity.yRot, 0) : Vec3.ZERO; } @Override - protected void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float fade, float pt) { - EntityRendererManager entityrenderermanager = Minecraft.getInstance() + protected void renderLast(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) { + EntityRenderDispatcher entityrenderermanager = Minecraft.getInstance() .getEntityRenderDispatcher(); if (entity == null) { @@ -123,8 +123,8 @@ public class ParrotElement extends AnimatedSceneElement { ms.pushPose(); ms.translate(location.x, location.y, location.z); - ms.translate(MathHelper.lerp(pt, entity.xo, entity.getX()), - MathHelper.lerp(pt, entity.yo, entity.getY()), MathHelper.lerp(pt, entity.zo, entity.getZ())); + ms.translate(Mth.lerp(pt, entity.xo, entity.getX()), + Mth.lerp(pt, entity.yo, entity.getY()), Mth.lerp(pt, entity.zo, entity.getZ())); MatrixTransformStack.of(ms) .rotateY(AngleHelper.angleLerp(pt, entity.yRotO, entity.yRot)); @@ -139,10 +139,10 @@ public class ParrotElement extends AnimatedSceneElement { public static abstract class ParrotPose { - abstract void tick(PonderScene scene, ParrotEntity entity, Vector3d location); + abstract void tick(PonderScene scene, Parrot entity, Vec3 location); - ParrotEntity create(PonderWorld world) { - ParrotEntity entity = new ParrotEntity(EntityType.PARROT, world); + Parrot create(PonderWorld world) { + Parrot entity = new Parrot(EntityType.PARROT, world); int nextInt = Create.RANDOM.nextInt(5); entity.setVariant(nextInt == 1 ? 0 : nextInt); // blue parrots are kinda hard to see return entity; @@ -153,14 +153,14 @@ public class ParrotElement extends AnimatedSceneElement { public static class DancePose extends ParrotPose { @Override - ParrotEntity create(PonderWorld world) { - ParrotEntity entity = super.create(world); + Parrot create(PonderWorld world) { + Parrot entity = super.create(world); entity.setRecordPlayingNearby(BlockPos.ZERO, true); return entity; } @Override - void tick(PonderScene scene, ParrotEntity entity, Vector3d location) { + void tick(PonderScene scene, Parrot entity, Vec3 location) { entity.yRotO = entity.yRot; entity.yRot -= 2; } @@ -170,14 +170,14 @@ public class ParrotElement extends AnimatedSceneElement { public static class FlappyPose extends ParrotPose { @Override - void tick(PonderScene scene, ParrotEntity entity, Vector3d location) { + void tick(PonderScene scene, Parrot entity, Vec3 location) { double length = entity.position() .subtract(entity.xOld, entity.yOld, entity.zOld) .length(); entity.onGround = false; double phase = Math.min(length * 15, 8); float f = (float) ((PonderUI.ponderTicks % 100) * phase); - entity.flapSpeed = MathHelper.sin(f) + 1; + entity.flapSpeed = Mth.sin(f) + 1; if (length == 0) entity.flapSpeed = 0; } @@ -193,8 +193,8 @@ public class ParrotElement extends AnimatedSceneElement { } @Override - void tick(PonderScene scene, ParrotEntity entity, Vector3d location) { - TileEntity tileEntity = scene.getWorld() + void tick(PonderScene scene, Parrot entity, Vec3 location) { + BlockEntity tileEntity = scene.getWorld() .getBlockEntity(componentPos); if (!(tileEntity instanceof KineticTileEntity)) return; @@ -208,30 +208,30 @@ public class ParrotElement extends AnimatedSceneElement { public static abstract class FaceVecPose extends ParrotPose { @Override - void tick(PonderScene scene, ParrotEntity entity, Vector3d location) { - Vector3d p_200602_2_ = getFacedVec(scene); - Vector3d Vector3d = location.add(entity.getEyePosition(0)); + void tick(PonderScene scene, Parrot entity, Vec3 location) { + Vec3 p_200602_2_ = getFacedVec(scene); + Vec3 Vector3d = location.add(entity.getEyePosition(0)); double d0 = p_200602_2_.x - Vector3d.x; double d1 = p_200602_2_.y - Vector3d.y; double d2 = p_200602_2_.z - Vector3d.z; - double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); + double d3 = (double) Mth.sqrt(d0 * d0 + d2 * d2); float targetPitch = - MathHelper.wrapDegrees((float) -(MathHelper.atan2(d1, d3) * (double) (180F / (float) Math.PI))); + Mth.wrapDegrees((float) -(Mth.atan2(d1, d3) * (double) (180F / (float) Math.PI))); float targetYaw = - MathHelper.wrapDegrees((float) -(MathHelper.atan2(d2, d0) * (double) (180F / (float) Math.PI)) + 90); + Mth.wrapDegrees((float) -(Mth.atan2(d2, d0) * (double) (180F / (float) Math.PI)) + 90); entity.xRot = AngleHelper.angleLerp(.4f, entity.xRot, targetPitch); entity.yRot = AngleHelper.angleLerp(.4f, entity.yRot, targetYaw); } - protected abstract Vector3d getFacedVec(PonderScene scene); + protected abstract Vec3 getFacedVec(PonderScene scene); } public static class FacePointOfInterestPose extends FaceVecPose { @Override - protected Vector3d getFacedVec(PonderScene scene) { + protected Vec3 getFacedVec(PonderScene scene) { return scene.getPointOfInterest(); } @@ -240,9 +240,9 @@ public class ParrotElement extends AnimatedSceneElement { public static class FaceCursorPose extends FaceVecPose { @Override - protected Vector3d getFacedVec(PonderScene scene) { + protected Vec3 getFacedVec(PonderScene scene) { Minecraft minecraft = Minecraft.getInstance(); - MainWindow w = minecraft.getWindow(); + Window w = minecraft.getWindow(); double mouseX = minecraft.mouseHandler.xpos() * w.getGuiScaledWidth() / w.getScreenWidth(); double mouseY = minecraft.mouseHandler.ypos() * w.getGuiScaledHeight() / w.getScreenHeight(); return scene.getTransform() diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/PonderOverlayElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/PonderOverlayElement.java index 89db05a60..aa1501b5e 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/PonderOverlayElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/PonderOverlayElement.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.ponder.elements; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.ponder.PonderElement; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderUI; @@ -9,6 +9,6 @@ public abstract class PonderOverlayElement extends PonderElement { public void tick(PonderScene scene) {} - public abstract void render(PonderScene scene, PonderUI screen, MatrixStack ms, float partialTicks); + public abstract void render(PonderScene scene, PonderUI screen, PoseStack ms, float partialTicks); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/PonderSceneElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/PonderSceneElement.java index dfa176d04..ed2e1ca40 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/PonderSceneElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/PonderSceneElement.java @@ -1,18 +1,18 @@ package com.simibubi.create.foundation.ponder.elements; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.ponder.PonderElement; import com.simibubi.create.foundation.ponder.PonderWorld; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; public abstract class PonderSceneElement extends PonderElement { - public abstract void renderFirst(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float pt); + public abstract void renderFirst(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float pt); - public abstract void renderLayer(PonderWorld world, IRenderTypeBuffer buffer, RenderType type, MatrixStack ms, float pt); + public abstract void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float pt); - public abstract void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float pt); + public abstract void renderLast(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float pt); } 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 cbfb14e7a..fbcdfb0fb 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 @@ -3,7 +3,7 @@ package com.simibubi.create.foundation.ponder.elements; import java.util.List; import java.util.function.Supplier; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.BoxElement; import com.simibubi.create.foundation.gui.Theme; import com.simibubi.create.foundation.ponder.PonderLocalization; @@ -12,13 +12,13 @@ import com.simibubi.create.foundation.ponder.PonderUI; import com.simibubi.create.foundation.ponder.content.PonderPalette; import com.simibubi.create.foundation.utility.Color; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector2f; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextProperties; -import net.minecraft.util.text.Style; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import com.mojang.math.Matrix4f; +import net.minecraft.world.phys.Vec2; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.network.chat.Style; import net.minecraftforge.fml.client.gui.GuiUtils; public class TextWindowElement extends AnimatedOverlayElement { @@ -29,7 +29,7 @@ public class TextWindowElement extends AnimatedOverlayElement { // from 0 to 200 int y; - Vector3d vec; + Vec3 vec; boolean nearScene = false; int color = PonderPalette.WHITE.getColor(); @@ -47,7 +47,7 @@ public class TextWindowElement extends AnimatedOverlayElement { return this; } - public Builder pointAt(Vector3d vec) { + public Builder pointAt(Vec3 vec) { TextWindowElement.this.vec = vec; return this; } @@ -89,26 +89,26 @@ public class TextWindowElement extends AnimatedOverlayElement { } @Override - protected void render(PonderScene scene, PonderUI screen, MatrixStack ms, float partialTicks, float fade) { + protected void render(PonderScene scene, PonderUI screen, PoseStack ms, float partialTicks, float fade) { if (bakedText == null) bakedText = textGetter.get(); if (fade < 1 / 16f) return; - Vector2f sceneToScreen = vec != null ? scene.getTransform() - .sceneToScreen(vec, partialTicks) : new Vector2f(screen.width / 2, (screen.height - 200) / 2 + y - 8); + Vec2 sceneToScreen = vec != null ? scene.getTransform() + .sceneToScreen(vec, partialTicks) : new Vec2(screen.width / 2, (screen.height - 200) / 2 + y - 8); float yDiff = (screen.height / 2f - sceneToScreen.y - 10) / 100f; - int targetX = (int) (screen.width * MathHelper.lerp(yDiff * yDiff, 6f / 8, 5f / 8)); + int targetX = (int) (screen.width * Mth.lerp(yDiff * yDiff, 6f / 8, 5f / 8)); if (nearScene) targetX = (int) Math.min(targetX, sceneToScreen.x + 50); int textWidth = Math.min(screen.width - targetX, 180); - List lines = screen.getFontRenderer().getSplitter().splitLines(bakedText, textWidth, Style.EMPTY); + List lines = screen.getFontRenderer().getSplitter().splitLines(bakedText, textWidth, Style.EMPTY); int boxWidth = 0; - for (ITextProperties line : lines) + for (FormattedText line : lines) boxWidth = Math.max(boxWidth, screen.getFontRenderer().width(line)); int boxHeight = screen.getFontRenderer() diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/TrackedElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/TrackedElement.java index b7c2cd7f9..8c66bcdd3 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/TrackedElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/TrackedElement.java @@ -3,10 +3,10 @@ package com.simibubi.create.foundation.ponder.elements; import java.lang.ref.WeakReference; import java.util.function.Consumer; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.ponder.PonderWorld; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; public abstract class TrackedElement extends PonderSceneElement { @@ -31,12 +31,12 @@ public abstract class TrackedElement extends PonderSceneElement { } @Override - public void renderFirst(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float pt) {} + public void renderFirst(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float pt) {} @Override - public void renderLayer(PonderWorld world, IRenderTypeBuffer buffer, RenderType type, MatrixStack ms, float pt) {} + public void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float pt) {} @Override - public void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float pt) {} + public void renderLast(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float pt) {} } 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 80f02ede3..ec6a84fbd 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 @@ -9,10 +9,10 @@ import java.util.Random; import org.lwjgl.opengl.GL11; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.mojang.blaze3d.vertex.MatrixApplyingVertexBuilder; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.vertex.SheetedDecalTextureGenerator; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderWorld; @@ -25,33 +25,33 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockModelRenderer; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.block.ModelBlockRenderer; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import com.mojang.blaze3d.vertex.BufferBuilder; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.model.ModelBakery; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.fluid.FluidState; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceContext.BlockMode; -import net.minecraft.util.math.RayTraceContext.FluidMode; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.block.entity.TickableBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.model.data.EmptyModelData; @@ -59,17 +59,17 @@ public class WorldSectionElement extends AnimatedSceneElement { public static final Compartment> DOC_WORLD_SECTION = new Compartment<>(); - List renderedTileEntities; - List tickableTileEntities; + List renderedTileEntities; + List tickableTileEntities; Selection section; boolean redraw; - Vector3d prevAnimatedOffset = Vector3d.ZERO; - Vector3d animatedOffset = Vector3d.ZERO; - Vector3d prevAnimatedRotation = Vector3d.ZERO; - Vector3d animatedRotation = Vector3d.ZERO; - Vector3d centerOfRotation = Vector3d.ZERO; - Vector3d stabilizationAnchor = null; + Vec3 prevAnimatedOffset = Vec3.ZERO; + Vec3 animatedOffset = Vec3.ZERO; + Vec3 prevAnimatedRotation = Vec3.ZERO; + Vec3 animatedRotation = Vec3.ZERO; + Vec3 centerOfRotation = Vec3.ZERO; + Vec3 stabilizationAnchor = null; BlockPos selectedBlock; @@ -105,11 +105,11 @@ public class WorldSectionElement extends AnimatedSceneElement { queueRedraw(); } - public void setCenterOfRotation(Vector3d center) { + public void setCenterOfRotation(Vec3 center) { centerOfRotation = center; } - public void stabilizeRotation(Vector3d anchor) { + public void stabilizeRotation(Vec3 anchor) { stabilizationAnchor = anchor; } @@ -129,10 +129,10 @@ public class WorldSectionElement extends AnimatedSceneElement { } public void resetAnimatedTransform() { - prevAnimatedOffset = Vector3d.ZERO; - animatedOffset = Vector3d.ZERO; - prevAnimatedRotation = Vector3d.ZERO; - animatedRotation = Vector3d.ZERO; + prevAnimatedOffset = Vec3.ZERO; + animatedOffset = Vec3.ZERO; + prevAnimatedRotation = Vec3.ZERO; + animatedRotation = Vec3.ZERO; } public void queueRedraw() { @@ -147,23 +147,23 @@ public class WorldSectionElement extends AnimatedSceneElement { section = null; } - public void setAnimatedRotation(Vector3d eulerAngles, boolean force) { + public void setAnimatedRotation(Vec3 eulerAngles, boolean force) { this.animatedRotation = eulerAngles; if (force) prevAnimatedRotation = animatedRotation; } - public Vector3d getAnimatedRotation() { + public Vec3 getAnimatedRotation() { return animatedRotation; } - public void setAnimatedOffset(Vector3d offset, boolean force) { + public void setAnimatedOffset(Vec3 offset, boolean force) { this.animatedOffset = offset; if (force) prevAnimatedOffset = animatedOffset; } - public Vector3d getAnimatedOffset() { + public Vec3 getAnimatedOffset() { return animatedOffset; } @@ -173,15 +173,15 @@ public class WorldSectionElement extends AnimatedSceneElement { } class WorldSectionRayTraceResult { - Vector3d actualHitVec; + Vec3 actualHitVec; BlockPos worldPos; } - public Pair rayTrace(PonderWorld world, Vector3d source, Vector3d target) { + public Pair rayTrace(PonderWorld world, Vec3 source, Vec3 target) { world.setMask(this.section); - Vector3d transformedTarget = reverseTransformVec(target); - BlockRayTraceResult rayTraceBlocks = world.clip(new RayTraceContext(reverseTransformVec(source), - transformedTarget, BlockMode.OUTLINE, FluidMode.NONE, null)); + Vec3 transformedTarget = reverseTransformVec(target); + BlockHitResult rayTraceBlocks = world.clip(new ClipContext(reverseTransformVec(source), + transformedTarget, Block.OUTLINE, Fluid.NONE, null)); world.clearMask(); if (rayTraceBlocks == null) @@ -194,19 +194,19 @@ public class WorldSectionElement extends AnimatedSceneElement { .lengthSqr() / source.subtract(target) .lengthSqr(); - Vector3d actualHit = VecHelper.lerp((float) t, target, source); + Vec3 actualHit = VecHelper.lerp((float) t, target, source); return Pair.of(actualHit, rayTraceBlocks.getBlockPos()); } - private Vector3d reverseTransformVec(Vector3d in) { + private Vec3 reverseTransformVec(Vec3 in) { float pt = AnimationTickHolder.getPartialTicks(); in = in.subtract(VecHelper.lerp(pt, prevAnimatedOffset, animatedOffset)); - if (!animatedRotation.equals(Vector3d.ZERO) || !prevAnimatedRotation.equals(Vector3d.ZERO)) { + if (!animatedRotation.equals(Vec3.ZERO) || !prevAnimatedRotation.equals(Vec3.ZERO)) { if (centerOfRotation == null) centerOfRotation = section.getCenter(); - double rotX = MathHelper.lerp(pt, prevAnimatedRotation.x, animatedRotation.x); - double rotZ = MathHelper.lerp(pt, prevAnimatedRotation.z, animatedRotation.z); - double rotY = MathHelper.lerp(pt, prevAnimatedRotation.y, animatedRotation.y); + double rotX = Mth.lerp(pt, prevAnimatedRotation.x, animatedRotation.x); + double rotZ = Mth.lerp(pt, prevAnimatedRotation.z, animatedRotation.z); + double rotY = Mth.lerp(pt, prevAnimatedRotation.y, animatedRotation.y); in = in.subtract(centerOfRotation); in = VecHelper.rotate(in, -rotX, Axis.X); in = VecHelper.rotate(in, -rotZ, Axis.Z); @@ -223,15 +223,15 @@ public class WorldSectionElement extends AnimatedSceneElement { return in; } - public void transformMS(MatrixStack ms, float pt) { + public void transformMS(PoseStack ms, float pt) { MatrixTransformStack.of(ms) .translate(VecHelper.lerp(pt, prevAnimatedOffset, animatedOffset)); - if (!animatedRotation.equals(Vector3d.ZERO) || !prevAnimatedRotation.equals(Vector3d.ZERO)) { + if (!animatedRotation.equals(Vec3.ZERO) || !prevAnimatedRotation.equals(Vec3.ZERO)) { if (centerOfRotation == null) centerOfRotation = section.getCenter(); - double rotX = MathHelper.lerp(pt, prevAnimatedRotation.x, animatedRotation.x); - double rotZ = MathHelper.lerp(pt, prevAnimatedRotation.z, animatedRotation.z); - double rotY = MathHelper.lerp(pt, prevAnimatedRotation.y, animatedRotation.y); + double rotX = Mth.lerp(pt, prevAnimatedRotation.x, animatedRotation.x); + double rotZ = Mth.lerp(pt, prevAnimatedRotation.z, animatedRotation.z); + double rotY = Mth.lerp(pt, prevAnimatedRotation.y, animatedRotation.y); MatrixTransformStack.of(ms) .translate(centerOfRotation) .rotateX(rotX) @@ -260,8 +260,8 @@ public class WorldSectionElement extends AnimatedSceneElement { tickableTileEntities.removeIf(te -> scene.getWorld() .getBlockEntity(te.getBlockPos()) != te); tickableTileEntities.forEach(te -> { - if (te instanceof ITickableTileEntity) - ((ITickableTileEntity) te).tick(); + if (te instanceof TickableBlockEntity) + ((TickableBlockEntity) te).tick(); }); } @@ -280,7 +280,7 @@ public class WorldSectionElement extends AnimatedSceneElement { tickableTileEntities = new ArrayList<>(); renderedTileEntities = new ArrayList<>(); section.forEach(pos -> { - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity tileEntity = world.getBlockEntity(pos); if (tileEntity == null) return; tickableTileEntities.add(tileEntity); @@ -290,17 +290,17 @@ public class WorldSectionElement extends AnimatedSceneElement { } @Override - protected void renderLayer(PonderWorld world, IRenderTypeBuffer buffer, RenderType type, MatrixStack ms, float fade, + protected void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float fade, float pt) { transformMS(ms, pt); renderStructure(world, ms, buffer, type, fade); } @Override - public void renderFirst(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float fade, float pt) { + public void renderFirst(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) { int light = -1; if (fade != 1) - light = (int) (MathHelper.lerp(fade, 5, 14)); + light = (int) (Mth.lerp(fade, 5, 14)); if (redraw) { renderedTileEntities = null; tickableTileEntities = null; @@ -311,21 +311,21 @@ public class WorldSectionElement extends AnimatedSceneElement { world.popLight(); Map blockBreakingProgressions = world.getBlockBreakingProgressions(); - MatrixStack overlayMS = null; + PoseStack overlayMS = null; for (Entry entry : blockBreakingProgressions.entrySet()) { BlockPos pos = entry.getKey(); if (!section.test(pos)) continue; if (overlayMS == null) { - overlayMS = new MatrixStack(); + overlayMS = new PoseStack(); world.scene.getTransform() .apply(overlayMS, pt, true); transformMS(overlayMS, pt); } ms.pushPose(); ms.translate(pos.getX(), pos.getY(), pos.getZ()); - IVertexBuilder builder = new MatrixApplyingVertexBuilder( + VertexConsumer builder = new SheetedDecalTextureGenerator( buffer.getBuffer(ModelBakery.DESTROY_TYPES.get(entry.getValue())), overlayMS.last().pose(), overlayMS.last().normal()); @@ -336,7 +336,7 @@ public class WorldSectionElement extends AnimatedSceneElement { } } - protected void renderStructure(PonderWorld world, MatrixStack ms, IRenderTypeBuffer buffer, RenderType type, + protected void renderStructure(PonderWorld world, PoseStack ms, MultiBufferSource buffer, RenderType type, float fade) { SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE; int code = hashCode() ^ world.hashCode(); @@ -356,7 +356,7 @@ public class WorldSectionElement extends AnimatedSceneElement { } @Override - protected void renderLast(PonderWorld world, IRenderTypeBuffer buffer, MatrixStack ms, float fade, float pt) { + protected void renderLast(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) { redraw = false; if (selectedBlock == null) return; @@ -364,32 +364,32 @@ public class WorldSectionElement extends AnimatedSceneElement { if (blockState.isAir()) return; VoxelShape shape = - blockState.getShape(world, selectedBlock, ISelectionContext.of(Minecraft.getInstance().player)); + blockState.getShape(world, selectedBlock, CollisionContext.of(Minecraft.getInstance().player)); if (shape.isEmpty()) return; ms.pushPose(); transformMS(ms, pt); RenderSystem.disableTexture(); - WorldRenderer.renderLineBox(ms, buffer.getBuffer(RenderType.lines()), shape.bounds() + LevelRenderer.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) { + private void renderTileEntities(PonderWorld world, PoseStack ms, MultiBufferSource buffer, float pt) { loadTEsIfMissing(world); TileEntityRenderHelper.renderTileEntities(world, renderedTileEntities, ms, buffer, pt); } private SuperByteBuffer buildStructureBuffer(PonderWorld world, RenderType layer) { ForgeHooksClient.setRenderLayer(layer); - MatrixStack ms = new MatrixStack(); - BlockRendererDispatcher dispatcher = Minecraft.getInstance() + PoseStack ms = new PoseStack(); + BlockRenderDispatcher dispatcher = Minecraft.getInstance() .getBlockRenderer(); - BlockModelRenderer blockRenderer = dispatcher.getModelRenderer(); + ModelBlockRenderer blockRenderer = dispatcher.getModelRenderer(); Random random = new Random(); - BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); - builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + BufferBuilder builder = new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize()); + builder.begin(GL11.GL_QUADS, DefaultVertexFormat.BLOCK); world.setMask(this.section); section.forEach(pos -> { @@ -399,15 +399,15 @@ public class WorldSectionElement extends AnimatedSceneElement { ms.pushPose(); ms.translate(pos.getX(), pos.getY(), pos.getZ()); - if (state.getRenderShape() != BlockRenderType.ENTITYBLOCK_ANIMATED && state.getBlock() != Blocks.AIR - && RenderTypeLookup.canRenderInLayer(state, layer)) { - TileEntity tileEntity = world.getBlockEntity(pos); + if (state.getRenderShape() != RenderShape.ENTITYBLOCK_ANIMATED && state.getBlock() != Blocks.AIR + && ItemBlockRenderTypes.canRenderInLayer(state, layer)) { + BlockEntity 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)) + if (!ifluidstate.isEmpty() && ItemBlockRenderTypes.canRenderInLayer(ifluidstate, layer)) dispatcher.renderLiquid(pos, world, builder, ifluidstate); ms.popPose(); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateElementInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateElementInstruction.java index 21e2a6c4a..1d9183d6a 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateElementInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateElementInstruction.java @@ -7,21 +7,21 @@ import com.simibubi.create.foundation.ponder.ElementLink; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.elements.PonderSceneElement; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public class AnimateElementInstruction extends TickingInstruction { - protected Vector3d deltaPerTick; - protected Vector3d totalDelta; - protected Vector3d target; + protected Vec3 deltaPerTick; + protected Vec3 totalDelta; + protected Vec3 target; protected ElementLink link; protected T element; - private BiConsumer setter; - private Function getter; + private BiConsumer setter; + private Function getter; - protected AnimateElementInstruction(ElementLink link, Vector3d totalDelta, int ticks, - BiConsumer setter, Function getter) { + protected AnimateElementInstruction(ElementLink link, Vec3 totalDelta, int ticks, + BiConsumer setter, Function getter) { super(false, ticks); this.link = link; this.setter = setter; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateMinecartInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateMinecartInstruction.java index a96e111d5..de49e865b 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateMinecartInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateMinecartInstruction.java @@ -6,22 +6,22 @@ import java.util.function.Function; import com.simibubi.create.foundation.ponder.ElementLink; import com.simibubi.create.foundation.ponder.elements.MinecartElement; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public class AnimateMinecartInstruction extends AnimateElementInstruction { public static AnimateMinecartInstruction rotate(ElementLink link, float rotation, int ticks) { - return new AnimateMinecartInstruction(link, new Vector3d(0, rotation, 0), ticks, + return new AnimateMinecartInstruction(link, new Vec3(0, rotation, 0), ticks, (wse, v) -> wse.setRotation((float) v.y, ticks == 0), MinecartElement::getRotation); } - public static AnimateMinecartInstruction move(ElementLink link, Vector3d offset, int ticks) { + public static AnimateMinecartInstruction move(ElementLink link, Vec3 offset, int ticks) { return new AnimateMinecartInstruction(link, offset, ticks, (wse, v) -> wse.setPositionOffset(v, ticks == 0), MinecartElement::getPositionOffset); } - protected AnimateMinecartInstruction(ElementLink link, Vector3d totalDelta, int ticks, - BiConsumer setter, Function getter) { + protected AnimateMinecartInstruction(ElementLink link, Vec3 totalDelta, int ticks, + BiConsumer setter, Function getter) { super(link, totalDelta, ticks, setter, getter); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateParrotInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateParrotInstruction.java index e0a45765b..7a7165b9f 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateParrotInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateParrotInstruction.java @@ -6,22 +6,22 @@ import java.util.function.Function; import com.simibubi.create.foundation.ponder.ElementLink; import com.simibubi.create.foundation.ponder.elements.ParrotElement; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public class AnimateParrotInstruction extends AnimateElementInstruction { - public static AnimateParrotInstruction rotate(ElementLink link, Vector3d rotation, int ticks) { + public static AnimateParrotInstruction rotate(ElementLink link, Vec3 rotation, int ticks) { return new AnimateParrotInstruction(link, rotation, ticks, (wse, v) -> wse.setRotation(v, ticks == 0), ParrotElement::getRotation); } - public static AnimateParrotInstruction move(ElementLink link, Vector3d offset, int ticks) { + public static AnimateParrotInstruction move(ElementLink link, Vec3 offset, int ticks) { return new AnimateParrotInstruction(link, offset, ticks, (wse, v) -> wse.setPositionOffset(v, ticks == 0), ParrotElement::getPositionOffset); } - protected AnimateParrotInstruction(ElementLink link, Vector3d totalDelta, int ticks, - BiConsumer setter, Function getter) { + protected AnimateParrotInstruction(ElementLink link, Vec3 totalDelta, int ticks, + BiConsumer setter, Function getter) { super(link, totalDelta, ticks, setter, getter); } 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 74d943fd0..62e6497da 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 @@ -10,8 +10,8 @@ import com.simibubi.create.content.contraptions.components.structureMovement.pul import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderWorld; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; public class AnimateTileEntityInstruction extends TickingInstruction { @@ -74,7 +74,7 @@ public class AnimateTileEntityInstruction extends TickingInstruction { } private static Optional castIfPresent(PonderWorld world, BlockPos pos, Class teType) { - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity 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/AnimateWorldSectionInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateWorldSectionInstruction.java index 5fb7b2c23..7bce8fbab 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateWorldSectionInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/AnimateWorldSectionInstruction.java @@ -6,23 +6,23 @@ import java.util.function.Function; import com.simibubi.create.foundation.ponder.ElementLink; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public class AnimateWorldSectionInstruction extends AnimateElementInstruction { - public static AnimateWorldSectionInstruction rotate(ElementLink link, Vector3d rotation, + public static AnimateWorldSectionInstruction rotate(ElementLink link, Vec3 rotation, int ticks) { return new AnimateWorldSectionInstruction(link, rotation, ticks, (wse, v) -> wse.setAnimatedRotation(v, ticks == 0), WorldSectionElement::getAnimatedRotation); } - public static AnimateWorldSectionInstruction move(ElementLink link, Vector3d offset, int ticks) { + public static AnimateWorldSectionInstruction move(ElementLink link, Vec3 offset, int ticks) { return new AnimateWorldSectionInstruction(link, offset, ticks, (wse, v) -> wse.setAnimatedOffset(v, ticks == 0), WorldSectionElement::getAnimatedOffset); } - protected AnimateWorldSectionInstruction(ElementLink link, Vector3d totalDelta, int ticks, - BiConsumer setter, Function getter) { + protected AnimateWorldSectionInstruction(ElementLink link, Vec3 totalDelta, int ticks, + BiConsumer setter, Function getter) { super(link, totalDelta, ticks, setter, getter); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/ChaseAABBInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/ChaseAABBInstruction.java index e0a19f30b..3472b54b9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/ChaseAABBInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/ChaseAABBInstruction.java @@ -3,15 +3,15 @@ package com.simibubi.create.foundation.ponder.instructions; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.content.PonderPalette; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.world.phys.AABB; public class ChaseAABBInstruction extends TickingInstruction { - private AxisAlignedBB bb; + private AABB bb; private Object slot; private PonderPalette color; - public ChaseAABBInstruction(PonderPalette color, Object slot, AxisAlignedBB bb, int ticks) { + public ChaseAABBInstruction(PonderPalette color, Object slot, AABB bb, int ticks) { super(false, ticks); this.color = color; this.slot = slot; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/CreateMinecartInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/CreateMinecartInstruction.java index a6216f177..0ed9c774a 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/CreateMinecartInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/CreateMinecartInstruction.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.ponder.instructions; import com.simibubi.create.foundation.ponder.elements.MinecartElement; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; public class CreateMinecartInstruction extends FadeIntoSceneInstruction { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/CreateParrotInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/CreateParrotInstruction.java index 56ada8ae2..80ebfc806 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/CreateParrotInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/CreateParrotInstruction.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.ponder.instructions; import com.simibubi.create.foundation.ponder.elements.ParrotElement; -import net.minecraft.util.Direction; +import net.minecraft.core.Direction; public class CreateParrotInstruction extends FadeIntoSceneInstruction { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/DisplayWorldSectionInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/DisplayWorldSectionInstruction.java index d9f5c70fc..bb19f0dff 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/DisplayWorldSectionInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/DisplayWorldSectionInstruction.java @@ -10,8 +10,8 @@ import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.Selection; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; public class DisplayWorldSectionInstruction extends FadeIntoSceneInstruction { 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 d66a4c2a9..223ab83fa 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 @@ -5,30 +5,30 @@ import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderWorld; import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.particles.IParticleData; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.world.phys.Vec3; public class EmitParticlesInstruction extends TickingInstruction { - private Vector3d anchor; + private Vec3 anchor; private Emitter emitter; private float runsPerTick; @FunctionalInterface public static interface Emitter { - public static Emitter simple(T data, Vector3d motion) { + public static Emitter simple(T data, Vec3 motion) { return (w, x, y, z) -> w.addParticle(data, x, y, z, motion.x, motion.y, motion.z); } - public static Emitter withinBlockSpace(T data, Vector3d motion) { + public static Emitter withinBlockSpace(T data, Vec3 motion) { return (w, x, y, z) -> w.addParticle(data, Math.floor(x) + Create.RANDOM.nextFloat(), Math.floor(y) + Create.RANDOM.nextFloat(), Math.floor(z) + Create.RANDOM.nextFloat(), motion.x, motion.y, motion.z); } - static ParticleManager paticleManager() { + static ParticleEngine paticleManager() { return Minecraft.getInstance().particleEngine; } @@ -36,7 +36,7 @@ public class EmitParticlesInstruction extends TickingInstruction { } - public EmitParticlesInstruction(Vector3d anchor, Emitter emitter, float runsPerTick, int ticks) { + public EmitParticlesInstruction(Vec3 anchor, Emitter emitter, float runsPerTick, int ticks) { super(false, ticks); this.anchor = anchor; this.emitter = emitter; 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 be5faf3e2..2f3537c8c 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 @@ -4,8 +4,8 @@ import com.simibubi.create.foundation.ponder.ElementLink; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.elements.AnimatedSceneElement; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.Vec3; public abstract class FadeIntoSceneInstruction extends TickingInstruction { @@ -25,7 +25,7 @@ public abstract class FadeIntoSceneInstruction e scene.addElement(element); element.setVisible(true); element.setFade(0); - element.setFadeVec(Vector3d.atLowerCornerOf(fadeInFrom.getNormal()).scale(.5f)); + element.setFadeVec(Vec3.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 83680d1a2..5cc438f14 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 @@ -4,8 +4,8 @@ import com.simibubi.create.foundation.ponder.ElementLink; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.elements.AnimatedSceneElement; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.Vec3; public class FadeOutOfSceneInstruction extends TickingInstruction { @@ -27,7 +27,7 @@ public class FadeOutOfSceneInstruction extends T return; element.setVisible(true); element.setFade(1); - element.setFadeVec(Vector3d.atLowerCornerOf(fadeOutTo.getNormal()).scale(.5f)); + element.setFadeVec(Vec3.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 63e0f91ef..e901ece96 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 @@ -4,8 +4,8 @@ import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.elements.AnimatedOverlayElement; import com.simibubi.create.foundation.ponder.elements.AnimatedSceneElement; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.Vec3; public class HideAllInstruction extends TickingInstruction { @@ -25,7 +25,7 @@ public class HideAllInstruction extends TickingInstruction { AnimatedSceneElement animatedSceneElement = (AnimatedSceneElement) element; animatedSceneElement.setFade(1); animatedSceneElement - .setFadeVec(fadeOutTo == null ? null : Vector3d.atLowerCornerOf(fadeOutTo.getNormal()).scale(.5f)); + .setFadeVec(fadeOutTo == null ? null : Vec3.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 95207ad96..aafbae409 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 @@ -3,15 +3,15 @@ package com.simibubi.create.foundation.ponder.instructions; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.content.PonderPalette; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; public class HighlightValueBoxInstruction extends TickingInstruction { - private Vector3d vec; - private Vector3d expands; + private Vec3 vec; + private Vec3 expands; - public HighlightValueBoxInstruction(Vector3d vec, Vector3d expands, int duration) { + public HighlightValueBoxInstruction(Vec3 vec, Vec3 expands, int duration) { super(false, duration); this.vec = vec; this.expands = expands; @@ -20,8 +20,8 @@ public class HighlightValueBoxInstruction extends TickingInstruction { @Override public void tick(PonderScene scene) { super.tick(scene); - AxisAlignedBB point = new AxisAlignedBB(vec, vec); - AxisAlignedBB expanded = point.inflate(expands.x, expands.y, expands.z); + AABB point = new AABB(vec, vec); + AABB 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/LineInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/LineInstruction.java index 63bd171d2..27530110f 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/LineInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/LineInstruction.java @@ -3,15 +3,15 @@ package com.simibubi.create.foundation.ponder.instructions; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.content.PonderPalette; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public class LineInstruction extends TickingInstruction { private PonderPalette color; - private Vector3d start; - private Vector3d end; + private Vec3 start; + private Vec3 end; - public LineInstruction(PonderPalette color, Vector3d start, Vector3d end, int ticks) { + public LineInstruction(PonderPalette color, Vec3 start, Vec3 end, int ticks) { super(false, ticks); this.color = color; this.start = start; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/MovePoiInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/MovePoiInstruction.java index a914595de..8a4dab91f 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/MovePoiInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/MovePoiInstruction.java @@ -3,13 +3,13 @@ package com.simibubi.create.foundation.ponder.instructions; import com.simibubi.create.foundation.ponder.PonderInstruction; import com.simibubi.create.foundation.ponder.PonderScene; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.Vec3; public class MovePoiInstruction extends PonderInstruction { - private Vector3d poi; + private Vec3 poi; - public MovePoiInstruction(Vector3d poi) { + public MovePoiInstruction(Vec3 poi) { this.poi = poi; } 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 e2e9d016b..ed1ca407d 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 @@ -6,8 +6,8 @@ import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.ponder.Selection; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; public class ReplaceBlocksInstruction extends WorldModifyInstruction { 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 2a8a46b3d..0080947c5 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 @@ -7,18 +7,18 @@ import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.ponder.Selection; import com.simibubi.create.foundation.tileEntity.SyncedTileEntity; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; public class TileEntityDataInstruction extends WorldModifyInstruction { private boolean redraw; - private UnaryOperator data; - private Class type; + private UnaryOperator data; + private Class type; - public TileEntityDataInstruction(Selection selection, Class type, - UnaryOperator data, boolean redraw) { + public TileEntityDataInstruction(Selection selection, Class type, + UnaryOperator data, boolean redraw) { super(selection); this.type = type; this.data = data; @@ -32,10 +32,10 @@ public class TileEntityDataInstruction extends WorldModifyInstruction { if (!world.getBounds() .isInside(pos)) return; - TileEntity tileEntity = world.getBlockEntity(pos); + BlockEntity tileEntity = world.getBlockEntity(pos); if (!type.isInstance(tileEntity)) return; - CompoundNBT apply = data.apply(tileEntity.save(new CompoundNBT())); + CompoundTag apply = data.apply(tileEntity.save(new CompoundTag())); BlockState state = world.getBlockState(pos); if (tileEntity instanceof SyncedTileEntity) ((SyncedTileEntity) tileEntity).readClientUpdate(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 59abb1d59..d5e9e9d3c 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 @@ -4,7 +4,7 @@ import java.util.function.BiConsumer; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.Theme; import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget; @@ -28,7 +28,7 @@ public class ChapterLabel extends AbstractSimiWidget { } @Override - public void render(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void render(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { UIRenderHelper.streak(ms, 0, x, y + height / 2, height - 2, width); Minecraft.getInstance().font.draw(ms, chapter.getTitle(), x + 50, y + 20, Theme.i(Theme.Key.TEXT_ACCENT_SLIGHT)); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/ui/LayoutHelper.java b/src/main/java/com/simibubi/create/foundation/ponder/ui/LayoutHelper.java index 32ca1df1d..f815220b9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/ui/LayoutHelper.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/ui/LayoutHelper.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.ponder.ui; -import net.minecraft.client.renderer.Rectangle2d; +import net.minecraft.client.renderer.Rect2i; public interface LayoutHelper { @@ -18,10 +18,10 @@ public interface LayoutHelper { int getTotalHeight(); - default Rectangle2d getArea() { + default Rect2i getArea() { int lWidth = getTotalWidth(); int lHeight = getTotalHeight(); - return new Rectangle2d(-lWidth / 2, -lHeight / 2, lWidth, lHeight); + return new Rect2i(-lWidth / 2, -lHeight / 2, lWidth, lHeight); } class CenteredHorizontalLayoutHelper implements LayoutHelper { 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 bce4be1b4..cbbcf9b2f 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 @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.ponder.ui; import javax.annotation.Nonnull; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.RenderElement; import com.simibubi.create.foundation.gui.Theme; @@ -15,15 +15,15 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.KeyMapping; +import net.minecraft.world.item.ItemStack; +import net.minecraft.util.Mth; public class PonderButton extends BoxWidget { protected ItemStack item; protected PonderTag tag; - protected KeyBinding shortcut; + protected KeyMapping shortcut; protected LerpedFloat flash = LerpedFloat.linear().startWithValue(0).chase(0, 0.1f, LerpedFloat.Chaser.EXP); public PonderButton(int x, int y) { @@ -37,7 +37,7 @@ public class PonderButton extends BoxWidget { paddingY = 2; } - public T withShortcut(KeyBinding key) { + public T withShortcut(KeyMapping key) { this.shortcut = key; //noinspection unchecked return (T) this; @@ -74,22 +74,22 @@ public class PonderButton extends BoxWidget { } @Override - protected void beforeRender(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + protected void beforeRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { super.beforeRender(ms, mouseX, mouseY, partialTicks); float flashValue = flash.getValue(partialTicks); if (flashValue > .1f) { - float sin = 0.5f + 0.5f * MathHelper.sin((AnimationTickHolder.getTicks(true) + partialTicks) / 5f); + float sin = 0.5f + 0.5f * Mth.sin((AnimationTickHolder.getTicks(true) + partialTicks) / 5f); sin *= flashValue; - Color nc1 = new Color(255, 255, 255, MathHelper.clamp(gradientColor1.getAlpha() + 150, 0, 255)); - Color nc2 = new Color(155, 155, 155, MathHelper.clamp(gradientColor2.getAlpha() + 150, 0, 255)); + Color nc1 = new Color(255, 255, 255, Mth.clamp(gradientColor1.getAlpha() + 150, 0, 255)); + Color nc2 = new Color(155, 155, 155, Mth.clamp(gradientColor2.getAlpha() + 150, 0, 255)); gradientColor1 = gradientColor1.mixWith(nc1, sin); gradientColor2 = gradientColor2.mixWith(nc2, sin); } } @Override - public void renderButton(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + public void renderButton(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) { super.renderButton(ms, mouseX, mouseY, partialTicks); float fadeValue = fade.getValue(); diff --git a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java index b598f3c21..bb7fa1fdc 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java @@ -15,6 +15,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import StructType; + @OnlyIn(Dist.CLIENT) public class AllMaterialSpecs { public static void init() { diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index 5dd47e831..f5f09b744 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.render; import static com.simibubi.create.Create.asResource; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class AllProgramSpecs { diff --git a/src/main/java/com/simibubi/create/foundation/render/Compartment.java b/src/main/java/com/simibubi/create/foundation/render/Compartment.java index 59a601df4..701517e3a 100644 --- a/src/main/java/com/simibubi/create/foundation/render/Compartment.java +++ b/src/main/java/com/simibubi/create/foundation/render/Compartment.java @@ -4,8 +4,8 @@ import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.core.PartialModel; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; public class Compartment { public static final Compartment GENERIC_TILE = new Compartment<>(); diff --git a/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java b/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java index be4939221..538236206 100644 --- a/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java +++ b/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java @@ -15,7 +15,7 @@ import com.jozufozu.flywheel.core.WorldContext; import com.jozufozu.flywheel.event.GatherContextEvent; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; 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 9c5c4d59d..9154e45a7 100644 --- a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java +++ b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java @@ -2,9 +2,16 @@ package com.simibubi.create.foundation.render; import static net.minecraft.state.properties.BlockStateProperties.FACING; +import javanet.minimport com.jozufozu.flywheel.core.PartialModel; +import com.jozufozu.flywheel.util.transform.MatrixTransformStack; +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.CreateClient; +import com.simibubi.create.foundation.utility.AngleHelper; import java.util.function.Supplier; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockState; -import com.jozufozu.flywheel.core.PartialModel; +ecraft.world.level.block.state.properties.BlockStatePropertieswheel.core.PartialModel; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.CreateClient; @@ -28,9 +35,9 @@ public class PartialBufferer { return CreateClient.BUFFER_CACHE.renderDirectionalPartial(partial, referenceState, facing, rotateToFace(facing)); } - public static Supplier rotateToFace(Direction facing) { + public static Supplier rotateToFace(Direction facing) { return () -> { - MatrixStack stack = new MatrixStack(); + PoseStack stack = new PoseStack(); MatrixTransformStack.of(stack) .centre() .rotateY(AngleHelper.horizontalAngle(facing)) diff --git a/src/main/java/com/simibubi/create/foundation/render/RainbowDebugStateProvider.java b/src/main/java/com/simibubi/create/foundation/render/RainbowDebugStateProvider.java index 9c925cd74..9e4fd21cc 100644 --- a/src/main/java/com/simibubi/create/foundation/render/RainbowDebugStateProvider.java +++ b/src/main/java/com/simibubi/create/foundation/render/RainbowDebugStateProvider.java @@ -4,7 +4,7 @@ import com.jozufozu.flywheel.core.shader.spec.IBooleanStateProvider; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.KineticDebugger; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class RainbowDebugStateProvider implements IBooleanStateProvider { diff --git a/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java b/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java index 21bf27add..bfc1eb673 100644 --- a/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java +++ b/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java @@ -5,17 +5,17 @@ import org.lwjgl.opengl.GL11; import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.Create; -import net.minecraft.client.renderer.RenderState; +import net.minecraft.client.renderer.RenderStateShard; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.inventory.container.PlayerContainer; -import net.minecraft.util.ResourceLocation; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.resources.ResourceLocation; -public class RenderTypes extends RenderState { +public class RenderTypes extends RenderStateShard { public static RenderType getOutlineTranslucent(ResourceLocation texture, boolean cull) { - RenderType.State rendertype$state = RenderType.State.builder() - .setTextureState(new RenderState.TextureState(texture, false, false)) + RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() + .setTextureState(new RenderStateShard.TextureStateShard(texture, false, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setDiffuseLightingState(DIFFUSE_LIGHTING) .setAlphaState(DEFAULT_ALPHA) @@ -24,47 +24,47 @@ public class RenderTypes extends RenderState { .setOverlayState(OVERLAY) .createCompositeState(true); return RenderType.create(createLayerName("outline_translucent" + (cull ? "_cull" : "")), - DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, rendertype$state); + DefaultVertexFormat.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, rendertype$state); } private static final RenderType OUTLINE_SOLID = - RenderType.create(createLayerName("outline_solid"), DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, - false, RenderType.State.builder() - .setTextureState(new RenderState.TextureState(AllSpecialTextures.BLANK.getLocation(), false, false)) + RenderType.create(createLayerName("outline_solid"), DefaultVertexFormat.NEW_ENTITY, GL11.GL_QUADS, 256, true, + false, RenderType.CompositeState.builder() + .setTextureState(new RenderStateShard.TextureStateShard(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() - .setTextureState(new RenderState.TextureState(texture, false, false)) + RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() + .setTextureState(new RenderStateShard.TextureStateShard(texture, false, false)) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) .createCompositeState(true); - return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, + return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormat.NEW_ENTITY, GL11.GL_QUADS, 256, true, false, rendertype$state); } public static RenderType getGlowingTranslucent(ResourceLocation texture) { - RenderType.State rendertype$state = RenderType.State.builder() - .setTextureState(new RenderState.TextureState(texture, false, false)) + RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() + .setTextureState(new RenderStateShard.TextureStateShard(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, + return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormat.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, rendertype$state); } - private static final RenderType GLOWING_SOLID = getGlowingSolid(PlayerContainer.BLOCK_ATLAS); - private static final RenderType GLOWING_TRANSLUCENT = getGlowingTranslucent(PlayerContainer.BLOCK_ATLAS); + private static final RenderType GLOWING_SOLID = getGlowingSolid(InventoryMenu.BLOCK_ATLAS); + private static final RenderType GLOWING_TRANSLUCENT = getGlowingTranslucent(InventoryMenu.BLOCK_ATLAS); private static final RenderType ITEM_PARTIAL_SOLID = - RenderType.create(createLayerName("item_solid"), DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, - false, RenderType.State.builder() + RenderType.create(createLayerName("item_solid"), DefaultVertexFormat.NEW_ENTITY, GL11.GL_QUADS, 256, true, + false, RenderType.CompositeState.builder() .setTextureState(BLOCK_SHEET) .setTransparencyState(NO_TRANSPARENCY) .setDiffuseLightingState(DIFFUSE_LIGHTING) @@ -73,7 +73,7 @@ public class RenderTypes extends RenderState { .createCompositeState(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() + DefaultVertexFormat.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, RenderType.CompositeState.builder() .setTextureState(BLOCK_SHEET) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setDiffuseLightingState(DIFFUSE_LIGHTING) @@ -83,7 +83,7 @@ public class RenderTypes extends RenderState { .createCompositeState(true)); private static final RenderType FLUID = RenderType.create(createLayerName("fluid"), - DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, RenderType.State.builder() + DefaultVertexFormat.NEW_ENTITY, GL11.GL_QUADS, 256, true, true, RenderType.CompositeState.builder() .setTextureState(BLOCK_SHEET_MIPPED) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setShadeModelState(SMOOTH_SHADE) 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 813f242a2..6f7da84bf 100644 --- a/src/main/java/com/simibubi/create/foundation/render/ShadowRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/ShadowRenderHelper.java @@ -1,20 +1,20 @@ package com.simibubi.create.foundation.render; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorldReader; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.LevelReader; /** * Taken from EntityRendererManager @@ -24,9 +24,9 @@ public class ShadowRenderHelper { private static final RenderType SHADOW_LAYER = RenderType.entityNoOutline(new ResourceLocation("textures/misc/shadow.png")); - public static void renderShadow(MatrixStack matrixStack, IRenderTypeBuffer buffer, float opacity, float radius) { - MatrixStack.Entry entry = matrixStack.last(); - IVertexBuilder builder = buffer.getBuffer(SHADOW_LAYER); + public static void renderShadow(PoseStack matrixStack, MultiBufferSource buffer, float opacity, float radius) { + PoseStack.Pose entry = matrixStack.last(); + VertexConsumer builder = buffer.getBuffer(SHADOW_LAYER); opacity /= 2; shadowVertex(entry, builder, opacity, -1 * radius, 0, -1 * radius, 0, 0); @@ -35,21 +35,21 @@ public class ShadowRenderHelper { shadowVertex(entry, builder, opacity, 1 * radius, 0, -1 * radius, 1, 0); } - public static void renderShadow(MatrixStack matrixStack, IRenderTypeBuffer buffer, IWorldReader world, - Vector3d pos, float opacity, float radius) { + public static void renderShadow(PoseStack matrixStack, MultiBufferSource buffer, LevelReader world, + Vec3 pos, float opacity, float radius) { float f = radius; 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 entry = matrixStack.last(); - IVertexBuilder builder = buffer.getBuffer(SHADOW_LAYER); + int i = Mth.floor(d2 - (double) f); + int j = Mth.floor(d2 + (double) f); + int k = Mth.floor(d0 - (double) f); + int l = Mth.floor(d0); + int i1 = Mth.floor(d1 - (double) f); + int j1 = Mth.floor(d1 + (double) f); + PoseStack.Pose entry = matrixStack.last(); + VertexConsumer builder = buffer.getBuffer(SHADOW_LAYER); for (BlockPos blockpos : BlockPos.betweenClosed(new BlockPos(i, k, i1), new BlockPos(j, l, j1))) { renderBlockShadow(entry, builder, world, blockpos, d2, d0, d1, f, @@ -57,12 +57,12 @@ public class ShadowRenderHelper { } } - private static void renderBlockShadow(MatrixStack.Entry entry, IVertexBuilder builder, - IWorldReader world, BlockPos pos, double x, double y, double z, + private static void renderBlockShadow(PoseStack.Pose entry, VertexConsumer builder, + LevelReader world, BlockPos pos, double x, double y, double z, float radius, float opacity) { BlockPos blockpos = pos.below(); BlockState blockstate = world.getBlockState(blockpos); - if (blockstate.getRenderShape() != BlockRenderType.INVISIBLE && world.getMaxLocalRawBrightness(pos) > 3) { + if (blockstate.getRenderShape() != RenderShape.INVISIBLE && world.getMaxLocalRawBrightness(pos) > 3) { if (blockstate.isCollisionShapeFullBlock(world, blockpos)) { VoxelShape voxelshape = blockstate.getShape(world, pos.below()); if (!voxelshape.isEmpty()) { @@ -74,7 +74,7 @@ public class ShadowRenderHelper { f = 1.0F; } - AxisAlignedBB axisalignedbb = voxelshape.bounds(); + AABB axisalignedbb = voxelshape.bounds(); double d0 = (double) pos.getX() + axisalignedbb.minX; double d1 = (double) pos.getX() + axisalignedbb.maxX; double d2 = (double) pos.getY() + axisalignedbb.minY; @@ -99,7 +99,7 @@ public class ShadowRenderHelper { } } - private static void shadowVertex(MatrixStack.Entry entry, IVertexBuilder builder, float alpha, + private static void shadowVertex(PoseStack.Pose entry, VertexConsumer builder, float alpha, float x, float y, float z, float u, float v) { builder.vertex(entry.pose(), x, y, z) .color(1.0F, 1.0F, 1.0F, alpha) 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 98273c1d2..4890c109c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -2,29 +2,29 @@ package com.simibubi.create.foundation.render; import com.jozufozu.flywheel.util.BufferBuilderReader; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.utility.Color; import it.unimi.dsi.fastutil.longs.Long2IntMap; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BufferBuilder; +import com.mojang.blaze3d.vertex.BufferBuilder; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix3f; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.math.vector.Vector4f; -import net.minecraft.world.World; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import com.mojang.math.Matrix3f; +import com.mojang.math.Matrix4f; +import com.mojang.math.Quaternion; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; +import net.minecraft.world.level.Level; import net.minecraftforge.client.model.pipeline.LightUtil; public class SuperByteBuffer { @@ -32,7 +32,7 @@ public class SuperByteBuffer { private final BufferBuilderReader template; // Vertex Position - private MatrixStack transforms; + private PoseStack transforms; // Vertex Coloring private boolean shouldColor; @@ -66,7 +66,7 @@ public class SuperByteBuffer { public SuperByteBuffer(BufferBuilder buf) { template = new BufferBuilderReader(buf); - transforms = new MatrixStack(); + transforms = new PoseStack(); transforms.pushPose(); stacker = MatrixTransformStack.of(transforms); } @@ -81,7 +81,7 @@ public class SuperByteBuffer { return (v - sprite.getV0()) / f * 16.0F; } - public void renderInto(MatrixStack input, IVertexBuilder builder) { + public void renderInto(PoseStack input, VertexConsumer builder) { if (isEmpty()) return; @@ -232,7 +232,7 @@ public class SuperByteBuffer { return stacker; } - public SuperByteBuffer translate(Vector3d vec) { + public SuperByteBuffer translate(Vec3 vec) { return translate(vec.x, vec.y, vec.z); } @@ -245,7 +245,7 @@ public class SuperByteBuffer { return this; } - public SuperByteBuffer transform(MatrixStack stack) { + public SuperByteBuffer transform(PoseStack stack) { transforms.last() .pose() .multiply(stack.last() @@ -420,11 +420,11 @@ public class SuperByteBuffer { } public static int transformColor(byte component, float scale) { - return MathHelper.clamp((int) (Byte.toUnsignedInt(component) * scale), 0, 255); + return Mth.clamp((int) (Byte.toUnsignedInt(component) * scale), 0, 255); } public static int transformColor(int component, float scale) { - return MathHelper.clamp((int) (component * scale), 0, 255); + return Mth.clamp((int) (component * scale), 0, 255); } public static int maxLight(int packedLight1, int packedLight2) { @@ -435,14 +435,14 @@ public class SuperByteBuffer { return LightTexture.pack(Math.max(blockLight1, blockLight2), Math.max(skyLight1, skyLight2)); } - private static int getLight(World world, Vector4f lightPos) { + private static int getLight(Level world, Vector4f lightPos) { BlockPos pos = new BlockPos(lightPos.x(), lightPos.y(), lightPos.z()); - return WORLD_LIGHT_CACHE.computeIfAbsent(pos.asLong(), $ -> WorldRenderer.getLightColor(world, pos)); + return WORLD_LIGHT_CACHE.computeIfAbsent(pos.asLong(), $ -> LevelRenderer.getLightColor(world, pos)); } @FunctionalInterface public interface SpriteShiftFunc { - void shift(IVertexBuilder builder, float u, float v); + void shift(VertexConsumer builder, float u, float v); } @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 5027a0313..c9d9045a8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java @@ -13,18 +13,18 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.util.VirtualEmptyModelData; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockModelRenderer; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.block.ModelBlockRenderer; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import com.mojang.blaze3d.vertex.BufferBuilder; +import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; public class SuperByteBufferCache { @@ -46,7 +46,7 @@ public class SuperByteBufferCache { } public SuperByteBuffer renderPartial(PartialModel partial, BlockState referenceState, - Supplier modelTransform) { + Supplier modelTransform) { return get(Compartment.PARTIAL, partial, () -> standardModelRender(partial.get(), referenceState, modelTransform.get())); } @@ -58,7 +58,7 @@ public class SuperByteBufferCache { } public SuperByteBuffer renderDirectionalPartial(PartialModel partial, BlockState referenceState, Direction dir, - Supplier modelTransform) { + Supplier modelTransform) { return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial), () -> standardModelRender(partial.get(), referenceState, modelTransform.get())); } @@ -102,28 +102,28 @@ public class SuperByteBufferCache { } private SuperByteBuffer standardBlockRender(BlockState renderedState) { - BlockRendererDispatcher dispatcher = Minecraft.getInstance() + BlockRenderDispatcher dispatcher = Minecraft.getInstance() .getBlockRenderer(); return standardModelRender(dispatcher.getBlockModel(renderedState), renderedState); } - private SuperByteBuffer standardModelRender(IBakedModel model, BlockState referenceState) { - return standardModelRender(model, referenceState, new MatrixStack()); + private SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState) { + return standardModelRender(model, referenceState, new PoseStack()); } - private SuperByteBuffer standardModelRender(IBakedModel model, BlockState referenceState, MatrixStack ms) { + private SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState, PoseStack ms) { BufferBuilder builder = getBufferBuilder(model, referenceState, ms); return new SuperByteBuffer(builder); } - public static BufferBuilder getBufferBuilder(IBakedModel model, BlockState referenceState, MatrixStack ms) { + public static BufferBuilder getBufferBuilder(BakedModel model, BlockState referenceState, PoseStack ms) { Minecraft mc = Minecraft.getInstance(); - BlockRendererDispatcher dispatcher = mc.getBlockRenderer(); - BlockModelRenderer blockRenderer = dispatcher.getModelRenderer(); + BlockRenderDispatcher dispatcher = mc.getBlockRenderer(); + ModelBlockRenderer blockRenderer = dispatcher.getModelRenderer(); BufferBuilder builder = new BufferBuilder(512); - builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + builder.begin(GL11.GL_QUADS, DefaultVertexFormat.BLOCK); blockRenderer.renderModel(mc.level, model, referenceState, BlockPos.ZERO.above(255), ms, builder, true, mc.level.random, 42, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); builder.end(); diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java index f55ad3870..109eb9d28 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java @@ -2,18 +2,18 @@ package com.simibubi.create.foundation.render; import java.util.SortedMap; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.VertexConsumer; import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; -import net.minecraft.client.renderer.Atlases; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.RegionRenderCacheBuilder; +import net.minecraft.client.renderer.Sheets; +import com.mojang.blaze3d.vertex.BufferBuilder; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.ChunkBufferBuilderPack; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.ModelBakery; -import net.minecraft.util.Util; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.Util; -public class SuperRenderTypeBuffer implements IRenderTypeBuffer { +public class SuperRenderTypeBuffer implements MultiBufferSource { static SuperRenderTypeBuffer instance; @@ -33,16 +33,16 @@ public class SuperRenderTypeBuffer implements IRenderTypeBuffer { lateBuffer = new SuperRenderTypeBufferPhase(); } - public IVertexBuilder getEarlyBuffer(RenderType type) { + public VertexConsumer getEarlyBuffer(RenderType type) { return earlyBuffer.getBuffer(type); } @Override - public IVertexBuilder getBuffer(RenderType type) { + public VertexConsumer getBuffer(RenderType type) { return defaultBuffer.getBuffer(type); } - public IVertexBuilder getLateBuffer(RenderType type) { + public VertexConsumer getLateBuffer(RenderType type) { return lateBuffer.getBuffer(type); } @@ -58,23 +58,23 @@ public class SuperRenderTypeBuffer implements IRenderTypeBuffer { lateBuffer.endBatch(type); } - private static class SuperRenderTypeBufferPhase extends IRenderTypeBuffer.Impl { + private static class SuperRenderTypeBufferPhase extends MultiBufferSource.BufferSource { // Visible clones from net.minecraft.client.renderer.RenderTypeBuffers - static final RegionRenderCacheBuilder blockBuilders = new RegionRenderCacheBuilder(); + static final ChunkBufferBuilderPack blockBuilders = new ChunkBufferBuilderPack(); static final SortedMap createEntityBuilders() { return Util.make(new Object2ObjectLinkedOpenHashMap<>(), (map) -> { - map.put(Atlases.solidBlockSheet(), blockBuilders.builder(RenderType.solid())); + map.put(Sheets.solidBlockSheet(), blockBuilders.builder(RenderType.solid())); assign(map, RenderTypes.getOutlineSolid()); - 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()); + map.put(Sheets.cutoutBlockSheet(), blockBuilders.builder(RenderType.cutout())); + map.put(Sheets.bannerSheet(), blockBuilders.builder(RenderType.cutoutMipped())); + map.put(Sheets.translucentCullBlockSheet(), blockBuilders.builder(RenderType.translucent())); // FIXME new equivalent of getEntityTranslucent() ? + assign(map, Sheets.shieldSheet()); + assign(map, Sheets.bedSheet()); + assign(map, Sheets.shulkerBoxSheet()); + assign(map, Sheets.signSheet()); + assign(map, Sheets.chestSheet()); assign(map, RenderType.translucentNoCrumbling()); assign(map, RenderType.glint()); assign(map, RenderType.entityGlint()); 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 78462e4ba..5a0da48ca 100644 --- a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java @@ -7,51 +7,51 @@ import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.Create; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector4f; -import net.minecraft.world.World; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import com.mojang.math.Matrix4f; +import com.mojang.math.Vector4f; +import net.minecraft.world.level.Level; public class TileEntityRenderHelper { - public static void renderTileEntities(World world, Iterable customRenderTEs, MatrixStack ms, - IRenderTypeBuffer buffer) { + public static void renderTileEntities(Level world, Iterable customRenderTEs, PoseStack ms, + MultiBufferSource buffer) { renderTileEntities(world, null, customRenderTEs, ms, null, buffer); } - public static void renderTileEntities(World world, Iterable customRenderTEs, MatrixStack ms, - IRenderTypeBuffer buffer, float pt) { + public static void renderTileEntities(Level world, Iterable customRenderTEs, PoseStack ms, + MultiBufferSource buffer, float pt) { renderTileEntities(world, null, customRenderTEs, ms, null, buffer, pt); } - public static void renderTileEntities(World world, @Nullable PlacementSimulationWorld renderWorld, - Iterable customRenderTEs, MatrixStack ms, @Nullable Matrix4f lightTransform, IRenderTypeBuffer buffer) { + public static void renderTileEntities(Level world, @Nullable PlacementSimulationWorld renderWorld, + Iterable customRenderTEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer) { renderTileEntities(world, renderWorld, customRenderTEs, ms, lightTransform, buffer, AnimationTickHolder.getPartialTicks()); } - public static void renderTileEntities(World world, @Nullable PlacementSimulationWorld renderWorld, - Iterable customRenderTEs, MatrixStack ms, @Nullable Matrix4f lightTransform, IRenderTypeBuffer buffer, + public static void renderTileEntities(Level world, @Nullable PlacementSimulationWorld renderWorld, + Iterable customRenderTEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer, float pt) { - Iterator iterator = customRenderTEs.iterator(); + Iterator iterator = customRenderTEs.iterator(); while (iterator.hasNext()) { - TileEntity tileEntity = iterator.next(); + BlockEntity tileEntity = iterator.next(); if (Backend.getInstance().canUseInstancing(renderWorld) && InstancedRenderRegistry.getInstance() .shouldSkipRender(tileEntity)) continue; - TileEntityRenderer renderer = TileEntityRendererDispatcher.instance.getRenderer(tileEntity); + BlockEntityRenderer renderer = BlockEntityRenderDispatcher.instance.getRenderer(tileEntity); if (renderer == null) { iterator.remove(); continue; @@ -90,12 +90,12 @@ public class TileEntityRenderHelper { } } - public static int getCombinedLight(World world, BlockPos worldPos, @Nullable PlacementSimulationWorld renderWorld, + public static int getCombinedLight(Level world, BlockPos worldPos, @Nullable PlacementSimulationWorld renderWorld, BlockPos renderWorldPos) { - int worldLight = WorldRenderer.getLightColor(world, worldPos); + int worldLight = LevelRenderer.getLightColor(world, worldPos); if (renderWorld != null) { - int renderWorldLight = WorldRenderer.getLightColor(renderWorld, renderWorldPos); + int renderWorldLight = LevelRenderer.getLightColor(renderWorld, renderWorldPos); return SuperByteBuffer.maxLight(worldLight, renderWorldLight); } 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 9f2dceeb1..fac9d9310 100644 --- a/src/main/java/com/simibubi/create/foundation/sound/ContinuousSound.java +++ b/src/main/java/com/simibubi/create/foundation/sound/ContinuousSound.java @@ -1,17 +1,17 @@ package com.simibubi.create.foundation.sound; -import net.minecraft.client.audio.TickableSound; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; +import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; -public class ContinuousSound extends TickableSound { +public class ContinuousSound extends AbstractTickableSoundInstance { private float sharedPitch; private SoundScape scape; private float relativeVolume; protected ContinuousSound(SoundEvent event, SoundScape scape, float sharedPitch, float relativeVolume) { - super(event, SoundCategory.AMBIENT); + super(event, SoundSource.AMBIENT); this.scape = scape; this.sharedPitch = sharedPitch; this.relativeVolume = relativeVolume; 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 61d460214..44bd1ca8c 100644 --- a/src/main/java/com/simibubi/create/foundation/sound/RepeatingSound.java +++ b/src/main/java/com/simibubi/create/foundation/sound/RepeatingSound.java @@ -3,10 +3,10 @@ package com.simibubi.create.foundation.sound; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.world.phys.Vec3; public class RepeatingSound { @@ -29,10 +29,10 @@ public class RepeatingSound { if (AnimationTickHolder.getTicks() % repeatDelay != 0) return; - ClientWorld world = Minecraft.getInstance().level; - Vector3d meanPos = scape.getMeanPos(); + ClientLevel world = Minecraft.getInstance().level; + Vec3 meanPos = scape.getMeanPos(); - world.playLocalSound(meanPos.x, meanPos.y, meanPos.z, event, SoundCategory.AMBIENT, + world.playLocalSound(meanPos.x, meanPos.y, meanPos.z, event, SoundSource.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 ab95e1a48..23535691e 100644 --- a/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java +++ b/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java @@ -10,18 +10,18 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.Entity; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; class SoundScape { List continuous; List repeating; private float pitch; private AmbienceGroup group; - private Vector3d meanPos; + private Vec3 meanPos; private PitchGroup pitchGroup; public SoundScape(float pitch, AmbienceGroup group) { @@ -65,12 +65,12 @@ class SoundScape { continuous.forEach(ContinuousSound::remove); } - public Vector3d getMeanPos() { + public Vec3 getMeanPos() { return meanPos == null ? meanPos = determineMeanPos() : meanPos; } - private Vector3d determineMeanPos() { - meanPos = Vector3d.ZERO; + private Vec3 determineMeanPos() { + meanPos = Vec3.ZERO; int amount = 0; for (BlockPos blockPos : SoundScapes.getAllLocations(group, pitchGroup)) { meanPos = meanPos.add(VecHelper.getCenterOf(blockPos)); @@ -87,12 +87,12 @@ class SoundScape { if (renderViewEntity != null) { double distanceTo = renderViewEntity.position() .distanceTo(getMeanPos()); - distanceMultiplier = (float) MathHelper.lerp(distanceTo / SoundScapes.MAX_AMBIENT_SOURCE_DISTANCE, 2, 0); + distanceMultiplier = (float) Mth.lerp(distanceTo / SoundScapes.MAX_AMBIENT_SOURCE_DISTANCE, 2, 0); } int soundCount = SoundScapes.getSoundCount(group, pitchGroup); float max = AllConfigs.CLIENT.ambientVolumeCap.getF(); float argMax = (float) SoundScapes.SOUND_VOLUME_ARG_MAX; - return MathHelper.clamp(soundCount / (argMax * 10f), 0.025f, max) * distanceMultiplier; + return Mth.clamp(soundCount / (argMax * 10f), 0.025f, max) * distanceMultiplier; } } 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 d62449315..e68530867 100644 --- a/src/main/java/com/simibubi/create/foundation/sound/SoundScapes.java +++ b/src/main/java/com/simibubi/create/foundation/sound/SoundScapes.java @@ -16,9 +16,9 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Pair; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; public class SoundScapes { diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/ComparatorUtil.java b/src/main/java/com/simibubi/create/foundation/tileEntity/ComparatorUtil.java index e35593b63..5ac7165e7 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/ComparatorUtil.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/ComparatorUtil.java @@ -3,17 +3,17 @@ package com.simibubi.create.foundation.tileEntity; import com.simibubi.create.foundation.fluid.SmartFluidTank; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.IBlockReader; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.BlockGetter; public class ComparatorUtil { public static int fractionToRedstoneLevel(double frac) { - return MathHelper.floor(MathHelper.clamp(frac * 14 + (frac > 0 ? 1 : 0), 0, 15)); + return Mth.floor(Mth.clamp(frac * 14 + (frac > 0 ? 1 : 0), 0, 15)); } - public static int levelOfSmartFluidTank(IBlockReader world, BlockPos pos) { + public static int levelOfSmartFluidTank(BlockGetter world, BlockPos pos) { SmartFluidTankBehaviour fluidBehaviour = TileEntityBehaviour.get(world, pos, SmartFluidTankBehaviour.TYPE); if (fluidBehaviour == null) return 0; 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 7d88ca00f..1af72e261 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java @@ -12,19 +12,19 @@ import com.simibubi.create.foundation.gui.IInteractionChecker; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.utility.IPartialSafeNBT; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.TickableBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.Level; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.items.CapabilityItemHandler; -public abstract class SmartTileEntity extends SyncedTileEntity implements ITickableTileEntity, IPartialSafeNBT, IInteractionChecker { +public abstract class SmartTileEntity extends SyncedTileEntity implements TickableBlockEntity, IPartialSafeNBT, IInteractionChecker { private final Map, TileEntityBehaviour> behaviours; // Internally maintained to be identical to behaviorMap.values() in order to improve iteration performance. @@ -37,7 +37,7 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka // Used for simulating this TE in a client-only setting private boolean virtualMode; - public SmartTileEntity(TileEntityType tileEntityTypeIn) { + public SmartTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); behaviours = new HashMap<>(); initialized = false; @@ -87,31 +87,31 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka } @Override - public final CompoundNBT save(CompoundNBT compound) { + public final CompoundTag save(CompoundTag compound) { write(compound, false); return compound; } @Override - public final CompoundNBT writeToClient(CompoundNBT compound) { + public final CompoundTag writeToClient(CompoundTag compound) { write(compound, true); return compound; } @Override - public final void readClientUpdate(BlockState state, CompoundNBT tag) { + public final void readClientUpdate(BlockState state, CompoundTag tag) { fromTag(state, tag, true); } @Override - public final void load(BlockState state, CompoundNBT tag) { + public final void load(BlockState state, CompoundTag tag) { fromTag(state, tag, false); } /** * Hook only these in future subclasses of STE */ - protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { + protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { if (firstNbtRead) { firstNbtRead = false; ArrayList list = new ArrayList<>(); @@ -127,13 +127,13 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka /** * Hook only these in future subclasses of STE */ - protected void write(CompoundNBT compound, boolean clientPacket) { + protected void write(CompoundTag compound, boolean clientPacket) { super.save(compound); behaviourList.forEach(tb -> tb.write(compound, clientPacket)); } @Override - public void writeSafe(CompoundNBT compound, boolean clientPacket) { + public void writeSafe(CompoundTag compound, boolean clientPacket) { super.save(compound); behaviourList.forEach(tb -> { if (tb.isSafeNBT()) @@ -214,19 +214,19 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka } @Override - public boolean canPlayerUse(PlayerEntity player) { + public boolean canPlayerUse(Player player) { if (level == null || level.getBlockEntity(worldPosition) != this) return false; return player.distanceToSqr(worldPosition.getX() + 0.5D, worldPosition.getY() + 0.5D, worldPosition.getZ() + 0.5D) <= 64.0D; } - public void sendToContainer(PacketBuffer buffer) { + public void sendToContainer(FriendlyByteBuf buffer) { buffer.writeBlockPos(getBlockPos()); buffer.writeNbt(getUpdateTag()); } - public World getWorld() { + public Level 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 10c85b48d..e2f6585c2 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/SyncedTileEntity.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/SyncedTileEntity.java @@ -3,36 +3,36 @@ package com.simibubi.create.foundation.tileEntity; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SUpdateTileEntityPacket; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.math.SectionPos; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.fml.network.PacketDistributor; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -public abstract class SyncedTileEntity extends TileEntity { +public abstract class SyncedTileEntity extends BlockEntity { - public SyncedTileEntity(TileEntityType tileEntityTypeIn) { + public SyncedTileEntity(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } @Override - public CompoundNBT getTileData() { + public CompoundTag getTileData() { return super.getTileData(); } @Override - public CompoundNBT getUpdateTag() { - return save(new CompoundNBT()); + public CompoundTag getUpdateTag() { + return save(new CompoundTag()); } @Override - public void handleUpdateTag(BlockState state, CompoundNBT tag) { + public void handleUpdateTag(BlockState state, CompoundTag tag) { load(state, tag); } @@ -47,22 +47,22 @@ public abstract class SyncedTileEntity extends TileEntity { } @Override - public SUpdateTileEntityPacket getUpdatePacket() { - return new SUpdateTileEntityPacket(getBlockPos(), 0, writeToClient(new CompoundNBT())); + public ClientboundBlockEntityDataPacket getUpdatePacket() { + return new ClientboundBlockEntityDataPacket(getBlockPos(), 0, writeToClient(new CompoundTag())); } @Override - public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) { + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { readClientUpdate(getBlockState(), pkt.getTag()); } // Special handling for client update packets - public void readClientUpdate(BlockState state, CompoundNBT tag) { + public void readClientUpdate(BlockState state, CompoundTag tag) { load(state, tag); } // Special handling for client update packets - public CompoundNBT writeToClient(CompoundNBT tag) { + public CompoundTag writeToClient(CompoundTag tag) { return save(tag); } @@ -75,7 +75,7 @@ public abstract class SyncedTileEntity extends TileEntity { return PacketDistributor.TRACKING_CHUNK.with(this::containedChunk); } - public Chunk containedChunk() { + public LevelChunk containedChunk() { 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 7eb8241ac..a57a65668 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java @@ -5,12 +5,12 @@ import java.util.ConcurrentModificationException; import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; public abstract class TileEntityBehaviour { @@ -37,11 +37,11 @@ public abstract class TileEntityBehaviour { } - public void read(CompoundNBT nbt, boolean clientPacket) { + public void read(CompoundTag nbt, boolean clientPacket) { } - public void write(CompoundNBT nbt, boolean clientPacket) { + public void write(CompoundTag nbt, boolean clientPacket) { } @@ -82,12 +82,12 @@ public abstract class TileEntityBehaviour { return tileEntity.getBlockPos(); } - public World getWorld() { + public Level getWorld() { return tileEntity.getLevel(); } - public static T get(IBlockReader reader, BlockPos pos, BehaviourType type) { - TileEntity te; + public static T get(BlockGetter reader, BlockPos pos, BehaviourType type) { + BlockEntity te; try { te = reader.getBlockEntity(pos); } catch (ConcurrentModificationException e) { @@ -96,14 +96,14 @@ public abstract class TileEntityBehaviour { return get(te, type); } - public static void destroy(IBlockReader reader, BlockPos pos, + public static void destroy(BlockGetter reader, BlockPos pos, BehaviourType type) { T behaviour = get(reader.getBlockEntity(pos), type); if (behaviour != null) behaviour.destroy(); } - public static T get(TileEntity te, BehaviourType type) { + public static T get(BlockEntity te, BehaviourType type) { if (te == null) return null; if (!(te instanceof SmartTileEntity)) diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/CenteredSideValueBoxTransform.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/CenteredSideValueBoxTransform.java index 4f3a8720c..d8bb3082f 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/CenteredSideValueBoxTransform.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/CenteredSideValueBoxTransform.java @@ -4,9 +4,9 @@ import java.util.function.BiPredicate; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.Vec3; public class CenteredSideValueBoxTransform extends ValueBoxTransform.Sided { @@ -21,7 +21,7 @@ public class CenteredSideValueBoxTransform extends ValueBoxTransform.Sided { } @Override - protected Vector3d getSouthLocation() { + protected Vec3 getSouthLocation() { return VecHelper.voxelSpace(8, 8, 16); } 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 0fd48ee01..4e1c0fef7 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 @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.tileEntity.behaviour; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.logistics.item.filter.FilterItem; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; @@ -10,23 +10,23 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.outliner.ChasingAABBOutline; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.gui.Font; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class ValueBox extends ChasingAABBOutline { - protected ITextComponent label; - protected ITextComponent sublabel = StringTextComponent.EMPTY; - protected ITextComponent scrollTooltip = StringTextComponent.EMPTY; - protected Vector3d labelOffset = Vector3d.ZERO; + protected Component label; + protected Component sublabel = TextComponent.EMPTY; + protected Component scrollTooltip = TextComponent.EMPTY; + protected Vec3 labelOffset = Vec3.ZERO; protected int passiveColor; protected int highlightColor; @@ -36,7 +36,7 @@ public class ValueBox extends ChasingAABBOutline { protected ValueBoxTransform transform; protected BlockState blockState; - public ValueBox(ITextComponent label, AxisAlignedBB bb, BlockPos pos) { + public ValueBox(Component label, AABB bb, BlockPos pos) { super(bb); this.label = label; this.pos = pos; @@ -48,17 +48,17 @@ public class ValueBox extends ChasingAABBOutline { return this; } - public ValueBox offsetLabel(Vector3d offset) { + public ValueBox offsetLabel(Vec3 offset) { this.labelOffset = offset; return this; } - public ValueBox subLabel(ITextComponent sublabel) { + public ValueBox subLabel(Component sublabel) { this.sublabel = sublabel; return this; } - public ValueBox scrollTooltip(ITextComponent scrollTip) { + public ValueBox scrollTooltip(Component scrollTip) { this.scrollTooltip = scrollTip; return this; } @@ -75,7 +75,7 @@ public class ValueBox extends ChasingAABBOutline { } @Override - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, float pt) { + public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { boolean hasTransform = transform != null; if (transform instanceof Sided && params.getHighlightedFace() != null) ((Sided) transform).fromSide(params.getHighlightedFace()); @@ -120,23 +120,23 @@ public class ValueBox extends ChasingAABBOutline { ms.popPose(); } - public void renderContents(MatrixStack ms, IRenderTypeBuffer buffer) {} + public void renderContents(PoseStack ms, MultiBufferSource buffer) {} public static class ItemValueBox extends ValueBox { ItemStack stack; int count; - public ItemValueBox(ITextComponent label, AxisAlignedBB bb, BlockPos pos, ItemStack stack, int count) { + public ItemValueBox(Component label, AABB bb, BlockPos pos, ItemStack stack, int count) { super(label, bb, pos); this.stack = stack; this.count = count; } @Override - public void renderContents(MatrixStack ms, IRenderTypeBuffer buffer) { + public void renderContents(PoseStack ms, MultiBufferSource buffer) { super.renderContents(ms, buffer); - FontRenderer font = Minecraft.getInstance().font; - ITextComponent countString = new StringTextComponent(count == 0 ? "*" : count + ""); + Font font = Minecraft.getInstance().font; + Component countString = new TextComponent(count == 0 ? "*" : count + ""); ms.translate(17.5f, -5f, 7f); boolean isFilter = stack.getItem() instanceof FilterItem; @@ -162,17 +162,17 @@ public class ValueBox extends ChasingAABBOutline { } public static class TextValueBox extends ValueBox { - ITextComponent text; + Component text; - public TextValueBox(ITextComponent label, AxisAlignedBB bb, BlockPos pos, ITextComponent text) { + public TextValueBox(Component label, AABB bb, BlockPos pos, Component text) { super(label, bb, pos); this.text = text; } @Override - public void renderContents(MatrixStack ms, IRenderTypeBuffer buffer) { + public void renderContents(PoseStack ms, MultiBufferSource buffer) { super.renderContents(ms, buffer); - FontRenderer font = Minecraft.getInstance().font; + Font font = Minecraft.getInstance().font; float scale = 4; ms.scale(scale, scale, 1); ms.translate(-4, -4, 5); @@ -195,14 +195,14 @@ public class ValueBox extends ChasingAABBOutline { public static class IconValueBox extends ValueBox { AllIcons icon; - public IconValueBox(ITextComponent label, INamedIconOptions iconValue, AxisAlignedBB bb, BlockPos pos) { + public IconValueBox(Component label, INamedIconOptions iconValue, AABB bb, BlockPos pos) { super(label, bb, pos); subLabel(Lang.translate(iconValue.getTranslationKey())); icon = iconValue.getIcon(); } @Override - public void renderContents(MatrixStack ms, IRenderTypeBuffer buffer) { + public void renderContents(PoseStack ms, MultiBufferSource buffer) { super.renderContents(ms, buffer); float scale = 4 * 16; ms.scale(scale, scale, scale); @@ -214,11 +214,11 @@ public class ValueBox extends ChasingAABBOutline { // util - protected void renderHoveringText(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text) { + protected void renderHoveringText(PoseStack ms, MultiBufferSource buffer, Component text) { renderHoveringText(ms, buffer, text, highlightColor, Color.mixColors(passiveColor, 0, 0.75f)); } - protected void renderHoveringText(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text, int color, + protected void renderHoveringText(PoseStack ms, MultiBufferSource buffer, Component text, int color, int shadowColor) { ms.pushPose(); drawString(ms, buffer, text, 0, 0, color); @@ -227,7 +227,7 @@ public class ValueBox extends ChasingAABBOutline { ms.popPose(); } - private static void drawString(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text, float x, float y, int color) { + private static void drawString(PoseStack ms, MultiBufferSource buffer, Component text, float x, float y, int color) { 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 083fca71a..f6a8a96bc 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 @@ -1,28 +1,28 @@ package com.simibubi.create.foundation.tileEntity.behaviour; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.relays.elementary.AbstractShaftBlock; import com.simibubi.create.content.logistics.item.filter.FilterItem; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.FenceBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FenceBlock; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.tags.BlockTags; import net.minecraftforge.client.model.ItemMultiLayerBakedModel; public class ValueBoxRenderer { - public static void renderItemIntoValueBox(ItemStack filter, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + public static void renderItemIntoValueBox(ItemStack filter, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); - IBakedModel modelWithOverrides = itemRenderer.getModel(filter, Minecraft.getInstance().level, null); + BakedModel modelWithOverrides = itemRenderer.getModel(filter, Minecraft.getInstance().level, null); boolean blockItem = modelWithOverrides.isGui3d() && !(modelWithOverrides instanceof ItemMultiLayerBakedModel); float scale = (!blockItem ? .5f : 1f) - 1 / 64f; float zOffset = (!blockItem ? -.225f : 0) + customZOffset(filter.getItem()); 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 d701a8ae7..dd31121f6 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 @@ -5,34 +5,34 @@ import java.util.function.Function; import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.phys.Vec3; public abstract class ValueBoxTransform { protected float scale = getScale(); - protected abstract Vector3d getLocalOffset(BlockState state); + protected abstract Vec3 getLocalOffset(BlockState state); - protected abstract void rotate(BlockState state, MatrixStack ms); + protected abstract void rotate(BlockState state, PoseStack ms); - public boolean testHit(BlockState state, Vector3d localHit) { - Vector3d offset = getLocalOffset(state); + public boolean testHit(BlockState state, Vec3 localHit) { + Vec3 offset = getLocalOffset(state); if (offset == null) return false; return localHit.distanceTo(offset) < scale / 2; } - public void transform(BlockState state, MatrixStack ms) { - Vector3d position = getLocalOffset(state); + public void transform(BlockState state, PoseStack ms) { + Vec3 position = getLocalOffset(state); if (position == null) return; ms.translate(position.x, position.y, position.z); @@ -44,7 +44,7 @@ public abstract class ValueBoxTransform { return state.getMaterial() != Material.AIR && getLocalOffset(state) != null; } - protected Vector3d rotateHorizontally(BlockState state, Vector3d vec) { + protected Vec3 rotateHorizontally(BlockState state, Vec3 vec) { float yRot = 0; if (state.hasProperty(BlockStateProperties.FACING)) yRot = AngleHelper.horizontalAngle(state.getValue(BlockStateProperties.FACING)); @@ -77,8 +77,8 @@ public abstract class ValueBoxTransform { return Pair.of(factory.apply(true), factory.apply(false)); } - public boolean testHit(BlockState state, Vector3d localHit) { - Vector3d offset = getLocalOffset(state); + public boolean testHit(BlockState state, Vec3 localHit) { + Vec3 offset = getLocalOffset(state); if (offset == null) return false; return localHit.distanceTo(offset) < scale / 3.5f; @@ -96,17 +96,17 @@ public abstract class ValueBoxTransform { } @Override - protected Vector3d getLocalOffset(BlockState state) { - Vector3d location = getSouthLocation(); + protected Vec3 getLocalOffset(BlockState state) { + Vec3 location = getSouthLocation(); location = VecHelper.rotateCentered(location, AngleHelper.horizontalAngle(getSide()), Axis.Y); location = VecHelper.rotateCentered(location, AngleHelper.verticalAngle(getSide()), Axis.Z); return location; } - protected abstract Vector3d getSouthLocation(); + protected abstract Vec3 getSouthLocation(); @Override - protected void rotate(BlockState state, MatrixStack ms) { + protected void rotate(BlockState state, PoseStack ms) { float yRot = AngleHelper.horizontalAngle(getSide()) + 180; float xRot = getSide() == Direction.UP ? 90 : getSide() == Direction.DOWN ? 270 : 0; MatrixTransformStack.of(ms) @@ -120,7 +120,7 @@ public abstract class ValueBoxTransform { } @Override - public boolean testHit(BlockState state, Vector3d localHit) { + public boolean testHit(BlockState state, Vec3 localHit) { return isSideActive(state, getSide()) && super.testHit(state, localHit); } 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 3d9af3d78..e7dbad420 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 @@ -6,9 +6,9 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; /** * Behaviour for TileEntities which can process items on belts or depots beneath @@ -42,7 +42,7 @@ public class BeltProcessingBehaviour extends TileEntityBehaviour { return this; } - public static boolean isBlocked(IBlockReader world, BlockPos processingSpace) { + public static boolean isBlocked(BlockGetter world, BlockPos processingSpace) { BlockState blockState = world.getBlockState(processingSpace.above()); if (AbstractFunnelBlock.isFunnel(blockState)) return false; 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 a11f4f4a0..3a157c9ff 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 @@ -13,12 +13,12 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; @@ -101,7 +101,7 @@ public class DirectBeltInputBehaviour extends TileEntityBehaviour { public ItemStack tryExportingToBeltFunnel(ItemStack stack, @Nullable Direction side, boolean simulate) { BlockPos funnelPos = tileEntity.getBlockPos() .above(); - World world = getWorld(); + Level world = getWorld(); BlockState funnelState = world.getBlockState(funnelPos); if (!(funnelState.getBlock() instanceof BeltFunnelBlock)) return null; @@ -109,7 +109,7 @@ public class DirectBeltInputBehaviour extends TileEntityBehaviour { return null; if (side != null && FunnelBlock.getFunnelFacing(funnelState) != side) return null; - TileEntity te = world.getBlockEntity(funnelPos); + BlockEntity te = world.getBlockEntity(funnelPos); if (!(te instanceof FunnelTileEntity)) return null; if (funnelState.getValue(BeltFunnelBlock.POWERED)) 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 9e43eca67..d3f200641 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 @@ -12,8 +12,8 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.Vec3; public class TransportedItemStackHandlerBehaviour extends TileEntityBehaviour { @@ -111,7 +111,7 @@ public class TransportedItemStackHandlerBehaviour extends TileEntityBehaviour { this.processingCallback.applyToAllItems(maxDistanceFromCenter, processFunction); } - public Vector3d getWorldPositionOf(TransportedItemStack transported) { + public Vec3 getWorldPositionOf(TransportedItemStack transported) { return positionGetter.getWorldPositionVector(transported); } @@ -128,7 +128,7 @@ public class TransportedItemStackHandlerBehaviour extends TileEntityBehaviour { @FunctionalInterface public interface PositionGetter { - public Vector3d getWorldPositionVector(TransportedItemStack transported); + public Vec3 getWorldPositionVector(TransportedItemStack transported); } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionBehaviour.java index e4ca847e1..a5c08af34 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionBehaviour.java @@ -6,10 +6,10 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; -import net.minecraft.item.Item; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.item.Item; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class EdgeInteractionBehaviour extends TileEntityBehaviour { @@ -43,12 +43,12 @@ public class EdgeInteractionBehaviour extends TileEntityBehaviour { @FunctionalInterface public interface ConnectionCallback { - public void apply(World world, BlockPos clicked, BlockPos neighbour); + public void apply(Level world, BlockPos clicked, BlockPos neighbour); } @FunctionalInterface public interface ConnectivityPredicate { - public boolean test(World world, BlockPos pos, Direction selectedFace, Direction connectedFace); + public boolean test(Level world, BlockPos pos, Direction selectedFace, Direction connectedFace); } } 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 47bb85727..c47a767d4 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 @@ -8,19 +8,19 @@ import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.RaycastHelper; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.LogicalSide; @@ -31,10 +31,10 @@ public class EdgeInteractionHandler { @SubscribeEvent public static void onBlockActivated(PlayerInteractEvent.RightClickBlock event) { - World world = event.getWorld(); + Level world = event.getWorld(); BlockPos pos = event.getPos(); - PlayerEntity player = event.getPlayer(); - Hand hand = event.getHand(); + Player player = event.getPlayer(); + InteractionHand hand = event.getHand(); ItemStack heldItem = player.getItemInHand(hand); if (player.isShiftKeyDown() || player.isSpectator()) @@ -42,7 +42,7 @@ public class EdgeInteractionHandler { EdgeInteractionBehaviour behaviour = TileEntityBehaviour.get(world, pos, EdgeInteractionBehaviour.TYPE); if (behaviour == null) return; - BlockRayTraceResult ray = RaycastHelper.rayTraceRange(world, player, 10); + BlockHitResult ray = RaycastHelper.rayTraceRange(world, player, 10); if (ray == null) return; if (behaviour.requiredItem.orElse(heldItem.getItem()) != heldItem.getItem()) @@ -55,11 +55,11 @@ public class EdgeInteractionHandler { if (event.getSide() != LogicalSide.CLIENT) behaviour.connectionCallback.apply(world, pos, pos.relative(activatedDirection)); event.setCanceled(true); - event.setCancellationResult(ActionResultType.SUCCESS); - world.playSound(null, pos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundCategory.BLOCKS, .25f, .1f); + event.setCancellationResult(InteractionResult.SUCCESS); + world.playSound(null, pos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.BLOCKS, .25f, .1f); } - public static List getConnectiveSides(World world, BlockPos pos, Direction face, + public static List getConnectiveSides(Level world, BlockPos pos, Direction face, EdgeInteractionBehaviour behaviour) { List sides = new ArrayList<>(6); if (BlockHelper.hasBlockSolidSide(world.getBlockState(pos.relative(face)), world, pos.relative(face), face.getOpposite())) @@ -80,19 +80,19 @@ public class EdgeInteractionHandler { return sides; } - public static Direction getActivatedDirection(World world, BlockPos pos, Direction face, Vector3d hit, + public static Direction getActivatedDirection(Level world, BlockPos pos, Direction face, Vec3 hit, EdgeInteractionBehaviour behaviour) { for (Direction facing : getConnectiveSides(world, pos, face, behaviour)) { - AxisAlignedBB bb = getBB(pos, facing); + AABB bb = getBB(pos, facing); if (bb.contains(hit)) return facing; } return null; } - static AxisAlignedBB getBB(BlockPos pos, Direction direction) { - AxisAlignedBB bb = new AxisAlignedBB(pos); - Vector3i vec = direction.getNormal(); + static AABB getBB(BlockPos pos, Direction direction) { + AABB bb = new AABB(pos); + Vec3i vec = direction.getNormal(); int x = vec.getX(); int y = vec.getY(); int z = vec.getZ(); 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 1c6d512ad..8c995ceb3 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 @@ -9,30 +9,30 @@ import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.TextComponent; public class EdgeInteractionRenderer { public static void tick() { Minecraft mc = Minecraft.getInstance(); - RayTraceResult target = mc.hitResult; - if (target == null || !(target instanceof BlockRayTraceResult)) + HitResult target = mc.hitResult; + if (target == null || !(target instanceof BlockHitResult)) return; - BlockRayTraceResult result = (BlockRayTraceResult) target; - ClientWorld world = mc.level; + BlockHitResult result = (BlockHitResult) target; + ClientLevel world = mc.level; BlockPos pos = result.getBlockPos(); - PlayerEntity player = mc.player; + Player player = mc.player; ItemStack heldItem = player.getMainHandItem(); if (player.isShiftKeyDown()) @@ -50,9 +50,9 @@ public class EdgeInteractionRenderer { Direction closestEdge = connectiveSides.get(0); double bestDistance = Double.MAX_VALUE; - Vector3d center = VecHelper.getCenterOf(pos); + Vec3 center = VecHelper.getCenterOf(pos); for (Direction direction : connectiveSides) { - double distance = Vector3d.atLowerCornerOf(direction.getNormal()).subtract(target.getLocation() + double distance = Vec3.atLowerCornerOf(direction.getNormal()).subtract(target.getLocation() .subtract(center)) .length(); if (distance > bestDistance) @@ -61,11 +61,11 @@ public class EdgeInteractionRenderer { closestEdge = direction; } - AxisAlignedBB bb = EdgeInteractionHandler.getBB(pos, closestEdge); + AABB bb = EdgeInteractionHandler.getBB(pos, closestEdge); boolean hit = bb.contains(target.getLocation()); - ValueBox box = new ValueBox(StringTextComponent.EMPTY, bb.move(-pos.getX(), -pos.getY(), -pos.getZ()), pos); - Vector3d textOffset = Vector3d.ZERO; + ValueBox box = new ValueBox(TextComponent.EMPTY, bb.move(-pos.getX(), -pos.getY(), -pos.getZ()), pos); + Vec3 textOffset = Vec3.ZERO; boolean positive = closestEdge.getAxisDirection() == AxisDirection.POSITIVE; if (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 b7098e455..dc1cfb499 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 @@ -12,14 +12,14 @@ import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.items.ItemHandlerHelper; @@ -29,7 +29,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { ValueBoxTransform slotPositioning; boolean showCount; - Vector3d textShift; + Vec3 textShift; private ItemStack filter; public int count; @@ -51,7 +51,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { callback = stack -> { }; isActive = () -> true; - textShift = Vector3d.ZERO; + textShift = Vec3.ZERO; count = 0; ticksUntilScrollPacket = -1; showCountPredicate = () -> showCount; @@ -63,7 +63,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { public boolean isSafeNBT() { return true; } @Override - public void write(CompoundNBT nbt, boolean clientPacket) { + public void write(CompoundTag nbt, boolean clientPacket) { nbt.put("Filter", getFilter().serializeNBT()); nbt.putInt("FilterAmount", count); @@ -75,7 +75,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { } @Override - public void read(CompoundNBT nbt, boolean clientPacket) { + public void read(CompoundTag nbt, boolean clientPacket) { filter = ItemStack.of(nbt.getCompound("Filter")); count = nbt.getInt("FilterAmount"); if (nbt.contains("ForceScrollable")) { @@ -132,7 +132,7 @@ public class FilteringBehaviour extends TileEntityBehaviour { return this; } - public FilteringBehaviour moveText(Vector3d shift) { + public FilteringBehaviour moveText(Vec3 shift) { textShift = shift; return this; } @@ -162,8 +162,8 @@ public class FilteringBehaviour extends TileEntityBehaviour { @Override public void destroy() { if (filter.getItem() instanceof FilterItem) { - Vector3d pos = VecHelper.getCenterOf(getPos()); - World world = getWorld(); + Vec3 pos = VecHelper.getCenterOf(getPos()); + Level world = getWorld(); world.addFreshEntity(new ItemEntity(world, pos.x, pos.y, pos.z, filter.copy())); } @@ -204,9 +204,9 @@ public class FilteringBehaviour extends TileEntityBehaviour { return TYPE; } - public boolean testHit(Vector3d hit) { + public boolean testHit(Vec3 hit) { BlockState state = tileEntity.getBlockState(); - Vector3d localHit = hit.subtract(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); + Vec3 localHit = hit.subtract(Vec3.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 562ba13ab..aa043857a 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 @@ -3,14 +3,14 @@ package com.simibubi.create.foundation.tileEntity.behaviour.filtering; import com.simibubi.create.foundation.networking.TileEntityConfigurationPacket; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; public class FilteringCountUpdatePacket extends TileEntityConfigurationPacket { int amount; - public FilteringCountUpdatePacket(PacketBuffer buffer) { + public FilteringCountUpdatePacket(FriendlyByteBuf buffer) { super(buffer); } @@ -20,12 +20,12 @@ public class FilteringCountUpdatePacket extends TileEntityConfigurationPacket { - CompoundNBT compound = new CompoundNBT(); + CompoundTag compound = new CompoundTag(); compound.putInt("Side", entry.getKey() .get3DDataValue()); entry.getValue() @@ -73,7 +73,7 @@ public class SidedFilteringBehaviour extends FilteringBehaviour { } @Override - public void read(CompoundNBT nbt, boolean clientPacket) { + public void read(CompoundTag nbt, boolean clientPacket) { NBTHelper.iterateCompoundList(nbt.getList("Filters", NBT.TAG_COMPOUND), compound -> { Direction face = Direction.from3DDataValue(compound.getInt("Side")); if (sidedFilters.containsKey(face)) @@ -136,10 +136,10 @@ public class SidedFilteringBehaviour extends FilteringBehaviour { .destroy(); } - public boolean testHit(Direction direction, Vector3d hit) { + public boolean testHit(Direction direction, Vec3 hit) { ValueBoxTransform.Sided sidedPositioning = (Sided) slotPositioning; BlockState state = tileEntity.getBlockState(); - Vector3d localHit = hit.subtract(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); + Vec3 localHit = hit.subtract(Vec3.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 f004b8529..368d4c331 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 @@ -13,13 +13,15 @@ import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; import net.minecraftforge.common.util.Constants.NBT; 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 @@ -170,15 +172,15 @@ public class SmartFluidTankBehaviour extends TileEntityBehaviour { } @Override - public void write(CompoundNBT nbt, boolean clientPacket) { + public void write(CompoundTag nbt, boolean clientPacket) { super.write(nbt, clientPacket); - ListNBT tanksNBT = new ListNBT(); + ListTag tanksNBT = new ListTag(); forEach(ts -> tanksNBT.add(ts.writeNBT())); nbt.put(getType().getName() + "Tanks", tanksNBT); } @Override - public void read(CompoundNBT nbt, boolean clientPacket) { + public void read(CompoundTag nbt, boolean clientPacket) { super.read(nbt, clientPacket); MutableInt index = new MutableInt(0); NBTHelper.iterateCompoundList(nbt.getList(getType().getName() + "Tanks", NBT.TAG_COMPOUND), c -> { @@ -261,14 +263,14 @@ public class SmartFluidTankBehaviour extends TileEntityBehaviour { return fluidLevel.getValue(partialTicks) * tank.getCapacity(); } - public CompoundNBT writeNBT() { - CompoundNBT compound = new CompoundNBT(); - compound.put("TankContent", tank.writeToNBT(new CompoundNBT())); + public CompoundTag writeNBT() { + CompoundTag compound = new CompoundTag(); + compound.put("TankContent", tank.writeToNBT(new CompoundTag())); compound.put("Level", fluidLevel.writeNBT()); return compound; } - public void readNBT(CompoundNBT compound, boolean clientPacket) { + public void readNBT(CompoundTag compound, boolean clientPacket) { tank.readFromNBT(compound.getCompound("TankContent")); fluidLevel.readNBT(compound.getCompound("Level"), clientPacket); if (!tank.getFluid() diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/inventory/CapManipulationBehaviourBase.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/inventory/CapManipulationBehaviourBase.java index 3375b59e7..07a48911e 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/inventory/CapManipulationBehaviourBase.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/inventory/CapManipulationBehaviourBase.java @@ -7,11 +7,11 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.BlockFace; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; @@ -103,7 +103,7 @@ public abstract class CapManipulationBehaviourBase capability = capability(); @@ -137,7 +137,7 @@ public abstract class CapManipulationBehaviourBase> offsets; - Function rotation; + Function> offsets; + Function rotation; float scale; - public SlotPositioning(Function> offsetsForState, - Function rotationForState) { + public SlotPositioning(Function> offsetsForState, + Function rotationForState) { offsets = offsetsForState; rotation = rotationForState; scale = 1; @@ -199,9 +199,9 @@ public class LinkBehaviour extends TileEntityBehaviour implements IRedstoneLinka } - public boolean testHit(Boolean first, Vector3d hit) { + public boolean testHit(Boolean first, Vec3 hit) { BlockState state = tileEntity.getBlockState(); - Vector3d localHit = hit.subtract(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); + Vec3 localHit = hit.subtract(Vec3.atLowerCornerOf(tileEntity.getBlockPos())); return (first ? firstSlot : secondSlot).testHit(state, localHit); } 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 1c428e62d..300e6befa 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 @@ -6,15 +6,15 @@ import com.simibubi.create.AllItems; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.RaycastHelper; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.LogicalSide; @@ -25,10 +25,10 @@ public class LinkHandler { @SubscribeEvent public static void onBlockActivated(PlayerInteractEvent.RightClickBlock event) { - World world = event.getWorld(); + Level world = event.getWorld(); BlockPos pos = event.getPos(); - PlayerEntity player = event.getPlayer(); - Hand hand = event.getHand(); + Player player = event.getPlayer(); + InteractionHand hand = event.getHand(); if (player.isShiftKeyDown() || player.isSpectator()) return; @@ -38,7 +38,7 @@ public class LinkHandler { return; ItemStack heldItem = player.getItemInHand(hand); - BlockRayTraceResult ray = RaycastHelper.rayTraceRange(world, player, 10); + BlockHitResult ray = RaycastHelper.rayTraceRange(world, player, 10); if (ray == null) return; if (AllItems.LINKED_CONTROLLER.isIn(heldItem)) @@ -51,8 +51,8 @@ public class LinkHandler { if (event.getSide() != LogicalSide.CLIENT) behaviour.setFrequency(first, heldItem); event.setCanceled(true); - event.setCancellationResult(ActionResultType.SUCCESS); - world.playSound(null, pos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundCategory.BLOCKS, .25f, .1f); + event.setCancellationResult(InteractionResult.SUCCESS); + world.playSound(null, pos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.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 23962d3c4..ec75511dc 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 @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.tileEntity.behaviour.linked; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.CreateClient; @@ -15,39 +15,39 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; public class LinkRenderer { public static void tick() { Minecraft mc = Minecraft.getInstance(); - RayTraceResult target = mc.hitResult; - if (target == null || !(target instanceof BlockRayTraceResult)) + HitResult target = mc.hitResult; + if (target == null || !(target instanceof BlockHitResult)) return; - BlockRayTraceResult result = (BlockRayTraceResult) target; - ClientWorld world = mc.level; + BlockHitResult result = (BlockHitResult) target; + ClientLevel world = mc.level; BlockPos pos = result.getBlockPos(); LinkBehaviour behaviour = TileEntityBehaviour.get(world, pos, LinkBehaviour.TYPE); if (behaviour == null) return; - ITextComponent freq1 = Lang.translate("logistics.firstFrequency"); - ITextComponent freq2 = Lang.translate("logistics.secondFrequency"); + Component freq1 = Lang.translate("logistics.firstFrequency"); + Component freq2 = Lang.translate("logistics.secondFrequency"); for (boolean first : Iterate.trueAndFalse) { - AxisAlignedBB bb = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).inflate(.25f); - ITextComponent label = first ? freq1 : freq2; + AABB bb = new AABB(Vec3.ZERO, Vec3.ZERO).inflate(.25f); + Component label = first ? freq1 : freq2; boolean hit = behaviour.testHit(first, target.getLocation()); ValueBoxTransform transform = first ? behaviour.firstSlot : behaviour.secondSlot; @@ -61,8 +61,8 @@ public class LinkRenderer { } } - public static void renderOnTileEntity(SmartTileEntity te, float partialTicks, MatrixStack ms, - IRenderTypeBuffer buffer, int light, int overlay) { + public static void renderOnTileEntity(SmartTileEntity te, float partialTicks, PoseStack ms, + MultiBufferSource buffer, int light, int overlay) { if (te == null || te.isRemoved()) return; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/BulkScrollValueBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/BulkScrollValueBehaviour.java index 245dab41f..8f5285100 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/BulkScrollValueBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/BulkScrollValueBehaviour.java @@ -6,13 +6,13 @@ import java.util.function.Function; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.network.chat.Component; public class BulkScrollValueBehaviour extends ScrollValueBehaviour { Function> groupGetter; - public BulkScrollValueBehaviour(ITextComponent label, SmartTileEntity te, ValueBoxTransform slot, + public BulkScrollValueBehaviour(Component label, SmartTileEntity te, ValueBoxTransform slot, Function> groupGetter) { super(label, te, slot); this.groupGetter = groupGetter; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollOptionBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollOptionBehaviour.java index 2756fa313..6bb236f93 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollOptionBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollOptionBehaviour.java @@ -3,13 +3,13 @@ package com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.network.chat.Component; public class ScrollOptionBehaviour & INamedIconOptions> extends ScrollValueBehaviour { private E[] options; - public ScrollOptionBehaviour(Class enum_, ITextComponent label, SmartTileEntity te, ValueBoxTransform slot) { + public ScrollOptionBehaviour(Class enum_, Component label, SmartTileEntity te, ValueBoxTransform slot) { super(label, te, slot); options = enum_.getEnumConstants(); between(0, options.length - 1); 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 090c32a21..9ea677928 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 @@ -10,18 +10,18 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; -import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; public class ScrollValueBehaviour extends TileEntityBehaviour { public static BehaviourType TYPE = new BehaviourType<>(); ValueBoxTransform slotPositioning; - Vector3d textShift; + Vec3 textShift; int min = 0; int max = 1; @@ -29,16 +29,16 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { public int scrollableValue; int ticksUntilScrollPacket; boolean forceClientState; - ITextComponent label; + Component label; Consumer callback; Consumer clientCallback; Function formatter; - Function unit; + Function unit; Function step; private Supplier isActive; boolean needsWrench; - public ScrollValueBehaviour(ITextComponent label, SmartTileEntity te, ValueBoxTransform slot) { + public ScrollValueBehaviour(Component label, SmartTileEntity te, ValueBoxTransform slot) { super(te); this.setLabel(label); slotPositioning = slot; @@ -46,7 +46,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { }; clientCallback = i -> { }; - textShift = Vector3d.ZERO; + textShift = Vec3.ZERO; formatter = i -> Integer.toString(i); step = (c) -> 1; value = 0; @@ -58,7 +58,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { public boolean isSafeNBT() { return true; } @Override - public void write(CompoundNBT nbt, boolean clientPacket) { + public void write(CompoundTag nbt, boolean clientPacket) { nbt.putInt("ScrollValue", value); if (clientPacket && forceClientState) { nbt.putBoolean("ForceScrollable", true); @@ -68,7 +68,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { } @Override - public void read(CompoundNBT nbt, boolean clientPacket) { + public void read(CompoundTag nbt, boolean clientPacket) { value = nbt.getInt("ScrollValue"); if (nbt.contains("ForceScrollable")) { ticksUntilScrollPacket = -1; @@ -110,7 +110,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { return this; } - public ScrollValueBehaviour moveText(Vector3d shift) { + public ScrollValueBehaviour moveText(Vec3 shift) { textShift = shift; return this; } @@ -125,7 +125,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { return this; } - public ScrollValueBehaviour withUnit(Function unit) { + public ScrollValueBehaviour withUnit(Function unit) { this.unit = unit; return this; } @@ -148,7 +148,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { } public void setValue(int value) { - value = MathHelper.clamp(value, min, max); + value = Mth.clamp(value, min, max); if (value == this.value) return; this.value = value; @@ -176,13 +176,13 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { return isActive.get(); } - public boolean testHit(Vector3d hit) { + public boolean testHit(Vec3 hit) { BlockState state = tileEntity.getBlockState(); - Vector3d localHit = hit.subtract(Vector3d.atLowerCornerOf(tileEntity.getBlockPos())); + Vec3 localHit = hit.subtract(Vec3.atLowerCornerOf(tileEntity.getBlockPos())); return slotPositioning.testHit(state, localHit); } - public void setLabel(ITextComponent label) { + public void setLabel(Component label) { this.label = label; } 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 0f7f15667..0edd728f1 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 @@ -10,11 +10,11 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal import com.simibubi.create.foundation.utility.animation.PhysicalFloat; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.HitResult; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -30,13 +30,13 @@ public class ScrollValueHandler { @OnlyIn(Dist.CLIENT) public static boolean onScroll(double delta) { - RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; - if (!(objectMouseOver instanceof BlockRayTraceResult)) + HitResult objectMouseOver = Minecraft.getInstance().hitResult; + if (!(objectMouseOver instanceof BlockHitResult)) return false; - BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver; + BlockHitResult result = (BlockHitResult) objectMouseOver; Minecraft mc = Minecraft.getInstance(); - ClientWorld world = mc.level; + ClientLevel world = mc.level; BlockPos blockPos = result.getBlockPos(); ScrollValueBehaviour scrolling = TileEntityBehaviour.get(world, blockPos, ScrollValueBehaviour.TYPE); @@ -71,14 +71,14 @@ public class ScrollValueHandler { if (prev != scrolling.scrollableValue) { float pitch = (scrolling.scrollableValue - scrolling.min) / (float) (scrolling.max - scrolling.min); - pitch = MathHelper.lerp(pitch, 1.5f, 2f); + pitch = Mth.lerp(pitch, 1.5f, 2f); AllSoundEvents.SCROLL_VALUE.play(world, mc.player, blockPos, 1, pitch); } return true; } public static float getScroll(float partialTicks) { - return wrenchCog.getValue(partialTicks) + MathHelper.lerp(partialTicks, lastPassiveScroll, passiveScroll); + return wrenchCog.getValue(partialTicks) + Mth.lerp(partialTicks, lastPassiveScroll, passiveScroll); } @OnlyIn(Dist.CLIENT) @@ -102,7 +102,7 @@ public class ScrollValueHandler { context.forward = delta > 0; double newValue = scrolling.scrollableValue + Math.signum(delta) * scrolling.step.apply(context); - scrolling.scrollableValue = (int) MathHelper.clamp(newValue, scrolling.min, scrolling.max); + scrolling.scrollableValue = (int) Mth.clamp(newValue, scrolling.min, scrolling.max); if (valueBefore != scrolling.scrollableValue) scrolling.clientCallback.accept(scrolling.scrollableValue); 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 f157c98fc..fc9155cfd 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 @@ -11,26 +11,26 @@ import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox.TextValueBox import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; public class ScrollValueRenderer { public static void tick() { Minecraft mc = Minecraft.getInstance(); - RayTraceResult target = mc.hitResult; - if (target == null || !(target instanceof BlockRayTraceResult)) + HitResult target = mc.hitResult; + if (target == null || !(target instanceof BlockHitResult)) return; - BlockRayTraceResult result = (BlockRayTraceResult) target; - ClientWorld world = mc.level; + BlockHitResult result = (BlockHitResult) target; + ClientLevel world = mc.level; BlockPos pos = result.getBlockPos(); Direction face = result.getDirection(); @@ -54,23 +54,23 @@ public class ScrollValueRenderer { addBox(world, pos, face, behaviour, highlight); } - protected static void addBox(ClientWorld world, BlockPos pos, Direction face, ScrollValueBehaviour behaviour, + protected static void addBox(ClientLevel world, BlockPos pos, Direction face, ScrollValueBehaviour behaviour, boolean highlight) { - AxisAlignedBB bb = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).inflate(.5f) + AABB bb = new AABB(Vec3.ZERO, Vec3.ZERO).inflate(.5f) .contract(0, 0, -.5f) .move(0, 0, -.125f); - ITextComponent label = behaviour.label; + Component label = behaviour.label; ValueBox box; if (behaviour instanceof ScrollOptionBehaviour) { box = new IconValueBox(label, ((ScrollOptionBehaviour) behaviour).getIconForSelected(), bb, pos); } else { - box = new TextValueBox(label, bb, pos, new StringTextComponent(behaviour.formatValue())); + box = new TextValueBox(label, bb, pos, new TextComponent(behaviour.formatValue())); if (behaviour.unit != null) - box.subLabel(new StringTextComponent("(").append(behaviour.unit.apply(behaviour.scrollableValue)).append(")")); + box.subLabel(new TextComponent("(").append(behaviour.unit.apply(behaviour.scrollableValue)).append(")")); } - box.scrollTooltip(new StringTextComponent("[").append(Lang.translate("action.scroll")).append("]")); + box.scrollTooltip(new TextComponent("[").append(Lang.translate("action.scroll")).append("]")); box.offsetLabel(behaviour.textShift.add(20, -10, 0)) .withColors(0x5A5D5A, 0xB5B7B6) .passive(!highlight); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueUpdatePacket.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueUpdatePacket.java index 3e4d0d90a..b6cd5ca07 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueUpdatePacket.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueUpdatePacket.java @@ -3,14 +3,14 @@ package com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue; import com.simibubi.create.foundation.networking.TileEntityConfigurationPacket; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.BlockPos; public class ScrollValueUpdatePacket extends TileEntityConfigurationPacket { int value; - public ScrollValueUpdatePacket(PacketBuffer buffer) { + public ScrollValueUpdatePacket(FriendlyByteBuf buffer) { super(buffer); } @@ -20,12 +20,12 @@ public class ScrollValueUpdatePacket extends TileEntityConfigurationPacket extends SafeTileEntityRenderer { +public abstract class ColoredOverlayTileEntityRenderer extends SafeTileEntityRenderer { - public ColoredOverlayTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public ColoredOverlayTileEntityRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; 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 d69e54731..e70781daf 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 @@ -1,28 +1,28 @@ package com.simibubi.create.foundation.tileEntity.renderer; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.block.Blocks; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.level.block.entity.BlockEntity; -public abstract class SafeTileEntityRenderer extends TileEntityRenderer { +public abstract class SafeTileEntityRenderer extends BlockEntityRenderer { - public SafeTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public SafeTileEntityRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - public final void render(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, + public final void render(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { if (isInvalid(te)) return; renderSafe(te, partialTicks, ms, buffer, light, overlay); } - protected abstract void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, + protected abstract void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay); public boolean isInvalid(T te) { diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/SmartTileEntityRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/SmartTileEntityRenderer.java index 7dfbf60ff..6ea566114 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/SmartTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/SmartTileEntityRenderer.java @@ -1,21 +1,21 @@ package com.simibubi.create.foundation.tileEntity.renderer; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkRenderer; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; public class SmartTileEntityRenderer extends SafeTileEntityRenderer { - public SmartTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public SmartTileEntityRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(T tileEntityIn, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, + protected void renderSafe(T tileEntityIn, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { FilteringRenderer.renderOnTileEntity(tileEntityIn, partialTicks, ms, buffer, light, overlay); LinkRenderer.renderOnTileEntity(tileEntityIn, partialTicks, ms, buffer, light, overlay); 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 4bef24374..3a1bbfe35 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AbstractBlockBreakQueue.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AbstractBlockBreakQueue.java @@ -5,33 +5,33 @@ import java.util.function.Consumer; import javax.annotation.Nullable; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import net.minecraftforge.event.ForgeEventFactory; public abstract class AbstractBlockBreakQueue { - protected Consumer makeCallbackFor(World world, float effectChance, ItemStack toDamage, - @Nullable PlayerEntity playerEntity, BiConsumer drop) { + protected Consumer makeCallbackFor(Level world, float effectChance, ItemStack toDamage, + @Nullable Player playerEntity, BiConsumer drop) { return pos -> { ItemStack usedTool = toDamage.copy(); BlockHelper.destroyBlockAs(world, pos, playerEntity, toDamage, effectChance, stack -> drop.accept(pos, stack)); if (toDamage.isEmpty() && !usedTool.isEmpty()) - ForgeEventFactory.onPlayerDestroyItem(playerEntity, usedTool, Hand.MAIN_HAND); + ForgeEventFactory.onPlayerDestroyItem(playerEntity, usedTool, InteractionHand.MAIN_HAND); }; } - public void destroyBlocks(World world, @Nullable LivingEntity entity, BiConsumer drop) { - PlayerEntity playerEntity = entity instanceof PlayerEntity ? ((PlayerEntity) entity) : null; + public void destroyBlocks(Level world, @Nullable LivingEntity entity, BiConsumer drop) { + Player playerEntity = entity instanceof Player ? ((Player) entity) : null; ItemStack toDamage = playerEntity != null && !playerEntity.isCreative() ? playerEntity.getMainHandItem() : ItemStack.EMPTY; destroyBlocks(world, toDamage, playerEntity, drop); } - public abstract void destroyBlocks(World world, ItemStack toDamage, @Nullable PlayerEntity playerEntity, + public abstract void destroyBlocks(Level world, ItemStack toDamage, @Nullable Player playerEntity, BiConsumer 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 4ed984af0..33d007d79 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.utility; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; public class AngleHelper { 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 2564c2cc6..2b22b2fe6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java @@ -5,7 +5,7 @@ import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedClientWorld; import net.minecraft.client.Minecraft; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.LevelAccessor; public class AnimationTickHolder { @@ -43,17 +43,17 @@ public class AnimationTickHolder { return (mc.isPaused() ? mc.pausePartialTick : mc.getFrameTime()); } - public static int getTicks(IWorld world) { + public static int getTicks(LevelAccessor world) { if (world instanceof WrappedClientWorld) return getTicks(((WrappedClientWorld) world).getWrappedWorld()); return world instanceof PonderWorld ? PonderUI.ponderTicks : getTicks(); } - public static float getRenderTime(IWorld world) { + public static float getRenderTime(LevelAccessor world) { return getTicks(world) + getPartialTicks(world); } - public static float getPartialTicks(IWorld world) { + public static float getPartialTicks(LevelAccessor world) { return world instanceof PonderWorld ? PonderUI.getPartialTicks() : getPartialTicks(); } } 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 a995e5fae..a4566b3b1 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockFace.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockFace.java @@ -1,9 +1,9 @@ package com.simibubi.create.foundation.utility; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; public class BlockFace extends Pair { @@ -37,15 +37,15 @@ public class BlockFace extends Pair { return getPos().relative(getFace()); } - public CompoundNBT serializeNBT() { - CompoundNBT compoundNBT = new CompoundNBT(); - compoundNBT.put("Pos", NBTUtil.writeBlockPos(getPos())); + public CompoundTag serializeNBT() { + CompoundTag compoundNBT = new CompoundTag(); + compoundNBT.put("Pos", NbtUtils.writeBlockPos(getPos())); NBTHelper.writeEnum(compoundNBT, "Face", getFace()); return compoundNBT; } - public static BlockFace fromNBT(CompoundNBT compound) { - return new BlockFace(NBTUtil.readBlockPos(compound.getCompound("Pos")), + public static BlockFace fromNBT(CompoundTag compound) { + return new BlockFace(NbtUtils.readBlockPos(compound.getCompound("Pos")), NBTHelper.readEnum(compound, "Face", Direction.class)); } 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 ac2f860f5..a70cd73fc 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java @@ -10,41 +10,41 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.actors.SeatBlock; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.BedBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.SlimeBlock; -import net.minecraft.client.particle.DiggingParticle; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.state.Property; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.SlabType; +import net.minecraft.world.level.block.BaseRailBlock; +import net.minecraft.world.level.block.BedBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SlimeBlock; +import net.minecraft.client.particle.TerrainParticle; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.SlabType; import net.minecraft.stats.Stats; import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.GameRules; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.ChunkSection; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.IPlantable; @@ -54,11 +54,11 @@ import net.minecraftforge.event.world.BlockEvent; public class BlockHelper { @OnlyIn(Dist.CLIENT) - public static void addReducedDestroyEffects(BlockState state, World worldIn, BlockPos pos, - ParticleManager manager) { - if (!(worldIn instanceof ClientWorld)) + public static void addReducedDestroyEffects(BlockState state, Level worldIn, BlockPos pos, + ParticleEngine manager) { + if (!(worldIn instanceof ClientLevel)) return; - ClientWorld world = (ClientWorld) worldIn; + ClientLevel world = (ClientLevel) worldIn; VoxelShape voxelshape = state.getShape(world, pos); MutableInt amtBoxes = new MutableInt(0); voxelshape.forAllBoxes((x1, y1, z1, x2, y2, z2) -> amtBoxes.increment()); @@ -68,9 +68,9 @@ public class BlockHelper { double d1 = Math.min(1.0D, x2 - x1); double d2 = Math.min(1.0D, y2 - y1); double d3 = Math.min(1.0D, z2 - z1); - int i = Math.max(2, MathHelper.ceil(d1 / 0.25D)); - int j = Math.max(2, MathHelper.ceil(d2 / 0.25D)); - int k = Math.max(2, MathHelper.ceil(d3 / 0.25D)); + int i = Math.max(2, Mth.ceil(d1 / 0.25D)); + int j = Math.max(2, Mth.ceil(d2 / 0.25D)); + int k = Math.max(2, Mth.ceil(d3 / 0.25D)); for (int l = 0; l < i; ++l) { for (int i1 = 0; i1 < j; ++i1) { @@ -85,7 +85,7 @@ public class BlockHelper { double d8 = d5 * d2 + y1; double d9 = d6 * d3 + z1; manager - .add((new DiggingParticle(world, (double) pos.getX() + d7, (double) pos.getY() + d8, + .add((new TerrainParticle(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)); } } @@ -124,7 +124,7 @@ public class BlockHelper { return blockState; } - public static int findAndRemoveInInventory(BlockState block, PlayerEntity player, int amount) { + public static int findAndRemoveInInventory(BlockState block, Player player, int amount) { int amountFound = 0; Item required = getRequiredItem(block).getItem(); @@ -186,66 +186,66 @@ public class BlockHelper { return itemStack; } - public static void destroyBlock(World world, BlockPos pos, float effectChance) { + public static void destroyBlock(Level world, BlockPos pos, float effectChance) { destroyBlock(world, pos, effectChance, stack -> Block.popResource(world, pos, stack)); } - public static void destroyBlock(World world, BlockPos pos, float effectChance, + public static void destroyBlock(Level world, BlockPos pos, float effectChance, Consumer droppedItemCallback) { destroyBlockAs(world, pos, null, ItemStack.EMPTY, effectChance, droppedItemCallback); } - public static void destroyBlockAs(World world, BlockPos pos, @Nullable PlayerEntity player, ItemStack usedTool, + public static void destroyBlockAs(Level world, BlockPos pos, @Nullable Player player, ItemStack usedTool, float effectChance, Consumer droppedItemCallback) { FluidState fluidState = world.getFluidState(pos); BlockState state = world.getBlockState(pos); if (world.random.nextFloat() < effectChance) world.levelEvent(2001, pos, Block.getId(state)); - TileEntity tileentity = state.hasTileEntity() ? world.getBlockEntity(pos) : null; + BlockEntity 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); if (event.isCanceled()) return; - if (event.getExpToDrop() > 0 && world instanceof ServerWorld) + if (event.getExpToDrop() > 0 && world instanceof ServerLevel) state.getBlock() - .popExperience((ServerWorld) world, pos, event.getExpToDrop()); + .popExperience((ServerLevel) world, pos, event.getExpToDrop()); usedTool.mineBlock(world, state, pos, player); player.awardStat(Stats.BLOCK_MINED.get(state.getBlock())); } - if (world instanceof ServerWorld && world.getGameRules() + if (world instanceof ServerLevel && world.getGameRules() .getBoolean(GameRules.RULE_DOBLOCKDROPS) && !world.restoringBlockSnapshots && (player == null || !player.isCreative())) { - for (ItemStack itemStack : Block.getDrops(state, (ServerWorld) world, pos, tileentity, player, usedTool)) + for (ItemStack itemStack : Block.getDrops(state, (ServerLevel) world, pos, tileentity, player, usedTool)) droppedItemCallback.accept(itemStack); - state.spawnAfterBreak((ServerWorld) world, pos, ItemStack.EMPTY); + state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY); } world.setBlockAndUpdate(pos, fluidState.createLegacyBlock()); } - public static boolean isSolidWall(IBlockReader reader, BlockPos fromPos, Direction toDirection) { + public static boolean isSolidWall(BlockGetter reader, BlockPos fromPos, Direction toDirection) { return hasBlockSolidSide(reader.getBlockState(fromPos.relative(toDirection)), reader, fromPos.relative(toDirection), toDirection.getOpposite()); } - public static boolean noCollisionInSpace(IBlockReader reader, BlockPos pos) { + public static boolean noCollisionInSpace(BlockGetter reader, BlockPos pos) { return reader.getBlockState(pos) .getCollisionShape(reader, pos) .isEmpty(); } - private static void placeRailWithoutUpdate(World world, BlockState state, BlockPos target) { + private static void placeRailWithoutUpdate(Level world, BlockState state, BlockPos target) { int i = target.getX() & 15; int j = target.getY(); int k = target.getZ() & 15; - Chunk chunk = world.getChunkAt(target); - ChunkSection chunksection = chunk.getSections()[j >> 4]; - if (chunksection == Chunk.EMPTY_SECTION) { - chunksection = new ChunkSection(j >> 4 << 4); + LevelChunk chunk = world.getChunkAt(target); + LevelChunkSection chunksection = chunk.getSections()[j >> 4]; + if (chunksection == LevelChunk.EMPTY_SECTION) { + chunksection = new LevelChunkSection(j >> 4 << 4); chunk.getSections()[j >> 4] = chunksection; } BlockState old = chunksection.setBlockState(i, j & 15, k, state); @@ -256,8 +256,8 @@ public class BlockHelper { 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) { + public static void placeSchematicBlock(Level world, BlockState state, BlockPos target, ItemStack stack, + @Nullable CompoundTag data) { // Piston if (state.hasProperty(BlockStateProperties.EXTENDED)) state = state.setValue(BlockStateProperties.EXTENDED, Boolean.FALSE); @@ -280,7 +280,7 @@ public class BlockHelper { int i = target.getX(); int j = target.getY(); int k = target.getZ(); - world.playSound(null, target, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, + world.playSound(null, target, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { @@ -291,14 +291,14 @@ public class BlockHelper { return; } - if (state.getBlock() instanceof AbstractRailBlock) { + if (state.getBlock() instanceof BaseRailBlock) { placeRailWithoutUpdate(world, state, target); } else { world.setBlock(target, state, 18); } if (data != null) { - TileEntity tile = world.getBlockEntity(target); + BlockEntity tile = world.getBlockEntity(target); if (tile != null) { data.putInt("x", target.getX()); data.putInt("y", target.getY()); @@ -324,13 +324,13 @@ public class BlockHelper { return 0; } - public static boolean hasBlockSolidSide(BlockState p_220056_0_, IBlockReader p_220056_1_, BlockPos p_220056_2_, + public static boolean hasBlockSolidSide(BlockState p_220056_0_, BlockGetter p_220056_1_, BlockPos p_220056_2_, Direction 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_, + public static boolean extinguishFire(Level world, @Nullable Player p_175719_1_, BlockPos p_175719_2_, Direction p_175719_3_) { p_175719_2_ = p_175719_2_.relative(p_175719_3_); if (world.getBlockState(p_175719_2_) diff --git a/src/main/java/com/simibubi/create/foundation/utility/Color.java b/src/main/java/com/simibubi/create/foundation/utility/Color.java index 1872f3be0..aa2b9a5c0 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Color.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Color.java @@ -6,8 +6,8 @@ import javax.annotation.Nonnull; import com.google.common.hash.Hashing; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; @SuppressWarnings("PointlessBitwiseExpression") public class Color { @@ -34,10 +34,10 @@ public class Color { public Color(float r, float g, float b, float a) { this( - (int) (0.5 + 0xff * MathHelper.clamp(r, 0, 1)), - (int) (0.5 + 0xff * MathHelper.clamp(g, 0, 1)), - (int) (0.5 + 0xff * MathHelper.clamp(b, 0, 1)), - (int) (0.5 + 0xff * MathHelper.clamp(a, 0, 1)) + (int) (0.5 + 0xff * Mth.clamp(r, 0, 1)), + (int) (0.5 + 0xff * Mth.clamp(g, 0, 1)), + (int) (0.5 + 0xff * Mth.clamp(b, 0, 1)), + (int) (0.5 + 0xff * Mth.clamp(a, 0, 1)) ); } @@ -142,8 +142,8 @@ public class Color { return value; } - public Vector3d asVector() { - return new Vector3d(getRedAsFloat(), getGreenAsFloat(), getBlueAsFloat()); + public Vec3 asVector() { + return new Vec3(getRedAsFloat(), getGreenAsFloat(), getBlueAsFloat()); } public Color setRed(int r) { @@ -163,23 +163,23 @@ public class Color { } public Color setRed(float r) { - return ensureMutable().setRedUnchecked((int) (0xff * MathHelper.clamp(r, 0, 1))); + return ensureMutable().setRedUnchecked((int) (0xff * Mth.clamp(r, 0, 1))); } public Color setGreen(float g) { - return ensureMutable().setGreenUnchecked((int) (0xff * MathHelper.clamp(g, 0, 1))); + return ensureMutable().setGreenUnchecked((int) (0xff * Mth.clamp(g, 0, 1))); } public Color setBlue(float b) { - return ensureMutable().setBlueUnchecked((int) (0xff * MathHelper.clamp(b, 0, 1))); + return ensureMutable().setBlueUnchecked((int) (0xff * Mth.clamp(b, 0, 1))); } public Color setAlpha(float a) { - return ensureMutable().setAlphaUnchecked((int) (0xff * MathHelper.clamp(a, 0, 1))); + return ensureMutable().setAlphaUnchecked((int) (0xff * Mth.clamp(a, 0, 1))); } public Color scaleAlpha(float factor) { - return ensureMutable().setAlphaUnchecked((int) (getAlpha() * MathHelper.clamp(factor, 0, 1))); + return ensureMutable().setAlphaUnchecked((int) (getAlpha() * Mth.clamp(factor, 0, 1))); } @Deprecated @@ -317,11 +317,11 @@ public class Color { * Try not to introduce new usages of this method and instead use Color instances directly */ @Deprecated - public static Vector3d vectorFromRGB(int color) { + public static Vec3 vectorFromRGB(int color) { int r = (color >> 16) & 0xFF; int g = (color >> 8) & 0xFF; int b = color & 0xFF; - return new Vector3d(r, g, b).scale(1 / 255d); + return new Vec3(r, g, b).scale(1 / 255d); } } 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 4022dba98..24628cc25 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ColorHandlers.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ColorHandlers.java @@ -1,25 +1,25 @@ package com.simibubi.create.foundation.utility; -import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.client.renderer.color.IBlockColor; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.world.GrassColors; -import net.minecraft.world.biome.BiomeColors; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.GrassColor; +import net.minecraft.client.renderer.BiomeColors; public class ColorHandlers { - public static IBlockColor getGrassyBlock() { + public static BlockColor getGrassyBlock() { return (state, world, pos, layer) -> pos != null && world != null ? BiomeColors.getAverageGrassColor(world, pos) - : GrassColors.get(0.5D, 1.0D); + : GrassColor.get(0.5D, 1.0D); } - public static IItemColor getGrassyItem() { - return (stack, layer) -> GrassColors.get(0.5D, 1.0D); + public static ItemColor getGrassyItem() { + return (stack, layer) -> GrassColor.get(0.5D, 1.0D); } - public static IBlockColor getRedstonePower() { - return (state, world, pos, layer) -> RedstoneWireBlock + public static BlockColor getRedstonePower() { + return (state, world, pos, layer) -> RedStoneWireBlock .getColorForPower(pos != null && world != null ? state.getValue(BlockStateProperties.POWER) : 0); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/Couple.java b/src/main/java/com/simibubi/create/foundation/utility/Couple.java index 79b4bc1ce..775b74d99 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Couple.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Couple.java @@ -11,8 +11,8 @@ import java.util.stream.Stream; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; public class Couple extends Pair implements Iterable { @@ -91,11 +91,11 @@ public class Couple extends Pair implements Iterable { return Couple.create(second, first); } - public ListNBT serializeEach(Function serializer) { + public ListTag serializeEach(Function serializer) { return NBTHelper.writeCompoundList(ImmutableList.of(first, second), serializer); } - public static Couple deserializeEach(ListNBT list, Function deserializer) { + public static Couple deserializeEach(ListTag list, Function deserializer) { List readCompoundList = NBTHelper.readCompoundList(list, deserializer); return new Couple<>(readCompoundList.get(0), readCompoundList.get(1)); } 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 f59840d5b..605aa793f 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Debug.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Debug.java @@ -3,10 +3,10 @@ package com.simibubi.create.foundation.utility; import com.simibubi.create.Create; import net.minecraft.client.Minecraft; -import net.minecraft.util.text.IFormattableTextComponent; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.ChatFormatting; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.common.thread.EffectiveSide; @@ -18,20 +18,20 @@ public class Debug { @Deprecated public static void debugChat(String message) { if (Minecraft.getInstance().player != null) - Minecraft.getInstance().player.displayClientMessage(new StringTextComponent(message), false); + Minecraft.getInstance().player.displayClientMessage(new TextComponent(message), false); } @Deprecated public static void debugChatAndShowStack(String message, int depth) { if (Minecraft.getInstance().player != null) - Minecraft.getInstance().player.displayClientMessage(new StringTextComponent(message).append("@") + Minecraft.getInstance().player.displayClientMessage(new TextComponent(message).append("@") .append(debugStack(depth)), false); } @Deprecated public static void debugMessage(String message) { if (Minecraft.getInstance().player != null) - Minecraft.getInstance().player.displayClientMessage(new StringTextComponent(message), true); + Minecraft.getInstance().player.displayClientMessage(new TextComponent(message), true); } @Deprecated @@ -46,21 +46,21 @@ public class Debug { } @Deprecated - public static ITextComponent debugStack(int depth) { + public static Component debugStack(int depth) { StackTraceElement[] stackTraceElements = Thread.currentThread() .getStackTrace(); - IFormattableTextComponent text = new StringTextComponent("[") - .append(new StringTextComponent(getLogicalSide()).withStyle(TextFormatting.GOLD)) + MutableComponent text = new TextComponent("[") + .append(new TextComponent(getLogicalSide()).withStyle(ChatFormatting.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()).withStyle(TextFormatting.YELLOW)) + text.append(new TextComponent(e.getMethodName()).withStyle(ChatFormatting.YELLOW)) .append(", "); } - return text.append(new StringTextComponent(" ...").withStyle(TextFormatting.GRAY)); + return text.append(new TextComponent(" ...").withStyle(ChatFormatting.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 14996e0ea..e08120af6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/DirectionHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/DirectionHelper.java @@ -1,14 +1,14 @@ package com.simibubi.create.foundation.utility; import static net.minecraft.util.Direction.DOWN; -import static net.minecraft.util.Direction.EAST; +import staticnet.minecraft.core.Directionn.EAST; import static net.minecraft.util.Direction.NORTH; -import static net.minecraft.util.Direction.SOUTH; +import staticnet.minecraft.core.Directionn.SOUTH; import static net.minecraft.util.Direction.UP; -import static net.minecraft.util.Direction.WEST; +import staticnet.minecraft.core.Directionn.WEST; import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; +import net.minecraft.core.Direction.Axis; /** * A bunch of methods that got stripped out of Direction in 1.15 diff --git a/src/main/java/com/simibubi/create/foundation/utility/DyeHelper.java b/src/main/java/com/simibubi/create/foundation/utility/DyeHelper.java index 2b9f1014b..57fc7aae6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/DyeHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/DyeHelper.java @@ -1,12 +1,12 @@ package com.simibubi.create.foundation.utility; -import net.minecraft.block.Blocks; -import net.minecraft.item.DyeColor; -import net.minecraft.util.IItemProvider; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.ItemLike; public class DyeHelper { - public static IItemProvider getWoolOfDye(DyeColor color) { + public static ItemLike getWoolOfDye(DyeColor color) { switch (color) { case BLACK: return Blocks.BLACK_WOOL; diff --git a/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java b/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java index deb9d4027..413f0dc9b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java @@ -15,7 +15,7 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.simibubi.create.Create; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; public class FilesHelper { @@ -44,7 +44,7 @@ public class FilesHelper { .replaceAll("\\W+", "_"); } - public static boolean saveTagCompoundAsJson(CompoundNBT compound, String path) { + public static boolean saveTagCompoundAsJson(CompoundTag compound, String path) { try { Files.deleteIfExists(Paths.get(path)); JsonWriter writer = new JsonWriter(Files.newBufferedWriter(Paths.get(path), StandardOpenOption.CREATE)); @@ -58,7 +58,7 @@ public class FilesHelper { return false; } - public static boolean saveTagCompoundAsJsonCompact(CompoundNBT compound, String path) { + public static boolean saveTagCompoundAsJsonCompact(CompoundTag compound, String path) { try { Files.deleteIfExists(Paths.get(path)); JsonWriter writer = new JsonWriter(Files.newBufferedWriter(Paths.get(path), StandardOpenOption.CREATE)); 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 ce5f20f32..2e46357e1 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/FontHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/FontHelper.java @@ -4,19 +4,19 @@ import java.text.BreakIterator; import java.util.LinkedList; import java.util.List; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.client.gui.Font; +import net.minecraft.client.renderer.MultiBufferSource; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.math.Matrix4f; import net.minecraftforge.client.MinecraftForgeClient; public final class FontHelper { private FontHelper() {} - public static List cutString(FontRenderer font, String text, int maxWidthPerLine) { + public static List cutString(Font font, String text, int maxWidthPerLine) { // Split words List words = new LinkedList<>(); BreakIterator iterator = BreakIterator.getLineInstance(MinecraftForgeClient.getLocale()); @@ -52,7 +52,7 @@ public final class FontHelper { return lines; } - public static void drawSplitString(MatrixStack ms, FontRenderer font, String text, int x, int y, int width, + public static void drawSplitString(PoseStack ms, Font font, String text, int x, int y, int width, int color) { List list = cutString(font, text, width); Matrix4f matrix4f = ms.last() @@ -70,12 +70,12 @@ public final class FontHelper { } } - private static int draw(FontRenderer font, String p_228078_1_, float p_228078_2_, float p_228078_3_, + private static int draw(Font font, String p_228078_1_, float p_228078_2_, float p_228078_3_, int p_228078_4_, Matrix4f p_228078_5_, boolean p_228078_6_) { if (p_228078_1_ == null) { return 0; } else { - IRenderTypeBuffer.Impl irendertypebuffer$impl = IRenderTypeBuffer.immediate(Tessellator.getInstance() + MultiBufferSource.BufferSource irendertypebuffer$impl = MultiBufferSource.immediate(Tesselator.getInstance() .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); diff --git a/src/main/java/com/simibubi/create/foundation/utility/ICoordinate.java b/src/main/java/com/simibubi/create/foundation/utility/ICoordinate.java index aa4bdcbb8..7a5f15942 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ICoordinate.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ICoordinate.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.utility; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; @FunctionalInterface public interface ICoordinate { diff --git a/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java b/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java index ae1ca8a9d..3c4952c1e 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java +++ b/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.utility; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; public interface IPartialSafeNBT { - public void writeSafe(CompoundNBT compound, boolean clientPacket); + public void writeSafe(CompoundTag compound, boolean clientPacket); } 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 fb923c13a..8dbed20bb 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java @@ -3,21 +3,21 @@ package com.simibubi.create.foundation.utility; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; -import net.minecraft.profiler.IProfiler; -import net.minecraft.resources.IFutureReloadListener; -import net.minecraft.resources.IResourceManager; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.server.packs.resources.PreparableReloadListener; +import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.util.Unit; @FunctionalInterface -public interface ISimpleReloadListener extends IFutureReloadListener { +public interface ISimpleReloadListener extends PreparableReloadListener { @Override - default CompletableFuture reload(IFutureReloadListener.IStage stage, IResourceManager resourceManager, IProfiler prepareProfiler, IProfiler applyProfiler, Executor prepareExecutor, Executor applyExecutor) { + default CompletableFuture reload(PreparableReloadListener.PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor) { return stage.wait(Unit.INSTANCE).thenRunAsync(() -> { onReload(resourceManager, applyProfiler); }, applyExecutor); } - void onReload(IResourceManager resourceManager, IProfiler profiler); + void onReload(ResourceManager resourceManager, ProfilerFiller profiler); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/IntAttached.java b/src/main/java/com/simibubi/create/foundation/utility/IntAttached.java index 157b533dc..f49436c92 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/IntAttached.java +++ b/src/main/java/com/simibubi/create/foundation/utility/IntAttached.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.utility; import java.util.function.Function; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; public class IntAttached extends Pair { @@ -42,14 +42,14 @@ public class IntAttached extends Pair { return getSecond(); } - public CompoundNBT serializeNBT(Function serializer) { - CompoundNBT nbt = new CompoundNBT(); + public CompoundTag serializeNBT(Function serializer) { + CompoundTag nbt = new CompoundTag(); nbt.put("Item", serializer.apply(getValue())); nbt.putInt("Location", getFirst()); return nbt; } - public static IntAttached read(CompoundNBT nbt, Function deserializer) { + public static IntAttached read(CompoundTag nbt, Function deserializer) { return IntAttached.with(nbt.getInt("Location"), deserializer.apply(nbt.getCompound("Item"))); } 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 138d2642c..3cd2be914 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Iterate.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Iterate.java @@ -4,9 +4,9 @@ import java.util.Arrays; import java.util.EnumSet; import java.util.List; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.BlockPos; public class Iterate { 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 4572424b2..5672747e0 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Lang.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Lang.java @@ -6,26 +6,26 @@ import java.util.Locale; import com.simibubi.create.Create; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.entity.player.Player; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; public class Lang { - public static TranslationTextComponent translate(String key, Object... args) { + public static TranslatableComponent translate(String key, Object... args) { return createTranslationTextComponent(key, args); } - public static TranslationTextComponent createTranslationTextComponent(String key, Object... args) { - return new TranslationTextComponent(Create.ID + "." + key, args); + public static TranslatableComponent createTranslationTextComponent(String key, Object... args) { + return new TranslatableComponent(Create.ID + "." + key, args); } - public static void sendStatus(PlayerEntity player, String key, Object... args) { + public static void sendStatus(Player player, String key, Object... args) { player.displayClientMessage(createTranslationTextComponent(key, args), true); } - public static List translatedOptions(String prefix, String... keys) { - List result = new ArrayList<>(keys.length); + public static List translatedOptions(String prefix, String... keys) { + List result = new ArrayList<>(keys.length); for (String key : keys) result.add(translate(prefix + "." + key)); diff --git a/src/main/java/com/simibubi/create/foundation/utility/ModelSwapper.java b/src/main/java/com/simibubi/create/foundation/utility/ModelSwapper.java index df5244978..57c81594f 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ModelSwapper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ModelSwapper.java @@ -10,12 +10,12 @@ import com.simibubi.create.foundation.item.render.CustomItemModels; import com.simibubi.create.foundation.item.render.CustomRenderedItemModel; import com.simibubi.create.foundation.item.render.CustomRenderedItems; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.BlockModelShapes; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.client.renderer.block.BlockModelShaper; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; @@ -46,7 +46,7 @@ public class ModelSwapper { } public void onModelBake(ModelBakeEvent event) { - Map modelRegistry = event.getModelRegistry(); + Map modelRegistry = event.getModelRegistry(); customBlockModels.forEach((block, modelFunc) -> swapModels(modelRegistry, getAllBlockStateModelLocations(block), modelFunc)); customItemModels.forEach((item, modelFunc) -> swapModels(modelRegistry, getItemModelLocation(item), modelFunc)); @@ -64,15 +64,15 @@ public class ModelSwapper { modEventBus.addListener(this::onModelBake); } - public static void swapModels(Map modelRegistry, - List locations, Function factory) { + public static void swapModels(Map modelRegistry, + List locations, Function factory) { locations.forEach(location -> { swapModels(modelRegistry, location, factory); }); } - public static void swapModels(Map modelRegistry, - ModelResourceLocation location, Function factory) { + public static void swapModels(Map modelRegistry, + ModelResourceLocation location, Function factory) { modelRegistry.put(location, factory.apply(modelRegistry.get(location))); } @@ -82,7 +82,7 @@ public class ModelSwapper { block.getStateDefinition() .getPossibleStates() .forEach(state -> { - models.add(BlockModelShapes.stateToModelLocation(blockRl, state)); + models.add(BlockModelShaper.stateToModelLocation(blockRl, state)); }); return models; } 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 1c877414e..d696b627a 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/NBTHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/NBTHelper.java @@ -7,21 +7,21 @@ import java.util.function.Function; import javax.annotation.Nonnull; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.FloatNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.FloatTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.phys.AABB; import net.minecraftforge.common.util.Constants.NBT; public class NBTHelper { - public static void putMarker(CompoundNBT nbt, String marker) { + public static void putMarker(CompoundTag nbt, String marker) { nbt.putBoolean(marker, true); } - public static > T readEnum(CompoundNBT nbt, String key, Class enumClass) { + public static > T readEnum(CompoundTag nbt, String key, Class enumClass) { T[] enumConstants = enumClass.getEnumConstants(); if (enumConstants == null) throw new IllegalArgumentException("Non-Enum class passed to readEnum: " + enumClass.getName()); @@ -36,59 +36,59 @@ public class NBTHelper { return enumConstants[0]; } - public static > void writeEnum(CompoundNBT nbt, String key, T enumConstant) { + public static > void writeEnum(CompoundTag nbt, String key, T enumConstant) { nbt.putString(key, enumConstant.name()); } - public static ListNBT writeCompoundList(Iterable list, Function serializer) { - ListNBT listNBT = new ListNBT(); + public static ListTag writeCompoundList(Iterable list, Function serializer) { + ListTag listNBT = new ListTag(); list.forEach(t -> listNBT.add(serializer.apply(t))); return listNBT; } - public static List readCompoundList(ListNBT listNBT, Function deserializer) { + public static List readCompoundList(ListTag listNBT, Function deserializer) { List list = new ArrayList<>(listNBT.size()); - listNBT.forEach(inbt -> list.add(deserializer.apply((CompoundNBT) inbt))); + listNBT.forEach(inbt -> list.add(deserializer.apply((CompoundTag) inbt))); return list; } - public static void iterateCompoundList(ListNBT listNBT, Consumer consumer) { - listNBT.forEach(inbt -> consumer.accept((CompoundNBT) inbt)); + public static void iterateCompoundList(ListTag listNBT, Consumer consumer) { + listNBT.forEach(inbt -> consumer.accept((CompoundTag) inbt)); } - public static ListNBT writeItemList(Iterable stacks) { + public static ListTag writeItemList(Iterable stacks) { return writeCompoundList(stacks, ItemStack::serializeNBT); } - public static List readItemList(ListNBT stacks) { + public static List readItemList(ListTag stacks) { return readCompoundList(stacks, ItemStack::of); } - public static ListNBT writeAABB(AxisAlignedBB bb) { - ListNBT bbtag = new ListNBT(); - 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)); + public static ListTag writeAABB(AABB bb) { + ListTag bbtag = new ListTag(); + bbtag.add(FloatTag.valueOf((float) bb.minX)); + bbtag.add(FloatTag.valueOf((float) bb.minY)); + bbtag.add(FloatTag.valueOf((float) bb.minZ)); + bbtag.add(FloatTag.valueOf((float) bb.maxX)); + bbtag.add(FloatTag.valueOf((float) bb.maxY)); + bbtag.add(FloatTag.valueOf((float) bb.maxZ)); return bbtag; } - public static AxisAlignedBB readAABB(ListNBT bbtag) { + public static AABB readAABB(ListTag bbtag) { if (bbtag == null || bbtag.isEmpty()) return null; - return new AxisAlignedBB(bbtag.getFloat(0), bbtag.getFloat(1), bbtag.getFloat(2), bbtag.getFloat(3), + return new AABB(bbtag.getFloat(0), bbtag.getFloat(1), bbtag.getFloat(2), bbtag.getFloat(3), bbtag.getFloat(4), bbtag.getFloat(5)); } @Nonnull - public static INBT getINBT(CompoundNBT nbt, String id) { - INBT inbt = nbt.get(id); + public static Tag getINBT(CompoundTag nbt, String id) { + Tag inbt = nbt.get(id); if (inbt != null) return inbt; - return new CompoundNBT(); + return new CompoundTag(); } } 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 8c1cc871a..403a1fb29 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java +++ b/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java @@ -9,51 +9,51 @@ import javax.annotation.Nullable; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.logistics.item.filter.FilterItem; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.tileentity.MobSpawnerTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.level.block.entity.SpawnerBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.network.chat.Component; import net.minecraftforge.common.util.Constants; public final class NBTProcessors { - private static final Map, UnaryOperator> processors = new HashMap<>(); - private static final Map, UnaryOperator> survivalProcessors = new HashMap<>(); + private static final Map, UnaryOperator> processors = new HashMap<>(); + private static final Map, UnaryOperator> survivalProcessors = new HashMap<>(); - public static synchronized void addProcessor(TileEntityType type, UnaryOperator processor) { + public static synchronized void addProcessor(BlockEntityType type, UnaryOperator processor) { processors.put(type, processor); } - public static synchronized void addSurvivalProcessor(TileEntityType type, UnaryOperator processor) { + public static synchronized void addSurvivalProcessor(BlockEntityType type, UnaryOperator processor) { survivalProcessors.put(type, processor); } static { - addProcessor(TileEntityType.SIGN, data -> { + addProcessor(BlockEntityType.SIGN, data -> { for (int i = 0; i < 4; ++i) { if (textComponentHasClickEvent(data.getString("Text" + (i + 1)))) return null; } return data; }); - addProcessor(TileEntityType.LECTERN, data -> { + addProcessor(BlockEntityType.LECTERN, data -> { if (!data.contains("Book", Constants.NBT.TAG_COMPOUND)) return data; - CompoundNBT book = data.getCompound("Book"); + CompoundTag book = data.getCompound("Book"); if (!book.contains("tag", Constants.NBT.TAG_COMPOUND)) return data; - CompoundNBT tag = book.getCompound("tag"); + CompoundTag tag = book.getCompound("tag"); if (!tag.contains("pages", Constants.NBT.TAG_LIST)) return data; - ListNBT pages = tag.getList("pages", Constants.NBT.TAG_STRING); + ListTag pages = tag.getList("pages", Constants.NBT.TAG_STRING); - for (INBT inbt : pages) { + for (Tag inbt : pages) { if (textComponentHasClickEvent(inbt.getAsString())) return null; } @@ -70,7 +70,7 @@ public final class NBTProcessors { } public static boolean textComponentHasClickEvent(String json) { - ITextComponent component = ITextComponent.Serializer.fromJson(json.isEmpty() ? "\"\"" : json); + Component component = Component.Serializer.fromJson(json.isEmpty() ? "\"\"" : json); return component != null && component.getStyle() != null && component.getStyle().getClickEvent() != null; } @@ -78,17 +78,17 @@ public final class NBTProcessors { } @Nullable - public static CompoundNBT process(TileEntity tileEntity, CompoundNBT compound, boolean survival) { + public static CompoundTag process(BlockEntity tileEntity, CompoundTag compound, boolean survival) { if (compound == null) return null; - TileEntityType type = tileEntity.getType(); + BlockEntityType type = tileEntity.getType(); if (survival && survivalProcessors.containsKey(type)) compound = survivalProcessors.get(type) .apply(compound); if (compound != null && processors.containsKey(type)) return processors.get(type) .apply(compound); - if (tileEntity instanceof MobSpawnerTileEntity) + if (tileEntity instanceof SpawnerBlockEntity) return compound; if (tileEntity.onlyOpCanSetNbt()) return null; 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 c734ab4e5..e0829811b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Pointing.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Pointing.java @@ -1,11 +1,11 @@ package com.simibubi.create.foundation.utility; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.IStringSerializable; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.util.StringRepresentable; -public enum Pointing implements IStringSerializable { +public enum Pointing implements StringRepresentable { UP(0), LEFT(270), DOWN(180), RIGHT(90); private int xRotation; 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 2b8b6af84..3060330a4 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/RaycastHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/RaycastHelper.java @@ -2,67 +2,67 @@ package com.simibubi.create.foundation.utility; import java.util.function.Predicate; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceContext.BlockMode; -import net.minecraft.util.math.RayTraceContext.FluidMode; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.util.Mth; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.Level; public class RaycastHelper { - public static BlockRayTraceResult rayTraceRange(World worldIn, PlayerEntity playerIn, double range) { - Vector3d origin = getTraceOrigin(playerIn); - Vector3d target = getTraceTarget(playerIn, range, origin); - RayTraceContext context = new RayTraceContext(origin, target, BlockMode.COLLIDER, FluidMode.NONE, playerIn); + public static BlockHitResult rayTraceRange(Level worldIn, Player playerIn, double range) { + Vec3 origin = getTraceOrigin(playerIn); + Vec3 target = getTraceTarget(playerIn, range, origin); + ClipContext context = new ClipContext(origin, target, Block.COLLIDER, Fluid.NONE, playerIn); return worldIn.clip(context); } - public static PredicateTraceResult rayTraceUntil(PlayerEntity playerIn, double range, + public static PredicateTraceResult rayTraceUntil(Player playerIn, double range, Predicate predicate) { - Vector3d origin = getTraceOrigin(playerIn); - Vector3d target = getTraceTarget(playerIn, range, origin); + Vec3 origin = getTraceOrigin(playerIn); + Vec3 target = getTraceTarget(playerIn, range, origin); return rayTraceUntil(origin, target, predicate); } - public static Vector3d getTraceTarget(PlayerEntity playerIn, double range, Vector3d origin) { + public static Vec3 getTraceTarget(Player playerIn, double range, Vec3 origin) { 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); - float f5 = MathHelper.sin(-f * 0.017453292F); + float f2 = Mth.cos(-f1 * 0.017453292F - (float) Math.PI); + float f3 = Mth.sin(-f1 * 0.017453292F - (float) Math.PI); + float f4 = -Mth.cos(-f * 0.017453292F); + float f5 = Mth.sin(-f * 0.017453292F); float f6 = f3 * f4; float f7 = f2 * f4; double d3 = range; - Vector3d Vector3d1 = origin.add((double) f6 * d3, (double) f5 * d3, (double) f7 * d3); + Vec3 Vector3d1 = origin.add((double) f6 * d3, (double) f5 * d3, (double) f7 * d3); return Vector3d1; } - public static Vector3d getTraceOrigin(PlayerEntity playerIn) { + public static Vec3 getTraceOrigin(Player playerIn) { double d0 = playerIn.getX(); double d1 = playerIn.getY() + (double) playerIn.getEyeHeight(); double d2 = playerIn.getZ(); - Vector3d Vector3d = new Vector3d(d0, d1, d2); + Vec3 Vector3d = new Vec3(d0, d1, d2); return Vector3d; } - public static PredicateTraceResult rayTraceUntil(Vector3d start, Vector3d end, Predicate predicate) { + public static PredicateTraceResult rayTraceUntil(Vec3 start, Vec3 end, Predicate predicate) { if (Double.isNaN(start.x) || Double.isNaN(start.y) || Double.isNaN(start.z)) return null; if (Double.isNaN(end.x) || Double.isNaN(end.y) || Double.isNaN(end.z)) return null; - int dx = MathHelper.floor(end.x); - int dy = MathHelper.floor(end.y); - int dz = MathHelper.floor(end.z); - int x = MathHelper.floor(start.x); - int y = MathHelper.floor(start.y); - int z = MathHelper.floor(start.z); + int dx = Mth.floor(end.x); + int dy = Mth.floor(end.y); + int dz = Mth.floor(end.z); + int x = Mth.floor(start.x); + int y = Mth.floor(start.y); + int z = Mth.floor(start.z); BlockPos currentPos = new BlockPos(x, y, z); @@ -146,18 +146,18 @@ public class RaycastHelper { if (d3 < d4 && d3 < d5) { enumfacing = dx > x ? Direction.WEST : Direction.EAST; - start = new Vector3d(d0, start.y + d7 * d3, start.z + d8 * d3); + start = new Vec3(d0, start.y + d7 * d3, start.z + d8 * d3); } else if (d4 < d5) { enumfacing = dy > y ? Direction.DOWN : Direction.UP; - start = new Vector3d(start.x + d6 * d4, d1, start.z + d8 * d4); + start = new Vec3(start.x + d6 * d4, d1, start.z + d8 * d4); } else { enumfacing = dz > z ? Direction.NORTH : Direction.SOUTH; - start = new Vector3d(start.x + d6 * d5, start.y + d7 * d5, d2); + start = new Vec3(start.x + d6 * d5, start.y + d7 * d5, d2); } - x = MathHelper.floor(start.x) - (enumfacing == Direction.EAST ? 1 : 0); - y = MathHelper.floor(start.y) - (enumfacing == Direction.UP ? 1 : 0); - z = MathHelper.floor(start.z) - (enumfacing == Direction.SOUTH ? 1 : 0); + x = Mth.floor(start.x) - (enumfacing == Direction.EAST ? 1 : 0); + y = Mth.floor(start.y) - (enumfacing == Direction.UP ? 1 : 0); + z = Mth.floor(start.z) - (enumfacing == Direction.SOUTH ? 1 : 0); currentPos = new BlockPos(x, y, z); if (predicate.test(currentPos)) diff --git a/src/main/java/com/simibubi/create/foundation/utility/RemapHelper.java b/src/main/java/com/simibubi/create/foundation/utility/RemapHelper.java index 5b471e63b..6517decb7 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/RemapHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/RemapHelper.java @@ -56,10 +56,10 @@ import java.util.Map; import com.simibubi.create.AllBlocks; import com.simibubi.create.Create; -import net.minecraft.block.Block; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.Item; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.RegistryEvent.MissingMappings.Mapping; 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 28038851a..706c96c41 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ServerSpeedProvider.java @@ -8,7 +8,7 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.client.Minecraft; -import net.minecraft.network.PacketBuffer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkEvent.Context; @@ -52,10 +52,10 @@ public class ServerSpeedProvider { public Packet() {} - public Packet(PacketBuffer buffer) {} + public Packet(FriendlyByteBuf buffer) {} @Override - public void write(PacketBuffer buffer) {} + public void write(FriendlyByteBuf buffer) {} @Override public void handle(Supplier context) { 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 70ccfb950..7046662b7 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java +++ b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java @@ -17,24 +17,24 @@ import com.simibubi.create.AllTags; import com.simibubi.create.compat.Mods; import com.simibubi.create.compat.dynamictrees.DynamicTree; -import net.minecraft.block.BambooBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.CactusBlock; -import net.minecraft.block.ChorusFlowerBlock; -import net.minecraft.block.ChorusPlantBlock; -import net.minecraft.block.KelpBlock; -import net.minecraft.block.KelpTopBlock; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.SugarCaneBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.level.block.BambooBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.CactusBlock; +import net.minecraft.world.level.block.ChorusFlowerBlock; +import net.minecraft.world.level.block.ChorusPlantBlock; +import net.minecraft.world.level.block.KelpPlantBlock; +import net.minecraft.world.level.block.KelpBlock; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.SugarCaneBlock; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.tags.BlockTags; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; public class TreeCutter { public static final Tree NO_TREE = new Tree(Collections.emptyList(), Collections.emptyList()); @@ -58,7 +58,7 @@ public class TreeCutter { * @return null if not found or not fully cut */ @Nonnull - public static Tree findTree(@Nullable IBlockReader reader, BlockPos pos) { + public static Tree findTree(@Nullable BlockGetter reader, BlockPos pos) { if (reader == null) return NO_TREE; @@ -172,9 +172,9 @@ public class TreeCutter { return true; if (block instanceof SugarCaneBlock) return true; - if (block instanceof KelpBlock) + if (block instanceof KelpPlantBlock) return true; - return block instanceof KelpTopBlock; + return block instanceof KelpBlock; } /** @@ -185,7 +185,7 @@ public class TreeCutter { * @param pos * @return */ - private static boolean validateCut(IBlockReader reader, BlockPos pos) { + private static boolean validateCut(BlockGetter reader, BlockPos pos) { Set visited = new HashSet<>(); List frontier = new LinkedList<>(); frontier.add(pos); @@ -246,7 +246,7 @@ public class TreeCutter { } @Override - public void destroyBlocks(World world, ItemStack toDamage, @Nullable PlayerEntity playerEntity, + public void destroyBlocks(Level world, ItemStack toDamage, @Nullable Player playerEntity, BiConsumer drop) { logs.forEach(makeCallbackFor(world, 1 / 2f, toDamage, playerEntity, drop)); leaves.forEach(makeCallbackFor(world, 1 / 8f, toDamage, playerEntity, drop)); 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 7d273f44e..24a2f974e 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java @@ -5,70 +5,70 @@ import java.util.Random; import javax.annotation.Nullable; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.DoubleNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Mirror; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Quaternion; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.math.vector.Vector3i; +import net.minecraft.client.Camera; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.nbt.DoubleTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import com.mojang.math.Quaternion; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; +import net.minecraft.core.Vec3i; public class VecHelper { public static final Vector3f ZERO_3F = new Vector3f(0, 0, 0); - public static final Vector3d CENTER_OF_ORIGIN = new Vector3d(.5, .5, .5); + public static final Vec3 CENTER_OF_ORIGIN = new Vec3(.5, .5, .5); - public static Vector3d rotate(Vector3d vec, Vector3d rotationVec) { + public static Vec3 rotate(Vec3 vec, Vec3 rotationVec) { return rotate(vec, rotationVec.x, rotationVec.y, rotationVec.z); } - public static Vector3d rotate(Vector3d vec, double xRot, double yRot, double zRot) { + public static Vec3 rotate(Vec3 vec, double xRot, double yRot, double zRot) { return rotate(rotate(rotate(vec, xRot, Axis.X), yRot, Axis.Y), zRot, Axis.Z); } - public static Vector3d rotateCentered(Vector3d vec, double deg, Axis axis) { - Vector3d shift = getCenterOf(BlockPos.ZERO); + public static Vec3 rotateCentered(Vec3 vec, double deg, Axis axis) { + Vec3 shift = getCenterOf(BlockPos.ZERO); return VecHelper.rotate(vec.subtract(shift), deg, axis).add(shift); } - public static Vector3d rotate(Vector3d vec, double deg, Axis axis) { + public static Vec3 rotate(Vec3 vec, double deg, Axis axis) { if (deg == 0) return vec; - if (vec == Vector3d.ZERO) + if (vec == Vec3.ZERO) return vec; float angle = (float) (deg / 180f * Math.PI); - double sin = MathHelper.sin(angle); - double cos = MathHelper.cos(angle); + double sin = Mth.sin(angle); + double cos = Mth.cos(angle); double x = vec.x; double y = vec.y; double z = vec.z; if (axis == Axis.X) - return new Vector3d(x, y * cos - z * sin, z * cos + y * sin); + return new Vec3(x, y * cos - z * sin, z * cos + y * sin); if (axis == Axis.Y) - return new Vector3d(x * cos + z * sin, y, z * cos - x * sin); + return new Vec3(x * cos + z * sin, y, z * cos - x * sin); if (axis == Axis.Z) - return new Vector3d(x * cos - y * sin, y * cos + x * sin, z); + return new Vec3(x * cos - y * sin, y * cos + x * sin, z); return vec; } - public static Vector3d mirrorCentered(Vector3d vec, Mirror mirror) { - Vector3d shift = getCenterOf(BlockPos.ZERO); + public static Vec3 mirrorCentered(Vec3 vec, Mirror mirror) { + Vec3 shift = getCenterOf(BlockPos.ZERO); return VecHelper.mirror(vec.subtract(shift), mirror).add(shift); } - public static Vector3d mirror(Vector3d vec, Mirror mirror) { + public static Vec3 mirror(Vec3 vec, Mirror mirror) { if (mirror == null || mirror == Mirror.NONE) return vec; - if (vec == Vector3d.ZERO) + if (vec == Vec3.ZERO) return vec; double x = vec.x; @@ -76,75 +76,75 @@ public class VecHelper { double z = vec.z; if (mirror == Mirror.LEFT_RIGHT) - return new Vector3d(x, y, -z); + return new Vec3(x, y, -z); if (mirror == Mirror.FRONT_BACK) - return new Vector3d(-x, y, z); + return new Vec3(-x, y, z); return vec; } - public static Vector3d lookAt(Vector3d vec, Vector3d fwd) { + public static Vec3 lookAt(Vec3 vec, Vec3 fwd) { fwd = fwd.normalize(); - Vector3d up = new Vector3d(0,1,0); + Vec3 up = new Vec3(0,1,0); 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.cross(up).normalize(); + up = new Vec3(0, 0, dot > 0 ? 1 : -1); + Vec3 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; - return new Vector3d(x, y, z); + return new Vec3(x, y, z); } - public static boolean isVecPointingTowards(Vector3d vec, Direction direction) { - return Vector3d.atLowerCornerOf(direction.getNormal()) + public static boolean isVecPointingTowards(Vec3 vec, Direction direction) { + return Vec3.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.ZERO)) + public static Vec3 getCenterOf(Vec3i pos) { + if (pos.equals(Vec3i.ZERO)) return CENTER_OF_ORIGIN; - return Vector3d.atLowerCornerOf(pos) + return Vec3.atLowerCornerOf(pos) .add(.5f, .5f, .5f); } - public static Vector3d offsetRandomly(Vector3d vec, Random r, float radius) { - return new Vector3d(vec.x + (r.nextFloat() - .5f) * 2 * radius, vec.y + (r.nextFloat() - .5f) * 2 * radius, + public static Vec3 offsetRandomly(Vec3 vec, Random r, float radius) { + return new Vec3(vec.x + (r.nextFloat() - .5f) * 2 * radius, vec.y + (r.nextFloat() - .5f) * 2 * radius, vec.z + (r.nextFloat() - .5f) * 2 * radius); } - public static Vector3d axisAlingedPlaneOf(Vector3d vec) { + public static Vec3 axisAlingedPlaneOf(Vec3 vec) { vec = vec.normalize(); - return new Vector3d(1, 1, 1).subtract(Math.abs(vec.x), Math.abs(vec.y), Math.abs(vec.z)); + return new Vec3(1, 1, 1).subtract(Math.abs(vec.x), Math.abs(vec.y), Math.abs(vec.z)); } - public static Vector3d axisAlingedPlaneOf(Direction face) { - return axisAlingedPlaneOf(Vector3d.atLowerCornerOf(face.getNormal())); + public static Vec3 axisAlingedPlaneOf(Direction face) { + return axisAlingedPlaneOf(Vec3.atLowerCornerOf(face.getNormal())); } - public static ListNBT writeNBT(Vector3d vec) { - ListNBT listnbt = new ListNBT(); - listnbt.add(DoubleNBT.valueOf(vec.x)); - listnbt.add(DoubleNBT.valueOf(vec.y)); - listnbt.add(DoubleNBT.valueOf(vec.z)); + public static ListTag writeNBT(Vec3 vec) { + ListTag listnbt = new ListTag(); + listnbt.add(DoubleTag.valueOf(vec.x)); + listnbt.add(DoubleTag.valueOf(vec.y)); + listnbt.add(DoubleTag.valueOf(vec.z)); return listnbt; } - public static Vector3d readNBT(ListNBT list) { + public static Vec3 readNBT(ListTag list) { if (list.isEmpty()) - return Vector3d.ZERO; - return new Vector3d(list.getDouble(0), list.getDouble(1), list.getDouble(2)); + return Vec3.ZERO; + return new Vec3(list.getDouble(0), list.getDouble(1), list.getDouble(2)); } - public static Vector3d voxelSpace(double x, double y, double z) { - return new Vector3d(x, y, z).scale(1 / 16f); + public static Vec3 voxelSpace(double x, double y, double z) { + return new Vec3(x, y, z).scale(1 / 16f); } - public static int getCoordinate(Vector3i pos, Axis axis) { + public static int getCoordinate(Vec3i pos, Axis axis) { return axis.choose(pos.getX(), pos.getY(), pos.getZ()); } - public static float getCoordinate(Vector3d vec, Axis axis) { + public static float getCoordinate(Vec3 vec, Axis axis) { return (float) axis.choose(vec.x, vec.y, vec.z); } @@ -158,52 +158,52 @@ public class VecHelper { return true; } - public static Vector3d clamp(Vector3d vec, float maxLength) { + public static Vec3 clamp(Vec3 vec, float maxLength) { return vec.length() > maxLength ? vec.normalize() .scale(maxLength) : vec; } - public static Vector3d lerp(float p, Vector3d from, Vector3d to) { + public static Vec3 lerp(float p, Vec3 from, Vec3 to) { return from.add(to.subtract(from) .scale(p)); } - public static Vector3d clampComponentWise(Vector3d vec, float maxLength) { - return new Vector3d(MathHelper.clamp(vec.x, -maxLength, maxLength), - MathHelper.clamp(vec.y, -maxLength, maxLength), MathHelper.clamp(vec.z, -maxLength, maxLength)); + public static Vec3 clampComponentWise(Vec3 vec, float maxLength) { + return new Vec3(Mth.clamp(vec.x, -maxLength, maxLength), + Mth.clamp(vec.y, -maxLength, maxLength), Mth.clamp(vec.z, -maxLength, maxLength)); } - public static Vector3d project(Vector3d vec, Vector3d ontoVec) { - if (ontoVec.equals(Vector3d.ZERO)) - return Vector3d.ZERO; + public static Vec3 project(Vec3 vec, Vec3 ontoVec) { + if (ontoVec.equals(Vec3.ZERO)) + return Vec3.ZERO; return ontoVec.scale(vec.dot(ontoVec) / ontoVec.lengthSqr()); } @Nullable - public static Vector3d intersectSphere(Vector3d origin, Vector3d lineDirection, Vector3d sphereCenter, + public static Vec3 intersectSphere(Vec3 origin, Vec3 lineDirection, Vec3 sphereCenter, double radius) { - if (lineDirection.equals(Vector3d.ZERO)) + if (lineDirection.equals(Vec3.ZERO)) return null; if (lineDirection.length() != 1) lineDirection = lineDirection.normalize(); - Vector3d diff = origin.subtract(sphereCenter); + Vec3 diff = origin.subtract(sphereCenter); double lineDotDiff = lineDirection.dot(diff); double delta = lineDotDiff * lineDotDiff - (diff.lengthSqr() - radius * radius); if (delta < 0) return null; - double t = -lineDotDiff + MathHelper.sqrt(delta); + double t = -lineDotDiff + Mth.sqrt(delta); return origin.add(lineDirection.scale(t)); } // https://forums.minecraftforge.net/topic/88562-116solved-3d-to-2d-conversion/?do=findComment&comment=413573 slightly modified - public static Vector3d projectToPlayerView(Vector3d target, float partialTicks) { + public static Vec3 projectToPlayerView(Vec3 target, float partialTicks) { /* * 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.getMainCamera(); - Vector3d camera_pos = ari.getPosition(); + Camera ari = Minecraft.getInstance().gameRenderer.getMainCamera(); + Vec3 camera_pos = ari.getPosition(); Quaternion camera_rotation_conj = ari.rotation() .copy(); camera_rotation_conj.conj(); @@ -217,25 +217,25 @@ public class VecHelper { Minecraft mc = Minecraft.getInstance(); if (mc.options.bobView) { Entity renderViewEntity = mc.getCameraEntity(); - if (renderViewEntity instanceof PlayerEntity) { - PlayerEntity playerentity = (PlayerEntity) renderViewEntity; + if (renderViewEntity instanceof Player) { + Player playerentity = (Player) renderViewEntity; float distwalked_modified = playerentity.walkDist; float f = distwalked_modified - playerentity.walkDistO; float f1 = -(distwalked_modified + f * partialTicks); - float f2 = MathHelper.lerp(partialTicks, playerentity.oBob, playerentity.bob); + float f2 = Mth.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); + Math.abs(Mth.cos(f1 * (float) Math.PI - 0.2F) * f2) * 5.0F, true); q2.conj(); result3f.transform(q2); Quaternion q1 = - new Quaternion(Vector3f.ZP, MathHelper.sin(f1 * (float) Math.PI) * f2 * 3.0F, true); + new Quaternion(Vector3f.ZP, Mth.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); + Vector3f bob_translation = new Vector3f((Mth.sin(f1 * (float) Math.PI) * f2 * 0.5F), + (-Math.abs(Mth.cos(f1 * (float) Math.PI) * f2)), 0.0f); bob_translation.setY(-bob_translation.y()); // this is weird but hey, if it works result3f.add(bob_translation); } @@ -247,7 +247,7 @@ public class VecHelper { float half_height = (float) mc.getWindow() .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()); + return new Vec3(-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 7b9b35e71..8ce2f7b4d 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/VoxelShaper.java @@ -7,13 +7,13 @@ import java.util.function.Function; import org.apache.commons.lang3.mutable.MutableObject; -import net.minecraft.block.Block; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.Block; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.Vec3; public class VoxelShaper { @@ -47,7 +47,7 @@ public class VoxelShaper { public VoxelShaper withVerticalShapes(VoxelShape upShape) { shapes.put(Direction.UP, upShape); - shapes.put(Direction.DOWN, rotatedCopy(upShape, new Vector3d(180, 0, 0))); + shapes.put(Direction.DOWN, rotatedCopy(upShape, new Vec3(180, 0, 0))); return this; } @@ -65,7 +65,7 @@ public class VoxelShaper { } protected static VoxelShaper forDirectionsWithRotation(VoxelShape shape, Direction facing, - Iterable directions, Function rotationValues) { + Iterable directions, Function rotationValues) { VoxelShaper voxelShaper = new VoxelShaper(); for (Direction dir : directions) { voxelShaper.shapes.put(dir, rotate(shape, facing, dir, rotationValues)); @@ -74,7 +74,7 @@ public class VoxelShaper { } protected static VoxelShape rotate(VoxelShape shape, Direction from, Direction to, - Function usingValues) { + Function usingValues) { if (from == to) return shape; @@ -83,17 +83,17 @@ public class VoxelShaper { .add(usingValues.apply(to))); } - protected static VoxelShape rotatedCopy(VoxelShape shape, Vector3d rotation) { - if (rotation.equals(Vector3d.ZERO)) + protected static VoxelShape rotatedCopy(VoxelShape shape, Vec3 rotation) { + if (rotation.equals(Vec3.ZERO)) return shape; - MutableObject result = new MutableObject<>(VoxelShapes.empty()); - Vector3d center = new Vector3d(8, 8, 8); + MutableObject result = new MutableObject<>(Shapes.empty()); + Vec3 center = new Vec3(8, 8, 8); shape.forAllBoxes((x1, y1, z1, x2, y2, z2) -> { - Vector3d v1 = new Vector3d(x1, y1, z1).scale(16) + Vec3 v1 = new Vec3(x1, y1, z1).scale(16) .subtract(center); - Vector3d v2 = new Vector3d(x2, y2, z2).scale(16) + Vec3 v2 = new Vec3(x2, y2, z2).scale(16) .subtract(center); v1 = VecHelper.rotate(v1, (float) rotation.x, Axis.X); @@ -107,25 +107,25 @@ public class VoxelShaper { .add(center); VoxelShape rotated = Block.box(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z); - result.setValue(VoxelShapes.or(result.getValue(), rotated)); + result.setValue(Shapes.or(result.getValue(), rotated)); }); return result.getValue(); } - protected static class DefaultRotationValues implements Function { + protected static class DefaultRotationValues implements Function { // assume facing up as the default rotation @Override - public Vector3d apply(Direction direction) { - return new Vector3d(direction == Direction.UP ? 0 : (Direction.Plane.VERTICAL.test(direction) ? 180 : 90), + public Vec3 apply(Direction direction) { + return new Vec3(direction == Direction.UP ? 0 : (Direction.Plane.VERTICAL.test(direction) ? 180 : 90), -horizontalAngleFromDirection(direction), 0); } } - protected static class HorizontalRotationValues implements Function { + protected static class HorizontalRotationValues implements Function { @Override - public Vector3d apply(Direction direction) { - return new Vector3d(0, -horizontalAngleFromDirection(direction), 0); + public Vec3 apply(Direction direction) { + return new Vec3(0, -horizontalAngleFromDirection(direction), 0); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/WorldAttached.java b/src/main/java/com/simibubi/create/foundation/utility/WorldAttached.java index 20555bdb3..4986354f5 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/WorldAttached.java +++ b/src/main/java/com/simibubi/create/foundation/utility/WorldAttached.java @@ -7,27 +7,27 @@ import java.util.Map; import javax.annotation.Nonnull; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.LevelAccessor; import net.minecraftforge.common.util.NonNullFunction; public class WorldAttached { - static List> allMaps = new ArrayList<>(); - Map attached; - private final NonNullFunction factory; + static List> allMaps = new ArrayList<>(); + Map attached; + private final NonNullFunction factory; - public WorldAttached(NonNullFunction factory) { + public WorldAttached(NonNullFunction factory) { this.factory = factory; attached = new HashMap<>(); allMaps.add(attached); } - public static void invalidateWorld(IWorld world) { + public static void invalidateWorld(LevelAccessor world) { allMaps.forEach(m -> m.remove(world)); } @Nonnull - public T get(IWorld world) { + public T get(LevelAccessor world) { T t = attached.get(world); if (t != null) return t; @@ -36,7 +36,7 @@ public class WorldAttached { return entry; } - public void put(IWorld world, T entry) { + public void put(LevelAccessor world, T entry) { attached.put(world, entry); } 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 2f256a42b..e627df235 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/WorldHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/WorldHelper.java @@ -1,11 +1,11 @@ package com.simibubi.create.foundation.utility; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.IWorld; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; +import net.minecraft.world.level.LevelAccessor; public class WorldHelper { - public static ResourceLocation getDimensionID(IWorld world) { + public static ResourceLocation getDimensionID(LevelAccessor world) { 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 bd15f8dcc..6c703caa3 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 @@ -2,8 +2,8 @@ package com.simibubi.create.foundation.utility.animation; import com.simibubi.create.foundation.utility.AngleHelper; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.MathHelper; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; // Can replace all Interpolated value classes // InterpolatedChasingValue, InterpolatedValue, InterpolatedChasingAngle, InterpolatedAngle @@ -26,7 +26,7 @@ public class LerpedFloat { } public static LerpedFloat linear() { - return new LerpedFloat((p, c, t) -> (float) MathHelper.lerp(p, c, t)); + return new LerpedFloat((p, c, t) -> (float) Mth.lerp(p, c, t)); } public static LerpedFloat angular() { @@ -55,14 +55,14 @@ public class LerpedFloat { public boolean updateChaseSpeed(double speed) { float prevSpeed = this.chaseSpeed; this.chaseSpeed = (float) speed; - return !MathHelper.equal(prevSpeed, speed); + return !Mth.equal(prevSpeed, speed); } public void tickChaser() { previousValue = value; if (chaseFunction == null) return; - if (MathHelper.equal((double) value, chaseTarget)) { + if (Mth.equal((double) value, chaseTarget)) { value = chaseTarget; return; } @@ -79,11 +79,11 @@ public class LerpedFloat { } public float getValue(float partialTicks) { - return MathHelper.lerp(partialTicks, previousValue, value); + return Mth.lerp(partialTicks, previousValue, value); } public boolean settled() { - return MathHelper.equal((double) previousValue, value); + return Mth.equal((double) previousValue, value); } public float getChaseTarget() { @@ -94,8 +94,8 @@ public class LerpedFloat { forcedSync = true; } - public CompoundNBT writeNBT() { - CompoundNBT compoundNBT = new CompoundNBT(); + public CompoundTag writeNBT() { + CompoundTag compoundNBT = new CompoundTag(); compoundNBT.putFloat("Speed", chaseSpeed); compoundNBT.putFloat("Target", chaseTarget); compoundNBT.putFloat("Value", value); @@ -105,13 +105,13 @@ public class LerpedFloat { return compoundNBT; } - public void readNBT(CompoundNBT compoundNBT, boolean clientPacket) { + public void readNBT(CompoundTag compoundNBT, boolean clientPacket) { if (!clientPacket || compoundNBT.contains("Force")) startWithValue(compoundNBT.getFloat("Value")); readChaser(compoundNBT); } - private void readChaser(CompoundNBT compoundNBT) { + private void readChaser(CompoundTag compoundNBT) { chaseSpeed = compoundNBT.getFloat("Speed"); chaseTarget = compoundNBT.getFloat("Target"); } @@ -126,10 +126,10 @@ public class LerpedFloat { public static final Chaser IDLE = (c, s, t) -> (float) c; public static final Chaser EXP = exp(Double.MAX_VALUE); - public static final Chaser LINEAR = (c, s, t) -> (float) (c + MathHelper.clamp(t - c, -s, s)); + public static final Chaser LINEAR = (c, s, t) -> (float) (c + Mth.clamp(t - c, -s, s)); public static Chaser exp(double maxEffectiveSpeed) { - return (c, s, t) -> (float) (c + MathHelper.clamp((t - c) * s, -maxEffectiveSpeed, maxEffectiveSpeed)); + return (c, s, t) -> (float) (c + Mth.clamp((t - c) * s, -maxEffectiveSpeed, maxEffectiveSpeed)); } float chase(double current, double speed, double target); diff --git a/src/main/java/com/simibubi/create/foundation/utility/animation/PhysicalFloat.java b/src/main/java/com/simibubi/create/foundation/utility/animation/PhysicalFloat.java index 26ae9a246..ca2e61afc 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/animation/PhysicalFloat.java +++ b/src/main/java/com/simibubi/create/foundation/utility/animation/PhysicalFloat.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.utility.animation; import java.util.ArrayList; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; public class PhysicalFloat { @@ -60,7 +60,7 @@ public class PhysicalFloat { forces.removeIf(Force::finished); if (Float.isFinite(limit)) { - speed = MathHelper.clamp(speed, -limit, limit); + speed = Mth.clamp(speed, -limit, limit); } value += speed; @@ -84,7 +84,7 @@ public class PhysicalFloat { } public float getValue(float partialTicks) { - return MathHelper.lerp(partialTicks, previousValue, value); + return Mth.lerp(partialTicks, previousValue, value); } } 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 01c6ddc6c..d443387a9 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 @@ -2,9 +2,9 @@ package com.simibubi.create.foundation.utility.ghost; import java.util.function.Supplier; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; public class GhostBlockParams { 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 f55febbb2..1f2a08de8 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 @@ -11,28 +11,28 @@ import javax.annotation.Nullable; import org.lwjgl.system.MemoryStack; import com.jozufozu.flywheel.util.VirtualEmptyModelData; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.placement.PlacementHelpers; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.util.math.vector.Vector4f; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import com.mojang.math.Matrix4f; +import com.mojang.math.Vector3f; +import net.minecraft.core.Vec3i; +import com.mojang.math.Vector4f; public abstract class GhostBlockRenderer { @@ -48,20 +48,20 @@ public abstract class GhostBlockRenderer { return standard; } - public abstract void render(MatrixStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params); + public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params); private static class DefaultGhostBlockRenderer extends GhostBlockRenderer { - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { + public void render(PoseStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { ms.pushPose(); - BlockRendererDispatcher dispatcher = Minecraft.getInstance() + BlockRenderDispatcher dispatcher = Minecraft.getInstance() .getBlockRenderer(); - IBakedModel model = dispatcher.getBlockModel(params.state); + BakedModel model = dispatcher.getBlockModel(params.state); - RenderType layer = RenderTypeLookup.getRenderType(params.state, false); - IVertexBuilder vb = buffer.getEarlyBuffer(layer); + RenderType layer = ItemBlockRenderTypes.getRenderType(params.state, false); + VertexConsumer vb = buffer.getEarlyBuffer(layer); BlockPos pos = params.pos; ms.translate(pos.getX(), pos.getY(), pos.getZ()); @@ -77,7 +77,7 @@ public abstract class GhostBlockRenderer { private static class TransparentGhostBlockRenderer extends GhostBlockRenderer { - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { + public void render(PoseStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { // prepare ms.pushPose(); @@ -85,13 +85,13 @@ public abstract class GhostBlockRenderer { // RenderSystem.pushMatrix(); Minecraft mc = Minecraft.getInstance(); - BlockRendererDispatcher dispatcher = mc.getBlockRenderer(); + BlockRenderDispatcher dispatcher = mc.getBlockRenderer(); - IBakedModel model = dispatcher.getBlockModel(params.state); + BakedModel model = dispatcher.getBlockModel(params.state); // RenderType layer = RenderTypeLookup.getEntityBlockLayer(params.state); RenderType layer = RenderType.translucent(); - IVertexBuilder vb = buffer.getEarlyBuffer(layer); + VertexConsumer vb = buffer.getEarlyBuffer(layer); BlockPos pos = params.pos; ms.translate(pos.getX(), pos.getY(), pos.getZ()); @@ -102,7 +102,7 @@ public abstract class GhostBlockRenderer { // dispatcher.getBlockModelRenderer().renderModel(ms.peek(), vb, params.state, model, 1f, 1f, 1f, 0xF000F0, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); renderModel(params, ms.last(), vb, params.state, model, 1f, 1f, 1f, - WorldRenderer.getLightColor(mc.level, pos), OverlayTexture.NO_OVERLAY, + LevelRenderer.getLightColor(mc.level, pos), OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); // buffer.draw(); @@ -113,8 +113,8 @@ public abstract class GhostBlockRenderer { } // BlockModelRenderer - public void renderModel(GhostBlockParams params, MatrixStack.Entry entry, IVertexBuilder vb, - @Nullable BlockState state, IBakedModel model, float p_228804_5_, float p_228804_6_, float p_228804_7_, + public void renderModel(GhostBlockParams params, PoseStack.Pose entry, VertexConsumer vb, + @Nullable BlockState state, BakedModel model, float p_228804_5_, float p_228804_6_, float p_228804_7_, int p_228804_8_, int p_228804_9_, net.minecraftforge.client.model.data.IModelData modelData) { Random random = new Random(); @@ -130,8 +130,8 @@ public abstract class GhostBlockRenderer { } // BlockModelRenderer - private static void renderQuad(GhostBlockParams params, MatrixStack.Entry p_228803_0_, - IVertexBuilder p_228803_1_, float p_228803_2_, float p_228803_3_, float p_228803_4_, + private static void renderQuad(GhostBlockParams params, PoseStack.Pose p_228803_0_, + VertexConsumer p_228803_1_, float p_228803_2_, float p_228803_3_, float p_228803_4_, List p_228803_5_, int p_228803_6_, int p_228803_7_) { Float alpha = params.alphaSupplier.get() * .75f * PlacementHelpers.getCurrentAlpha(); @@ -140,9 +140,9 @@ public abstract class GhostBlockRenderer { float f1; float f2; 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); + f = Mth.clamp(p_228803_2_, 0.0F, 1.0F); + f1 = Mth.clamp(p_228803_3_, 0.0F, 1.0F); + f2 = Mth.clamp(p_228803_4_, 0.0F, 1.0F); } else { f = 1.0F; f1 = 1.0F; @@ -156,20 +156,20 @@ public abstract class GhostBlockRenderer { } // IVertexBuilder - static void quad(float alpha, IVertexBuilder vb, MatrixStack.Entry p_227890_1_, BakedQuad p_227890_2_, + static void quad(float alpha, VertexConsumer vb, PoseStack.Pose 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_.getVertices(); - Vector3i Vector3i = p_227890_2_.getDirection() + Vec3i Vector3i = p_227890_2_.getDirection() .getNormal(); Vector3f vector3f = new Vector3f((float) Vector3i.getX(), (float) Vector3i.getY(), (float) Vector3i.getZ()); Matrix4f matrix4f = p_227890_1_.pose(); vector3f.transform(p_227890_1_.normal()); - int vertexSize = DefaultVertexFormats.BLOCK.getIntegerSize(); + int vertexSize = DefaultVertexFormat.BLOCK.getIntegerSize(); int j = aint.length / vertexSize; try (MemoryStack memorystack = MemoryStack.stackPush()) { - ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getVertexSize()); + ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormat.BLOCK.getVertexSize()); IntBuffer intbuffer = bytebuffer.asIntBuffer(); for (int k = 0; k < j; ++k) { diff --git a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlocks.java b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlocks.java index 240afe3a4..996b51724 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlocks.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlocks.java @@ -3,18 +3,18 @@ package com.simibubi.create.foundation.utility.ghost; import java.util.HashMap; import java.util.Map; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.util.Mth; public class GhostBlocks { public static double getBreathingAlpha() { double period = 2500; double timer = System.currentTimeMillis() % period; - double offset = MathHelper.cos((float) ((2d/period) * Math.PI * timer)); + double offset = Mth.cos((float) ((2d/period) * Math.PI * timer)); return 0.55d - 0.2d * offset; } @@ -54,7 +54,7 @@ public class GhostBlocks { ghosts.entrySet().removeIf(e -> !e.getValue().isAlive()); } - public void renderAll(MatrixStack ms, SuperRenderTypeBuffer buffer) { + public void renderAll(PoseStack ms, SuperRenderTypeBuffer buffer) { ghosts.forEach((slot, entry) -> { GhostBlockRenderer ghost = entry.ghost; ghost.render(ms, buffer, entry.params); 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 059fbbc2b..12af40349 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 @@ -1,48 +1,48 @@ package com.simibubi.create.foundation.utility.outliner; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; public class AABBOutline extends Outline { - protected AxisAlignedBB bb; + protected AABB bb; - public AABBOutline(AxisAlignedBB bb) { + public AABBOutline(AABB bb) { this.setBounds(bb); } @Override - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, float pt) { + public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { renderBB(ms, buffer, bb); } - public void renderBB(MatrixStack ms, SuperRenderTypeBuffer buffer, AxisAlignedBB bb) { - Vector3d projectedView = Minecraft.getInstance().gameRenderer.getMainCamera() + public void renderBB(PoseStack ms, SuperRenderTypeBuffer buffer, AABB bb) { + Vec3 projectedView = Minecraft.getInstance().gameRenderer.getMainCamera() .getPosition(); boolean noCull = bb.contains(projectedView); bb = bb.inflate(noCull ? -1 / 128d : 1 / 128d); noCull |= params.disableCull; - Vector3d xyz = new Vector3d(bb.minX, bb.minY, bb.minZ); - Vector3d Xyz = new Vector3d(bb.maxX, bb.minY, bb.minZ); - Vector3d xYz = new Vector3d(bb.minX, bb.maxY, bb.minZ); - Vector3d XYz = new Vector3d(bb.maxX, bb.maxY, bb.minZ); - Vector3d xyZ = new Vector3d(bb.minX, bb.minY, bb.maxZ); - Vector3d XyZ = new Vector3d(bb.maxX, bb.minY, bb.maxZ); - Vector3d xYZ = new Vector3d(bb.minX, bb.maxY, bb.maxZ); - Vector3d XYZ = new Vector3d(bb.maxX, bb.maxY, bb.maxZ); + Vec3 xyz = new Vec3(bb.minX, bb.minY, bb.minZ); + Vec3 Xyz = new Vec3(bb.maxX, bb.minY, bb.minZ); + Vec3 xYz = new Vec3(bb.minX, bb.maxY, bb.minZ); + Vec3 XYz = new Vec3(bb.maxX, bb.maxY, bb.minZ); + Vec3 xyZ = new Vec3(bb.minX, bb.minY, bb.maxZ); + Vec3 XyZ = new Vec3(bb.maxX, bb.minY, bb.maxZ); + Vec3 xYZ = new Vec3(bb.minX, bb.maxY, bb.maxZ); + Vec3 XYZ = new Vec3(bb.maxX, bb.maxY, bb.maxZ); - Vector3d start = xyz; + Vec3 start = xyz; renderAACuboidLine(ms, buffer, start, Xyz); renderAACuboidLine(ms, buffer, start, xYz); renderAACuboidLine(ms, buffer, start, xyZ); @@ -71,8 +71,8 @@ public class AABBOutline extends Outline { } - protected void renderFace(MatrixStack ms, SuperRenderTypeBuffer buffer, Direction direction, Vector3d p1, Vector3d p2, - Vector3d p3, Vector3d p4, boolean noCull) { + protected void renderFace(PoseStack ms, SuperRenderTypeBuffer buffer, Direction direction, Vec3 p1, Vec3 p2, + Vec3 p3, Vec3 p4, boolean noCull) { if (!params.faceTexture.isPresent()) return; @@ -83,18 +83,18 @@ public class AABBOutline extends Outline { (direction == params.getHighlightedFace() && params.hightlightedFaceTexture.isPresent()) ? 1 : 0.5f; RenderType translucentType = RenderTypes.getOutlineTranslucent(faceTexture, !noCull); - IVertexBuilder builder = buffer.getLateBuffer(translucentType); + VertexConsumer builder = buffer.getLateBuffer(translucentType); Axis axis = direction.getAxis(); - Vector3d uDiff = p2.subtract(p1); - Vector3d vDiff = p4.subtract(p1); + Vec3 uDiff = p2.subtract(p1); + Vec3 vDiff = p4.subtract(p1); float maxU = (float) Math.abs(axis == Axis.X ? uDiff.z : uDiff.x); float maxV = (float) Math.abs(axis == Axis.Y ? vDiff.z : vDiff.y); putQuadUV(ms, builder, p1, p2, p3, p4, 0, 0, maxU, maxV, Direction.UP); params.alpha = alphaBefore; } - public void setBounds(AxisAlignedBB bb) { + public void setBounds(AABB bb) { this.bb = bb; } 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 9e17f3e39..27a5520cd 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 @@ -6,19 +6,19 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.renderer.RenderType; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; public class BlockClusterOutline extends Outline { @@ -30,11 +30,11 @@ public class BlockClusterOutline extends Outline { } @Override - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, float pt) { + public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { for (MergeEntry edge : cluster.visibleEdges) { - Vector3d start = Vector3d.atLowerCornerOf(edge.pos); + Vec3 start = Vec3.atLowerCornerOf(edge.pos); Direction direction = Direction.get(AxisDirection.POSITIVE, edge.axis); - renderAACuboidLine(ms, buffer, start, Vector3d.atLowerCornerOf(edge.pos.relative(direction))); + renderAACuboidLine(ms, buffer, start, Vec3.atLowerCornerOf(edge.pos.relative(direction))); } for (MergeEntry face : cluster.visibleFaces.keySet()) { @@ -47,18 +47,18 @@ public class BlockClusterOutline extends Outline { } } - protected void renderBlockFace(MatrixStack ms, SuperRenderTypeBuffer buffer, BlockPos pos, Direction face) { + protected void renderBlockFace(PoseStack ms, SuperRenderTypeBuffer buffer, BlockPos pos, Direction face) { Optional faceTexture = params.faceTexture; if (!faceTexture.isPresent()) return; RenderType translucentType = RenderTypes.getOutlineTranslucent(faceTexture.get() .getLocation(), true); - IVertexBuilder builder = buffer.getLateBuffer(translucentType); + VertexConsumer builder = buffer.getLateBuffer(translucentType); - Vector3d center = VecHelper.getCenterOf(pos); - Vector3d offset = Vector3d.atLowerCornerOf(face.getNormal()); - Vector3d plane = VecHelper.axisAlingedPlaneOf(offset); + Vec3 center = VecHelper.getCenterOf(pos); + Vec3 offset = Vec3.atLowerCornerOf(face.getNormal()); + Vec3 plane = VecHelper.axisAlingedPlaneOf(offset); Axis axis = face.getAxis(); offset = offset.scale(1 / 2f + 1 / 64d); @@ -67,13 +67,13 @@ public class BlockClusterOutline extends Outline { int deg = face.getAxisDirection() .getStep() * 90; - Vector3d a1 = plane.add(center); + Vec3 a1 = plane.add(center); plane = VecHelper.rotate(plane, deg, axis); - Vector3d a2 = plane.add(center); + Vec3 a2 = plane.add(center); plane = VecHelper.rotate(plane, deg, axis); - Vector3d a3 = plane.add(center); + Vec3 a3 = plane.add(center); plane = VecHelper.rotate(plane, deg, axis); - Vector3d a4 = plane.add(center); + Vec3 a4 = plane.add(center); putQuad(ms, builder, a1, a2, a3, a4, face); } 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 66d0140fc..28cd3189b 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 @@ -1,23 +1,23 @@ package com.simibubi.create.foundation.utility.outliner; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.phys.AABB; +import net.minecraft.util.Mth; public class ChasingAABBOutline extends AABBOutline { - AxisAlignedBB targetBB; - AxisAlignedBB prevBB; + AABB targetBB; + AABB prevBB; - public ChasingAABBOutline(AxisAlignedBB bb) { + public ChasingAABBOutline(AABB bb) { super(bb); prevBB = bb.inflate(0); targetBB = bb.inflate(0); } - public void target(AxisAlignedBB target) { + public void target(AABB target) { targetBB = target; } @@ -28,15 +28,15 @@ public class ChasingAABBOutline extends AABBOutline { } @Override - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, float pt) { + public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { renderBB(ms, buffer, interpolateBBs(prevBB, bb, pt)); } - private static AxisAlignedBB interpolateBBs(AxisAlignedBB current, AxisAlignedBB target, float pt) { - return new AxisAlignedBB(MathHelper.lerp(pt, current.minX, target.minX), - MathHelper.lerp(pt, current.minY, target.minY), MathHelper.lerp(pt, current.minZ, target.minZ), - MathHelper.lerp(pt, current.maxX, target.maxX), MathHelper.lerp(pt, current.maxY, target.maxY), - MathHelper.lerp(pt, current.maxZ, target.maxZ)); + private static AABB interpolateBBs(AABB current, AABB target, float pt) { + return new AABB(Mth.lerp(pt, current.minX, target.minX), + Mth.lerp(pt, current.minY, target.minY), Mth.lerp(pt, current.minZ, target.minZ), + Mth.lerp(pt, current.maxX, target.maxX), Mth.lerp(pt, current.maxY, target.maxY), + Mth.lerp(pt, current.maxZ, target.maxZ)); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java index 5b16d2b66..b13b9be32 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java @@ -1,24 +1,24 @@ package com.simibubi.create.foundation.utility.outliner; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class LineOutline extends Outline { - protected Vector3d start = Vector3d.ZERO; - protected Vector3d end = Vector3d.ZERO; + protected Vec3 start = Vec3.ZERO; + protected Vec3 end = Vec3.ZERO; - public LineOutline set(Vector3d start, Vector3d end) { + public LineOutline set(Vec3 start, Vec3 end) { this.start = start; this.end = end; return this; } @Override - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, float pt) { + public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { renderCuboidLine(ms, buffer, start, end); } @@ -38,16 +38,16 @@ public class LineOutline extends Outline { } @Override - public LineOutline set(Vector3d start, Vector3d end) { + public LineOutline set(Vec3 start, Vec3 end) { if (!end.equals(this.end)) super.set(start, end); return this; } @Override - public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, float pt) { - float distanceToTarget = 1 - MathHelper.lerp(pt, prevProgress, progress); - Vector3d start = end.add(this.start.subtract(end) + public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { + float distanceToTarget = 1 - Mth.lerp(pt, prevProgress, progress); + Vec3 start = end.add(this.start.subtract(end) .scale(distanceToTarget)); renderCuboidLine(ms, buffer, start, end); } 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 22a8f86bc..f0edac9c8 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 @@ -5,9 +5,9 @@ import java.util.Optional; import javax.annotation.Nullable; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.matrix.MatrixStack.Entry; -import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.PoseStack.Pose; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; @@ -16,11 +16,11 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix3f; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.util.Mth; +import com.mojang.math.Matrix3f; +import net.minecraft.world.phys.Vec3; public abstract class Outline { @@ -31,40 +31,40 @@ public abstract class Outline { params = new OutlineParams(); } - public abstract void render(MatrixStack ms, SuperRenderTypeBuffer buffer, float pt); + public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt); - 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)); + public void renderCuboidLine(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 start, Vec3 end) { + Vec3 diff = end.subtract(start); + float hAngle = AngleHelper.deg(Mth.atan2(diff.x, diff.z)); float hDistance = (float) diff.multiply(1, 0, 1) .length(); - float vAngle = AngleHelper.deg(MathHelper.atan2(hDistance, diff.y)) - 90; + float vAngle = AngleHelper.deg(Mth.atan2(hDistance, diff.y)) - 90; ms.pushPose(); MatrixTransformStack.of(ms) .translate(start) .rotateY(hAngle).rotateX(vAngle); - renderAACuboidLine(ms, buffer, Vector3d.ZERO, new Vector3d(0, 0, diff.length())); + renderAACuboidLine(ms, buffer, Vec3.ZERO, new Vec3(0, 0, diff.length())); ms.popPose(); } - public void renderAACuboidLine(MatrixStack ms, SuperRenderTypeBuffer buffer, Vector3d start, Vector3d end) { + public void renderAACuboidLine(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 start, Vec3 end) { float lineWidth = params.getLineWidth(); if (lineWidth == 0) return; - IVertexBuilder builder = buffer.getBuffer(RenderTypes.getOutlineSolid()); + VertexConsumer builder = buffer.getBuffer(RenderTypes.getOutlineSolid()); - Vector3d diff = end.subtract(start); + Vec3 diff = end.subtract(start); if (diff.x + diff.y + diff.z < 0) { - Vector3d temp = start; + Vec3 temp = start; start = end; end = temp; diff = diff.scale(-1); } - Vector3d extension = diff.normalize() + Vec3 extension = diff.normalize() .scale(lineWidth / 2); - Vector3d plane = VecHelper.axisAlingedPlaneOf(diff); + Vec3 plane = VecHelper.axisAlingedPlaneOf(diff); Direction face = Direction.getNearest(diff.x, diff.y, diff.z); Axis axis = face.getAxis(); @@ -72,17 +72,17 @@ public abstract class Outline { end = end.add(extension); plane = plane.scale(lineWidth / 2); - Vector3d a1 = plane.add(start); - Vector3d b1 = plane.add(end); + Vec3 a1 = plane.add(start); + Vec3 b1 = plane.add(end); plane = VecHelper.rotate(plane, -90, axis); - Vector3d a2 = plane.add(start); - Vector3d b2 = plane.add(end); + Vec3 a2 = plane.add(start); + Vec3 b2 = plane.add(end); plane = VecHelper.rotate(plane, -90, axis); - Vector3d a3 = plane.add(start); - Vector3d b3 = plane.add(end); + Vec3 a3 = plane.add(start); + Vec3 b3 = plane.add(end); plane = VecHelper.rotate(plane, -90, axis); - Vector3d a4 = plane.add(start); - Vector3d b4 = plane.add(end); + Vec3 a4 = plane.add(start); + Vec3 b4 = plane.add(end); if (params.disableNormals) { face = Direction.UP; @@ -97,7 +97,7 @@ 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); + Vec3 vec = a1.subtract(a4); face = Direction.getNearest(vec.x, vec.y, vec.z); putQuad(ms, builder, a1, b1, b2, a2, face); vec = VecHelper.rotate(vec, -90, axis); @@ -111,12 +111,12 @@ public abstract class Outline { putQuad(ms, builder, a4, b4, b1, a1, face); } - public void putQuad(MatrixStack ms, IVertexBuilder builder, Vector3d v1, Vector3d v2, Vector3d v3, Vector3d v4, + public void putQuad(PoseStack ms, VertexConsumer builder, Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, Direction normal) { putQuadUV(ms, builder, v1, v2, v3, v4, 0, 0, 1, 1, normal); } - public void putQuadUV(MatrixStack ms, IVertexBuilder builder, Vector3d v1, Vector3d v2, Vector3d v3, Vector3d v4, float minU, + public void putQuadUV(PoseStack ms, VertexConsumer builder, Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, float minU, float minV, float maxU, float maxV, Direction normal) { putVertex(ms, builder, v1, minU, minV, normal); putVertex(ms, builder, v2, maxU, minV, normal); @@ -124,11 +124,11 @@ public abstract class Outline { putVertex(ms, builder, v4, minU, maxV, normal); } - protected void putVertex(MatrixStack ms, IVertexBuilder builder, Vector3d pos, float u, float v, Direction normal) { + protected void putVertex(PoseStack ms, VertexConsumer builder, Vec3 pos, float u, float v, Direction normal) { int i = 15 << 20 | 15 << 4; int j = i >> 16 & '\uffff'; int k = i & '\uffff'; - Entry peek = ms.last(); + Pose peek = ms.last(); Color rgb = params.rgb; if (transformNormals == null) transformNormals = peek.normal(); diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java index 776663486..852bc235b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java @@ -7,16 +7,16 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox; import com.simibubi.create.foundation.utility.outliner.LineOutline.EndChasingLineOutline; import com.simibubi.create.foundation.utility.outliner.Outline.OutlineParams; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; public class Outliner { @@ -33,7 +33,7 @@ public class Outliner { return box.getParams(); } - public OutlineParams showLine(Object slot, Vector3d start, Vector3d end) { + public OutlineParams showLine(Object slot, Vec3 start, Vec3 end) { if (!outlines.containsKey(slot)) { LineOutline outline = new LineOutline(); outlines.put(slot, new OutlineEntry(outline)); @@ -44,7 +44,7 @@ public class Outliner { return entry.outline.getParams(); } - public OutlineParams endChasingLine(Object slot, Vector3d start, Vector3d end, float chasingProgress) { + public OutlineParams endChasingLine(Object slot, Vec3 start, Vec3 end, float chasingProgress) { if (!outlines.containsKey(slot)) { EndChasingLineOutline outline = new EndChasingLineOutline(); outlines.put(slot, new OutlineEntry(outline)); @@ -56,21 +56,21 @@ public class Outliner { return entry.outline.getParams(); } - public OutlineParams showAABB(Object slot, AxisAlignedBB bb, int ttl) { + public OutlineParams showAABB(Object slot, AABB bb, int ttl) { createAABBOutlineIfMissing(slot, bb); ChasingAABBOutline outline = getAndRefreshAABB(slot, ttl); outline.prevBB = outline.targetBB = outline.bb = bb; return outline.getParams(); } - public OutlineParams showAABB(Object slot, AxisAlignedBB bb) { + public OutlineParams showAABB(Object slot, AABB bb) { createAABBOutlineIfMissing(slot, bb); ChasingAABBOutline outline = getAndRefreshAABB(slot); outline.prevBB = outline.targetBB = outline.bb = bb; return outline.getParams(); } - public OutlineParams chaseAABB(Object slot, AxisAlignedBB bb) { + public OutlineParams chaseAABB(Object slot, AABB bb) { createAABBOutlineIfMissing(slot, bb); ChasingAABBOutline outline = getAndRefreshAABB(slot); outline.targetBB = bb; @@ -105,7 +105,7 @@ public class Outliner { // Utility - private void createAABBOutlineIfMissing(Object slot, AxisAlignedBB bb) { + private void createAABBOutlineIfMissing(Object slot, AABB bb) { if (!outlines.containsKey(slot) || !(outlines.get(slot).outline instanceof AABBOutline)) { ChasingAABBOutline outline = new ChasingAABBOutline(bb); outlines.put(slot, new OutlineEntry(outline)); @@ -145,7 +145,7 @@ public class Outliner { toClear.forEach(outlines::remove); } - public void renderOutlines(MatrixStack ms, SuperRenderTypeBuffer buffer, float pt) { + public void renderOutlines(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { outlines.forEach((key, entry) -> { Outline outline = entry.getOutline(); outline.params.alpha = 1; @@ -155,7 +155,7 @@ public class Outliner { float fadeticks = OutlineEntry.fadeTicks; float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks); float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks); - float alpha = MathHelper.lerp(pt, lastAlpha, currentAlpha); + float alpha = Mth.lerp(pt, lastAlpha, currentAlpha); outline.params.alpha = alpha * alpha * alpha; if (outline.params.alpha < 1 / 8f) 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 63ec2aace..51e96c8c7 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 @@ -13,17 +13,17 @@ import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; @MethodsReturnNonnullByDefault public interface IPlacementHelper { @@ -58,10 +58,10 @@ public interface IPlacementHelper { * Use {@link PlacementOffset#success(Vector3i)} with the new BlockPos to indicate a success * and call {@link PlacementOffset#withTransform(Function)} if the blocks default state has to be modified before it is placed */ - PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray); + PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray); //sets the offset's ghost state with the default state of the held block item, this is used in PlacementHelpers and can be ignored in most cases - default PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray, ItemStack heldItem) { + default PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray, ItemStack heldItem) { PlacementOffset offset = getOffset(player, world, state, pos, ray); if (heldItem.getItem() instanceof BlockItem) { BlockItem blockItem = (BlockItem) heldItem.getItem(); @@ -79,23 +79,23 @@ public interface IPlacementHelper { * @param offset the PlacementOffset returned by {@link #getOffset(PlayerEntity, World, BlockState, BlockPos, BlockRayTraceResult)}
* the offset will always be successful if this method is called */ - default void renderAt(BlockPos pos, BlockState state, BlockRayTraceResult ray, PlacementOffset offset) { + default void renderAt(BlockPos pos, BlockState state, BlockHitResult ray, PlacementOffset offset) { displayGhost(offset); } //RIP - static void renderArrow(Vector3d center, Vector3d target, Direction arrowPlane) { + static void renderArrow(Vec3 center, Vec3 target, Direction arrowPlane) { renderArrow(center, target, arrowPlane, 1D); } - static void renderArrow(Vector3d center, Vector3d target, Direction arrowPlane, double distanceFromCenter) { - Vector3d direction = target.subtract(center).normalize(); - Vector3d facing = Vector3d.atLowerCornerOf(arrowPlane.getNormal()); - Vector3d start = center.add(direction); - Vector3d offset = direction.scale(distanceFromCenter - 1); - 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); + static void renderArrow(Vec3 center, Vec3 target, Direction arrowPlane, double distanceFromCenter) { + Vec3 direction = target.subtract(center).normalize(); + Vec3 facing = Vec3.atLowerCornerOf(arrowPlane.getNormal()); + Vec3 start = center.add(direction); + Vec3 offset = direction.scale(distanceFromCenter - 1); + Vec3 offsetA = direction.cross(facing).normalize().scale(.25); + Vec3 offsetB = facing.cross(direction).normalize().scale(.25); + Vec3 endA = center.add(direction.scale(.75)).add(offsetA); + Vec3 endB = center.add(direction.scale(.75)).add(offsetB); CreateClient.OUTLINER.showLine("placementArrowA" + center + target, start.add(offset), endA.add(offset)).lineWidth(1 / 16f); CreateClient.OUTLINER.showLine("placementArrowB" + center + target, start.add(offset), endB.add(offset)).lineWidth(1 / 16f); } @@ -109,39 +109,39 @@ public interface IPlacementHelper { .breathingAlpha(); } - static List orderedByDistanceOnlyAxis(BlockPos pos, Vector3d hit, Direction.Axis axis) { + static List orderedByDistanceOnlyAxis(BlockPos pos, Vec3 hit, Direction.Axis axis) { return orderedByDistance(pos, hit, dir -> dir.getAxis() == axis); } - static List orderedByDistanceOnlyAxis(BlockPos pos, Vector3d hit, Direction.Axis axis, Predicate includeDirection) { + static List orderedByDistanceOnlyAxis(BlockPos pos, Vec3 hit, Direction.Axis axis, Predicate includeDirection) { return orderedByDistance(pos, hit, ((Predicate) dir -> dir.getAxis() == axis).and(includeDirection)); } - static List orderedByDistanceExceptAxis(BlockPos pos, Vector3d hit, Direction.Axis axis) { + static List orderedByDistanceExceptAxis(BlockPos pos, Vec3 hit, Direction.Axis axis) { return orderedByDistance(pos, hit, dir -> dir.getAxis() != axis); } - static List orderedByDistanceExceptAxis(BlockPos pos, Vector3d hit, Direction.Axis axis, Predicate includeDirection) { + static List orderedByDistanceExceptAxis(BlockPos pos, Vec3 hit, Direction.Axis axis, Predicate includeDirection) { return orderedByDistance(pos, hit, ((Predicate) dir -> dir.getAxis() != axis).and(includeDirection)); } - static List orderedByDistanceExceptAxis(BlockPos pos, Vector3d hit, Direction.Axis first, Direction.Axis second) { + static List orderedByDistanceExceptAxis(BlockPos pos, Vec3 hit, Direction.Axis first, Direction.Axis second) { return orderedByDistanceExceptAxis(pos, hit, first, d -> d.getAxis() != second); } - static List orderedByDistanceExceptAxis(BlockPos pos, Vector3d hit, Direction.Axis first, Direction.Axis second, Predicate includeDirection) { + static List orderedByDistanceExceptAxis(BlockPos pos, Vec3 hit, Direction.Axis first, Direction.Axis second, Predicate includeDirection) { return orderedByDistanceExceptAxis(pos, hit, first, ((Predicate) d -> d.getAxis() != second).and(includeDirection)); } - static List orderedByDistance(BlockPos pos, Vector3d hit) { + static List orderedByDistance(BlockPos pos, Vec3 hit) { return orderedByDistance(pos, hit, _$ -> true); } - static List orderedByDistance(BlockPos pos, Vector3d hit, Predicate includeDirection) { - Vector3d centerToHit = hit.subtract(VecHelper.getCenterOf(pos)); + static List orderedByDistance(BlockPos pos, Vec3 hit, Predicate includeDirection) { + Vec3 centerToHit = hit.subtract(VecHelper.getCenterOf(pos)); return Arrays.stream(Iterate.directions) .filter(includeDirection) - .map(dir -> Pair.of(dir, Vector3d.atLowerCornerOf(dir.getNormal()).distanceTo(centerToHit))) + .map(dir -> Pair.of(dir, Vec3.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 25903ef46..9ed87f01c 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 @@ -6,7 +6,7 @@ import java.util.stream.Collectors; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.CClient; @@ -16,21 +16,21 @@ import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.BlockState; -import net.minecraft.client.MainWindow; +import net.minecraft.world.level.block.state.BlockState; +import com.mojang.blaze3d.platform.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.math.vector.Vector3f; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import com.mojang.math.Matrix4f; +import net.minecraft.world.phys.Vec3; +import com.mojang.math.Vector3f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderGameOverlayEvent; @@ -78,15 +78,15 @@ public class PlacementHelpers { @OnlyIn(Dist.CLIENT) private static void checkHelpers() { Minecraft mc = Minecraft.getInstance(); - ClientWorld world = mc.level; + ClientLevel world = mc.level; if (world == null) return; - if (!(mc.hitResult instanceof BlockRayTraceResult)) + if (!(mc.hitResult instanceof BlockHitResult)) return; - BlockRayTraceResult ray = (BlockRayTraceResult) mc.hitResult; + BlockHitResult ray = (BlockHitResult) mc.hitResult; if (mc.player == null) return; @@ -94,7 +94,7 @@ public class PlacementHelpers { 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()) { + for (InteractionHand hand : InteractionHand.values()) { ItemStack heldItem = mc.player.getItemInHand(hand); List filteredForHeldItem = helpers.stream().filter(helper -> helper.matchesItem(heldItem)).collect(Collectors.toList()); @@ -150,10 +150,10 @@ public class PlacementHelpers { return; Minecraft mc = Minecraft.getInstance(); - PlayerEntity player = mc.player; + Player player = mc.player; if (player != null && animationTick > 0) { - MainWindow res = event.getWindow(); + Window res = event.getWindow(); float screenY = res.getGuiScaledHeight() / 2f; float screenX = res.getGuiScaledWidth() / 2f; @@ -168,21 +168,21 @@ public class PlacementHelpers { } @OnlyIn(Dist.CLIENT) - private static void drawDirectionIndicator(MatrixStack ms, float partialTicks, float centerX, float centerY, float progress) { + private static void drawDirectionIndicator(PoseStack ms, float partialTicks, float centerX, float centerY, float progress) { float r = .8f; float g = .8f; float b = .8f; float a = progress * progress; - Vector3d projTarget = VecHelper.projectToPlayerView(VecHelper.getCenterOf(lastTarget), partialTicks); + Vec3 projTarget = VecHelper.projectToPlayerView(VecHelper.getCenterOf(lastTarget), partialTicks); - Vector3d target = new Vector3d(projTarget.x, projTarget.y, 0); + Vec3 target = new Vec3(projTarget.x, projTarget.y, 0); if (projTarget.z > 0) { target = target.reverse(); } - Vector3d norm = target.normalize(); - Vector3d ref = new Vector3d(0, 1, 0); + Vec3 norm = target.normalize(); + Vec3 ref = new Vec3(0, 1, 0); float targetAngle = AngleHelper.deg(Math.acos(norm.dot(ref))); angle.withSpeed(0.25f); @@ -209,7 +209,7 @@ public class PlacementHelpers { textured(ms, centerX, centerY, a, snappedAngle); } - private static void fadedArrow(MatrixStack ms, float centerX, float centerY, float r, float g, float b, float a, float length, float snappedAngle) { + private static void fadedArrow(PoseStack ms, float centerX, float centerY, float r, float g, float b, float a, float length, float snappedAngle) { ms.pushPose(); RenderSystem.disableTexture(); RenderSystem.enableBlend(); @@ -223,9 +223,9 @@ public class PlacementHelpers { double scale = AllConfigs.CLIENT.indicatorScale.get(); RenderSystem.scaled(scale, scale, 1); - Tessellator tessellator = Tessellator.getInstance(); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuilder(); - bufferbuilder.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION_COLOR); + bufferbuilder.begin(GL11.GL_POLYGON, DefaultVertexFormat.POSITION_COLOR); Matrix4f mat = ms.last().pose(); @@ -247,7 +247,7 @@ public class PlacementHelpers { ms.popPose(); } - private static void textured(MatrixStack ms, float centerX, float centerY, float alpha, float snappedAngle) { + private static void textured(PoseStack ms, float centerX, float centerY, float alpha, float snappedAngle) { ms.pushPose(); RenderSystem.enableTexture(); AllGuiTextures.PLACEMENT_INDICATOR_SHEET.bind(); @@ -270,9 +270,9 @@ public class PlacementHelpers { float tw = 1f; float th = tex_size; - Tessellator tessellator = Tessellator.getInstance(); + Tesselator tessellator = Tesselator.getInstance(); BufferBuilder buffer = tessellator.getBuilder(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION_COLOR_TEX); Matrix4f mat = ms.last().pose(); buffer.vertex(mat, -1, -1, 0).color(1f, 1f, 1f, alpha).uv(tx, ty).endVertex(); 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 4ab7ef08f..331c6d21b 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 @@ -3,23 +3,23 @@ package com.simibubi.create.foundation.utility.placement; import java.util.function.Function; import net.minecraft.advancements.CriteriaTriggers; -import net.minecraft.block.BlockState; -import net.minecraft.block.SoundType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.stats.Stats; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.vector.Vector3i; -import net.minecraft.world.World; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.sounds.SoundSource; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.event.world.BlockEvent; @@ -27,7 +27,7 @@ import net.minecraftforge.event.world.BlockEvent; public class PlacementOffset { private final boolean success; - private Vector3i pos; + private Vec3i pos; private Function stateTransform; private BlockState ghostState; @@ -46,15 +46,15 @@ public class PlacementOffset { return new PlacementOffset(true); } - public static PlacementOffset success(Vector3i pos) { + public static PlacementOffset success(Vec3i pos) { return success().at(pos); } - public static PlacementOffset success(Vector3i pos, Function transform) { + public static PlacementOffset success(Vec3i pos, Function transform) { return success().at(pos).withTransform(transform); } - public PlacementOffset at(Vector3i pos) { + public PlacementOffset at(Vec3i pos) { this.pos = pos; return this; } @@ -73,7 +73,7 @@ public class PlacementOffset { return success; } - public Vector3i getPos() { + public Vec3i getPos() { return pos; } @@ -96,26 +96,26 @@ public class PlacementOffset { return ghostState; } - public boolean isReplaceable(World world) { + public boolean isReplaceable(Level world) { if (!success) return false; return world.getBlockState(new BlockPos(pos)).getMaterial().isReplaceable(); } - public ActionResultType placeInWorld(World world, BlockItem blockItem, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { + public InteractionResult placeInWorld(Level world, BlockItem blockItem, Player player, InteractionHand hand, BlockHitResult ray) { if (!isReplaceable(world)) - return ActionResultType.PASS; + return InteractionResult.PASS; if (world.isClientSide) - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; - ItemUseContext context = new ItemUseContext(player, hand, ray); + UseOnContext context = new UseOnContext(player, hand, ray); BlockPos newPos = new BlockPos(pos); if (!world.mayInteract(player, newPos)) - return ActionResultType.PASS; + return InteractionResult.PASS; BlockState state = stateTransform.apply(blockItem.getBlock().defaultBlockState()); if (state.hasProperty(BlockStateProperties.WATERLOGGED)) { @@ -129,21 +129,21 @@ public class PlacementOffset { BlockEvent.EntityPlaceEvent event = new BlockEvent.EntityPlaceEvent(snapshot, IPlacementHelper.ID, player); if (MinecraftForge.EVENT_BUS.post(event)) { snapshot.restore(true, false); - return ActionResultType.FAIL; + return InteractionResult.FAIL; } BlockState newState = world.getBlockState(newPos); 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); + world.playSound(null, newPos, soundtype.getPlaceSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); player.awardStat(Stats.ITEM_USED.get(blockItem)); - if (player instanceof ServerPlayerEntity) - CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) player, newPos, context.getItemInHand()); + if (player instanceof ServerPlayer) + CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer) player, newPos, context.getItemInHand()); if (!player.isCreative()) context.getItemInHand().shrink(1); - return ActionResultType.SUCCESS; + return InteractionResult.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 8488daf3a..0c64d5f5d 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 @@ -10,14 +10,14 @@ import com.simibubi.create.foundation.utility.placement.IPlacementHelper; import com.simibubi.create.foundation.utility.placement.PlacementOffset; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockState; -import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.state.Property; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.core.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ForgeMod; @MethodsReturnNonnullByDefault @@ -40,7 +40,7 @@ public abstract class PoleHelper> implements IPlacementH return axisFunction.apply(state) == axis; } - public int attachedPoles(World world, BlockPos pos, Direction direction) { + public int attachedPoles(Level world, BlockPos pos, Direction direction) { BlockPos checkPos = pos.relative(direction); BlockState state = world.getBlockState(checkPos); int count = 0; @@ -58,12 +58,12 @@ public abstract class PoleHelper> implements IPlacementH } @Override - public PlacementOffset getOffset(PlayerEntity player, World world, BlockState state, BlockPos pos, BlockRayTraceResult ray) { + public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) { 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) { - ModifiableAttributeInstance reach = player.getAttribute(ForgeMod.REACH_DISTANCE.get()); + AttributeInstance reach = player.getAttribute(ForgeMod.REACH_DISTANCE.get()); if (reach != null && reach.hasModifier(ExtendoGripItem.singleRangeAttributeModifier)) range += 4; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/recipe/IRecipeTypeInfo.java b/src/main/java/com/simibubi/create/foundation/utility/recipe/IRecipeTypeInfo.java index bf347471f..7ec3f0b83 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/recipe/IRecipeTypeInfo.java +++ b/src/main/java/com/simibubi/create/foundation/utility/recipe/IRecipeTypeInfo.java @@ -1,15 +1,15 @@ package com.simibubi.create.foundation.utility.recipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.util.ResourceLocation; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.resources.ResourceLocation; public interface IRecipeTypeInfo { ResourceLocation getId(); - > T getSerializer(); + > T getSerializer(); - > T getType(); + > T getType(); } 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 95123ff19..9a21b9777 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 @@ -4,9 +4,9 @@ import java.util.function.Predicate; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; /** * Commonly used Predicates for searching through recipe collections. @@ -16,21 +16,21 @@ import net.minecraft.item.crafting.IRecipeType; */ public class RecipeConditions { - public static Predicate> isOfType(IRecipeType... otherTypes) { + public static Predicate> isOfType(RecipeType... otherTypes) { return recipe -> { - IRecipeType recipeType = recipe.getType(); - for (IRecipeType other : otherTypes) + RecipeType recipeType = recipe.getType(); + for (RecipeType other : otherTypes) if (recipeType == other) return true; return false; }; } - public static Predicate> firstIngredientMatches(ItemStack stack) { + public static Predicate> firstIngredientMatches(ItemStack stack) { return r -> !r.getIngredients().isEmpty() && r.getIngredients().get(0).test(stack); } - public static Predicate> outputMatchesFilter(FilteringBehaviour filtering) { + public static Predicate> outputMatchesFilter(FilteringBehaviour filtering) { return r -> filtering.test(r.getResultItem()); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeFinder.java b/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeFinder.java index b6a098d44..90e09b6e0 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeFinder.java +++ b/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeFinder.java @@ -12,8 +12,8 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.simibubi.create.foundation.utility.ISimpleReloadListener; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.level.Level; /** * Utility for searching through a world's recipe collection. Non-dynamic @@ -25,7 +25,7 @@ import net.minecraft.world.World; */ public class RecipeFinder { - private static Cache>> cachedSearches = CacheBuilder.newBuilder().build(); + private static Cache>> cachedSearches = CacheBuilder.newBuilder().build(); /** * Find all IRecipes matching the condition predicate. If this search is made @@ -37,7 +37,7 @@ public class RecipeFinder { * @param conditions * @return A started search to continue with more specific conditions. */ - public static List> get(@Nullable Object cacheKey, World world, Predicate> conditions) { + public static List> get(@Nullable Object cacheKey, Level world, Predicate> conditions) { if (cacheKey == null) return startSearch(world, conditions); @@ -50,8 +50,8 @@ public class RecipeFinder { return Collections.emptyList(); } - private static List> startSearch(World world, Predicate> conditions) { - List> list = world.getRecipeManager().getRecipes().stream().filter(conditions) + private static List> startSearch(Level world, Predicate> conditions) { + List> list = world.getRecipeManager().getRecipes().stream().filter(conditions) .collect(Collectors.toList()); return list; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/DummyStatusListener.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/DummyStatusListener.java index b963a236c..c229f4a3e 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/DummyStatusListener.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/DummyStatusListener.java @@ -1,10 +1,10 @@ package com.simibubi.create.foundation.utility.worldWrappers; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.listener.IChunkStatusListener; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.server.level.progress.ChunkProgressListener; -public class DummyStatusListener implements IChunkStatusListener { +public class DummyStatusListener implements ChunkProgressListener { @Override public void updateSpawnPos(ChunkPos p_219509_1_) {} 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 18ce49c0c..9aedeaa83 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 @@ -3,15 +3,15 @@ package com.simibubi.create.foundation.utility.worldWrappers; import java.util.HashMap; import java.util.function.Predicate; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; public class PlacementSimulationServerWorld extends WrappedServerWorld { public HashMap blocksAdded; - public PlacementSimulationServerWorld(ServerWorld wrapped) { + public PlacementSimulationServerWorld(ServerLevel wrapped) { super(wrapped); blocksAdded = new HashMap<>(); } 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 57a1462b6..27486bad2 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 @@ -9,38 +9,38 @@ import java.util.function.Predicate; import com.jozufozu.flywheel.backend.IFlywheelWorld; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.SectionPos; -import net.minecraft.world.World; -import net.minecraft.world.lighting.WorldLightManager; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.lighting.LevelLightEngine; public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelWorld { public Map blocksAdded; - public Map tesAdded; + public Map tesAdded; public Set spannedSections; - public WorldLightManager lighter; + public LevelLightEngine lighter; public WrappedChunkProvider chunkProvider; - private final BlockPos.Mutable scratch = new BlockPos.Mutable(); + private final BlockPos.MutableBlockPos scratch = new BlockPos.MutableBlockPos(); - public PlacementSimulationWorld(World wrapped) { + public PlacementSimulationWorld(Level wrapped) { this(wrapped, new WrappedChunkProvider()); } - public PlacementSimulationWorld(World wrapped, WrappedChunkProvider chunkProvider) { + public PlacementSimulationWorld(Level wrapped, WrappedChunkProvider chunkProvider) { super(wrapped, chunkProvider); this.chunkProvider = chunkProvider.setWorld(this); spannedSections = new HashSet<>(); - lighter = new WorldLightManager(chunkProvider, true, false); // blockLight, skyLight + lighter = new LevelLightEngine(chunkProvider, true, false); // blockLight, skyLight blocksAdded = new HashMap<>(); tesAdded = new HashMap<>(); } @Override - public WorldLightManager getLightEngine() { + public LevelLightEngine getLightEngine() { return lighter; } @@ -55,7 +55,7 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW } } - public void setTileEntities(Collection tileEntities) { + public void setTileEntities(Collection tileEntities) { tesAdded.clear(); tileEntities.forEach(te -> tesAdded.put(te.getBlockPos(), te)); } @@ -86,7 +86,7 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW } @Override - public TileEntity getBlockEntity(BlockPos pos) { + public BlockEntity getBlockEntity(BlockPos pos) { return tesAdded.get(pos); } 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 eb608d262..bc9ad57cd 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 @@ -2,25 +2,25 @@ package com.simibubi.create.foundation.utility.worldWrappers; import java.util.function.BiFunction; -import net.minecraft.block.BlockState; -import net.minecraft.fluid.FluidState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; -public class RayTraceWorld implements IBlockReader { +public class RayTraceWorld implements BlockGetter { - private IWorld template; + private LevelAccessor template; private BiFunction stateGetter; - public RayTraceWorld(IWorld template, BiFunction stateGetter) { + public RayTraceWorld(LevelAccessor template, BiFunction stateGetter) { this.template = template; this.stateGetter = stateGetter; } @Override - public TileEntity getBlockEntity(BlockPos pos) { + public BlockEntity getBlockEntity(BlockPos pos) { return template.getBlockEntity(pos); } 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 7d68691b1..be243df32 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 @@ -9,15 +9,15 @@ import javax.annotation.Nullable; import com.simibubi.create.foundation.utility.worldWrappers.chunk.EmptierChunk; import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.chunk.AbstractChunkProvider; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.lighting.WorldLightManager; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.chunk.ChunkSource; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.lighting.LevelLightEngine; -public class WrappedChunkProvider extends AbstractChunkProvider { +public class WrappedChunkProvider extends ChunkSource { private PlacementSimulationWorld world; public HashMap chunks; @@ -38,22 +38,22 @@ public class WrappedChunkProvider extends AbstractChunkProvider { @Nullable @Override - public IBlockReader getChunkForLighting(int x, int z) { + public BlockGetter getChunkForLighting(int x, int z) { return getChunk(x, z); } @Override - public IBlockReader getLevel() { + public BlockGetter getLevel() { return world; } @Nullable @Override - public IChunk getChunk(int x, int z, ChunkStatus status, boolean p_212849_4_) { + public ChunkAccess getChunk(int x, int z, ChunkStatus status, boolean p_212849_4_) { return getChunk(x, z); } - public IChunk getChunk(int x, int z) { + public ChunkAccess getChunk(int x, int z) { long pos = ChunkPos.asLong(x, z); if (chunks == null) @@ -68,7 +68,7 @@ public class WrappedChunkProvider extends AbstractChunkProvider { } @Override - public WorldLightManager getLightEngine() { + public LevelLightEngine 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 4e497fdc7..141b68819 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 @@ -8,23 +8,23 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import mezz.jei.api.MethodsReturnNonnullByDefault; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityPredicate; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.particles.IParticleData; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.LightType; -import net.minecraft.world.World; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.ai.targeting.TargetingConditions; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.Level; import net.minecraft.world.level.ColorResolver; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -33,16 +33,16 @@ import net.minecraftforge.api.distmarker.OnlyIn; @SuppressWarnings("deprecation") @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public class WrappedClientWorld extends ClientWorld { +public class WrappedClientWorld extends ClientLevel { private static final Minecraft mc = Minecraft.getInstance(); - protected World world; + protected Level world; - private WrappedClientWorld(World world) { + private WrappedClientWorld(Level world) { 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; } - public static WrappedClientWorld of(World world) { + public static WrappedClientWorld of(Level world) { return new WrappedClientWorld(world); } @@ -57,12 +57,12 @@ public class WrappedClientWorld extends ClientWorld { } @Override - public Stream getBlockCollisions(@Nullable Entity entity, AxisAlignedBB axisAlignedBB) { + public Stream getBlockCollisions(@Nullable Entity entity, AABB axisAlignedBB) { return world.getBlockCollisions(entity, axisAlignedBB); } @Override - public Stream getBlockCollisions(@Nullable Entity entity, AxisAlignedBB axisAlignedBB, BiPredicate blockStateBlockPosBiPredicate) { + public Stream getBlockCollisions(@Nullable Entity entity, AABB axisAlignedBB, BiPredicate blockStateBlockPosBiPredicate) { return world.getBlockCollisions(entity, axisAlignedBB, blockStateBlockPosBiPredicate); } @@ -75,7 +75,7 @@ public class WrappedClientWorld extends ClientWorld { @Override - public int getBrightness(LightType type, BlockPos pos) { + public int getBrightness(LightLayer type, BlockPos pos) { return world.getBrightness(type, pos); } @@ -91,7 +91,7 @@ public class WrappedClientWorld extends ClientWorld { @Nullable @Override - 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_) { + public T getNearestEntity(List p_217361_1_, TargetingConditions 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_); } @@ -104,41 +104,41 @@ public class WrappedClientWorld extends ClientWorld { @Override - public void addParticle(IParticleData p_195594_1_, double p_195594_2_, double p_195594_4_, double p_195594_6_, double p_195594_8_, double p_195594_10_, double p_195594_12_) { + public void addParticle(ParticleOptions p_195594_1_, double p_195594_2_, double p_195594_4_, double p_195594_6_, double p_195594_8_, double p_195594_10_, double p_195594_12_) { world.addParticle(p_195594_1_, p_195594_2_, p_195594_4_, p_195594_6_, p_195594_8_, p_195594_10_, p_195594_12_); } @Override - public void addParticle(IParticleData p_195590_1_, boolean p_195590_2_, double p_195590_3_, double p_195590_5_, double p_195590_7_, double p_195590_9_, double p_195590_11_, double p_195590_13_) { + public void addParticle(ParticleOptions p_195590_1_, boolean p_195590_2_, double p_195590_3_, double p_195590_5_, double p_195590_7_, double p_195590_9_, double p_195590_11_, double p_195590_13_) { world.addParticle(p_195590_1_, p_195590_2_, p_195590_3_, p_195590_5_, p_195590_7_, p_195590_9_, p_195590_11_, p_195590_13_); } @Override - 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_) { + public void addAlwaysVisibleParticle(ParticleOptions 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 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_) { + public void addAlwaysVisibleParticle(ParticleOptions 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 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_) { + public void playLocalSound(double p_184134_1_, double p_184134_3_, double p_184134_5_, SoundEvent p_184134_7_, SoundSource 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 - public void playSound(@Nullable PlayerEntity p_184148_1_, double p_184148_2_, double p_184148_4_, double p_184148_6_, SoundEvent p_184148_8_, SoundCategory p_184148_9_, float p_184148_10_, float p_184148_11_) { + public void playSound(@Nullable Player p_184148_1_, double p_184148_2_, double p_184148_4_, double p_184148_6_, SoundEvent p_184148_8_, SoundSource p_184148_9_, float p_184148_10_, float p_184148_11_) { world.playSound(p_184148_1_, p_184148_2_, p_184148_4_, p_184148_6_, p_184148_8_, p_184148_9_, p_184148_10_, p_184148_11_); } @Nullable @Override - public TileEntity getBlockEntity(BlockPos p_175625_1_) { + public BlockEntity getBlockEntity(BlockPos p_175625_1_) { return world.getBlockEntity(p_175625_1_); } - public World getWrappedWorld() { + public Level 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 8104de717..9d060a062 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 @@ -6,40 +6,40 @@ import java.util.List; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.crafting.RecipeManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.server.MinecraftServer; -import net.minecraft.tags.ITagCollectionSupplier; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.Util; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ITickList; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.server.ServerChunkProvider; -import net.minecraft.world.server.ServerTickList; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.storage.IServerWorldInfo; -import net.minecraft.world.storage.MapData; -import net.minecraft.world.storage.SaveFormat; +import net.minecraft.tags.TagContainer; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.TickList; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.server.level.ServerChunkCache; +import net.minecraft.world.level.ServerTickList; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.storage.ServerLevelData; +import net.minecraft.world.level.saveddata.maps.MapItemSavedData; +import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public class WrappedServerWorld extends ServerWorld { +public class WrappedServerWorld extends ServerLevel { - protected World world; + protected Level world; - public WrappedServerWorld(World world) { + public WrappedServerWorld(Level world) { super(world.getServer(), Util.backgroundExecutor(), getLevelSaveFromWorld(world), - (IServerWorldInfo) world.getLevelData(), world.dimension(), world.dimensionType(), - new DummyStatusListener(), ((ServerChunkProvider) world.getChunkSource()).getGenerator(), world.isDebug(), + (ServerLevelData) world.getLevelData(), world.dimension(), world.dimensionType(), + new DummyStatusListener(), ((ServerChunkCache) world.getChunkSource()).getGenerator(), world.isDebug(), world.getBiomeManager().biomeZoomSeed, Collections.emptyList(), false); this.world = world; } @@ -61,7 +61,7 @@ public class WrappedServerWorld extends ServerWorld { @Override public ServerTickList getBlockTicks() { - ITickList tl = world.getBlockTicks(); + TickList tl = world.getBlockTicks(); if (tl instanceof ServerTickList) return (ServerTickList) tl; return super.getBlockTicks(); @@ -69,29 +69,29 @@ public class WrappedServerWorld extends ServerWorld { @Override public ServerTickList getLiquidTicks() { - ITickList tl = world.getLiquidTicks(); + TickList tl = world.getLiquidTicks(); if (tl instanceof ServerTickList) return (ServerTickList) tl; return super.getLiquidTicks(); } @Override - public void levelEvent(PlayerEntity player, int type, BlockPos pos, int data) { + public void levelEvent(Player player, int type, BlockPos pos, int data) { } @Override - public List players() { + public List players() { return Collections.emptyList(); } @Override - public void playSound(PlayerEntity player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, + public void playSound(Player player, double x, double y, double z, SoundEvent soundIn, SoundSource category, float volume, float pitch) { } @Override - 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_) { + public void playSound(Player p_217384_1_, Entity p_217384_2_, SoundEvent p_217384_3_, + SoundSource p_217384_4_, float p_217384_5_, float p_217384_6_) { } @Override @@ -100,7 +100,7 @@ public class WrappedServerWorld extends ServerWorld { } @Override - public MapData getMapData(String mapName) { + public MapItemSavedData getMapData(String mapName) { return null; } @@ -111,7 +111,7 @@ public class WrappedServerWorld extends ServerWorld { } @Override - public void setMapData(MapData mapDataIn) { + public void setMapData(MapItemSavedData mapDataIn) { } @Override @@ -129,7 +129,7 @@ public class WrappedServerWorld extends ServerWorld { } @Override - public ITagCollectionSupplier getTagManager() { + public TagContainer getTagManager() { return world.getTagManager(); } @@ -138,7 +138,7 @@ public class WrappedServerWorld extends ServerWorld { return world.getUncachedNoiseBiome(p_225604_1_, p_225604_2_, p_225604_3_); } - private static SaveFormat.LevelSave getLevelSaveFromWorld(World world) { + private static LevelStorageSource.LevelStorageAccess getLevelSaveFromWorld(Level world) { return ObfuscationReflectionHelper.getPrivateValue(MinecraftServer.class, world.getServer(), "field_71310_m"); // 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 46b8cdcf6..c1594edd7 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 @@ -8,52 +8,52 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.crafting.RecipeManager; -import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.tags.ITagCollectionSupplier; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.DynamicRegistries; -import net.minecraft.world.ITickList; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.chunk.AbstractChunkProvider; -import net.minecraft.world.lighting.WorldLightManager; -import net.minecraft.world.storage.ISpawnWorldInfo; -import net.minecraft.world.storage.MapData; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.world.scores.Scoreboard; +import net.minecraft.tags.TagContainer; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.core.RegistryAccess; +import net.minecraft.world.level.TickList; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.chunk.ChunkSource; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.storage.WritableLevelData; +import net.minecraft.world.level.saveddata.maps.MapItemSavedData; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -public class WrappedWorld extends World { +public class WrappedWorld extends Level { - protected World world; - protected AbstractChunkProvider provider; + protected Level world; + protected ChunkSource provider; - public WrappedWorld(World world, AbstractChunkProvider provider) { - super((ISpawnWorldInfo) world.getLevelData(), world.dimension(), world.dimensionType(), world::getProfiler, + public WrappedWorld(Level world, ChunkSource provider) { + super((WritableLevelData) world.getLevelData(), world.dimension(), world.dimensionType(), world::getProfiler, world.isClientSide, world.isDebug(), 0); this.world = world; this.provider = provider; } - public WrappedWorld(World world) { + public WrappedWorld(Level world) { this(world, null); } - public World getLevel() { + public Level getLevel() { return world; } @Override - public WorldLightManager getLightEngine() { + public LevelLightEngine getLightEngine() { return world.getLightEngine(); } @@ -68,7 +68,7 @@ public class WrappedWorld extends World { } @Override - public TileEntity getBlockEntity(@Nullable BlockPos pos) { + public BlockEntity getBlockEntity(@Nullable BlockPos pos) { return world.getBlockEntity(pos); } @@ -88,35 +88,35 @@ public class WrappedWorld extends World { } @Override - public ITickList getBlockTicks() { + public TickList getBlockTicks() { return world.getBlockTicks(); } @Override - public ITickList getLiquidTicks() { + public TickList getLiquidTicks() { return world.getLiquidTicks(); } @Override - public AbstractChunkProvider getChunkSource() { + public ChunkSource getChunkSource() { return provider; } @Override - public void levelEvent(@Nullable PlayerEntity player, int type, BlockPos pos, int data) {} + public void levelEvent(@Nullable Player player, int type, BlockPos pos, int data) {} @Override - public List players() { + public List players() { return Collections.emptyList(); } @Override - public void playSound(@Nullable PlayerEntity player, double x, double y, double z, SoundEvent soundIn, - SoundCategory category, float volume, float pitch) {} + public void playSound(@Nullable Player player, double x, double y, double z, SoundEvent soundIn, + SoundSource category, float volume, float pitch) {} @Override - 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_) {} + public void playSound(@Nullable Player p_217384_1_, Entity p_217384_2_, SoundEvent p_217384_3_, + SoundSource p_217384_4_, float p_217384_5_, float p_217384_6_) {} @Override public Entity getEntity(int id) { @@ -124,7 +124,7 @@ public class WrappedWorld extends World { } @Override - public MapData getMapData(String mapName) { + public MapItemSavedData getMapData(String mapName) { return null; } @@ -137,7 +137,7 @@ public class WrappedWorld extends World { } @Override - public void setMapData(MapData mapDataIn) {} + public void setMapData(MapItemSavedData mapDataIn) {} @Override public int getFreeMapId() { @@ -158,7 +158,7 @@ public class WrappedWorld extends World { } @Override - public ITagCollectionSupplier getTagManager() { + public TagContainer getTagManager() { return world.getTagManager(); } @@ -168,7 +168,7 @@ public class WrappedWorld extends World { } @Override - public DynamicRegistries registryAccess() { + public RegistryAccess registryAccess() { return world.registryAccess(); } @@ -178,7 +178,7 @@ public class WrappedWorld extends World { } @Override - public void blockEntityChanged(BlockPos p_175646_1_, TileEntity p_175646_2_) { + public void blockEntityChanged(BlockPos p_175646_1_, BlockEntity p_175646_2_) { } @Override 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 e5a963e2b..991388ec1 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 @@ -5,19 +5,19 @@ import java.util.function.Predicate; import javax.annotation.Nullable; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.lighting.WorldLightManager; -import net.minecraft.world.server.ChunkHolder; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.server.level.ChunkHolder; -public class EmptierChunk extends Chunk { +public class EmptierChunk extends LevelChunk { public EmptierChunk() { super(null, null, null); @@ -37,7 +37,7 @@ public class EmptierChunk extends Chunk { } @Nullable - public WorldLightManager getLightEngine() { + public LevelLightEngine getLightEngine() { return null; } @@ -52,21 +52,21 @@ public class EmptierChunk extends Chunk { public void removeEntity(Entity p_76608_1_, int p_76608_2_) { } @Nullable - public TileEntity getBlockEntity(BlockPos p_177424_1_, Chunk.CreateEntityType p_177424_2_) { + public BlockEntity getBlockEntity(BlockPos p_177424_1_, LevelChunk.EntityCreationType p_177424_2_) { return null; } - public void addBlockEntity(TileEntity p_150813_1_) { } + public void addBlockEntity(BlockEntity p_150813_1_) { } - public void setBlockEntity(BlockPos p_177426_1_, TileEntity p_177426_2_) { } + public void setBlockEntity(BlockPos p_177426_1_, BlockEntity p_177426_2_) { } public void removeBlockEntity(BlockPos p_177425_1_) { } public void markUnsaved() { } - public void getEntities(@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_, AABB p_177414_2_, List p_177414_3_, Predicate p_177414_4_) { } - public void getEntitiesOfClass(Class p_177430_1_, AxisAlignedBB p_177430_2_, List p_177430_3_, Predicate p_177430_4_) { } + public void getEntitiesOfClass(Class p_177430_1_, AABB p_177430_2_, List p_177430_3_, Predicate p_177430_4_) { } public boolean isEmpty() { return true; @@ -76,7 +76,7 @@ public class EmptierChunk extends Chunk { return true; } - public ChunkHolder.LocationType getFullStatus() { - return ChunkHolder.LocationType.BORDER; + public ChunkHolder.FullChunkStatus getFullStatus() { + return ChunkHolder.FullChunkStatus.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 6eaa14f87..13d2ccf4f 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 @@ -11,26 +11,26 @@ import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationW import it.unimi.dsi.fastutil.longs.LongSet; import it.unimi.dsi.fastutil.shorts.ShortList; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.palette.UpgradeData; -import net.minecraft.world.ITickList; -import net.minecraft.world.biome.BiomeContainer; -import net.minecraft.world.chunk.ChunkSection; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.Heightmap; -import net.minecraft.world.gen.feature.structure.Structure; -import net.minecraft.world.gen.feature.structure.StructureStart; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.UpgradeData; +import net.minecraft.world.level.TickList; +import net.minecraft.world.level.chunk.ChunkBiomeContainer; +import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.feature.StructureFeature; +import net.minecraft.world.level.levelgen.structure.StructureStart; -public class WrappedChunk implements IChunk { +public class WrappedChunk implements ChunkAccess { final PlacementSimulationWorld world; boolean needsLight; @@ -38,7 +38,7 @@ public class WrappedChunk implements IChunk { final int z; final ChunkPos pos; - private final ChunkSection[] sections; + private final LevelChunkSection[] sections; public WrappedChunk(PlacementSimulationWorld world, int x, int z) { this.world = world; @@ -47,7 +47,7 @@ public class WrappedChunk implements IChunk { this.z = z; this.pos = new ChunkPos(x, z); - this.sections = new ChunkSection[16]; + this.sections = new LevelChunkSection[16]; for (int i = 0; i < 16; i++) { sections[i] = new WrappedChunkSection(this, i << 4); @@ -68,7 +68,7 @@ public class WrappedChunk implements IChunk { } @Override - public ChunkSection[] getSections() { + public LevelChunkSection[] getSections() { return sections; } @@ -84,7 +84,7 @@ public class WrappedChunk implements IChunk { } @Override - public void setBlockEntity(BlockPos p_177426_1_, TileEntity p_177426_2_) { + public void setBlockEntity(BlockPos p_177426_1_, BlockEntity p_177426_2_) { } @@ -99,22 +99,22 @@ public class WrappedChunk implements IChunk { } @Override - public Collection> getHeightmaps() { + public Collection> getHeightmaps() { return null; } @Override - public void setHeightmap(Heightmap.Type p_201607_1_, long[] p_201607_2_) { + public void setHeightmap(Heightmap.Types p_201607_1_, long[] p_201607_2_) { } @Override - public Heightmap getOrCreateHeightmapUnprimed(Heightmap.Type p_217303_1_) { + public Heightmap getOrCreateHeightmapUnprimed(Heightmap.Types p_217303_1_) { return null; } @Override - public int getHeight(Heightmap.Type p_201576_1_, int p_201576_2_, int p_201576_3_) { + public int getHeight(Heightmap.Types p_201576_1_, int p_201576_2_, int p_201576_3_) { return 0; } @@ -130,7 +130,7 @@ public class WrappedChunk implements IChunk { @Nullable @Override - public BiomeContainer getBiomes() { + public ChunkBiomeContainer getBiomes() { return null; } @@ -156,23 +156,23 @@ public class WrappedChunk implements IChunk { @Nullable @Override - public CompoundNBT getBlockEntityNbt(BlockPos p_201579_1_) { + public CompoundTag getBlockEntityNbt(BlockPos p_201579_1_) { return null; } @Nullable @Override - public CompoundNBT getBlockEntityNbtForSaving(BlockPos p_223134_1_) { + public CompoundTag getBlockEntityNbtForSaving(BlockPos p_223134_1_) { return null; } @Override - public ITickList getBlockTicks() { + public TickList getBlockTicks() { return null; } @Override - public ITickList getLiquidTicks() { + public TickList getLiquidTicks() { return null; } @@ -203,7 +203,7 @@ public class WrappedChunk implements IChunk { @Nullable @Override - public TileEntity getBlockEntity(BlockPos pos) { + public BlockEntity getBlockEntity(BlockPos pos) { return null; } @@ -218,42 +218,42 @@ public class WrappedChunk implements IChunk { } @Override - public void addReferenceForFeature(Structure arg0, long arg1) { + public void addReferenceForFeature(StructureFeature arg0, long arg1) { } @Override - public Map, LongSet> getAllReferences() { + public Map, LongSet> getAllReferences() { return null; } @Override - public LongSet getReferencesForFeature(Structure arg0) { + public LongSet getReferencesForFeature(StructureFeature arg0) { return null; } @Override - public StructureStart getStartForFeature(Structure arg0) { + public StructureStart getStartForFeature(StructureFeature arg0) { return null; } @Override - public void setAllReferences(Map, LongSet> arg0) { + public void setAllReferences(Map, LongSet> arg0) { } @Override - public void setStartForFeature(Structure arg0, StructureStart arg1) { + public void setStartForFeature(StructureFeature arg0, StructureStart arg1) { } @Override - public void setAllStarts(Map, StructureStart> p_201612_1_) { + public void setAllStarts(Map, StructureStart> p_201612_1_) { } @Override - public Map, StructureStart> getAllStarts() { + 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 26282a22b..bde5b28f8 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 @@ -1,9 +1,9 @@ package com.simibubi.create.foundation.utility.worldWrappers.chunk; -import net.minecraft.block.BlockState; -import net.minecraft.world.chunk.ChunkSection; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.LevelChunkSection; -public class WrappedChunkSection extends ChunkSection { +public class WrappedChunkSection extends LevelChunkSection { public WrappedChunk owner; 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 9113dd70a..9b014a876 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/AllWorldFeatures.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/AllWorldFeatures.java @@ -8,14 +8,14 @@ import com.simibubi.create.Create; import com.simibubi.create.content.palettes.AllPaletteBlocks; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.block.Block; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.WorldGenRegistries; -import net.minecraft.world.biome.Biome.Category; -import net.minecraft.world.biome.Biomes; -import net.minecraft.world.gen.GenerationStage; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.placement.Placement; +import net.minecraft.world.level.block.Block; +import net.minecraft.core.Registry; +import net.minecraft.data.BuiltinRegistries; +import net.minecraft.world.level.biome.Biome.BiomeCategory; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.placement.FeatureDecorator; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.world.BiomeLoadingEvent; @@ -63,7 +63,7 @@ public class AllWorldFeatures { // ForgeRegistries.DECORATORS.register(ConfigDrivenDecorator.INSTANCE); entries.entrySet() .forEach(entry -> { - Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, Create.ID + "_" + entry.getKey(), + Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, Create.ID + "_" + entry.getKey(), entry.getValue() .getFeature()); }); @@ -74,10 +74,10 @@ public class AllWorldFeatures { .forEach(entry -> { if (event.getName() == Biomes.THE_VOID.getRegistryName()) return; - if (event.getCategory() == Category.NETHER) + if (event.getCategory() == BiomeCategory.NETHER) return; event.getGeneration() - .addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, entry.getFeature()); + .addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, entry.getFeature()); }); } @@ -97,7 +97,7 @@ public class AllWorldFeatures { .register(ConfigDrivenOreFeature.INSTANCE); } - public static void registerDecoratorFeatures(RegistryEvent.Register> event) { + public static void registerDecoratorFeatures(RegistryEvent.Register> event) { event.getRegistry() .register(ConfigDrivenDecorator.INSTANCE); } 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 86cfb3fe9..07684250d 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenDecorator.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenDecorator.java @@ -4,11 +4,11 @@ import java.util.Random; import java.util.stream.IntStream; import java.util.stream.Stream; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.gen.placement.SimplePlacement; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.levelgen.placement.SimpleFeatureDecorator; -public class ConfigDrivenDecorator extends SimplePlacement { +public class ConfigDrivenDecorator extends SimpleFeatureDecorator { public static final ConfigDrivenDecorator INSTANCE = new ConfigDrivenDecorator(); @@ -21,7 +21,7 @@ public class ConfigDrivenDecorator extends SimplePlacement place(Random r, ConfigDrivenOreFeatureConfig config, BlockPos pos) { float frequency = config.getFrequency(); - int floored = MathHelper.floor(frequency); + int floored = Mth.floor(frequency); int count = floored + (r.nextFloat() < frequency - floored ? 1 : 0); if (count == 0) return Stream.empty(); 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 0d6eeb8ce..0377847b0 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenFeatureEntry.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenFeatureEntry.java @@ -5,11 +5,14 @@ import java.util.Optional; import com.simibubi.create.foundation.config.ConfigBase; import com.tterrag.registrate.util.nullness.NonNullSupplier; -import net.minecraft.block.Block; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.OreFeatureConfig.FillerBlockType; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration.Predicates; 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,7 +52,7 @@ public class ConfigDrivenFeatureEntry extends ConfigBase { private ConfiguredFeature createFeature() { ConfigDrivenOreFeatureConfig config = - new ConfigDrivenOreFeatureConfig(FillerBlockType.NATURAL_STONE, block.get() + new ConfigDrivenOreFeatureConfig(Predicates.NATURAL_STONE, block.get() .defaultBlockState(), id); return ConfigDrivenOreFeature.INSTANCE.configured(config) 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 b93026dc8..66ee609f2 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenOreFeature.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/ConfigDrivenOreFeature.java @@ -3,13 +3,13 @@ package com.simibubi.create.foundation.worldgen; import java.util.BitSet; import java.util.Random; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.ISeedReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.Heightmap; -import net.minecraft.world.gen.feature.Feature; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.feature.Feature; public class ConfigDrivenOreFeature extends Feature { @@ -22,27 +22,27 @@ public class ConfigDrivenOreFeature extends Feature CODEC = RecordCodecBuilder.create((p_236568_0_) -> { return p_236568_0_.group(RuleTest.CODEC.fieldOf("target") 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 d58fa40a6..f44ac6ca9 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java @@ -8,18 +8,20 @@ import com.simibubi.create.content.curiosities.tools.SandPaperItem; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.state.IntegerProperty; -import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.InteractionResult; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.Level; +import net.minecraft.server.level.ServerLevel; + +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; public class OxidizingBlock extends Block { @@ -43,7 +45,7 @@ public class OxidizingBlock extends Block { } @Override - public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel worldIn, BlockPos pos, Random random) { if (worldIn.getRandom() .nextFloat() <= chance) { int currentState = state.getValue(OXIDIZATION); @@ -75,16 +77,16 @@ public class OxidizingBlock extends Block { } @Override - public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, - BlockRayTraceResult blockRayTraceResult) { + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, + BlockHitResult blockRayTraceResult) { if (state.getValue(OXIDIZATION) > 0 && player.getItemInHand(hand) .getItem() instanceof SandPaperItem) { if (!player.isCreative()) player.getItemInHand(hand) .hurtAndBreak(1, player, p -> p.broadcastBreakEvent(p.getUsedItemHand())); world.setBlockAndUpdate(pos, state.setValue(OXIDIZATION, 0)); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index c47d220df..555e6768f 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,96 +1,96 @@ -public net.minecraft.network.play.ServerPlayNetHandler field_147365_f # floatingTickCount -public net.minecraft.client.network.play.ClientPlayNetHandler field_217287_m # viewDistance +public net.minecraft.server.network.ServerGamePacketListenerImpl f_9737_ # floatingTickCount +public net.minecraft.client.multiplayer.ClientPacketListener f_104897_ # viewDistance # CubeParticle -protected net.minecraft.client.particle.Particle field_228343_B_ # collidedY +protected net.minecraft.client.particle.Particle f_107205_ # collidedY # Needed for ChunkUtil, maybe remove these for releases # ChunkManager -public net.minecraft.world.server.ChunkManager func_219212_a(JLnet/minecraft/world/server/ChunkHolder;)V #scheduleSave -public net.minecraft.world.server.ChunkManager field_219251_e #loadedChunks -public net.minecraft.world.server.ChunkManager field_219262_p #immutableLoadedChunksDirty -public net.minecraft.world.server.ChunkManager field_219253_g #chunksToUnload +public net.minecraft.server.level.ChunkMap m_140181_(JLnet/minecraft/server/level/ChunkHolder;)V #scheduleSave +public net.minecraft.server.level.ChunkMap f_140129_ #loadedChunks +public net.minecraft.server.level.ChunkMap f_140140_ #immutableLoadedChunksDirty +public net.minecraft.server.level.ChunkMap f_140131_ #chunksToUnload # ChunkStatus -public-f net.minecraft.world.chunk.ChunkStatus field_222617_m #FULL -public net.minecraft.world.chunk.ChunkStatus$IGenerationWorker -public net.minecraft.world.chunk.ChunkStatus$ILoadingWorker +public-f net.minecraft.world.level.chunk.ChunkStatus f_62326_ #FULL +public net.minecraft.world.level.chunk.ChunkStatus$GenerationTask +public net.minecraft.world.level.chunk.ChunkStatus$LoadingTask # PotionBrewing -public net.minecraft.potion.PotionBrewing field_185215_c # POTION_ITEMS +public net.minecraft.world.item.alchemy.PotionBrewing f_43496_ # POTION_ITEMS -public net.minecraft.client.gui.FontRenderer func_238419_a_(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/gui/fonts/Font; # getFontStorage -protected net.minecraft.entity.Entity func_226266_a_(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/Entity$IMoveCallback;)V # updatePassengerPosition -public net.minecraft.world.server.ChunkManager field_219266_t # field_219266_t -public net.minecraft.world.biome.BiomeManager field_226833_b_ # seed +public net.minecraft.client.gui.Font m_92863_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/gui/font/FontSet; # getFontStorage +protected net.minecraft.world.entity.Entity m_19956_(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Entity$MoveFunction;)V # updatePassengerPosition +public net.minecraft.server.level.ChunkMap f_140144_ # field_219266_t +public net.minecraft.world.level.biome.BiomeManager f_47863_ # seed -public net.minecraft.client.renderer.ItemRenderer field_175057_n # textureManager +public net.minecraft.client.renderer.entity.ItemRenderer f_115096_ # textureManager # Beacon -public net.minecraft.tileentity.BeaconTileEntity field_174909_f # beamSegments +public net.minecraft.world.level.block.entity.BeaconBlockEntity f_58648_ # beamSegments # Server Tick List (For stopping placed fluids from spilling) -public net.minecraft.world.server.ServerTickList field_205374_d # pendingTickListEntriesHashSet -public net.minecraft.world.server.ServerTickList field_205375_e # pendingTickListEntriesTreeSet +public net.minecraft.world.level.ServerTickList f_47209_ # pendingTickListEntriesHashSet +public net.minecraft.world.level.ServerTickList f_47210_ # pendingTickListEntriesTreeSet # Lightmap information for instanced rendering -public net.minecraft.client.renderer.LightTexture field_205112_c #resourceLocation -public net.minecraft.client.Minecraft field_193996_ah #renderPartialTicksPaused +public net.minecraft.client.renderer.LightTexture f_109872_ #resourceLocation +public net.minecraft.client.Minecraft f_91013_ #renderPartialTicksPaused # Functions needed to setup a projection matrix -public net.minecraft.client.renderer.GameRenderer field_78529_t #rendererUpdateCount -public net.minecraft.client.renderer.GameRenderer func_228380_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V #bobViewWhenHurt -public net.minecraft.client.renderer.GameRenderer func_228383_b_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V #bobView +public net.minecraft.client.renderer.GameRenderer f_109065_ #rendererUpdateCount +public net.minecraft.client.renderer.GameRenderer m_109117_(Lcom/mojang/blaze3d/vertex/PoseStack;F)V #bobViewWhenHurt +public net.minecraft.client.renderer.GameRenderer m_109138_(Lcom/mojang/blaze3d/vertex/PoseStack;F)V #bobView # Expose fog state to the public public com.mojang.blaze3d.platform.GlStateManager$FogState -public com.mojang.blaze3d.platform.GlStateManager field_225663_h_ #FOG +public com.mojang.blaze3d.platform.GlStateManager f_84068_ #FOG public com.mojang.blaze3d.platform.GlStateManager$BooleanState -public com.mojang.blaze3d.platform.GlStateManager$BooleanState field_179201_b #field_179201_b +public com.mojang.blaze3d.platform.GlStateManager$BooleanState f_84586_ #field_179201_b # GameRenderer -public net.minecraft.client.renderer.GameRenderer func_215311_a(Lnet/minecraft/client/renderer/ActiveRenderInfo;FZ)D #getFOVModifier +public net.minecraft.client.renderer.GameRenderer m_109141_(Lnet/minecraft/client/Camera;FZ)D #getFOVModifier # FirstPersonRenderer -public net.minecraft.client.renderer.FirstPersonRenderer field_187467_d # itemStackMainHand -public net.minecraft.client.renderer.FirstPersonRenderer field_187468_e # itemStackOffHand +public net.minecraft.client.renderer.ItemInHandRenderer f_109300_ # itemStackMainHand +public net.minecraft.client.renderer.ItemInHandRenderer f_109301_ # itemStackOffHand # EntityRendererManager -public net.minecraft.client.renderer.entity.EntityRendererManager field_178637_m # playerRenderer +public net.minecraft.client.renderer.entity.EntityRenderDispatcher f_114364_ # playerRenderer # IResizeCallback -public net.minecraft.util.palette.IResizeCallback +public net.minecraft.world.level.chunk.PaletteResize # Entity -public net.minecraft.entity.Entity func_205011_p()V # updateAquatics -public net.minecraft.entity.Entity field_70122_E #onGround +public net.minecraft.world.entity.Entity func_205011_p()V # updateAquatics +public net.minecraft.world.entity.Entity f_19861_ #onGround # For uploading matrices as vertex attributes. -public net.minecraft.util.math.vector.Matrix3f field_226097_a_ #a00 -public net.minecraft.util.math.vector.Matrix3f field_226098_b_ #a01 -public net.minecraft.util.math.vector.Matrix3f field_226099_c_ #a02 -public net.minecraft.util.math.vector.Matrix3f field_226100_d_ #a10 -public net.minecraft.util.math.vector.Matrix3f field_226101_e_ #a11 -public net.minecraft.util.math.vector.Matrix3f field_226102_f_ #a12 -public net.minecraft.util.math.vector.Matrix3f field_226103_g_ #a20 -public net.minecraft.util.math.vector.Matrix3f field_226104_h_ #a21 -public net.minecraft.util.math.vector.Matrix3f field_226105_i_ #a22 +public com.mojang.math.Matrix3f f_8134_ #a00 +public com.mojang.math.Matrix3f f_8135_ #a01 +public com.mojang.math.Matrix3f f_8136_ #a02 +public com.mojang.math.Matrix3f f_8137_ #a10 +public com.mojang.math.Matrix3f f_8138_ #a11 +public com.mojang.math.Matrix3f f_8139_ #a12 +public com.mojang.math.Matrix3f f_8140_ #a20 +public com.mojang.math.Matrix3f f_8141_ #a21 +public com.mojang.math.Matrix3f f_8142_ #a22 -public net.minecraft.util.math.vector.Matrix4f field_226575_a_ #a00 -public net.minecraft.util.math.vector.Matrix4f field_226576_b_ #a01 -public net.minecraft.util.math.vector.Matrix4f field_226577_c_ #a02 -public net.minecraft.util.math.vector.Matrix4f field_226578_d_ #a03 -public net.minecraft.util.math.vector.Matrix4f field_226579_e_ #a10 -public net.minecraft.util.math.vector.Matrix4f field_226580_f_ #a11 -public net.minecraft.util.math.vector.Matrix4f field_226581_g_ #a12 -public net.minecraft.util.math.vector.Matrix4f field_226582_h_ #a13 -public net.minecraft.util.math.vector.Matrix4f field_226583_i_ #a20 -public net.minecraft.util.math.vector.Matrix4f field_226584_j_ #a21 -public net.minecraft.util.math.vector.Matrix4f field_226585_k_ #a22 -public net.minecraft.util.math.vector.Matrix4f field_226586_l_ #a23 -public net.minecraft.util.math.vector.Matrix4f field_226587_m_ #a30 -public net.minecraft.util.math.vector.Matrix4f field_226588_n_ #a31 -public net.minecraft.util.math.vector.Matrix4f field_226589_o_ #a32 -public net.minecraft.util.math.vector.Matrix4f field_226590_p_ #a33 +public com.mojang.math.Matrix4f f_27603_ #a00 +public com.mojang.math.Matrix4f f_27604_ #a01 +public com.mojang.math.Matrix4f f_27605_ #a02 +public com.mojang.math.Matrix4f f_27606_ #a03 +public com.mojang.math.Matrix4f f_27607_ #a10 +public com.mojang.math.Matrix4f f_27608_ #a11 +public com.mojang.math.Matrix4f f_27609_ #a12 +public com.mojang.math.Matrix4f f_27610_ #a13 +public com.mojang.math.Matrix4f f_27611_ #a20 +public com.mojang.math.Matrix4f f_27612_ #a21 +public com.mojang.math.Matrix4f f_27613_ #a22 +public com.mojang.math.Matrix4f f_27614_ #a23 +public com.mojang.math.Matrix4f f_27615_ #a30 +public com.mojang.math.Matrix4f f_27616_ #a31 +public com.mojang.math.Matrix4f f_27617_ #a32 +public com.mojang.math.Matrix4f f_27618_ #a33 -public net.minecraft.client.renderer.WorldRenderer field_228407_B_ #blockBreakingProgressions +public net.minecraft.client.renderer.LevelRenderer f_109409_ #blockBreakingProgressions \ No newline at end of file