Skip to content

Commit

Permalink
Merge branch '1.21.0/dev' into 1.21.0/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Partonetrain authored Jan 8, 2025
2 parents 594b1fe + 1575adf commit 6af7398
Show file tree
Hide file tree
Showing 62 changed files with 388 additions and 626 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
Expand All @@ -19,6 +20,7 @@
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.RenderShape;
Expand All @@ -37,10 +39,8 @@
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import org.violetmoon.quark.addons.oddities.block.be.TinyPotatoBlockEntity;
import org.violetmoon.quark.addons.oddities.item.TinyPotatoBlockItem;
import org.violetmoon.quark.addons.oddities.module.TinyPotatoModule;
Expand Down Expand Up @@ -113,12 +113,12 @@ public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull B

@SuppressWarnings("deprecation")
@Override
public ItemStack getCloneItemStack(BlockGetter level, BlockPos pos, BlockState state) {
public ItemStack getCloneItemStack(LevelReader level, BlockPos pos, BlockState state) {
ItemStack stack = super.getCloneItemStack(level, pos, state);
BlockEntity be = level.getBlockEntity(pos);
if(be instanceof TinyPotatoBlockEntity tater) {
if(tater.hasCustomName())
stack.setHoverName(tater.getCustomName());
stack.set(DataComponents.CUSTOM_NAME, tater.getCustomName());

if(tater.angry)
ItemNBTHelper.setBoolean(stack, ANGRY, true);
Expand Down Expand Up @@ -170,7 +170,7 @@ public BlockState updateShape(BlockState state, @NotNull Direction facing, @NotN

@Override
public void setPlacedBy(@NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity living, ItemStack stack) {
boolean hasCustomName = stack.hasCustomHoverName();
boolean hasCustomName = stack.has(DataComponents.CUSTOM_NAME);
boolean isAngry = isAngry(stack);
if(hasCustomName || isAngry) {
BlockEntity be = world.getBlockEntity(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvent;
Expand All @@ -23,9 +24,7 @@
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;

import org.jetbrains.annotations.NotNull;

import org.violetmoon.quark.addons.oddities.block.CrateBlock;
import org.violetmoon.quark.addons.oddities.capability.CrateItemHandler;
import org.violetmoon.quark.addons.oddities.inventory.CrateMenu;
Expand Down Expand Up @@ -72,17 +71,15 @@ public void tick() {
}

@Override
protected void saveAdditional(@NotNull CompoundTag compound) {
super.saveAdditional(compound);

compound.merge(itemHandler().serializeNBT());
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.saveAdditional(tag, provider);
tag.merge(itemHandler().serializeNBT(provider));
}

@Override
public void load(@NotNull CompoundTag nbt) {
super.load(nbt);

itemHandler().deserializeNBT(nbt);
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.loadAdditional(tag, provider);
itemHandler().deserializeNBT(provider, tag);
}

public CrateItemHandler itemHandler() {
Expand Down Expand Up @@ -266,5 +263,4 @@ private void playSound(BlockState state, SoundEvent sound) {
double d2 = (double) this.worldPosition.getZ() + 0.5D;
this.level.playSound(null, d0, d1, d2, sound, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.violetmoon.quark.addons.oddities.module.MagnetsModule;
import org.violetmoon.quark.api.IMagneticEntity;
import org.violetmoon.quark.content.automation.entity.Gravisand;
import org.violetmoon.quark.content.experimental.module.VariantSelectorModule;
import org.violetmoon.quark.mixin.mixins.accessor.AccessorServerGamePacketListener;
import org.violetmoon.zeta.api.ICollateralMover;

Expand Down Expand Up @@ -59,7 +58,7 @@ private void magnetize(BlockState state, Direction dir, Direction moveDir, int p
}

if (targetState.getBlock() == MagnetsModule.magnetized_block && level.getBlockEntity(targetPos) instanceof MagnetizedBlockBlockEntity mbe) {
targetState = mbe.blockState;
targetState = mbe.getBlockState();
}

if (!canFluxPenetrate(targetPos, targetState)) break;
Expand Down Expand Up @@ -125,9 +124,9 @@ private void pushEntity(Direction dir, double magnitude, Entity e) {
}

private boolean canPullEntity(Entity e) {
if (this.level.isClientSide) {
if (MagnetsModule.affectsArmor && e instanceof Player) {
for (var armor : e.getArmorSlots()) {
if (level.isClientSide) {
if (MagnetsModule.affectsArmor && e instanceof Player player) {
for (var armor : player.getArmorSlots()) {
if (MagnetSystem.isItemMagnetic(armor.getItem())) return true;
}
}
Expand All @@ -145,8 +144,8 @@ private boolean canPullEntity(Entity e) {
return MagnetSystem.isBlockMagnetic(fb.getBlockState());
}

if (MagnetsModule.affectsArmor) {
for (var armor : e.getArmorSlots()) {
if (MagnetsModule.affectsArmor && e instanceof Player player) {
for (var armor : player.getArmorSlots()) {
if (MagnetSystem.isItemMagnetic(armor.getItem())) return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.violetmoon.quark.addons.oddities.capability;

import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand All @@ -9,10 +10,8 @@
import net.minecraft.world.Containers;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.items.ItemStackHandler;

import net.neoforged.neoforge.items.ItemStackHandler;
import org.jetbrains.annotations.NotNull;

import org.violetmoon.quark.addons.oddities.module.CrateModule;
import org.violetmoon.quark.base.handler.SortingHandler;

Expand Down Expand Up @@ -159,25 +158,23 @@ protected void onLoad() {
}

@Override
public CompoundTag serializeNBT() {
public CompoundTag serializeNBT(HolderLookup.Provider provider) {
ListTag items = new ListTag();
for(ItemStack stack : stacks) {
if(!stack.isEmpty())
items.add(stack.save(new CompoundTag()));
if(!stack.isEmpty()) items.add(stack.save(provider, new CompoundTag()));
}
CompoundTag nbt = new CompoundTag();
nbt.put("stacks", items);
return nbt;
}

@Override
public void deserializeNBT(CompoundTag nbt) {
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) {
stacks = NonNullList.withSize(maxItems, ItemStack.EMPTY);

ListTag items = nbt.getList("stacks", Tag.TAG_COMPOUND);
for(int i = 0; i < items.size(); i++)
stacks.set(i, ItemStack.of(items.getCompound(i)));
stacks.set(i, ItemStack.parseOptional(provider, items.getCompound(i)));
onLoad();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public MatrixEnchantingPlusButton(int x, int y, OnPress onPress) {
}

@Override
public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
public void renderWidget(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height;
if(!visible)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.*;
import net.minecraft.world.item.ItemStack;

import org.jetbrains.annotations.NotNull;

import org.violetmoon.quark.addons.oddities.inventory.slot.BackpackSlot;
import org.violetmoon.quark.addons.oddities.inventory.slot.CachedItemHandlerSlot;
import org.violetmoon.quark.addons.oddities.module.BackpackModule;
Expand Down Expand Up @@ -79,7 +77,7 @@ else if(index == 0) // crafting result
slot.onQuickCraft(stack, baseStack);
}

else if(slotType != null && slotType.getType() == Type.ARMOR && !this.slots.get(equipIndex).hasItem()) { // shift clicking armor
else if(slotType != null && slotType.getType() == Type.HUMANOID_ARMOR && !this.slots.get(equipIndex).hasItem()) { // shift clicking armor
if(!this.moveItemStackTo(stack, equipIndex, equipIndex + 1, false))
return ItemStack.EMPTY;
}
Expand Down Expand Up @@ -140,7 +138,7 @@ public boolean moveItemStackTo(ItemStack stack, int start, int length, boolean r
int maxStack = Math.min(stack.getMaxStackSize(), slot.getMaxStackSize());
int rmv = Math.min(maxStack, stack.getCount());

if(slot.mayPlace(cloneStack(stack, rmv)) && existingStack.getItem().equals(stack.getItem()) && ItemStack.isSameItemSameTags(stack, existingStack)) {
if(slot.mayPlace(cloneStack(stack, rmv)) && existingStack.getItem().equals(stack.getItem()) && ItemStack.isSameItemSameComponents(stack, existingStack)) {
int existingSize = existingStack.getCount() + stack.getCount();

if(existingSize <= maxStack) {
Expand Down Expand Up @@ -209,5 +207,4 @@ public static void saveCraftingInventory(Player player) {
public @NotNull MenuType<?> getType() {
return BackpackModule.menyType;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void registerTaters(ZAddModels event, String mod, Set<String> usedNames,
usedNames.add(path);

path = path.substring("models/".length(), path.length() - ".json".length());
event.register(Quark.asResource(path));
event.register(ModelResourceLocation.standalone(Quark.asResource(path)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;

import org.violetmoon.quark.addons.oddities.client.render.entity.TotemOfHoldingRenderer;
import org.violetmoon.quark.addons.oddities.entity.TotemOfHoldingEntity;
import org.violetmoon.quark.base.Quark;
Expand Down Expand Up @@ -61,7 +60,6 @@ public final void register(ZRegister event) {
.updateInterval(128) // update interval
.fireImmune()
.setShouldReceiveVelocityUpdates(false)
.setCustomClientFactory((spawnEntity, world) -> new TotemOfHoldingEntity(totemType, world))
.build("totem");
Quark.ZETA.registry.register(totemType, "totem", Registries.ENTITY_TYPE);
}
Expand Down Expand Up @@ -126,7 +124,7 @@ public final void clientSetup(ZClientSetup event) {

@LoadEvent
public void registerAdditionalModels(ZAddModels event) {
event.register(new ModelResourceLocation(Quark.MOD_ID, "extra/totem_of_holding", "inventory"));
event.register(ModelResourceLocation.inventory(Quark.asResource("extra/totem_of_holding")));
}
}
}
5 changes: 3 additions & 2 deletions src/main/java/org/violetmoon/quark/base/Quark.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -46,10 +47,10 @@ public class Quark {
() -> TerrablenderUndergroundBiomeHandler::new,
() -> VanillaUndergroundBiomeHandler::new);

public Quark() {
public Quark(IEventBus bus) {
instance = this;

ZETA.start();
ZETA.start(bus);

proxy = Env.unsafeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
proxy.start();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/violetmoon/quark/base/QuarkClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.violetmoon.quark.base;

import net.minecraftforge.client.event.RegisterColorHandlersEvent;
import org.violetmoon.quark.integration.lootr.client.ClientLootrIntegration;
import org.violetmoon.quark.integration.lootr.client.IClientLootrIntegration;
import org.violetmoon.zeta.client.ClientTicker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,37 @@ protected void init() {
protected float partialTicks;

@Override
public void renderBackground(GuiGraphics guiGraphics) {
public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
time += partialTicks;

Minecraft mc = Minecraft.getInstance();

if(mc.level == null) {
float spin = partialTicks * 2;
float blur = 0.85F;

if(time < 20F && !QuarkGeneralConfig.disableQMenuEffects) {
if (time < 20F && !QuarkGeneralConfig.disableQMenuEffects) {
spin += (20F - time);
blur = (time / 20F) * 0.75F + 0.1F;
}

PANORAMA.render(spin, blur);
} else
super.renderBackground(guiGraphics);
PANORAMA.render(graphics, this.width, this.height, spin, blur);
} else {
super.renderBackground(graphics, mouseX, mouseY, partialTick);
}

int boxWidth = 400;
guiGraphics.fill(width / 2 - boxWidth / 2, 0, width / 2 + boxWidth / 2, this.height, 0x66000000);
guiGraphics.fill(width / 2 - boxWidth / 2 - 1, 0, width / 2 - boxWidth / 2, this.height, 0x66999999); // nice
guiGraphics.fill(width / 2 + boxWidth / 2, 0, width / 2 + boxWidth / 2 + 1, this.height, 0x66999999);
graphics.fill(width / 2 - boxWidth / 2, 0, width / 2 + boxWidth / 2, this.height, 0x66000000);
graphics.fill(width / 2 - boxWidth / 2 - 1, 0, width / 2 - boxWidth / 2, this.height, 0x66999999); // nice
graphics.fill(width / 2 + boxWidth / 2, 0, width / 2 + boxWidth / 2 + 1, this.height, 0x66999999);
}

@Override
public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
this.partialTicks = partialTicks;

super.render(guiGraphics, mouseX, mouseY, partialTicks);

guiGraphics.drawCenteredString(font, I18n.get("quark.gui.config.subheader1", ChatFormatting.LIGHT_PURPLE, ContributorRewardHandler.featuredPatron, ChatFormatting.RESET), width / 2, 28, 0x9EFFFE);
guiGraphics.drawCenteredString(font, I18n.get("quark.gui.config.subheader2"), width / 2, 38, 0x9EFFFE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public void setupAnim(@NotNull LivingEntity entity, float limbSwing, float limbS
}

@Override
public void renderToBuffer(@NotNull PoseStack ms, @NotNull VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a) {
public void renderToBuffer(PoseStack poseStack, VertexConsumer consumer, int light, int overlay, int color) {
setPartVisibility(slot);
super.renderToBuffer(ms, buffer, light, overlay, r, g, b, a);
super.renderToBuffer(poseStack, consumer, light, overlay, color);
}

// [VanillaCopy] HumanoidArmorLayer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void render(Boat boat, float yaw, float partialTicks, PoseStack matrix, @
matrix.mulPose(Axis.YP.rotationDegrees(90.0F));
model.setupAnim(boat, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F);
VertexConsumer vertexconsumer = buffer.getBuffer(model.renderType(loc));
model.renderToBuffer(matrix, vertexconsumer, light, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
model.renderToBuffer(matrix, vertexconsumer, light, OverlayTexture.NO_OVERLAY);
if(!boat.isUnderWater()) {
VertexConsumer waterMask = buffer.getBuffer(RenderType.waterMask());
model.waterPatch().render(matrix, waterMask, light, OverlayTexture.NO_OVERLAY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ public static void register(ZRegister event) {
quarkBoatEntityType = EntityType.Builder.<QuarkBoat>of(QuarkBoat::new, MobCategory.MISC)
.sized(1.375F, 0.5625F)
.clientTrackingRange(10)
.setCustomClientFactory((spawnEntity, world) -> new QuarkBoat(quarkBoatEntityType, world))
.build("quark_boat");

quarkChestBoatEntityType = EntityType.Builder.<QuarkChestBoat>of(QuarkChestBoat::new, MobCategory.MISC)
.sized(1.375F, 0.5625F)
.clientTrackingRange(10)
.setCustomClientFactory((spawnEntity, world) -> new QuarkChestBoat(quarkChestBoatEntityType, world))
.build("quark_chest_boat");

Quark.ZETA.registry.register(quarkBoatEntityType, "quark_boat", Registries.ENTITY_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.Level;

import org.jetbrains.annotations.NotNull;

import org.violetmoon.quark.base.handler.WoodSetHandler;
import org.violetmoon.quark.base.handler.WoodSetHandler.QuarkBoatType;

Expand Down
Loading

0 comments on commit 6af7398

Please sign in to comment.