Skip to content

Commit

Permalink
Updated to 1.19.4 and had to edit a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
pluto7073 committed Jun 12, 2023
1 parent 5c23fac commit a400981
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 12 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.2
loader_version=0.14.21

# Mod Properties
mod_version = 1.19.3-2.0
mod_version = 1.19.4-2.0
maven_group = ml.pluto7073
archives_base_name = PlutosCoffeeMod-Fabric

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.76.1+1.19.3
fabric_version=0.83.0+1.19.4
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.gui.screen.ingame.ForgingScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.SmithingScreenHandler;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

Expand All @@ -23,4 +24,15 @@ protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) {
super.drawForeground(matrices, mouseX, mouseY);
}

protected void drawInvalidRecipeArrow(MatrixStack matrices, int x, int y) {
if (this.hasInvalidRecipe()) {
drawTexture(matrices, x + 65, y + 46, this.backgroundWidth, 0, 28, 21);
}

}

private boolean hasInvalidRecipe() {
return (this.handler).getSlot(0).hasStack() && (this.handler).getSlot(1).hasStack() && (this.handler).getSlot(2).hasStack() && !(this.handler).getSlot((this.handler).getResultSlotIndex()).hasStack();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.SmithingRecipe;
import net.minecraft.screen.ForgingScreenHandler;
import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.screen.slot.ForgingSlotsManager;
import net.minecraft.screen.slot.Slot;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Optional;

public class CoffeeWorkstationScreenHandler extends ForgingScreenHandler {

Expand Down Expand Up @@ -85,8 +88,31 @@ public void updateResult() {
}

@Override
protected boolean isUsableAsAddition(ItemStack stack) {
return recipes.stream().anyMatch((recipe) -> recipe.testAddition(stack));
protected ForgingSlotsManager getForgingSlotsManager() {
return ForgingSlotsManager.create().input(0, 27, 47, stack -> {
return this.recipes.stream().anyMatch(recipe -> {
return recipe.testBase(stack);
});
}).input(1, 76, 47, stack -> {
return this.recipes.stream().anyMatch(recipe -> {
return recipe.testAddition(stack);
});
}).output(2, 134, 47).build();
}

private static Optional<Integer> getQuickMoveSlot(CoffeeWorkstationRecipe recipe, ItemStack stack) {
if (recipe.testBase(stack)) {
return Optional.of(0);
} else {
return recipe.testAddition(stack) ? Optional.of(1) : Optional.empty();
}
}

@Override
protected boolean isValidIngredient(ItemStack stack) {
return this.recipes.stream().map((recipe) -> {
return getQuickMoveSlot(recipe, stack);
}).anyMatch(Optional::isPresent);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static <M extends ScreenHandler, U extends Screen & ScreenHandlerProvider
}

@Inject(at = @At("TAIL"), method = "<clinit>")
private static void clInitInject(CallbackInfo ci) {
private static void plutoscoffee_clInitInject(CallbackInfo ci) {
register(ModScreens.BREWER_SCREEN_HANDLER_TYPE, CoffeeBrewerScreen::new);
register(ModScreens.WORKSTATION_HANDLER_TYPE, CoffeeWorkstationScreen::new);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class ItemColorsMixin {

@Inject(at = @At("TAIL"), method = "create", cancellable = true)
private static void createInject(BlockColors blockColors, CallbackInfoReturnable<ItemColors> cir) {
private static void plutoscoffee_createInject(BlockColors blockColors, CallbackInfoReturnable<ItemColors> cir) {
ItemColors itemColors = cir.getReturnValue();
itemColors.register((stack, tintIndex) -> tintIndex > 0 ? -1 : Utils.getCoffeeColour(stack), ModItems.BREWED_COFFEE);
cir.setReturnValue(itemColors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class MinecraftClientMixin {

@Inject(at = @At("HEAD"), method = "tick")
public void onFirstTick(CallbackInfo ci) {
public void plutoscoffee_onFirstTick(CallbackInfo ci) {
PlutosCoffee.MOD.loadLater();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class ResourceReloadLoggerMixin {

@Inject(at = @At("TAIL"), method = "finish")
public void onFinishResourceReload(CallbackInfo ci) {
public void plutoscoffee_onFinishResourceReload(CallbackInfo ci) {
VersionChecker.showWarningScreen();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.nbt.NbtList;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.recipe.*;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
import net.minecraft.world.World;
Expand All @@ -39,6 +40,10 @@ public boolean matches(Inventory inventory, World world) {
}

@Override
public ItemStack craft(Inventory inventory, DynamicRegistryManager registryManager) {
return craft(inventory);
}

public ItemStack craft(Inventory inventory) {
ItemStack stack = result.copy();
NbtList sourceAdds = inventory.getStack(0).getOrCreateSubNbt("Coffee").getList("Additions", NbtElement.STRING_TYPE);
Expand All @@ -57,7 +62,7 @@ public boolean fits(int width, int height) {
}

@Override
public ItemStack getOutput() {
public ItemStack getOutput(DynamicRegistryManager registryManager) {
return this.result;
}

Expand All @@ -70,6 +75,10 @@ public boolean testAddition(ItemStack stack) {
return addition.test(stack);
}

public boolean testBase(ItemStack stack) {
return base.test(stack);
}

public ItemStack createIcon() {
return new ItemStack(ModBlocks.COFFEE_WORKSTATION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ml.pluto7073.plutoscoffee.gui.CoffeeWorkstationScreenHandler;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.resource.featuretoggle.FeatureFlags;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.Identifier;
Expand All @@ -17,7 +18,7 @@ public class ModScreens {
public static void init() {}

private static <T extends ScreenHandler> ScreenHandlerType<T> register(String id, ScreenHandlerType.Factory<T> factory) {
return Registry.register(Registries.SCREEN_HANDLER, new Identifier(PlutosCoffee.MOD_ID, id), new ScreenHandlerType<>(factory));
return Registry.register(Registries.SCREEN_HANDLER, new Identifier(PlutosCoffee.MOD_ID, id), new ScreenHandlerType<>(factory, FeatureFlags.VANILLA_FEATURES));
}

static {
Expand Down

0 comments on commit a400981

Please sign in to comment.