Merge branch 'mc1.20.1/feature-dev' into mc1.21.1/dev

# Conflicts:
#	src/generated/resources/.cache/82992cbf8f2794d83ac94034835eac0acd7915b9
#	src/generated/resources/.cache/dc4224e5ed0ee367217e022442da0b7476174a87
#	src/generated/resources/data/create/recipe/crafting/logistics/packager.json
#	src/main/java/com/simibubi/create/content/contraptions/AbstractContraptionEntity.java
#	src/main/java/com/simibubi/create/content/contraptions/Contraption.java
#	src/main/java/com/simibubi/create/content/contraptions/ContraptionHandlerClient.java
#	src/main/java/com/simibubi/create/content/contraptions/ControlledContraptionEntity.java
#	src/main/java/com/simibubi/create/content/contraptions/OrientedContraptionEntity.java
#	src/main/java/com/simibubi/create/content/contraptions/actors/trainControls/ControlsHandler.java
#	src/main/java/com/simibubi/create/content/contraptions/gantry/GantryCarriageBlock.java
#	src/main/java/com/simibubi/create/content/contraptions/gantry/GantryContraptionEntity.java
#	src/main/java/com/simibubi/create/content/contraptions/minecart/capability/MinecartController.java
#	src/main/java/com/simibubi/create/content/contraptions/mounted/MinecartContraptionItem.java
#	src/main/java/com/simibubi/create/content/contraptions/piston/PistonExtensionPoleBlock.java
#	src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyBlock.java
#	src/main/java/com/simibubi/create/content/contraptions/render/ContraptionVisual.java
#	src/main/java/com/simibubi/create/content/contraptions/sync/ContraptionInteractionPacket.java
#	src/main/java/com/simibubi/create/content/contraptions/sync/ContraptionSeatMappingPacket.java
#	src/main/java/com/simibubi/create/content/decoration/copycat/CopycatBarsModel.java
#	src/main/java/com/simibubi/create/content/equipment/bell/BasicParticleData.java
#	src/main/java/com/simibubi/create/content/equipment/blueprint/BlueprintAssignCompleteRecipePacket.java
#	src/main/java/com/simibubi/create/content/equipment/blueprint/BlueprintEntity.java
#	src/main/java/com/simibubi/create/content/equipment/blueprint/BlueprintItem.java
#	src/main/java/com/simibubi/create/content/equipment/blueprint/BlueprintMenu.java
#	src/main/java/com/simibubi/create/content/equipment/blueprint/BlueprintOverlayRenderer.java
#	src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem.java
#	src/main/java/com/simibubi/create/content/equipment/potatoCannon/BuiltinPotatoProjectileTypes.java
#	src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoProjectileEntity.java
#	src/main/java/com/simibubi/create/content/equipment/sandPaper/SandPaperItem.java
#	src/main/java/com/simibubi/create/content/equipment/symmetryWand/SymmetryWandItem.java
#	src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxBlockEntity.java
#	src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxDisposeAllPacket.java
#	src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxEquipPacket.java
#	src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxHandler.java
#	src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxMenu.java
#	src/main/java/com/simibubi/create/content/equipment/wrench/WrenchEventHandler.java
#	src/main/java/com/simibubi/create/content/equipment/wrench/WrenchItem.java
#	src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainBlock.java
#	src/main/java/com/simibubi/create/content/fluids/particle/FluidParticleData.java
#	src/main/java/com/simibubi/create/content/fluids/pump/PumpBlockEntity.java
#	src/main/java/com/simibubi/create/content/fluids/tank/FluidTankBlock.java
#	src/main/java/com/simibubi/create/content/fluids/transfer/FluidDrainingBehaviour.java
#	src/main/java/com/simibubi/create/content/kinetics/base/RotationIndicatorParticleData.java
#	src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java
#	src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java
#	src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltCrusherInteractionHandler.java
#	src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltFunnelInteractionHandler.java
#	src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltTunnelInteractionHandler.java
#	src/main/java/com/simibubi/create/content/kinetics/crafter/ConnectedInputHandler.java
#	src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankBlockEntity.java
#	src/main/java/com/simibubi/create/content/kinetics/crusher/CrushingWheelControllerBlockEntity.java
#	src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerFakePlayer.java
#	src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerHandler.java
#	src/main/java/com/simibubi/create/content/kinetics/fan/AirFlowParticleData.java
#	src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java
#	src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmPlacementPacket.java
#	src/main/java/com/simibubi/create/content/kinetics/millstone/MillstoneBlock.java
#	src/main/java/com/simibubi/create/content/kinetics/saw/SawBlockEntity.java
#	src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogwheelBlock.java
#	src/main/java/com/simibubi/create/content/kinetics/steamEngine/SteamJetParticleData.java
#	src/main/java/com/simibubi/create/content/kinetics/transmission/sequencer/SequencedGearshiftBlock.java
#	src/main/java/com/simibubi/create/content/legacy/ChromaticCompoundItem.java
#	src/main/java/com/simibubi/create/content/logistics/box/PackageEntity.java
#	src/main/java/com/simibubi/create/content/logistics/box/PackageItem.java
#	src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBehaviour.java
#	src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelConnection.java
#	src/main/java/com/simibubi/create/content/logistics/funnel/AbstractFunnelBlock.java
#	src/main/java/com/simibubi/create/content/logistics/packager/PackagerBlock.java
#	src/main/java/com/simibubi/create/content/logistics/packager/PackagerBlockEntity.java
#	src/main/java/com/simibubi/create/content/logistics/tableCloth/ShoppingListItem.java
#	src/main/java/com/simibubi/create/content/logistics/tunnel/BrassTunnelBlock.java
#	src/main/java/com/simibubi/create/content/logistics/vault/ItemVaultBlock.java
#	src/main/java/com/simibubi/create/content/processing/basin/BasinBlock.java
#	src/main/java/com/simibubi/create/content/processing/basin/BasinRecipe.java
#	src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerBlock.java
#	src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerHandler.java
#	src/main/java/com/simibubi/create/content/processing/sequenced/SequencedAssemblyRecipe.java
#	src/main/java/com/simibubi/create/content/processing/sequenced/SequencedRecipe.java
#	src/main/java/com/simibubi/create/content/redstone/displayLink/DisplayLinkBlockEntity.java
#	src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java
#	src/main/java/com/simibubi/create/content/trains/CubeParticleData.java
#	src/main/java/com/simibubi/create/content/trains/display/FlapDisplayBlock.java
#	src/main/java/com/simibubi/create/content/trains/schedule/ScheduleItem.java
#	src/main/java/com/simibubi/create/content/trains/schedule/ScheduleItemEntityInteraction.java
#	src/main/java/com/simibubi/create/content/trains/station/GlobalStation.java
#	src/main/java/com/simibubi/create/content/trains/track/TrackBlockItem.java
#	src/main/java/com/simibubi/create/content/trains/track/TrackModel.java
#	src/main/java/com/simibubi/create/content/trains/track/TrackPlacement.java
#	src/main/java/com/simibubi/create/foundation/block/render/ReducedDestroyEffects.java
#	src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java
#	src/main/java/com/simibubi/create/foundation/item/ItemHelper.java
#	src/main/java/com/simibubi/create/foundation/particle/AirParticleData.java
#	src/main/java/com/simibubi/create/foundation/particle/ICustomParticleData.java
#	src/main/java/com/simibubi/create/foundation/particle/ICustomParticleDataWithSprite.java
#	src/main/java/com/simibubi/create/infrastructure/command/HighlightCommand.java
This commit is contained in:
IThundxr 2025-02-13 14:52:42 -05:00
commit 0bcc9a50a7
Failed to generate hash of commit
162 changed files with 1230 additions and 1246 deletions

View file

@ -1,4 +1,4 @@
// 1.21.1 2025-02-07T16:00:29.940743506 Create's Standard Recipes
// 1.21.1 2025-02-13T14:54:49.107068454 Create's Standard Recipes
489f0a3e3d8571c4897f49eada95a23290a472dc data/create/advancement/recipes/combat/crafting/appliances/netherite_backtank.json
b024ae44179c47b9be8fa35acc763c22b7b01b2e data/create/advancement/recipes/combat/crafting/appliances/netherite_backtank_from_netherite.json
41d2909fcf45f9098c0ee306810c16168d4e8ae4 data/create/advancement/recipes/combat/crafting/appliances/netherite_diving_boots.json
@ -467,7 +467,7 @@ d439c719d4091a68a77138efa47ce353cb7e6b8a data/create/recipe/crafting/logistics/d
7b09481688982f7b1f78550db94736c91da4364e data/create/recipe/crafting/logistics/factory_gauge_clear.json
28295e21a01b3e28a8b6b4d8e803b82e5520b008 data/create/recipe/crafting/logistics/item_hatch.json
d08ad62fbc754be2f73f4fd4652a992864f602da data/create/recipe/crafting/logistics/package_frogport.json
5dacf1011f4f856c336ea82953d35e488ff89c30 data/create/recipe/crafting/logistics/packager.json
4785e7a3830d18aee2dc3db2013b79b99b74e05e data/create/recipe/crafting/logistics/packager.json
1500607d23fede3c0cc81b84de772f136c17e445 data/create/recipe/crafting/logistics/packager_from_conversion.json
c58be916b2f7cb728d182b0d4ad3a66bbdb36b75 data/create/recipe/crafting/logistics/powered_latch.json
3fe7cd194a137bc1ceafb4169463c1c6929e3b49 data/create/recipe/crafting/logistics/powered_toggle_latch.json

View file

@ -1,4 +1,4 @@
// 1.21.1 2025-02-07T16:00:29.904603492 Registrate Provider for create [Registries, Data Maps, Recipes, Advancements, Loot Tables, Tags (enchantments), Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), generic_server_provider, Blockstates, Item models, Lang (en_us/en_ud), generic_client_provider]
// 1.21.1 2025-02-13T14:54:49.082344099 Registrate Provider for create [Registries, Data Maps, Recipes, Advancements, Loot Tables, Tags (enchantments), Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), generic_server_provider, Blockstates, Item models, Lang (en_us/en_ud), generic_client_provider]
60bbdf92d2ac9824ea6144955c74043a6005f79d assets/create/blockstates/acacia_window.json
6a67703c2697d81b7dc83e9d72a66f9c9ff08383 assets/create/blockstates/acacia_window_pane.json
c3ae87b62e81d8e9476eccd793bb1548d74c66a1 assets/create/blockstates/adjustable_chain_gearshift.json
@ -642,8 +642,8 @@ b0d8f08968763a5f74e5cd5644377a76a9f39753 assets/create/blockstates/yellow_toolbo
fe8c497aacc641c2f01cec90bba9f19e59cc2ed2 assets/create/blockstates/yellow_valve_handle.json
e819e93fdcbe9fd9c050a052d2718ff3b3539365 assets/create/blockstates/zinc_block.json
64121dcb216381c83b4fe28aa361ea07c24c9ad0 assets/create/blockstates/zinc_ore.json
99c03ec65894ea7d88e3346c5e0c086a7acec6af assets/create/lang/en_ud.json
5f0262b9f6c1139659f6dab4d9c371be50503c0b assets/create/lang/en_us.json
443742f2bb4fc520ec7db483fd22425884cb95be assets/create/lang/en_ud.json
282779fe7ecc64cd99c08e3a7397646af9f500c4 assets/create/lang/en_us.json
a97e1060e00ae701a02e39cd4ef8054cf345fac4 assets/create/models/block/acacia_window.json
103e032c0b1a0a6a27c67da8c91179a564bd281c assets/create/models/block/acacia_window_pane_noside.json
fb00b627abda76ad4fea867ca57dbfadd24fffa3 assets/create/models/block/acacia_window_pane_noside_alt.json

View file

@ -1580,6 +1580,7 @@
"create.package_port.cannot_reach_down": "pɹɐʍuʍop ʇɔǝuuoɔ ʇouuɐƆ",
"create.package_port.too_far": "ʎɐʍɐ ɹɐɟ oo⟘",
"create.package_port.valid": "✔ ʇɔǝuuoƆ uɐƆ",
"create.packager.no_portable_storage": ןʇɔǝɹıp ǝbɐɹoʇS ǝןqɐʇɹoԀ ɥʇıʍ ǝɔɐɟɹǝʇuı ʇouuɐɔ sɹǝbɐʞɔɐԀ",
"create.packager_link.clear": "uoıʇɔǝןǝs pǝɹɐǝןƆ",
"create.packager_link.set": "pǝʇɔǝןǝs ʇǝbɹɐ⟘",
"create.packager_link.success": "ʇǝbɹɐʇ oʇ punoq ʎןןnɟssǝɔɔnS",

View file

@ -1580,6 +1580,7 @@
"create.package_port.cannot_reach_down": "Cannot connect downward",
"create.package_port.too_far": "Too far away",
"create.package_port.valid": "Can Connect ✔",
"create.packager.no_portable_storage": "Packagers cannot interface with Portable Storage directly",
"create.packager_link.clear": "Cleared selection",
"create.packager_link.set": "Target selected",
"create.packager_link.success": "Successfully bound to target",

View file

