Skip to content

Commit

Permalink
Merge pull request #63 from Crec0/update-1.19.3
Browse files Browse the repository at this point in the history
Update 1.19.3
  • Loading branch information
gnembon authored Dec 19, 2022
2 parents 88504ef + adea427 commit 393e04e
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 41 deletions.
43 changes: 18 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'io.github.juuxel.loom-quiltflower' version '1.8.0'
id 'maven-publish'
}

Expand Down Expand Up @@ -36,48 +37,40 @@ processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.mod_version
expand "version": project.version
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"

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

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}

jar {
from "LICENSE"
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(jar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
from components.java
}
}

// select the repositories you want to publish to
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// uncomment to publish to the local maven
// mavenLocal()
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use or https://modmuss50.me/fabric.html
minecraft_version=1.19.1
yarn_mappings=1.19.1+build.6
loader_version=0.14.9
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.3
loader_version=0.14.11
# check available versions on maven for the given minecraft version you are using
carpet_core_version=1.4.83+v220727
carpet_core_version=1.4.91+v221207

# Mod Properties
mod_version = 1.4.83
mod_version = 1.4.91
maven_group = carpet-autocraftingtable
archives_base_name = carpet-autocraftingtable

Expand Down
24 changes: 24 additions & 0 deletions src/main/java/carpet_autocraftingtable/AutoCraftingTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

import carpet.CarpetExtension;
import carpet.CarpetServer;
import com.google.common.reflect.TypeToken;
import com.google.gson.GsonBuilder;
import org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Map;

public class AutoCraftingTable implements CarpetExtension
{
Expand All @@ -15,4 +24,19 @@ public void onGameStarted() {
// let's /carpet handle our few simple settings
CarpetServer.settingsManager.parseSettingsClass(AutoCraftingTableSettings.class);
}

@Override
public Map<String, String> canHasTranslations(String lang) {
InputStream langFile = AutoCraftingTable.class.getClassLoader().getResourceAsStream("assets/carpet-autocraftingtable/lang/%s.json".formatted(lang));
if (langFile == null) {
return Collections.emptyMap();
}
String jsonData;
try {
jsonData = IOUtils.toString(langFile, StandardCharsets.UTF_8);
} catch (IOException e) {
return Collections.emptyMap();
}
return new GsonBuilder().create().fromJson(jsonData, new TypeToken<Map<String, String>>() {}.getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void onContentChanged(Inventory inv) {
}

@Override
public ItemStack transferSlot(PlayerEntity player, int index) {
public ItemStack quickMove(PlayerEntity player, int index) {
ItemStack remainderResultStack = ItemStack.EMPTY;
Slot slot = this.slots.get(index);
if (slot.hasStack()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package carpet_autocraftingtable;

import carpet.settings.Rule;
import carpet.api.settings.Rule;

import static carpet.settings.RuleCategory.CREATIVE;
import static carpet.api.settings.RuleCategory.CREATIVE;

/**
* Here is your example Settings class you can plug to use carpetmod /carpet settings command
*/
public class AutoCraftingTableSettings
{
@Rule(desc = "Auto-crafting table", category = {CREATIVE, "extras"})
@Rule(categories = {CREATIVE, "extras"})
public static boolean autoCraftingTable = false;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import net.minecraft.recipe.RecipeMatcher;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.RecipeUnlocker;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -35,9 +36,9 @@

public class CraftingTableBlockEntity extends LockableContainerBlockEntity implements SidedInventory, RecipeUnlocker, RecipeInputProvider {
public static final BlockEntityType<CraftingTableBlockEntity> TYPE = Registry.register(
Registry.BLOCK_ENTITY_TYPE,
"carpet:crafting_table",
BlockEntityType.Builder.create(CraftingTableBlockEntity::new, Blocks.CRAFTING_TABLE).build(null)
Registries.BLOCK_ENTITY_TYPE,
"carpet:crafting_table",
BlockEntityType.Builder.create(CraftingTableBlockEntity::new, Blocks.CRAFTING_TABLE).build(null)
);
private static final int[] OUTPUT_SLOTS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
private static final int[] INPUT_SLOTS = {1, 2, 3, 4, 5, 6, 7, 8, 9};
Expand Down Expand Up @@ -215,7 +216,7 @@ private ItemStack craft() {
if (!remainingStack.isEmpty()) {
if (current.isEmpty()) {
inventory.set(i, remainingStack);
} else if (ItemStack.areItemsEqualIgnoreDamage(current, remainingStack) && ItemStack.areEqual(current, remainingStack)) {
} else if (ItemStack.canCombine(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 @@ -13,7 +13,7 @@ public class BootStrapMixin {
method="initialize",
at=@At(
value = "INVOKE",
target = "Lnet/minecraft/util/registry/Registry;freezeRegistries()V",
target = "Lnet/minecraft/registry/Registries;bootstrap()V",
shift = At.Shift.BEFORE
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"carpet.rule.autoCraftingTable.desc": "Converts the vanilla crafting tables into carpet's auto-crafting table"
}

0 comments on commit 393e04e

Please sign in to comment.