feat: obtainableReinforcedDeepSlate
This commit is contained in:
13 files changed
+161
-66
No files matched your search
@@ -1,9 +1,7 @@
|
|||||||
# Fabric Example Mod
|
# Carpet SLS Addition
|
||||||
|
|
||||||
## Setup
|
This is an extension of the [Carpet Mod](https://github.com/gnembon/fabric-carpet).
|
||||||
|
|
||||||
For setup instructions please see the [fabric wiki page](https://fabricmc.net/wiki/tutorial:setup) that relates to the IDE that you are using.
|
## StarLight Server
|
||||||
|
|
||||||
## License
|
[Homepage](https://www.starlight.cool/)
|
||||||
|
|
||||||
This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.
|
|
||||||
+12
-10
@@ -11,11 +11,15 @@ version = project.mod_version
|
|||||||
group = project.maven_group
|
group = project.maven_group
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// Add repositories to retrieve artifacts from in here.
|
maven {
|
||||||
// You should only use this when depending on other mods because
|
url 'https://masa.dy.fi/maven'
|
||||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
}
|
||||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
maven {
|
||||||
// for more information about repositories.
|
url 'https://jitpack.io'
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
url 'https://www.cursemaven.com'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -24,13 +28,11 @@ dependencies {
|
|||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
|
|
||||||
|
// carpet
|
||||||
|
modImplementation "carpet:fabric-carpet:${project.carpet_core_version}"
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
// Uncomment the following line to enable the deprecated Fabric API modules.
|
|
||||||
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
|
|
||||||
|
|
||||||
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
|||||||
+4
-3
@@ -8,9 +8,10 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
loader_version=0.14.9
|
loader_version=0.14.9
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.0
|
mod_version = 0.1
|
||||||
maven_group = com.example
|
maven_group = com.github.zly2006
|
||||||
archives_base_name = fabric-example-mod
|
archives_base_name = carpet-sls-addition
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.60.0+1.19.2
|
fabric_version=0.60.0+1.19.2
|
||||||
|
carpet_core_version=1.19.2-1.4.84+v221018
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.github.zly2006.carpetslsaddition;
|
||||||
|
|
||||||
|
import carpet.api.settings.Rule;
|
||||||
|
|
||||||
|
import static com.github.zly2006.carpetslsaddition.ServerMain.*;
|
||||||
|
|
||||||
|
public class SLSCarpetSettings {
|
||||||
|
@Rule(categories = {CARPET_ID})
|
||||||
|
public static boolean obtainableReinforcedDeepSlate = false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.github.zly2006.carpetslsaddition;
|
||||||
|
|
||||||
|
import carpet.CarpetExtension;
|
||||||
|
import carpet.CarpetServer;
|
||||||
|
import carpet.api.settings.*;
|
||||||
|
import com.google.common.collect.MapMaker;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.fabricmc.loader.api.Version;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import org.spongepowered.asm.mixin.injection.struct.InjectorGroupInfo;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class ServerMain implements ModInitializer, CarpetExtension {
|
||||||
|
public static final String MOD_ID = "carpet-sls-addition";
|
||||||
|
public static final String MOD_NAME = "Carpet SLS Addition";
|
||||||
|
public static final String CARPET_ID = "slsaddition";
|
||||||
|
static final Gson GSON = new Gson();
|
||||||
|
public static final Version MOD_VERSION = FabricLoader.getInstance().getModContainer(MOD_ID).get().getMetadata().getVersion();
|
||||||
|
public static ServerMain INSTANCE;
|
||||||
|
MinecraftServer server;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInitialize() {
|
||||||
|
INSTANCE = this;
|
||||||
|
CarpetServer.manageExtension(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServerLoaded(MinecraftServer server) {
|
||||||
|
this.server = server;
|
||||||
|
CarpetServer.settingsManager.parseSettingsClass(SLSCarpetSettings.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> canHasTranslations(String lang) {
|
||||||
|
Map<String, String> translation = Maps.newHashMap();
|
||||||
|
String jsonFile;
|
||||||
|
try (InputStream stream = ServerMain.class.getResourceAsStream("/assets/slsaddition/lang/%s.json".formatted(lang))) {
|
||||||
|
jsonFile = new String(stream.readAllBytes());
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
try (InputStream stream = ServerMain.class.getResourceAsStream("/assets/slsaddition/lang/%s.json".formatted("en_us"))) {
|
||||||
|
jsonFile = new String(stream.readAllBytes());
|
||||||
|
} catch (IOException e) {
|
||||||
|
return translation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GSON.fromJson(jsonFile, JsonObject.class).entrySet().stream()
|
||||||
|
.filter(entry -> entry.getKey().startsWith("carpet.rule."))
|
||||||
|
.filter(entry -> entry.getValue().isJsonPrimitive())
|
||||||
|
.map(entry -> Map.entry(entry.getKey(), entry.getValue().getAsString()))
|
||||||
|
.forEach(entry -> translation.put(entry.getKey(), entry.getValue()));
|
||||||
|
return translation;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.github.zly2006.carpetslsaddition.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.entity.FallingBlockEntity;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
@Mixin(FallingBlockEntity.class)
|
||||||
|
public class MixinFallingBlockEntity {
|
||||||
|
@Inject(method = "handleFallDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getOtherEntities(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;Ljava/util/function/Predicate;)Ljava/util/List;"), locals = LocalCapture.CAPTURE_FAILSOFT)
|
||||||
|
private void handleFallDamage(float fallDistance, float damageMultiplier, DamageSource damageSource, CallbackInfoReturnable<Boolean> cir, int i, Predicate<?> predicate, DamageSource damageSource2, float f) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.github.zly2006.carpetslsaddition.mixin;
|
||||||
|
|
||||||
|
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||||
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
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.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(ItemEntity.class)
|
||||||
|
public abstract class MixinItemEntity {
|
||||||
|
@Shadow
|
||||||
|
public abstract ItemStack getStack();
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract void setStack(ItemStack stack);
|
||||||
|
|
||||||
|
@Inject(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;discard()V"), cancellable = true)
|
||||||
|
private void damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
if (source == DamageSource.ANVIL && SLSCarpetSettings.obtainableReinforcedDeepSlate) {
|
||||||
|
if ((getStack().isOf(Items.DEEPSLATE) || getStack().isOf(Items.COBBLED_DEEPSLATE))
|
||||||
|
&& getStack().getCount() == 64) {
|
||||||
|
setStack(new ItemStack(Items.REINFORCED_DEEPSLATE));
|
||||||
|
cir.setReturnValue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package net.fabricmc.example;
|
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class ExampleMod implements ModInitializer {
|
|
||||||
// This logger is used to write text to the console and the log file.
|
|
||||||
// It is considered best practice to use your mod id as the logger's name.
|
|
||||||
// That way, it's clear which mod wrote info, warnings, and errors.
|
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger("modid");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInitialize() {
|
|
||||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
|
||||||
// However, some things (like resources) may still be uninitialized.
|
|
||||||
// Proceed with mild caution.
|
|
||||||
|
|
||||||
LOGGER.info("Hello Fabric world!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.fabricmc.example.mixin;
|
|
||||||
|
|
||||||
import net.fabricmc.example.ExampleMod;
|
|
||||||
import net.minecraft.client.gui.screen.TitleScreen;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(TitleScreen.class)
|
|
||||||
public class ExampleMixin {
|
|
||||||
@Inject(at = @At("HEAD"), method = "init()V")
|
|
||||||
private void init(CallbackInfo info) {
|
|
||||||
ExampleMod.LOGGER.info("This line is printed by an example mod mixin!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File renamed without changes.
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"carpet.rule.obtainableReinforcedDeepSlate.desc": "When an anvil falls on 64 dropped deepslates, they will be turned in a reinforced deepslate instead of disappearing."
|
||||||
|
}
|
||||||
@@ -1,36 +1,35 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "modid",
|
"id": "carpet-sls-addition",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
|
|
||||||
"name": "Example Mod",
|
"name": "Example Mod",
|
||||||
"description": "This is an example description! Tell everyone what your mod is about!",
|
"description": "This is an example description! Tell everyone what your mod is about!",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Me!"
|
"zly2006"
|
||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://fabricmc.net/",
|
|
||||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"icon": "assets/modid/icon.png",
|
"icon": "assets/slsaddition/icon.png",
|
||||||
|
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"net.fabricmc.example.ExampleMod"
|
"com.github.zly2006.carpetslsaddition.ServerMain"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"modid.mixins.json"
|
"slsaddition.mixins.json"
|
||||||
],
|
],
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.9",
|
"fabricloader": ">=0.14.9",
|
||||||
"fabric-api": "*",
|
"fabric-api": "*",
|
||||||
"minecraft": "~1.19",
|
"minecraft": "~1.19",
|
||||||
"java": ">=17"
|
"java": ">=17",
|
||||||
|
"carpet": "*"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
"another-mod": "*"
|
"another-mod": "*"
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "net.fabricmc.example.mixin",
|
"package": "com.github.zly2006.carpetslsaddition.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"MixinFallingBlockEntity",
|
||||||
|
"MixinItemEntity"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"ExampleMixin"
|
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
Reference in new issue
Block a user