Skip to content

Commit

Permalink
Update to 1.20.5(6)
Browse files Browse the repository at this point in the history
  • Loading branch information
QPCrummer committed May 4, 2024
1 parent 3f0cdfd commit 12e16d4
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 47 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import java.nio.charset.StandardCharsets

plugins {
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
id("com.modrinth.minotaur") version "2.8.4"
id("com.modrinth.minotaur") version "2.8.7"
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand All @@ -26,8 +26,8 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
modImplementation include("eu.pb4:polymer-core:0.7.1+1.20.4")
modImplementation include("xyz.nucleoid:server-translations-api:2.2.0+1.20.3-rc1")
modImplementation include("eu.pb4:polymer-core:0.8.0-beta.8+1.20.6")
modImplementation include("xyz.nucleoid:server-translations-api:2.3.0+1.20.5-rc2")
}

loom {
Expand All @@ -43,7 +43,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
org.gradle.jvmargs=-Xmx1G
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.1
fabric_version=0.91.2+1.20.4
mod_version=1.0.13
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.11
fabric_version=0.97.8+1.20.6
mod_version=1.0.14
maven_group=com.github.tatercertified
archives_base_name=fabricautocrafter
modrinth_id=wbqioEpc
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.tatercertified.fabricautocrafter;

import eu.pb4.polymer.core.api.block.PolymerBlock;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
Expand All @@ -10,7 +10,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.stat.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
Expand All @@ -22,12 +21,12 @@

public class AutoCrafter extends Block implements PolymerBlock, BlockEntityProvider {

protected AutoCrafter(FabricBlockSettings blockSettings) {
protected AutoCrafter(AbstractBlock.Settings blockSettings) {
super(blockSettings);
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
if (world.isClient) {
return ActionResult.SUCCESS;
} else if (world.getBlockEntity(pos) instanceof CraftingTableBlockEntity entity) {
Expand All @@ -38,8 +37,8 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
}

@Override
public Block getPolymerBlock(BlockState state) {
return CRAFTING_TABLE;
public BlockState getPolymerBlockState(BlockState state) {
return CRAFTING_TABLE.getDefaultState();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import eu.pb4.polymer.core.api.block.PolymerBlockUtils;
import eu.pb4.polymer.core.api.item.PolymerBlockItem;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
Expand All @@ -21,9 +20,9 @@
public class AutoCrafterMod implements ModInitializer {

public static final Identifier IDENTIFIER = new Identifier("autocrafter", "autocrafter");
public static final Block BLOCK = new AutoCrafter(FabricBlockSettings.copyOf(Blocks.CRAFTING_TABLE).strength(2.5f, 2.5f));
public static final BlockItem ITEM = new PolymerBlockItem(BLOCK, new FabricItemSettings(), Items.CRAFTING_TABLE);
public static final BlockEntityType<CraftingTableBlockEntity> TYPE = FabricBlockEntityTypeBuilder.create(CraftingTableBlockEntity::new, BLOCK).build(null);
public static final Block BLOCK = new AutoCrafter(AbstractBlock.Settings.copy(Blocks.CRAFTING_TABLE).strength(2.5f, 2.5f));
public static final BlockItem ITEM = new PolymerBlockItem(BLOCK, new Item.Settings(), Items.CRAFTING_TABLE);
public static final BlockEntityType<CraftingTableBlockEntity> TYPE = BlockEntityType.Builder.create(CraftingTableBlockEntity::new, BLOCK).build(null);

@Override
public void onInitialize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.recipe.*;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import static com.github.tatercertified.fabricautocrafter.AutoCrafterMod.TYPE;
Expand Down Expand Up @@ -53,24 +53,36 @@ public CraftingInventory boundCraftingInventory(ScreenHandler handler) {
}

@Override
public void writeNbt(NbtCompound tag) {
super.writeNbt(tag);
Inventories.writeNbt(tag, inventory);
tag.put("Output", output.writeNbt(new NbtCompound()));
protected void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
super.writeNbt(nbt, registryLookup);
Inventories.writeNbt(nbt, inventory, registryLookup);
if (!output.isEmpty()) {
nbt.put("Output", output.encode(registryLookup));
}
}

@Override
public void readNbt(NbtCompound tag) {
super.readNbt(tag);
Inventories.readNbt(tag, inventory);
this.output = ItemStack.fromNbt(tag.getCompound("Output"));
protected void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
super.readNbt(nbt, registryLookup);
Inventories.readNbt(nbt, inventory, registryLookup);
this.output = ItemStack.fromNbtOrEmpty(registryLookup, nbt.getCompound("Output"));
}

@Override
protected Text getContainerName() {
return Text.translatable("container.crafting");
}

@Override
protected DefaultedList<ItemStack> getHeldStacks() {
return this.inventory;
}

@Override
protected void setHeldStacks(DefaultedList<ItemStack> inventory) {
this.inventory = inventory;
}

@Override
protected ScreenHandler createScreenHandler(int id, PlayerInventory playerInventory) {
final AutoCraftingTableContainer container = new AutoCraftingTableContainer(id, playerInventory, this);
Expand Down Expand Up @@ -191,13 +203,13 @@ private Optional<CraftingRecipe> getCurrentRecipe() {

if (getLastRecipe != null) {
CraftingRecipe recipe = (CraftingRecipe) getLastRecipe.value();
Map<Identifier, RecipeEntry<CraftingRecipe>> craftingRecipes = manager.getAllOfType(RecipeType.CRAFTING);
if (craftingRecipes.containsKey(recipe) && craftingRecipes.get(recipe) != null) {
CraftingRecipe mapRecipe = craftingRecipes.get(recipe).value();
if (mapRecipe != null && mapRecipe.matches(craftingInventory, world)) {
return Optional.of(recipe);
}
}
Collection<RecipeEntry<CraftingRecipe>> craftingRecipes = manager.getAllOfType(RecipeType.CRAFTING);

return craftingRecipes.stream()
.filter(entry -> entry.value().equals(recipe))
.map(RecipeEntry::value)
.filter(mapRecipe1 -> mapRecipe1.matches(craftingInventory, world))
.findFirst();
}

Optional<RecipeEntry<CraftingRecipe>> recipe = manager.getFirstMatch(RecipeType.CRAFTING, craftingInventory, world);
Expand All @@ -221,9 +233,11 @@ private ItemStack craft() {
current.decrement(1);
}
if (!remainingStack.isEmpty()) {
System.out.println("TEST1");
if (current.isEmpty()) {
System.out.println("TEST2");
inventory.set(i, remainingStack);
} else if (ItemStack.canCombine(current, remainingStack)) {
} else if (ItemStack.areItemsAndComponentsEqual(current, remainingStack)) {
current.increment(remainingStack.getCount());
} else {
ItemScatterer.spawn(world, pos.getX(), pos.getY(), pos.getZ(), remainingStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;

/**
Expand Down Expand Up @@ -57,7 +58,7 @@ private static boolean canInsertStack(Hopper hopper, ItemStack test) {
if (hopper.isValid(i, test)) {
var stack = hopper.getStack(i);
if (stack.isEmpty() || (stack.getCount() < Math.min(stack.getMaxCount(), hopper.getMaxCountPerStack())
&& ItemStack.canCombine(stack, test))) return true;
&& ItemStack.areItemsAndComponentsEqual(stack, test))) return true;
}
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/act.accesswidener
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
accessWidener v1 named
accessible method net/minecraft/recipe/RecipeManager getAllOfType (Lnet/minecraft/recipe/RecipeType;)Ljava/util/Map;
accessible method net/minecraft/recipe/RecipeManager getAllOfType (Lnet/minecraft/recipe/RecipeType;)Ljava/util/Collection;
3 changes: 2 additions & 1 deletion src/main/resources/data/autocrafter/recipes/autocrafter.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
},
"result": {
"item": "autocrafter:autocrafter"
"count": 1,
"id": "autocrafter:autocrafter"
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"depends": {
"fabricloader": "*",
"fabric": "*",
"minecraft": ">=1.20.3",
"minecraft": ">=1.20.5",
"java": ">=17"
}
}

0 comments on commit 12e16d4

Please sign in to comment.