Skip to content

Commit

Permalink
A PR a day keeps the bugs away
Browse files Browse the repository at this point in the history
Signed-off-by: cph101 <[email protected]>
  • Loading branch information
cph101 committed Sep 30, 2024
1 parent 5d542da commit 4a43931
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 227 deletions.
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ dependencies {
runtimeOnly(("mezz.jei:jei-${property("minecraft_version")}-neoforge:${property("jei_version")}"))

// Curios dependency
compileOnly(("top.theillusivec4.curios:curios-neoforge:${property("curios_version")}:api"))
runtimeOnly(("top.theillusivec4.curios:curios-neoforge:${property("curios_version")}"))
implementation(("top.theillusivec4.curios:curios-neoforge:${property("curios_version")}"))

implementation(("team.lodestar.lodestone:lodestone:${property("minecraft_version")}-${property("lodestone_version")}"))

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ mod_authors=Sammy Semicolon
mod_description=A dark magic mod focused on soul and spirit magic.
lodestone_version=1.7.0.71
jei_version=19.18.3.204
curios_version=9.0.9+1.21
curios_version=9.0.12+1.21
fusion_version=1.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import net.minecraft.util.*;
import net.minecraft.world.item.*;
import net.minecraft.world.item.crafting.*;
import net.neoforged.neoforge.common.crafting.ICustomIngredient;
import org.joml.*;
import org.lwjgl.opengl.*;
import team.lodestar.lodestone.registry.client.*;
import team.lodestar.lodestone.systems.easing.*;
import team.lodestar.lodestone.systems.recipe.*;
import team.lodestar.lodestone.systems.rendering.*;
import team.lodestar.lodestone.systems.rendering.shader.*;

Expand Down Expand Up @@ -64,7 +64,7 @@ public static <T extends AbstractProgressionCodexScreen> void renderTransitionFa
shaderInstance.safeGetUniform("Speed").set(1000f);
Consumer<Float> setZoom = f -> shaderInstance.safeGetUniform("Zoom").set(f);
Consumer<Float> setIntensity = f -> shaderInstance.safeGetUniform("Intensity").set(f);
builder.setPosColorTexDefaultFormat().setAlpha(effectAlpha).setShader(ShaderRegistry.TOUCH_OF_DARKNESS.getInstance());
builder.setPosTexColorDefaultFormat().setAlpha(effectAlpha).setShader(ShaderRegistry.TOUCH_OF_DARKNESS.getInstance());

setZoom.accept(zoom);
setIntensity.accept(intensity);
Expand Down Expand Up @@ -93,7 +93,7 @@ public static void renderRiteIcon(ResourceLocation texture, MalumSpiritType spir
}

public static void renderRiteIcon(ResourceLocation texture, MalumSpiritType spiritType, PoseStack stack, boolean corrupted, float glowAlpha, int x, int y, int z) {
ExtendedShaderInstance shaderInstance = (ExtendedShaderInstance) LodestoneShaderRegistry.DISTORTED_TEXTURE.getInstance().get();
ExtendedShaderInstance shaderInstance = (ExtendedShaderInstance) LodestoneShaders.DISTORTED_TEXTURE.getInstance().get();
shaderInstance.safeGetUniform("YFrequency").set(corrupted ? 5f : 11f);
shaderInstance.safeGetUniform("XFrequency").set(corrupted ? 12f : 17f);
shaderInstance.safeGetUniform("Speed").set(2000f * (corrupted ? -0.75f : 1));
Expand Down Expand Up @@ -129,7 +129,7 @@ public static void renderWavyIcon(ResourceLocation location, PoseStack stack, in
renderWavyIcon(location, stack, x, y, 0, 16, 16);
}
public static void renderWavyIcon(ResourceLocation location, PoseStack stack, int x, int y, int z, int textureWidth, int textureHeight) {
ExtendedShaderInstance shaderInstance = (ExtendedShaderInstance) LodestoneShaderRegistry.DISTORTED_TEXTURE.getInstance().get();
ExtendedShaderInstance shaderInstance = (ExtendedShaderInstance) LodestoneShaders.DISTORTED_TEXTURE.getInstance().get();
shaderInstance.safeGetUniform("YFrequency").set(10f);
shaderInstance.safeGetUniform("XFrequency").set(12f);
shaderInstance.safeGetUniform("Speed").set(1000f);
Expand Down Expand Up @@ -195,18 +195,21 @@ public static void renderTexture(ResourceLocation texture, PoseStack poseStack,
RenderSystem.disableBlend();
}

public static void renderComponents(AbstractMalumScreen screen, GuiGraphics guiGraphics, List<? extends IRecipeComponent> components, int left, int top, int mouseX, int mouseY, boolean vertical) {
List<ItemStack> items = components.stream().map(IRecipeComponent::getStack).collect(Collectors.toList());
public static void renderComponents(AbstractMalumScreen screen, GuiGraphics guiGraphics, List<Ingredient> components, int left, int top, int mouseX, int mouseY, boolean vertical) {
List<ItemStack> items = components.stream().flatMap(i -> Arrays.stream(i.getItems())).collect(Collectors.toList());
renderItemList(screen, guiGraphics, items, left, top, mouseX, mouseY, vertical).run();
}

public static Runnable renderBufferedComponents(AbstractMalumScreen screen, GuiGraphics guiGraphics, List<? extends IRecipeComponent> components, int left, int top, int mouseX, int mouseY, boolean vertical) {
List<ItemStack> items = components.stream().map(IRecipeComponent::getStack).collect(Collectors.toList());
public static Runnable renderBufferedComponents(AbstractMalumScreen screen, GuiGraphics guiGraphics, List<Ingredient> components, int left, int top, int mouseX, int mouseY, boolean vertical) {
List<ItemStack> items = components.stream().flatMap(i -> Arrays.stream(i.getItems())).collect(Collectors.toList());
return renderItemList(screen, guiGraphics, items, left, top, mouseX, mouseY, vertical);
}

public static void renderComponent(AbstractMalumScreen screen, GuiGraphics guiGraphics, IRecipeComponent component, int posX, int posY, int mouseX, int mouseY) {
renderItem(screen, guiGraphics, component.getStacks(), posX, posY, mouseX, mouseY);
public static void renderComponent(AbstractMalumScreen screen, GuiGraphics guiGraphics, Ingredient component, int posX, int posY, int mouseX, int mouseY) {
switch (component.getItems().length) {
case 1 -> renderItem(screen, guiGraphics, component.getItems()[0], posX, posY, mouseX, mouseY);
default -> renderItemList(screen, guiGraphics, List.of(component.getItems()), posX, posY, mouseX, mouseY, true).run();
}
}

public static void renderItem(AbstractMalumScreen screen, GuiGraphics guiGraphics, Ingredient ingredient, int posX, int posY, int mouseX, int mouseY) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
import com.sammy.malum.client.screen.codex.pages.*;
import com.sammy.malum.client.screen.codex.screens.*;
import com.sammy.malum.common.recipe.*;
import com.sammy.malum.core.systems.recipe.LodestoneRecipeType;
import com.sammy.malum.core.systems.recipe.SpiritIngredient;
import com.sammy.malum.registry.common.recipe.RecipeTypeRegistry;
import net.minecraft.client.*;
import net.minecraft.client.gui.*;
import net.minecraft.util.*;
import net.minecraft.world.item.*;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.SingleRecipeInput;
import net.neoforged.neoforge.common.crafting.ICustomIngredient;

import java.util.*;
import java.util.function.*;
Expand All @@ -18,14 +25,12 @@
public class SpiritRepairPage extends BookPage {
private final SpiritRepairRecipe recipe;

public SpiritRepairPage(Predicate<SpiritRepairRecipe> predicate) {
public SpiritRepairPage(Predicate<Recipe<SingleRecipeInput>> predicate) {
super(MalumMod.malumPath("textures/gui/book/pages/spirit_repair_page.png"));
if (Minecraft.getInstance() == null) //this is null during datagen
{
this.recipe = null;
return;
}
this.recipe = SpiritRepairRecipe.getRecipe(Minecraft.getInstance().level, predicate);
//this is null during datagen
if (Minecraft.getInstance() instanceof Minecraft mcInstance) {
this.recipe = LodestoneRecipeType.findRecipe(mcInstance.level, RecipeTypeRegistry.SPIRIT_REPAIR.get(), predicate);
} else this.recipe = null;
}

public SpiritRepairPage(SpiritRepairRecipe recipe) {
Expand All @@ -39,17 +44,16 @@ public boolean isValid() {
}

public static SpiritRepairPage fromInput(Item inputItem) {
return new SpiritRepairPage(s -> s.doesInputMatch(inputItem.getDefaultInstance()));
return new SpiritRepairPage(s -> s.matches(new SingleRecipeInput(inputItem.getDefaultInstance()), null));
}

@Override
public void render(EntryScreen screen, GuiGraphics guiGraphics, int left, int top, int mouseX, int mouseY, float partialTicks, boolean isRepeat) {
renderComponents(screen, guiGraphics, recipe.spirits, left + 63, top + 16, mouseX, mouseY, false);
renderComponents(screen, guiGraphics, recipe.spirits.stream().map(ICustomIngredient::toVanilla).toList(), left + 63, top + 16, mouseX, mouseY, false);
final List<ItemStack> damaged = recipe.inputs.stream().map(Item::getDefaultInstance).peek(s -> s.setDamageValue(Mth.floor(s.getMaxDamage() * recipe.durabilityPercentage))).collect(Collectors.toList());
final List<ItemStack> repaired = recipe.inputs.stream().map(s -> SpiritRepairRecipe.getRepairRecipeOutput(s.getDefaultInstance())).collect(Collectors.toList());
final List<ItemStack> repaired = recipe.inputs.stream().map(Item::getDefaultInstance).collect(Collectors.toList());
renderItem(screen, guiGraphics, damaged, left + 82, top + 59, mouseX, mouseY);
renderComponent(screen, guiGraphics, recipe.repairMaterial, left + 44, top + 59, mouseX, mouseY);
renderComponent(screen, guiGraphics, recipe.repairMaterial.ingredient(), left + 44, top + 59, mouseX, mouseY);
renderItem(screen, guiGraphics, repaired, left + 63, top + 126, mouseX, mouseY);

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sammy.malum.common.block.curiosities.repair_pylon;

import com.sammy.malum.MalumMod;
import com.sammy.malum.common.block.*;
import com.sammy.malum.common.block.storage.*;
import com.sammy.malum.common.item.spirit.*;
Expand All @@ -12,13 +13,15 @@
import com.sammy.malum.visual_effects.networked.pylon.*;
import net.minecraft.core.*;
import net.minecraft.nbt.*;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.*;
import net.minecraft.world.*;
import net.minecraft.world.entity.player.*;
import net.minecraft.world.item.*;
import net.minecraft.world.level.block.entity.*;
import net.minecraft.world.level.block.state.*;
import net.minecraft.world.phys.*;
import net.neoforged.neoforge.capabilities.IBlockCapabilityProvider;
import net.neoforged.neoforge.items.IItemHandler;
import net.neoforged.neoforge.items.wrapper.CombinedInvWrapper;
import org.jetbrains.annotations.*;
Expand All @@ -32,7 +35,7 @@
import java.util.*;
import java.util.function.*;

public class RepairPylonCoreBlockEntity extends MultiBlockCoreEntity {
public class RepairPylonCoreBlockEntity extends MultiBlockCoreEntity implements IBlockCapabilityProvider<IItemHandler, Direction> {

private static final Vec3 PYLON_ITEM_OFFSET = new Vec3(0.5f, 2.5f, 0.5f);
private static final int HORIZONTAL_RANGE = 6;
Expand Down Expand Up @@ -72,7 +75,7 @@ public String getSerializedName() {
public float spiritAmount;
public float spiritSpin;

private final LazyOptional<IItemHandler> combinedInventory = LazyOptional.of(() -> new CombinedInvWrapper(inventory, spiritInventory));
private final Supplier<IItemHandler> combinedInventory = () -> new CombinedInvWrapper(inventory, spiritInventory);

public RepairPylonCoreBlockEntity(BlockEntityType<? extends RepairPylonCoreBlockEntity> type, MultiBlockStructure structure, BlockPos pos, BlockState state) {
super(type, structure, pos, state);
Expand Down Expand Up @@ -143,28 +146,23 @@ public void loadAdditional(CompoundTag compound, HolderLookup.Provider pRegistri
}

@Override
public InteractionResult onUse(Player player, InteractionHand hand) {
public ItemInteractionResult onUseWithItem(Player player, ItemStack stack, InteractionHand hand) {
if (level.isClientSide) {
return InteractionResult.CONSUME;
return ItemInteractionResult.CONSUME;
}
if (hand.equals(InteractionHand.MAIN_HAND)) {
ItemStack heldStack = player.getMainHandItem();
final boolean isEmpty = heldStack.isEmpty();
ItemStack spiritStack = spiritInventory.interact(level, player, hand);
if (!spiritStack.isEmpty()) {
return InteractionResult.SUCCESS;
return ItemInteractionResult.SUCCESS;
}
if (!(heldStack.getItem() instanceof SpiritShardItem)) {
ItemStack stack = inventory.interact(level, player, hand);
if (!stack.isEmpty()) {
return InteractionResult.SUCCESS;
ItemStack finishedStack = inventory.interact(level, player, hand);
if (!finishedStack.isEmpty()) {
return ItemInteractionResult.SUCCESS;
}
}
if (isEmpty) {
return InteractionResult.SUCCESS;
} else {
return InteractionResult.FAIL;
}
return ItemInteractionResult.FAIL;
}
return super.onUse(player, hand);
}
Expand Down Expand Up @@ -282,20 +280,21 @@ public boolean tryRepair() {

public boolean tryRepair(IMalumSpecialItemAccessPoint provider) {
LodestoneBlockEntityInventory inventoryForAltar = provider.getSuppliedInventory();
SpiritRepairRecipe newRecipe = SpiritRepairRecipe.getRecipe(level, inventoryForAltar.getStackInSlot(0), inventory.getStackInSlot(0), spiritInventory.nonEmptyItemStacks);
return newRecipe != null;
if (getLevel() instanceof ServerLevel serverSide) return SpiritRepairRecipe.getRecipe(serverSide, inventoryForAltar.getStackInSlot(0), inventory.getStackInSlot(0), spiritInventory.nonEmptyItemStacks) != null;
else MalumMod.LOGGER.warn("RepairPylonCBE.tryRepair called from wrong side"); return false;
}

public void prepareRepair(IMalumSpecialItemAccessPoint provider) {
ParticleEffectTypeRegistry.REPAIR_PYLON_PREPARES.createPositionedEffect(level, new PositionEffectData(worldPosition), ColorEffectData.fromRecipe(recipe.spirits), PylonPrepareRepairParticleEffect.createData(provider.getAccessPointBlockPos()));
if (getLevel() instanceof ServerLevel serverSide) ParticleEffectTypeRegistry.REPAIR_PYLON_PREPARES.createPositionedEffect(serverSide, new PositionEffectData(worldPosition), ColorEffectData.fromRecipe(recipe.spirits), PylonPrepareRepairParticleEffect.createData(provider.getAccessPointBlockPos()));
else MalumMod.LOGGER.warn("RepairPylonCBE.prepareRepair called from wrong side");
setState(RepairPylonState.REPAIRING);
}

public void repairItem(IMalumSpecialItemAccessPoint provider) {
final LodestoneBlockEntityInventory suppliedInventory = provider.getSuppliedInventory();
ItemStack damagedItem = suppliedInventory.getStackInSlot(0);
ItemStack repairMaterial = inventory.getStackInSlot(0);
repairMaterial.shrink(recipe.repairMaterial.getCount());
repairMaterial.shrink(recipe.repairMaterial.count());
for (SpiritWithCount spirit : recipe.spirits) {
for (int i = 0; i < spiritInventory.slotCount; i++) {
ItemStack spiritStack = spiritInventory.getStackInSlot(i);
Expand Down
Loading

0 comments on commit 4a43931

Please sign in to comment.