From dabe6602a7c9db6bb35599a973595dac97409450 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Tue, 14 Nov 2023 21:26:11 -0500 Subject: [PATCH] porting --- .../oddities/block/pipe/BasePipeBlock.java | 19 +++-- .../screen/BackpackInventoryScreen.java | 38 +++++----- .../oddities/inventory/BackpackMenu.java | 9 ++- .../addons/oddities/item/BackpackItem.java | 4 +- .../oddities/module/BackpackModule.java | 24 +++---- .../java/org/violetmoon/quark/base/Quark.java | 4 ++ .../quark/base/handler/WoodSetHandler.java | 7 +- .../client/module/AutoWalkKeybindModule.java | 5 +- .../content/client/module/CameraModule.java | 1 + .../client/tooltip/AttributeTooltips.java | 70 +++++++------------ .../module/AutomaticToolRestockModule.java | 13 ++-- .../content/mobs/ai/BarkAtDarknessGoal.java | 5 +- .../quark/content/mobs/entity/Toretoise.java | 3 +- .../tools/entity/rang/AbstractPickarang.java | 54 +++++++------- .../tools/module/AncientTomesModule.java | 17 ++--- .../tools/module/BottledCloudModule.java | 21 +++--- .../module/BetterElytraRocketModule.java | 2 +- .../module/CampfiresBoostElytraModule.java | 2 +- .../world/block/AncientSaplingBlock.java | 32 +++++---- .../world/block/BlossomLeavesBlock.java | 3 +- .../world/block/BlossomSaplingBlock.java | 1 + .../world/gen/BigStoneClusterGenerator.java | 22 +++--- .../content/world/item/AncientFruitItem.java | 3 +- .../world/module/AncientWoodModule.java | 5 +- .../world/module/BigStoneClustersModule.java | 13 ++-- .../world/module/BlossomTreesModule.java | 20 +++--- .../quark/mixin/BeehiveBlockEntityMixin.java | 2 +- .../zeta/block/ZetaLeavesBlock.java | 22 +++--- .../client/config/widget/CategoryButton.java | 26 ++++--- .../client/config/widget/CheckboxButton.java | 25 +++---- .../zeta/registry/BrewingRegistry.java | 13 ++-- 31 files changed, 233 insertions(+), 252 deletions(-) diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/BasePipeBlock.java b/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/BasePipeBlock.java index e3c1532ffe..bb5534d150 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/BasePipeBlock.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/BasePipeBlock.java @@ -1,10 +1,5 @@ package org.violetmoon.quark.addons.oddities.block.pipe; -import java.util.HashSet; -import java.util.Set; - -import javax.annotation.Nonnull; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.InteractionHand; @@ -17,11 +12,7 @@ import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.EntityBlock; -import net.minecraft.world.level.block.Mirror; -import net.minecraft.world.level.block.Rotation; -import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -29,6 +20,7 @@ import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import org.jetbrains.annotations.Nullable; @@ -38,6 +30,10 @@ import org.violetmoon.zeta.module.ZetaModule; import org.violetmoon.zeta.registry.RenderLayerRegistry; +import javax.annotation.Nonnull; +import java.util.HashSet; +import java.util.Set; + import static org.violetmoon.quark.base.handler.MiscUtil.directionProperty; public abstract class BasePipeBlock extends ZetaBlock implements EntityBlock { @@ -62,7 +58,8 @@ protected static BooleanProperty property(Direction direction) { protected BasePipeBlock(String name, ZetaModule module) { super(name, module, CreativeModeTab.TAB_REDSTONE, - Block.Properties.of(Material.GLASS) + Block.Properties.of() + .instrument(NoteBlockInstrument.HAT) .strength(3F, 10F) .sound(SoundType.GLASS) .noOcclusion()); diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/client/screen/BackpackInventoryScreen.java b/src/main/java/org/violetmoon/quark/addons/oddities/client/screen/BackpackInventoryScreen.java index ed4c19c348..f147ff09e4 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/client/screen/BackpackInventoryScreen.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/client/screen/BackpackInventoryScreen.java @@ -1,10 +1,11 @@ package org.violetmoon.quark.addons.oddities.client.screen; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.ImageButton; -import net.minecraft.client.gui.components.Widget; +import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.screens.inventory.InventoryScreen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; @@ -13,14 +14,10 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.item.ItemStack; - -import javax.annotation.Nonnull; - import org.violetmoon.quark.addons.oddities.inventory.BackpackMenu; import org.violetmoon.quark.addons.oddities.module.BackpackModule; import org.violetmoon.quark.base.Quark; import org.violetmoon.quark.base.QuarkClient; -import org.violetmoon.quark.base.network.QuarkNetwork; import org.violetmoon.quark.base.network.message.oddities.HandleBackpackMessage; import java.util.HashMap; @@ -57,12 +54,12 @@ public void init() { buttonYs.clear(); - for(Widget widget : renderables) - if(widget instanceof Button b) - if(b.getClass().getName().contains("GuiButtonInventoryBook")) { // class check for Patchouli - if(!buttonYs.containsKey(b)) { - b.y -= 29; - buttonYs.put(b, b.y); + for (Renderable renderable : renderables) + if (renderable instanceof Button b) + if (b.getClass().getName().contains("GuiButtonInventoryBook")) { // class check for Patchouli + if (!buttonYs.containsKey(b)) { + b.setY(b.getY() - 29); + buttonYs.put(b, b.getY()); } } @@ -70,7 +67,7 @@ public void init() { @Override public void containerTick() { - buttonYs.forEach((button, y) -> button.y = y); + buttonYs.forEach(AbstractWidget::setY); super.containerTick(); @@ -95,23 +92,22 @@ public void removed() { } @Override - protected void renderBg(@Nonnull PoseStack stack, float partialTicks, int mouseX, int mouseY) { + protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) { RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.setShaderTexture(0, BACKPACK_INVENTORY_BACKGROUND); int i = leftPos; int j = topPos; - blit(stack, i, j, 0, 0, imageWidth, imageHeight); - renderEntityInInventory(i + 51, j + 75, 30, i + 51 - mouseX, j + 75 - 50 - mouseY, minecraft.player); + guiGraphics.blit(BACKPACK_INVENTORY_BACKGROUND, i, j, 0, 0, imageWidth, imageHeight); + renderEntityInInventoryFollowsMouse(guiGraphics, i + 51, j + 75, 30, i + 51 - mouseX, j + 75 - 50 - mouseY, minecraft.player); moveCharmsButtons(); } private void moveCharmsButtons() { - for(Widget widget : renderables) { + for (Renderable renderable : renderables) { //Charms buttons have a static Y pos, so use that to only focus on them. - if(widget instanceof ImageButton img) { - if(img.y == height / 2 - 22) - img.setPosition(img.x, img.y - 29); + if (renderable instanceof ImageButton img) { + if (img.getY() == height / 2 - 22) + img.setPosition(img.getX(), img.getY() - 29); } } } diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/inventory/BackpackMenu.java b/src/main/java/org/violetmoon/quark/addons/oddities/inventory/BackpackMenu.java index 2dde74ef7d..8119e6ffae 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/inventory/BackpackMenu.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/inventory/BackpackMenu.java @@ -8,18 +8,17 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.*; import net.minecraft.world.item.ItemStack; - -import javax.annotation.Nonnull; - 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; import org.violetmoon.quark.base.util.InventoryIIH; +import javax.annotation.Nonnull; + public class BackpackMenu extends InventoryMenu { public BackpackMenu(int windowId, Player player) { - super(player.getInventory(), !player.level.isClientSide, player); + super(player.getInventory(), !player.getCommandSenderWorld().isClientSide, player); this.containerId = windowId; Inventory inventory = player.getInventory(); @@ -138,7 +137,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.tagMatches(stack, existingStack)) { + if (slot.mayPlace(cloneStack(stack, rmv)) && existingStack.getItem().equals(stack.getItem()) && ItemStack.isSameItemSameTags(stack, existingStack)) { int existingSize = existingStack.getCount() + stack.getCount(); if (existingSize <= maxStack) { diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java b/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java index 2b60064094..3bfa53f72d 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java @@ -173,7 +173,7 @@ public void inventoryTick(@Nonnull ItemStack stack, Level worldIn, @Nonnull Enti @Override public boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity entityItem) { - if(BackpackModule.superOpMode || entityItem.level.isClientSide) + if(BackpackModule.superOpMode || entityItem.getCommandSenderWorld().isClientSide) return false; if (!ItemNBTHelper.detectNBT(stack)) @@ -190,7 +190,7 @@ public boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity entityItem) { ItemStack stackAt = handler.getStackInSlot(i); if(!stackAt.isEmpty()) { ItemStack copy = stackAt.copy(); - Containers.dropItemStack(entityItem.level, entityItem.getX(), entityItem.getY(), entityItem.getZ(), copy); + Containers.dropItemStack(entityItem.getCommandSenderWorld(), entityItem.getX(), entityItem.getY(), entityItem.getZ(), copy); } } diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/module/BackpackModule.java b/src/main/java/org/violetmoon/quark/addons/oddities/module/BackpackModule.java index dd65391089..00d6294ad6 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/module/BackpackModule.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/module/BackpackModule.java @@ -6,8 +6,8 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.InventoryScreen; import net.minecraft.client.renderer.item.ItemProperties; -import net.minecraft.core.Registry; import net.minecraft.core.cauldron.CauldronInteraction; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; @@ -18,15 +18,10 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.DyeableArmorItem; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Rarity; +import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraftforge.common.extensions.IForgeMenuType; import org.violetmoon.quark.addons.oddities.client.screen.BackpackInventoryScreen; import org.violetmoon.quark.addons.oddities.inventory.BackpackMenu; @@ -82,11 +77,14 @@ public final void register(ZRegister event) { ravager_hide = new ZetaItem("ravager_hide", this, new Item.Properties().rarity(Rarity.RARE).tab(CreativeModeTab.TAB_MATERIALS)).setCondition(() -> enableRavagerHide); menyType = IForgeMenuType.create(BackpackMenu::fromNetwork); - Quark.ZETA.registry.register(menyType, "backpack", Registry.MENU_REGISTRY); + Quark.ZETA.registry.register(menyType, "backpack", Registries.MENU); - bonded_ravager_hide = new ZetaBlock("bonded_ravager_hide", this, CreativeModeTab.TAB_BUILDING_BLOCKS, Block.Properties.of(Material.WOOL, DyeColor.BLACK) + bonded_ravager_hide = new ZetaBlock("bonded_ravager_hide", this, CreativeModeTab.TAB_BUILDING_BLOCKS, Block.Properties.of() + .mapColor(DyeColor.BLACK) + .instrument(NoteBlockInstrument.GUITAR) .strength(1F) - .sound(SoundType.WOOL)) + .sound(SoundType.WOOL) + .ignitedByLava()) .setCondition(() -> enableRavagerHide); CauldronInteraction.WATER.put(backpack, CauldronInteraction.DYED_ITEM); @@ -107,10 +105,10 @@ public void onDrops(ZLivingDrops event) { chance--; amount++; } - if(chance > 0 && entity.level.random.nextDouble() < chance) + if(chance > 0 && entity.getCommandSenderWorld().random.nextDouble() < chance) amount++; - event.getDrops().add(new ItemEntity(entity.level, entity.getX(), entity.getY(), entity.getZ(), new ItemStack(ravager_hide, amount))); + event.getDrops().add(new ItemEntity(entity.getCommandSenderWorld(), entity.getX(), entity.getY(), entity.getZ(), new ItemStack(ravager_hide, amount))); } } diff --git a/src/main/java/org/violetmoon/quark/base/Quark.java b/src/main/java/org/violetmoon/quark/base/Quark.java index 0dbbab868a..afba9df9a8 100644 --- a/src/main/java/org/violetmoon/quark/base/Quark.java +++ b/src/main/java/org/violetmoon/quark/base/Quark.java @@ -1,5 +1,6 @@ package org.violetmoon.quark.base; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; @@ -32,4 +33,7 @@ public Quark() { proxy.start(); } + public static ResourceLocation asResource(String name) { + return new ResourceLocation(MOD_ID, name); + } } diff --git a/src/main/java/org/violetmoon/quark/base/handler/WoodSetHandler.java b/src/main/java/org/violetmoon/quark/base/handler/WoodSetHandler.java index 0502d8ca8b..b74bfb6cf9 100644 --- a/src/main/java/org/violetmoon/quark/base/handler/WoodSetHandler.java +++ b/src/main/java/org/violetmoon/quark/base/handler/WoodSetHandler.java @@ -28,6 +28,7 @@ import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockBehaviour.Properties; import net.minecraft.world.level.block.state.properties.WoodType; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; import net.minecraftforge.common.ToolActions; @@ -104,11 +105,11 @@ public static void setup(ZCommonSetup event) { }); } - public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name, MaterialColor color, MaterialColor barkColor, boolean flammable) { + public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name, MapColor color, MapColor barkColor, boolean flammable) { return addWoodSet(event, module, name, color, barkColor, true, true, flammable); } - public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name, MaterialColor color, MaterialColor barkColor, boolean hasLog, boolean hasBoat, boolean flammable) { + public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name, MapColor color, MapColor barkColor, boolean hasLog, boolean hasBoat, boolean flammable) { WoodType type = WoodType.register(WoodType.create(Quark.MOD_ID + ":" + name)); WoodSet set = new WoodSet(name, module, type); @@ -185,7 +186,7 @@ public static void makeSignWork(Block sign, Block wallSign) { BlockEntityType.SIGN.validBlocks = ImmutableSet.copyOf(validBlocks); } - private static RotatedPillarBlock log(String name, ZetaModule module, MaterialColor topColor, MaterialColor sideColor) { + private static RotatedPillarBlock log(String name, ZetaModule module, MapColor topColor, MapColor sideColor) { return new ZetaPillarBlock(name, module, CreativeModeTab.TAB_BUILDING_BLOCKS, BlockBehaviour.Properties.of(Material.WOOD, s -> s.getValue(RotatedPillarBlock.AXIS) == Direction.Axis.Y ? topColor : sideColor) .strength(2.0F).sound(SoundType.WOOD)); diff --git a/src/main/java/org/violetmoon/quark/content/client/module/AutoWalkKeybindModule.java b/src/main/java/org/violetmoon/quark/content/client/module/AutoWalkKeybindModule.java index d4433113c2..72221a9c78 100644 --- a/src/main/java/org/violetmoon/quark/content/client/module/AutoWalkKeybindModule.java +++ b/src/main/java/org/violetmoon/quark/content/client/module/AutoWalkKeybindModule.java @@ -1,5 +1,6 @@ package org.violetmoon.quark.content.client.module; +import net.minecraft.client.gui.GuiGraphics; import org.violetmoon.quark.base.QuarkClient; import org.violetmoon.quark.base.config.Config; import org.violetmoon.zeta.client.event.load.ZKeyMapping; @@ -56,6 +57,8 @@ public void drawHUD(ZRenderGuiOverlay.Hotbar event) { if(drawHud && autorunning) { String message = I18n.get("quark.misc.autowalking"); + GuiGraphics guiGraphics = event.getGuiGraphics(); + Minecraft mc = Minecraft.getInstance(); int w = mc.font.width("OoO" + message + "oOo"); @@ -70,7 +73,7 @@ public void drawHUD(ZRenderGuiOverlay.Hotbar event) { case 1 -> displayMessage = "oOo " + message + " OoO"; } - mc.font.drawShadow(event.getPoseStack(), displayMessage, x, y, 0xFFFFFFFF); + guiGraphics.drawString(mc.font, displayMessage, x, y, 0xFFFFFFFF, true); } } diff --git a/src/main/java/org/violetmoon/quark/content/client/module/CameraModule.java b/src/main/java/org/violetmoon/quark/content/client/module/CameraModule.java index 1a9fada677..7d7d2aad70 100644 --- a/src/main/java/org/violetmoon/quark/content/client/module/CameraModule.java +++ b/src/main/java/org/violetmoon/quark/content/client/module/CameraModule.java @@ -7,6 +7,7 @@ import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.client.Screenshot; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.resources.language.I18n; diff --git a/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java b/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java index 864f6e6798..c805ec1c8e 100644 --- a/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java +++ b/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java @@ -1,30 +1,5 @@ package org.violetmoon.quark.content.client.tooltip; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.core.registries.BuiltInRegistries; -import org.jetbrains.annotations.NotNull; -import org.violetmoon.quark.base.Quark; -import org.violetmoon.quark.base.QuarkClient; -import org.violetmoon.quark.base.handler.MiscUtil; -import org.violetmoon.quark.content.client.hax.PseudoAccessorItemStack; -import org.violetmoon.quark.content.client.module.ImprovedTooltipsModule; -import org.violetmoon.quark.content.client.resources.AttributeDisplayType; -import org.violetmoon.quark.content.client.resources.AttributeIconEntry; -import org.violetmoon.quark.content.client.resources.AttributeSlot; -import org.violetmoon.quark.content.client.resources.AttributeIconEntry.CompareType; -import org.violetmoon.zeta.client.event.play.ZGatherTooltipComponents; -import org.violetmoon.zeta.util.ItemNBTHelper; - import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; @@ -35,12 +10,11 @@ import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.entity.ItemRenderer; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.network.chat.MutableComponent; @@ -49,12 +23,7 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobType; -import net.minecraft.world.entity.ai.attributes.Attribute; -import net.minecraft.world.entity.ai.attributes.AttributeInstance; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.attributes.AttributeSupplier; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.ai.attributes.DefaultAttributes; +import net.minecraft.world.entity.ai.attributes.*; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.ItemStack; @@ -63,6 +32,22 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; +import org.jetbrains.annotations.NotNull; +import org.violetmoon.quark.base.Quark; +import org.violetmoon.quark.base.QuarkClient; +import org.violetmoon.quark.base.handler.MiscUtil; +import org.violetmoon.quark.content.client.hax.PseudoAccessorItemStack; +import org.violetmoon.quark.content.client.module.ImprovedTooltipsModule; +import org.violetmoon.quark.content.client.resources.AttributeDisplayType; +import org.violetmoon.quark.content.client.resources.AttributeIconEntry; +import org.violetmoon.quark.content.client.resources.AttributeIconEntry.CompareType; +import org.violetmoon.quark.content.client.resources.AttributeSlot; +import org.violetmoon.zeta.client.event.play.ZGatherTooltipComponents; +import org.violetmoon.zeta.util.ItemNBTHelper; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.*; /** * @author WireSegal @@ -210,7 +195,7 @@ private static boolean extractAttributeValues(ItemStack stack, Map slotAttributes, Minecraft mc, boolean forceRenderIfZero, Multimap equippedSlotAttributes, @Nullable Set equippedAttrsToRender) { + private static int renderAttribute(GuiGraphics guiGraphics, Attribute attribute, AttributeSlot slot, int x, int y, ItemStack stack, Multimap slotAttributes, Minecraft mc, boolean forceRenderIfZero, Multimap equippedSlotAttributes, @Nullable Set equippedAttrsToRender) { AttributeIconEntry entry = getIconForAttribute(attribute); if (entry != null) { if (equippedAttrsToRender != null) @@ -221,8 +206,7 @@ private static int renderAttribute(PoseStack matrix, Attribute attribute, Attrib RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.setShaderTexture(0, entry.texture()); - GuiComponent.blit(matrix, x, y, 0, 0, 9, 9, 9, 9); + guiGraphics.blit(entry.texture(), x, y, 0, 0, 9, 9, 9, 9); MutableComponent valueStr = format(attribute, value, entry.displayTypes().get(slot)); @@ -239,13 +223,12 @@ private static int renderAttribute(PoseStack matrix, Attribute attribute, Attrib ChatFormatting color = compareType.getColor(value, otherValue); if (color != ChatFormatting.WHITE) { - RenderSystem.setShaderTexture(0, color == ChatFormatting.RED ? TEXTURE_DOWNGRADE : TEXTURE_UPGRADE); int xp = x - 2; int yp = y - 2; if (ImprovedTooltipsModule.animateUpDownArrows && QuarkClient.ticker.total % 20 < 10) yp++; - GuiComponent.blit(matrix, xp, yp, 0, 0, 13, 13, 13, 13); + guiGraphics.blit(color == ChatFormatting.RED ? TEXTURE_DOWNGRADE : TEXTURE_UPGRADE, xp, yp, 0, 0, 13, 13, 13, 13); } @@ -255,7 +238,7 @@ private static int renderAttribute(PoseStack matrix, Attribute attribute, Attrib } } - mc.font.draw(matrix, valueStr, x + 12, y + 1, -1); + guiGraphics.drawString(mc.font, valueStr, x + 12, y + 1, -1); x += mc.font.width(valueStr) + 20; } } @@ -387,15 +370,14 @@ public void renderImage(@NotNull Font font, int tooltipX, int tooltipY, @NotNull if (showSlots) { RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.setShaderTexture(0, MiscUtil.GENERAL_ICONS); - guiGraphics.blit(pose, x, y, 193 + slot.ordinal() * 9, 35, 9, 9, 256, 256); + guiGraphics.blit(MiscUtil.GENERAL_ICONS, x, y, 193 + slot.ordinal() * 9, 35, 9, 9, 256, 256); x += 20; } for (Attribute key : slotAttributes.keySet()) - x = renderAttribute(pose, key, slot, x, y, stack, slotAttributes, mc, false, presentOnEquipped, equippedAttrsToRender); + x = renderAttribute(guiGraphics, key, slot, x, y, stack, slotAttributes, mc, false, presentOnEquipped, equippedAttrsToRender); for (Attribute key : equippedAttrsToRender) - x = renderAttribute(pose, key, slot, x, y, stack, slotAttributes, mc, true, presentOnEquipped, null); + x = renderAttribute(guiGraphics, key, slot, x, y, stack, slotAttributes, mc, true, presentOnEquipped, null); for (Attribute key : slotAttributes.keys()) { diff --git a/src/main/java/org/violetmoon/quark/content/management/module/AutomaticToolRestockModule.java b/src/main/java/org/violetmoon/quark/content/management/module/AutomaticToolRestockModule.java index 87209a4f5e..98b94898cd 100644 --- a/src/main/java/org/violetmoon/quark/content/management/module/AutomaticToolRestockModule.java +++ b/src/main/java/org/violetmoon/quark/content/management/module/AutomaticToolRestockModule.java @@ -1,9 +1,7 @@ package org.violetmoon.quark.content.management.module; import com.google.common.collect.Lists; -import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Inventory; @@ -17,10 +15,6 @@ import net.minecraftforge.common.ToolActions; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.PlayerInvWrapper; - -import java.util.*; -import java.util.function.Predicate; - import org.violetmoon.quark.addons.oddities.module.BackpackModule; import org.violetmoon.quark.api.event.GatherToolClassesEvent; import org.violetmoon.quark.base.Quark; @@ -36,6 +30,9 @@ import org.violetmoon.zeta.module.ZetaModule; import org.violetmoon.zeta.util.RegistryUtil; +import java.util.*; +import java.util.function.Predicate; + @ZetaLoadModule(category = "management", antiOverlap = "inventorytweaks") public class AutomaticToolRestockModule extends ZetaModule { @@ -172,7 +169,7 @@ private boolean crawlInventory(IItemHandler inv, int lowerBound, int upperBound, @PlayEvent public void onPlayerTick(ZPlayerTick.End event) { - if(!event.getPlayer().level.isClientSide && replacements.containsKey(event.getPlayer())) { + if(!event.getPlayer().getCommandSenderWorld().isClientSide && replacements.containsKey(event.getPlayer())) { Stack replacementStack = replacements.get(event.getPlayer()); synchronized(mutex) { while(!replacementStack.isEmpty()) { @@ -274,7 +271,7 @@ private static List generateDefaultEnchantmentList() { List strings = new ArrayList<>(); for(Enchantment e : enchants) - strings.add(Registry.ENCHANTMENT.getKey(e).toString()); + strings.add(BuiltInRegistries.ENCHANTMENT.getKey(e).toString()); return strings; } diff --git a/src/main/java/org/violetmoon/quark/content/mobs/ai/BarkAtDarknessGoal.java b/src/main/java/org/violetmoon/quark/content/mobs/ai/BarkAtDarknessGoal.java index 7277c0dacc..e3d23ef50d 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/ai/BarkAtDarknessGoal.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/ai/BarkAtDarknessGoal.java @@ -6,11 +6,10 @@ import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.phys.Vec3; +import org.violetmoon.quark.content.mobs.entity.Shiba; import java.util.EnumSet; -import org.violetmoon.quark.content.mobs.entity.Shiba; - public class BarkAtDarknessGoal extends Goal { private final Shiba shiba; @@ -28,7 +27,7 @@ public void tick() { if(shiba.currentHyperfocus != null) { navigator.moveTo(navigator.createPath(shiba.currentHyperfocus, 1), 1.1); - if(shiba.level instanceof ServerLevel slevel && shiba.tickCount % 10 == 0) { + if(shiba.getCommandSenderWorld() instanceof ServerLevel slevel && shiba.tickCount % 10 == 0) { Vec3 pos = shiba.position(); slevel.sendParticles(ParticleTypes.ANGRY_VILLAGER, pos.x, pos.y + 0.5, pos.z, 1, 0.25F, 0.1F, 0.25F, 0); shiba.lookAt(Anchor.EYES, new Vec3(shiba.currentHyperfocus.getX() + 0.5, shiba.currentHyperfocus.getY(), shiba.currentHyperfocus.getZ() + 0.5)); diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java index adec558299..04edf9e503 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java @@ -40,6 +40,7 @@ import net.minecraft.world.level.material.Material; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.AABB; import net.minecraftforge.common.ToolActions; @@ -268,7 +269,7 @@ public boolean hurt(DamageSource source, float amount) { return super.hurt(source, amount); } - public void dropOre(int ore, LootContext.Builder lootContext) { + public void dropOre(int ore, LootParams.Builder lootContext) { lootContext.withParameter(LootContextParams.ORIGIN, position()); BlockState dropState = null; diff --git a/src/main/java/org/violetmoon/quark/content/tools/entity/rang/AbstractPickarang.java b/src/main/java/org/violetmoon/quark/content/tools/entity/rang/AbstractPickarang.java index 5c876f464f..1d703947f6 100755 --- a/src/main/java/org/violetmoon/quark/content/tools/entity/rang/AbstractPickarang.java +++ b/src/main/java/org/violetmoon/quark/content/tools/entity/rang/AbstractPickarang.java @@ -8,6 +8,7 @@ import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.Tag; import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; @@ -16,7 +17,6 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; -import net.minecraft.world.damagesource.IndirectEntityDamageSource; import net.minecraft.world.effect.MobEffectUtil; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; @@ -35,7 +35,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; @@ -46,16 +46,14 @@ import net.minecraftforge.common.ForgeMod; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.network.NetworkHooks; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import org.violetmoon.quark.base.Quark; import org.violetmoon.quark.base.handler.QuarkSounds; import org.violetmoon.quark.content.mobs.entity.Toretoise; import org.violetmoon.quark.content.tools.config.PickarangType; import org.violetmoon.quark.content.tools.module.PickarangModule; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; import java.util.UUID; @@ -104,7 +102,7 @@ public void shoot(Entity entityThrower, float rotationPitchIn, float rotationYaw float f2 = Mth.cos(rotationYawIn * ((float)Math.PI / 180F)) * Mth.cos(rotationPitchIn * ((float)Math.PI / 180F)); this.shoot(f, f1, f2, velocity, inaccuracy); Vec3 Vector3d = entityThrower.getDeltaMovement(); - this.setDeltaMovement(this.getDeltaMovement().add(Vector3d.x, entityThrower.isOnGround() ? 0.0D : Vector3d.y, Vector3d.z)); + this.setDeltaMovement(this.getDeltaMovement().add(Vector3d.x, entityThrower.onGround() ? 0.0D : Vector3d.y, Vector3d.z)); } @@ -144,7 +142,7 @@ protected void defineSynchedData() { } protected void checkImpact() { - if(level.isClientSide) + if (getCommandSenderWorld().isClientSide) return; Vec3 motion = getDeltaMovement(); @@ -161,7 +159,7 @@ protected void checkImpact() { onHit(result); else doEntities = false; } else { - HitResult result = level.clip(new ClipContext(position, rayEnd, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)); + HitResult result = getCommandSenderWorld().clip(new ClipContext(position, rayEnd, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)); if(result.getType() == Type.MISS) return; @@ -179,7 +177,7 @@ protected void checkImpact() { @Nullable protected EntityHitResult raycastEntities(Vec3 from, Vec3 to) { - return ProjectileUtil.getEntityHitResult(level, this, from, to, getBoundingBox().expandTowards(getDeltaMovement()).inflate(1.0D), (entity) -> + return ProjectileUtil.getEntityHitResult(getCommandSenderWorld(), this, from, to, getBoundingBox().expandTowards(getDeltaMovement()).inflate(1.0D), (entity) -> !entity.isSpectator() && entity.isAlive() && (entity.isPickable() || entity instanceof AbstractPickarang) @@ -197,15 +195,16 @@ protected void onHit(@Nonnull HitResult result) { if(result.getType() == Type.BLOCK && result instanceof BlockHitResult blockHitResult) { BlockPos hit = blockHitResult.getBlockPos(); - BlockState state = level.getBlockState(hit); + BlockState state = getCommandSenderWorld().getBlockState(hit); - if(getPiercingModifier() == 0 || state.getMaterial().isSolidBlocking()) + // TODO find replacement for BlockState#isSolid + if(getPiercingModifier() == 0 || state.isSolid()) addHit(); if(!(owner instanceof ServerPlayer player)) return; //more general way of doing it instead of just checking hardness - float progress = getBlockDestroyProgress(state,player, level, hit); + float progress = getBlockDestroyProgress(state,player, getCommandSenderWorld(), hit); if (progress == 0) return; float equivalentHardness = (1) / (progress * 100); @@ -217,7 +216,7 @@ && canDestroyBlock(state)) { player.setItemInHand(InteractionHand.MAIN_HAND, getStack()); if (player.gameMode.destroyBlock(hit)) - level.levelEvent(null, LevelEvent.PARTICLES_DESTROY_BLOCK, hit, Block.getId(state)); + getCommandSenderWorld().levelEvent(null, LevelEvent.PARTICLES_DESTROY_BLOCK, hit, Block.getId(state)); else clank(); @@ -256,8 +255,8 @@ && canDestroyBlock(state)) { if(ore != 0) { addHit(toretoise); - if (level instanceof ServerLevel serverLevel) { - LootContext.Builder lootBuilder = new LootContext.Builder(serverLevel) + if (getCommandSenderWorld() instanceof ServerLevel serverLevel) { + LootParams.Builder lootBuilder = new LootParams.Builder(serverLevel) .withParameter(LootContextParams.TOOL, pickarang); if (owner instanceof Player player) lootBuilder.withLuck(player.getLuck()); @@ -292,9 +291,10 @@ && canDestroyBlock(state)) { manager.addTransientAttributeModifiers(modifiers); ItemStack stack = getStack(); - stack.hurt(1, level.random, null); + stack.hurt(1, getCommandSenderWorld().random, null); setStack(stack); - hit.hurt(new IndirectEntityDamageSource("player", this, this).setProjectile(), + // FIXME maybe register custom damage source? - IThundxr + hit.hurt(getCommandSenderWorld().damageSources().indirectMagic(this, this), (float) manager.getValue(Attributes.ATTACK_DAMAGE)); } } @@ -411,7 +411,7 @@ public void tick() { float drag; if (this.isInWater()) { for(int i = 0; i < 4; ++i) { - this.level.addParticle(ParticleTypes.BUBBLE, pos.x - ourMotion.x * 0.25D, pos.y - ourMotion.y * 0.25D, pos.z - ourMotion.z * 0.25D, ourMotion.x, ourMotion.y, ourMotion.z); + this.getCommandSenderWorld().addParticle(ParticleTypes.BUBBLE, pos.x - ourMotion.x * 0.25D, pos.y - ourMotion.y * 0.25D, pos.z - ourMotion.z * 0.25D, ourMotion.x, ourMotion.y, ourMotion.z); } drag = 0.8F; @@ -434,7 +434,7 @@ public void tick() { LivingEntity owner = getThrower(); if(owner == null || !owner.isAlive() || !(owner instanceof Player)) { - if(!level.isClientSide) { + if(!getCommandSenderWorld().isClientSide) { while(isInWall()) setPos(getX(), getY() + 1, getZ()); @@ -448,15 +448,15 @@ public void tick() { if(!returning) { if(liveTime > getPickarangType().timeout) setReturning(); - if (!level.getWorldBorder().isWithinBounds(getBoundingBox())) + if (!getCommandSenderWorld().getWorldBorder().isWithinBounds(getBoundingBox())) spark(); } else { noPhysics = true; int eff = getEfficiencyModifier(); - List items = level.getEntitiesOfClass(ItemEntity.class, getBoundingBox().inflate(2)); - List xp = level.getEntitiesOfClass(ExperienceOrb.class, getBoundingBox().inflate(2)); + List items = getCommandSenderWorld().getEntitiesOfClass(ItemEntity.class, getBoundingBox().inflate(2)); + List xp = getCommandSenderWorld().getEntitiesOfClass(ExperienceOrb.class, getBoundingBox().inflate(2)); Vec3 ourPos = position(); for(ItemEntity item : items) { @@ -482,7 +482,7 @@ public void tick() { Inventory inventory = player.getInventory(); ItemStack stackInSlot = inventory.getItem(slot); - if(!level.isClientSide) { + if(!getCommandSenderWorld().isClientSide) { playSound(QuarkSounds.ENTITY_PICKARANG_PICKUP, 1, 1); if(player instanceof ServerPlayer sp && (this instanceof Flamerang) && isOnFire() && getPassengers().size() > 0) @@ -549,8 +549,8 @@ private void giveItemToPlayer(Player player, ItemEntity itemEntity) { @Nullable public LivingEntity getThrower() { - if (this.owner == null && this.ownerId != null && this.level instanceof ServerLevel) { - Entity entity = ((ServerLevel)this.level).getEntity(this.ownerId); + if (this.owner == null && this.ownerId != null && this.getCommandSenderWorld() instanceof ServerLevel) { + Entity entity = ((ServerLevel) this.getCommandSenderWorld()).getEntity(this.ownerId); if (entity instanceof LivingEntity) { this.owner = (LivingEntity)entity; } else { @@ -626,7 +626,7 @@ public void addAdditionalSaveData(@Nonnull CompoundTag compound) { @Nonnull @Override - public Packet getAddEntityPacket() { + public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } diff --git a/src/main/java/org/violetmoon/quark/content/tools/module/AncientTomesModule.java b/src/main/java/org/violetmoon/quark/content/tools/module/AncientTomesModule.java index 19bc77676d..9ac1e44419 100644 --- a/src/main/java/org/violetmoon/quark/content/tools/module/AncientTomesModule.java +++ b/src/main/java/org/violetmoon/quark/content/tools/module/AncientTomesModule.java @@ -6,7 +6,6 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.network.chat.Component; @@ -34,18 +33,14 @@ import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer; import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import org.violetmoon.quark.api.QuarkCapabilities; import org.violetmoon.quark.base.Quark; import org.violetmoon.quark.base.config.Config; import org.violetmoon.quark.base.handler.MiscUtil; -import org.violetmoon.zeta.advancement.ManualTrigger; import org.violetmoon.quark.content.tools.item.AncientTomeItem; import org.violetmoon.quark.content.tools.loot.EnchantTome; import org.violetmoon.quark.content.world.module.MonsterBoxModule; +import org.violetmoon.zeta.advancement.ManualTrigger; import org.violetmoon.zeta.event.bus.LoadEvent; import org.violetmoon.zeta.event.bus.PlayEvent; import org.violetmoon.zeta.event.load.ZCommonSetup; @@ -61,6 +56,8 @@ import org.violetmoon.zeta.module.ZetaModule; import org.violetmoon.zeta.util.Hint; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -303,7 +300,7 @@ public void onAnvilUse(ZAnvilRepair event) { ItemStack right = event.getRight(); if(curseGear && (right.is(ancient_tome) || event.getLeft().is(ancient_tome))){ - event.getOutput().enchant(curses.get(event.getEntity().level.random.nextInt(curses.size())),1); + event.getOutput().enchant(curses.get(event.getEntity().getCommandSenderWorld().random.nextInt(curses.size())),1); } if(isOverlevel(output) && (right.getItem() == Items.ENCHANTED_BOOK || right.getItem() == ancient_tome) && event.getEntity() instanceof ServerPlayer sp) @@ -397,7 +394,7 @@ private static List generateDefaultEnchantmentList() { List strings = new ArrayList<>(); for(Enchantment e : enchants) { - ResourceLocation regname = Registry.ENCHANTMENT.getKey(e); + ResourceLocation regname = BuiltInRegistries.ENCHANTMENT.getKey(e); if(e != null && regname != null) strings.add(regname.toString()); } @@ -414,7 +411,7 @@ private void setupEnchantList() { private final List curses = new ArrayList<>(); public void setupCursesList() { - for (var e : Registry.ENCHANTMENT) { + for (var e : BuiltInRegistries.ENCHANTMENT) { if (e.isCurse()) curses.add(e); } } @@ -427,7 +424,7 @@ public static Enchantment getTomeEnchantment(ItemStack stack) { for(int i = 0; i < list.size(); ++i) { CompoundTag nbt = list.getCompound(i); - Enchantment enchant = Registry.ENCHANTMENT.get(ResourceLocation.tryParse(nbt.getString("id"))); + Enchantment enchant = BuiltInRegistries.ENCHANTMENT.get(ResourceLocation.tryParse(nbt.getString("id"))); if (enchant != null) return enchant; } diff --git a/src/main/java/org/violetmoon/quark/content/tools/module/BottledCloudModule.java b/src/main/java/org/violetmoon/quark/content/tools/module/BottledCloudModule.java index 12a7a587f8..c236f6ece5 100644 --- a/src/main/java/org/violetmoon/quark/content/tools/module/BottledCloudModule.java +++ b/src/main/java/org/violetmoon/quark/content/tools/module/BottledCloudModule.java @@ -1,5 +1,14 @@ package org.violetmoon.quark.content.tools.module; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; import org.violetmoon.quark.base.Quark; import org.violetmoon.quark.base.config.Config; import org.violetmoon.quark.content.tools.block.CloudBlock; @@ -15,16 +24,6 @@ import org.violetmoon.zeta.module.ZetaModule; import org.violetmoon.zeta.util.Hint; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; -import net.minecraft.core.Registry; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.BlockEntityType; - @ZetaLoadModule(category = "tools") public class BottledCloudModule extends ZetaModule { @@ -44,7 +43,7 @@ public final void register(ZRegister event) { bottled_cloud = new BottledCloudItem(this); blockEntityType = BlockEntityType.Builder.of(CloudBlockEntity::new, cloud).build(null); - Quark.ZETA.registry.register(blockEntityType, "cloud", Registry.BLOCK_ENTITY_TYPE_REGISTRY); + Quark.ZETA.registry.register(blockEntityType, "cloud", Registries.BLOCK_ENTITY_TYPE); } @PlayEvent diff --git a/src/main/java/org/violetmoon/quark/content/tweaks/module/BetterElytraRocketModule.java b/src/main/java/org/violetmoon/quark/content/tweaks/module/BetterElytraRocketModule.java index 8e2784ea2d..0f826de5be 100644 --- a/src/main/java/org/violetmoon/quark/content/tweaks/module/BetterElytraRocketModule.java +++ b/src/main/java/org/violetmoon/quark/content/tweaks/module/BetterElytraRocketModule.java @@ -21,7 +21,7 @@ public void onUseRocket(ZRightClickItem event) { Player player = event.getEntity(); ItemStack chest = player.getItemBySlot(EquipmentSlot.CHEST); if(!player.isFallFlying() && zeta.itemExtensions.get(chest).canElytraFlyZeta(chest, player)) { - Level world = player.level; + Level world = player.getCommandSenderWorld(); ItemStack itemstack = event.getItemStack(); if(itemstack.getItem() instanceof FireworkRocketItem) { diff --git a/src/main/java/org/violetmoon/quark/content/tweaks/module/CampfiresBoostElytraModule.java b/src/main/java/org/violetmoon/quark/content/tweaks/module/CampfiresBoostElytraModule.java index 25699f240a..a2f1153072 100644 --- a/src/main/java/org/violetmoon/quark/content/tweaks/module/CampfiresBoostElytraModule.java +++ b/src/main/java/org/violetmoon/quark/content/tweaks/module/CampfiresBoostElytraModule.java @@ -36,7 +36,7 @@ public void onPlayerTick(ZPlayerTick.Start event) { Vec3 motion = player.getDeltaMovement(); if(motion.y() < maxSpeed) { BlockPos pos = player.blockPosition(); - Level world = player.level; + Level world = player.getCommandSenderWorld(); int moves = 0; while(world.isEmptyBlock(pos) && world.isInWorldBounds(pos) && moves < 20) { diff --git a/src/main/java/org/violetmoon/quark/content/world/block/AncientSaplingBlock.java b/src/main/java/org/violetmoon/quark/content/world/block/AncientSaplingBlock.java index 61a24c46c6..b25f8dc25a 100644 --- a/src/main/java/org/violetmoon/quark/content/world/block/AncientSaplingBlock.java +++ b/src/main/java/org/violetmoon/quark/content/world/block/AncientSaplingBlock.java @@ -1,18 +1,11 @@ package org.violetmoon.quark.content.world.block; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.OptionalInt; -import java.util.function.BiConsumer; -import java.util.stream.Collectors; - -import javax.annotation.Nonnull; - import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import net.minecraft.core.BlockPos; -import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.resources.ResourceKey; import net.minecraft.util.RandomSource; import net.minecraft.util.valueproviders.ConstantInt; import net.minecraft.util.valueproviders.UniformInt; @@ -30,10 +23,19 @@ import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacer; import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType; +import org.violetmoon.quark.base.Quark; import org.violetmoon.quark.content.world.module.AncientWoodModule; import org.violetmoon.zeta.block.ZetaSaplingBlock; import org.violetmoon.zeta.module.ZetaModule; +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; + public class AncientSaplingBlock extends ZetaSaplingBlock { public AncientSaplingBlock(ZetaModule module) { @@ -56,11 +58,17 @@ public AncientTree() { .build(); } + ResourceKey> ANCIENT_TREE = ResourceKey.create(Registries.CONFIGURED_FEATURE, Quark.asResource("ancient_tree")); + @Override - protected Holder> getConfiguredFeature(@Nonnull RandomSource rand, boolean hjskfsd) { - return Holder.direct(new ConfiguredFeature<>(Feature.TREE, config)); + protected ResourceKey> getConfiguredFeature(@Nonnull RandomSource rand, boolean hasFlowers) { + return ANCIENT_TREE; } + //fixme find how to call this + public void bootstrap(BootstapContext> context) { + context.register(ANCIENT_TREE, new ConfiguredFeature<>(Feature.TREE, config)); + } } public static class MultiFolliageStraightTrunkPlacer extends TrunkPlacer { diff --git a/src/main/java/org/violetmoon/quark/content/world/block/BlossomLeavesBlock.java b/src/main/java/org/violetmoon/quark/content/world/block/BlossomLeavesBlock.java index 74fd056171..8bf1435dc2 100644 --- a/src/main/java/org/violetmoon/quark/content/world/block/BlossomLeavesBlock.java +++ b/src/main/java/org/violetmoon/quark/content/world/block/BlossomLeavesBlock.java @@ -8,6 +8,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.material.MaterialColor; import org.violetmoon.quark.content.world.module.BlossomTreesModule; import org.violetmoon.zeta.block.ZetaLeavesBlock; @@ -15,7 +16,7 @@ public class BlossomLeavesBlock extends ZetaLeavesBlock { - public BlossomLeavesBlock(String colorName, ZetaModule module, MaterialColor color) { + public BlossomLeavesBlock(String colorName, ZetaModule module, MapColor color) { super(colorName + "_blossom", module, color); } diff --git a/src/main/java/org/violetmoon/quark/content/world/block/BlossomSaplingBlock.java b/src/main/java/org/violetmoon/quark/content/world/block/BlossomSaplingBlock.java index 82b813dbb7..ee8b1e79f9 100644 --- a/src/main/java/org/violetmoon/quark/content/world/block/BlossomSaplingBlock.java +++ b/src/main/java/org/violetmoon/quark/content/world/block/BlossomSaplingBlock.java @@ -47,6 +47,7 @@ public BlossomTree(Block leafBlock) { leaf = leafBlock.defaultBlockState(); } + //fixme tree stuff @Override protected Holder> getConfiguredFeature(@Nonnull RandomSource rand, boolean hjskfsd) { return Holder.direct(new ConfiguredFeature<>(Feature.TREE, config)); diff --git a/src/main/java/org/violetmoon/quark/content/world/gen/BigStoneClusterGenerator.java b/src/main/java/org/violetmoon/quark/content/world/gen/BigStoneClusterGenerator.java index 9f79d1acbb..f963a90e17 100644 --- a/src/main/java/org/violetmoon/quark/content/world/gen/BigStoneClusterGenerator.java +++ b/src/main/java/org/violetmoon/quark/content/world/gen/BigStoneClusterGenerator.java @@ -1,22 +1,20 @@ package org.violetmoon.quark.content.world.gen; -import java.util.Objects; -import java.util.Random; -import java.util.function.BooleanSupplier; - +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.server.level.WorldGenRegion; +import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkGenerator; import org.violetmoon.quark.base.Quark; import org.violetmoon.quark.base.world.generator.multichunk.ClusterBasedGenerator; import org.violetmoon.quark.content.world.config.AirStoneClusterConfig; import org.violetmoon.quark.content.world.config.BigStoneClusterConfig; import org.violetmoon.quark.content.world.module.BigStoneClustersModule; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; -import net.minecraft.server.level.WorldGenRegion; -import net.minecraft.world.level.ServerLevelAccessor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.ChunkGenerator; +import java.util.Objects; +import java.util.Random; +import java.util.function.BooleanSupplier; public class BigStoneClusterGenerator extends ClusterBasedGenerator { @@ -24,7 +22,7 @@ public class BigStoneClusterGenerator extends ClusterBasedGenerator { private final BlockState placeState; public BigStoneClusterGenerator(BigStoneClusterConfig config, BlockState placeState, BooleanSupplier condition) { - super(config.dimensions, () -> config.enabled && condition.getAsBoolean(), config, Objects.toString(Quark.ZETA.registry.getRegistryName(placeState.getBlock(), Registry.BLOCK)).hashCode()); + super(config.dimensions, () -> config.enabled && condition.getAsBoolean(), config, Objects.toString(Quark.ZETA.registry.getRegistryName(placeState.getBlock(), BuiltInRegistries.BLOCK)).hashCode()); this.config = config; this.placeState = placeState; } diff --git a/src/main/java/org/violetmoon/quark/content/world/item/AncientFruitItem.java b/src/main/java/org/violetmoon/quark/content/world/item/AncientFruitItem.java index c2c2b8cd3e..f3f92d9321 100644 --- a/src/main/java/org/violetmoon/quark/content/world/item/AncientFruitItem.java +++ b/src/main/java/org/violetmoon/quark/content/world/item/AncientFruitItem.java @@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -16,7 +17,7 @@ public class AncientFruitItem extends ZetaItem { public AncientFruitItem(ZetaModule module) { - super("ancient_fruit", module, new Item.Properties().tab(CreativeModeTab.TAB_FOOD) + super("ancient_fruit", module, new Item.Properties().tab(CreativeModeTabs.FOOD_AND_DRINKS) .food(new FoodProperties.Builder().nutrition(4).saturationMod(0.3F).alwaysEat().build())); } diff --git a/src/main/java/org/violetmoon/quark/content/world/module/AncientWoodModule.java b/src/main/java/org/violetmoon/quark/content/world/module/AncientWoodModule.java index 9676b2422e..b1eddfcd13 100644 --- a/src/main/java/org/violetmoon/quark/content/world/module/AncientWoodModule.java +++ b/src/main/java/org/violetmoon/quark/content/world/module/AncientWoodModule.java @@ -2,12 +2,11 @@ import com.google.common.base.Functions; import com.google.common.collect.ImmutableSet; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.ComposterBlock; import net.minecraft.world.level.material.MapColor; -import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.storage.loot.BuiltInLootTables; import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer; @@ -72,7 +71,7 @@ public void register(ZRegister event) { ancient_sapling = new AncientSaplingBlock(this); ancient_fruit = new AncientFruitItem(this); - event.getVariantRegistry().addFlowerPot(ancient_sapling, Quark.ZETA.registry.getRegistryName(ancient_sapling, Registry.BLOCK).getPath(), Functions.identity()); + event.getVariantRegistry().addFlowerPot(ancient_sapling, Quark.ZETA.registry.getRegistryName(ancient_sapling, BuiltInRegistries.BLOCK).getPath(), Functions.identity()); event.getAdvancementModifierRegistry().addModifier(new BalancedDietModifier(this, ImmutableSet.of(ancient_fruit)) .setCondition(() -> GeneralConfig.enableAdvancementModification)); diff --git a/src/main/java/org/violetmoon/quark/content/world/module/BigStoneClustersModule.java b/src/main/java/org/violetmoon/quark/content/world/module/BigStoneClustersModule.java index 660fbd589b..0157f7ae1f 100644 --- a/src/main/java/org/violetmoon/quark/content/world/module/BigStoneClustersModule.java +++ b/src/main/java/org/violetmoon/quark/content/world/module/BigStoneClustersModule.java @@ -1,7 +1,7 @@ package org.violetmoon.quark.content.world.module; import com.google.common.collect.Lists; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BiomeTags; import net.minecraft.world.item.Items; @@ -10,11 +10,6 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.levelgen.GenerationStep.Decoration; import net.minecraftforge.common.Tags; - -import java.util.List; -import java.util.function.BiPredicate; -import java.util.function.BooleanSupplier; - import org.violetmoon.quark.base.config.Config; import org.violetmoon.quark.base.config.type.CompoundBiomeConfig; import org.violetmoon.quark.base.config.type.DimensionConfig; @@ -31,6 +26,10 @@ import org.violetmoon.zeta.module.ZetaLoadModule; import org.violetmoon.zeta.module.ZetaModule; +import java.util.List; +import java.util.function.BiPredicate; +import java.util.function.BooleanSupplier; + @ZetaLoadModule(category = "world") public class BigStoneClustersModule extends ZetaModule { @@ -88,7 +87,7 @@ public final void configChanged(ZConfigChanged event) { } String dimFinal = dimension; - Registry.BLOCK.getOptional(new ResourceLocation(bname)).ifPresent(blockObj -> { + BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(bname)).ifPresent(blockObj -> { if(blockObj != Blocks.AIR) { if(dimFinal == null) blockReplacePredicate = blockReplacePredicate.or((w, b) -> blockObj == b); diff --git a/src/main/java/org/violetmoon/quark/content/world/module/BlossomTreesModule.java b/src/main/java/org/violetmoon/quark/content/world/module/BlossomTreesModule.java index 38de294060..4c1c4df000 100644 --- a/src/main/java/org/violetmoon/quark/content/world/module/BlossomTreesModule.java +++ b/src/main/java/org/violetmoon/quark/content/world/module/BlossomTreesModule.java @@ -3,6 +3,8 @@ import java.util.HashMap; import java.util.Map; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.material.MapColor; import org.violetmoon.quark.base.config.Config; import org.violetmoon.quark.base.handler.WoodSetHandler; import org.violetmoon.quark.base.handler.WoodSetHandler.WoodSet; @@ -27,7 +29,7 @@ import net.minecraft.tags.BiomeTags; import net.minecraft.world.level.block.ComposterBlock; import net.minecraft.world.level.levelgen.GenerationStep.Decoration; -import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.material.MapColor; import net.minecraftforge.common.Tags; @ZetaLoadModule(category = "world") @@ -47,13 +49,13 @@ public class BlossomTreesModule extends ZetaModule { @LoadEvent public final void register(ZRegister event) { - woodSet = WoodSetHandler.addWoodSet(event, this, "blossom", MaterialColor.COLOR_RED, MaterialColor.COLOR_BROWN, true); + woodSet = WoodSetHandler.addWoodSet(event, this, "blossom", MapColor.COLOR_RED, MapColor.COLOR_BROWN, true); - add(event, "blue", MaterialColor.COLOR_LIGHT_BLUE, blue); - add(event, "lavender", MaterialColor.COLOR_PINK, lavender); - add(event, "orange", MaterialColor.TERRACOTTA_ORANGE, orange); - add(event, "yellow", MaterialColor.COLOR_YELLOW, yellow); - add(event, "red", MaterialColor.COLOR_RED, red); + add(event, "blue", MapColor.COLOR_LIGHT_BLUE, blue); + add(event, "lavender", MapColor.COLOR_PINK, lavender); + add(event, "orange", MapColor.TERRACOTTA_ORANGE, orange); + add(event, "yellow", MapColor.COLOR_YELLOW, yellow); + add(event, "red", MapColor.COLOR_RED, red); } @LoadEvent @@ -77,11 +79,11 @@ public void addAdditionalHints(ZGatherHints consumer) { consumer.hintItem(tree.sapling.asItem()); } - private void add(ZRegister event, String colorName, MaterialColor color, BlossomTreeConfig config) { + private void add(ZRegister event, String colorName, MapColor color, BlossomTreeConfig config) { BlossomLeavesBlock leaves = new BlossomLeavesBlock(colorName, this, color); BlossomTree tree = new BlossomTree(leaves); BlossomSaplingBlock sapling = new BlossomSaplingBlock(colorName, this, tree); - event.getVariantRegistry().addFlowerPot(sapling, zeta.registry.getRegistryName(sapling, Registry.BLOCK).getPath(), Functions.identity()); + event.getVariantRegistry().addFlowerPot(sapling, zeta.registry.getRegistryName(sapling, BuiltInRegistries.BLOCK).getPath(), Functions.identity()); trees.put(tree, config); } diff --git a/src/main/java/org/violetmoon/quark/mixin/BeehiveBlockEntityMixin.java b/src/main/java/org/violetmoon/quark/mixin/BeehiveBlockEntityMixin.java index 8a21d81880..eff74aead3 100644 --- a/src/main/java/org/violetmoon/quark/mixin/BeehiveBlockEntityMixin.java +++ b/src/main/java/org/violetmoon/quark/mixin/BeehiveBlockEntityMixin.java @@ -22,7 +22,7 @@ private static boolean doNotRemoveUUIDOfBees(CompoundTag instance, String key) { @Inject(method = "setBeeReleaseData", at = @At("HEAD")) private static void rerollUUIDIfNeeded(int ticksInHive, Bee bee, CallbackInfo ci) { - if (bee.level instanceof ServerLevel level) { + if (bee.getCommandSenderWorld() instanceof ServerLevel level) { if (level.getEntities().get(bee.getUUID()) != null) bee.setUUID(Mth.createInsecureUUID(level.random)); } diff --git a/src/main/java/org/violetmoon/zeta/block/ZetaLeavesBlock.java b/src/main/java/org/violetmoon/zeta/block/ZetaLeavesBlock.java index 8ab5b61c1d..237708780a 100644 --- a/src/main/java/org/violetmoon/zeta/block/ZetaLeavesBlock.java +++ b/src/main/java/org/violetmoon/zeta/block/ZetaLeavesBlock.java @@ -1,32 +1,36 @@ package org.violetmoon.zeta.block; -import java.util.function.BooleanSupplier; - -import javax.annotation.Nullable; - import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.level.material.PushReaction; import org.violetmoon.zeta.module.ZetaModule; import org.violetmoon.zeta.registry.RenderLayerRegistry; +import javax.annotation.Nullable; +import java.util.function.BooleanSupplier; + public class ZetaLeavesBlock extends LeavesBlock implements IZetaBlock { private final ZetaModule module; private BooleanSupplier enabledSupplier = () -> true; - public ZetaLeavesBlock(String name, ZetaModule module, MaterialColor color) { - super(Block.Properties.of(Material.LEAVES, color) + public ZetaLeavesBlock(String name, ZetaModule module, MapColor color) { + super(Block.Properties.of() + .mapColor(color) .strength(0.2F) .randomTicks() .sound(SoundType.GRASS) .noOcclusion() .isValidSpawn((s, r, p, t) -> false) .isSuffocating((s, r, p) -> false) - .isViewBlocking((s, r, p) -> false)); + .isViewBlocking((s, r, p) -> false) + .ignitedByLava() + .pushReaction(PushReaction.DESTROY) + .isRedstoneConductor((s, r, p) -> false)); this.module = module; diff --git a/src/main/java/org/violetmoon/zeta/client/config/widget/CategoryButton.java b/src/main/java/org/violetmoon/zeta/client/config/widget/CategoryButton.java index f9d7800712..8de982ebb8 100644 --- a/src/main/java/org/violetmoon/zeta/client/config/widget/CategoryButton.java +++ b/src/main/java/org/violetmoon/zeta/client/config/widget/CategoryButton.java @@ -1,43 +1,41 @@ package org.violetmoon.zeta.client.config.widget; -import java.util.List; - -import javax.annotation.Nonnull; - -import org.violetmoon.zeta.client.ZetaClient; - -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.violetmoon.zeta.client.ZetaClient; -public class CategoryButton extends Button { +import java.util.List; +public class CategoryButton extends Button { private final ZetaClient zc; private final ItemStack icon; private final Component text; public CategoryButton(ZetaClient zc, int x, int y, int w, int h, Component text, ItemStack icon, OnPress onClick) { - super(x, y, w, h, Component.literal(""), onClick); + //fixme make sure this works + //super(x, y, w, h, Component.literal(""), onClick); + super(new Button.Builder(Component.literal(""), onClick).pos(x, y).size(w, h)); this.zc = zc; this.icon = icon; this.text = text; } @Override - public void render(@Nonnull PoseStack mstack, int mouseX, int mouseY, float partialTicks) { - super.render(mstack, mouseX, mouseY, partialTicks); + public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { + super.render(guiGraphics, mouseX, mouseY, partialTicks); if(!active && isHovered) zc.topLayerTooltipHandler.setTooltip(List.of(I18n.get("quark.gui.config.missingaddon")), mouseX, mouseY); Minecraft mc = Minecraft.getInstance(); - mc.getItemRenderer().renderGuiItem(icon, x + 5, y + 2); + guiGraphics.renderFakeItem(icon, getX() + 5, getY() + 2); int iconPad = (16 + 5) / 2; - drawCenteredString(mstack, mc.font, text, x + width / 2 + iconPad, y + (height - 8) / 2, getFGColor()); + guiGraphics.drawCenteredString(mc.font, text, getX() + width / 2 + iconPad, getY() + (height - 8) / 2, getFGColor()); } - } diff --git a/src/main/java/org/violetmoon/zeta/client/config/widget/CheckboxButton.java b/src/main/java/org/violetmoon/zeta/client/config/widget/CheckboxButton.java index 8e97875da0..ace09c2239 100644 --- a/src/main/java/org/violetmoon/zeta/client/config/widget/CheckboxButton.java +++ b/src/main/java/org/violetmoon/zeta/client/config/widget/CheckboxButton.java @@ -1,20 +1,17 @@ package org.violetmoon.zeta.client.config.widget; -import javax.annotation.Nonnull; - -import org.violetmoon.zeta.client.ZetaClient; -import org.violetmoon.zeta.config.ChangeSet; -import org.violetmoon.zeta.config.ValueDefinition; - import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import org.violetmoon.zeta.client.ZetaClient; +import org.violetmoon.zeta.config.ChangeSet; +import org.violetmoon.zeta.config.ValueDefinition; public class CheckboxButton extends Button { - //checked: u0 v0 to u16 v16 //unchecked: u16 v0 to u32 v16 private final ResourceLocation iconsTexture; @@ -22,7 +19,9 @@ public class CheckboxButton extends Button { private final ChangeSet changes; public CheckboxButton(ResourceLocation iconsTexture, int x, int y, ChangeSet changes, ValueDefinition value) { - super(x, y, 20, 20, Component.literal(""), CheckboxButton::toggle); + //fixme make sure this is correct + //super(x, y, 20, 20, Component.literal(""), CheckboxButton::toggle); + super(new Button.Builder(Component.literal(""), CheckboxButton::toggle).pos(x, y).size(20, 20)); this.iconsTexture = iconsTexture; this.value = value; this.changes = changes; @@ -39,17 +38,15 @@ private static void toggle(Button press) { } @Override - public void renderButton(@Nonnull PoseStack mstack, int mouseX, int mouseY, float partial) { - super.renderButton(mstack, mouseX, mouseY, partial); + protected void renderWidget(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partial) { + super.renderWidget(guiGraphics, mouseX, mouseY, partial); RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.setShaderTexture(0, iconsTexture); boolean enabled = changes.get(value) && active; int u = enabled ? 0 : 16; int v = 0; - blit(mstack, x + 2, y + 1, u, v, 15, 15); + guiGraphics.blit(iconsTexture, getX() + 2, getY() + 1, u, v, 15, 15); } - } diff --git a/src/main/java/org/violetmoon/zeta/registry/BrewingRegistry.java b/src/main/java/org/violetmoon/zeta/registry/BrewingRegistry.java index 87cd2378cf..c1e2f4eab6 100644 --- a/src/main/java/org/violetmoon/zeta/registry/BrewingRegistry.java +++ b/src/main/java/org/violetmoon/zeta/registry/BrewingRegistry.java @@ -1,7 +1,8 @@ package org.violetmoon.zeta.registry; import com.google.common.collect.Maps; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; @@ -9,12 +10,10 @@ import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.item.crafting.Ingredient; - -import javax.annotation.Nullable; - import org.violetmoon.zeta.Zeta; import org.violetmoon.zeta.recipe.FlagIngredient; +import javax.annotation.Nullable; import java.util.Map; import java.util.function.Supplier; @@ -47,7 +46,7 @@ public void addPotionMix(String flag, Supplier reagent, MobEffect ef public void addPotionMix(String flag, Supplier reagent, MobEffect effect, @Nullable MobEffect negation, int normalTime, int longTime, int strongTime) { - ResourceLocation loc = zeta.registry.getRegistryName(effect, Registry.MOB_EFFECT); + ResourceLocation loc = zeta.registry.getRegistryName(effect, BuiltInRegistries.MOB_EFFECT); if (loc != null) { String baseName = loc.getPath(); @@ -60,7 +59,7 @@ public void addPotionMix(String flag, Supplier reagent, MobEffect ef addPotionMix(flag, reagent, normalType, longType, strongType); if (negation != null) { - ResourceLocation negationLoc = zeta.registry.getRegistryName(negation, Registry.MOB_EFFECT); + ResourceLocation negationLoc = zeta.registry.getRegistryName(negation, BuiltInRegistries.MOB_EFFECT); if (negationLoc != null) { String negationBaseName = negationLoc.getPath(); @@ -117,7 +116,7 @@ protected void addFlaggedRecipe(String flag, Potion potion, Supplier protected Potion registerPotion(MobEffectInstance eff, String baseName, String name) { Potion effect = new Potion(zeta.modid + "." + baseName, eff); - zeta.registry.register(effect, name, Registry.POTION_REGISTRY); + zeta.registry.register(effect, name, Registries.POTION); return effect; }