@ -7,12 +7,15 @@
},
"C": {
"tag": "c:ingots/iron"
},
"R": {
"tag": "c:dusts/redstone"
}
},
"pattern": [
" C ",
"CAC",
" C "
"RCR"
],
"result": {
"count": 1,

View file

@ -258,7 +258,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
return true;
return contraption.getSeatMapping()
.size() < contraption.getSeats()
.size();
.size();
}
public Component getContraptionName() {
@ -289,7 +289,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
public boolean handlePlayerInteraction(Player player, BlockPos localPos, Direction side,
InteractionHand interactionHand) {
InteractionHand interactionHand) {
int indexOfSeat = contraption.getSeats()
.indexOf(localPos);
if (indexOfSeat == -1 || AllItems.WRENCH.isIn(player.getItemInHand(interactionHand))) {
@ -483,11 +483,10 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
skipActorStop = false;
for (Entity entity : getPassengers()) {
if (!(entity instanceof OrientedContraptionEntity))
if (!(entity instanceof OrientedContraptionEntity orientedCE))
continue;
if (!contraption.stabilizedSubContraptions.containsKey(entity.getUUID()))
continue;
OrientedContraptionEntity orientedCE = (OrientedContraptionEntity) entity;
if (orientedCE.contraption != null && orientedCE.contraption.stalled) {
contraption.stalled = true;
break;
@ -524,7 +523,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
protected boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor,
Vec3 actorPosition, BlockPos gridPosition) {
Vec3 actorPosition, BlockPos gridPosition) {
Vec3 previousPosition = context.position;
if (previousPosition == null)
return false;
@ -730,7 +729,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
@Override
protected void doWaterSplashEffect() {}
protected void doWaterSplashEffect() {
}
public Contraption getContraption() {
return contraption;
@ -797,7 +797,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
@Override
// Make sure nothing can move contraptions out of the way
public void setDeltaMovement(Vec3 motionIn) {}
public void setDeltaMovement(Vec3 motionIn) {
}
@Override
public PushReaction getPistonPushReaction() {

View file

@ -92,7 +92,6 @@ import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag;
import net.minecraft.network.protocol.game.DebugPackets;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ai.village.poi.PoiTypes;
@ -104,11 +103,11 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.DoorBlock;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.PressurePlateBlock;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
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.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.ChestType;
@ -209,7 +208,7 @@ public abstract class Contraption {
}
protected boolean addToInitialFrontier(Level world, BlockPos pos, Direction forcedDirection,
Queue<BlockPos> frontier) throws AssemblyException {
Queue<BlockPos> frontier) throws AssemblyException {
return true;
}
@ -300,9 +299,11 @@ public abstract class Contraption {
}
}
/** move the first block in frontier queue */
/**
* move the first block in frontier queue
*/
protected boolean moveBlock(Level world, @Nullable Direction forcedDirection, Queue<BlockPos> frontier,
Set<BlockPos> visited) throws AssemblyException {
Set<BlockPos> visited) throws AssemblyException {
BlockPos pos = frontier.poll();
if (pos == null)
return false;
@ -326,7 +327,7 @@ public abstract class Contraption {
if (AllBlocks.BELT.has(state))
moveBelt(pos, frontier, visited, state);
if (AllBlocks.WINDMILL_BEARING.has(state) && world.getBlockEntity(pos)instanceof WindmillBearingBlockEntity wbbe)
if (AllBlocks.WINDMILL_BEARING.has(state) && world.getBlockEntity(pos) instanceof WindmillBearingBlockEntity wbbe)
wbbe.disassembleForMovement();
if (AllBlocks.GANTRY_CARRIAGE.has(state))
@ -356,7 +357,7 @@ public abstract class Contraption {
}
// Bogeys tend to have sticky sides
if (state.getBlock()instanceof AbstractBogeyBlock<?> bogey)
if (state.getBlock() instanceof AbstractBogeyBlock<?> bogey)
for (Direction d : bogey.getStickySurfaces(world, pos, state))
if (!visited.contains(pos.relative(d)))
frontier.add(pos.relative(d));
@ -436,7 +437,7 @@ public abstract class Contraption {
}
protected void movePistonHead(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
BlockState state) {
BlockState state) {
Direction direction = state.getValue(MechanicalPistonHeadBlock.FACING);
BlockPos offset = pos.relative(direction.getOpposite());
if (!visited.contains(offset)) {
@ -459,7 +460,7 @@ public abstract class Contraption {
}
protected void movePistonPole(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
BlockState state) {
BlockState state) {
for (Direction d : Iterate.directionsInAxis(state.getValue(PistonExtensionPoleBlock.FACING)
.getAxis())) {
BlockPos offset = pos.relative(d);
@ -482,7 +483,7 @@ public abstract class Contraption {
}
protected void moveGantryPinion(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
BlockState state) {
BlockState state) {
BlockPos offset = pos.relative(state.getValue(GantryCarriageBlock.FACING));
if (!visited.contains(offset))
frontier.add(offset);
@ -498,7 +499,7 @@ public abstract class Contraption {
}
protected void moveGantryShaft(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
BlockState state) {
BlockState state) {
for (Direction d : Iterate.directions) {
BlockPos offset = pos.relative(d);
if (!visited.contains(offset)) {
@ -572,7 +573,7 @@ public abstract class Contraption {
}
private boolean moveMechanicalPiston(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited,
BlockState state) throws AssemblyException {
BlockState state) throws AssemblyException {
Direction direction = state.getValue(MechanicalPistonBlock.FACING);
PistonState pistonState = state.getValue(MechanicalPistonBlock.STATE);
if (pistonState == PistonState.MOVING)
@ -596,11 +597,10 @@ public abstract class Contraption {
}
private boolean moveChassis(Level world, BlockPos pos, Direction movementDirection, Queue<BlockPos> frontier,
Set<BlockPos> visited) {
Set<BlockPos> visited) {
BlockEntity be = world.getBlockEntity(pos);
if (!(be instanceof ChassisBlockEntity))
if (!(be instanceof ChassisBlockEntity chassis))
return false;
ChassisBlockEntity chassis = (ChassisBlockEntity) be;
chassis.addAttachedChasses(frontier, visited);
List<BlockPos> includedBlockPositions = chassis.getIncludedBlockPositions(movementDirection, false);
if (includedBlockPositions == null)
@ -653,9 +653,8 @@ public abstract class Contraption {
if (be != null) {
CompoundTag updateTag = be.getUpdateTag(level.registryAccess());
// the ID needs to be in the tag so the client can properly add the BlockEntity
ResourceLocation id = Objects.requireNonNull(BlockEntityType.getKey(be.getType()));
updateTag.putString("id", id.toString());
// empty tags are intentionally kept, see writeBlocksCompound
// for testing, this line can be commented to emulate legacy behavior
updateTags.put(localPos, updateTag);
}
@ -672,8 +671,8 @@ public abstract class Contraption {
if (be instanceof CreativeCrateBlockEntity
&& ((CreativeCrateBlockEntity) be).getBehaviour(FilteringBehaviour.TYPE)
.getFilter()
.isEmpty())
.getFilter()
.isEmpty())
hasUniversalCreativeCrate = true;
}
@ -734,11 +733,11 @@ public abstract class Contraption {
capturedMultiblocks.clear();
nbt.getList("CapturedMultiblocks", Tag.TAG_COMPOUND).forEach(c -> {
CompoundTag tag = (CompoundTag) c;
if (!tag.contains("Controller", Tag.TAG_COMPOUND) && !tag.contains("Parts", Tag.TAG_LIST))
return;
CompoundTag tag = (CompoundTag) c;
if (!tag.contains("Controller", Tag.TAG_COMPOUND) && !tag.contains("Parts", Tag.TAG_LIST))
return;
BlockPos controllerPos = NBTHelper.readBlockPos(tag, "Controller");
BlockPos controllerPos = NBTHelper.readBlockPos(tag, "Controller");
tag.getList("Parts", Tag.TAG_COMPOUND)
.forEach(part -> {
CompoundTag cPart = (CompoundTag) part;
@ -918,10 +917,12 @@ public abstract class Contraption {
// for client sync, treat the updateTag as the data
if (updateTag != null) {
c.put("Data", updateTag);
}
// legacy: use full data if update tag is not available
if (updateTag == null && block.nbt() != null) {
} else if (block.nbt() != null) {
// an updateTag is saved for all BlockEntities, even when empty.
// this case means that the contraption was assembled pre-updateTags.
// in this case, we need to use the full BlockEntity data.
c.put("Data", block.nbt());
NBTHelper.putMarker(c, "Legacy");
}
} else {
// otherwise, write actual data as the data, save updateTag on its own
@ -976,29 +977,17 @@ public abstract class Contraption {
if (c.contains("UpdateTag", Tag.TAG_COMPOUND)) {
CompoundTag updateTag = c.getCompound("UpdateTag");
if (!updateTag.isEmpty()) {
this.updateTags.put(info.pos(), updateTag);
}
// it's very important that empty tags are read here. see writeBlocksCompound
this.updateTags.put(info.pos(), updateTag);
}
if (!world.isClientSide)
return;
CompoundTag tag = info.nbt();
if (tag == null)
return;
tag.putInt("x", info.pos().getX());
tag.putInt("y", info.pos().getY());
tag.putInt("z", info.pos().getZ());
BlockEntity be = BlockEntity.loadStatic(info.pos(), info.state(), tag, world.registryAccess());
// create the BlockEntity client-side for rendering
BlockEntity be = readBlockEntity(world, info, c);
if (be == null)
return;
be.setLevel(world);
if (be instanceof KineticBlockEntity kbe)
kbe.setSpeed(0);
be.getBlockState();
presentBlockEntities.put(info.pos(), be);
modelData.put(info.pos(), be.getModelData());
@ -1010,8 +999,49 @@ public abstract class Contraption {
});
}
@Nullable
private static BlockEntity readBlockEntity(Level level, StructureBlockInfo info, CompoundTag tag) {
BlockState state = info.state();
BlockPos pos = info.pos();
CompoundTag nbt = info.nbt();
if (tag.contains("Legacy")) {
// for contraptions that were assembled pre-updateTags, we need to use the old strategy.
if (nbt == null)
return null;
nbt.putInt("x", pos.getX());
nbt.putInt("y", pos.getY());
nbt.putInt("z", pos.getZ());
BlockEntity be = BlockEntity.loadStatic(pos, state, nbt, level.registryAccess());
postprocessReadBlockEntity(level, be);
return be;
}
if (!state.hasBlockEntity() || !(state.getBlock() instanceof EntityBlock entityBlock))
return null;
BlockEntity be = entityBlock.newBlockEntity(pos, state);
postprocessReadBlockEntity(level, be);
if (be != null && nbt != null) {
be.handleUpdateTag(nbt, level.registryAccess());
}
return be;
}
private static void postprocessReadBlockEntity(Level level, @Nullable BlockEntity be) {
if (be != null) {
be.setLevel(level);
if (be instanceof KineticBlockEntity kbe) {
kbe.setSpeed(0);
}
}
}
private static StructureBlockInfo readStructureBlockInfo(CompoundTag blockListEntry,
HashMapPalette<BlockState> palette) {
HashMapPalette<BlockState> palette) {
return new StructureBlockInfo(BlockPos.of(blockListEntry.getLong("Pos")),
Objects.requireNonNull(palette.valueFor(blockListEntry.getInt("State"))),
blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null);
@ -1037,7 +1067,7 @@ public abstract class Contraption {
for (boolean brittles : Iterate.trueAndFalse) {
for (Iterator<StructureBlockInfo> iterator = blocks.values()
.iterator(); iterator.hasNext();) {
.iterator(); iterator.hasNext(); ) {
StructureBlockInfo block = iterator.next();
if (brittles != BlockMovementChecks.isBrittle(block.state()))
continue;
@ -1142,7 +1172,7 @@ public abstract class Contraption {
if (blockState.getDestroySpeed(world, targetPos) == -1 || (state.getCollisionShape(world, targetPos)
.isEmpty()
&& !blockState.getCollisionShape(world, targetPos)
.isEmpty())) {
.isEmpty())) {
if (targetPos.getY() == world.getMinBuildHeight())
targetPos = targetPos.above();
world.levelEvent(2001, targetPos, Block.getId(state));
@ -1163,7 +1193,7 @@ public abstract class Contraption {
state = state.setValue(SlidingDoorBlock.VISIBLE, !state.getValue(SlidingDoorBlock.OPEN))
.setValue(SlidingDoorBlock.POWERED, false);
// Stop Sculk shriekers from getting "stuck" if moved mid-shriek.
if(state.is(Blocks.SCULK_SHRIEKER)){
if (state.is(Blocks.SCULK_SHRIEKER)) {
state = Blocks.SCULK_SHRIEKER.defaultBlockState();
}
@ -1182,7 +1212,7 @@ public abstract class Contraption {
CompoundTag tag = block.nbt();
// Temporary fix: Calling load(CompoundTag tag) on a Sculk sensor causes it to not react to vibrations.
if(state.is(Blocks.SCULK_SENSOR) || state.is(Blocks.SCULK_SHRIEKER))
if (state.is(Blocks.SCULK_SENSOR) || state.is(Blocks.SCULK_SHRIEKER))
tag = null;
if (blockEntity != null)
@ -1449,19 +1479,19 @@ public abstract class Contraption {
simplifiedEntityColliderProvider.cancel(false);
}
simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> {
VoxelShape combinedShape = Shapes.empty();
for (Entry<BlockPos, StructureBlockInfo> entry : blocks.entrySet()) {
StructureBlockInfo info = entry.getValue();
BlockPos localPos = entry.getKey();
VoxelShape collisionShape = info.state().getCollisionShape(world, localPos, CollisionContext.empty());
if (collisionShape.isEmpty())
continue;
combinedShape = Shapes.joinUnoptimized(combinedShape,
collisionShape.move(localPos.getX(), localPos.getY(), localPos.getZ()), BooleanOp.OR);
}
return combinedShape.optimize()
.toAabbs();
})
VoxelShape combinedShape = Shapes.empty();
for (Entry<BlockPos, StructureBlockInfo> entry : blocks.entrySet()) {
StructureBlockInfo info = entry.getValue();
BlockPos localPos = entry.getKey();
VoxelShape collisionShape = info.state().getCollisionShape(world, localPos, CollisionContext.empty());
if (collisionShape.isEmpty())
continue;
combinedShape = Shapes.joinUnoptimized(combinedShape,
collisionShape.move(localPos.getX(), localPos.getY(), localPos.getZ()), BooleanOp.OR);
}
return combinedShape.optimize()
.toAabbs();
})
.thenAccept(r -> {
simplifiedEntityColliders = Optional.of(r);
});
@ -1469,12 +1499,12 @@ public abstract class Contraption {
public static float getRadius(Set<BlockPos> blocks, Direction.Axis axis) {
switch (axis) {
case X:
return getMaxDistSqr(blocks, BlockPos::getY, BlockPos::getZ);
case Y:
return getMaxDistSqr(blocks, BlockPos::getX, BlockPos::getZ);
case Z:
return getMaxDistSqr(blocks, BlockPos::getX, BlockPos::getY);
case X:
return getMaxDistSqr(blocks, BlockPos::getY, BlockPos::getZ);
case Y:
return getMaxDistSqr(blocks, BlockPos::getX, BlockPos::getZ);
case Z:
return getMaxDistSqr(blocks, BlockPos::getX, BlockPos::getY);
}
throw new IllegalStateException("Impossible axis");

View file

@ -142,7 +142,7 @@ public class ContraptionCollider {
// Make player 'shorter' to make it less likely to become stuck
if (playerType == PlayerType.CLIENT && entityBounds.getYsize() > 1)
entityBounds = entityBounds.contract(0, 2 / 16f, 0);
motion = motion.subtract(contraptionMotion);
motion = rotationMatrix.transform(motion);
@ -765,15 +765,12 @@ public class ContraptionCollider {
MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state());
if (movementBehaviour != null) {
if (movementBehaviour instanceof BlockBreakingMovementBehaviour) {
BlockBreakingMovementBehaviour behaviour = (BlockBreakingMovementBehaviour) movementBehaviour;
if (movementBehaviour instanceof BlockBreakingMovementBehaviour behaviour) {
if (!behaviour.canBreak(world, colliderPos, collidedState) && !emptyCollider)
return true;
continue;
}
if (movementBehaviour instanceof HarvesterMovementBehaviour) {
HarvesterMovementBehaviour harvesterMovementBehaviour =
(HarvesterMovementBehaviour) movementBehaviour;
if (movementBehaviour instanceof HarvesterMovementBehaviour harvesterMovementBehaviour) {
if (!harvesterMovementBehaviour.isValidCrop(world, colliderPos, collidedState)
&& !harvesterMovementBehaviour.isValidOther(world, colliderPos, collidedState)
&& !emptyCollider)

View file

@ -90,7 +90,7 @@ public class ContraptionHandlerClient {
Collection<WeakReference<AbstractContraptionEntity>> contraptions =
ContraptionHandler.loadedContraptions.get(mc.level)
.values();
double bestDistance = Double.MAX_VALUE;
BlockHitResult bestResult = null;
AbstractContraptionEntity bestEntity = null;
@ -106,23 +106,23 @@ public class ContraptionHandlerClient {
BlockHitResult rayTraceResult = rayTraceContraption(origin, target, contraptionEntity);
if (rayTraceResult == null)
continue;
double distance = contraptionEntity.toGlobalVector(rayTraceResult.getLocation(), 1).distanceTo(origin);
if (distance > bestDistance)
continue;
bestResult = rayTraceResult;
bestDistance = distance;
bestEntity = contraptionEntity;
}
if (bestResult == null)
return;
InteractionHand hand = event.getHand();
Direction face = bestResult.getDirection();
BlockPos pos = bestResult.getBlockPos();
if (bestEntity.handlePlayerInteraction(player, pos, face, hand)) {
CatnipServices.NETWORK.sendToServer(new ContraptionInteractionPacket(bestEntity, hand, pos, face));
} else
@ -133,7 +133,7 @@ public class ContraptionHandlerClient {
}
private static boolean handleSpecialInteractions(AbstractContraptionEntity contraptionEntity, Player player,
BlockPos localPos, Direction side, InteractionHand interactionHand) {
BlockPos localPos, Direction side, InteractionHand interactionHand) {
if (AllItems.WRENCH.isIn(player.getItemInHand(interactionHand))
&& contraptionEntity instanceof CarriageContraptionEntity car)
return TrainRelocator.carriageWrenched(car.toGlobalVector(VecHelper.getCenterOf(localPos), 1), car);
@ -154,7 +154,7 @@ public class ContraptionHandlerClient {
@Nullable
public static BlockHitResult rayTraceContraption(Vec3 origin, Vec3 target,
AbstractContraptionEntity contraptionEntity) {
AbstractContraptionEntity contraptionEntity) {
Vec3 localOrigin = contraptionEntity.toLocalVector(origin, 1);
Vec3 localTarget = contraptionEntity.toLocalVector(target, 1);
Contraption contraption = contraptionEntity.getContraption();

View file

@ -45,7 +45,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
}
public static ControlledContraptionEntity create(Level world, IControlContraption controller,
Contraption contraption) {
Contraption contraption) {
ControlledContraptionEntity entity =
new ControlledContraptionEntity(AllEntityTypes.CONTROLLED_CONTRAPTION.get(), world);
entity.controllerPos = controller.getBlockPosition();
@ -142,12 +142,14 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
}
@Override
public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {}
public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {
}
// Always noop this. Controlled Contraptions are given their position on the client from the BE
@Override
@OnlyIn(Dist.CLIENT)
public void lerpTo(double pX, double pY, double pZ, float pYRot, float pXRot, int pSteps) {}
public void lerpTo(double pX, double pY, double pZ, float pYRot, float pXRot, int pSteps) {
}
protected void tickContraption() {
angleDelta = angle - prevAngle;
@ -172,14 +174,13 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
@Override
protected boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor,
Vec3 actorPosition, BlockPos gridPosition) {
Vec3 actorPosition, BlockPos gridPosition) {
if (super.shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition))
return true;
// Special activation timer for actors in the center of a bearing contraption
if (!(contraption instanceof BearingContraption))
if (!(contraption instanceof BearingContraption bc))
return false;
BearingContraption bc = (BearingContraption) contraption;
Direction facing = bc.getFacing();
Vec3 activeAreaOffset = actor.getActiveAreaOffset(context);
if (!activeAreaOffset.multiply(VecHelper.axisAlingedPlaneOf(Vec3.atLowerCornerOf(facing.getNormal())))
@ -247,10 +248,10 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
if (axis != null) {
TransformStack.of(matrixStack)
.nudge(getId())
.center()
.rotateDegrees(angle, axis)
.uncenter();
.nudge(getId())
.center()
.rotateDegrees(angle, axis)
.uncenter();
}
}
}

View file

@ -97,7 +97,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
}
public static OrientedContraptionEntity createAtYaw(Level world, Contraption contraption,
Direction initialOrientation, float initialYaw) {
Direction initialOrientation, float initialYaw) {
OrientedContraptionEntity entity = create(world, contraption, initialOrientation);
entity.startAtYaw(initialYaw);
entity.manuallyPlaced = true;
@ -257,8 +257,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
boolean rotationLock = false;
boolean pauseWhileRotating = false;
boolean wasStalled = isStalled();
if (contraption instanceof MountedContraption) {
MountedContraption mountedContraption = (MountedContraption) contraption;
if (contraption instanceof MountedContraption mountedContraption) {
rotationLock = mountedContraption.rotationMode == CartMovementMode.ROTATION_LOCKED;
pauseWhileRotating = mountedContraption.rotationMode == CartMovementMode.ROTATE_PAUSED;
}
@ -342,15 +341,13 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
return false;
}
if (contraption instanceof StabilizedContraption) {
if (!(riding instanceof OrientedContraptionEntity))
if (contraption instanceof StabilizedContraption stabilized) {
if (!(riding instanceof OrientedContraptionEntity parent))
return false;
StabilizedContraption stabilized = (StabilizedContraption) contraption;
Direction facing = stabilized.getFacing();
if (facing.getAxis()
.isVertical())
return false;
OrientedContraptionEntity parent = (OrientedContraptionEntity) riding;
prevYaw = yaw;
yaw = AngleHelper.wrapAngle180(getInitialYaw() - parent.getInitialYaw()) - parent.getViewYRot(1);
return false;
@ -369,12 +366,10 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
Vec3 motion = movementVector.normalize();
if (!rotationLock) {
if (riding instanceof AbstractMinecart) {
AbstractMinecart minecartEntity = (AbstractMinecart) riding;
if (riding instanceof AbstractMinecart minecartEntity) {
BlockPos railPosition = minecartEntity.getCurrentRailPosition();
BlockState blockState = level().getBlockState(railPosition);
if (blockState.getBlock() instanceof BaseRailBlock) {
BaseRailBlock abstractRailBlock = (BaseRailBlock) blockState.getBlock();
if (blockState.getBlock() instanceof BaseRailBlock abstractRailBlock) {
RailShape railDirection =
abstractRailBlock.getRailDirection(blockState, level(), railPosition, minecartEntity);
motion = VecHelper.project(motion, MinecartSim2020.getRailVec(railDirection));

View file

@ -44,13 +44,13 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
public boolean isActive(MovementContext context) {
return MovementBehaviour.super.isActive(context)
&& !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(HarvesterBlock.FACING)
.getOpposite());
.getOpposite());
}
@Override
public Vec3 getActiveAreaOffset(MovementContext context) {
return Vec3.atLowerCornerOf(context.state.getValue(HarvesterBlock.FACING)
.getNormal())
.getNormal())
.scale(.45);
}
@ -97,8 +97,7 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
boolean harvestPartial = AllConfigs.server().kinetics.harvestPartiallyGrown.get();
boolean replant = AllConfigs.server().kinetics.harvesterReplants.get();
if (state.getBlock() instanceof CropBlock) {
CropBlock crop = (CropBlock) state.getBlock();
if (state.getBlock() instanceof CropBlock crop) {
if (harvestPartial)
return state != crop.getStateForAge(0) || !replant;
return crop.isMaxAge(state);
@ -107,9 +106,8 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
if (state.getCollisionShape(world, pos)
.isEmpty() || state.getBlock() instanceof CocoaBlock) {
for (Property<?> property : state.getProperties()) {
if (!(property instanceof IntegerProperty))
if (!(property instanceof IntegerProperty ageProperty))
continue;
IntegerProperty ageProperty = (IntegerProperty) property;
if (!property.getName()
.equals(BlockStateProperties.AGE_1.getName()))
continue;
@ -168,8 +166,7 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
}
Block block = state.getBlock();
if (block instanceof CropBlock) {
CropBlock crop = (CropBlock) block;
if (block instanceof CropBlock crop) {
return crop.getStateForAge(0);
}
if (block == Blocks.SWEET_BERRY_BUSH) {
@ -208,15 +205,15 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
@Override
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffers) {
if (!VisualizationManager.supportsVisualization(context.world))
ContraptionMatrices matrices, MultiBufferSource buffers) {
if (!VisualizationManager.supportsVisualization(context.world))
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
}
@Nullable
@Override
public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld,
MovementContext movementContext) {
MovementContext movementContext) {
return new HarvesterActorVisual(visualizationContext, simulationWorld, movementContext);
}

View file

@ -41,7 +41,7 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
public boolean isActive(MovementContext context) {
return super.isActive(context)
&& !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(PloughBlock.FACING)
.getOpposite());
.getOpposite());
}
@Override
@ -86,7 +86,7 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
@Override
public Vec3 getActiveAreaOffset(MovementContext context) {
return Vec3.atLowerCornerOf(context.state.getValue(PloughBlock.FACING)
.getNormal())
.getNormal())
.scale(.45);
}
@ -120,12 +120,11 @@ 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 ServerLevel) {
ServerLevel world = (ServerLevel) context.world;
if (brokenState.getBlock() == Blocks.SNOW && context.world instanceof ServerLevel world) {
brokenState.getDrops(new LootParams.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)))
.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));
}
}

View file

@ -49,7 +49,7 @@ public class RollerBlockEntity extends SmartBlockEntity {
@Override
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
behaviours.add(filtering = new FilteringBehaviour(this, new RollerValueBox(3)));
behaviours.add(mode = new ScrollOptionBehaviour<RollingMode>(RollingMode.class,
behaviours.add(mode = new ScrollOptionBehaviour<>(RollingMode.class,
CreateLang.translateDirect("contraptions.roller_mode"), this, new RollerValueBox(-3)));
filtering.setLabel(CreateLang.translateDirect("contraptions.mechanical_roller.pave_material"));

View file

@ -106,7 +106,7 @@ public class ControlsHandler {
// Keepalive Pressed Keys
if (packetCooldown == 0) {
// if (!pressedKeys.isEmpty()) {
CatnipServices.NETWORK.sendToServer(new ControlsInputPacket(pressedKeys, true, entity.getId(), controlsPos, false));
CatnipServices.NETWORK.sendToServer(new ControlsInputPacket(pressedKeys, true, entity.getId(), controlsPos, false));
packetCooldown = PACKET_RATE;
// }
}

View file

@ -24,7 +24,7 @@ public class ControlsServerHandler {
public static void tick(LevelAccessor world) {
Map<UUID, ControlsContext> map = receivedInputs.get(world);
for (Iterator<Entry<UUID, ControlsContext>> iterator = map.entrySet()
.iterator(); iterator.hasNext();) {
.iterator(); iterator.hasNext(); ) {
Entry<UUID, ControlsContext> entry = iterator.next();
ControlsContext ctx = entry.getValue();
@ -35,7 +35,7 @@ public class ControlsServerHandler {
continue;
}
for (Iterator<ManuallyPressedKey> entryIterator = list.iterator(); entryIterator.hasNext();) {
for (Iterator<ManuallyPressedKey> entryIterator = list.iterator(); entryIterator.hasNext(); ) {
ManuallyPressedKey pressedKey = entryIterator.next();
pressedKey.decrement();
if (!pressedKey.isAlive())
@ -61,7 +61,7 @@ public class ControlsServerHandler {
}
public static void receivePressed(LevelAccessor world, AbstractContraptionEntity entity, BlockPos controlsPos,
UUID uniqueID, Collection<Integer> collect, boolean pressed) {
UUID uniqueID, Collection<Integer> collect, boolean pressed) {
Map<UUID, ControlsContext> map = receivedInputs.get(world);
if (map.containsKey(uniqueID) && map.get(uniqueID).entity != entity)
@ -70,9 +70,9 @@ public class ControlsServerHandler {
ControlsContext ctx = map.computeIfAbsent(uniqueID, $ -> new ControlsContext(entity, controlsPos));
Collection<ManuallyPressedKey> list = ctx.keys;
WithNext: for (Integer activated : collect) {
for (Iterator<ManuallyPressedKey> iterator = list.iterator(); iterator.hasNext();) {
ManuallyPressedKey entry = iterator.next();
WithNext:
for (Integer activated : collect) {
for (ManuallyPressedKey entry : list) {
Integer inputType = entry.getSecond();
if (inputType.equals(activated)) {
if (!pressed)

View file

@ -293,10 +293,9 @@ public class ClockworkBearingBlockEntity extends KineticBlockEntity
@Override
public void attach(ControlledContraptionEntity contraption) {
if (!(contraption.getContraption() instanceof ClockworkContraption))
if (!(contraption.getContraption() instanceof ClockworkContraption cc))
return;
ClockworkContraption cc = (ClockworkContraption) contraption.getContraption();
setChanged();
Direction facing = getBlockState().getValue(BlockStateProperties.FACING);
BlockPos anchor = worldPosition.relative(facing, cc.offset + 1);
@ -382,9 +381,8 @@ public class ClockworkBearingBlockEntity extends KineticBlockEntity
@Override
public boolean isAttachedTo(AbstractContraptionEntity contraption) {
if (!(contraption.getContraption() instanceof ClockworkContraption))
if (!(contraption.getContraption() instanceof ClockworkContraption cc))
return false;
ClockworkContraption cc = (ClockworkContraption) contraption.getContraption();
if (cc.handType == HandType.HOUR)
return this.hourHand == contraption;
else

View file

@ -37,14 +37,16 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour {
public ItemStack canBeDisabledVia(MovementContext context) {
return null;
}
@Override
@Override
public boolean disableBlockEntityRendering() {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
ContraptionMatrices matrices, MultiBufferSource buffer) {
if (VisualizationManager.supportsVisualization(context.world))
return;
@ -79,7 +81,7 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour {
@Nullable
@Override
public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld,
MovementContext movementContext) {
MovementContext movementContext) {
return new StabilizedBearingVisual(visualizationContext, simulationWorld, movementContext);
}
@ -91,13 +93,11 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour {
Direction.Axis axis = facing.getAxis();
AbstractContraptionEntity entity = context.contraption.entity;
if (entity instanceof ControlledContraptionEntity) {
ControlledContraptionEntity controlledCE = (ControlledContraptionEntity) entity;
if (entity instanceof ControlledContraptionEntity controlledCE) {
if (context.contraption.canBeStabilized(facing, context.localPos))
offset = -controlledCE.getAngle(renderPartialTicks);
} else if (entity instanceof OrientedContraptionEntity) {
OrientedContraptionEntity orientedCE = (OrientedContraptionEntity) entity;
} else if (entity instanceof OrientedContraptionEntity orientedCE) {
if (axis.isVertical())
offset = -orientedCE.getViewYRot(renderPartialTicks);
else {

View file

@ -109,8 +109,7 @@ public class ChassisBlockEntity extends SmartBlockEntity {
continue;
visited.add(current);
BlockEntity blockEntity = level.getBlockEntity(current);
if (blockEntity instanceof ChassisBlockEntity) {
ChassisBlockEntity chassis = (ChassisBlockEntity) blockEntity;
if (blockEntity instanceof ChassisBlockEntity chassis) {
collected.add(chassis);
visited.add(current);
chassis.addAttachedChasses(frontier, visited);
@ -127,7 +126,7 @@ public class ChassisBlockEntity extends SmartBlockEntity {
if (isRadial()) {
// Collect chain of radial chassis
for (int offset : new int[] { -1, 1 }) {
for (int offset : new int[]{-1, 1}) {
Direction direction = Direction.get(AxisDirection.POSITIVE, axis);
BlockPos currentPos = worldPosition.relative(direction, offset);
if (!level.isLoaded(currentPos))
@ -175,7 +174,7 @@ public class ChassisBlockEntity extends SmartBlockEntity {
Direction facing = Direction.get(AxisDirection.POSITIVE, axis);
int chassisRange = visualize ? currentlySelectedRange : getRange();
for (int offset : new int[] { 1, -1 }) {
for (int offset : new int[]{1, -1}) {
if (offset == -1)
facing = facing.getOpposite();
boolean sticky = state.getValue(block.getGlueableSide(state, facing));
@ -256,7 +255,7 @@ public class ChassisBlockEntity extends SmartBlockEntity {
class ChassisScrollValueBehaviour extends BulkScrollValueBehaviour {
public ChassisScrollValueBehaviour(Component label, SmartBlockEntity be, ValueBoxTransform slot,
Function<SmartBlockEntity, List<? extends SmartBlockEntity>> groupGetter) {
Function<SmartBlockEntity, List<? extends SmartBlockEntity>> groupGetter) {
super(label, be, slot, groupGetter);
}

View file

@ -92,7 +92,7 @@ public class ChassisRangeDisplay {
boolean hasWrench = AllItems.WRENCH.isIn(player.getMainHandItem());
for (Iterator<BlockPos> iterator = entries.keySet()
.iterator(); iterator.hasNext();) {
.iterator(); iterator.hasNext(); ) {
BlockPos pos = iterator.next();
Entry entry = entries.get(pos);
if (tickEntry(entry, hasWrench))
@ -100,7 +100,7 @@ public class ChassisRangeDisplay {
Outliner.getInstance().keep(entry.getOutlineKey());
}
for (Iterator<GroupEntry> iterator = groupEntries.iterator(); iterator.hasNext();) {
for (Iterator<GroupEntry> iterator = groupEntries.iterator(); iterator.hasNext(); ) {
GroupEntry group = iterator.next();
if (tickEntry(group, hasWrench)) {
iterator.remove();
@ -114,18 +114,16 @@ public class ChassisRangeDisplay {
return;
HitResult over = Minecraft.getInstance().hitResult;
if (!(over instanceof BlockHitResult))
if (!(over instanceof BlockHitResult ray))
return;
BlockHitResult ray = (BlockHitResult) over;
BlockPos pos = ray.getBlockPos();
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity == null || blockEntity.isRemoved())
return;
if (!(blockEntity instanceof ChassisBlockEntity))
if (!(blockEntity instanceof ChassisBlockEntity chassisBlockEntity))
return;
boolean ctrl = AllKeys.ctrlDown();
ChassisBlockEntity chassisBlockEntity = (ChassisBlockEntity) blockEntity;
if (ctrl) {
GroupEntry existingGroupForPos = getExistingGroupForPos(pos);

View file

@ -78,7 +78,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
@Override
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos updatePos,
boolean p_220069_6_) {
boolean p_220069_6_) {
if (updatePos.equals(pos.relative(state.getValue(FACING)
.getOpposite())) && !canSurvive(state, world, pos))
world.destroyBlock(pos, true);
@ -86,7 +86,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState otherState, LevelAccessor world,
BlockPos pos, BlockPos p_196271_6_) {
BlockPos pos, BlockPos p_196271_6_) {
if (state.getValue(FACING) != direction.getOpposite())
return state;
return cycleAxisIfNecessary(state, direction, otherState);
@ -109,9 +109,8 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
}
public static Axis getValidGantryShaftAxis(BlockState state) {
if (!(state.getBlock() instanceof GantryCarriageBlock))
if (!(state.getBlock() instanceof GantryCarriageBlock block))
return Axis.Y;
IRotate block = (IRotate) state.getBlock();
Axis rotationAxis = block.getRotationAxis(state);
Axis facingAxis = state.getValue(FACING)
.getAxis();

View file

@ -102,7 +102,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
BlockPos gantryShaftPos = BlockPos.containing(currentPosition).relative(facing.getOpposite());
BlockEntity be = level().getBlockEntity(gantryShaftPos);
if (!(be instanceof GantryShaftBlockEntity) || !AllBlocks.GANTRY_SHAFT.has(be.getBlockState())) {
if (!(be instanceof GantryShaftBlockEntity gantryShaftBlockEntity) || !AllBlocks.GANTRY_SHAFT.has(be.getBlockState())) {
if (!level().isClientSide) {
setContraptionMotion(Vec3.ZERO);
disassemble();
@ -112,7 +112,6 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
BlockState blockState = be.getBlockState();
Direction direction = blockState.getValue(GantryShaftBlock.FACING);
GantryShaftBlockEntity gantryShaftBlockEntity = (GantryShaftBlockEntity) be;
float pinionMovementSpeed = gantryShaftBlockEntity.getPinionMovementSpeed();
if (blockState.getValue(GantryShaftBlock.POWERED) || pinionMovementSpeed == 0) {
@ -186,11 +185,13 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
}
@Override
public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {}
public void teleportTo(double p_70634_1_, double p_70634_3_, double p_70634_5_) {
}
@Override
@OnlyIn(Dist.CLIENT)
public void lerpTo(double pX, double pY, double pZ, float pYRot, float pXRot, int pSteps) {}
public void lerpTo(double pX, double pY, double pZ, float pYRot, float pXRot, int pSteps) {
}
@Override
protected void handleStallInformation(double x, double y, double z, float angle) {
@ -205,7 +206,8 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
@Override
@OnlyIn(Dist.CLIENT)
public void applyLocalTransforms(PoseStack matrixStack, float partialTicks) {}
public void applyLocalTransforms(PoseStack matrixStack, float partialTicks) {
}
public void updateClientMotion() {
float modifier = movementAxis.getAxisDirection()
@ -231,9 +233,8 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
@OnlyIn(Dist.CLIENT)
public static void handlePacket(GantryContraptionUpdatePacket packet) {
Entity entity = Minecraft.getInstance().level.getEntity(packet.entityID());
if (!(entity instanceof GantryContraptionEntity))
if (!(entity instanceof GantryContraptionEntity ce))
return;
GantryContraptionEntity ce = (GantryContraptionEntity) entity;
ce.axisMotion = packet.motion();
ce.clientOffsetDiff = packet.coord() - ce.getAxisCoord();
ce.sequencedOffsetLimit = packet.sequenceLimit();

View file

@ -70,9 +70,9 @@ public class CouplingHandler {
Entity entity1 = world.getEntity(cartId1);
Entity entity2 = world.getEntity(cartId2);
if (!(entity1 instanceof AbstractMinecart))
if (!(entity1 instanceof AbstractMinecart cart1))
return false;
if (!(entity2 instanceof AbstractMinecart))
if (!(entity2 instanceof AbstractMinecart cart2))
return false;
String tooMany = "two_couplings_max";
@ -95,8 +95,6 @@ public class CouplingHandler {
return false;
}
AbstractMinecart cart1 = (AbstractMinecart) entity1;
AbstractMinecart cart2 = (AbstractMinecart) entity2;
UUID mainID = cart1.getUUID();
UUID connectedID = cart2.getUUID();
MinecartController mainController = CapabilityMinecartController.getIfPresent(world, mainID);

View file

@ -40,7 +40,7 @@ public class CouplingPhysics {
Couple<Vec3> corrections = Couple.create(null, null);
Couple<Float> maxSpeed = carts.map(AbstractMinecart::getMaxCartSpeedOnRail);
boolean firstLoop = true;
for (boolean current : new boolean[] { true, false, true }) {
for (boolean current : new boolean[]{true, false, true}) {
AbstractMinecart cart = carts.get(current);
AbstractMinecart otherCart = carts.get(!current);
@ -54,8 +54,7 @@ public class CouplingPhysics {
BlockPos railPosition = cart.getCurrentRailPosition();
BlockState railState = world.getBlockState(railPosition.above());
if (railState.getBlock() instanceof BaseRailBlock) {
BaseRailBlock block = (BaseRailBlock) railState.getBlock();
if (railState.getBlock() instanceof BaseRailBlock block) {
shape = block.getRailDirection(railState, world, railPosition, cart);
}
@ -71,7 +70,7 @@ public class CouplingPhysics {
correction = shape != null
? followLinkOnRail(link, pos, correctionMagnitude, MinecartSim2020.getRailVec(shape)).subtract(pos)
: link.normalize()
.scale(correctionMagnitude);
.scale(correctionMagnitude);
float maxResolveSpeed = 1.75f;
correction = VecHelper.clamp(correction, Math.min(maxResolveSpeed, maxSpeed.get(current)));
@ -102,15 +101,14 @@ public class CouplingPhysics {
Couple<RailShape> shapes = carts.mapWithContext((minecart, current) -> {
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();
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 BaseRailBlock))
if (!(railState.getBlock() instanceof BaseRailBlock block))
return null;
BaseRailBlock block = (BaseRailBlock) railState.getBlock();
return block.getRailDirection(railState, world, railPosition, minecart);
});

View file

@ -57,7 +57,7 @@ public class MinecartCouplingItem extends Item {
}
protected static boolean onCouplingInteractOnMinecart(PlayerInteractEvent.EntityInteract event,
AbstractMinecart minecart, Player player, MinecartController controller) {
AbstractMinecart minecart, Player player, MinecartController controller) {
Level world = event.getLevel();
if (controller.isFullyCoupled()) {
if (!world.isClientSide)
@ -70,7 +70,7 @@ public class MinecartCouplingItem extends Item {
}
private static boolean onWrenchInteractOnMinecart(EntityInteract event, AbstractMinecart minecart, Player player,
MinecartController controller) {
MinecartController controller) {
int couplings = (controller.isConnectedToCoupling() ? 1 : 0) + (controller.isLeadingCoupling() ? 1 : 0);
if (couplings == 0)
return false;

View file

@ -125,15 +125,15 @@ public class MinecartController implements INBTSerializable<CompoundTag> {
int j = Mth.floor(cart.getY());
int k = Mth.floor(cart.getZ());
if (world.getBlockState(new BlockPos(i, j - 1, k))
.is(BlockTags.RAILS)) {
.is(BlockTags.RAILS)) {
--j;
}
BlockPos blockpos = new BlockPos(i, j, k);
BlockState blockstate = world.getBlockState(blockpos);
if (cart.canUseRail() && blockstate.is(BlockTags.RAILS)
&& blockstate.getBlock() instanceof PoweredRailBlock
&& ((PoweredRailBlock) blockstate.getBlock())
.isActivatorRail()) {
&& blockstate.getBlock() instanceof PoweredRailBlock
&& ((PoweredRailBlock) blockstate.getBlock())
.isActivatorRail()) {
if (cart.isVehicle()) {
cart.ejectPassengers();
}
@ -413,7 +413,8 @@ public class MinecartController implements INBTSerializable<CompoundTag> {
Vec3 motion;
float yaw, pitch;
private StallData() {}
private StallData() {
}
StallData(AbstractMinecart entity) {
position = entity.position();

View file

@ -182,9 +182,8 @@ public class CartAssemblerBlockEntity extends SmartBlockEntity implements IDispl
return;
Entity entity = cart.getPassengers()
.get(0);
if (!(entity instanceof OrientedContraptionEntity))
if (!(entity instanceof OrientedContraptionEntity contraption))
return;
OrientedContraptionEntity contraption = (OrientedContraptionEntity) entity;
UUID couplingId = contraption.getCouplingId();
if (couplingId == null) {

View file

@ -115,7 +115,7 @@ public class MinecartContraptionItem extends Item {
BlockState blockstate1 = world.getBlockState(blockpos.below());
RailShape railshape1 = blockstate1.getBlock() instanceof BaseRailBlock
? ((BaseRailBlock) blockstate1.getBlock()).getRailDirection(blockstate1, world, blockpos.below(),
null)
null)
: RailShape.NORTH_SOUTH;
if (direction != Direction.DOWN && railshape1.isAscending()) {
d3 = -0.4D;
@ -178,7 +178,7 @@ public class MinecartContraptionItem extends Item {
}
public static void addContraptionToMinecart(Level world, ItemStack itemstack, AbstractMinecart cart,
@Nullable Direction newFacing) {
@Nullable Direction newFacing) {
if (itemstack.has(AllDataComponents.MINECRAFT_CONTRAPTION_DATA)) {
CompoundTag contraptionTag = itemstack.get(AllDataComponents.MINECRAFT_CONTRAPTION_DATA);
@ -188,7 +188,7 @@ public class MinecartContraptionItem extends Item {
OrientedContraptionEntity contraptionEntity =
newFacing == null ? OrientedContraptionEntity.create(world, mountedContraption, intialOrientation)
: OrientedContraptionEntity.createAtYaw(world, mountedContraption, intialOrientation,
newFacing.toYRot());
newFacing.toYRot());
contraptionEntity.startRiding(cart);
contraptionEntity.setPos(cart.getX(), cart.getY(), cart.getZ());
@ -215,20 +215,18 @@ public class MinecartContraptionItem extends Item {
return;
if (entity instanceof AbstractContraptionEntity)
entity = entity.getVehicle();
if (!(entity instanceof AbstractMinecart))
if (!(entity instanceof AbstractMinecart cart))
return;
if (!entity.isAlive())
return;
if (player instanceof DeployerFakePlayer dfp && dfp.onMinecartContraption)
return;
AbstractMinecart cart = (AbstractMinecart) entity;
Type type = cart.getMinecartType();
if (type != Type.RIDEABLE && type != Type.FURNACE && type != Type.CHEST)
return;
List<Entity> passengers = cart.getPassengers();
if (passengers.isEmpty() || !(passengers.get(0) instanceof OrientedContraptionEntity))
if (passengers.isEmpty() || !(passengers.get(0) instanceof OrientedContraptionEntity oce))
return;
OrientedContraptionEntity oce = (OrientedContraptionEntity) passengers.get(0);
Contraption contraption = oce.getContraption();
if (ContraptionMovementSetting.isNoPickup(contraption.getBlocks()
@ -247,7 +245,7 @@ public class MinecartContraptionItem extends Item {
contraption.stop(event.getLevel());
for (MutablePair<StructureBlockInfo, MovementContext> pair : contraption.getActors())
if (AllMovementBehaviours.getBehaviour(pair.left.state())instanceof PortableStorageInterfaceMovement psim)
if (AllMovementBehaviours.getBehaviour(pair.left.state()) instanceof PortableStorageInterfaceMovement psim)
psim.reset(pair.right);
ItemStack generatedStack = create(type, oce);
@ -255,7 +253,7 @@ public class MinecartContraptionItem extends Item {
if (ContraptionPickupLimiting.isTooLargeForPickup(generatedStack.saveOptional(event.getLevel().registryAccess()))) {
MutableComponent message = CreateLang.translateDirect("contraption.minecart_contraption_too_big")
.withStyle(ChatFormatting.RED);
.withStyle(ChatFormatting.RED);
player.displayClientMessage(message, true);
return;
}
@ -276,17 +274,17 @@ public class MinecartContraptionItem extends Item {
ItemStack stack = ItemStack.EMPTY;
switch (type) {
case RIDEABLE:
stack = AllItems.MINECART_CONTRAPTION.asStack();
break;
case FURNACE:
stack = AllItems.FURNACE_MINECART_CONTRAPTION.asStack();
break;
case CHEST:
stack = AllItems.CHEST_MINECART_CONTRAPTION.asStack();
break;
default:
break;
case RIDEABLE:
stack = AllItems.MINECART_CONTRAPTION.asStack();
break;
case FURNACE:
stack = AllItems.FURNACE_MINECART_CONTRAPTION.asStack();
break;
case CHEST:
stack = AllItems.CHEST_MINECART_CONTRAPTION.asStack();
break;
default:
break;
}
if (stack.isEmpty())

View file

@ -46,12 +46,12 @@ import net.minecraft.world.phys.shapes.VoxelShape;
public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock implements IWrenchable, SimpleWaterloggedBlock {
private static final int placementHelperId = PlacementHelpers.register(PlacementHelper.get());
private static final int placementHelperId = PlacementHelpers.register(PlacementHelper.get());
public PistonExtensionPoleBlock(Properties properties) {
super(properties);
registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP).setValue(BlockStateProperties.WATERLOGGED, false));
}
public PistonExtensionPoleBlock(Properties properties) {
super(properties);
registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP).setValue(BlockStateProperties.WATERLOGGED, false));
}
@Override
public PushReaction getPistonPushReaction(BlockState state) {
@ -66,7 +66,7 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
BlockPos pistonHead = null;
BlockPos pistonBase = null;
for (int modifier : new int[] { 1, -1 }) {
for (int modifier : new int[]{1, -1}) {
for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset +=
modifier) {
BlockPos currentPos = pos.relative(direction, offset);
@ -90,18 +90,17 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead)
.getValue(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase)
.getValue(BlockStateProperties.FACING)) {
.getValue(BlockStateProperties.FACING)) {
final BlockPos basePos = pistonBase;
BlockPos.betweenClosedStream(pistonBase, pistonHead)
.filter(p -> !p.equals(pos) && !p.equals(basePos))
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
.filter(p -> !p.equals(pos) && !p.equals(basePos))
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
worldIn.setBlockAndUpdate(basePos, worldIn.getBlockState(basePos)
.setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
.setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
BlockEntity be = worldIn.getBlockEntity(basePos);
if (be instanceof MechanicalPistonBlockEntity) {
MechanicalPistonBlockEntity baseBE = (MechanicalPistonBlockEntity) be;
if (be instanceof MechanicalPistonBlockEntity baseBE) {
baseBE.offset = 0;
baseBE.onLengthBroken();
}
@ -121,7 +120,7 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
FluidState FluidState = context.getLevel()
.getFluidState(context.getClickedPos());
return defaultBlockState().setValue(FACING, context.getClickedFace()
.getOpposite())
.getOpposite())
.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER));
}
@ -129,7 +128,7 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId);
if (placementHelper.matchesItem(stack) && !player.isShiftKeyDown())
return placementHelper.getOffset(player, level, state, pos, hitResult).placeInWorld(level, (BlockItem) stack.getItem(), player, hand, hitResult);
return placementHelper.getOffset(player, level, state, pos, hitResult).placeInWorld(level, (BlockItem) stack.getItem(), player, hand, hitResult);
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
@ -146,38 +145,38 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
super.createBlockStateDefinition(builder);
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
if (state.getValue(BlockStateProperties.WATERLOGGED))
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
return state;
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
if (state.getValue(BlockStateProperties.WATERLOGGED))
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
return state;
}
@Override
protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) {
return false;
}
@MethodsReturnNonnullByDefault
public static class PlacementHelper extends PoleHelper<Direction> {
@MethodsReturnNonnullByDefault
public static class PlacementHelper extends PoleHelper<Direction> {
private static final PlacementHelper instance = new PlacementHelper();
private static final PlacementHelper instance = new PlacementHelper();
public static PlacementHelper get() {
return instance;
}
public static PlacementHelper get() {
return instance;
}
private PlacementHelper(){
super(
AllBlocks.PISTON_EXTENSION_POLE::has,
state -> state.getValue(FACING).getAxis(),
FACING
);
}
private PlacementHelper() {
super(
AllBlocks.PISTON_EXTENSION_POLE::has,
state -> state.getValue(FACING).getAxis(),
FACING
);
}
@Override
public Predicate<ItemStack> getItemPredicate() {
return AllBlocks.PISTON_EXTENSION_POLE::isIn;
}
}
@Override
public Predicate<ItemStack> getItemPredicate() {
return AllBlocks.PISTON_EXTENSION_POLE::isIn;
}
}
}

View file

@ -36,14 +36,13 @@ import net.minecraft.world.phys.shapes.VoxelShape;
public class PulleyBlock extends HorizontalAxisKineticBlock implements IBE<PulleyBlockEntity> {
public PulleyBlock(Properties properties) {
super(properties);
}
public PulleyBlock(Properties properties) {
super(properties);
}
private static void onRopeBroken(Level world, BlockPos pulleyPos) {
private static void onRopeBroken(Level world, BlockPos pulleyPos) {
BlockEntity be = world.getBlockEntity(pulleyPos);
if (be instanceof PulleyBlockEntity) {
PulleyBlockEntity pulley = (PulleyBlockEntity) be;
if (be instanceof PulleyBlockEntity pulley) {
pulley.initialOffset = 0;
pulley.onLengthBroken();
}
@ -63,119 +62,119 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements IBE<Pulle
@Override
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
if (!player.mayBuild())
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
if (player.isShiftKeyDown())
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
if (stack.isEmpty()) {
if (!player.mayBuild())
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
if (player.isShiftKeyDown())
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
if (stack.isEmpty()) {
withBlockEntityDo(level, pos, be -> be.assembleNextTick = true);
return ItemInteractionResult.SUCCESS;
}
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
return ItemInteractionResult.SUCCESS;
}
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
@Override
public Class<PulleyBlockEntity> getBlockEntityClass() {
return PulleyBlockEntity.class;
}
@Override
public Class<PulleyBlockEntity> getBlockEntityClass() {
return PulleyBlockEntity.class;
}
@Override
public BlockEntityType<? extends PulleyBlockEntity> getBlockEntityType() {
return AllBlockEntityTypes.ROPE_PULLEY.get();
}
@Override
public BlockEntityType<? extends PulleyBlockEntity> getBlockEntityType() {
return AllBlockEntityTypes.ROPE_PULLEY.get();
}
private static class RopeBlockBase extends Block implements SimpleWaterloggedBlock {
private static class RopeBlockBase extends Block implements SimpleWaterloggedBlock {
public RopeBlockBase(Properties properties) {
super(properties);
registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false));
}
public RopeBlockBase(Properties properties) {
super(properties);
registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false));
}
@Override
protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) {
return false;
}
protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) {
return false;
}
@Override
public PushReaction getPistonPushReaction(BlockState state) {
return PushReaction.BLOCK;
}
@Override
public PushReaction getPistonPushReaction(BlockState state) {
return PushReaction.BLOCK;
}
@Override
public ItemStack getCloneItemStack(BlockState state, HitResult target, LevelReader level, BlockPos pos,
@Override
public ItemStack getCloneItemStack(BlockState state, HitResult target, LevelReader level, BlockPos pos,
Player player) {
return AllBlocks.ROPE_PULLEY.asStack();
}
return AllBlocks.ROPE_PULLEY.asStack();
}
@Override
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (!isMoving && (!state.hasProperty(BlockStateProperties.WATERLOGGED) || !newState.hasProperty(BlockStateProperties.WATERLOGGED) || state.getValue(BlockStateProperties.WATERLOGGED) == newState.getValue(BlockStateProperties.WATERLOGGED))) {
onRopeBroken(worldIn, pos.above());
if (!worldIn.isClientSide) {
BlockState above = worldIn.getBlockState(pos.above());
BlockState below = worldIn.getBlockState(pos.below());
if (above.getBlock() instanceof RopeBlockBase)
worldIn.destroyBlock(pos.above(), true);
if (below.getBlock() instanceof RopeBlockBase)
worldIn.destroyBlock(pos.below(), true);
}
}
if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
worldIn.removeBlockEntity(pos);
}
}
@Override
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (!isMoving && (!state.hasProperty(BlockStateProperties.WATERLOGGED) || !newState.hasProperty(BlockStateProperties.WATERLOGGED) || state.getValue(BlockStateProperties.WATERLOGGED) == newState.getValue(BlockStateProperties.WATERLOGGED))) {
onRopeBroken(worldIn, pos.above());
if (!worldIn.isClientSide) {
BlockState above = worldIn.getBlockState(pos.above());
BlockState below = worldIn.getBlockState(pos.below());
if (above.getBlock() instanceof RopeBlockBase)
worldIn.destroyBlock(pos.above(), true);
if (below.getBlock() instanceof RopeBlockBase)
worldIn.destroyBlock(pos.below(), true);
}
}
if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
worldIn.removeBlockEntity(pos);
}
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
}
@Override
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
builder.add(BlockStateProperties.WATERLOGGED);
super.createBlockStateDefinition(builder);
}
@Override
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
builder.add(BlockStateProperties.WATERLOGGED);
super.createBlockStateDefinition(builder);
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState,
LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
if (state.getValue(BlockStateProperties.WATERLOGGED))
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
return state;
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState,
LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
if (state.getValue(BlockStateProperties.WATERLOGGED))
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
return state;
}
@Override
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 BlockState getStateForPlacement(BlockPlaceContext context) {
FluidState FluidState = context.getLevel().getFluidState(context.getClickedPos());
return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(FluidState.getType() == Fluids.WATER));
}
}
}
public static class MagnetBlock extends RopeBlockBase {
public static class MagnetBlock extends RopeBlockBase {
public MagnetBlock(Properties properties) {
super(properties);
}
public MagnetBlock(Properties properties) {
super(properties);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
return AllShapes.PULLEY_MAGNET;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
return AllShapes.PULLEY_MAGNET;
}
}
}
public static class RopeBlock extends RopeBlockBase {
public static class RopeBlock extends RopeBlockBase {
public RopeBlock(Properties properties) {
super(properties);
}
public RopeBlock(Properties properties) {
super(properties);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
return AllShapes.FOUR_VOXEL_POLE.get(Direction.UP);
}
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
return AllShapes.FOUR_VOXEL_POLE.get(Direction.UP);
}
}
}

View file

@ -77,9 +77,9 @@ public class PulleyBlockEntity extends LinearActuatorBlockEntity implements Thre
if (level.isClientSide() && mirrorParent != null)
if (sharedMirrorContraption == null || sharedMirrorContraption.get() == null
|| !sharedMirrorContraption.get()
.isAlive()) {
.isAlive()) {
sharedMirrorContraption = null;
if (level.getBlockEntity(mirrorParent)instanceof PulleyBlockEntity pte && pte.movedContraption != null)
if (level.getBlockEntity(mirrorParent) instanceof PulleyBlockEntity pte && pte.movedContraption != null)
sharedMirrorContraption = new WeakReference<>(pte.movedContraption);
}
@ -205,8 +205,8 @@ public class PulleyBlockEntity extends LinearActuatorBlockEntity implements Thre
.getCollisionShape(level, magnetPos)
.isEmpty());
level.setBlock(magnetPos, AllBlocks.PULLEY_MAGNET.getDefaultState()
.setValue(BlockStateProperties.WATERLOGGED,
Boolean.valueOf(ifluidstate.getType() == Fluids.WATER)),
.setValue(BlockStateProperties.WATERLOGGED,
Boolean.valueOf(ifluidstate.getType() == Fluids.WATER)),
66);
}
}
@ -256,8 +256,7 @@ public class PulleyBlockEntity extends LinearActuatorBlockEntity implements Thre
@Override
protected Vec3 toPosition(float offset) {
if (movedContraption.getContraption() instanceof PulleyContraption) {
PulleyContraption contraption = (PulleyContraption) movedContraption.getContraption();
if (movedContraption.getContraption() instanceof PulleyContraption contraption) {
return Vec3.atLowerCornerOf(contraption.anchor)
.add(0, contraption.getInitialOffset() - offset, 0);

View file

@ -73,6 +73,9 @@ public class ContraptionVisual<E extends AbstractContraptionEntity> extends Abst
setEmbeddingMatrices(partialTick);
Contraption contraption = entity.getContraption();
// The contraption could be null if it wasn't synced (ex. too much data)
if (contraption == null)
return;
setupModel(contraption);

View file

@ -14,6 +14,7 @@ import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.client.model.data.ModelData;
public class CopycatBarsModel extends CopycatModel {
@ -29,7 +30,7 @@ public class CopycatBarsModel extends CopycatModel {
@Override
protected List<BakedQuad> getCroppedQuads(BlockState state, Direction side, RandomSource rand, BlockState material,
ModelData wrappedData, RenderType renderType) {
ModelData wrappedData, RenderType renderType) {
BakedModel model = getModelOf(material);
List<BakedQuad> superQuads = originalModel.getQuads(state, side, rand, wrappedData, renderType);
TextureAtlasSprite targetSprite = model.getParticleIcon(wrappedData);
@ -39,8 +40,7 @@ public class CopycatBarsModel extends CopycatModel {
if (side != null && (vertical || side.getAxis() == Axis.Y)) {
List<BakedQuad> templateQuads = model.getQuads(material, null, rand, wrappedData, renderType);
for (int i = 0; i < templateQuads.size(); i++) {
BakedQuad quad = templateQuads.get(i);
for (BakedQuad quad : templateQuads) {
if (quad.getDirection() != Direction.UP)
continue;
targetSprite = quad.getSprite();
@ -53,8 +53,7 @@ public class CopycatBarsModel extends CopycatModel {
List<BakedQuad> quads = new ArrayList<>();
for (int i = 0; i < superQuads.size(); i++) {
BakedQuad quad = superQuads.get(i);
for (BakedQuad quad : superQuads) {
TextureAtlasSprite original = quad.getSprite();
BakedQuad newQuad = BakedQuadHelper.clone(quad);
int[] vertexData = newQuad.getVertices();

View file

@ -31,7 +31,7 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
@Override
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_) {
float pt, float p_225628_8_, float p_225628_9_, float p_225628_10_) {
if (entity.getPose() == Pose.SLEEPING)
return;
@ -40,13 +40,12 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
return;
M entityModel = getParentModel();
if (!(entityModel instanceof HumanoidModel))
if (!(entityModel instanceof HumanoidModel<?> model))
return;
HumanoidModel<?> model = (HumanoidModel<?>) entityModel;
VertexConsumer vc = buffer.getBuffer(Sheets.cutoutBlockSheet());
BlockState renderedState = item.getBlock().defaultBlockState()
.setValue(BacktankBlock.HORIZONTAL_FACING, Direction.SOUTH);
.setValue(BacktankBlock.HORIZONTAL_FACING, Direction.SOUTH);
SuperByteBuffer backtank = CachedBuffers.block(renderedState);
SuperByteBuffer cogs = CachedBuffers.partial(BacktankRenderer.getCogsModel(renderedState), renderedState);
SuperByteBuffer nob = CachedBuffers.partial(BacktankRenderer.getShaftModel(renderedState), renderedState);
@ -87,11 +86,10 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
registerOn(renderer);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public static void registerOn(EntityRenderer<?> entityRenderer) {
if (!(entityRenderer instanceof LivingEntityRenderer))
if (!(entityRenderer instanceof LivingEntityRenderer<?, ?> livingRenderer))
return;
LivingEntityRenderer<?, ?> livingRenderer = (LivingEntityRenderer<?, ?>) entityRenderer;
if (!(livingRenderer.getModel() instanceof HumanoidModel))
return;
BacktankArmorLayer<?, ?> layer = new BacktankArmorLayer<>(livingRenderer);

View file

@ -82,8 +82,7 @@ public class DivingBootsItem extends BaseArmorItem {
return false;
if (entity.getPose() == Pose.SWIMMING)
return false;
if (entity instanceof Player) {
Player playerEntity = (Player) entity;
if (entity instanceof Player playerEntity) {
if (playerEntity.getAbilities().flying)
return false;
}

View file

@ -17,6 +17,7 @@ import net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
@ -27,7 +28,8 @@ import net.neoforged.api.distmarker.OnlyIn;
@MethodsReturnNonnullByDefault
public abstract class BasicParticleData<T extends Particle> implements ParticleOptions, ICustomParticleDataWithSprite<BasicParticleData<T>> {
public BasicParticleData() { }
public BasicParticleData() {
}
@Override
public StreamCodec<? super RegistryFriendlyByteBuf, BasicParticleData<T>> getStreamCodec() {
@ -50,6 +52,6 @@ public abstract class BasicParticleData<T extends Particle> implements ParticleO
@OnlyIn(Dist.CLIENT)
public ParticleEngine.SpriteParticleRegistration<BasicParticleData<T>> getMetaFactory() {
return animatedSprite -> (data, worldIn, x, y, z, vx, vy, vz) ->
getBasicFactory().makeParticle(worldIn, x, y, z, vx, vy, vz, animatedSprite);
getBasicFactory().makeParticle(worldIn, x, y, z, vx, vy, vz, animatedSprite);
}
}

View file

@ -3,13 +3,14 @@ package com.simibubi.create.content.equipment.blueprint;
import com.simibubi.create.AllPackets;
import net.createmod.catnip.net.base.ServerboundPacketPayload;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
public record BlueprintAssignCompleteRecipePacket(ResourceLocation recipeId) implements ServerboundPacketPayload {
public static final StreamCodec<ByteBuf, BlueprintAssignCompleteRecipePacket> STREAM_CODEC = ResourceLocation.STREAM_CODEC.map(
BlueprintAssignCompleteRecipePacket::new, BlueprintAssignCompleteRecipePacket::recipeId
public static final StreamCodec<ByteBuf, com.simibubi.create.content.equipment.blueprint.BlueprintAssignCompleteRecipePacket> STREAM_CODEC = ResourceLocation.STREAM_CODEC.map(
com.simibubi.create.content.equipment.blueprint.BlueprintAssignCompleteRecipePacket::new, com.simibubi.create.content.equipment.blueprint.BlueprintAssignCompleteRecipePacket::recipeId
);
@Override

View file

@ -222,7 +222,7 @@ public class BlueprintEntity extends HangingEntity
BlockPos blockpos = this.pos.relative(this.direction.getOpposite());
Direction upDirection = direction.getAxis()
.isHorizontal() ? Direction.UP
: direction == Direction.UP ? verticalOrientation : verticalOrientation.getOpposite();
: direction == Direction.UP ? verticalOrientation : verticalOrientation.getOpposite();
Direction newDirection = direction.getAxis()
.isVertical() ? verticalOrientation.getClockWise() : direction.getCounterClockWise();
BlockPos.MutableBlockPos blockpos$mutable = new BlockPos.MutableBlockPos();
@ -290,8 +290,7 @@ public class BlueprintEntity extends HangingEntity
return;
playSound(SoundEvents.PAINTING_BREAK, 1.0F, 1.0F);
if (p_110128_1_ instanceof Player) {
Player playerentity = (Player) p_110128_1_;
if (p_110128_1_ instanceof Player playerentity) {
if (playerentity.getAbilities().instabuild)
return;
}
@ -364,7 +363,8 @@ public class BlueprintEntity extends HangingEntity
Map<Integer, ItemStack> craftingGrid = new HashMap<>();
boolean success = true;
Search: for (int i = 0; i < 9; i++) {
Search:
for (int i = 0; i < 9; i++) {
FilterItemStack requestedItem = FilterItemStack.of(items.getStackInSlot(i));
if (requestedItem.isEmpty()) {
craftingGrid.put(i, ItemStack.EMPTY);

View file

@ -11,6 +11,7 @@ import com.simibubi.create.content.logistics.filter.FilterItem;
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute;
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.InTagAttribute;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute.ItemAttributeEntry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -32,6 +33,7 @@ import net.minecraft.world.item.crafting.Ingredient.Value;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.ShapedRecipe;
import net.minecraft.world.level.Level;
import net.neoforged.neoforge.common.crafting.CompoundIngredient;
import net.neoforged.neoforge.items.ItemStackHandler;
@ -47,14 +49,14 @@ public class BlueprintItem extends Item {
Player player = ctx.getPlayer();
ItemStack stack = ctx.getItemInHand();
BlockPos pos = ctx.getClickedPos()
.relative(face);
.relative(face);
if (player != null && !player.mayUseItemAt(pos, face, stack))
return InteractionResult.FAIL;
Level world = ctx.getLevel();
HangingEntity hangingentity = new BlueprintEntity(world, pos, face, face.getAxis()
.isHorizontal() ? Direction.DOWN : ctx.getHorizontalDirection());
.isHorizontal() ? Direction.DOWN : ctx.getHorizontalDirection());
CustomData customData = stack.get(DataComponents.CUSTOM_DATA);
if (customData != null)
@ -81,7 +83,7 @@ public class BlueprintItem extends Item {
for (int row = 0; row < shapedRecipe.getHeight(); row++)
for (int col = 0; col < shapedRecipe.getWidth(); col++)
inv.setStackInSlot(row * 3 + col,
convertIngredientToFilter(ingredients.get(row * shapedRecipe.getWidth() + col)));
convertIngredientToFilter(ingredients.get(row * shapedRecipe.getWidth() + col)));
} else {
for (int i = 0; i < ingredients.size(); i++)
inv.setStackInSlot(i, convertIngredientToFilter(ingredients.get(i)));
@ -116,7 +118,7 @@ public class BlueprintItem extends Item {
if (itemList instanceof TagValue tagValue) {
ItemStack filterItem = AllItems.ATTRIBUTE_FILTER.asStack();
filterItem.set(AllDataComponents.ATTRIBUTE_FILTER_WHITELIST_MODE, AttributeFilterWhitelistMode.WHITELIST_DISJ);
List<ItemAttribute.ItemAttributeEntry> attributes = new ArrayList<>();
List<ItemAttributeEntry> attributes = new ArrayList<>();
ItemAttribute at = new InTagAttribute(ItemTags.create(tagValue.tag().location()));
attributes.add(new ItemAttribute.ItemAttributeEntry(at, false));
filterItem.set(AllDataComponents.ATTRIBUTE_FILTER_MATCHED_ATTRIBUTES, attributes);

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllDataComponents;
import com.simibubi.create.AllMenuTypes;
import com.simibubi.create.content.equipment.blueprint.BlueprintEntity.BlueprintSection;
import com.simibubi.create.foundation.gui.menu.GhostItemMenu;
import net.minecraft.client.Minecraft;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
@ -20,6 +21,7 @@ import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.items.IItemHandler;
@ -70,12 +72,12 @@ public class BlueprintMenu extends GhostItemMenu<BlueprintSection> {
ServerPlayer serverplayerentity = (ServerPlayer) player;
CraftingContainer craftingInventory = new BlueprintCraftingInventory(this, ghostInventory);
Optional<RecipeHolder<CraftingRecipe>> optional = player.getServer()
.getRecipeManager()
.getRecipeFor(RecipeType.CRAFTING, craftingInventory.asCraftInput(), player.getCommandSenderWorld());
.getRecipeManager()
.getRecipeFor(RecipeType.CRAFTING, craftingInventory.asCraftInput(), player.getCommandSenderWorld());
if (!optional.isPresent()) {
if (ghostInventory.getStackInSlot(9)
.isEmpty())
.isEmpty())
return;
if (!contentHolder.inferredIcon)
return;
@ -125,9 +127,8 @@ public class BlueprintMenu extends GhostItemMenu<BlueprintSection> {
int entityID = extraData.readVarInt();
int section = extraData.readVarInt();
Entity entityByID = Minecraft.getInstance().level.getEntity(entityID);
if (!(entityByID instanceof BlueprintEntity))
if (!(entityByID instanceof BlueprintEntity blueprintEntity))
return null;
BlueprintEntity blueprintEntity = (BlueprintEntity) entityByID;
BlueprintSection blueprintSection = blueprintEntity.getSection(section);
return blueprintSection;
}

View file

@ -54,6 +54,7 @@ import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.HitResult.Type;
import net.neoforged.neoforge.items.ItemHandlerHelper;
import net.neoforged.neoforge.items.ItemStackHandler;
@ -92,10 +93,9 @@ public class BlueprintOverlayRenderer {
return;
EntityHitResult entityRay = (EntityHitResult) mouseOver;
if (!(entityRay.getEntity() instanceof BlueprintEntity))
if (!(entityRay.getEntity() instanceof BlueprintEntity blueprintEntity))
return;
BlueprintEntity blueprintEntity = (BlueprintEntity) entityRay.getEntity();
BlueprintSection sectionAt = blueprintEntity.getSectionAt(entityRay.getLocation()
.subtract(blueprintEntity.position()));
@ -151,7 +151,7 @@ public class BlueprintOverlayRenderer {
shopContext = new BlueprintOverlayShopContext(false, dce.getStockLevelForTrade(list), alreadyPurchased);
ingredients.add(Pair.of(dce.getPaymentItem()
.copyWithCount(dce.getPaymentAmount()),
.copyWithCount(dce.getPaymentAmount()),
!dce.getPaymentItem()
.isEmpty() && shopContext.stockLevel() > shopContext.purchases()));
for (BigItemStack entry : dce.requestData.encodedRequest().stacks())
@ -241,7 +241,8 @@ public class BlueprintOverlayRenderer {
newlyAdded.clear();
newlyMissing.clear();
Search: for (int i = 0; i < 9; i++) {
Search:
for (int i = 0; i < 9; i++) {
FilterItemStack requestedItem = FilterItemStack.of(items.getStackInSlot(i));
if (requestedItem.isEmpty()) {
craftingGrid.put(i, ItemStack.EMPTY);
@ -351,7 +352,7 @@ public class BlueprintOverlayRenderer {
AllGuiTextures.TRADE_OVERLAY.render(guiGraphics, guiGraphics.guiWidth() / 2 - 48, y - 19);
if (shopContext.purchases() > 0) {
guiGraphics.renderItem(AllItems.SHOPPING_LIST.asStack(), guiGraphics.guiWidth() / 2 + 20, y - 20);
guiGraphics.drawString(mc.font, Component.literal("x" + shopContext.purchases()), guiGraphics.guiWidth() / 2 + 20 + 16,
guiGraphics.drawString(mc.font, Component.literal("x" + shopContext.purchases()), guiGraphics.guiWidth() / 2 + 20 + 16,
y - 20 + 4, 0xff_eeeeee, true);
}
}
@ -411,7 +412,7 @@ public class BlueprintOverlayRenderer {
if ((mc.gui.getGuiTicks() / 40) % cycle != i)
continue;
guiGraphics.renderComponentTooltip(mc.gui.getFont(), tooltipLines, mc.getWindow()
.getGuiScaledWidth(),
.getGuiScaledWidth(),
mc.getWindow()
.getGuiScaledHeight());
}
@ -421,7 +422,7 @@ public class BlueprintOverlayRenderer {
}
public static void drawItemStack(GuiGraphics graphics, Minecraft mc, int x, int y, ItemStack itemStack,
String count) {
String count) {
if (itemStack.getItem() instanceof FilterItem) {
int step = AnimationTickHolder.getTicks(mc.level) / 10;
ItemStack[] itemsMatchingFilter = getItemsMatchingFilter(itemStack);

View file

@ -37,6 +37,7 @@ import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult.Type;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.event.tick.EntityTickEvent;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.bus.api.EventPriority;
@ -51,7 +52,6 @@ import net.neoforged.neoforge.event.entity.player.PlayerEvent;
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
import net.neoforged.neoforge.event.level.BlockEvent.BreakEvent;
import net.neoforged.neoforge.event.level.BlockEvent.EntityPlaceEvent;
import net.neoforged.neoforge.event.tick.EntityTickEvent;
@EventBusSubscriber
public class ExtendoGripItem extends Item {
@ -65,11 +65,11 @@ public class ExtendoGripItem extends Item {
AttributeModifier.Operation.ADD_VALUE);
private static final Supplier<Multimap<Holder<Attribute>, AttributeModifier>> rangeModifier = Suppliers.memoize(() ->
// Holding an ExtendoGrip
ImmutableMultimap.of(Attributes.BLOCK_INTERACTION_RANGE, singleRangeAttributeModifier));
// Holding an ExtendoGrip
ImmutableMultimap.of(Attributes.BLOCK_INTERACTION_RANGE, singleRangeAttributeModifier));
private static final Supplier<Multimap<Holder<Attribute>, AttributeModifier>> doubleRangeModifier = Suppliers.memoize(() ->
// Holding two ExtendoGrips o.O
ImmutableMultimap.of(Attributes.BLOCK_INTERACTION_RANGE, doubleRangeAttributeModifier));
// Holding two ExtendoGrips o.O
ImmutableMultimap.of(Attributes.BLOCK_INTERACTION_RANGE, doubleRangeAttributeModifier));
private static DamageSource lastActiveDamageSource;
@ -82,11 +82,9 @@ public class ExtendoGripItem extends Item {
@SubscribeEvent
public static void holdingExtendoGripIncreasesRange(EntityTickEvent.Pre event) {
if (!(event.getEntity() instanceof Player))
if (!(event.getEntity() instanceof Player player))
return;
Player player = (Player) event.getEntity();
CompoundTag persistentData = player.getPersistentData();
boolean inOff = AllItems.EXTENDO_GRIP.isIn(player.getOffhandItem());
boolean inMain = AllItems.EXTENDO_GRIP.isIn(player.getMainHandItem());
@ -246,9 +244,8 @@ public class ExtendoGripItem extends Item {
if (lastActiveDamageSource == null)
return;
Entity entity = lastActiveDamageSource.getDirectEntity();
if (!(entity instanceof Player))
if (!(entity instanceof Player player))
return;
Player player = (Player) entity;
if (!isHoldingExtendoGrip(player))
return;
event.setStrength(event.getStrength() + 2);

View file

@ -66,7 +66,7 @@ public class GoggleOverlayRenderer {
return;
HitResult objectMouseOver = mc.hitResult;
if (!(objectMouseOver instanceof BlockHitResult)) {
if (!(objectMouseOver instanceof BlockHitResult result)) {
lastHovered = null;
hoverTicks = 0;
return;
@ -80,7 +80,6 @@ public class GoggleOverlayRenderer {
return;
}
BlockHitResult result = (BlockHitResult) objectMouseOver;
ClientLevel world = mc.level;
BlockPos pos = result.getBlockPos();

View file

@ -1,10 +1,16 @@
package com.simibubi.create.content.equipment.potatoCannon;
import java.util.UUID;
import java.util.function.BiPredicate;
import java.util.function.Predicate;
import java.util.function.Supplier;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair;
import com.simibubi.create.AllItems;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.mixin.accessor.FallingBlockEntityAccessor;
import net.createmod.catnip.data.WorldAttached;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -35,17 +41,13 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.common.SpecialPlantable;
import net.neoforged.neoforge.common.util.FakePlayer;
import net.neoforged.neoforge.common.util.TriState;
import net.neoforged.neoforge.event.EventHooks;
import net.neoforged.neoforge.event.entity.EntityTeleportEvent;
import java.util.UUID;
import java.util.function.BiPredicate;
import java.util.function.Predicate;
import java.util.function.Supplier;
public class BuiltinPotatoProjectileTypes {
private static final GameProfile ZOMBIE_CONVERTER_NAME =
@ -55,206 +57,204 @@ public class BuiltinPotatoProjectileTypes {
public static final PotatoCannonProjectileType
FALLBACK = create("fallback").damage(0)
FALLBACK = create("fallback").damage(0)
.register(),
POTATO = create("potato").damage(5)
.reloadTicks(15)
.velocity(1.25f)
.knockback(1.5f)
.renderTumbling()
.onBlockHit(plantCrop(Blocks.POTATOES))
.registerAndAssign(Items.POTATO),
POTATO = create("potato").damage(5)
.reloadTicks(15)
.velocity(1.25f)
.knockback(1.5f)
.renderTumbling()
.onBlockHit(plantCrop(Blocks.POTATOES))
.registerAndAssign(Items.POTATO),
BAKED_POTATO = create("baked_potato").damage(5)
.reloadTicks(15)
.velocity(1.25f)
.knockback(0.5f)
.renderTumbling()
.preEntityHit(setFire(3))
.registerAndAssign(Items.BAKED_POTATO),
BAKED_POTATO = create("baked_potato").damage(5)
.reloadTicks(15)
.velocity(1.25f)
.knockback(0.5f)
.renderTumbling()
.preEntityHit(setFire(3))
.registerAndAssign(Items.BAKED_POTATO),
CARROT = create("carrot").damage(4)
.reloadTicks(12)
.velocity(1.45f)
.knockback(0.3f)
.renderTowardMotion(140, 1)
.soundPitch(1.5f)
.onBlockHit(plantCrop(Blocks.CARROTS))
.registerAndAssign(Items.CARROT),
CARROT = create("carrot").damage(4)
.reloadTicks(12)
.velocity(1.45f)
.knockback(0.3f)
.renderTowardMotion(140, 1)
.soundPitch(1.5f)
.onBlockHit(plantCrop(Blocks.CARROTS))
.registerAndAssign(Items.CARROT),
GOLDEN_CARROT = create("golden_carrot").damage(12)
.reloadTicks(15)
.velocity(1.45f)
.knockback(0.5f)
.renderTowardMotion(140, 2)
.soundPitch(1.5f)
.registerAndAssign(Items.GOLDEN_CARROT),
GOLDEN_CARROT = create("golden_carrot").damage(12)
.reloadTicks(15)
.velocity(1.45f)
.knockback(0.5f)
.renderTowardMotion(140, 2)
.soundPitch(1.5f)
.registerAndAssign(Items.GOLDEN_CARROT),
SWEET_BERRIES = create("sweet_berry").damage(3)
.reloadTicks(10)
.knockback(0.1f)
.velocity(1.05f)
.renderTumbling()
.splitInto(3)
.soundPitch(1.25f)
.registerAndAssign(Items.SWEET_BERRIES),
SWEET_BERRIES = create("sweet_berry").damage(3)
.reloadTicks(10)
.knockback(0.1f)
.velocity(1.05f)
.renderTumbling()
.splitInto(3)
.soundPitch(1.25f)
.registerAndAssign(Items.SWEET_BERRIES),
GLOW_BERRIES = create("glow_berry").damage(2)
.reloadTicks(10)
.knockback(0.05f)
.velocity(1.05f)
.renderTumbling()
.splitInto(2)
.soundPitch(1.2f)
.onEntityHit(potion(MobEffects.GLOWING, 1, 200, false))
.registerAndAssign(Items.GLOW_BERRIES),
GLOW_BERRIES = create("glow_berry").damage(2)
.reloadTicks(10)
.knockback(0.05f)
.velocity(1.05f)
.renderTumbling()
.splitInto(2)
.soundPitch(1.2f)
.onEntityHit(potion(MobEffects.GLOWING, 1, 200, false))
.registerAndAssign(Items.GLOW_BERRIES),
CHOCOLATE_BERRIES = create("chocolate_berry").damage(4)
.reloadTicks(10)
.knockback(0.2f)
.velocity(1.05f)
.renderTumbling()
.splitInto(3)
.soundPitch(1.25f)
.registerAndAssign(AllItems.CHOCOLATE_BERRIES.get()),
CHOCOLATE_BERRIES = create("chocolate_berry").damage(4)
.reloadTicks(10)
.knockback(0.2f)
.velocity(1.05f)
.renderTumbling()
.splitInto(3)
.soundPitch(1.25f)
.registerAndAssign(AllItems.CHOCOLATE_BERRIES.get()),
POISON_POTATO = create("poison_potato").damage(5)
.reloadTicks(15)
.knockback(0.05f)
.velocity(1.25f)
.renderTumbling()
.onEntityHit(potion(MobEffects.POISON, 1, 160, true))
.registerAndAssign(Items.POISONOUS_POTATO),
POISON_POTATO = create("poison_potato").damage(5)
.reloadTicks(15)
.knockback(0.05f)
.velocity(1.25f)
.renderTumbling()
.onEntityHit(potion(MobEffects.POISON, 1, 160, true))
.registerAndAssign(Items.POISONOUS_POTATO),
CHORUS_FRUIT = create("chorus_fruit").damage(3)
.reloadTicks(15)
.velocity(1.20f)
.knockback(0.05f)
.renderTumbling()
.onEntityHit(chorusTeleport(20))
.registerAndAssign(Items.CHORUS_FRUIT),
CHORUS_FRUIT = create("chorus_fruit").damage(3)
.reloadTicks(15)
.velocity(1.20f)
.knockback(0.05f)
.renderTumbling()
.onEntityHit(chorusTeleport(20))
.registerAndAssign(Items.CHORUS_FRUIT),
APPLE = create("apple").damage(5)
.reloadTicks(10)
.velocity(1.45f)
.knockback(0.5f)
.renderTumbling()
.soundPitch(1.1f)
.registerAndAssign(Items.APPLE),
APPLE = create("apple").damage(5)
.reloadTicks(10)
.velocity(1.45f)
.knockback(0.5f)
.renderTumbling()
.soundPitch(1.1f)
.registerAndAssign(Items.APPLE),
HONEYED_APPLE = create("honeyed_apple").damage(6)
.reloadTicks(15)
.velocity(1.35f)
.knockback(0.1f)
.renderTumbling()
.soundPitch(1.1f)
.onEntityHit(potion(MobEffects.MOVEMENT_SLOWDOWN, 2, 160, true))
.registerAndAssign(AllItems.HONEYED_APPLE.get()),
HONEYED_APPLE = create("honeyed_apple").damage(6)
.reloadTicks(15)
.velocity(1.35f)
.knockback(0.1f)
.renderTumbling()
.soundPitch(1.1f)
.onEntityHit(potion(MobEffects.MOVEMENT_SLOWDOWN, 2, 160, true))
.registerAndAssign(AllItems.HONEYED_APPLE.get()),
GOLDEN_APPLE = create("golden_apple").damage(1)
.reloadTicks(100)
.velocity(1.45f)
.knockback(0.05f)
.renderTumbling()
.soundPitch(1.1f)
.onEntityHit(ray -> {
Entity entity = ray.getEntity();
Level world = entity.level();
GOLDEN_APPLE = create("golden_apple").damage(1)
.reloadTicks(100)
.velocity(1.45f)
.knockback(0.05f)
.renderTumbling()
.soundPitch(1.1f)
.onEntityHit(ray -> {
Entity entity = ray.getEntity();
Level world = entity.level();
if (!(entity instanceof ZombieVillager) || !((ZombieVillager) entity).hasEffect(MobEffects.WEAKNESS))
return foodEffects(Foods.GOLDEN_APPLE, false).test(ray);
if (world.isClientSide)
return false;
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(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLDEN_APPLE, 1));
((ZombieVillager) entity).mobInteract(dummy, InteractionHand.MAIN_HAND);
return true;
})
.registerAndAssign(Items.GOLDEN_APPLE),
FakePlayer dummy = ZOMBIE_CONVERTERS.get(world);
dummy.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLDEN_APPLE, 1));
((ZombieVillager) entity).mobInteract(dummy, InteractionHand.MAIN_HAND);
return true;
})
.registerAndAssign(Items.GOLDEN_APPLE),
ENCHANTED_GOLDEN_APPLE = create("enchanted_golden_apple").damage(1)
.reloadTicks(100)
.velocity(1.45f)
.knockback(0.05f)
.renderTumbling()
.soundPitch(1.1f)
.onEntityHit(foodEffects(Foods.ENCHANTED_GOLDEN_APPLE, false))
.registerAndAssign(Items.ENCHANTED_GOLDEN_APPLE),
ENCHANTED_GOLDEN_APPLE = create("enchanted_golden_apple").damage(1)
.reloadTicks(100)
.velocity(1.45f)
.knockback(0.05f)
.renderTumbling()
.soundPitch(1.1f)
.onEntityHit(foodEffects(Foods.ENCHANTED_GOLDEN_APPLE, false))
.registerAndAssign(Items.ENCHANTED_GOLDEN_APPLE),
BEETROOT = create("beetroot").damage(2)
.reloadTicks(5)
.velocity(1.6f)
.knockback(0.1f)
.renderTowardMotion(140, 2)
.soundPitch(1.6f)
.registerAndAssign(Items.BEETROOT),
BEETROOT = create("beetroot").damage(2)
.reloadTicks(5)
.velocity(1.6f)
.knockback(0.1f)
.renderTowardMotion(140, 2)
.soundPitch(1.6f)
.registerAndAssign(Items.BEETROOT),
MELON_SLICE = create("melon_slice").damage(3)
.reloadTicks(8)
.knockback(0.1f)
.velocity(1.45f)
.renderTumbling()
.soundPitch(1.5f)
.registerAndAssign(Items.MELON_SLICE),
MELON_SLICE = create("melon_slice").damage(3)
.reloadTicks(8)
.knockback(0.1f)
.velocity(1.45f)
.renderTumbling()
.soundPitch(1.5f)
.registerAndAssign(Items.MELON_SLICE),
GLISTERING_MELON = create("glistering_melon").damage(5)
.reloadTicks(8)
.knockback(0.1f)
.velocity(1.45f)
.renderTumbling()
.soundPitch(1.5f)
.onEntityHit(potion(MobEffects.GLOWING, 1, 100, true))
.registerAndAssign(Items.GLISTERING_MELON_SLICE),
GLISTERING_MELON = create("glistering_melon").damage(5)
.reloadTicks(8)
.knockback(0.1f)
.velocity(1.45f)
.renderTumbling()
.soundPitch(1.5f)
.onEntityHit(potion(MobEffects.GLOWING, 1, 100, true))
.registerAndAssign(Items.GLISTERING_MELON_SLICE),
MELON_BLOCK = create("melon_block").damage(8)
.reloadTicks(20)
.knockback(2.0f)
.velocity(0.95f)
.renderTumbling()
.soundPitch(0.9f)
.onBlockHit(placeBlockOnGround(Blocks.MELON))
.registerAndAssign(Blocks.MELON),
MELON_BLOCK = create("melon_block").damage(8)
.reloadTicks(20)
.knockback(2.0f)
.velocity(0.95f)
.renderTumbling()
.soundPitch(0.9f)
.onBlockHit(placeBlockOnGround(Blocks.MELON))
.registerAndAssign(Blocks.MELON),
PUMPKIN_BLOCK = create("pumpkin_block").damage(6)
.reloadTicks(15)
.knockback(2.0f)
.velocity(0.95f)
.renderTumbling()
.soundPitch(0.9f)
.onBlockHit(placeBlockOnGround(Blocks.PUMPKIN))
.registerAndAssign(Blocks.PUMPKIN),
PUMPKIN_BLOCK = create("pumpkin_block").damage(6)
.reloadTicks(15)
.knockback(2.0f)
.velocity(0.95f)
.renderTumbling()
.soundPitch(0.9f)
.onBlockHit(placeBlockOnGround(Blocks.PUMPKIN))
.registerAndAssign(Blocks.PUMPKIN),
PUMPKIN_PIE = create("pumpkin_pie").damage(7)
.reloadTicks(15)
.knockback(0.05f)
.velocity(1.1f)
.renderTumbling()
.sticky()
.soundPitch(1.1f)
.registerAndAssign(Items.PUMPKIN_PIE),
PUMPKIN_PIE = create("pumpkin_pie").damage(7)
.reloadTicks(15)
.knockback(0.05f)
.velocity(1.1f)
.renderTumbling()
.sticky()
.soundPitch(1.1f)
.registerAndAssign(Items.PUMPKIN_PIE),
CAKE = create("cake").damage(8)
.reloadTicks(15)
.knockback(0.1f)
.velocity(1.1f)
.renderTumbling()
.sticky()
.soundPitch(1.0f)
.registerAndAssign(Items.CAKE),
CAKE = create("cake").damage(8)
.reloadTicks(15)
.knockback(0.1f)
.velocity(1.1f)
.renderTumbling()
.sticky()
.soundPitch(1.0f)
.registerAndAssign(Items.CAKE),
BLAZE_CAKE = create("blaze_cake").damage(15)
.reloadTicks(20)
.knockback(0.3f)
.velocity(1.1f)
.renderTumbling()
.sticky()
.preEntityHit(setFire(12))
.soundPitch(1.0f)
.registerAndAssign(AllItems.BLAZE_CAKE.get())
;
BLAZE_CAKE = create("blaze_cake").damage(15)
.reloadTicks(20)
.knockback(0.3f)
.velocity(1.1f)
.renderTumbling()
.sticky()
.preEntityHit(setFire(12))
.soundPitch(1.0f)
.registerAndAssign(AllItems.BLAZE_CAKE.get());
private static PotatoCannonProjectileType.Builder create(String name) {
return new PotatoCannonProjectileType.Builder(Create.asResource(name));
@ -378,9 +378,8 @@ public class BuiltinPotatoProjectileTypes {
Level world = entity.getCommandSenderWorld();
if (world.isClientSide)
return true;
if (!(entity instanceof LivingEntity))
if (!(entity instanceof LivingEntity livingEntity))
return false;
LivingEntity livingEntity = (LivingEntity) entity;
double entityX = livingEntity.getX();
double entityY = livingEntity.getY();
@ -415,6 +414,7 @@ public class BuiltinPotatoProjectileTypes {
};
}
public static void register() {}
public static void register() {
}
}

View file

@ -36,6 +36,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.entity.IEntityWithComplexSpawn;
public class PotatoProjectileEntity extends AbstractHurtingProjectile implements IEntityWithComplexSpawn {
@ -216,14 +217,12 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
if (random.nextDouble() <= recoveryChance)
recoverItem();
if (!(target instanceof LivingEntity)) {
if (!(target instanceof LivingEntity livingentity)) {
playHitSound(level(), position());
kill();
return;
}
LivingEntity livingentity = (LivingEntity) target;
if (type.getReloadTicks() < 10)
livingentity.invulnerableTime = type.getReloadTicks() + 10;

View file

@ -121,8 +121,8 @@ public class SandPaperItem extends Item implements CustomUseEffectsItem {
if (worldIn.isClientSide) {
spawnParticles(entityLiving.getEyePosition(1)
.add(entityLiving.getLookAngle()
.scale(.5f)),
.add(entityLiving.getLookAngle()
.scale(.5f)),
toPolish, worldIn);
return stack;
}

View file

@ -19,9 +19,9 @@ import com.simibubi.create.foundation.blockEntity.behaviour.animatedContainer.An
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.utility.ResetableLazy;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.animation.LerpedFloat;
import net.createmod.catnip.animation.LerpedFloat.Chaser;
import net.createmod.catnip.math.VecHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap.Builder;
@ -42,6 +42,7 @@ import net.minecraft.world.item.component.ItemContainerContents;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
@ -124,7 +125,7 @@ public class ToolboxBlockEntity extends SmartBlockEntity implements MenuProvider
boolean update = false;
for (Iterator<Entry<Integer, WeakHashMap<Player, Integer>>> toolboxSlots = connectedPlayers.entrySet()
.iterator(); toolboxSlots.hasNext();) {
.iterator(); toolboxSlots.hasNext(); ) {
Entry<Integer, WeakHashMap<Player, Integer>> toolboxSlotEntry = toolboxSlots.next();
WeakHashMap<Player, Integer> set = toolboxSlotEntry.getValue();
@ -134,7 +135,7 @@ public class ToolboxBlockEntity extends SmartBlockEntity implements MenuProvider
boolean clear = referenceItem.isEmpty();
for (Iterator<Entry<Player, Integer>> playerEntries = set.entrySet()
.iterator(); playerEntries.hasNext();) {
.iterator(); playerEntries.hasNext(); ) {
Entry<Player, Integer> playerEntry = playerEntries.next();
Player player = playerEntry.getKey();
@ -226,16 +227,11 @@ public class ToolboxBlockEntity extends SmartBlockEntity implements MenuProvider
Set<ServerPlayer> affected = new HashSet<>();
for (Iterator<Entry<Integer, WeakHashMap<Player, Integer>>> toolboxSlots = connectedPlayers.entrySet()
.iterator(); toolboxSlots.hasNext();) {
for (Entry<Integer, WeakHashMap<Player, Integer>> toolboxSlotEntry : connectedPlayers.entrySet()) {
Entry<Integer, WeakHashMap<Player, Integer>> toolboxSlotEntry = toolboxSlots.next();
WeakHashMap<Player, Integer> set = toolboxSlotEntry.getValue();
for (Iterator<Entry<Player, Integer>> playerEntries = set.entrySet()
.iterator(); playerEntries.hasNext();) {
Entry<Player, Integer> playerEntry = playerEntries.next();
for (Entry<Player, Integer> playerEntry : set.entrySet()) {
Player player = playerEntry.getKey();
int hotbarSlot = playerEntry.getValue();
@ -359,8 +355,8 @@ public class ToolboxBlockEntity extends SmartBlockEntity implements MenuProvider
public Component getDisplayName() {
return customName != null ? customName
: AllBlocks.TOOLBOXES.get(getColor())
.get()
.getName();
.get()
.getName();
}
@Override

View file

@ -10,12 +10,12 @@ import net.createmod.catnip.net.base.ServerboundPacketPayload;
import io.netty.buffer.ByteBuf;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.neoforge.items.ItemHandlerHelper;
public record ToolboxDisposeAllPacket(BlockPos toolboxPos) implements ServerboundPacketPayload {

View file

@ -14,6 +14,7 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.neoforge.items.ItemHandlerHelper;
public record ToolboxEquipPacket(BlockPos toolboxPos, int slot, int hotbarSlot) implements ServerboundPacketPayload {

View file

@ -12,7 +12,6 @@ import net.createmod.catnip.data.WorldAttached;
import net.createmod.catnip.nbt.NBTHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
@ -44,12 +43,11 @@ public class ToolboxHandler {
return;
if (!(world instanceof ServerLevel))
return;
if (!(entity instanceof ServerPlayer))
if (!(entity instanceof ServerPlayer player))
return;
if (entity.tickCount % validationTimer != 0)
return;
ServerPlayer player = (ServerPlayer) entity;
if (!player.getPersistentData()
.contains("CreateToolboxData"))
return;
@ -90,8 +88,8 @@ public class ToolboxHandler {
if (player.getPersistentData()
.contains("CreateToolboxData")
&& !player.getPersistentData()
.getCompound("CreateToolboxData")
.isEmpty()) {
.getCompound("CreateToolboxData")
.isEmpty()) {
syncData(player);
}
}

View file

@ -11,7 +11,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
@ -20,6 +19,7 @@ import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.neoforge.items.SlotItemHandler;
public class ToolboxMenu extends MenuBase<ToolboxBlockEntity> {
@ -130,8 +130,8 @@ public class ToolboxMenu extends MenuBase<ToolboxBlockEntity> {
int x = 79;
int y = 37;
int[] xOffsets = { x, x + 33, x + 66, x + 66 + 6, x + 66, x + 33, x, x - 6 };
int[] yOffsets = { y, y - 6, y, y + 33, y + 66, y + 66 + 6, y + 66, y + 33 };
int[] xOffsets = {x, x + 33, x + 66, x + 66 + 6, x + 66, x + 33, x, x - 6};
int[] yOffsets = {y, y - 6, y, y + 33, y + 66, y + 66 + 6, y + 66, y + 33};
for (int compartment = 0; compartment < 8; compartment++) {
int baseIndex = compartment * STACKS_PER_COMPARTMENT;

View file

@ -10,6 +10,7 @@ import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
@ -40,12 +41,11 @@ public class WrenchEventHandler {
.getBlockState(event.getPos());
Block block = state.getBlock();
if (!(block instanceof IWrenchable))
if (!(block instanceof IWrenchable actor))
return;
BlockHitResult hitVec = event.getHitVec();
UseOnContext context = new UseOnContext(player, event.getHand(), hitVec);
IWrenchable actor = (IWrenchable) block;
InteractionResult result =
player.isShiftKeyDown() ? actor.onSneakWrenched(state, context) : actor.onWrenched(state, context);

View file

@ -51,13 +51,12 @@ public class WrenchItem extends Item {
.getBlockState(context.getClickedPos());
Block block = state.getBlock();
if (!(block instanceof IWrenchable)) {
if (!(block instanceof IWrenchable actor)) {
if (player.isShiftKeyDown() && canWrenchPickup(state))
return onItemUseOnOther(context);
return super.useOn(context);
}
IWrenchable actor = (IWrenchable) block;
if (player.isShiftKeyDown())
return actor.onSneakWrenched(state, context);
return actor.onWrenched(state, context);
@ -85,7 +84,7 @@ public class WrenchItem extends Item {
public static void wrenchInstaKillsMinecarts(AttackEntityEvent event) {
Entity target = event.getTarget();
if (!(target instanceof AbstractMinecart))
if (!(target instanceof AbstractMinecart minecart))
return;
Player player = event.getEntity();
ItemStack heldItem = player.getMainHandItem();
@ -93,7 +92,6 @@ public class WrenchItem extends Item {
return;
if (player.isCreative())
return;
AbstractMinecart minecart = (AbstractMinecart) target;
minecart.hurt(minecart.damageSources().playerAttack(player), 100);
}
}

View file

@ -33,6 +33,7 @@ import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.neoforged.neoforge.capabilities.Capabilities;
public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainBlockEntity> {
@ -43,7 +44,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainB
@Override
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
if (stack.getItem() instanceof BlockItem && stack.getCapability(Capabilities.FluidHandler.ITEM) == null)
if (stack.getItem() instanceof BlockItem && stack.getCapability(Capabilities.FluidHandler.ITEM) == null)
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
return onBlockEntityUseItemOn(level, pos, be -> {
@ -69,14 +70,13 @@ public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainB
@Override
public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) {
super.updateEntityAfterFallOn(worldIn, entityIn);
if (!(entityIn instanceof ItemEntity))
if (!(entityIn instanceof ItemEntity itemEntity))
return;
if (!entityIn.isAlive())
return;
if (entityIn.level().isClientSide)
return;
ItemEntity itemEntity = (ItemEntity) entityIn;
DirectBeltInputBehaviour inputBehaviour =
BlockEntityBehaviour.get(worldIn, entityIn.blockPosition(), DirectBeltInputBehaviour.TYPE);
if (inputBehaviour == null)
@ -92,7 +92,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainB
}
protected ItemInteractionResult tryExchange(Level worldIn, Player player, InteractionHand handIn, ItemStack heldItem,
ItemDrainBlockEntity be) {
ItemDrainBlockEntity be) {
if (FluidHelper.tryEmptyItemIntoBE(worldIn, player, handIn, heldItem, be))
return ItemInteractionResult.SUCCESS;
if (GenericItemEmptying.canItemBeEmptied(worldIn, heldItem))
@ -102,7 +102,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, IBE<ItemDrainB
@Override
public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_,
CollisionContext p_220053_4_) {
CollisionContext p_220053_4_) {
return AllShapes.CASING_13PX.get(Direction.UP);
}

View file

@ -11,6 +11,7 @@ import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.fluids.FluidStack;
@ -20,7 +21,8 @@ public class FluidParticleData implements ParticleOptions, ICustomParticleData<F
private ParticleType<FluidParticleData> type;
private FluidStack fluid;
public FluidParticleData() {}
public FluidParticleData() {
}
@SuppressWarnings("unchecked")
public FluidParticleData(ParticleType<?> type, FluidStack fluid) {

View file

@ -58,13 +58,13 @@ public class PumpBlock extends DirectionalKineticBlock
@Override
public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_,
CollisionContext p_220053_4_) {
CollisionContext p_220053_4_) {
return AllShapes.PUMP.get(state.getValue(FACING));
}
@Override
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block otherBlock, BlockPos neighborPos,
boolean isMoving) {
boolean isMoving) {
DebugPackets.sendNeighborsUpdatePacket(world, pos);
Direction d = FluidPropagator.validateNeighbourChange(state, world, pos, otherBlock, neighborPos, isMoving);
if (d == null)
@ -88,7 +88,7 @@ public class PumpBlock extends DirectionalKineticBlock
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world,
BlockPos pos, BlockPos neighbourPos) {
BlockPos pos, BlockPos neighbourPos) {
if (state.getValue(BlockStateProperties.WATERLOGGED))
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
return state;
@ -146,9 +146,8 @@ public class PumpBlock extends DirectionalKineticBlock
if (isPump(state) && isPump(oldState) && state.getValue(FACING) == oldState.getValue(FACING)
.getOpposite()) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (!(blockEntity instanceof PumpBlockEntity))
if (!(blockEntity instanceof PumpBlockEntity pump))
return;
PumpBlockEntity pump = (PumpBlockEntity) blockEntity;
pump.pressureUpdate = true;
}
}

View file

@ -23,10 +23,10 @@ import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import net.createmod.catnip.math.BlockFace;
import net.createmod.catnip.data.Couple;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.data.Pair;
import net.createmod.catnip.math.BlockFace;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
@ -35,6 +35,7 @@ import net.minecraft.world.level.LevelAccessor;
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.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
@ -227,7 +228,7 @@ public class PumpBlockEntity extends KineticBlockEntity {
}
protected boolean searchForEndpointRecursively(Map<BlockPos, Pair<Integer, Map<Direction, Boolean>>> pipeGraph,
Set<BlockFace> targets, Map<Integer, Set<BlockFace>> validFaces, BlockFace currentFace, boolean pull) {
Set<BlockFace> targets, Map<Integer, Set<BlockFace>> validFaces, BlockFace currentFace, boolean pull) {
BlockPos currentPos = currentFace.getPos();
if (!pipeGraph.containsKey(currentPos))
return false;
@ -276,8 +277,7 @@ public class PumpBlockEntity extends KineticBlockEntity {
// facing a pump
if (PumpBlock.isPump(connectedState) && connectedState.getValue(PumpBlock.FACING)
.getAxis() == face.getAxis() && blockEntity instanceof PumpBlockEntity) {
PumpBlockEntity pumpBE = (PumpBlockEntity) blockEntity;
.getAxis() == face.getAxis() && blockEntity instanceof PumpBlockEntity pumpBE) {
return pumpBE.isPullingOnSide(pumpBE.isFront(blockFace.getOppositeFace())) != pull;
}
@ -362,7 +362,7 @@ public class PumpBlockEntity extends KineticBlockEntity {
@Override
public AttachmentTypes getRenderedRimAttachment(BlockAndTintGetter world, BlockPos pos, BlockState state,
Direction direction) {
Direction direction) {
AttachmentTypes attachment = super.getRenderedRimAttachment(world, pos, state, direction);
if (attachment == AttachmentTypes.RIM)
return AttachmentTypes.NONE;

View file

@ -50,6 +50,7 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.common.util.DeferredSoundType;
import net.neoforged.neoforge.fluids.FluidStack;
@ -124,7 +125,7 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
@Override
public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos,
CollisionContext pContext) {
CollisionContext pContext) {
if (pContext == CollisionContext.empty())
return CAMPFIRE_SMOKE_CLIP;
return pState.getShape(pLevel, pPos);
@ -137,7 +138,7 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
@Override
public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState,
LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) {
LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) {
if (pDirection == Direction.DOWN && pNeighborState.getBlock() != this)
withBlockEntityDo(pLevel, pCurrentPos, FluidTankBlockEntity::updateBoilerTemperature);
return pState;
@ -252,9 +253,8 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
if (state.hasBlockEntity() && (state.getBlock() != newState.getBlock() || !newState.hasBlockEntity())) {
BlockEntity be = world.getBlockEntity(pos);
if (!(be instanceof FluidTankBlockEntity))
if (!(be instanceof FluidTankBlockEntity tankBE))
return;
FluidTankBlockEntity tankBE = (FluidTankBlockEntity) be;
world.removeBlockEntity(pos);
ConnectivityHandler.splitMulti(tankBE);
}
@ -276,16 +276,16 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
return state;
boolean x = mirror == Mirror.FRONT_BACK;
switch (state.getValue(SHAPE)) {
case WINDOW_NE:
return state.setValue(SHAPE, x ? Shape.WINDOW_NW : Shape.WINDOW_SE);
case WINDOW_NW:
return state.setValue(SHAPE, x ? Shape.WINDOW_NE : Shape.WINDOW_SW);
case WINDOW_SE:
return state.setValue(SHAPE, x ? Shape.WINDOW_SW : Shape.WINDOW_NE);
case WINDOW_SW:
return state.setValue(SHAPE, x ? Shape.WINDOW_SE : Shape.WINDOW_NW);
default:
return state;
case WINDOW_NE:
return state.setValue(SHAPE, x ? Shape.WINDOW_NW : Shape.WINDOW_SE);
case WINDOW_NW:
return state.setValue(SHAPE, x ? Shape.WINDOW_NE : Shape.WINDOW_SW);
case WINDOW_SE:
return state.setValue(SHAPE, x ? Shape.WINDOW_SW : Shape.WINDOW_NE);
case WINDOW_SW:
return state.setValue(SHAPE, x ? Shape.WINDOW_SE : Shape.WINDOW_NW);
default:
return state;
}
}
@ -298,16 +298,16 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
private BlockState rotateOnce(BlockState state) {
switch (state.getValue(SHAPE)) {
case WINDOW_NE:
return state.setValue(SHAPE, Shape.WINDOW_SE);
case WINDOW_NW:
return state.setValue(SHAPE, Shape.WINDOW_NE);
case WINDOW_SE:
return state.setValue(SHAPE, Shape.WINDOW_SW);
case WINDOW_SW:
return state.setValue(SHAPE, Shape.WINDOW_NW);
default:
return state;
case WINDOW_NE:
return state.setValue(SHAPE, Shape.WINDOW_SE);
case WINDOW_NW:
return state.setValue(SHAPE, Shape.WINDOW_NE);
case WINDOW_SE:
return state.setValue(SHAPE, Shape.WINDOW_SW);
case WINDOW_SW:
return state.setValue(SHAPE, Shape.WINDOW_NW);
default:
return state;
}
}
@ -348,7 +348,7 @@ public class FluidTankBlock extends Block implements IWrenchable, IBE<FluidTankB
public static void updateBoilerState(BlockState pState, Level pLevel, BlockPos tankPos) {
BlockState tankState = pLevel.getBlockState(tankPos);
if (!(tankState.getBlock()instanceof FluidTankBlock tank))
if (!(tankState.getBlock() instanceof FluidTankBlock tank))
return;
FluidTankBlockEntity tankBE = tank.getBlockEntity(pLevel, tankPos);
if (tankBE == null)

View file

@ -15,8 +15,8 @@ import com.simibubi.create.foundation.fluid.FluidHelper;
import it.unimi.dsi.fastutil.PriorityQueue;
import it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue;
import net.createmod.catnip.math.BBHelper;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.math.BBHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
@ -30,6 +30,7 @@ import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.neoforged.neoforge.fluids.FluidStack;
public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
@ -107,8 +108,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
&& blockState.getValue(BlockStateProperties.WATERLOGGED)) {
emptied = blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false));
fluid = Fluids.WATER;
} else if (blockState.getBlock() instanceof LiquidBlock) {
LiquidBlock flowingFluid = (LiquidBlock) blockState.getBlock();
} else if (blockState.getBlock() instanceof LiquidBlock flowingFluid) {
emptied = Blocks.AIR.defaultBlockState();
if (blockState.getValue(LiquidBlock.LEVEL) == 0)
fluid = flowingFluid.fluid;
@ -125,7 +125,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
}
} else if (blockState.getFluidState()
.getType() != Fluids.EMPTY && blockState.getCollisionShape(world, currentPos, CollisionContext.empty())
.isEmpty()) {
.isEmpty()) {
fluid = blockState.getFluidState()
.getType();
emptied = Blocks.AIR.defaultBlockState();
@ -230,7 +230,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
return blockState.getValue(LiquidBlock.LEVEL) == 0 ? FluidBlockType.SOURCE : FluidBlockType.FLOWING;
if (blockState.getFluidState()
.getType() != Fluids.EMPTY && blockState.getCollisionShape(getWorld(), pos, CollisionContext.empty())
.isEmpty())
.isEmpty())
return FluidBlockType.SOURCE;
return FluidBlockType.NONE;
}

View file

@ -14,8 +14,8 @@ import com.simibubi.create.infrastructure.config.AllConfigs;
import it.unimi.dsi.fastutil.PriorityQueue;
import it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue;
import net.createmod.catnip.math.BBHelper;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.math.BBHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.sounds.SoundEvents;
@ -203,8 +203,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
}
LevelTickAccess<Fluid> pendingFluidTicks = world.getFluidTicks();
if (pendingFluidTicks instanceof LevelTicks) {
LevelTicks<Fluid> serverTickList = (LevelTicks<Fluid>) pendingFluidTicks;
if (pendingFluidTicks instanceof LevelTicks<Fluid> serverTickList) {
serverTickList.clearArea(new BoundingBox(currentPos));
}
@ -268,7 +267,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
if (fluidState.getType() != Fluids.EMPTY
&& blockState.getCollisionShape(getWorld(), pos, CollisionContext.empty())
.isEmpty())
.isEmpty())
return toFill.isSame(fluidState.getType()) ? SpaceType.FILLED : SpaceType.BLOCKING;
return canBeReplacedByFluid(world, pos, blockState) ? SpaceType.FILLABLE : SpaceType.BLOCKING;

View file

@ -5,9 +5,9 @@ import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer;
import com.simibubi.create.infrastructure.config.AllConfigs;
import net.createmod.catnip.render.SuperByteBufferCache;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.outliner.Outliner;
import net.createmod.catnip.render.SuperByteBufferCache;
import net.createmod.catnip.theme.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
@ -47,16 +47,16 @@ public class KineticDebugger {
if (be.getTheoreticalSpeed() != 0 && !shape.isEmpty())
Outliner.getInstance().chaseAABB("kineticSource", shape.bounds()
.move(toOutline))
.lineWidth(1 / 16f)
.colored(be.hasSource() ? Color.generateFromLong(be.network).getRGB() : 0xffcc00);
.lineWidth(1 / 16f)
.colored(be.hasSource() ? Color.generateFromLong(be.network).getRGB() : 0xffcc00);
if (state.getBlock() instanceof IRotate) {
Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state);
Vec3 vec = Vec3.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, axis)
.getNormal());
.getNormal());
Vec3 center = VecHelper.getCenterOf(be.getBlockPos());
Outliner.getInstance().showLine("rotationAxis", center.add(vec), center.subtract(vec))
.lineWidth(1 / 16f);
.lineWidth(1 / 16f);
}
}
@ -76,10 +76,9 @@ public class KineticDebugger {
return null;
if (world == null)
return null;
if (!(obj instanceof BlockHitResult))
if (!(obj instanceof BlockHitResult ray))
return null;
BlockHitResult ray = (BlockHitResult) obj;
BlockEntity be = world.getBlockEntity(ray.getBlockPos());
if (!(be instanceof KineticBlockEntity))
return null;

View file

@ -47,11 +47,9 @@ public class RotationPropagator {
Block fromBlock = stateFrom.getBlock();
Block toBlock = stateTo.getBlock();
if (!(fromBlock instanceof IRotate && toBlock instanceof IRotate))
if (!(fromBlock instanceof IRotate definitionFrom && toBlock instanceof IRotate definitionTo))
return 0;
final IRotate definitionFrom = (IRotate) fromBlock;
final IRotate definitionTo = (IRotate) toBlock;
final BlockPos diff = to.getBlockPos()
.subtract(from.getBlockPos());
final Direction direction = Direction.getNearest(diff.getX(), diff.getY(), diff.getZ());
@ -157,7 +155,7 @@ public class RotationPropagator {
}
private static float getAxisModifier(KineticBlockEntity be, Direction direction) {
if (!(be.hasSource()||be.isSource()) || !(be instanceof DirectionalShaftHalvesBlockEntity))
if (!(be.hasSource() || be.isSource()) || !(be instanceof DirectionalShaftHalvesBlockEntity))
return 1;
Direction source = ((DirectionalShaftHalvesBlockEntity) be).getSourceFacing();
@ -235,7 +233,7 @@ public class RotationPropagator {
Math.signum(newSpeed) != Math.signum(speedOfNeighbour) && (newSpeed != 0 && speedOfNeighbour != 0);
boolean tooFast = Math.abs(newSpeed) > AllConfigs.server().kinetics.maxRotationSpeed.get()
|| Math.abs(oppositeSpeed) > AllConfigs.server().kinetics.maxRotationSpeed.get();
|| Math.abs(oppositeSpeed) > AllConfigs.server().kinetics.maxRotationSpeed.get();
// Check for both the new speed and the opposite speed, just in case
boolean speedChangedTooOften = currentTE.getFlickerScore() > MAX_FLICKER_SCORE;
@ -321,10 +319,9 @@ public class RotationPropagator {
if (!(neighbourState.getBlock() instanceof IRotate))
continue;
BlockEntity blockEntity = worldIn.getBlockEntity(neighbourPos);
if (!(blockEntity instanceof KineticBlockEntity))
if (!(blockEntity instanceof KineticBlockEntity neighbourBE))
continue;
final KineticBlockEntity neighbourBE = (KineticBlockEntity) blockEntity;
if (!neighbourBE.hasSource() || !neighbourBE.source.equals(pos))
continue;
@ -350,9 +347,8 @@ public class RotationPropagator {
while (!frontier.isEmpty()) {
final BlockPos pos = frontier.remove(0);
BlockEntity blockEntity = world.getBlockEntity(pos);
if (!(blockEntity instanceof KineticBlockEntity))
if (!(blockEntity instanceof KineticBlockEntity currentBE))
continue;
final KineticBlockEntity currentBE = (KineticBlockEntity) blockEntity;
currentBE.removeSource();
currentBE.sendData();
@ -393,9 +389,8 @@ public class RotationPropagator {
return null;
BlockEntity neighbourBE = currentTE.getLevel()
.getBlockEntity(neighbourPos);
if (!(neighbourBE instanceof KineticBlockEntity))
if (!(neighbourBE instanceof KineticBlockEntity neighbourKBE))
return null;
KineticBlockEntity neighbourKBE = (KineticBlockEntity) neighbourBE;
if (!(neighbourKBE.getBlockState()
.getBlock() instanceof IRotate))
return null;
@ -439,9 +434,8 @@ public class RotationPropagator {
}
BlockState blockState = be.getBlockState();
if (!(blockState.getBlock() instanceof IRotate))
if (!(blockState.getBlock() instanceof IRotate block))
return neighbours;
IRotate block = (IRotate) blockState.getBlock();
return be.addPropagationLocations(block, blockState, neighbours);
}

View file

@ -38,9 +38,8 @@ public abstract class GeneratingKineticBlockEntity extends KineticBlockEntity {
public void setSource(BlockPos source) {
super.setSource(source);
BlockEntity blockEntity = level.getBlockEntity(source);
if (!(blockEntity instanceof KineticBlockEntity))
if (!(blockEntity instanceof KineticBlockEntity sourceBE))
return;
KineticBlockEntity sourceBE = (KineticBlockEntity) blockEntity;
if (reActivateSource && Math.abs(sourceBE.getSpeed()) >= Math.abs(getGeneratedSpeed()))
reActivateSource = false;
}

View file

@ -28,8 +28,7 @@ public abstract class KineticBlock extends Block implements IRotate {
// we can prevent a major re-propagation here
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof KineticBlockEntity) {
KineticBlockEntity kineticBlockEntity = (KineticBlockEntity) blockEntity;
if (blockEntity instanceof KineticBlockEntity kineticBlockEntity) {
kineticBlockEntity.preventSpeedUpdate = 0;
if (oldState.getBlock() != state.getBlock())
@ -42,7 +41,7 @@ public abstract class KineticBlock extends Block implements IRotate {
kineticBlockEntity.preventSpeedUpdate = 2;
}
}
@Override
public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) {
IBE.onRemove(pState, pLevel, pPos, pNewState);
@ -61,14 +60,13 @@ public abstract class KineticBlock extends Block implements IRotate {
@Override
public void updateIndirectNeighbourShapes(BlockState stateIn, LevelAccessor worldIn, BlockPos pos, int flags,
int count) {
int count) {
if (worldIn.isClientSide())
return;
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (!(blockEntity instanceof KineticBlockEntity))
if (!(blockEntity instanceof KineticBlockEntity kbe))
return;
KineticBlockEntity kbe = (KineticBlockEntity) blockEntity;
if (kbe.preventSpeedUpdate > 0)
return;
@ -86,10 +84,9 @@ public abstract class KineticBlock extends Block implements IRotate {
return;
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (!(blockEntity instanceof KineticBlockEntity))
if (!(blockEntity instanceof KineticBlockEntity kbe))
return;
KineticBlockEntity kbe = (KineticBlockEntity) blockEntity;
kbe.effects.queueRotationIndicators();
}

View file

@ -419,9 +419,9 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI
.forGoggles(tooltip);
Component hint = CreateLang.translateDirect("gui.contraptions.network_overstressed");
List<Component> cutString = TooltipHelper.cutTextComponent(hint, Palette.GRAY_AND_WHITE);
for (int i = 0; i < cutString.size(); i++)
for (Component component : cutString)
CreateLang.builder()
.add(cutString.get(i)
.add(component
.copy())
.forGoggles(tooltip);
return true;
@ -435,9 +435,9 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI
CreateLang.translateDirect("gui.contraptions.not_fast_enough", I18n.get(getBlockState().getBlock()
.getDescriptionId()));
List<Component> cutString = TooltipHelper.cutTextComponent(hint, Palette.GRAY_AND_WHITE);
for (int i = 0; i < cutString.size(); i++)
for (Component component : cutString)
CreateLang.builder()
.add(cutString.get(i)
.add(component
.copy())
.forGoggles(tooltip);
return true;

View file

@ -76,10 +76,9 @@ public class KineticEffectHandler {
BlockState state = kte.getBlockState();
Block block = state.getBlock();
if (!(block instanceof KineticBlock))
if (!(block instanceof KineticBlock kb))
return;
KineticBlock kb = (KineticBlock) block;
float radius1 = kb.getParticleInitialRadius();
float radius2 = kb.getParticleTargetRadius();

View file

@ -13,6 +13,7 @@ import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
@ -22,7 +23,7 @@ public class RotationIndicatorParticleData
public static final MapCodec<RotationIndicatorParticleData> CODEC = RecordCodecBuilder.mapCodec(i -> i
.group(Codec.INT.fieldOf("color")
.forGetter(p -> p.color),
.forGetter(p -> p.color),
Codec.FLOAT.fieldOf("speed")
.forGetter(p -> p.speed),
Codec.FLOAT.fieldOf("radius1")

View file

@ -134,7 +134,7 @@ public class BeltBlock extends HorizontalKineticBlock
@Override
public ItemStack getCloneItemStack(BlockState state, HitResult target, LevelReader level, BlockPos pos,
Player player) {
Player player) {
return AllItems.BELT_CONNECTOR.asStack();
}
@ -390,18 +390,18 @@ public class BeltBlock extends HorizontalKineticBlock
return shape;
return getBlockEntityOptional(worldIn, pos).map(be -> {
Entity entity = ((EntityCollisionContext) context).getEntity();
if (entity == null)
Entity entity = ((EntityCollisionContext) context).getEntity();
if (entity == null)
return shape;
BeltBlockEntity controller = be.getControllerBE();
if (controller == null)
return shape;
if (controller.passengers == null || !controller.passengers.containsKey(entity))
return BeltShapes.getCollisionShape(state);
return shape;
BeltBlockEntity controller = be.getControllerBE();
if (controller == null)
return shape;
if (controller.passengers == null || !controller.passengers.containsKey(entity))
return BeltShapes.getCollisionShape(state);
return shape;
})
})
.orElse(shape);
}
@ -449,8 +449,7 @@ public class BeltBlock extends HorizontalKineticBlock
BlockEntity blockEntity = world.getBlockEntity(beltPos);
BlockState currentState = world.getBlockState(beltPos);
if (blockEntity instanceof BeltBlockEntity && AllBlocks.BELT.has(currentState)) {
BeltBlockEntity be = (BeltBlockEntity) blockEntity;
if (blockEntity instanceof BeltBlockEntity be && AllBlocks.BELT.has(currentState)) {
be.setController(currentPos);
be.beltLength = beltChain.size();
be.index = index;
@ -492,8 +491,7 @@ public class BeltBlock extends HorizontalKineticBlock
boolean hasPulley = false;
BlockEntity blockEntity = world.getBlockEntity(currentPos);
if (blockEntity instanceof BeltBlockEntity) {
BeltBlockEntity belt = (BeltBlockEntity) blockEntity;
if (blockEntity instanceof BeltBlockEntity belt) {
if (belt.isController())
belt.getInventory()
.ejectAll();
@ -512,7 +510,7 @@ public class BeltBlock extends HorizontalKineticBlock
@Override
public BlockState updateShape(BlockState state, Direction side, BlockState p_196271_3_, LevelAccessor world,
BlockPos pos, BlockPos p_196271_6_) {
BlockPos pos, BlockPos p_196271_6_) {
updateWater(world, state, pos);
if (side.getAxis()
.isHorizontal())
@ -622,7 +620,7 @@ public class BeltBlock extends HorizontalKineticBlock
return rotate;
if (state.getValue(HORIZONTAL_FACING)
.getAxisDirection() != rotate.getValue(HORIZONTAL_FACING)
.getAxisDirection()) {
.getAxisDirection()) {
if (state.getValue(PART) == BeltPart.START)
return rotate.setValue(PART, BeltPart.END);
if (state.getValue(PART) == BeltPart.END)

View file

@ -47,6 +47,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.client.model.data.ModelData;
@ -393,7 +394,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
}
private void applyToAllItems(float maxDistanceFromCenter,
Function<TransportedItemStack, TransportedResult> processFunction) {
Function<TransportedItemStack, TransportedResult> processFunction) {
BeltBlockEntity controller = getControllerBE();
if (controller == null)
return;
@ -476,8 +477,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
return inserted;
BlockEntity teAbove = level.getBlockEntity(worldPosition.above());
if (teAbove instanceof BrassTunnelBlockEntity) {
BrassTunnelBlockEntity tunnelBE = (BrassTunnelBlockEntity) teAbove;
if (teAbove instanceof BrassTunnelBlockEntity tunnelBE) {
if (tunnelBE.hasDistributionBehaviour()) {
if (!tunnelBE.getStackToDistribute()
.isEmpty())
@ -546,7 +546,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
@Override
public float propagateRotationTo(KineticBlockEntity target, BlockState stateFrom, BlockState stateTo, BlockPos diff,
boolean connectedViaAxes, boolean connectedViaCogs) {
boolean connectedViaAxes, boolean connectedViaCogs) {
if (target instanceof BeltBlockEntity && !connectedViaAxes)
return getController().equals(((BeltBlockEntity) target).getController()) ? 1 : 0;
return 0;

View file

@ -459,10 +459,9 @@ public class BeltSlicer {
public static void tickHoveringInformation() {
Minecraft mc = Minecraft.getInstance();
HitResult target = mc.hitResult;
if (target == null || !(target instanceof BlockHitResult))
if (target == null || !(target instanceof BlockHitResult result))
return;
BlockHitResult result = (BlockHitResult) target;
ClientLevel world = mc.level;
BlockPos pos = result.getBlockPos();
BlockState state = world.getBlockState(pos);

View file

@ -11,64 +11,65 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.items.ItemHandlerHelper;
public class BeltCrusherInteractionHandler {
public static boolean checkForCrushers(BeltInventory beltInventory, TransportedItemStack currentItem,
float nextOffset) {
public static boolean checkForCrushers(BeltInventory beltInventory, TransportedItemStack currentItem,
float nextOffset) {
boolean beltMovementPositive = beltInventory.beltMovementPositive;
int firstUpcomingSegment = (int) Math.floor(currentItem.beltPosition);
int step = beltMovementPositive ? 1 : -1;
firstUpcomingSegment = Mth.clamp(firstUpcomingSegment, 0, beltInventory.belt.beltLength - 1);
boolean beltMovementPositive = beltInventory.beltMovementPositive;
int firstUpcomingSegment = (int) Math.floor(currentItem.beltPosition);
int step = beltMovementPositive ? 1 : -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();
Level world = beltInventory.belt.getLevel();
BlockState crusherState = world.getBlockState(crusherPos);
if (!(crusherState.getBlock() instanceof CrushingWheelControllerBlock))
continue;
Direction crusherFacing = crusherState.getValue(CrushingWheelControllerBlock.FACING);
Direction movementFacing = beltInventory.belt.getMovementFacing();
if (crusherFacing != movementFacing)
continue;
for (int segment = firstUpcomingSegment; beltMovementPositive ? segment <= nextOffset
: segment + 1 >= nextOffset; segment += step) {
BlockPos crusherPos = BeltHelper.getPositionForOffset(beltInventory.belt, segment)
.above();
Level world = beltInventory.belt.getLevel();
BlockState crusherState = world.getBlockState(crusherPos);
if (!(crusherState.getBlock() instanceof CrushingWheelControllerBlock))
continue;
Direction crusherFacing = crusherState.getValue(CrushingWheelControllerBlock.FACING);
Direction movementFacing = beltInventory.belt.getMovementFacing();
if (crusherFacing != movementFacing)
continue;
float crusherEntry = segment + .5f;
crusherEntry += .399f * (beltMovementPositive ? -1 : 1);
float postCrusherEntry = crusherEntry + .799f * (!beltMovementPositive ? -1 : 1);
float crusherEntry = segment + .5f;
crusherEntry += .399f * (beltMovementPositive ? -1 : 1);
float postCrusherEntry = crusherEntry + .799f * (!beltMovementPositive ? -1 : 1);
boolean hasCrossed = nextOffset > crusherEntry && nextOffset < postCrusherEntry && beltMovementPositive
|| nextOffset < crusherEntry && nextOffset > postCrusherEntry && !beltMovementPositive;
if (!hasCrossed)
return false;
currentItem.beltPosition = crusherEntry;
boolean hasCrossed = nextOffset > crusherEntry && nextOffset < postCrusherEntry && beltMovementPositive
|| nextOffset < crusherEntry && nextOffset > postCrusherEntry && !beltMovementPositive;
if (!hasCrossed)
return false;
currentItem.beltPosition = crusherEntry;
BlockEntity be = world.getBlockEntity(crusherPos);
if (!(be instanceof CrushingWheelControllerBlockEntity crusherBE))
return true;
BlockEntity be = world.getBlockEntity(crusherPos);
if (!(be instanceof CrushingWheelControllerBlockEntity crusherBE))
return true;
ItemStack toInsert = currentItem.stack.copy();
ItemStack remainder = ItemHandlerHelper.insertItemStacked(crusherBE.inventory, toInsert, false);
if (ItemStack.matches(toInsert, remainder))
return true;
ItemStack remainder = ItemHandlerHelper.insertItemStacked(crusherBE.inventory, toInsert, false);
if (ItemStack.matches(toInsert, remainder))
return true;
int notFilled = currentItem.stack.getCount() - toInsert.getCount();
if (!remainder.isEmpty()) {
remainder.grow(notFilled);
} else if (notFilled > 0)
remainder = currentItem.stack.copyWithCount(notFilled);
int notFilled = currentItem.stack.getCount() - toInsert.getCount();
if (!remainder.isEmpty()) {
remainder.grow(notFilled);
} else if (notFilled > 0)
remainder = currentItem.stack.copyWithCount(notFilled);
currentItem.stack = remainder;
beltInventory.belt.sendData();
return true;
}
currentItem.stack = remainder;
beltInventory.belt.sendData();
return true;
}
return false;
}
return false;
}
}

View file

@ -19,7 +19,7 @@ import net.minecraft.world.level.block.state.BlockState;
public class BeltFunnelInteractionHandler {
public static boolean checkForFunnels(BeltInventory beltInventory, TransportedItemStack currentItem,
float nextOffset) {
float nextOffset) {
boolean beltMovementPositive = beltInventory.beltMovementPositive;
int firstUpcomingSegment = (int) Math.floor(currentItem.beltPosition);
int step = beltMovementPositive ? 1 : -1;
@ -58,10 +58,9 @@ public class BeltFunnelInteractionHandler {
continue;
BlockEntity be = world.getBlockEntity(funnelPos);
if (!(be instanceof FunnelBlockEntity))
if (!(be instanceof FunnelBlockEntity funnelBE))
return true;
FunnelBlockEntity funnelBE = (FunnelBlockEntity) be;
InvManipulationBehaviour inserting = funnelBE.getBehaviour(InvManipulationBehaviour.TYPE);
FilteringBehaviour filtering = funnelBE.getBehaviour(FilteringBehaviour.TYPE);
@ -71,7 +70,7 @@ public class BeltFunnelInteractionHandler {
else
continue;
if(beltInventory.belt.invVersionTracker.stillWaiting(inserting))
if (beltInventory.belt.invVersionTracker.stillWaiting(inserting))
continue;
int amountToExtract = funnelBE.getAmountToExtract();

View file

@ -21,12 +21,13 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.items.ItemHandlerHelper;
public class BeltTunnelInteractionHandler {
public static boolean flapTunnelsAndCheckIfStuck(BeltInventory beltInventory, TransportedItemStack current,
float nextOffset) {
float nextOffset) {
int currentSegment = (int) current.beltPosition;
int upcomingSegment = (int) nextOffset;
@ -48,8 +49,7 @@ public class BeltTunnelInteractionHandler {
BeltTunnelBlockEntity nextTunnel = getTunnelOnSegment(beltInventory, upcomingSegment);
int transferred = current.stack.getCount();
if (nextTunnel instanceof BrassTunnelBlockEntity) {
BrassTunnelBlockEntity brassTunnel = (BrassTunnelBlockEntity) nextTunnel;
if (nextTunnel instanceof BrassTunnelBlockEntity brassTunnel) {
if (brassTunnel.hasDistributionBehaviour()) {
if (!brassTunnel.canTakeItems())
return true;
@ -115,7 +115,7 @@ public class BeltTunnelInteractionHandler {
}
public static boolean stuckAtTunnel(BeltInventory beltInventory, int offset, ItemStack stack,
Direction movementDirection) {
Direction movementDirection) {
BeltBlockEntity belt = beltInventory.belt;
BlockPos pos = BeltHelper.getPositionForOffset(belt, offset)
.above();
@ -125,9 +125,8 @@ public class BeltTunnelInteractionHandler {
return false;
BlockEntity be = belt.getLevel()
.getBlockEntity(pos);
if (be == null || !(be instanceof BrassTunnelBlockEntity))
if (be == null || !(be instanceof BrassTunnelBlockEntity tunnel))
return false;
BrassTunnelBlockEntity tunnel = (BrassTunnelBlockEntity) be;
return !tunnel.canInsert(movementDirection.getOpposite(), stack);
}

View file

@ -60,7 +60,7 @@ public class ChainConveyorPackage {
public void setBE(ChainConveyorBlockEntity ccbe) {
if (beReference == null || beReference.get() != ccbe)
beReference = new WeakReference<ChainConveyorBlockEntity>(ccbe);
beReference = new WeakReference<>(ccbe);
}
}

View file

@ -30,6 +30,7 @@ import net.minecraft.nbt.Tag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.items.IItemHandler;
import net.neoforged.neoforge.items.IItemHandlerModifiable;
import net.neoforged.neoforge.items.ItemStackHandler;
@ -127,7 +128,7 @@ public class ConnectedInputHandler {
}
public static void connectControllers(Level world, MechanicalCrafterBlockEntity crafter1,
MechanicalCrafterBlockEntity crafter2) {
MechanicalCrafterBlockEntity crafter2) {
crafter1.input.data.forEach(offset -> {
BlockPos connectedPos = crafter1.getBlockPos()
@ -153,10 +154,9 @@ public class ConnectedInputHandler {
private static void modifyAndUpdate(Level world, BlockPos pos, Consumer<ConnectedInput> callback) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (!(blockEntity instanceof MechanicalCrafterBlockEntity))
if (!(blockEntity instanceof MechanicalCrafterBlockEntity crafter))
return;
MechanicalCrafterBlockEntity crafter = (MechanicalCrafterBlockEntity) blockEntity;
callback.accept(crafter.input);
crafter.setChanged();
crafter.connectivityChanged();

View file

@ -5,11 +5,9 @@ import com.simibubi.create.AllPartialModels;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.kinetics.base.GeneratingKineticBlockEntity;
import dev.engine_room.flywheel.api.model.Model;
import dev.engine_room.flywheel.lib.model.Models;
import net.createmod.catnip.animation.AnimationTickHolder;
import net.createmod.catnip.render.CachedBuffers;
import net.createmod.catnip.render.SuperByteBuffer;
import net.createmod.catnip.animation.AnimationTickHolder;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
@ -17,6 +15,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
@ -50,9 +49,8 @@ public class HandCrankBlockEntity extends GeneratingKineticBlockEntity {
@Override
public float getGeneratedSpeed() {
Block block = getBlockState().getBlock();
if (!(block instanceof HandCrankBlock))
if (!(block instanceof HandCrankBlock crank))
return 0;
HandCrankBlock crank = (HandCrankBlock) block;
int speed = (inUse == 0 ? 0 : clockwise() ? -1 : 1) * crank.getRotationSpeed();
return convertToDirection(speed, getBlockState().getValue(HandCrankBlock.FACING));
}

View file

@ -43,6 +43,7 @@ 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.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.capabilities.Capabilities;
@ -122,10 +123,10 @@ public class CrushingWheelControllerBlockEntity extends SmartBlockEntity {
.getStep();
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.
// 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.
// drop the items as before.
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));
@ -210,32 +211,32 @@ public class CrushingWheelControllerBlockEntity extends SmartBlockEntity {
double movement = Math.max(-speed / 4f, -.5f) * -offset;
processingEntity.setDeltaMovement(
new Vec3(facing.getAxis() == Axis.X ? movement : xMotion, facing.getAxis() == Axis.Y ? movement : 0f // Do
// not
// move
// entities
// upwards
// or
// downwards
// for
// horizontal
// crushers,
// not
// move
// entities
// upwards
// or
// downwards
// for
// horizontal
// crushers,
, facing.getAxis() == Axis.Z ? movement : zMotion)); // Or they'll only get their feet crushed.
if (level.isClientSide)
return;
if (!(processingEntity instanceof ItemEntity)) {
if (!(processingEntity instanceof ItemEntity itemEntity)) {
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();
if (processingEntity instanceof LivingEntity) {
if ((((LivingEntity) processingEntity).getHealth() - crusherDamage <= 0) // Takes LivingEntity instances
// as exception, so it can
// move them before it would
// kill them.
// as exception, so it can
// move them before it would
// kill them.
&& (((LivingEntity) processingEntity).hurtTime <= 0)) { // This way it can actually output the items
// to the right spot.
// to the right spot.
processingEntity.setPos(entityOutPos.x, entityOutPos.y, entityOutPos.z);
}
}
@ -246,7 +247,6 @@ public class CrushingWheelControllerBlockEntity extends SmartBlockEntity {
return;
}
ItemEntity itemEntity = (ItemEntity) processingEntity;
itemEntity.setPickUpDelay(20);
if (facing.getAxis() == Axis.Y) {
if (processingEntity.getY() * -offset < (centerPos.y - .25f) * -offset) {
@ -309,8 +309,7 @@ public class CrushingWheelControllerBlockEntity extends SmartBlockEntity {
for (int roll = 0; roll < rolls; roll++) {
List<ItemStack> rolledResults = recipe.get().value()
.rollResults();
for (int i = 0; i < rolledResults.size(); i++) {
ItemStack stack = rolledResults.get(i);
for (ItemStack stack : rolledResults) {
ItemHelper.addToList(stack, list);
}
}

View file

@ -30,6 +30,7 @@ import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.bus.api.EventPriority;
@ -114,8 +115,7 @@ public class DeployerFakePlayer extends FakePlayer {
public static void deployerCollectsDropsFromKilledEntities(LivingDropsEvent event) {
DamageSource source = event.getSource();
Entity trueSource = source.getEntity();
if (trueSource != null && trueSource instanceof DeployerFakePlayer) {
DeployerFakePlayer fakePlayer = (DeployerFakePlayer) trueSource;
if (trueSource != null && trueSource instanceof DeployerFakePlayer fakePlayer) {
event.getDrops()
.forEach(stack -> fakePlayer.getInventory()
.placeItemBackInInventory(stack.getItem()));
@ -151,7 +151,7 @@ public class DeployerFakePlayer extends FakePlayer {
CKinetics.DeployerAggroSetting setting = AllConfigs.server().kinetics.ignoreDeployerAttacks.get();
switch(setting) {
switch (setting) {
case ALL -> event.setCanceled(true);
case CREEPERS -> {
if (mob instanceof Creeper)

View file

@ -5,8 +5,6 @@ import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.world.item.MobBucketItem;
import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.AllDataComponents;
@ -47,6 +45,7 @@ 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.MobBucketItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.ClipContext;
@ -65,6 +64,7 @@ import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.common.CommonHooks;
import net.neoforged.neoforge.common.extensions.IBaseRailBlockExtension;
import net.neoforged.neoforge.common.util.TriState;
@ -98,7 +98,7 @@ public class DeployerHandler {
if (rayMode && (pos.relative(face.getOpposite(), 3)
.equals(position)
|| pos.relative(face.getOpposite(), 1)
.equals(position)))
.equals(position)))
return Blocks.BEDROCK.defaultBlockState();
return level.getBlockState(position);
}
@ -110,8 +110,7 @@ public class DeployerHandler {
.getBlock() == ((BlockItem) held.getItem()).getBlock())
return false;
if (held.getItem() instanceof BucketItem) {
BucketItem bucketItem = (BucketItem) held.getItem();
if (held.getItem() instanceof BucketItem bucketItem) {
Fluid fluid = bucketItem.content;
if (fluid != Fluids.EMPTY && world.getFluidState(targetPos)
.getType() == fluid)
@ -146,7 +145,7 @@ public class DeployerHandler {
}
private static void activateInner(DeployerFakePlayer player, Vec3 vec, BlockPos clickedPos, Vec3 extensionVector,
Mode mode) {
Mode mode) {
Vec3 rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f));
Vec3 rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f));
@ -178,15 +177,14 @@ public class DeployerHandler {
if (cancelResult == null) {
if (entity.interact(player, hand)
.consumesAction()) {
if (entity instanceof AbstractVillager) {
AbstractVillager villager = ((AbstractVillager) entity);
if (entity instanceof AbstractVillager villager) {
if (villager.getTradingPlayer() instanceof DeployerFakePlayer)
villager.setTradingPlayer(null);
}
success = true;
} else if (entity instanceof LivingEntity
&& stack.interactLivingEntity(player, (LivingEntity) entity, hand)
.consumesAction())
.consumesAction())
success = true;
}
if (!success && entity instanceof Player playerEntity) {
@ -415,14 +413,14 @@ public class DeployerHandler {
}
public static InteractionResult safeOnUse(BlockState state, Level world, BlockPos pos, Player player,
InteractionHand hand, BlockHitResult ray) {
InteractionHand hand, BlockHitResult ray) {
if (state.getBlock() instanceof BeehiveBlock)
return safeOnBeehiveUse(state, world, pos, player, hand);
return BlockHelper.invokeUse(state, world, player, hand, ray);
}
protected static InteractionResult safeOnBeehiveUse(BlockState state, Level world, BlockPos pos, Player player,
InteractionHand hand) {
InteractionHand hand) {
// <> BeehiveBlock#onUse
BeehiveBlock block = (BeehiveBlock) state.getBlock();

View file

@ -21,12 +21,12 @@ import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
import dev.engine_room.flywheel.lib.transform.TransformStack;
import net.createmod.catnip.animation.AnimationTickHolder;
import net.createmod.catnip.math.AngleHelper;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.nbt.NBTHelper;
import net.createmod.catnip.render.CachedBuffers;
import net.createmod.catnip.render.SuperByteBuffer;
import net.createmod.catnip.animation.AnimationTickHolder;
import net.createmod.catnip.nbt.NBTHelper;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.math.AngleHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
@ -50,7 +50,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
@Override
protected void renderSafe(DeployerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
int light, int overlay) {
renderItem(be, partialTicks, ms, buffer, light, overlay);
FilteringRenderer.renderOnBlockEntity(be, partialTicks, ms, buffer, light, overlay);
@ -60,7 +60,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
}
protected void renderItem(DeployerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
int light, int overlay) {
if (be.heldItem.isEmpty()) return;
@ -110,7 +110,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
}
protected void renderComponents(DeployerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
int light, int overlay) {
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
if (!VisualizationManager.supportsVisualization(be.getLevel())) {
KineticBlockEntityRenderer.renderRotatingKineticBlock(be, getRenderedBlockState(be), ms, vb, light);
@ -155,7 +155,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
}
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
ContraptionMatrices matrices, MultiBufferSource buffer) {
VertexConsumer builder = buffer.getBuffer(RenderType.solid());
BlockState blockState = context.state;
Mode mode = NBTHelper.readEnum(context.blockEntityData, "Mode", Mode.class);
@ -188,8 +188,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
m.pushPose();
Direction.Axis axis = Direction.Axis.Y;
if (context.state.getBlock() instanceof IRotate) {
IRotate def = (IRotate) context.state.getBlock();
if (context.state.getBlock() instanceof IRotate def) {
axis = def.getRotationAxis(context.state);
}

View file

@ -74,7 +74,7 @@ public class AirCurrent {
}
protected void tickAffectedEntities(Level world) {
for (Iterator<Entity> iterator = caughtEntities.iterator(); iterator.hasNext();) {
for (Iterator<Entity> iterator = caughtEntities.iterator(); iterator.hasNext(); ) {
Entity entity = iterator.next();
if (!entity.isAlive() || !entity.getBoundingBox()
.intersects(bounds) || isPlayerCreativeFlying(entity)) {
@ -129,8 +129,7 @@ public class AirCurrent {
}
public static boolean isPlayerCreativeFlying(Entity entity) {
if (entity instanceof Player) {
Player player = (Player) entity;
if (entity instanceof Player player) {
return player.isCreative() && player.getAbilities().flying;
}
return false;
@ -143,7 +142,7 @@ public class AirCurrent {
FanProcessingType processingType = pair.getRight();
if (processingType == AllFanProcessingTypes.NONE)
continue;
handler.handleProcessingOnAllItems(transported -> {
if (world.isClientSide) {
processingType.spawnProcessingParticles(world, handler.getWorldPositionOf(transported));
@ -251,18 +250,18 @@ public class AirCurrent {
if (shapeDepth == Double.POSITIVE_INFINITY) {
continue;
}
return Math.min((float) (i + shapeDepth + 1/32d), max);
return Math.min((float) (i + shapeDepth + 1 / 32d), max);
}
return max;
}
private static final double[][] DEPTH_TEST_COORDINATES = {
{ 0.25, 0.25 },
{ 0.25, 0.75 },
{ 0.5, 0.5 },
{ 0.75, 0.25 },
{ 0.75, 0.75 }
{0.25, 0.25},
{0.25, 0.75},
{0.5, 0.5},
{0.75, 0.25},
{0.75, 0.75}
};
// Finds the maximum depth of the shape when traveling in the given direction.

View file

@ -11,6 +11,7 @@ import net.minecraft.core.Vec3i;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.neoforged.api.distmarker.Dist;
@ -22,10 +23,10 @@ public class AirFlowParticleData implements ParticleOptions, ICustomParticleData
public static final MapCodec<AirFlowParticleData> CODEC = RecordCodecBuilder.mapCodec(i ->
i.group(
Codec.INT.fieldOf("x").forGetter(p -> p.posX),
Codec.INT.fieldOf("y").forGetter(p -> p.posY),
Codec.INT.fieldOf("z").forGetter(p -> p.posZ))
.apply(i, AirFlowParticleData::new));
Codec.INT.fieldOf("x").forGetter(p -> p.posX),
Codec.INT.fieldOf("y").forGetter(p -> p.posY),
Codec.INT.fieldOf("z").forGetter(p -> p.posZ))
.apply(i, AirFlowParticleData::new));
public static final StreamCodec<RegistryFriendlyByteBuf, AirFlowParticleData> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.INT, p -> p.posX,

View file

@ -109,9 +109,8 @@ public class EncasedFanBlockEntity extends KineticBlockEntity implements IAirCur
.isVertical())
return;
BlockEntity poweredChute = level.getBlockEntity(worldPosition.relative(direction));
if (!(poweredChute instanceof ChuteBlockEntity))
if (!(poweredChute instanceof ChuteBlockEntity chuteBE))
return;
ChuteBlockEntity chuteBE = (ChuteBlockEntity) poweredChute;
if (direction == Direction.DOWN)
chuteBE.updatePull();
else

View file

@ -40,7 +40,8 @@ public class NozzleBlockEntity extends SmartBlockEntity {
}
@Override
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {}
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
}
@Override
protected void write(CompoundTag compound, HolderLookup.Provider registries, boolean clientPacket) {
@ -87,10 +88,10 @@ public class NozzleBlockEntity extends SmartBlockEntity {
}
}
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext(); ) {
Entity entity = iterator.next();
Vec3 diff = entity.position()
.subtract(center);
.subtract(center);
if (!(entity instanceof Player) && level.isClientSide)
continue;
@ -106,7 +107,7 @@ public class NozzleBlockEntity extends SmartBlockEntity {
float factor = (entity instanceof ItemEntity) ? 1 / 128f : 1 / 32f;
Vec3 pushVec = diff.normalize()
.scale((range - distance) * (pushing ? 1 : -1));
.scale((range - distance) * (pushing ? 1 : -1));
entity.setDeltaMovement(entity.getDeltaMovement()
.add(pushVec.scale(factor)));
entity.fallDistance = 0;
@ -124,10 +125,9 @@ public class NozzleBlockEntity extends SmartBlockEntity {
private float calcRange() {
BlockEntity be = level.getBlockEntity(fanPos);
if (!(be instanceof IAirCurrentSource))
if (!(be instanceof IAirCurrentSource source))
return 0;
IAirCurrentSource source = (IAirCurrentSource) be;
if (source.getAirCurrent() == null)
return 0;
if (source.getSpeed() == 0)
@ -148,7 +148,7 @@ public class NozzleBlockEntity extends SmartBlockEntity {
for (Entity entity : level.getEntitiesOfClass(Entity.class, bb)) {
Vec3 diff = entity.position()
.subtract(center);
.subtract(center);
double distance = diff.length();
if (distance > range || entity.isShiftKeyDown() || AirCurrent.isPlayerCreativeFlying(entity))
@ -164,7 +164,7 @@ public class NozzleBlockEntity extends SmartBlockEntity {
pushingEntities.add(entity);
}
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext(); ) {
Entity entity = iterator.next();
if (entity.isAlive())
continue;
@ -173,7 +173,7 @@ public class NozzleBlockEntity extends SmartBlockEntity {
if (!pushing && pushingEntities.size() > 256 && !level.isClientSide) {
level.explode(null, center.x, center.y, center.z, 2, ExplosionInteraction.NONE);
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext(); ) {
Entity entity = iterator.next();
entity.discard();
iterator.remove();

View file

@ -8,9 +8,9 @@ import com.simibubi.create.content.kinetics.base.IRotate;
import com.simibubi.create.foundation.block.IBE;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.lang.Lang;
import net.createmod.catnip.levelWrappers.WrappedLevel;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.theme.Color;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -121,9 +121,8 @@ public class GaugeBlock extends DirectionalAxisKineticBlock implements IBE<Gauge
@Override
public void animateTick(BlockState stateIn, Level worldIn, BlockPos pos, RandomSource rand) {
BlockEntity be = worldIn.getBlockEntity(pos);
if (be == null || !(be instanceof GaugeBlockEntity))
if (be == null || !(be instanceof GaugeBlockEntity gaugeBE))
return;
GaugeBlockEntity gaugeBE = (GaugeBlockEntity) be;
if (gaugeBE.dialTarget == 0)
return;
int color = gaugeBE.color;
@ -169,8 +168,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock implements IBE<Gauge
@Override
public int getAnalogOutputSignal(BlockState blockState, Level worldIn, BlockPos pos) {
BlockEntity be = worldIn.getBlockEntity(pos);
if (be instanceof GaugeBlockEntity) {
GaugeBlockEntity gaugeBlockEntity = (GaugeBlockEntity) be;
if (be instanceof GaugeBlockEntity gaugeBlockEntity) {
return Mth.ceil(Mth.clamp(gaugeBlockEntity.dialTarget * 14, 0, 15));
}
return 0;

View file

@ -203,7 +203,7 @@ public class AllArmInteractionPointTypes {
return state.getBlock() instanceof AbstractFunnelBlock
&& !(state.hasProperty(FunnelBlock.EXTRACTING) && state.getValue(FunnelBlock.EXTRACTING))
&& !(state.hasProperty(BeltFunnelBlock.SHAPE)
&& state.getValue(BeltFunnelBlock.SHAPE) == Shape.PUSHING);
&& state.getValue(BeltFunnelBlock.SHAPE) == Shape.PUSHING);
}
@Override
@ -301,12 +301,13 @@ public class AllArmInteractionPointTypes {
public static class DepositOnlyArmInteractionPoint extends ArmInteractionPoint {
public DepositOnlyArmInteractionPoint(ArmInteractionPointType type, Level level, BlockPos pos,
BlockState state) {
BlockState state) {
super(type, level, pos, state);
}
@Override
public void cycleMode() {}
public void cycleMode() {
}
@Override
public ItemStack extract(int slot, int amount, boolean simulate) {
@ -407,9 +408,8 @@ public class AllArmInteractionPointTypes {
@Override
public ItemStack extract(int slot, int amount, boolean simulate) {
BlockEntity be = level.getBlockEntity(pos);
if (!(be instanceof MechanicalCrafterBlockEntity))
if (!(be instanceof MechanicalCrafterBlockEntity crafter))
return ItemStack.EMPTY;
MechanicalCrafterBlockEntity crafter = (MechanicalCrafterBlockEntity) be;
SmartInventory inventory = crafter.getInventory();
inventory.allowExtraction();
ItemStack extract = super.extract(slot, amount, simulate);
@ -666,7 +666,7 @@ public class AllArmInteractionPointTypes {
@Override
protected Vec3 getInteractionPositionVector() {
return Vec3.atLowerCornerOf(pos)
.add(.5f, 1, .5f);
.add(.5f, 1, .5f);
}
}
}

View file

@ -114,7 +114,7 @@ public class ArmBlockEntity extends KineticBlockEntity implements TransformableB
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
super.addBehaviours(behaviours);
selectionMode = new ScrollOptionBehaviour<SelectionMode>(SelectionMode.class,
selectionMode = new ScrollOptionBehaviour<>(SelectionMode.class,
CreateLang.translateDirect("logistics.when_multiple_outputs_available"), this, new SelectionModeValueBox());
behaviours.add(selectionMode);
@ -261,7 +261,8 @@ public class ArmBlockEntity extends KineticBlockEntity implements TransformableB
if (scanRange > inputs.size())
scanRange = inputs.size();
InteractionPoints: for (int i = startIndex; i < scanRange; i++) {
InteractionPoints:
for (int i = startIndex; i < scanRange; i++) {
ArmInteractionPoint armInteractionPoint = inputs.get(i);
if (!armInteractionPoint.isValid())
continue;

View file

@ -94,7 +94,7 @@ public class ArmInteractionPointHandler {
return;
int removed = 0;
for (Iterator<ArmInteractionPoint> iterator = currentSelection.iterator(); iterator.hasNext();) {
for (Iterator<ArmInteractionPoint> iterator = currentSelection.iterator(); iterator.hasNext(); ) {
ArmInteractionPoint point = iterator.next();
if (point.getPos()
.closerThan(pos, ArmBlockEntity.getRange()))
@ -157,11 +157,10 @@ public class ArmInteractionPointHandler {
}
HitResult objectMouseOver = Minecraft.getInstance().hitResult;
if (!(objectMouseOver instanceof BlockHitResult)) {
if (!(objectMouseOver instanceof BlockHitResult result)) {
return;
}
BlockHitResult result = (BlockHitResult) objectMouseOver;
BlockPos pos = result.getBlockPos();
BlockEntity be = Minecraft.getInstance().level.getBlockEntity(pos);
@ -185,7 +184,7 @@ public class ArmInteractionPointHandler {
}
private static void drawOutlines(Collection<ArmInteractionPoint> selection) {
for (Iterator<ArmInteractionPoint> iterator = selection.iterator(); iterator.hasNext();) {
for (Iterator<ArmInteractionPoint> iterator = selection.iterator(); iterator.hasNext(); ) {
ArmInteractionPoint point = iterator.next();
if (!point.isValid()) {
@ -203,7 +202,7 @@ public class ArmInteractionPointHandler {
int color = point.getMode()
.getColor();
Outliner.getInstance().showAABB(point, shape.bounds()
.move(pos))
.move(pos))
.colored(color)
.lineWidth(1 / 16f);
}

View file

@ -16,6 +16,7 @@ import net.minecraft.network.codec.StreamCodec;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;

View file

@ -26,6 +26,7 @@ import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.items.IItemHandler;
import net.neoforged.neoforge.items.IItemHandlerModifiable;

View file

@ -66,6 +66,7 @@ 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.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.capabilities.Capabilities;
@ -359,15 +360,14 @@ public class SawBlockEntity extends BlockBreakingKineticBlockEntity {
inventory.clear();
for (int roll = 0; roll < rolls; roll++) {
List<ItemStack> results = new LinkedList<ItemStack>();
List<ItemStack> results = new LinkedList<>();
if (recipe instanceof CuttingRecipe)
results = ((CuttingRecipe) recipe).rollResults();
else if (recipe instanceof StonecutterRecipe || recipe.getType() == woodcuttingRecipeType.get())
results.add(recipe.getResultItem(level.registryAccess())
.copy());
for (int i = 0; i < results.size(); i++) {
ItemStack stack = results.get(i);
for (ItemStack stack : results) {
ItemHelper.addToList(stack, list);
}
}

View file

@ -8,9 +8,9 @@ import com.simibubi.create.content.kinetics.simpleRelays.BracketedKineticBlockEn
import com.simibubi.create.content.kinetics.simpleRelays.SimpleKineticBlockEntity;
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.render.CachedBuffers;
import net.createmod.catnip.render.SuperByteBuffer;
import net.createmod.catnip.data.Iterate;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
@ -40,16 +40,15 @@ public class EncasedCogRenderer extends KineticBlockEntityRenderer<SimpleKinetic
@Override
protected void renderSafe(SimpleKineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
int light, int overlay) {
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
if (VisualizationManager.supportsVisualization(be.getLevel()))
return;
BlockState blockState = be.getBlockState();
Block block = blockState.getBlock();
if (!(block instanceof IRotate))
if (!(block instanceof IRotate def))
return;
IRotate def = (IRotate) block;
Axis axis = getRotationAxisOf(be);
BlockPos pos = be.getBlockPos();

View file

@ -71,8 +71,8 @@ public class EncasedCogwheelBlock extends RotatedPillarKineticBlock
if (target instanceof BlockHitResult)
return ((BlockHitResult) target).getDirection()
.getAxis() != getRotationAxis(state)
? isLarge ? AllBlocks.LARGE_COGWHEEL.asStack() : AllBlocks.COGWHEEL.asStack()
: getCasing().asItem().getDefaultInstance();
? isLarge ? AllBlocks.LARGE_COGWHEEL.asStack() : AllBlocks.COGWHEEL.asStack()
: getCasing().asItem().getDefaultInstance();
return super.getCloneItemStack(state, target, level, pos, player);
}
@ -197,18 +197,18 @@ public class EncasedCogwheelBlock extends RotatedPillarKineticBlock
boolean clockwise = rotation == Rotation.CLOCKWISE_90;
if (rotationAxis == Direction.Axis.X) {
if ( axis == Direction.Axis.Z && !clockwise
|| axis == Direction.Axis.Y && clockwise) {
if (axis == Direction.Axis.Z && !clockwise
|| axis == Direction.Axis.Y && clockwise) {
return swapShafts(state);
}
} else if (rotationAxis == Direction.Axis.Y) {
if ( axis == Direction.Axis.X && !clockwise
|| axis == Direction.Axis.Z && clockwise) {
if (axis == Direction.Axis.X && !clockwise
|| axis == Direction.Axis.Z && clockwise) {
return swapShafts(state);
}
} else if (rotationAxis == Direction.Axis.Z) {
if ( axis == Direction.Axis.Y && !clockwise
|| axis == Direction.Axis.X && clockwise) {
if (axis == Direction.Axis.Y && !clockwise
|| axis == Direction.Axis.X && clockwise) {
return swapShafts(state);
}
}
@ -220,7 +220,7 @@ public class EncasedCogwheelBlock extends RotatedPillarKineticBlock
public BlockState mirror(BlockState state, Mirror mirror) {
Direction.Axis axis = state.getValue(AXIS);
if (axis == Direction.Axis.X && mirror == Mirror.FRONT_BACK
|| axis == Direction.Axis.Z && mirror == Mirror.LEFT_RIGHT) {
|| axis == Direction.Axis.Z && mirror == Mirror.LEFT_RIGHT) {
return swapShafts(state);
}
return state;
@ -270,20 +270,19 @@ public class EncasedCogwheelBlock extends RotatedPillarKineticBlock
@Override
public void handleEncasing(BlockState state, Level level, BlockPos pos, ItemStack heldItem, Player player, InteractionHand hand,
BlockHitResult ray) {
BlockHitResult ray) {
BlockState encasedState = defaultBlockState()
.setValue(AXIS, state.getValue(AXIS));
.setValue(AXIS, state.getValue(AXIS));
for (Direction d : Iterate.directionsInAxis(state.getValue(AXIS))) {
BlockState adjacentState = level.getBlockState(pos.relative(d));
if (!(adjacentState.getBlock() instanceof IRotate))
if (!(adjacentState.getBlock() instanceof IRotate def))
continue;
IRotate def = (IRotate) adjacentState.getBlock();
if (!def.hasShaftTowards(level, pos.relative(d), adjacentState, d.getOpposite()))
continue;
encasedState =
encasedState.cycle(d.getAxisDirection() == AxisDirection.POSITIVE ? EncasedCogwheelBlock.TOP_SHAFT
: EncasedCogwheelBlock.BOTTOM_SHAFT);
: EncasedCogwheelBlock.BOTTOM_SHAFT);
}
KineticBlockEntity.switchToBlockState(level, pos, encasedState);

View file

@ -12,6 +12,7 @@ import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;

View file

@ -38,12 +38,12 @@ public class GearshiftBlock extends AbstractEncasedShaftBlock implements IBE<Spl
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
return super.getStateForPlacement(context).setValue(POWERED,
context.getLevel().hasNeighborSignal(context.getClickedPos()));
context.getLevel().hasNeighborSignal(context.getClickedPos()));
}
@Override
public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
boolean isMoving) {
if (worldIn.isClientSide)
return;
@ -78,9 +78,8 @@ public class GearshiftBlock extends AbstractEncasedShaftBlock implements IBE<Spl
@Override
public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, RandomSource random) {
BlockEntity be = worldIn.getBlockEntity(pos);
if (be == null || !(be instanceof KineticBlockEntity))
if (be == null || !(be instanceof KineticBlockEntity kte))
return;
KineticBlockEntity kte = (KineticBlockEntity) be;
RotationPropagator.handleAdded(worldIn, pos, kte);
}
}

View file

@ -54,13 +54,13 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen
}
@Override
public boolean shouldCheckWeakPower(BlockState state, SignalGetter level, BlockPos pos, Direction side) {
return false;
}
public boolean shouldCheckWeakPower(BlockState state, SignalGetter level, BlockPos pos, Direction side) {
return false;
}
@Override
public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos fromPos,
boolean isMoving) {
boolean isMoving) {
if (level.isClientSide)
return;
if (!level.getBlockTicks()

View file

@ -26,11 +26,10 @@ public class TurntableHandler {
return;
BlockEntity blockEntity = mc.level.getBlockEntity(pos);
if (!(blockEntity instanceof TurntableBlockEntity))
if (!(blockEntity instanceof TurntableBlockEntity turnTable))
return;
TurntableBlockEntity turnTable = (TurntableBlockEntity) blockEntity;
float speed = turnTable.getSpeed() * 3/10;
float speed = turnTable.getSpeed() * 3 / 10;
if (speed == 0)
return;
@ -38,8 +37,8 @@ public class TurntableHandler {
Vec3 origin = VecHelper.getCenterOf(pos);
Vec3 offset = mc.player.position().subtract(origin);
if (offset.length() > 1/4f)
speed *= Mth.clamp((1/2f - offset.length()) * 2, 0, 1);
if (offset.length() > 1 / 4f)
speed *= Mth.clamp((1 / 2f - offset.length()) * 2, 0, 1);
mc.player.setYRot(mc.player.yRotO - speed * AnimationTickHolder.getPartialTicks());
mc.player.yBodyRot = mc.player.getYRot();

View file

@ -204,7 +204,7 @@ public class ChromaticCompoundItem extends Item {
}
public boolean checkLight(ItemStack stack, ItemEntity entity, Level world, ItemStack itemStack, Vec3 positionVec,
BlockPos randomOffset, BlockState state) {
BlockPos randomOffset, BlockState state) {
if (state.getLightEmission(world, randomOffset) == 0)
return false;
if (state.getDestroySpeed(world, randomOffset) == -1)

View file

@ -16,7 +16,6 @@ import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.math.AngleHelper;
import net.createmod.ponder.api.level.PonderLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.server.level.ServerLevel;
@ -49,6 +48,7 @@ import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.neoforged.neoforge.common.CommonHooks;
import net.neoforged.neoforge.entity.IEntityWithComplexSpawn;
import net.neoforged.neoforge.items.ItemStackHandler;
@ -58,8 +58,6 @@ public class PackageEntity extends LivingEntity implements IEntityWithComplexSpa
private Entity originalEntity;
public ItemStack box;
public int extractorAnimationProgress;
public Direction extractorSide;
public int insertionDelay;
public Vec3 clientPosition, vec2 = Vec3.ZERO, vec3 = Vec3.ZERO;
@ -275,7 +273,7 @@ public class PackageEntity extends LivingEntity implements IEntityWithComplexSpa
boolean isOtherPackage = entityIn instanceof PackageEntity;
if (!isOtherPackage && tossedBy.get() != null)
tossedBy = new WeakReference<Player>(null); // no nudging
tossedBy = new WeakReference<>(null); // no nudging
if (isOtherPackage) {
if (entityIn.getBoundingBox().minY < this.getBoundingBox().maxY)
@ -451,10 +449,6 @@ public class PackageEntity extends LivingEntity implements IEntityWithComplexSpa
setDeltaMovement(additionalData.readFloat(), additionalData.readFloat(), additionalData.readFloat());
}
protected SoundEvent getFallSound(int heightIn) {
return SoundEvents.CHISELED_BOOKSHELF_FALL;
}
@Override
public float getVoicePitch() {
return 1.5f;
@ -475,4 +469,8 @@ public class PackageEntity extends LivingEntity implements IEntityWithComplexSpa
return null;
}
@Override
public boolean isAffectedByPotions() {
return false;
}
}

View file

@ -111,7 +111,7 @@ public class PackageItem extends Item {
}
public static void setOrder(ItemStack box, int orderId, int linkIndex, boolean isFinalLink, int fragmentIndex,
boolean isFinal, @Nullable PackageOrder orderContext) {
boolean isFinal, @Nullable PackageOrder orderContext) {
PackageOrderData order = new PackageOrderData(orderId, linkIndex, isFinalLink, fragmentIndex, isFinal, orderContext);
box.set(AllDataComponents.PACKAGE_ORDER_DATA, order);
}
@ -185,7 +185,7 @@ public class PackageItem extends Item {
@Override
public void appendHoverText(ItemStack stack, TooltipContext tooltipContext, List<Component> tooltipComponents,
TooltipFlag tooltipFlag) {
TooltipFlag tooltipFlag) {
super.appendHoverText(stack, tooltipContext, tooltipComponents, tooltipFlag);
if (stack.has(AllDataComponents.PACKAGE_ADDRESS))
@ -262,9 +262,9 @@ public class PackageItem extends Item {
if (itemstack.getItem() instanceof SpawnEggItem sei && worldIn instanceof ServerLevel sl) {
EntityType<?> entitytype = sei.getType(itemstack);
Entity entity = entitytype.spawn(sl, itemstack, null, BlockPos.containing(playerIn.position()
.add(playerIn.getLookAngle()
.multiply(1, 0, 1)
.normalize())),
.add(playerIn.getLookAngle()
.multiply(1, 0, 1)
.normalize())),
MobSpawnType.SPAWN_EGG, false, false);
if (entity != null)
itemstack.shrink(1);
@ -310,7 +310,7 @@ public class PackageItem extends Item {
.getAxis()
.isHorizontal())
point = point.add(Vec3.atLowerCornerOf(context.getClickedFace()
.getNormal())
.getNormal())
.scale(r));
AABB scanBB = new AABB(point, point).inflate(r, 0, r)
@ -367,7 +367,7 @@ public class PackageItem extends Item {
PackageEntity packageEntity = new PackageEntity(world, vec.x, vec.y, vec.z);
packageEntity.setBox(copy);
packageEntity.setDeltaMovement(motion);
packageEntity.tossedBy = new WeakReference<Player>(player);
packageEntity.tossedBy = new WeakReference<>(player);
world.addFreshEntity(packageEntity);
}

Some files were not shown because too many files have changed in this diff Show more