Skip to content

Commit 2f707ab

Browse files
committed
another pass
1 parent ce66c51 commit 2f707ab

File tree

63 files changed

+360
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+360
-375
lines changed

src/main/java/com/simibubi/create/AllBlocks.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@
276276
import com.tterrag.registrate.util.entry.BlockEntry;
277277

278278
import net.createmod.catnip.data.Couple;
279+
280+
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
281+
import net.fabricmc.fabric.api.registry.FuelRegistry;
282+
279283
import net.minecraft.client.renderer.RenderType;
280284
import net.minecraft.core.Direction.Axis;
281285
import net.minecraft.core.Direction.AxisDirection;
@@ -1867,6 +1871,7 @@ public class AllBlocks {
18671871
.properties(p -> p.noOcclusion())
18681872
.properties(p -> p.mapColor(MapColor.TERRACOTTA_BLUE)
18691873
.sound(SoundType.NETHERITE_BLOCK))
1874+
.properties(p -> p.pushReaction(PushReaction.NORMAL))
18701875
.transform(pickaxeOnly())
18711876
.addLayer(() -> RenderType::cutoutMipped)
18721877
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
@@ -2580,11 +2585,13 @@ public class AllBlocks {
25802585
.properties(p -> p.mapColor(MapColor.COLOR_BROWN)
25812586
.sound(SoundType.CHISELED_BOOKSHELF)
25822587
.ignitedByLava())
2588+
.onRegister(block -> FlammableBlockRegistry.getDefaultInstance().add(block, 20, 100))
25832589
.transform(axeOnly())
25842590
.blockstate(BlockStateGen.horizontalAxisBlockProvider(false))
25852591
.tag(Tags.Blocks.STORAGE_BLOCKS)
25862592
.tag(AllTags.forgeBlockTag("storage_blocks/cardboard"))
25872593
.item(CardboardBlockItem::new)
2594+
.onRegister(item -> FuelRegistry.INSTANCE.add(item, 4000))
25882595
.tag(AllTags.forgeItemTag("storage_blocks/cardboard"))
25892596
.tag(Tags.Items.STORAGE_BLOCKS)
25902597
.build()
@@ -2597,6 +2604,7 @@ public class AllBlocks {
25972604
.properties(p -> p.mapColor(MapColor.COLOR_BROWN)
25982605
.sound(SoundType.CHISELED_BOOKSHELF)
25992606
.ignitedByLava())
2607+
.onRegister(block -> FlammableBlockRegistry.getDefaultInstance().add(block, 20, 100))
26002608
.transform(axeOnly())
26012609
.blockstate(BlockStateGen.horizontalAxisBlockProvider(false))
26022610
.loot((r, b) -> r.add(b, LootTable.lootTable()
@@ -2607,6 +2615,7 @@ public class AllBlocks {
26072615
.setRolls(ConstantValue.exactly(1.0F))
26082616
.add(LootItem.lootTableItem(AllBlocks.CARDBOARD_BLOCK.asItem()))))))
26092617
.item(CardboardBlockItem::new)
2618+
.onRegister(item -> FuelRegistry.INSTANCE.add(item, 4000))
26102619
.build()
26112620
.lang("Bound Block of Cardboard")
26122621
.register();

src/main/java/com/simibubi/create/content/contraptions/sync/ContraptionSeatMappingPacket.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import java.util.Map;
55
import java.util.UUID;
66

7+
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
78
import com.simibubi.create.foundation.networking.SimplePacketBase;
89

10+
import net.createmod.catnip.math.VecHelper;
911
import net.minecraft.client.Minecraft;
1012
import net.minecraft.network.FriendlyByteBuf;
1113
import net.minecraft.world.entity.Entity;
@@ -51,7 +53,7 @@ public void write(FriendlyByteBuf buffer) {
5153
public boolean handle(Context context) {
5254
context.enqueueWork(() -> {
5355
Entity entityByID = Minecraft.getInstance().level.getEntity(entityID);
54-
if (!(entityByID instanceof AbstractContraptionEntitycontraptionEntity))
56+
if (!(entityByID instanceof AbstractContraptionEntity contraptionEntity))
5557
return;
5658

5759

@@ -62,7 +64,7 @@ public boolean handle(Context context) {
6264
Vec3 transformedVector = contraptionEntity.getPassengerPosition(dismountedByID, 1);
6365
if (transformedVector != null)
6466
dismountedByID.getCustomData()
65-
.put("ContraptionDismountLocation", net.createmod.catnip.utility.VecHelper.writeNBT(transformedVector));
67+
.put("ContraptionDismountLocation", VecHelper.writeNBT(transformedVector));
6668
}
6769

6870
contraptionEntity.getContraption()

src/main/java/com/simibubi/create/content/contraptions/wrench/RadialWrenchMenu.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
import javax.annotation.Nullable;
1212

13+
import io.github.fabricators_of_create.porting_lib.util.KeyBindingHelper;
14+
1315
import org.joml.Matrix4f;
1416

1517
import com.mojang.blaze3d.platform.InputConstants;
@@ -271,7 +273,7 @@ private void renderRadialSectors(GuiGraphics graphics) {
271273
.rotateZDegrees(-i * sectorAngle);
272274

273275
poseStack.translate(0, 0, 100);
274-
276+
275277
try {
276278
GuiGameElement.of(blockState, blockEntity)
277279
.rotateBlock(player.getXRot(), player.getYRot() + 180, 0f)
@@ -366,7 +368,7 @@ public void renderBackground(GuiGraphics graphics) {
366368
@Override
367369
public boolean keyReleased(int code, int scanCode, int modifiers) {
368370
InputConstants.Key mouseKey = InputConstants.getKey(code, scanCode);
369-
if (AllKeys.ROTATE_MENU.getKeybind().isActiveAndMatches(mouseKey)) {
371+
if (KeyBindingHelper.isActiveAndMatches(AllKeys.ROTATE_MENU.getKeybind(), mouseKey)) {
370372
submitChange();
371373
return true;
372374
}

src/main/java/com/simibubi/create/content/decoration/CardboardBlock.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package com.simibubi.create.content.decoration;
22

3-
import net.minecraft.core.BlockPos;
43
import net.minecraft.core.Direction;
54
import net.minecraft.core.Direction.Axis;
65
import net.minecraft.core.Direction.AxisDirection;
76
import net.minecraft.world.item.context.BlockPlaceContext;
8-
import net.minecraft.world.level.BlockGetter;
97
import net.minecraft.world.level.block.Block;
108
import net.minecraft.world.level.block.Mirror;
119
import net.minecraft.world.level.block.Rotation;
@@ -29,16 +27,6 @@ public BlockState getStateForPlacement(BlockPlaceContext pContext) {
2927
.getAxis());
3028
}
3129

32-
@Override
33-
public int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
34-
return 100;
35-
}
36-
37-
@Override
38-
public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
39-
return 20;
40-
}
41-
4230
@Override
4331
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
4432
super.createBlockStateDefinition(builder.add(HORIZONTAL_AXIS));
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package com.simibubi.create.content.decoration;
22

3-
import org.jetbrains.annotations.Nullable;
4-
53
import net.minecraft.world.item.BlockItem;
6-
import net.minecraft.world.item.ItemStack;
7-
import net.minecraft.world.item.crafting.RecipeType;
84
import net.minecraft.world.level.block.Block;
95

106
public class CardboardBlockItem extends BlockItem {
@@ -13,9 +9,4 @@ public CardboardBlockItem(Block pBlock, Properties pProperties) {
139
super(pBlock, pProperties);
1410
}
1511

16-
@Override
17-
public int getBurnTime(ItemStack itemStack, @Nullable RecipeType<?> recipeType) {
18-
return 4000;
19-
}
20-
2112
}

src/main/java/com/simibubi/create/content/decoration/copycat/CopycatPanelModel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.simibubi.create.AllBlocks;
66
import com.simibubi.create.foundation.model.BakedModelHelper;
77

8+
import net.createmod.catnip.data.Iterate;
89
import net.minecraft.client.Minecraft;
910
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
1011
import net.minecraft.client.resources.model.BakedModel;
@@ -91,7 +92,7 @@ protected void emitBlockQuadsInner(BlockAndTintGetter blockView, BlockState stat
9192
}
9293

9394
// 2 Pieces
94-
for (boolean front : net.createmod.catnip.utility.Iterate.trueAndFalse) {
95+
for (boolean front : Iterate.trueAndFalse) {
9596
Vec3 normalScaledN13 = normal.scale(front ? 0 : -13 / 16f);
9697
float contract = 16 - (front ? 1 : 2);
9798
AABB bb = CUBE_AABB.contract(normal.x * contract / 16, normal.y * contract / 16, normal.z * contract / 16);

src/main/java/com/simibubi/create/content/equipment/armor/DivingBootsItem.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.simibubi.create.content.equipment.armor;
22

3+
import net.createmod.catnip.nbt.NBTHelper;
34
import net.minecraft.resources.ResourceLocation;
45
import net.minecraft.tags.FluidTags;
56
import net.minecraft.world.entity.Entity;
@@ -67,7 +68,7 @@ protected static boolean affects(LivingEntity entity) {
6768
return false;
6869
}
6970

70-
net.createmod.catnip.utility.NBTHelper.putMarker(entity.getCustomData(), "HeavyBoots");
71+
NBTHelper.putMarker(entity.getCustomData(), "HeavyBoots");
7172
if (!entity.isInWater())
7273
return false;
7374
if (entity.getPose() == Pose.SWIMMING)

src/main/java/com/simibubi/create/content/equipment/clipboard/ClipboardBlockEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void onEditedBy(Player player) {
4848
public void lazyTick() {
4949
super.lazyTick();
5050
if (level.isClientSide())
51-
DistExecutor.unsafeRunWhenOn(EnvType.CLIENT, () -> this::advertiseToAddressHelper);
51+
EnvExecutor.runWhenOn(EnvType.CLIENT, () -> this::advertiseToAddressHelper);
5252
}
5353

5454
public void updateWrittenState() {

src/main/java/com/simibubi/create/content/equipment/clipboard/ClipboardValueSettingsHandler.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ private static InteractionResult interact(ItemStack itemStack, BlockPos pos, Lev
151151
return InteractionResult.PASS;
152152

153153
if (smartBE instanceof ClipboardBlockEntity cbe) {
154-
event.setCanceled(true);
155-
event.setCancellationResult(InteractionResult.SUCCESS);
156154

157155
if (!world.isClientSide()) {
158156
List<List<ClipboardEntry>> listTo = ClipboardEntry.readAll(itemStack);
@@ -195,7 +193,7 @@ private static InteractionResult interact(ItemStack itemStack, BlockPos pos, Lev
195193
.withStyle(ChatFormatting.WHITE))
196194
.style(ChatFormatting.GREEN)
197195
.component(), true);
198-
return;
196+
return InteractionResult.SUCCESS;
199197
}
200198
CompoundTag tag = itemStack.getTagElement("CopiedValues");
201199
if (paste && tag == null)

src/main/java/com/simibubi/create/content/equipment/hats/CreateHatArmorLayer.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
1212
import dev.engine_room.flywheel.lib.transform.TransformStack;
13+
14+
import io.github.fabricators_of_create.porting_lib.mixin.accessors.client.accessor.ModelPartAccessor;
15+
1316
import net.createmod.catnip.render.CachedBuffers;
1417
import net.minecraft.client.model.AgeableListModel;
1518
import net.minecraft.client.model.EntityModel;
@@ -50,11 +53,12 @@ public void render(PoseStack ms, MultiBufferSource buffer, int light, LivingEnti
5053

5154
if (entityModel instanceof AgeableListModel<?> model) {
5255
if (model.young) {
53-
if (model.scaleHead) {
54-
float f = 1.5F / model.babyHeadScale;
56+
AgeableListModelAccessor accessor = (AgeableListModelAccessor) model;
57+
if (accessor.getScaleHead()) {
58+
float f = 1.5F / accessor.getBabyHeadScale();
5559
ms.scale(f, f, f);
5660
}
57-
ms.translate(0.0D, model.babyYHeadOffset / 16.0F, model.babyZHeadOffset / 16.0F);
61+
ms.translate(0.0D, accessor.getBabyYHeadOffset() / 16.0F, accessor.getBabyZHeadOffset() / 16.0F);
5862
}
5963

6064
ModelPart head = getHeadPart(model);
@@ -70,7 +74,8 @@ public void render(PoseStack ms, MultiBufferSource buffer, int light, LivingEnti
7074

7175
ModelPart lastChild = partsToHead.get(partsToHead.size() - 1);
7276
if (!lastChild.isEmpty()) {
73-
Cube cube = lastChild.cubes.get(Mth.clamp(info.cubeIndex(), 0, lastChild.cubes.size() - 1));
77+
List<Cube> cubes = ((ModelPartAccessor) (Object) lastChild).porting_lib$cubes();
78+
Cube cube = cubes.get(Mth.clamp(info.cubeIndex(), 0, cubes.size() - 1));
7479
ms.translate(info.offset().x() / 16.0F, (cube.minY - cube.maxY + info.offset().y()) / 16.0F, info.offset().z() / 16.0F);
7580
float max = Math.max(cube.maxX - cube.minX, cube.maxZ - cube.minZ) / 8.0F * info.scale();
7681
ms.scale(max, max, max);

src/main/java/com/simibubi/create/content/equipment/potatoCannon/AllPotatoProjectileEntityHitActions.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,7 @@ public boolean execute(ItemStack projectile, EntityHitResult ray, Type type) {
158158
double teleportZ = entityZ + (livingEntity.getRandom()
159159
.nextDouble() - 0.5D) * teleportDiameter;
160160

161-
EntityTeleportEvent.ChorusFruit event =
162-
ForgeEventFactory.onChorusFruitTeleport(livingEntity, teleportX, teleportY, teleportZ);
163-
if (event.isCanceled())
164-
return false;
165-
if (livingEntity.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) {
161+
if (livingEntity.randomTeleport(teleportX, teleportY, teleportZ, true)) {
166162
if (livingEntity.isPassenger())
167163
livingEntity.stopRiding();
168164

src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantmen
247247
return true;
248248
if (enchantment == AllEnchantments.POTATO_RECOVERY.get())
249249
return true;
250-
return super.canApplyAtEnchantingTable(stack, enchantment);
250+
return CustomEnchantingBehaviorItem.super.canApplyAtEnchantingTable(stack, enchantment);
251251
}
252252

253253
@Override

src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonItemRenderer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer {
2525
public static final RenderItemDecorationsCallback DECORATOR = (guiGraphics, font, stack, xOffset, yOffset) -> {
2626
LocalPlayer player = Minecraft.getInstance().player;
2727
if (player == null) {
28-
return false;
28+
return;
2929
}
3030

3131
Ammo ammo = PotatoCannonItem.getAmmo(player, stack);
3232
if (ammo == null || AllItems.POTATO_CANNON.is(ammo.stack())) {
33-
return false;
33+
return;
3434
}
3535

3636
PoseStack poseStack = guiGraphics.pose();
@@ -39,7 +39,6 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer {
3939
poseStack.scale(.5f, .5f, .5f);
4040
guiGraphics.renderItem(ammo.stack(), 0, 0);
4141
poseStack.popPose();
42-
return false;
4342
};
4443

4544
protected static final PartialModel COG = PartialModel.of(Create.asResource("item/potato_cannon/cog"));

src/main/java/com/simibubi/create/content/equipment/wrench/IWrenchable.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
1010
import com.simibubi.create.content.kinetics.base.RotatedPillarKineticBlock;
1111

12+
import com.simibubi.create.foundation.utility.BlockHelper;
13+
1214
import net.createmod.catnip.math.VoxelShaper;
1315
import net.minecraft.core.BlockPos;
1416
import net.minecraft.core.Direction;
@@ -19,10 +21,13 @@
1921
import net.minecraft.world.item.context.UseOnContext;
2022
import net.minecraft.world.level.Level;
2123
import net.minecraft.world.level.block.Block;
24+
import net.minecraft.world.level.block.entity.BlockEntity;
2225
import net.minecraft.world.level.block.state.BlockState;
2326

2427
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
2528

29+
import java.util.Objects;
30+
2631
public interface IWrenchable {
2732

2833
default InteractionResult onWrenched(BlockState state, UseOnContext context) {
@@ -48,26 +53,27 @@ default BlockState updateAfterWrenched(BlockState newState, UseOnContext context
4853
default InteractionResult onSneakWrenched(BlockState state, UseOnContext context) {
4954
Level world = context.getLevel();
5055
BlockPos pos = context.getClickedPos();
51-
Player player = context.getPlayer();
56+
// note: this player is never null
57+
Player player = Objects.requireNonNull(context.getPlayer());
5258

5359
if (!(world instanceof ServerLevel serverLevel))
5460
return InteractionResult.SUCCESS;
5561

56-
boolean shouldBreak = PlayerBlockBreakEvents.BEFORE.invoker().beforeBlockBreak(world, player, pos, world.getBlockState(pos), null);
57-
if (!shouldBreak)
58-
return InteractionResult.SUCCESS;
59-
60-
if (player != null && !player.isCreative()) {
61-
Block.getDrops(state, serverLevel, pos, world.getBlockEntity(pos), player, context.getItemInHand())
62-
.forEach(itemStack -> {
63-
player.getInventory()
64-
.placeItemBackInInventory(itemStack);
65-
});
66-
}
62+
BlockEntity be = world.getBlockEntity(pos);
63+
BlockHelper.runWithBreakEvents(world, pos, state, be, player, () -> {
64+
if (!player.isCreative()) {
65+
Block.getDrops(state, serverLevel, pos, be, player, context.getItemInHand())
66+
.forEach(itemStack -> {
67+
player.getInventory()
68+
.placeItemBackInInventory(itemStack);
69+
});
70+
}
71+
72+
state.spawnAfterBreak(serverLevel, pos, ItemStack.EMPTY, true);
73+
world.destroyBlock(pos, false);
74+
playRemoveSound(world, pos);
75+
});
6776

68-
state.spawnAfterBreak(serverLevel, pos, ItemStack.EMPTY, true);
69-
world.destroyBlock(pos, false);
70-
playRemoveSound(world, pos);
7177
return InteractionResult.SUCCESS;
7278
}
7379

src/main/java/com/simibubi/create/content/fluids/OpenEndedPipe.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ public long insert(FluidVariant resource, long maxAmount, TransactionContext tra
256256

257257
long fill = super.insert(resource, maxAmount, transaction);
258258

259-
if (effectHandler != null && !resource.isEmpty()) {
259+
if (effectHandler != null) {
260260
// resource should be copied before giving it to the handler.
261261
// if hasBlockState is false, it was already copied above.
262-
FluidStack exposed = hasBlockState ? resource.copy() : resource;
262+
FluidStack exposed = new FluidStack(resource, 81);
263263
effectHandler.apply(world, aoe, exposed);
264264
}
265265

266-
if (getFluidAmount() == 1000 || !hasBlockState)
267-
if (provideFluidToSpace(containedFluidStack, false))
266+
if (getFluidAmount() == FluidConstants.BUCKET || !hasBlockState)
267+
if (provideFluidToSpace(containedFluidStack, transaction))
268268
setFluid(FluidStack.EMPTY);
269269
return fill;
270270
}

src/main/java/com/simibubi/create/content/fluids/PipeAttachmentModel.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,6 @@ private void addQuads(BlockAndTintGetter world, BlockState state, BlockPos pos,
8989
.emitBlockQuads(world, state, pos, randomSupplier, context);
9090
}
9191

92-
@Override
93-
public boolean useAmbientOcclusion(BlockState state, RenderType renderType) {
94-
return ao;
95-
}
96-
97-
@Override
98-
public boolean useAmbientOcclusion(BlockState state) {
99-
return ao;
100-
}
101-
10292
@Override
10393
public boolean useAmbientOcclusion() {
10494
return ao;

0 commit comments

Comments
 (0)