diff --git a/build.properties b/build.properties index 325935e9..bd9787bf 100644 --- a/build.properties +++ b/build.properties @@ -3,7 +3,7 @@ mapping_channel=parchment mod_id=psi forge_version=43.3.0 jei_version=11.6.0.1013 -build_number=101 +build_number=102 patchy_version=1.19.2-77 dir_output=../Build Output/Psi/ version=1.19 diff --git a/src/main/java/vazkii/psi/api/PsiAPI.java b/src/main/java/vazkii/psi/api/PsiAPI.java index 93d58ff8..46555b9e 100644 --- a/src/main/java/vazkii/psi/api/PsiAPI.java +++ b/src/main/java/vazkii/psi/api/PsiAPI.java @@ -17,10 +17,15 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; +import net.minecraft.tags.BlockTags; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.Tiers; import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.common.ForgeTier; +import net.minecraftforge.common.TierSortingRegistry; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.CapabilityToken; @@ -35,14 +40,15 @@ import vazkii.psi.api.internal.DummyMethodHandler; import vazkii.psi.api.internal.IInternalMethodHandler; import vazkii.psi.api.material.PsimetalArmorMaterial; -import vazkii.psi.api.material.PsimetalToolMaterial; import vazkii.psi.api.spell.ISpellAcceptor; import vazkii.psi.api.spell.ISpellImmune; import vazkii.psi.api.spell.SpellPiece; import vazkii.psi.api.spell.detonator.IDetonationHandler; +import vazkii.psi.common.item.base.ModItems; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -81,7 +87,11 @@ public final class PsiAPI { public static final PsimetalArmorMaterial PSIMETAL_ARMOR_MATERIAL = new PsimetalArmorMaterial("psimetal", 18, new int[] { 2, 5, 6, 2 }, 12, SoundEvents.ARMOR_EQUIP_IRON, 0F, () -> Ingredient.of(Registry.ITEM.get(new ResourceLocation(MOD_ID, "psimetal"))), 0.0f); - public static final PsimetalToolMaterial PSIMETAL_TOOL_MATERIAL = new PsimetalToolMaterial(); + public static final Tier PSIMETAL_TOOL_MATERIAL = TierSortingRegistry.registerTier( + new ForgeTier(3, 900, 7.8F, 2F, 12, BlockTags.NEEDS_DIAMOND_TOOL, () -> Ingredient.of(ModItems.psimetal)), + new ResourceLocation(MOD_ID, "psimetal_tier"), + List.of(Tiers.DIAMOND), List.of(Tiers.NETHERITE)); + /** * Registers a Spell Piece. diff --git a/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java b/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java deleted file mode 100644 index a7f4cf10..00000000 --- a/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This class is distributed as part of the Psi Mod. - * Get the Source Code in github: - * https://github.com/Vazkii/Psi - * - * Psi is Open Source and distributed under the - * Psi License: https://psi.vazkii.net/license.php - */ -package vazkii.psi.api.material; - -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.LazyLoadedValue; -import net.minecraft.world.item.Tier; -import net.minecraft.world.item.crafting.Ingredient; - -import vazkii.psi.api.PsiAPI; - -public class PsimetalToolMaterial implements Tier { - private static final LazyLoadedValue REPAIR_MATERIAL = new LazyLoadedValue<>( - () -> Ingredient.of(Registry.ITEM.get(new ResourceLocation(PsiAPI.MOD_ID, "psimetal")))); - - @Override - public int getUses() { - return 900; - } - - @Override - public float getSpeed() { - return 7.8F; - } - - @Override - public float getAttackDamageBonus() { - return 2F; - } - - @Override - public int getLevel() { - return 3; - } - - @Override - public int getEnchantmentValue() { - return 12; - } - - @Override - public Ingredient getRepairIngredient() { - return REPAIR_MATERIAL.get(); - } -} diff --git a/src/main/java/vazkii/psi/client/gui/widget/PiecePanelWidget.java b/src/main/java/vazkii/psi/client/gui/widget/PiecePanelWidget.java index df7318c9..6c73ebe0 100644 --- a/src/main/java/vazkii/psi/client/gui/widget/PiecePanelWidget.java +++ b/src/main/java/vazkii/psi/client/gui/widget/PiecePanelWidget.java @@ -134,7 +134,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { } public int getPageCount() { - return (visibleButtons.size() / PIECES_PER_PAGE) + 1; + return (int) Math.ceil((float) visibleButtons.size() / PIECES_PER_PAGE); } public void populatePanelButtons() { diff --git a/src/main/java/vazkii/psi/common/block/tile/TileCADAssembler.java b/src/main/java/vazkii/psi/common/block/tile/TileCADAssembler.java index df7163e5..6bd93f1b 100644 --- a/src/main/java/vazkii/psi/common/block/tile/TileCADAssembler.java +++ b/src/main/java/vazkii/psi/common/block/tile/TileCADAssembler.java @@ -59,31 +59,8 @@ public class TileCADAssembler extends BlockEntity implements ITileCADAssembler, @ObjectHolder(registryName = "minecraft:block_entity_type", value = LibMisc.PREFIX_MOD + LibBlockNames.CAD_ASSEMBLER) public static BlockEntityType TYPE; - private final IItemHandlerModifiable inventory = new ItemStackHandler(6) { - @Override - protected void onContentsChanged(int slot) { - super.onContentsChanged(slot); - if(0 < slot && slot < 6) { - clearCachedCAD(); - } - } + private final CADStackHandler inventory = new CADStackHandler(6); - @Override - public boolean isItemValid(int slot, @Nonnull ItemStack stack) { - if(stack.isEmpty()) { - return true; - } - - if(slot == 0) { - return ISocketable.isSocketable(stack); - } else if(slot < 6) { - return stack.getItem() instanceof ICADComponent && - ((ICADComponent) stack.getItem()).getComponentType(stack) == EnumCADComponent.values()[slot - 1]; - } - - return false; - } - }; private final IItemHandler publicInv = new IItemHandler() { @Override public int getSlots() { @@ -237,11 +214,7 @@ public boolean isBulletSlotEnabled(int slot) { @Override protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); - NonNullList items = NonNullList.withSize(inventory.getSlots(), ItemStack.EMPTY); - for(int i = 0; i < inventory.getSlots(); i++) { - items.set(i, inventory.getStackInSlot(i)); - } - ContainerHelper.saveAllItems(tag, items); + ContainerHelper.saveAllItems(tag, inventory.getItems()); } @Override @@ -250,10 +223,13 @@ public void load(CompoundTag cmp) { readPacketNBT(cmp); } + + public void readPacketNBT(@Nonnull CompoundTag tag) { // Migrate old CAD assemblers to the new format - if(tag.getInt("version") < 1) { - ListTag items = tag.getList("Items", 10); + ListTag items = tag.getList("Items", 10); + if(items.size() == 19) { + for(int i = 0; i < inventory.getSlots(); i++) { inventory.setStackInSlot(i, ItemStack.EMPTY); } @@ -295,7 +271,7 @@ public void readPacketNBT(@Nonnull CompoundTag tag) { } } } else { - //CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(inventory, null, tag.getList("Items", Tag.TAG_COMPOUND)); //TODO Fix this but we need answers + ContainerHelper.loadAllItems(tag, inventory.getItems()); } } @@ -324,4 +300,45 @@ public Component getDisplayName() { public AbstractContainerMenu createMenu(int i, Inventory playerInventory, Player playerEntity) { return new ContainerCADAssembler(i, playerInventory, this); } + + private class CADStackHandler extends ItemStackHandler { + + + private CADStackHandler(int size) { + super(size); + } + + private NonNullList getItems() { + return this.stacks; + } + + private void setItems(NonNullList pItems) { + this.stacks = pItems; + } + + @Override + protected void onContentsChanged(int slot) { + super.onContentsChanged(slot); + if (0 < slot && slot < 6) { + clearCachedCAD(); + } + setChanged(); + } + + @Override + public boolean isItemValid(int slot, @Nonnull ItemStack stack) { + if (stack.isEmpty()) { + return true; + } + + if (slot == 0) { + return ISocketable.isSocketable(stack); + } else if (slot < 6) { + return stack.getItem() instanceof ICADComponent && + ((ICADComponent) stack.getItem()).getComponentType(stack).ordinal() == slot - 1; + } + + return false; + } + } } diff --git a/src/main/java/vazkii/psi/common/block/tile/container/ContainerCADAssembler.java b/src/main/java/vazkii/psi/common/block/tile/container/ContainerCADAssembler.java index 546eac7f..68426e98 100644 --- a/src/main/java/vazkii/psi/common/block/tile/container/ContainerCADAssembler.java +++ b/src/main/java/vazkii/psi/common/block/tile/container/ContainerCADAssembler.java @@ -214,6 +214,7 @@ public ItemStack quickMoveStack(Player playerIn, int from) { @Override public void removed(Player playerIn) { + super.removed(playerIn); assembler.clearCachedCAD(); } } diff --git a/src/main/java/vazkii/psi/common/core/handler/AdditiveMotionHandler.java b/src/main/java/vazkii/psi/common/core/handler/AdditiveMotionHandler.java index 89f5649e..95f141de 100644 --- a/src/main/java/vazkii/psi/common/core/handler/AdditiveMotionHandler.java +++ b/src/main/java/vazkii/psi/common/core/handler/AdditiveMotionHandler.java @@ -50,6 +50,7 @@ public static void onPlayerTick(TickEvent.LevelTickEvent e) { //Otherwise it feels jerky. if(entity instanceof ServerPlayer) { MessageRegister.sendToPlayer(motion, (ServerPlayer) entity); + ((ServerPlayer) entity).connection.aboveGroundTickCount = -80; //Improve "Kicked for Flying" } else { entity.push(vec.x, vec.y, vec.z); } diff --git a/src/main/java/vazkii/psi/common/core/handler/ContributorSpellCircleHandler.java b/src/main/java/vazkii/psi/common/core/handler/ContributorSpellCircleHandler.java index 5a9869de..e352ca18 100644 --- a/src/main/java/vazkii/psi/common/core/handler/ContributorSpellCircleHandler.java +++ b/src/main/java/vazkii/psi/common/core/handler/ContributorSpellCircleHandler.java @@ -69,7 +69,7 @@ public static boolean isContributor(String name) { @SubscribeEvent public static void onCadTake(CADTakeEvent event) { - if(ContributorSpellCircleHandler.isContributor(event.getPlayer().getName().getString().toLowerCase(Locale.ROOT)) && !((ICAD) event.getCad().getItem()).getComponentInSlot(event.getCad(), EnumCADComponent.DYE).isEmpty()) { + if(ContributorSpellCircleHandler.isContributor(event.getPlayer().getName().getString().toLowerCase(Locale.ROOT)) && !event.getCad().isEmpty() && !((ICAD) event.getCad().getItem()).getComponentInSlot(event.getCad(), EnumCADComponent.DYE).isEmpty()) { ItemStack dyeStack = ((ICAD) event.getCad().getItem()).getComponentInSlot(event.getCad(), EnumCADComponent.DYE); ((ICADColorizer) dyeStack.getItem()).setContributorName(dyeStack, event.getPlayer().getName().getString()); ItemCAD.setComponent(event.getCad(), dyeStack); diff --git a/src/main/java/vazkii/psi/common/item/ItemVectorRuler.java b/src/main/java/vazkii/psi/common/item/ItemVectorRuler.java index 2ad493ee..e51001bb 100644 --- a/src/main/java/vazkii/psi/common/item/ItemVectorRuler.java +++ b/src/main/java/vazkii/psi/common/item/ItemVectorRuler.java @@ -50,13 +50,12 @@ public InteractionResult useOn(UseOnContext ctx) { BlockPos pos = ctx.getClickedPos(); ItemStack stack = ctx.getPlayer().getItemInHand(ctx.getHand()); - int srcY = stack.getOrCreateTag().contains(TAG_SRC_Y) ? stack.getOrCreateTag().getInt(TAG_SRC_Y) : -1; - if(srcY == -1 || ctx.getPlayer().isShiftKeyDown()) { + if(!stack.getOrCreateTag().contains(TAG_SRC_Y) || ctx.getPlayer().isShiftKeyDown()) { stack.getOrCreateTag().putInt(TAG_SRC_X, pos.getX()); stack.getOrCreateTag().putInt(TAG_SRC_Y, pos.getY()); stack.getOrCreateTag().putInt(TAG_SRC_Z, pos.getZ()); - stack.getOrCreateTag().putInt(TAG_DST_Y, -1); + stack.removeTagKey(TAG_DST_Y); } else { stack.getOrCreateTag().putInt(TAG_DST_X, pos.getX()); stack.getOrCreateTag().putInt(TAG_DST_Y, pos.getY()); @@ -77,12 +76,12 @@ public Vector3 getVector(ItemStack stack) { int srcY = stack.getOrCreateTag().getInt(TAG_SRC_Y); int srcZ = stack.getOrCreateTag().getInt(TAG_SRC_Z); - int dstY = stack.getOrCreateTag().contains(TAG_DST_Y) ? stack.getOrCreateTag().getInt(TAG_DST_Y) : -1; - if(dstY == -1) { + if(!stack.getOrCreateTag().contains(TAG_DST_Y)) { return new Vector3(srcX, srcY, srcZ); } int dstX = stack.getOrCreateTag().getInt(TAG_DST_X); + int dstY = stack.getOrCreateTag().getInt(TAG_DST_Y); int dstZ = stack.getOrCreateTag().getInt(TAG_DST_Z); return new Vector3(dstX - srcX, dstY - srcY, dstZ - srcZ); diff --git a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalArmor.java b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalArmor.java index 885eb9a5..cf50f0fb 100644 --- a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalArmor.java +++ b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalArmor.java @@ -180,6 +180,9 @@ public int getColor(@Nonnull ItemStack stack) { return ICADColorizer.DEFAULT_SPELL_COLOR; } + public void setColor(ItemStack stack, int color) { + } + @Override public void initializeClient(Consumer consumer) { consumer.accept(new IClientItemExtensions() { diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index a0350e4c..9971b66f 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -24,4 +24,5 @@ public net.minecraft.client.gui.Gui f_92986_ # minecraft public net.minecraft.client.gui.components.ChatComponent m_93787_(Lnet/minecraft/network/chat/Component;I)V # addMessage public net.minecraft.client.gui.components.ChatComponent m_93803_(I)V # removeById public net.minecraft.client.renderer.RenderType$CompositeRenderType -public net.minecraft.client.renderer.RenderStateShard f_173101_ # POSITION_COLOR_TEX_SHADER \ No newline at end of file +public net.minecraft.client.renderer.RenderStateShard f_173101_ # POSITION_COLOR_TEX_SHADER +public net.minecraft.server.network.ServerGamePacketListenerImpl f_9737_ # floatingTickCount \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 479cba0f..ec8f8ca4 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -4,23 +4,30 @@ issueTrackerURL="https://github.com/Vazkii/Psi" license="https://psi.vazkii.net/license.php" [[mods]] -modId="psi" -displayName="Psi" -version="2.0.0" -authors="Vazkii, Wiiv, WireSegal, Kamefrede, Williewillus, Hubry, Dudblockman" -description=''' -Psionic Spellcasting Instruments -''' + modId="psi" + displayName="Psi" + version="2.0.0" + authors="Vazkii, Wiiv, WireSegal, Kamefrede, Williewillus, Hubry, Dudblockman" + description=''' + Psionic Spellcasting Instruments + ''' + [[dependencies.psi]] modId="patchouli" mandatory=true versionRange="[1.19.2-77,)" side="BOTH" - [[dependencies.psi]] modId="forge" mandatory=true - versionRange="[42.2.0,)" + versionRange="[43.3.0,)" ordering="AFTER" + side="BOTH" + +[[dependencies.psi]] + modId="minecraft" + mandatory=true + versionRange="[1.19,1.19.2]" + ordering="NONE" side="BOTH" \ No newline at end of file