Skip to content

Commit

Permalink
another pass
Browse files Browse the repository at this point in the history
  • Loading branch information
TropheusJ committed Mar 1, 2025
1 parent ce66c51 commit 2f707ab
Show file tree
Hide file tree
Showing 63 changed files with 360 additions and 375 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/simibubi/create/AllBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@
import com.tterrag.registrate.util.entry.BlockEntry;

import net.createmod.catnip.data.Couple;

import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;

import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
Expand Down Expand Up @@ -1867,6 +1871,7 @@ public class AllBlocks {
.properties(p -> p.noOcclusion())
.properties(p -> p.mapColor(MapColor.TERRACOTTA_BLUE)
.sound(SoundType.NETHERITE_BLOCK))
.properties(p -> p.pushReaction(PushReaction.NORMAL))
.transform(pickaxeOnly())
.addLayer(() -> RenderType::cutoutMipped)
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
Expand Down Expand Up @@ -2580,11 +2585,13 @@ public class AllBlocks {
.properties(p -> p.mapColor(MapColor.COLOR_BROWN)
.sound(SoundType.CHISELED_BOOKSHELF)
.ignitedByLava())
.onRegister(block -> FlammableBlockRegistry.getDefaultInstance().add(block, 20, 100))
.transform(axeOnly())
.blockstate(BlockStateGen.horizontalAxisBlockProvider(false))
.tag(Tags.Blocks.STORAGE_BLOCKS)
.tag(AllTags.forgeBlockTag("storage_blocks/cardboard"))
.item(CardboardBlockItem::new)
.onRegister(item -> FuelRegistry.INSTANCE.add(item, 4000))
.tag(AllTags.forgeItemTag("storage_blocks/cardboard"))
.tag(Tags.Items.STORAGE_BLOCKS)
.build()
Expand All @@ -2597,6 +2604,7 @@ public class AllBlocks {
.properties(p -> p.mapColor(MapColor.COLOR_BROWN)
.sound(SoundType.CHISELED_BOOKSHELF)
.ignitedByLava())
.onRegister(block -> FlammableBlockRegistry.getDefaultInstance().add(block, 20, 100))
.transform(axeOnly())
.blockstate(BlockStateGen.horizontalAxisBlockProvider(false))
.loot((r, b) -> r.add(b, LootTable.lootTable()
Expand All @@ -2607,6 +2615,7 @@ public class AllBlocks {
.setRolls(ConstantValue.exactly(1.0F))
.add(LootItem.lootTableItem(AllBlocks.CARDBOARD_BLOCK.asItem()))))))
.item(CardboardBlockItem::new)
.onRegister(item -> FuelRegistry.INSTANCE.add(item, 4000))
.build()
.lang("Bound Block of Cardboard")
.register();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import java.util.Map;
import java.util.UUID;

import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
import com.simibubi.create.foundation.networking.SimplePacketBase;

import net.createmod.catnip.math.VecHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.Entity;
Expand Down Expand Up @@ -51,7 +53,7 @@ public void write(FriendlyByteBuf buffer) {
public boolean handle(Context context) {
context.enqueueWork(() -> {
Entity entityByID = Minecraft.getInstance().level.getEntity(entityID);
if (!(entityByID instanceof AbstractContraptionEntitycontraptionEntity))
if (!(entityByID instanceof AbstractContraptionEntity contraptionEntity))
return;


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

contraptionEntity.getContraption()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import javax.annotation.Nullable;

import io.github.fabricators_of_create.porting_lib.util.KeyBindingHelper;

import org.joml.Matrix4f;

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

poseStack.translate(0, 0, 100);

try {
GuiGameElement.of(blockState, blockEntity)
.rotateBlock(player.getXRot(), player.getYRot() + 180, 0f)
Expand Down Expand Up @@ -366,7 +368,7 @@ public void renderBackground(GuiGraphics graphics) {
@Override
public boolean keyReleased(int code, int scanCode, int modifiers) {
InputConstants.Key mouseKey = InputConstants.getKey(code, scanCode);
if (AllKeys.ROTATE_MENU.getKeybind().isActiveAndMatches(mouseKey)) {
if (KeyBindingHelper.isActiveAndMatches(AllKeys.ROTATE_MENU.getKeybind(), mouseKey)) {
submitChange();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.simibubi.create.content.decoration;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
Expand All @@ -29,16 +27,6 @@ public BlockState getStateForPlacement(BlockPlaceContext pContext) {
.getAxis());
}

@Override
public int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return 100;
}

@Override
public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return 20;
}

@Override
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder.add(HORIZONTAL_AXIS));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.simibubi.create.content.decoration;

import org.jetbrains.annotations.Nullable;

import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.block.Block;

public class CardboardBlockItem extends BlockItem {
Expand All @@ -13,9 +9,4 @@ public CardboardBlockItem(Block pBlock, Properties pProperties) {
super(pBlock, pProperties);
}

@Override
public int getBurnTime(ItemStack itemStack, @Nullable RecipeType<?> recipeType) {
return 4000;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.model.BakedModelHelper;

import net.createmod.catnip.data.Iterate;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.resources.model.BakedModel;
Expand Down Expand Up @@ -91,7 +92,7 @@ protected void emitBlockQuadsInner(BlockAndTintGetter blockView, BlockState stat
}

// 2 Pieces
for (boolean front : net.createmod.catnip.utility.Iterate.trueAndFalse) {
for (boolean front : Iterate.trueAndFalse) {
Vec3 normalScaledN13 = normal.scale(front ? 0 : -13 / 16f);
float contract = 16 - (front ? 1 : 2);
AABB bb = CUBE_AABB.contract(normal.x * contract / 16, normal.y * contract / 16, normal.z * contract / 16);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.simibubi.create.content.equipment.armor;

import net.createmod.catnip.nbt.NBTHelper;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.entity.Entity;
Expand Down Expand Up @@ -67,7 +68,7 @@ protected static boolean affects(LivingEntity entity) {
return false;
}

net.createmod.catnip.utility.NBTHelper.putMarker(entity.getCustomData(), "HeavyBoots");
NBTHelper.putMarker(entity.getCustomData(), "HeavyBoots");
if (!entity.isInWater())
return false;
if (entity.getPose() == Pose.SWIMMING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void onEditedBy(Player player) {
public void lazyTick() {
super.lazyTick();
if (level.isClientSide())
DistExecutor.unsafeRunWhenOn(EnvType.CLIENT, () -> this::advertiseToAddressHelper);
EnvExecutor.runWhenOn(EnvType.CLIENT, () -> this::advertiseToAddressHelper);
}

public void updateWrittenState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ private static InteractionResult interact(ItemStack itemStack, BlockPos pos, Lev
return InteractionResult.PASS;

if (smartBE instanceof ClipboardBlockEntity cbe) {
event.setCanceled(true);
event.setCancellationResult(InteractionResult.SUCCESS);

if (!world.isClientSide()) {
List<List<ClipboardEntry>> listTo = ClipboardEntry.readAll(itemStack);
Expand Down Expand Up @@ -195,7 +193,7 @@ private static InteractionResult interact(ItemStack itemStack, BlockPos pos, Lev
.withStyle(ChatFormatting.WHITE))
.style(ChatFormatting.GREEN)
.component(), true);
return;
return InteractionResult.SUCCESS;
}
CompoundTag tag = itemStack.getTagElement("CopiedValues");
if (paste && tag == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

import dev.engine_room.flywheel.lib.model.baked.PartialModel;
import dev.engine_room.flywheel.lib.transform.TransformStack;

import io.github.fabricators_of_create.porting_lib.mixin.accessors.client.accessor.ModelPartAccessor;

import net.createmod.catnip.render.CachedBuffers;
import net.minecraft.client.model.AgeableListModel;
import net.minecraft.client.model.EntityModel;
Expand Down Expand Up @@ -50,11 +53,12 @@ public void render(PoseStack ms, MultiBufferSource buffer, int light, LivingEnti

if (entityModel instanceof AgeableListModel<?> model) {
if (model.young) {
if (model.scaleHead) {
float f = 1.5F / model.babyHeadScale;
AgeableListModelAccessor accessor = (AgeableListModelAccessor) model;
if (accessor.getScaleHead()) {
float f = 1.5F / accessor.getBabyHeadScale();
ms.scale(f, f, f);
}
ms.translate(0.0D, model.babyYHeadOffset / 16.0F, model.babyZHeadOffset / 16.0F);
ms.translate(0.0D, accessor.getBabyYHeadOffset() / 16.0F, accessor.getBabyZHeadOffset() / 16.0F);
}

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

ModelPart lastChild = partsToHead.get(partsToHead.size() - 1);
if (!lastChild.isEmpty()) {
Cube cube = lastChild.cubes.get(Mth.clamp(info.cubeIndex(), 0, lastChild.cubes.size() - 1));
List<Cube> cubes = ((ModelPartAccessor) (Object) lastChild).porting_lib$cubes();
Cube cube = cubes.get(Mth.clamp(info.cubeIndex(), 0, cubes.size() - 1));
ms.translate(info.offset().x() / 16.0F, (cube.minY - cube.maxY + info.offset().y()) / 16.0F, info.offset().z() / 16.0F);
float max = Math.max(cube.maxX - cube.minX, cube.maxZ - cube.minZ) / 8.0F * info.scale();
ms.scale(max, max, max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,7 @@ public boolean execute(ItemStack projectile, EntityHitResult ray, Type type) {
double teleportZ = entityZ + (livingEntity.getRandom()
.nextDouble() - 0.5D) * teleportDiameter;

EntityTeleportEvent.ChorusFruit event =
ForgeEventFactory.onChorusFruitTeleport(livingEntity, teleportX, teleportY, teleportZ);
if (event.isCanceled())
return false;
if (livingEntity.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) {
if (livingEntity.randomTeleport(teleportX, teleportY, teleportZ, true)) {
if (livingEntity.isPassenger())
livingEntity.stopRiding();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantmen
return true;
if (enchantment == AllEnchantments.POTATO_RECOVERY.get())
return true;
return super.canApplyAtEnchantingTable(stack, enchantment);
return CustomEnchantingBehaviorItem.super.canApplyAtEnchantingTable(stack, enchantment);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer {
public static final RenderItemDecorationsCallback DECORATOR = (guiGraphics, font, stack, xOffset, yOffset) -> {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) {
return false;
return;
}

Ammo ammo = PotatoCannonItem.getAmmo(player, stack);
if (ammo == null || AllItems.POTATO_CANNON.is(ammo.stack())) {
return false;
return;
}

PoseStack poseStack = guiGraphics.pose();
Expand All @@ -39,7 +39,6 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer {
poseStack.scale(.5f, .5f, .5f);
guiGraphics.renderItem(ammo.stack(), 0, 0);
poseStack.popPose();
return false;
};

protected static final PartialModel COG = PartialModel.of(Create.asResource("item/potato_cannon/cog"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
import com.simibubi.create.content.kinetics.base.RotatedPillarKineticBlock;

import com.simibubi.create.foundation.utility.BlockHelper;

import net.createmod.catnip.math.VoxelShaper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand All @@ -19,10 +21,13 @@
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;

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

import java.util.Objects;

public interface IWrenchable {

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

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

boolean shouldBreak = PlayerBlockBreakEvents.BEFORE.invoker().beforeBlockBreak(world, player, pos, world.getBlockState(pos), null);
if (!shouldBreak)
return InteractionResult.SUCCESS;

if (player != null && !player.isCreative()) {
Block.getDrops(state, serverLevel, pos, world.getBlockEntity(pos), player, context.getItemInHand())
.forEach(itemStack -> {
player.getInventory()
.placeItemBackInInventory(itemStack);
});
}
BlockEntity be = world.getBlockEntity(pos);
BlockHelper.runWithBreakEvents(world, pos, state, be, player, () -> {
if (!player.isCreative()) {
Block.getDrops(state, serverLevel, pos, be, player, context.getItemInHand())
.forEach(itemStack -> {
player.getInventory()
.placeItemBackInInventory(itemStack);
});
}

state.spawnAfterBreak(serverLevel, pos, ItemStack.EMPTY, true);
world.destroyBlock(pos, false);
playRemoveSound(world, pos);
});

state.spawnAfterBreak(serverLevel, pos, ItemStack.EMPTY, true);
world.destroyBlock(pos, false);
playRemoveSound(world, pos);
return InteractionResult.SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ public long insert(FluidVariant resource, long maxAmount, TransactionContext tra

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

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

if (getFluidAmount() == 1000 || !hasBlockState)
if (provideFluidToSpace(containedFluidStack, false))
if (getFluidAmount() == FluidConstants.BUCKET || !hasBlockState)
if (provideFluidToSpace(containedFluidStack, transaction))
setFluid(FluidStack.EMPTY);
return fill;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ private void addQuads(BlockAndTintGetter world, BlockState state, BlockPos pos,
.emitBlockQuads(world, state, pos, randomSupplier, context);
}

@Override
public boolean useAmbientOcclusion(BlockState state, RenderType renderType) {
return ao;
}

@Override
public boolean useAmbientOcclusion(BlockState state) {
return ao;
}

@Override
public boolean useAmbientOcclusion() {
return ao;
Expand Down
Loading

0 comments on commit 2f707ab

Please sign in to comment.