diff --git a/.gitattributes b/.gitattributes index f811f6a..20fc528 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,15 @@ -# Disable autocrlf on generated files, they always generate with LF -# Add any extra files or paths here to make git stop saying they -# are changed when only line endings change. -src/generated/**/.cache/cache text eol=lf -src/generated/**/*.json text eol=lf +* text eol=lf +*.bat text eol=crlf +*.patch text eol=lf +*.java text eol=lf +*.gradle text eol=crlf +*.png binary +*.gif binary +*.exe binary +*.dll binary +*.jar binary +*.lzma binary +*.zip binary +*.pyd binary +*.cfg text eol=lf +*.jks binary \ No newline at end of file diff --git a/.gitignore b/.gitignore index b569492..778a722 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,8 @@ out *.ipr *.iws *.iml -.idea +.idea/* +!.idea/scopes # gradle build @@ -20,8 +21,3 @@ build # other eclipse run - -# Files from Forge MDK -forge*changelog.txt - -libs/ diff --git a/.idea/scopes/Fabric_sources.xml b/.idea/scopes/Fabric_sources.xml new file mode 100644 index 0000000..0448412 --- /dev/null +++ b/.idea/scopes/Fabric_sources.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/scopes/Forge_sources.xml b/.idea/scopes/Forge_sources.xml new file mode 100644 index 0000000..7b5f24d --- /dev/null +++ b/.idea/scopes/Forge_sources.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Common/build.gradle b/Common/build.gradle new file mode 100644 index 0000000..ea3a28a --- /dev/null +++ b/Common/build.gradle @@ -0,0 +1,54 @@ +plugins { + id 'java' + id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' + id 'maven-publish' +} + +archivesBaseName = "${mod_name}-common-${minecraft_version}" + +minecraft { + version(minecraft_version) + runs { + if (project.hasProperty('common_runs_enabled') ? project.findProperty('common_runs_enabled').toBoolean() : true) { + + server(project.hasProperty('common_server_run_name') ? project.findProperty('common_server_run_name') : 'vanilla_server') { + workingDirectory(this.file("run")) + } + client(project.hasProperty('common_client_run_name') ? project.findProperty('common_client_run_name') : 'vanilla_client') { + workingDirectory(this.file("run")) + } + } + } +} + +dependencies { + compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5' + implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' +} + +processResources { + + def buildProps = project.properties.clone() + + filesMatching(['pack.mcmeta']) { + + expand buildProps + } +} + +publishing { + publications { + mavenJava(MavenPublication) { + groupId project.group + artifactId project.archivesBaseName + version project.version + from components.java + } + } + + repositories { + maven { + url "file://" + System.getenv("local_maven") + } + } +} \ No newline at end of file diff --git a/Common/src/main/java/tschipp/carryon/CommonClass.java b/Common/src/main/java/tschipp/carryon/CommonClass.java new file mode 100644 index 0000000..ec070b7 --- /dev/null +++ b/Common/src/main/java/tschipp/carryon/CommonClass.java @@ -0,0 +1,40 @@ +package tschipp.carryon; + +import tschipp.carryon.platform.Services; +import net.minecraft.core.Registry; +import net.minecraft.network.chat.Component; +import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.TooltipFlag; + +import java.util.List; + +public class CommonClass { + + // This method serves as an initialization hook for the mod. The vanilla + // game has no mechanism to load tooltip listeners so this must be + // invoked from a mod loader specific project like Forge or Fabric. + public static void init() { + + Constants.LOG.info("Hello from Common init on {}! we are currently in a {} environment!", Services.PLATFORM.getPlatformName(), Services.PLATFORM.isDevelopmentEnvironment() ? "development" : "production"); + Constants.LOG.info("Diamond Item >> {}", Registry.ITEM.getKey(Items.DIAMOND)); + } + + // This method serves as a hook to modify item tooltips. The vanilla game + // has no mechanism to load tooltip listeners so this must be registered + // by a mod loader like Forge or Fabric. + public static void onItemTooltip(ItemStack stack, TooltipFlag context, List tooltip) { + + if (!stack.isEmpty()) { + + final FoodProperties food = stack.getItem().getFoodProperties(); + + if (food != null) { + + tooltip.add(Component.literal("Nutrition: " + food.getNutrition())); + tooltip.add(Component.literal("Saturation: " + food.getSaturationModifier())); + } + } + } +} \ No newline at end of file diff --git a/Common/src/main/java/tschipp/carryon/Constants.java b/Common/src/main/java/tschipp/carryon/Constants.java new file mode 100644 index 0000000..c7ce9f8 --- /dev/null +++ b/Common/src/main/java/tschipp/carryon/Constants.java @@ -0,0 +1,11 @@ +package tschipp.carryon; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Constants { + + public static final String MOD_ID = "carryon"; + public static final String MOD_NAME = "Carry On"; + public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME); +} \ No newline at end of file diff --git a/Common/src/main/java/tschipp/carryon/common/carry/CarryOnData.java b/Common/src/main/java/tschipp/carryon/common/carry/CarryOnData.java new file mode 100644 index 0000000..5d44e97 --- /dev/null +++ b/Common/src/main/java/tschipp/carryon/common/carry/CarryOnData.java @@ -0,0 +1,89 @@ +package tschipp.carryon.common.carry; + +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; + +import javax.annotation.Nullable; + +public class CarryOnData { + + private CarryType type; + private CompoundTag nbt; + + public CarryOnData(CompoundTag data) + { + if(data.contains("type")) + this.type = CarryType.valueOf(data.getString("type")); + else + this.type = CarryType.INVALID; + + this.nbt = data; + } + + public CompoundTag getNbt() + { + nbt.putString("type", type.toString()); + return nbt; + } + + public void setBlock(BlockState state, @Nullable BlockEntity tile) + { + this.type = CarryType.BLOCK; + CompoundTag stateData = NbtUtils.writeBlockState(state); + nbt.put("block", stateData); + + if(tile != null) + { + CompoundTag tileData = tile.saveWithId(); + nbt.put("tile", tileData); + } + } + + public BlockState getBlock() + { + if(this.type != CarryType.BLOCK) + throw new IllegalStateException("Called getBlock on data that contained " + this.type); + + return NbtUtils.readBlockState(nbt.getCompound("block")); + } + + @Nullable + public BlockEntity getBlockEntity(BlockPos pos) + { + if(this.type != CarryType.BLOCK) + throw new IllegalStateException("Called getBlockEntity on data that contained " + this.type); + + if(!nbt.contains("tile")) + return null; + + return BlockEntity.loadStatic(pos, this.getBlock(), nbt.getCompound("tile")); + } + + public void setEntity(Entity entity) + { + this.type = CarryType.ENTITY; + CompoundTag entityData = new CompoundTag(); + entity.save(entityData); + nbt.put("entity", entityData); + } + + public Entity getEntity(Level level) + { + if(this.type != CarryType.ENTITY) + throw new IllegalStateException("Called getEntity on data that contained " + this.type); + + return EntityType.create(nbt.getCompound("entity"), level).orElseThrow(); + } + + public enum CarryType { + BLOCK, + ENTITY, + INVALID + } +} diff --git a/Common/src/main/java/tschipp/carryon/common/carry/CarryOnDataManager.java b/Common/src/main/java/tschipp/carryon/common/carry/CarryOnDataManager.java new file mode 100644 index 0000000..f6f1433 --- /dev/null +++ b/Common/src/main/java/tschipp/carryon/common/carry/CarryOnDataManager.java @@ -0,0 +1,25 @@ +package tschipp.carryon.common.carry; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.entity.player.Player; + +public class CarryOnDataManager { + + public static final EntityDataAccessor CARRY_DATA_KEY = SynchedEntityData.defineId(Player.class, EntityDataSerializers.COMPOUND_TAG); + + + public CarryOnData getCarryData(Player player) + { + CompoundTag data = player.getEntityData().get(CARRY_DATA_KEY); + return new CarryOnData(data); + } + + public void setCarryData(Player player, CarryOnData data) + { + player.getEntityData().set(CARRY_DATA_KEY, data.getNbt()); + } + +} diff --git a/Common/src/main/java/tschipp/carryon/mixin/PlayerMixin.java b/Common/src/main/java/tschipp/carryon/mixin/PlayerMixin.java new file mode 100644 index 0000000..83e5f69 --- /dev/null +++ b/Common/src/main/java/tschipp/carryon/mixin/PlayerMixin.java @@ -0,0 +1,27 @@ +package tschipp.carryon.mixin; + + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +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; +import tschipp.carryon.common.carry.CarryOnDataManager; + +@Mixin(Player.class) +public abstract class PlayerMixin extends Entity { + + public PlayerMixin(EntityType type, Level level) { + super(type, level); + } + + @Inject(at = @At("RETURN"), method = "defineSynchedData()V") + private void onDefineSynchedData(CallbackInfo info) { + this.entityData.define(CarryOnDataManager.CARRY_DATA_KEY, new CompoundTag()); + } + +} diff --git a/Common/src/main/java/tschipp/carryon/platform/Services.java b/Common/src/main/java/tschipp/carryon/platform/Services.java new file mode 100644 index 0000000..2343834 --- /dev/null +++ b/Common/src/main/java/tschipp/carryon/platform/Services.java @@ -0,0 +1,20 @@ +package tschipp.carryon.platform; + +import tschipp.carryon.Constants; +import tschipp.carryon.platform.services.IPlatformHelper; + +import java.util.ServiceLoader; + +public class Services { + + public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class); + + public static T load(Class clazz) { + + final T loadedService = ServiceLoader.load(clazz) + .findFirst() + .orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName())); + Constants.LOG.debug("Loaded {} for service {}", loadedService, clazz); + return loadedService; + } +} diff --git a/Common/src/main/java/tschipp/carryon/platform/services/IPlatformHelper.java b/Common/src/main/java/tschipp/carryon/platform/services/IPlatformHelper.java new file mode 100644 index 0000000..b62b62e --- /dev/null +++ b/Common/src/main/java/tschipp/carryon/platform/services/IPlatformHelper.java @@ -0,0 +1,26 @@ +package tschipp.carryon.platform.services; + +public interface IPlatformHelper { + + /** + * Gets the name of the current platform + * + * @return The name of the current platform. + */ + String getPlatformName(); + + /** + * Checks if a mod with the given id is loaded. + * + * @param modId The mod to check if it is loaded. + * @return True if the mod is loaded, false otherwise. + */ + boolean isModLoaded(String modId); + + /** + * Check if the game is currently in a development environment. + * + * @return True if in a development environment, false otherwise. + */ + boolean isDevelopmentEnvironment(); +} diff --git a/Common/src/main/resources/carryon.mixins.json b/Common/src/main/resources/carryon.mixins.json new file mode 100644 index 0000000..93ca0e7 --- /dev/null +++ b/Common/src/main/resources/carryon.mixins.json @@ -0,0 +1,16 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "tschipp.carryon.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "server": [ + ], + "injectors": { + "defaultRequire": 1 + }, + "refmap": "${refmap_target}refmap.json" +} \ No newline at end of file diff --git a/Common/src/main/resources/pack.mcmeta b/Common/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..52854ec --- /dev/null +++ b/Common/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "${mod_name}", + "pack_format": 8 + } +} \ No newline at end of file diff --git a/Fabric/build.gradle b/Fabric/build.gradle new file mode 100644 index 0000000..337a4a2 --- /dev/null +++ b/Fabric/build.gradle @@ -0,0 +1,64 @@ +plugins { + id 'fabric-loom' version '0.12-SNAPSHOT' + id 'maven-publish' + id 'idea' +} + +archivesBaseName = "${mod_name}-fabric-${minecraft_version}" + +dependencies { + minecraft "com.mojang:minecraft:${minecraft_version}" + mappings loom.officialMojangMappings() + modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}" + implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' + implementation project(":Common") +} + +loom { + runs { + client { + client() + setConfigName("Fabric Client") + ideConfigGenerated(true) + runDir("run") + } + server { + server() + setConfigName("Fabric Server") + ideConfigGenerated(true) + runDir("run") + } + } +} + + +processResources { + from project(":Common").sourceSets.main.resources + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +tasks.withType(JavaCompile) { + source(project(":Common").sourceSets.main.allSource) +} + +publishing { + publications { + mavenJava(MavenPublication) { + groupId project.group + artifactId project.archivesBaseName + version project.version + from components.java + } + } + + repositories { + maven { + url "file://" + System.getenv("local_maven") + } + } +} diff --git a/Fabric/src/main/java/tschipp/carryon/ExampleMod.java b/Fabric/src/main/java/tschipp/carryon/ExampleMod.java new file mode 100644 index 0000000..44cfecb --- /dev/null +++ b/Fabric/src/main/java/tschipp/carryon/ExampleMod.java @@ -0,0 +1,23 @@ +package tschipp.carryon; + +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; + +public class ExampleMod implements ModInitializer { + + @Override + public void onInitialize() { + + // This method is invoked by the Fabric mod loader when it is ready + // to load your mod. You can access Fabric and Common code in this + // project. + + // Use Fabric to bootstrap the Common mod. + Constants.LOG.info("Hello Fabric world!"); + CommonClass.init(); + + // Some code like events require special initialization from the + // loader specific code. + ItemTooltipCallback.EVENT.register(CommonClass::onItemTooltip); + } +} diff --git a/Fabric/src/main/java/tschipp/carryon/mixin/ExampleMixin.java b/Fabric/src/main/java/tschipp/carryon/mixin/ExampleMixin.java new file mode 100644 index 0000000..0137cbd --- /dev/null +++ b/Fabric/src/main/java/tschipp/carryon/mixin/ExampleMixin.java @@ -0,0 +1,21 @@ +package tschipp.carryon.mixin; + +import tschipp.carryon.Constants; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.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) { + + Constants.LOG.info("This line is printed by an example mod mixin from Fabric!"); + Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType()); + Constants.LOG.info("Classloader: {}", this.getClass().getClassLoader()); + } +} \ No newline at end of file diff --git a/Fabric/src/main/java/tschipp/carryon/platform/FabricPlatformHelper.java b/Fabric/src/main/java/tschipp/carryon/platform/FabricPlatformHelper.java new file mode 100644 index 0000000..bd10051 --- /dev/null +++ b/Fabric/src/main/java/tschipp/carryon/platform/FabricPlatformHelper.java @@ -0,0 +1,24 @@ +package tschipp.carryon.platform; + +import tschipp.carryon.platform.services.IPlatformHelper; +import net.fabricmc.loader.api.FabricLoader; + +public class FabricPlatformHelper implements IPlatformHelper { + + @Override + public String getPlatformName() { + return "Fabric"; + } + + @Override + public boolean isModLoaded(String modId) { + + return FabricLoader.getInstance().isModLoaded(modId); + } + + @Override + public boolean isDevelopmentEnvironment() { + + return FabricLoader.getInstance().isDevelopmentEnvironment(); + } +} diff --git a/Fabric/src/main/resources/META-INF/services/tschipp.carryon.platform.services.IPlatformHelper b/Fabric/src/main/resources/META-INF/services/tschipp.carryon.platform.services.IPlatformHelper new file mode 100644 index 0000000..c765743 --- /dev/null +++ b/Fabric/src/main/resources/META-INF/services/tschipp.carryon.platform.services.IPlatformHelper @@ -0,0 +1 @@ +tschipp.carryon.platform.FabricPlatformHelper \ No newline at end of file diff --git a/Fabric/src/main/resources/carryon.fabric.mixins.json b/Fabric/src/main/resources/carryon.fabric.mixins.json new file mode 100644 index 0000000..caf1cd6 --- /dev/null +++ b/Fabric/src/main/resources/carryon.fabric.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "tschipp.carryon.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } + } + diff --git a/Fabric/src/main/resources/fabric.mod.json b/Fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..47bb916 --- /dev/null +++ b/Fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,39 @@ +{ + "schemaVersion": 1, + "id": "modid", + "version": "${version}", + + "name": "Example Mod", + "description": "This is an example description! Tell everyone what your mod is about!", + "authors": [ + "Me!" + ], + "contact": { + "homepage": "https://fabricmc.net/", + "sources": "https://github.com/FabricMC/fabric-example-mod" + }, + + "license": "CC0-1.0", + "icon": "assets/modid/icon.png", + + "environment": "*", + "entrypoints": { + "main": [ + "tschipp.carryon.ExampleMod" + ] + }, + "mixins": [ + "carryon.fabric.mixins.json" + ], + + "depends": { + "fabricloader": ">=0.14", + "fabric": "*", + "minecraft": "1.19.x", + "java": ">=17" + }, + "suggests": { + "another-mod": "*" + } + } + \ No newline at end of file diff --git a/Forge/build.gradle b/Forge/build.gradle new file mode 100644 index 0000000..f8ae222 --- /dev/null +++ b/Forge/build.gradle @@ -0,0 +1,123 @@ +buildscript { + repositories { + maven { url = 'https://maven.minecraftforge.net' } + maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } + mavenCentral() + } + dependencies { + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true + classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' + } +} +apply plugin: 'java' +apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'eclipse' +apply plugin: 'org.spongepowered.mixin' +apply plugin: 'maven-publish' + +archivesBaseName = "${mod_name}-forge-${minecraft_version}" + +mixin { + add sourceSets.main, "${mod_id}.refmap.json" + + config "${mod_id}.mixins.json" + config "${mod_id}.forge.mixins.json" +} + +minecraft { + mappings channel: 'official', version: minecraft_version + + if (project.hasProperty('forge_ats_enabled') && project.findProperty('forge_ats_enabled').toBoolean()) { + // This location is hardcoded in Forge and can not be changed. + // https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123 + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + project.logger.debug('Forge Access Transformers are enabled for this project.') + } + + runs { + client { + workingDirectory project.file('run') + ideaModule "${rootProject.name}.${project.name}.main" + taskName 'Client' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" + args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json" + mods { + modClientRun { + source sourceSets.main + source project(":Common").sourceSets.main + } + } + } + + server { + workingDirectory project.file('run') + ideaModule "${rootProject.name}.${project.name}.main" + taskName 'Server' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" + args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json" + mods { + modServerRun { + source sourceSets.main + source project(":Common").sourceSets.main + } + } + } + + data { + workingDirectory project.file('run') + ideaModule "${rootProject.name}.${project.name}.main" + args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + taskName 'Data' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" + args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json" + mods { + modDataRun { + source sourceSets.main + source project(":Common").sourceSets.main + } + } + } + } +} + +sourceSets.main.resources.srcDir 'src/generated/resources' + +dependencies { + minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" + compileOnly project(":Common") + annotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor' +} + +tasks.withType(JavaCompile) { + source(project(":Common").sourceSets.main.allSource) +} + +processResources { + from project(":Common").sourceSets.main.resources + + filesMatching('*.mixins.json') { + expand "refmap_target": "${mod_id}." + } +} + + +jar.finalizedBy('reobfJar') + +publishing { + publications { + mavenJava(MavenPublication) { + groupId project.group + artifactId project.archivesBaseName + version project.version + artifact jar + } + } + repositories { + maven { + url "file://" + System.getenv("local_maven") + } + } +} diff --git a/Forge/src/main/java/tschipp/carryon/ExampleMod.java b/Forge/src/main/java/tschipp/carryon/ExampleMod.java new file mode 100644 index 0000000..11cb673 --- /dev/null +++ b/Forge/src/main/java/tschipp/carryon/ExampleMod.java @@ -0,0 +1,33 @@ +package tschipp.carryon; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fml.common.Mod; + +@Mod(Constants.MOD_ID) +public class ExampleMod { + + public ExampleMod() { + + // This method is invoked by the Forge mod loader when it is ready + // to load your mod. You can access Forge and Common code in this + // project. + + // Use Forge to bootstrap the Common mod. + Constants.LOG.info("Hello Forge world!"); + CommonClass.init(); + + // Some code like events require special initialization from the + // loader specific code. + MinecraftForge.EVENT_BUS.addListener(this::onItemTooltip); + + } + + // This method exists as a wrapper for the code in the Common project. + // It takes Forge's event object and passes the parameters along to + // the Common listener. + private void onItemTooltip(ItemTooltipEvent event) { + + CommonClass.onItemTooltip(event.getItemStack(), event.getFlags(), event.getToolTip()); + } +} \ No newline at end of file diff --git a/Forge/src/main/java/tschipp/carryon/platform/ForgePlatformHelper.java b/Forge/src/main/java/tschipp/carryon/platform/ForgePlatformHelper.java new file mode 100644 index 0000000..8d24bb7 --- /dev/null +++ b/Forge/src/main/java/tschipp/carryon/platform/ForgePlatformHelper.java @@ -0,0 +1,26 @@ +package tschipp.carryon.platform; + +import tschipp.carryon.platform.services.IPlatformHelper; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.loading.FMLLoader; + +public class ForgePlatformHelper implements IPlatformHelper { + + @Override + public String getPlatformName() { + + return "Forge"; + } + + @Override + public boolean isModLoaded(String modId) { + + return ModList.get().isLoaded(modId); + } + + @Override + public boolean isDevelopmentEnvironment() { + + return !FMLLoader.isProduction(); + } +} diff --git a/Forge/src/main/resources/META-INF/mods.toml b/Forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..a2889e3 --- /dev/null +++ b/Forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,62 @@ +# This is an example mods.toml file. It contains the data relating to the loading mods. +# There are several mandatory fields (#mandatory), and many more that are optional (#optional). +# The overall format is standard TOML format, v0.5.0. +# Note that there are a couple of TOML lists in this file. +# Find more information on toml format here: https://github.com/toml-lang/toml +# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml +modLoader="javafml" #mandatory +# A version range to match for said mod loader - for regular FML @Mod it will be the forge version +loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. +# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. +license="All rights reserved" +# A URL to refer people to when problems occur with this mod +#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional +# A list of mods - how many allowed here is determined by the individual mod loader +[[mods]] #mandatory +# The modid of the mod +modId="multiloader" #mandatory +# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it +# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata +# see the associated build.gradle script for how to populate this completely automatically during a build +version="${file.jarVersion}" #mandatory + # A display name for the mod +displayName="Example Mod" #mandatory +# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ +#updateJSONURL="https://change.me.example.invalid/updates.json" #optional +# A URL for the "homepage" for this mod, displayed in the mod UI +#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional +# A file name (in the root of the mod JAR) containing a logo for display +logoFile="multiloader.png" #optional +# A text field displayed in the mod UI +credits="Thanks for this example mod goes to Java" #optional +# A text field displayed in the mod UI +authors="Love, Cheese and small house plants" #optional +# The description text for the mod (multi line!) (#mandatory) +description=''' +This is a long form description of the mod. You can write whatever you want here + +Have some lorem ipsum. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis lacinia magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sagittis luctus odio eu tempus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque volutpat ligula eget lacus auctor sagittis. In hac habitasse platea dictumst. Nunc gravida elit vitae sem vehicula efficitur. Donec mattis ipsum et arcu lobortis, eleifend sagittis sem rutrum. Cras pharetra quam eget posuere fermentum. Sed id tincidunt justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. +''' +# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. +[[dependencies.multiloader]] #optional + # the modid of the dependency + modId="forge" #mandatory + # Does this dependency have to exist - if not, ordering below must be specified + mandatory=true #mandatory + # The version range of the dependency + versionRange="[43,)" #mandatory + # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory + ordering="NONE" + # Side this dependency is applied on - BOTH, CLIENT or SERVER + side="BOTH" +# Here's another dependency +[[dependencies.multiloader]] + modId="minecraft" + mandatory=true +# This version range declares a minimum of the current minecraft version up to but not including the next major version + versionRange="[1.19.2,1.20)" + ordering="NONE" + side="BOTH" diff --git a/Forge/src/main/resources/META-INF/services/tschipp.carryon.platform.services.IPlatformHelper b/Forge/src/main/resources/META-INF/services/tschipp.carryon.platform.services.IPlatformHelper new file mode 100644 index 0000000..471251d --- /dev/null +++ b/Forge/src/main/resources/META-INF/services/tschipp.carryon.platform.services.IPlatformHelper @@ -0,0 +1 @@ +tschipp.carryon.platform.ForgePlatformHelper \ No newline at end of file diff --git a/Forge/src/main/resources/carryon.forge.mixins.json b/Forge/src/main/resources/carryon.forge.mixins.json new file mode 100644 index 0000000..93ca0e7 --- /dev/null +++ b/Forge/src/main/resources/carryon.forge.mixins.json @@ -0,0 +1,16 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "tschipp.carryon.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "server": [ + ], + "injectors": { + "defaultRequire": 1 + }, + "refmap": "${refmap_target}refmap.json" +} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 65c5ca8..0e259d4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,165 +1,121 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 +Creative Commons Legal Code - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +CC0 1.0 Universal + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. +Statement of Purpose - 0. Additional Definitions. +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. - 1. Exception to Section 3 of the GNU GPL. +4. Limitations and Disclaimers. - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/README.md b/README.md index 0900fdd..1329c2c 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,25 @@ +# MultiLoader Template -# Carry On [![](http://cf.way2muchnoise.eu/carry-on.svg)](https://minecraft.curseforge.com/projects/carry-on) [![](http://cf.way2muchnoise.eu/versions/carry-on.svg)](https://minecraft.curseforge.com/projects/carry-on) +This project provides a Gradle project template that can compile mods for both Forge and Fabric using a common sourceset. This project does not require any third party libraries or dependencies. -To use CarryOn in your projects, include this in your build.gradle: -``` -repositories { - maven { - url "https://maven.blamejared.com/" - } -} +## Getting Started -dependencies { - deobfCompile "tschipp.carryon:carryon-MCVERSION:MODVERSION" -} -``` -Make sure to replace `MCVERSION` and `MODVERSION` with the appropriate versions. +## IntelliJ IDEA +This guide will show how to import the MultiLoader Template into IntelliJ IDEA. The setup process is roughly equivalent to setting up Forge and Fabric independently and should be very familiar to anyone who has worked with their MDKs. + +1. Clone or download this repository to your computer. +2. Configure the project by editing the `group`, `mod_name`, `mod_author`, and `mod_id` properties in the `gradle.properties` file. You will also need to change the `rootProject.name` property in `settings.gradle`. +3. Open the template's root folder as a new project in IDEA. This is the folder that contains this README file and the gradlew executable. +4. If your default JVM/JDK is not Java 17 you will encounter an error when opening the project. This error is fixed by going to `File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM`and changing the value to a valid Java 17 JVM. You will also need to set the Project SDK to Java 17. This can be done by going to `File > Project Structure > Project SDK`. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project. +5. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Common > Tasks > vanilla gradle > decompile`. Run this task to decompile Minecraft. +6. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Forge > Tasks > forgegradle runs > genIntellijRuns`. Run this task to set up run configurations for Forge. +7. Open your Run/Debug Configurations. Under the Application category there should now be options to run Forge and Fabric projects. Select one of the client options and try to run it. +8. Assuming you were able to run the game in step 7 your workspace should now be set up. + +### Eclipse +While it is possible to use this template in Eclipse it is not recommended. During the development of this template multiple critical bugs and quirks related to Eclipse were found at nearly every level of the required build tools. While we continue to work with these tools to report and resolve issues support for projects like these are not there yet. For now Eclipse is considered unsupported by this project. The development cycle for build tools is notoriously slow so there are no ETAs available. + +## Development Guide +When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knowledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the Forge or Fabric project. + +Loader specific projects such as the Forge and Fabric project are used to load the Common project into the game. These projects also define code that is specific to that loader. Loader specific projects can access all of the code in the Common project. It is important to remember that the Common project can not access code from loader specific projects. diff --git a/build.gradle b/build.gradle index 23476a9..98616ee 100644 --- a/build.gradle +++ b/build.gradle @@ -1,242 +1,63 @@ -buildscript { +subprojects { + + apply plugin: 'java' + + java.toolchain.languageVersion = JavaLanguageVersion.of(17) + java.withSourcesJar() + java.withJavadocJar() + + jar { + from(rootProject.file("LICENSE")) { + rename { "${it}_${mod_name}" } + } + manifest { + attributes([ + 'Specification-Title' : mod_name, + 'Specification-Vendor' : mod_author, + 'Specification-Version' : project.jar.archiveVersion, + 'Implementation-Title' : project.name, + 'Implementation-Version' : project.jar.archiveVersion, + 'Implementation-Vendor' : mod_author, + 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + 'Timestamp' : System.currentTimeMillis(), + 'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", + 'Built-On-Minecraft' : minecraft_version + ]) + } + } + + sourcesJar { + from(rootProject.file("LICENSE")) { + rename { "${it}_${mod_name}" } + } + } + repositories { - maven { url = 'https://maven.minecraftforge.net' } - maven { url = 'https://maven.parchmentmc.org' } - jcenter() + mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - classpath 'org.parchmentmc:librarian:1.+' - } -} -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' -apply plugin: 'maven-publish' -apply plugin: 'org.parchmentmc.librarian.forgegradle' - - -apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle' -apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle' - -//import net.minecraftforge.gradle.common.task.SignJar -import groovy.json.JsonSlurper -import groovy.json.JsonOutput - -if (project.hasProperty('secretFile')) { - loadSecrets(new File((String) findProperty('secretFile'))) -} - -version = "${version}" -group = "tschipp.carryon" -archivesBaseName = "carryon-${minecraft_version}" - - -if (System.getenv('BUILD_NUMBER') != null) { - version += "." + System.getenv('BUILD_NUMBER') -} - -java.toolchain.languageVersion = JavaLanguageVersion.of(17) -println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) - -minecraft { - mappings channel: 'parchment', version: "${mappings_version}" - - runs { - client { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - - property 'forge.logging.console.level', 'debug' - - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg" - - mods { - carryon { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - - property 'forge.logging.console.level', 'debug' - - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg" - - mods { - carryon { - source sourceSets.main - } - } - } - - data { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - - property 'forge.logging.console.level', 'debug' - - args '--mod', 'carryon', '--all', '--output', file('src/generated/resources/') - - mods { - carryon { - source sourceSets.main - } - } - } - } -} - -repositories { - - maven { - url "https://maven.blamejared.com/" - } - - maven { - url "https://maven.mcmoddev.com/" - } - - flatDir { - dirs 'libs' - } - - maven { - url "https://www.cursemaven.com" - } -} - -dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - - //implementation fg.deobf("net.darkhax.gamestages:GameStages-1.16.4:6.0.1") - //implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-1.16.4:9.3.18") - //implementation fg.deobf("curse.maven:obfuscate-289380:3169370") - - //fileTree("libs").matching { - // include "*.jar" - //}.each { - // String filename = it.getName(); - // filename = filename.substring(0, filename.length() - 4); - // int lastDash = filename.lastIndexOf("-"); - // filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length()); - // implementation fg.deobf("blank:${filename}") - //} - -} - -// Example for how to get properties into the manifest for reading by the runtime.. -jar { - manifest { - attributes([ - "Specification-Title": "carryon", - "Specification-Vendor": "Carry On", - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"Carry On", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } -} - -jar.finalizedBy('reobfJar') - -task sourcesJar(type: Jar, dependsOn: classes) { - description = 'Creates a JAR containing the source code.' - from sourceSets.main.allSource - classifier = 'sources' -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - description = 'Creates a JAR containing the JavaDocs.' - from javadoc.destinationDir - classifier = 'javadoc' -} - -task deobfJar(type: Jar) { - description = 'Creates a JAR containing the non-obfuscated compiled code.' - from sourceSets.main.output - classifier = "deobf" -} - -artifacts { - archives sourcesJar - archives javadocJar - archives deobfJar -} - - -publishing { - - publications { - - mavenJava(MavenPublication) { - - groupId project.group - artifactId project.archivesBaseName - version project.version - from components.java - - // Allows the maven pom file to be modified. - pom.withXml { - - // Go through all the dependencies. - asNode().dependencies.dependency.each { dep -> - - println 'Surpressing artifact ' + dep.artifactId.last().value().last() + ' from maven dependencies.' - assert dep.parent().remove(dep) - } - } - - artifact sourcesJar { - - classifier 'sources' - } - artifact javadocJar { - - classifier 'javadoc' - } - artifact deobfJar { - - classifier 'deobf' - } - } - } - - repositories { maven { + name = 'Sponge / Mixin' + url = 'https://repo.spongepowered.org/repository/maven-public/' + } - url "file://" + System.getenv("local_maven") + maven { + name = 'BlameJared Maven (CrT / Bookshelf)' + url = 'https://maven.blamejared.com' } } + + tasks.withType(JavaCompile).configureEach { + + it.options.encoding = 'UTF-8' + it.options.release = 17 + } + + // Disables Gradle's custom module metadata from being published to maven. The + // metadata includes mapped dependencies which are not reasonably consumable by + // other mod developers. + tasks.withType(GenerateModuleMetadata) { + + enabled = false + } } - -//task signJar(type: SignJar, dependsOn: jar) { - // Skips if the keyStore property is missing. - // onlyIf { - // project.hasProperty('modkeyStore') - // } - - // findProperty allows us to reference the property without it existing. - // Using project.propName would cause the script to fail validation if - // the property did not exist. - // keyStore = project.findProperty('modkeyStore') - // alias = project.findProperty('modkeyStoreAlias') - // storePass = project.findProperty('modkeyStorePass') - // keyPass = project.findProperty('modkeyStoreKeyPass') - // inputFile = jar.archivePath - // outputFile = jar.archivePath -//} - -// Runs this task automatically when build is ran. -//build.dependsOn signJar \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 9d9cf13..2586b09 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,26 @@ -# Sets default memory used for gradle commands. Can be overridden by user or command line properties. -# This is required to provide enough memory for the Minecraft decompilation process. +# Project +version=2.0.0 +group=tschipp.carryon + +# Common +minecraft_version=1.19.2 +common_runs_enabled=false +common_client_run_name=Common Client +common_server_run_name=Common Server + +# Forge +forge_version=43.1.30 +//forge_ats_enabled=true + +# Fabric +fabric_version=0.62.0+1.19.2 +fabric_loader_version=0.14.9 + +# Mod options +mod_name=Carry On +mod_author=Tschipp, PurpliciousCow +mod_id=carryon + +# Gradle org.gradle.jvmargs=-Xmx3G -version=1.17.0 -minecraft_version=1.18.2 -mappings_version=2022.02.13-1.18.1 -forge_version=40.0.3 -org.gradle.daemon=false -# chorg.gradle.java.home=C:/Program Files/AdoptOpenJDK/jdk-17.0.1/ \ No newline at end of file +org.gradle.daemon=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..ae04661 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index c53aefa..b4f908a 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env bash # -# Copyright © 2015-2021 the original authors. +# Copyright 2015 the original author or authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,101 +17,67 @@ # ############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# +## +## Gradle start up script for UN*X +## ############################################################################## # Attempt to set APP_HOME - # Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} +APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum +MAX_FD="maximum" warn () { echo "$*" -} >&2 +} die () { echo echo "$*" echo exit 1 -} >&2 +} # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MSYS* | MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -121,9 +87,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java + JAVACMD="$JAVA_HOME/jre/sh/java" else - JAVACMD=$JAVA_HOME/bin/java + JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -132,7 +98,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD=java + JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -140,95 +106,78 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi fi -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi # For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=$( cygpath --unix "$JAVACMD" ) + JAVACMD=`cygpath --unix "$JAVACMD"` - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +ARGV=("$@") +eval set -- $DEFAULT_JVM_OPTS -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" +IFS=$' +' read -rd '' -a JAVA_OPTS_ARR <<< "$(echo $JAVA_OPTS | xargs -n1)" +IFS=$' +' read -rd '' -a GRADLE_OPTS_ARR <<< "$(echo $GRADLE_OPTS | xargs -n1)" -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" +exec "$JAVACMD" "$@" "${JAVA_OPTS_ARR[@]}" "${GRADLE_OPTS_ARR[@]}" "-Dorg.gradle.appname=$APP_BASE_NAME" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "${ARGV[@]}" diff --git a/logs/debug.log b/logs/debug.log deleted file mode 100644 index e69de29..0000000 diff --git a/logs/latest.log b/logs/latest.log deleted file mode 100644 index e69de29..0000000 diff --git a/Jenkinsfile b/old/Jenkinsfile similarity index 100% rename from Jenkinsfile rename to old/Jenkinsfile diff --git a/old/LICENSE b/old/LICENSE new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/old/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/old/README.md b/old/README.md new file mode 100644 index 0000000..0900fdd --- /dev/null +++ b/old/README.md @@ -0,0 +1,16 @@ + +# Carry On [![](http://cf.way2muchnoise.eu/carry-on.svg)](https://minecraft.curseforge.com/projects/carry-on) [![](http://cf.way2muchnoise.eu/versions/carry-on.svg)](https://minecraft.curseforge.com/projects/carry-on) + +To use CarryOn in your projects, include this in your build.gradle: +``` +repositories { + maven { + url "https://maven.blamejared.com/" + } +} + +dependencies { + deobfCompile "tschipp.carryon:carryon-MCVERSION:MODVERSION" +} +``` +Make sure to replace `MCVERSION` and `MODVERSION` with the appropriate versions. diff --git a/old/build.gradle b/old/build.gradle new file mode 100644 index 0000000..dfebe13 --- /dev/null +++ b/old/build.gradle @@ -0,0 +1,239 @@ +buildscript { + dependencies { + classpath 'org.parchmentmc:librarian:1.+' + } +} + +plugins { + id 'eclipse' + id 'maven-publish' + id 'net.minecraftforge.gradle' version '5.1.+' +} + +apply plugin: 'org.parchmentmc.librarian.forgegradle' + + +apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle' +apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle' + +//import net.minecraftforge.gradle.common.task.SignJar +import groovy.json.JsonSlurper +import groovy.json.JsonOutput + +if (project.hasProperty('secretFile')) { + loadSecrets(new File((String) findProperty('secretFile'))) +} + +version = "${version}" +group = "tschipp.carryon" +archivesBaseName = "carryon-${minecraft_version}" + + +if (System.getenv('BUILD_NUMBER') != null) { + version += "." + System.getenv('BUILD_NUMBER') +} + +java.toolchain.languageVersion = JavaLanguageVersion.of(17) +println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) + +minecraft { + mappings channel: 'parchment', version: "${mappings_version}" + + runs { + client { + workingDirectory project.file('run') + + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + + property 'forge.logging.console.level', 'debug' + + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg" + + mods { + carryon { + source sourceSets.main + } + } + } + + server { + workingDirectory project.file('run') + + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + + property 'forge.logging.console.level', 'debug' + + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg" + + mods { + carryon { + source sourceSets.main + } + } + } + + data { + workingDirectory project.file('run') + + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + + property 'forge.logging.console.level', 'debug' + + args '--mod', 'carryon', '--all', '--output', file('src/generated/resources/') + + mods { + carryon { + source sourceSets.main + } + } + } + } +} + +repositories { + + maven { + url "https://maven.blamejared.com/" + } + + maven { + url "https://maven.mcmoddev.com/" + } + + flatDir { + dirs 'libs' + } + + maven { + url "https://www.cursemaven.com" + } +} + +dependencies { + minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" + + //implementation fg.deobf("net.darkhax.gamestages:GameStages-1.16.4:6.0.1") + //implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-1.16.4:9.3.18") + //implementation fg.deobf("curse.maven:obfuscate-289380:3169370") + + //fileTree("libs").matching { + // include "*.jar" + //}.each { + // String filename = it.getName(); + // filename = filename.substring(0, filename.length() - 4); + // int lastDash = filename.lastIndexOf("-"); + // filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length()); + // implementation fg.deobf("blank:${filename}") + //} + +} + +// Example for how to get properties into the manifest for reading by the runtime.. +jar { + manifest { + attributes([ + "Specification-Title": "carryon", + "Specification-Vendor": "Carry On", + "Specification-Version": "1", // We are version 1 of ourselves + "Implementation-Title": project.name, + "Implementation-Version": "${version}", + "Implementation-Vendor" :"Carry On", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } +} + +jar.finalizedBy('reobfJar') + +task sourcesJar(type: Jar, dependsOn: classes) { + description = 'Creates a JAR containing the source code.' + from sourceSets.main.allSource + classifier = 'sources' +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + description = 'Creates a JAR containing the JavaDocs.' + from javadoc.destinationDir + classifier = 'javadoc' +} + +task deobfJar(type: Jar) { + description = 'Creates a JAR containing the non-obfuscated compiled code.' + from sourceSets.main.output + classifier = "deobf" +} + +artifacts { + archives sourcesJar + archives javadocJar + archives deobfJar +} + + +publishing { + + publications { + + mavenJava(MavenPublication) { + + groupId project.group + artifactId project.archivesBaseName + version project.version + from components.java + + // Allows the maven pom file to be modified. + pom.withXml { + + // Go through all the dependencies. + asNode().dependencies.dependency.each { dep -> + + println 'Surpressing artifact ' + dep.artifactId.last().value().last() + ' from maven dependencies.' + assert dep.parent().remove(dep) + } + } + + artifact sourcesJar { + + classifier 'sources' + } + artifact javadocJar { + + classifier 'javadoc' + } + artifact deobfJar { + + classifier 'deobf' + } + } + } + + repositories { + + maven { + + url "file://" + System.getenv("local_maven") + } + } +} + +//task signJar(type: SignJar, dependsOn: jar) { + // Skips if the keyStore property is missing. + // onlyIf { + // project.hasProperty('modkeyStore') + // } + + // findProperty allows us to reference the property without it existing. + // Using project.propName would cause the script to fail validation if + // the property did not exist. + // keyStore = project.findProperty('modkeyStore') + // alias = project.findProperty('modkeyStoreAlias') + // storePass = project.findProperty('modkeyStorePass') + // keyPass = project.findProperty('modkeyStoreKeyPass') + // inputFile = jar.archivePath + // outputFile = jar.archivePath +//} + +// Runs this task automatically when build is ran. +//build.dependsOn signJar \ No newline at end of file diff --git a/old/gradle.properties b/old/gradle.properties new file mode 100644 index 0000000..c8d56c2 --- /dev/null +++ b/old/gradle.properties @@ -0,0 +1,9 @@ +# Sets default memory used for gradle commands. Can be overridden by user or command line properties. +# This is required to provide enough memory for the Minecraft decompilation process. +org.gradle.jvmargs=-Xmx3G +version=1.18.1 +minecraft_version=1.19 +mappings_version=1.19.2-2022.09.18 +forge_version=41.0.100 +org.gradle.daemon=false +# chorg.gradle.java.home=C:/Program Files/AdoptOpenJDK/jdk-17.0.1/ \ No newline at end of file diff --git a/old/settings.gradle b/old/settings.gradle new file mode 100644 index 0000000..ba700c1 --- /dev/null +++ b/old/settings.gradle @@ -0,0 +1,9 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { url = 'https://maven.minecraftforge.net/' } + maven { url = 'https://maven.parchmentmc.org' } + jcenter() + mavenCentral() + } +} \ No newline at end of file diff --git a/src/main/java/tschipp/carryon/CarryOn.java b/old/src/main/java/tschipp/carryon/CarryOn.java similarity index 89% rename from src/main/java/tschipp/carryon/CarryOn.java rename to old/src/main/java/tschipp/carryon/CarryOn.java index 6ae3ef4..fe3c6f1 100644 --- a/src/main/java/tschipp/carryon/CarryOn.java +++ b/old/src/main/java/tschipp/carryon/CarryOn.java @@ -7,9 +7,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; @@ -56,6 +53,7 @@ public class CarryOn ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Configs.SERVER_CONFIG); info = ModLoadingContext.get().getActiveContainer().getModInfo(); + RegistrationHandler.init(); } private void setup(final FMLCommonSetupEvent event) @@ -63,7 +61,7 @@ public class CarryOn String version = info.getVersion().toString(); // PreInitevent. CarryOn.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(CarryOn.MODID, "carryonpackets"), () -> version, version::equals, version::equals); - + // CLIENT PACKETS CarryOn.network.registerMessage(0, CarrySlotPacket.class, CarrySlotPacket::toBytes, CarrySlotPacket::new, CarrySlotPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT)); CarryOn.network.registerMessage(1, ScriptReloadPacket.class, ScriptReloadPacket::toBytes, ScriptReloadPacket::new, ScriptReloadPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT)); @@ -78,13 +76,4 @@ public class CarryOn proxy.setup(event); } - - @SubscribeEvent - public static void onRegistry(RegistryEvent.Register event) - { - RegistrationHandler.regItems(); - - event.getRegistry().register(RegistrationHandler.itemEntity); - event.getRegistry().register(RegistrationHandler.itemTile); - } } \ No newline at end of file diff --git a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java b/old/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java similarity index 95% rename from src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java rename to old/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java index 369ac95..637287d 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java +++ b/old/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java @@ -21,7 +21,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderHandEvent; -import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.event.level.LevelEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModList; import tschipp.carryon.client.helper.CarryRenderHelper; @@ -51,7 +51,7 @@ public class RenderEntityEvents @OnlyIn(Dist.CLIENT) @SubscribeEvent - public void onLevelUnload(WorldEvent.Unload event) + public void onLevelUnload(LevelEvent.Unload event) { nbtEntityMap.clear(); } @@ -68,13 +68,13 @@ public class RenderEntityEvents Player player = Minecraft.getInstance().player; ItemStack stack = player.getMainHandItem(); int perspective = CarryRenderHelper.getPerspective(); - float partialticks = event.getPartialTicks(); + float partialticks = event.getPartialTick(); PoseStack matrix = event.getPoseStack(); int light = event.getPackedLight(); MultiBufferSource buffer = event.getMultiBufferSource(); EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher(); - if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)) + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(stack)) { if (ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) return; diff --git a/src/main/java/tschipp/carryon/client/event/RenderEvents.java b/old/src/main/java/tschipp/carryon/client/event/RenderEvents.java similarity index 90% rename from src/main/java/tschipp/carryon/client/event/RenderEvents.java rename to old/src/main/java/tschipp/carryon/client/event/RenderEvents.java index 3bf1cea..c561372 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEvents.java +++ b/old/src/main/java/tschipp/carryon/client/event/RenderEvents.java @@ -28,7 +28,7 @@ import net.minecraft.client.resources.model.BakedModel; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.ClickEvent.Action; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; @@ -48,9 +48,9 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderLevelLastEvent; import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.client.event.ScreenEvent.InitScreenEvent; +import net.minecraftforge.client.event.ScreenEvent; import net.minecraftforge.event.TickEvent.PlayerTickEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.EntityJoinLevelEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.LogicalSide; @@ -87,7 +87,7 @@ public class RenderEvents { ItemStack stack = player.getMainHandItem(); - if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity)) + if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile.get() || stack.getItem() == RegistrationHandler.itemEntity.get())) { if (ItemCarryonBlock.hasTileData(stack) || ItemCarryonEntity.hasEntityData(stack)) { @@ -124,7 +124,7 @@ public class RenderEvents @SubscribeEvent @OnlyIn(Dist.CLIENT) - public void onJoinLevel(EntityJoinWorldEvent event) + public void onJoinLevel(EntityJoinLevelEvent event) { if (event.getEntity() instanceof Player) { @@ -136,10 +136,10 @@ public class RenderEvents if (CarryOn.FINGERPRINT_VIOLATED) { - TextComponent cf = new TextComponent(ChatFormatting.AQUA + "Curseforge" + ChatFormatting.RED); + Component cf = Component.literal(ChatFormatting.AQUA + "Curseforge" + ChatFormatting.RED); cf.getStyle().withClickEvent(new ClickEvent(Action.OPEN_URL, "https://minecraft.curseforge.com/projects/carry-on")); - player.displayClientMessage(new TextComponent(ChatFormatting.RED + "[CarryOn] WARNING! Invalid fingerprint detected! The Carry On mod file may have been tampered with! If you didn't download the file from ").append(cf).append(ChatFormatting.RED + " or through any kind of mod launcher, immediately delete the file and re-download it from ").append(cf), false); + player.displayClientMessage(Component.literal(ChatFormatting.RED + "[CarryOn] WARNING! Invalid fingerprint detected! The Carry On mod file may have been tampered with! If you didn't download the file from ").append(cf).append(ChatFormatting.RED + " or through any kind of mod launcher, immediately delete the file and re-download it from ").append(cf), false); } } @@ -152,7 +152,7 @@ public class RenderEvents @SuppressWarnings("resource") @OnlyIn(Dist.CLIENT) @SubscribeEvent - public void onGuiInit(InitScreenEvent.Pre event) + public void onGuiInit(ScreenEvent.Init.Pre event) { if (event.getScreen() != null) { @@ -163,7 +163,7 @@ public class RenderEvents { ItemStack stack = player.getItemInHand(InteractionHand.MAIN_HAND); - if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))) + if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile.get() && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(stack))) { Minecraft.getInstance().player.closeContainer(); Minecraft.getInstance().screen = null; @@ -192,7 +192,7 @@ public class RenderEvents { ItemStack stack = Minecraft.getInstance().player.getMainHandItem(); - if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))) + if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile.get() && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(stack))) { if (settings.keyDrop.matches(key, scancode)) { @@ -241,7 +241,7 @@ public class RenderEvents PoseStack matrix = event.getPoseStack(); int light = event.getPackedLight(); - if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) && perspective == 0 && !f1) + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile.get() && ItemCarryonBlock.hasTileData(stack) && perspective == 0 && !f1) { if (ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) return; @@ -336,7 +336,7 @@ public class RenderEvents light = manager.getPackedLightCoords(player, partialticks); ItemStack stack = player.getMainHandItem(); - if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile.get() && ItemCarryonBlock.hasTileData(stack)) { Block block = ItemCarryonBlock.getBlock(stack); BlockState state = ItemCarryonBlock.getBlockState(stack); @@ -380,7 +380,7 @@ public class RenderEvents matrix.popPose(); } - else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)) + else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(stack)) { Entity entity = RenderEntityEvents.getEntity(stack, level); @@ -594,7 +594,7 @@ public class RenderEvents if (handleMobends() && !ModList.get().isLoaded("obfuscate")) { ItemStack stack = player.getMainHandItem(); - if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)) + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile.get() && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(stack)) { PlayerModel model = getPlayerModel((AbstractClientPlayer) player); @@ -629,8 +629,8 @@ public class RenderEvents } else if (renderLeft) { - renderArmPost(model.leftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder); - renderArmPost(model.leftSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder); + renderArmPost(model.leftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder); + renderArmPost(model.leftSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder); } if (renderRight && rotRight != null) @@ -640,16 +640,16 @@ public class RenderEvents } else if (renderRight) { - renderArmPost(model.rightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder); - renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder); + renderArmPost(model.rightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder); + renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder); } } else { - renderArmPost(model.rightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder); - renderArmPost(model.leftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder); - renderArmPost(model.leftSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder); - renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder); + renderArmPost(model.rightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder); + renderArmPost(model.leftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder); + renderArmPost(model.leftSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder); + renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder); } if (buffer instanceof BufferSource) @@ -672,10 +672,10 @@ public class RenderEvents if (handleMobends() && !ModList.get().isLoaded("obfuscate")) { - Player player = event.getPlayer(); + Player player = event.getEntity(); Pose pose = player.getPose(); ItemStack stack = player.getMainHandItem(); - if (pose != Pose.SWIMMING && pose != Pose.FALL_FLYING && !stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))) + if (pose != Pose.SWIMMING && pose != Pose.FALL_FLYING && !stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile.get() && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(stack))) { PlayerModel model = event.getRenderer().getModel(); @@ -787,8 +787,8 @@ public class RenderEvents // { // ItemStack stack = event.getItemStack(); // - // if (stack != null && (stack.getItem() == RegistrationHandler.itemTile || - // stack.getItem() == RegistrationHandler.itemEntity)) + // if (stack != null && (stack.getItem() == RegistrationHandler.itemTile.get() || + // stack.getItem() == RegistrationHandler.itemEntity.get())) // { // event.setCanceled(true); // } diff --git a/src/main/java/tschipp/carryon/client/helper/CarryRenderHelper.java b/old/src/main/java/tschipp/carryon/client/helper/CarryRenderHelper.java similarity index 100% rename from src/main/java/tschipp/carryon/client/helper/CarryRenderHelper.java rename to old/src/main/java/tschipp/carryon/client/helper/CarryRenderHelper.java diff --git a/src/main/java/tschipp/carryon/client/keybinds/CarryOnKeybinds.java b/old/src/main/java/tschipp/carryon/client/keybinds/CarryOnKeybinds.java similarity index 63% rename from src/main/java/tschipp/carryon/client/keybinds/CarryOnKeybinds.java rename to old/src/main/java/tschipp/carryon/client/keybinds/CarryOnKeybinds.java index 3fdeb58..905bdbb 100644 --- a/src/main/java/tschipp/carryon/client/keybinds/CarryOnKeybinds.java +++ b/old/src/main/java/tschipp/carryon/client/keybinds/CarryOnKeybinds.java @@ -4,21 +4,26 @@ import net.minecraft.client.KeyMapping; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.ClientRegistry; +import net.minecraftforge.client.event.RegisterKeyMappingsEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import tschipp.carryon.CarryOn; +@EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD, value = Dist.CLIENT) public class CarryOnKeybinds { public static final String KEYBIND_KEY = "carryOnKeyPressed"; public static KeyMapping carryKey; - @OnlyIn(Dist.CLIENT) - public static void init() + + @SubscribeEvent + public static void registerKeybinds(RegisterKeyMappingsEvent event) { carryKey = new KeyMapping("key.carry.desc", 340, "key.carry.category"); - ClientRegistry.registerKeyBinding(carryKey); + event.register(carryKey); } public static boolean isKeyPressed(Player player) diff --git a/src/main/java/tschipp/carryon/common/capabilities/IPosition.java b/old/src/main/java/tschipp/carryon/common/capabilities/IPosition.java similarity index 100% rename from src/main/java/tschipp/carryon/common/capabilities/IPosition.java rename to old/src/main/java/tschipp/carryon/common/capabilities/IPosition.java diff --git a/src/main/java/tschipp/carryon/common/capabilities/PositionProvider.java b/old/src/main/java/tschipp/carryon/common/capabilities/PositionProvider.java similarity index 100% rename from src/main/java/tschipp/carryon/common/capabilities/PositionProvider.java rename to old/src/main/java/tschipp/carryon/common/capabilities/PositionProvider.java diff --git a/src/main/java/tschipp/carryon/common/capabilities/TEPosition.java b/old/src/main/java/tschipp/carryon/common/capabilities/TEPosition.java similarity index 100% rename from src/main/java/tschipp/carryon/common/capabilities/TEPosition.java rename to old/src/main/java/tschipp/carryon/common/capabilities/TEPosition.java diff --git a/src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java b/old/src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java similarity index 96% rename from src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java rename to old/src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java index 9f08d77..d3d61bf 100644 --- a/src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java +++ b/old/src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java @@ -23,7 +23,7 @@ public class PositionClientEvents @SuppressWarnings("resource") @OnlyIn(Dist.CLIENT) @SubscribeEvent - public void onGui(ScreenEvent.DrawScreenEvent event) + public void onGui(ScreenEvent.BackgroundRendered event) { if (event.getScreen() != null) { @@ -58,7 +58,7 @@ public class PositionClientEvents @SubscribeEvent public void onGuiClose(PlayerContainerEvent.Close event) { - Player player = event.getPlayer(); + Player player = event.getEntity(); if (player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent()) { IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition()); diff --git a/src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java b/old/src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java similarity index 95% rename from src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java rename to old/src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java index 8f24262..81081a7 100644 --- a/src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java +++ b/old/src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java @@ -32,8 +32,8 @@ public class PositionCommonEvents public void onBlockRight(PlayerInteractEvent.RightClickBlock event) { BlockPos pos = event.getPos(); - Level level = event.getWorld(); - Player player = event.getPlayer(); + Level level = event.getLevel(); + Player player = event.getEntity(); if (event.isCanceled() || player == null || player instanceof FakePlayer) return; diff --git a/src/main/java/tschipp/carryon/common/command/CommandCarryOn.java b/old/src/main/java/tschipp/carryon/common/command/CommandCarryOn.java similarity index 84% rename from src/main/java/tschipp/carryon/common/command/CommandCarryOn.java rename to old/src/main/java/tschipp/carryon/common/command/CommandCarryOn.java index 256e846..aafc3dc 100644 --- a/src/main/java/tschipp/carryon/common/command/CommandCarryOn.java +++ b/old/src/main/java/tschipp/carryon/common/command/CommandCarryOn.java @@ -10,7 +10,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.commands.arguments.EntityArgument; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; import net.minecraftforge.network.PacketDistributor; @@ -49,17 +49,17 @@ public class CommandCarryOn ServerPlayer player = source.getPlayerOrException(); ItemStack main = player.getMainHandItem(); - if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemTile) + if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemTile.get()) { - source.sendSuccess(new TextComponent("Block: " + ItemCarryonBlock.getBlock(main)), true); - source.sendSuccess(new TextComponent("BlockState: " + ItemCarryonBlock.getBlockState(main)), true); - source.sendSuccess(new TextComponent("ItemStack: " + ItemCarryonBlock.getItemStack(main)), true); + source.sendSuccess(Component.literal("Block: " + ItemCarryonBlock.getBlock(main)), true); + source.sendSuccess(Component.literal("BlockState: " + ItemCarryonBlock.getBlockState(main)), true); + source.sendSuccess(Component.literal("ItemStack: " + ItemCarryonBlock.getItemStack(main)), true); if (ModelOverridesHandler.hasCustomOverrideModel(ItemCarryonBlock.getBlockState(main), ItemCarryonBlock.getTileData(main))) - source.sendSuccess(new TextComponent("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemCarryonBlock.getBlockState(main), ItemCarryonBlock.getTileData(main))), true); + source.sendSuccess(Component.literal("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemCarryonBlock.getBlockState(main), ItemCarryonBlock.getTileData(main))), true); if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemCarryonBlock.getBlockState(main))) - source.sendSuccess(new TextComponent("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonBlock.getBlockState(main))), true); + source.sendSuccess(Component.literal("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonBlock.getBlockState(main))), true); CarryOn.LOGGER.info("Block: " + ItemCarryonBlock.getBlock(main)); CarryOn.LOGGER.info("BlockState: " + ItemCarryonBlock.getBlockState(main)); @@ -73,13 +73,13 @@ public class CommandCarryOn return 1; } - else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity) + else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity.get()) { - source.sendSuccess(new TextComponent("Entity: " + ItemCarryonEntity.getEntity(main, player.level)), true); - source.sendSuccess(new TextComponent("Entity Name: " + ItemCarryonEntity.getEntityName(main)), true); + source.sendSuccess(Component.literal("Entity: " + ItemCarryonEntity.getEntity(main, player.level)), true); + source.sendSuccess(Component.literal("Entity Name: " + ItemCarryonEntity.getEntityName(main)), true); if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemCarryonEntity.getEntity(main, player.level))) - source.sendSuccess(new TextComponent("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonEntity.getEntity(main, player.level))), true); + source.sendSuccess(Component.literal("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonEntity.getEntity(main, player.level))), true); CarryOn.LOGGER.info("Entity: " + ItemCarryonEntity.getEntity(main, player.level)); CarryOn.LOGGER.info("Entity Name: " + ItemCarryonEntity.getEntityName(main)); @@ -104,15 +104,15 @@ public class CommandCarryOn for (ServerPlayer player : players) { int cleared = 0; - cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile, 64, player.inventoryMenu.getCraftSlots()); // TODO - cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity, 64, player.inventoryMenu.getCraftSlots()); + cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile.get(), 64, player.inventoryMenu.getCraftSlots()); // TODO + cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity.get(), 64, player.inventoryMenu.getCraftSlots()); CarryOn.network.send(PacketDistributor.PLAYER.with(() -> player), new CarrySlotPacket(9, player.getId())); if (cleared != 1) - source.sendSuccess(new TextComponent("Cleared " + cleared + " Items!"), true); + source.sendSuccess(Component.literal("Cleared " + cleared + " Items!"), true); else - source.sendSuccess(new TextComponent("Cleared " + cleared + " Item!"), true); + source.sendSuccess(Component.literal("Cleared " + cleared + " Item!"), true); return 1; } diff --git a/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java b/old/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java similarity index 100% rename from src/main/java/tschipp/carryon/common/config/CarryOnConfig.java rename to old/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java diff --git a/old/src/main/java/tschipp/carryon/common/config/Configs.java b/old/src/main/java/tschipp/carryon/common/config/Configs.java new file mode 100644 index 0000000..85f02c5 --- /dev/null +++ b/old/src/main/java/tschipp/carryon/common/config/Configs.java @@ -0,0 +1,329 @@ +package tschipp.carryon.common.config; + +import java.util.Arrays; +import java.util.List; + +import com.electronwill.nightconfig.core.CommentedConfig; +import com.electronwill.nightconfig.core.file.CommentedFileConfig; + +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; +import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; +import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; +import net.minecraftforge.common.ForgeConfigSpec.IntValue; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.minecraftforge.fml.event.config.ModConfigEvent; +import tschipp.carryon.CarryOn; +import tschipp.carryon.common.handler.ListHandler; + +@Mod.EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD) +public class Configs { + + private static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder(); + private static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder(); + + public static final ForgeConfigSpec SERVER_CONFIG; + public static final ForgeConfigSpec CLIENT_CONFIG; + + public static boolean SERVER_LOADED = false; + + static { + + Settings.init(SERVER_BUILDER, CLIENT_BUILDER); + Blacklist.init(SERVER_BUILDER, CLIENT_BUILDER); + WhiteList.init(SERVER_BUILDER, CLIENT_BUILDER); + ModelOverrides.init(SERVER_BUILDER, CLIENT_BUILDER); + CustomPickupConditions.init(SERVER_BUILDER, CLIENT_BUILDER); + + SERVER_CONFIG = SERVER_BUILDER.build(); + CLIENT_CONFIG = CLIENT_BUILDER.build(); + } + + @SubscribeEvent + public static void onLoad(final ModConfigEvent event) { + if (event.getConfig().getModId().equals(CarryOn.MODID) && event.getConfig().getSpec() == SERVER_CONFIG) { + SERVER_LOADED = true; + + CommentedConfig cfg = event.getConfig().getConfigData(); + + if (cfg instanceof CommentedFileConfig cfig) { + cfig.load(); + ListHandler.initConfigLists(); + } + } + } + +// @SubscribeEvent +// public static void onConfigChanged(ModConfigEvent.Reloading event) { +// if (event.getConfig().getModId().equals(CarryOn.MODID) && event.getConfig().getSpec() == SERVER_CONFIG) { +// +// CommentedConfig cfg = event.getConfig().getConfigData(); +// +// if (cfg instanceof CommentedFileConfig) +// { +// ((CommentedFileConfig) cfg).load(); +// ListHandler.initConfigLists(); +// } +// } +// } + + public static class Settings { + public static BooleanValue facePlayer; + + public static BooleanValue heavyTiles; + + public static BooleanValue pickupAllBlocks; + + public static BooleanValue slownessInCreative; + + public static DoubleValue maxDistance; + + public static DoubleValue maxEntityWidth; + + public static DoubleValue maxEntityHeight; + + public static BooleanValue pickupHostileMobs; + + public static BooleanValue heavyEntities; + + public static DoubleValue blockSlownessMultiplier; + + public static DoubleValue entitySlownessMultiplier; + + public static BooleanValue renderArms; + + public static BooleanValue allowBabies; + + public static BooleanValue useWhitelistBlocks; + + public static BooleanValue useWhitelistEntities; + + public static BooleanValue useWhitelistStacking; + + public static BooleanValue hitWhileCarrying; + + public static BooleanValue dropCarriedWhenHit; + + public static BooleanValue useScripts; + + public static BooleanValue stackableEntities; + + public static IntValue maxEntityStackLimit; + + public static BooleanValue entitySizeMattersStacking; + + public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) { + c.comment("Settings"); + s.comment("Settings"); + + s.push("settings"); + c.push("settings"); + + maxDistance = s.comment("Maximum distance from where Blocks and Entities can be picked up") + .defineInRange("maxDistance", 2.5, 0, Double.MAX_VALUE); + + maxEntityWidth = s.comment("Max width of entities that can be picked up in survival mode") + .defineInRange("maxEntityWidth", 1.5, 0, 10); + + maxEntityHeight = s.comment("Max height of entities that can be picked up in survival mode") + .defineInRange("maxEntityHeight", 2.0, 0, 10); + + blockSlownessMultiplier = s.comment("Slowness multiplier for blocks") + .defineInRange("blockSlownessMultiplier", 1, 0, Double.MAX_VALUE); + + entitySlownessMultiplier = s.comment("Slowness multiplier for entities") + .defineInRange("entitySlownessMultiplier", 1, 0, Double.MAX_VALUE); + + maxEntityStackLimit = s.comment("Maximum stack limit for entities").defineInRange("maxEntityStackLimit", 10, + 1, Integer.MAX_VALUE); + + facePlayer = c.comment("If the front of the Tile Entities should face the player or should face outward") + .define("facePlayer", false); + + heavyTiles = s.comment("More complex Tile Entities slow down the player more").define("heavyTiles", true); + + pickupAllBlocks = s.comment("Allow all blocks to be picked up, not just Tile Entites") + .define("pickupAllBlocks", false); + + slownessInCreative = s.comment("Whether Blocks and Entities slow the creative player down when carried") + .define("slownessInCreative", true); + + pickupHostileMobs = s.comment("Whether hostile mobs should be able to picked up in survival mode") + .define("pickupHostileMobs", false); + + heavyEntities = s.comment("Larger Entities slow down the player more").define("heavyEntities", true); + + renderArms = c.comment("Arms should render on sides when carrying").define("renderArms", true); + + allowBabies = s + .comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)") + .define("allowBabies", false); + + useWhitelistBlocks = s.comment("Use Whitelist instead of Blacklist for Blocks").define("useWhitelistBlocks", + false); + + useWhitelistEntities = s.comment("Use Whitelist instead of Blacklist for Entities") + .define("useWhitelistEntities", false); + + useWhitelistStacking = s.comment("Use Whitelist instead of Blacklist for Stacking") + .define("useWhitelistStacking", false); + + hitWhileCarrying = s.comment("Whether the player can hit blocks and entities while carrying or not") + .define("hitWhileCarrying", false); + + dropCarriedWhenHit = s.comment("Whether the player drops the carried object when hit or not") + .define("dropCarriedWhenHit", false); + + useScripts = s.comment( + "Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance") + .worldRestart().define("useScripts", false); + + stackableEntities = s.comment("Allows entities to be stacked using Carry On").define("stackableEntities", + true); + + entitySizeMattersStacking = s.comment("Whether entities' size matters when stacking or not") + .define("stackableEntities", true); + + s.pop(); + c.pop(); + + } + + } + + public static class WhiteList { + public static ConfigValue> allowedEntities; + + public static ConfigValue> allowedBlocks; + + public static ConfigValue> allowedStacking; + + public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) { + s.comment( + "Whitelist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config"); + + allowedEntities = s.comment("Entities that CAN be picked up (useWhitelistEntities must be true)") + .defineList("whitelist.allowedEntities", Arrays.asList(), + obj -> obj instanceof String ? true : false); + + allowedBlocks = s.comment("Blocks that CAN be picked up (useWhitelistBlocks must be true)").defineList( + "whitelist.allowedBlocks", Arrays.asList(), obj -> obj instanceof String ? true : false); + + allowedStacking = s.comment( + "Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)") + .defineList("whitelist.allowedStacking", Arrays.asList(), + obj -> obj instanceof String ? true : false); + } + } + + public static class Blacklist { + public static ConfigValue> forbiddenTiles; + + public static ConfigValue> forbiddenEntities; + + public static ConfigValue> forbiddenStacking; + + public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) { + s.comment( + "Blacklist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config"); + + forbiddenTiles = s.comment("Blocks that cannot be picked up").defineList("blacklist.forbiddenTiles", + Arrays.asList("#forge:immovable", "#forge:relocation_not_supported", "minecraft:end_portal", + "minecraft:end_gateway", "minecraft:tall_grass", "minecraft:large_fern", "minecraft:peony", + "minecraft:rose_bush", "minecraft:lilac", "minecraft:sunflower", "minecraft:*_bed", + "minecraft:oak_door", "minecraft:iron_door", "minecraft:spruce_door", + "minecraft:birch_door", "minecraft:jungle_door", "minecraft:acacia_door", + "minecraft:dark_oak_door", "minecraft:waterlily", "minecraft:cake", + "minecraft:nether_portal", "minecraft:tall_seagrass", "animania:block_trough", + "animania:block_invisiblock", "colossalchests:*", "ic2:*", "bigreactors:*", "forestry:*", + "tconstruct:*", "rustic:*", "botania:*", "astralsorcery:*", "quark:colored_bed_*", + "immersiveengineering:*", "embers:block_furnace", "embers:ember_bore", + "embers:ember_activator", "embers:mixer", "embers:heat_coil", "embers:large_tank", + "embers:crystal_cell", "embers:alchemy_pedestal", "embers:boiler", "embers:combustor", + "embers:catalzyer", "embers:field_chart", "embers:inferno_forge", + "storagedrawers:framingtable", "skyresources:*", "lootbags:*", "exsartagine:*", + "aquamunda:tank", "opencomputers:*", "malisisdoors:*", "industrialforegoing:*", + "minecolonies:*", "thaumcraft:pillar*", "thaumcraft:infernal_furnace", + "thaumcraft:placeholder*", "thaumcraft:infusion_matrix", "thaumcraft:golem_builder", + "thaumcraft:thaumatorium*", "magneticraft:oil_heater", "magneticraft:solar_panel", + "magneticraft:steam_engine", "magneticraft:shelving_unit", "magneticraft:grinder", + "magneticraft:sieve", "magneticraft:solar_tower", "magneticraft:solar_mirror", + "magneticraft:container", "magneticraft:pumpjack", "magneticraft:solar_panel", + "magneticraft:refinery", "magneticraft:oil_heater", "magneticraft:hydraulic_press", + "magneticraft:multiblock_gap", "refinedstorage:*", "mcmultipart:*", "enderstorage:*", + "betterstorage:*", "practicallogistics2:*", "wearablebackpacks:*", "rftools:screen", + "rftools:creative_screen", "create:*", "magic_doorknob:*", "iceandfire:*", "ftbquests:*", + "waystones:*"), + obj -> obj instanceof String); + + forbiddenEntities = s.comment("Entities that cannot be picked up").defineList("blacklist.forbiddenEntities", + Arrays.asList("minecraft:end_crystal", "minecraft:ender_dragon", "minecraft:ghast", + "minecraft:shulker", "minecraft:leash_knot", "minecraft:armor_stand", + "minecraft:item_frame", "minecraft:painting", "minecraft:shulker_bullet", + "animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart", + "animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*"), + obj -> obj instanceof String ? true : false); + + forbiddenStacking = s.comment("Entities that cannot have other entities stacked on top of them").defineList( + "blacklist.forbiddenStacking", Arrays.asList("minecraft:horse"), + obj -> obj instanceof String ? true : false); + } + + } + + public static class ModelOverrides { + public static ConfigValue> modelOverrides; + + public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) { + c.comment( + "Model Overrides. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config"); + + modelOverrides = c.comment("Model Overrides based on NBT or on Meta. Advanced Users Only!").defineList( + "modeloverrides.overrides", + Arrays.asList("minecraft:hopper->(block)minecraft:hopper", + "minecraft:comparator->(block)minecraft:comparator", + "minecraft:repeater->(block)minecraft:repeater", + "minecraft:cauldron->(block)minecraft:cauldron", + "minecraft:brewing_stand->(item)minecraft:brewing_stand", + "minecraft:flower_pot->(block)minecraft:flower_pot", + "minecraft:sugar_cane->(block)minecraft:sugar_cane", + "minecraft:redstone_wire->(item)minecraft:redstone", + "animania:block_nest->(block)animania:block_nest", + "animania:cheese_mold;0->(block)animania:cheese_mold;0", + "animania:cheese_mold;1->(block)animania:cheese_mold;1", + "animania:cheese_mold;2->(block)animania:cheese_mold;2", + "animania:cheese_mold;3->(block)animania:cheese_mold;3", + "animania:cheese_mold;4->(block)animania:cheese_mold;4", + "animania:cheese_mold;5->(block)animania:cheese_mold;5", + "animania:cheese_mold;6->(block)animania:cheese_mold;6", + "animania:cheese_mold;7->(block)animania:cheese_mold;7", + "animania:cheese_mold;8->(block)animania:cheese_mold;8", + "animania:cheese_mold;9->(block)animania:cheese_mold;9", + "animania:cheese_mold;10->(block)animania:cheese_mold;10"), + obj -> obj instanceof String ? true : false); + } + } + + public static class CustomPickupConditions { + + public static ConfigValue> customPickupConditionsBlocks; + + public static ConfigValue> customPickupConditionsEntities; + + public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) { + s.comment( + "Custom Pickup Conditions. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Custom-Pickup-Condition-Config"); + + customPickupConditionsBlocks = s.comment("Custom Pickup Conditions for Blocks").defineList( + "custom_pickup_conditions.customPickupConditionsBlocks", Arrays.asList(), + obj -> obj instanceof String ? true : false); + + customPickupConditionsEntities = s.comment("Custom Pickup Conditions for Entities").defineList( + "custom_pickup_conditions.customPickupConditionsEntities", Arrays.asList(), + obj -> obj instanceof String ? true : false); + } + } + +} diff --git a/src/main/java/tschipp/carryon/common/event/IMCEvents.java b/old/src/main/java/tschipp/carryon/common/event/IMCEvents.java similarity index 100% rename from src/main/java/tschipp/carryon/common/event/IMCEvents.java rename to old/src/main/java/tschipp/carryon/common/event/IMCEvents.java diff --git a/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java b/old/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java similarity index 91% rename from src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java rename to old/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java index e3f0653..b85ec59 100644 --- a/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java +++ b/old/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java @@ -19,8 +19,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Material; import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.EntityJoinLevelEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingTickEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.EventPriority; @@ -42,9 +42,9 @@ public class ItemEntityEvents @SubscribeEvent(priority = EventPriority.HIGH) public void onBlockClick(PlayerInteractEvent.RightClickBlock event) { - Player player = event.getPlayer(); + Player player = event.getEntity(); ItemStack stack = player.getMainHandItem(); - if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)) + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(stack)) { player.getPersistentData().remove("carrySlot"); event.setUseBlock(Result.DENY); @@ -65,15 +65,15 @@ public class ItemEntityEvents } @SubscribeEvent(priority = EventPriority.HIGH) - public void onItemDropped(EntityJoinWorldEvent event) + public void onItemDropped(EntityJoinLevelEvent event) { Entity e = event.getEntity(); - Level level = event.getWorld(); + Level level = event.getLevel(); if (e instanceof net.minecraft.world.entity.item.ItemEntity eitem) { ItemStack stack = eitem.getItem(); Item item = stack.getItem(); - if (item == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)) + if (item == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(stack)) { BlockPos pos = eitem.blockPosition(); Entity entity = ItemCarryonEntity.getEntity(stack, level); @@ -89,19 +89,19 @@ public class ItemEntityEvents @SubscribeEvent(priority = EventPriority.HIGH) public void onEntityRightClick(PlayerInteractEvent.EntityInteract event) { - Player player = event.getPlayer(); + Player player = event.getEntity(); if (player instanceof ServerPlayer) { ItemStack main = player.getMainHandItem(); ItemStack off = player.getOffhandItem(); - Level level = event.getWorld(); + Level level = event.getLevel(); Entity entity = event.getTarget(); BlockPos pos = entity.blockPosition(); if (main.isEmpty() && off.isEmpty() && CarryOnKeybinds.isKeyPressed(player)) { - ItemStack stack = new ItemStack(RegistrationHandler.itemEntity); + ItemStack stack = new ItemStack(RegistrationHandler.itemEntity.get()); if (entity.invulnerableTime == 0) { @@ -139,7 +139,7 @@ public class ItemEntityEvents } } - else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(main) && !CarryOnKeybinds.isKeyPressed(player) && Settings.stackableEntities.get()) + else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(main) && !CarryOnKeybinds.isKeyPressed(player) && Settings.stackableEntities.get()) { Entity entityHeld = ItemCarryonEntity.getEntity(main, level); @@ -243,12 +243,12 @@ public class ItemEntityEvents } @SubscribeEvent - public void onLivingUpdate(LivingUpdateEvent event) + public void onLivingUpdate(LivingTickEvent event) { - LivingEntity entity = event.getEntityLiving(); + LivingEntity entity = event.getEntity(); Level level = entity.level; ItemStack main = entity.getMainHandItem(); - if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(main)) + if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(main)) { BlockPos pos = entity.blockPosition(); BlockPos below = pos.relative(Direction.DOWN); diff --git a/src/main/java/tschipp/carryon/common/event/ItemEvents.java b/old/src/main/java/tschipp/carryon/common/event/ItemEvents.java similarity index 87% rename from src/main/java/tschipp/carryon/common/event/ItemEvents.java rename to old/src/main/java/tschipp/carryon/common/event/ItemEvents.java index 8989074..cba0ba7 100644 --- a/src/main/java/tschipp/carryon/common/event/ItemEvents.java +++ b/old/src/main/java/tschipp/carryon/common/event/ItemEvents.java @@ -8,7 +8,7 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.ClickEvent.Action; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; @@ -27,16 +27,17 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.event.TagsUpdatedEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.EntityJoinLevelEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent; -import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingTickEvent; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent; import net.minecraftforge.event.entity.player.PlayerEvent.StartTracking; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.event.world.BlockEvent.BreakEvent; +import net.minecraftforge.event.level.BlockEvent.BreakEvent; +import net.minecraftforge.event.level.LevelEvent; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -49,6 +50,7 @@ import net.minecraftforge.network.PacketDistributor.TargetPoint; import tschipp.carryon.CarryOn; import tschipp.carryon.client.keybinds.CarryOnKeybinds; import tschipp.carryon.common.command.CommandCarryOn; +import tschipp.carryon.common.config.Configs; import tschipp.carryon.common.config.Configs.Settings; import tschipp.carryon.common.handler.CustomPickupOverrideHandler; import tschipp.carryon.common.handler.ListHandler; @@ -71,9 +73,9 @@ public class ItemEvents if (event.isCanceled()) return; - Player player = event.getPlayer(); + Player player = event.getEntity(); ItemStack stack = player.getMainHandItem(); - if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile.get() && ItemCarryonBlock.hasTileData(stack)) { player.getPersistentData().remove("carrySlot"); event.setUseBlock(Result.DENY); @@ -94,15 +96,15 @@ public class ItemEvents } @SubscribeEvent(priority = EventPriority.HIGH) - public void onItemDropped(EntityJoinWorldEvent event) + public void onItemDropped(EntityJoinLevelEvent event) { Entity e = event.getEntity(); - Level level = event.getWorld(); + Level level = event.getLevel(); if (e instanceof net.minecraft.world.entity.item.ItemEntity eitem) { ItemStack stack = eitem.getItem(); Item item = stack.getItem(); - if (item == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) + if (item == RegistrationHandler.itemTile.get() && ItemCarryonBlock.hasTileData(stack)) { BlockPos pos = eitem.blockPosition(); BlockPos finalPos = pos; @@ -146,15 +148,15 @@ public class ItemEvents @SubscribeEvent public void onPlayerLogin(PlayerLoggedInEvent event) { - if (event.getPlayer() instanceof Player) + if (event.getEntity() instanceof Player) { - Player player = event.getPlayer(); + Player player = event.getEntity(); Level level = player.getCommandSenderWorld(); ItemStack carried = player.getMainHandItem(); - if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile || carried.getItem() == RegistrationHandler.itemEntity) + if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile.get() || carried.getItem() == RegistrationHandler.itemEntity.get()) { - if (carried.getItem() == RegistrationHandler.itemTile) + if (carried.getItem() == RegistrationHandler.itemTile.get()) { CarryOnOverride override = ScriptChecker.inspectBlock(ItemCarryonBlock.getBlockState(carried), level, player.blockPosition(), ItemCarryonBlock.getTileData(carried)); if (override != null) @@ -174,9 +176,9 @@ public class ItemEvents } } - if (event.getPlayer() instanceof ServerPlayer) + if (event.getEntity() instanceof ServerPlayer) { - CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getPlayer()), new ScriptReloadPacket(ScriptReader.OVERRIDES.values())); + CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new ScriptReloadPacket(ScriptReader.OVERRIDES.values())); } } @@ -197,21 +199,27 @@ public class ItemEvents { ListHandler.initConfigLists(); } + + @SubscribeEvent + public void unloadWorld(LevelEvent.Unload event) + { + Configs.SERVER_LOADED = false; + } @SubscribeEvent public void onEntityStartTracking(StartTracking event) { Entity e = event.getTarget(); - Player tracker = event.getPlayer(); + Player tracker = event.getEntity(); if (e instanceof Player player && tracker instanceof ServerPlayer) { Level level = player.getCommandSenderWorld(); ItemStack carried = player.getMainHandItem(); - if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile || carried.getItem() == RegistrationHandler.itemEntity) + if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile.get() || carried.getItem() == RegistrationHandler.itemEntity.get()) { - if (carried.getItem() == RegistrationHandler.itemTile) + if (carried.getItem() == RegistrationHandler.itemTile.get()) { CarryOnOverride override = ScriptChecker.inspectBlock(ItemCarryonBlock.getBlockState(carried), level, player.blockPosition(), ItemCarryonBlock.getTileData(carried)); if (override != null) @@ -235,11 +243,11 @@ public class ItemEvents @SubscribeEvent public void harvestSpeed(BreakSpeed event) { - Player player = event.getPlayer(); + Player player = event.getEntity(); if (player != null && !Settings.hitWhileCarrying.get()) { ItemStack stack = player.getMainHandItem(); - if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity)) + if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile.get() || stack.getItem() == RegistrationHandler.itemEntity.get())) event.setNewSpeed(0); } } @@ -247,9 +255,9 @@ public class ItemEvents @SubscribeEvent public void attackEntity(AttackEntityEvent event) { - Player player = event.getPlayer(); + Player player = event.getEntity(); ItemStack stack = player.getMainHandItem(); - if (!stack.isEmpty() && !Settings.hitWhileCarrying.get() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity)) + if (!stack.isEmpty() && !Settings.hitWhileCarrying.get() && (stack.getItem() == RegistrationHandler.itemTile.get() || stack.getItem() == RegistrationHandler.itemEntity.get())) { event.setCanceled(true); } @@ -262,7 +270,7 @@ public class ItemEvents if (player != null && !Settings.hitWhileCarrying.get()) { ItemStack stack = player.getMainHandItem(); - if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity)) + if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile.get() || stack.getItem() == RegistrationHandler.itemEntity.get())) event.setCanceled(true); } } @@ -270,11 +278,11 @@ public class ItemEvents @SubscribeEvent public void playerAttack(LivingAttackEvent event) { - LivingEntity eliving = event.getEntityLiving(); + LivingEntity eliving = event.getEntity(); if (eliving instanceof Player player && Settings.dropCarriedWhenHit.get()) { ItemStack stack = player.getMainHandItem(); - if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity) && !player.level.isClientSide) + if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile.get() || stack.getItem() == RegistrationHandler.itemEntity.get()) && !player.level.isClientSide) { player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY); ItemEntity item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), stack); @@ -288,7 +296,7 @@ public class ItemEvents @SubscribeEvent(priority = EventPriority.HIGH) public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) { - Player player = event.getPlayer(); + Player player = event.getEntity(); if (event.isCanceled()) return; @@ -298,14 +306,14 @@ public class ItemEvents ItemStack main = player.getMainHandItem(); ItemStack off = player.getOffhandItem(); - Level level = event.getWorld(); + Level level = event.getLevel(); BlockPos pos = event.getPos(); BlockState state = level.getBlockState(pos); if (main.isEmpty() && off.isEmpty() && CarryOnKeybinds.isKeyPressed(player)) { - ItemStack stack = new ItemStack(RegistrationHandler.itemTile); + ItemStack stack = new ItemStack(RegistrationHandler.itemTile.get()); BlockEntity te = level.getBlockEntity(pos); if (PickupHandler.canPlayerPickUpBlock((ServerPlayer) player, te, level, pos)) @@ -360,10 +368,10 @@ public class ItemEvents BlockEntity.loadStatic(pos, statee, tag); } - player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Error detected. Cannot pick up block."), false); - TextComponent s = new TextComponent(ChatFormatting.GOLD + "here"); + player.displayClientMessage(Component.literal(ChatFormatting.RED + "Error detected. Cannot pick up block."), false); + Component s = Component.literal(ChatFormatting.GOLD + "here"); s.getStyle().withClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues")); - player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Please report this error ").append(s), false); + player.displayClientMessage(Component.literal(ChatFormatting.RED + "Please report this error ").append(s), false); } } @@ -433,11 +441,11 @@ public class ItemEvents public void onRespawn(PlayerEvent.Clone event) { Player original = event.getOriginal(); - Player player = event.getPlayer(); + Player player = event.getEntity(); boolean wasDead = event.isWasDeath(); GameRules rules = player.level.getGameRules(); boolean keepInv = rules.getBoolean(GameRules.RULE_KEEPINVENTORY); - boolean wasCarrying = player.getInventory().contains(new ItemStack(RegistrationHandler.itemTile)) || player.getInventory().contains(new ItemStack(RegistrationHandler.itemEntity)); + boolean wasCarrying = player.getInventory().contains(new ItemStack(RegistrationHandler.itemTile.get())) || player.getInventory().contains(new ItemStack(RegistrationHandler.itemEntity.get())); if ((wasDead ? keepInv : true) && wasCarrying) { @@ -460,18 +468,18 @@ public class ItemEvents } @SubscribeEvent - public void dropNonHotbarItems(LivingUpdateEvent event) + public void dropNonHotbarItems(LivingTickEvent event) { - LivingEntity entity = event.getEntityLiving(); + LivingEntity entity = event.getEntity(); if (entity instanceof Player player && !entity.level.isClientSide) { - boolean hasCarried = player.getInventory().contains(new ItemStack(RegistrationHandler.itemTile)) || player.getInventory().contains(new ItemStack(RegistrationHandler.itemEntity)); + boolean hasCarried = player.getInventory().contains(new ItemStack(RegistrationHandler.itemTile.get())) || player.getInventory().contains(new ItemStack(RegistrationHandler.itemEntity.get())); ItemStack inHand = player.getMainHandItem(); - if (hasCarried && inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity && player.getDimensionChangingDelay() == 0) + if (hasCarried && inHand.getItem() != RegistrationHandler.itemTile.get() && inHand.getItem() != RegistrationHandler.itemEntity.get() && player.getDimensionChangingDelay() == 0) { - int slotBlock = this.getSlot(player, RegistrationHandler.itemTile); - int slotEntity = this.getSlot(player, RegistrationHandler.itemEntity); + int slotBlock = this.getSlot(player, RegistrationHandler.itemTile.get()); + int slotEntity = this.getSlot(player, RegistrationHandler.itemEntity.get()); ItemEntity item = null; if (slotBlock != -1) diff --git a/src/main/java/tschipp/carryon/common/handler/CustomPickupOverrideHandler.java b/old/src/main/java/tschipp/carryon/common/handler/CustomPickupOverrideHandler.java similarity index 81% rename from src/main/java/tschipp/carryon/common/handler/CustomPickupOverrideHandler.java rename to old/src/main/java/tschipp/carryon/common/handler/CustomPickupOverrideHandler.java index edff1cb..9cb629a 100644 --- a/src/main/java/tschipp/carryon/common/handler/CustomPickupOverrideHandler.java +++ b/old/src/main/java/tschipp/carryon/common/handler/CustomPickupOverrideHandler.java @@ -3,16 +3,13 @@ package tschipp.carryon.common.handler; import java.util.HashMap; import java.util.List; -import com.mojang.brigadier.StringReader; -import com.mojang.brigadier.exceptions.CommandSyntaxException; - -import net.minecraft.commands.arguments.blocks.BlockStateParser; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.fml.ModList; import net.minecraftforge.registries.ForgeRegistries; import tschipp.carryon.common.config.Configs.CustomPickupConditions; import tschipp.carryon.common.helper.InvalidConfigException; +import tschipp.carryon.common.helper.StringParser; public class CustomPickupOverrideHandler { @@ -85,15 +82,7 @@ public class CustomPickupOverrideHandler for (String cond : PICKUP_CONDITIONS.keySet()) { - BlockStateParser parser = new BlockStateParser(new StringReader(cond), false); - try - { - parser.parse(false); - } - catch (CommandSyntaxException e) - { - } - if (parser.getState() == state) + if(state == StringParser.getBlockState(cond)); return true; } @@ -104,15 +93,7 @@ public class CustomPickupOverrideHandler { for (String cond : PICKUP_CONDITIONS.keySet()) { - BlockStateParser parser = new BlockStateParser(new StringReader(cond), false); - try - { - parser.parse(false); - } - catch (CommandSyntaxException e) - { - } - if (parser.getState() == state) + if(state == StringParser.getBlockState(cond)); return PICKUP_CONDITIONS.get(cond); } return null; @@ -123,13 +104,13 @@ public class CustomPickupOverrideHandler if (!ModList.get().isLoaded("gamestages")) return false; - String name = entity.getType().getRegistryName().toString(); + String name = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()).toString(); return PICKUP_CONDITIONS_ENTITIES.containsKey(name); } public static String getPickupCondition(Entity entity) { - String name = entity.getType().getRegistryName().toString(); + String name = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()).toString(); return PICKUP_CONDITIONS_ENTITIES.get(name); } diff --git a/src/main/java/tschipp/carryon/common/handler/ListHandler.java b/old/src/main/java/tschipp/carryon/common/handler/ListHandler.java similarity index 86% rename from src/main/java/tschipp/carryon/common/handler/ListHandler.java rename to old/src/main/java/tschipp/carryon/common/handler/ListHandler.java index 384d5b4..a8ec5eb 100644 --- a/src/main/java/tschipp/carryon/common/handler/ListHandler.java +++ b/old/src/main/java/tschipp/carryon/common/handler/ListHandler.java @@ -12,6 +12,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.block.Block; import net.minecraftforge.registries.ForgeRegistries; +import tschipp.carryon.common.config.Configs; import tschipp.carryon.common.config.Configs.Blacklist; import tschipp.carryon.common.config.Configs.WhiteList; @@ -33,7 +34,7 @@ public class ListHandler public static boolean isForbidden(Block block) { - String name = block.getRegistryName().toString(); + String name = ForgeRegistries.BLOCKS.getKey(block).toString(); if (FORBIDDEN_TILES.contains(name)) return true; else @@ -51,7 +52,7 @@ public class ListHandler for (TagKey tag : FORBIDDEN_TILES_TAGS) { - if (block.defaultBlockState().m_204336_(tag)) + if (block.defaultBlockState().is(tag)) return true; } @@ -61,12 +62,12 @@ public class ListHandler public static boolean isForbidden(Entity entity) { - String name = entity.getType().getRegistryName().toString(); + String name = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()).toString(); boolean contains = FORBIDDEN_ENTITIES.contains(name); for (TagKey> tag : FORBIDDEN_ENTITIES_TAGS) { - if (entity.getType().m_204039_(tag)) + if (entity.getType().is(tag)) return true; } @@ -75,12 +76,12 @@ public class ListHandler public static boolean isAllowed(Entity entity) { - String name = entity.getType().getRegistryName().toString(); + String name = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()).toString(); boolean contains = ALLOWED_ENTITIES.contains(name); for (TagKey> tag : ALLOWED_ENTITIES_TAGS) { - if (entity.getType().m_204039_(tag)) + if (entity.getType().is(tag)) return true; } @@ -89,12 +90,12 @@ public class ListHandler public static boolean isStackingForbidden(Entity entity) { - String name = entity.getType().getRegistryName().toString(); + String name = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()).toString(); boolean contains = FORBIDDEN_STACKING.contains(name); for (TagKey> tag : FORBIDDEN_STACKING_TAGS) { - if (entity.getType().m_204039_(tag)) + if (entity.getType().is(tag)) return true; } @@ -103,12 +104,12 @@ public class ListHandler public static boolean isStackingAllowed(Entity entity) { - String name = entity.getType().getRegistryName().toString(); + String name = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()).toString(); boolean contains = ALLOWED_STACKING.contains(name); for (TagKey> tag : ALLOWED_STACKING_TAGS) { - if (entity.getType().m_204039_(tag)) + if (entity.getType().is(tag)) return true; } @@ -117,7 +118,7 @@ public class ListHandler public static boolean isAllowed(Block block) { - String name = block.getRegistryName().toString(); + String name = ForgeRegistries.BLOCKS.getKey(block).toString(); if (ALLOWED_TILES.contains(name)) return true; else @@ -135,7 +136,7 @@ public class ListHandler for (TagKey tag : ALLOWED_TILES_TAGS) { - if (block.defaultBlockState().m_204336_(tag)) + if (block.defaultBlockState().is(tag)) return true; } @@ -147,6 +148,9 @@ public class ListHandler @SuppressWarnings("deprecation") public static void initConfigLists() { + if(!Configs.SERVER_LOADED) + return; + FORBIDDEN_ENTITIES.clear(); FORBIDDEN_ENTITIES_TAGS.clear(); FORBIDDEN_STACKING.clear(); @@ -182,7 +186,7 @@ public class ListHandler { String[] filter = forbiddenEntity.get(i).replace("*", ",").split(","); - ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]); + ResourceLocation[] keys = ForgeRegistries.ENTITY_TYPES.getKeys().toArray(new ResourceLocation[0]); for (ResourceLocation key : keys) { if (containsAll(key.toString(), filter)) @@ -206,7 +210,7 @@ public class ListHandler { String[] filter = allowedEntities.get(i).replace("*", ",").split(","); - ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]); + ResourceLocation[] keys = ForgeRegistries.ENTITY_TYPES.getKeys().toArray(new ResourceLocation[0]); for (ResourceLocation key : keys) { if (containsAll(key.toString(), filter)) @@ -240,7 +244,7 @@ public class ListHandler { String[] filter = forbiddenStacking.get(i).replace("*", ",").split(","); - ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]); + ResourceLocation[] keys = ForgeRegistries.ENTITY_TYPES.getKeys().toArray(new ResourceLocation[0]); for (ResourceLocation key : keys) { if (containsAll(key.toString(), filter)) @@ -264,7 +268,7 @@ public class ListHandler { String[] filter = allowedStacking.get(i).replace("*", ",").split(","); - ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]); + ResourceLocation[] keys = ForgeRegistries.ENTITY_TYPES.getKeys().toArray(new ResourceLocation[0]); for (ResourceLocation key : keys) { if (containsAll(key.toString(), filter)) @@ -277,8 +281,9 @@ public class ListHandler } } - Map> blocktags = Registry.BLOCK.m_203613_().collect(Collectors.toMap(t -> t.f_203868_(), t -> t)); - Map>> entitytags = Registry.ENTITY_TYPE.m_203613_().collect(Collectors.toMap(t -> t.f_203868_(), t -> t)); + + Map> blocktags = Registry.BLOCK.getTagNames().collect(Collectors.toMap(t -> t.location(), t -> t)); + Map>> entitytags = Registry.ENTITY_TYPE.getTagNames().collect(Collectors.toMap(t -> t.location(), t -> t)); diff --git a/src/main/java/tschipp/carryon/common/handler/ModelOverridesHandler.java b/old/src/main/java/tschipp/carryon/common/handler/ModelOverridesHandler.java similarity index 96% rename from src/main/java/tschipp/carryon/common/handler/ModelOverridesHandler.java rename to old/src/main/java/tschipp/carryon/common/handler/ModelOverridesHandler.java index 70dc0f1..d5df5da 100644 --- a/src/main/java/tschipp/carryon/common/handler/ModelOverridesHandler.java +++ b/old/src/main/java/tschipp/carryon/common/handler/ModelOverridesHandler.java @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.ModList; +import net.minecraftforge.registries.ForgeRegistries; import tschipp.carryon.common.config.Configs.ModelOverrides; import tschipp.carryon.common.helper.InvalidConfigException; import tschipp.carryon.common.helper.StringParser; @@ -131,12 +132,12 @@ public class ModelOverridesHandler keyComp.put("nbttag", tag); if (toOverrideObject instanceof Block) { - keyComp.putString("block", ((Block) toOverrideObject).getRegistryName().toString()); + keyComp.putString("block", ForgeRegistries.BLOCKS.getKey(((Block) toOverrideObject)).toString()); } else { keyComp.putInt("stateid", Block.getId((BlockState) toOverrideObject)); - keyComp.putString("block", ((BlockState) toOverrideObject).getBlock().getRegistryName().toString()); + keyComp.putString("block", ForgeRegistries.BLOCKS.getKey(((BlockState) toOverrideObject).getBlock()).toString()); } OVERRIDE_OBJECTS.put(keyComp, overrideObject); } diff --git a/src/main/java/tschipp/carryon/common/handler/PickupHandler.java b/old/src/main/java/tschipp/carryon/common/handler/PickupHandler.java similarity index 96% rename from src/main/java/tschipp/carryon/common/handler/PickupHandler.java rename to old/src/main/java/tschipp/carryon/common/handler/PickupHandler.java index 83b1bb1..49cf777 100644 --- a/src/main/java/tschipp/carryon/common/handler/PickupHandler.java +++ b/old/src/main/java/tschipp/carryon/common/handler/PickupHandler.java @@ -19,7 +19,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.AttackEntityEvent; -import net.minecraftforge.event.world.BlockEvent; +import net.minecraftforge.event.level.BlockEvent; import tschipp.carryon.common.config.Configs.Settings; import tschipp.carryon.common.helper.CarryonGamestageHelper; import tschipp.carryon.common.item.ItemCarryonBlock; @@ -103,7 +103,7 @@ public class PickupHandler { double distance = pos.distanceToSqr(player.position()); - if (distance <= Math.pow(Settings.maxDistance.get(), 2) && toPickUp instanceof TamableAnimal tame && tame.getOwnerUUID() != null && tame.getOwnerUUID() != Player.createPlayerUUID(player.getGameProfile())) + if (distance <= Math.pow(Settings.maxDistance.get(), 2) && toPickUp instanceof TamableAnimal tame && tame.getOwnerUUID() != null && tame.getOwnerUUID() != player.getGameProfile().getId()) return false; if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp)) @@ -136,7 +136,7 @@ public class PickupHandler if (toPickUp instanceof TamableAnimal tame) { UUID owner = tame.getOwnerUUID(); - UUID playerID = Player.createPlayerUUID(player.getGameProfile()); + UUID playerID = player.getGameProfile().getId(); if (owner != null && !owner.equals(playerID)) return false; } diff --git a/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java b/old/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java similarity index 74% rename from src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java rename to old/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java index 3b62dfd..08c120c 100644 --- a/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java +++ b/old/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java @@ -6,7 +6,10 @@ import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; -import net.minecraftforge.registries.ObjectHolder; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import tschipp.carryon.CarryOn; import tschipp.carryon.client.event.RenderEntityEvents; import tschipp.carryon.client.event.RenderEvents; @@ -22,18 +25,17 @@ import tschipp.carryon.common.item.ItemCarryonEntity; @EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD) public class RegistrationHandler { - @ObjectHolder("carryon:tile_item") - public static Item itemTile; + + private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, CarryOn.MODID); - @ObjectHolder("carryon:entity_item") - public static Item itemEntity; + public static final RegistryObject itemTile = ITEMS.register("tile_item", () -> new ItemCarryonBlock()); + public static final RegistryObject itemEntity = ITEMS.register("entity_item", () -> new ItemCarryonEntity()); - public static void regItems() - { - itemTile = new ItemCarryonBlock(); - itemEntity = new ItemCarryonEntity(); + + public static void init() { + ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); } - + public static void regCommonEvents() { MinecraftForge.EVENT_BUS.register(new ItemEvents()); diff --git a/src/main/java/tschipp/carryon/common/helper/CarryonGamestageHelper.java b/old/src/main/java/tschipp/carryon/common/helper/CarryonGamestageHelper.java similarity index 100% rename from src/main/java/tschipp/carryon/common/helper/CarryonGamestageHelper.java rename to old/src/main/java/tschipp/carryon/common/helper/CarryonGamestageHelper.java diff --git a/src/main/java/tschipp/carryon/common/helper/InvalidConfigException.java b/old/src/main/java/tschipp/carryon/common/helper/InvalidConfigException.java similarity index 100% rename from src/main/java/tschipp/carryon/common/helper/InvalidConfigException.java rename to old/src/main/java/tschipp/carryon/common/helper/InvalidConfigException.java diff --git a/src/main/java/tschipp/carryon/common/helper/KeyboardCallbackWrapper.java b/old/src/main/java/tschipp/carryon/common/helper/KeyboardCallbackWrapper.java similarity index 100% rename from src/main/java/tschipp/carryon/common/helper/KeyboardCallbackWrapper.java rename to old/src/main/java/tschipp/carryon/common/helper/KeyboardCallbackWrapper.java diff --git a/src/main/java/tschipp/carryon/common/helper/ReflectionHelper.java b/old/src/main/java/tschipp/carryon/common/helper/ReflectionHelper.java similarity index 100% rename from src/main/java/tschipp/carryon/common/helper/ReflectionHelper.java rename to old/src/main/java/tschipp/carryon/common/helper/ReflectionHelper.java diff --git a/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java b/old/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java similarity index 100% rename from src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java rename to old/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java diff --git a/src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java b/old/src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java similarity index 98% rename from src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java rename to old/src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java index 2996f47..b73eef1 100644 --- a/src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java +++ b/old/src/main/java/tschipp/carryon/common/helper/ScriptParseHelper.java @@ -15,6 +15,7 @@ import net.minecraft.world.level.material.Material; import net.minecraft.world.scores.Objective; import net.minecraft.world.scores.Score; import net.minecraft.world.scores.Scoreboard; +import net.minecraftforge.registries.ForgeRegistries; public class ScriptParseHelper { @@ -256,7 +257,7 @@ public class ScriptParseHelper for (MobEffectInstance effect : effects) { int amp = effect.getAmplifier(); - String name = effect.getEffect().getRegistryName().toString(); + String name = ForgeRegistries.MOB_EFFECTS.getKey(effect.getEffect()).toString(); if (names.contains(name)) { diff --git a/src/main/java/tschipp/carryon/common/helper/ScrollCallbackWrapper.java b/old/src/main/java/tschipp/carryon/common/helper/ScrollCallbackWrapper.java similarity index 100% rename from src/main/java/tschipp/carryon/common/helper/ScrollCallbackWrapper.java rename to old/src/main/java/tschipp/carryon/common/helper/ScrollCallbackWrapper.java diff --git a/src/main/java/tschipp/carryon/common/helper/StringParser.java b/old/src/main/java/tschipp/carryon/common/helper/StringParser.java similarity index 77% rename from src/main/java/tschipp/carryon/common/helper/StringParser.java rename to old/src/main/java/tschipp/carryon/common/helper/StringParser.java index 1a4ba08..668ffa7 100644 --- a/src/main/java/tschipp/carryon/common/helper/StringParser.java +++ b/old/src/main/java/tschipp/carryon/common/helper/StringParser.java @@ -5,7 +5,11 @@ import javax.annotation.Nullable; import com.mojang.brigadier.StringReader; import net.minecraft.commands.arguments.blocks.BlockStateParser; +import net.minecraft.commands.arguments.blocks.BlockStateParser.BlockResult; import net.minecraft.commands.arguments.item.ItemParser; +import net.minecraft.commands.arguments.item.ItemParser.ItemResult; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.TagParser; import net.minecraft.world.item.Item; @@ -32,12 +36,11 @@ public class StringParser if (string == null) return null; - BlockStateParser parser = new BlockStateParser(new StringReader(string), false); try { - parser.parse(false); - return parser.getState(); + BlockResult result = BlockStateParser.parseForBlock(HolderLookup.forRegistry(Registry.BLOCK), new StringReader(string), false); + return result.blockState(); } catch (Exception e) { @@ -52,12 +55,11 @@ public class StringParser if (string == null) return null; - ItemParser parser = new ItemParser(new StringReader(string), false); try { - parser.parse(); - return parser.getItem(); + ItemResult res = ItemParser.parseForItem(HolderLookup.forRegistry(Registry.ITEM), new StringReader(string)); + return res.item().get(); } catch (Exception e) { @@ -71,13 +73,13 @@ public class StringParser if (string == null) return null; - ItemParser parser = new ItemParser(new StringReader(string), false); try { - parser.parse(); - Item item = parser.getItem(); - CompoundTag nbt = parser.getNbt(); + ItemResult res = ItemParser.parseForItem(HolderLookup.forRegistry(Registry.ITEM), new StringReader(string)); + + Item item = res.item().get(); + CompoundTag nbt = res.nbt(); ItemStack stack = new ItemStack(item, 1); diff --git a/src/main/java/tschipp/carryon/common/item/ItemCarryonBlock.java b/old/src/main/java/tschipp/carryon/common/item/ItemCarryonBlock.java similarity index 95% rename from src/main/java/tschipp/carryon/common/item/ItemCarryonBlock.java rename to old/src/main/java/tschipp/carryon/common/item/ItemCarryonBlock.java index 6084c93..356084e 100644 --- a/src/main/java/tschipp/carryon/common/item/ItemCarryonBlock.java +++ b/old/src/main/java/tschipp/carryon/common/item/ItemCarryonBlock.java @@ -13,7 +13,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.ClickEvent.Action; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.effect.MobEffectInstance; @@ -33,8 +32,9 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.BlockSnapshot; -import net.minecraftforge.event.world.BlockEvent.EntityPlaceEvent; +import net.minecraftforge.event.level.BlockEvent.EntityPlaceEvent; import net.minecraftforge.fml.ModList; +import net.minecraftforge.registries.ForgeRegistries; import tschipp.carryon.CarryOn; import tschipp.carryon.client.keybinds.CarryOnKeybinds; import tschipp.carryon.common.config.Configs.Settings; @@ -51,7 +51,6 @@ public class ItemCarryonBlock extends Item public ItemCarryonBlock() { super(new Item.Properties().stacksTo(1)); - this.setRegistryName(CarryOn.MODID, "tile_item"); } @Override @@ -77,7 +76,7 @@ public class ItemCarryonBlock extends Item return getItemStack(stack).getHoverName(); } - return new TextComponent(""); + return Component.literal(""); } @Override @@ -207,7 +206,7 @@ public class ItemCarryonBlock extends Item { CarryOn.LOGGER.info("Block: " + ItemCarryonBlock.getBlock(stack)); CarryOn.LOGGER.info("BlockState: " + ItemCarryonBlock.getBlockState(stack)); - // CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack)); + // CarryOn.LOGGER.info("Meta: " + itemTile.get().getMeta(stack)); CarryOn.LOGGER.info("ItemStack: " + ItemCarryonBlock.getItemStack(stack)); if (ModelOverridesHandler.hasCustomOverrideModel(ItemCarryonBlock.getBlockState(stack), ItemCarryonBlock.getTileData(stack))) @@ -216,10 +215,10 @@ public class ItemCarryonBlock extends Item if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemCarryonBlock.getBlockState(stack))) CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonBlock.getBlockState(stack))); - player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Error detected. Cannot place block. Execute \"/carryon clear\" to remove the item"), false); - TextComponent s = new TextComponent(ChatFormatting.GOLD + "here"); + player.displayClientMessage(Component.literal(ChatFormatting.RED + "Error detected. Cannot place block. Execute \"/carryon clear\" to remove the item"), false); + Component s = Component.literal(ChatFormatting.GOLD + "here"); s.getStyle().withClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues")); - player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Please report this error ").append(s), false); + player.displayClientMessage(Component.literal(ChatFormatting.RED + "Please report this error ").append(s), false); } } @@ -276,7 +275,7 @@ public class ItemCarryonBlock extends Item // ItemStack drop = new ItemStack(state.getBlock().getItemDropped(state, // itemRand, 0), 1, state.getBlock().damageDropped(state)); - tag.putString("block", state.getBlock().getRegistryName().toString()); + tag.putString("block", ForgeRegistries.BLOCKS.getKey(state.getBlock()).toString()); // Item item = Item.getItemFromBlock(state.getBlock()); // tag.setInt("meta", drop.getItemDamage()); tag.putInt("stateid", Block.getId(state)); diff --git a/src/main/java/tschipp/carryon/common/item/ItemCarryonEntity.java b/old/src/main/java/tschipp/carryon/common/item/ItemCarryonEntity.java similarity index 95% rename from src/main/java/tschipp/carryon/common/item/ItemCarryonEntity.java rename to old/src/main/java/tschipp/carryon/common/item/ItemCarryonEntity.java index fe15a0e..531d217 100644 --- a/src/main/java/tschipp/carryon/common/item/ItemCarryonEntity.java +++ b/old/src/main/java/tschipp/carryon/common/item/ItemCarryonEntity.java @@ -9,8 +9,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.effect.MobEffectInstance; @@ -28,7 +26,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.util.ObfuscationReflectionHelper; -import tschipp.carryon.CarryOn; import tschipp.carryon.client.keybinds.CarryOnKeybinds; import tschipp.carryon.common.config.Configs.Settings; import tschipp.carryon.common.event.ItemEvents; @@ -49,7 +46,6 @@ public class ItemCarryonEntity extends Item public ItemCarryonEntity() { super(new Item.Properties().stacksTo(1)); - this.setRegistryName(CarryOn.MODID, "entity_item"); } @Override @@ -58,10 +54,10 @@ public class ItemCarryonEntity extends Item if (hasEntityData(stack)) { - return new TranslatableComponent(getEntityType(stack).getDescriptionId()); + return Component.translatable(getEntityType(stack).getDescriptionId()); } - return new TextComponent(""); + return Component.literal(""); } public static boolean hasEntityData(ItemStack stack) diff --git a/src/main/java/tschipp/carryon/common/scripting/CarryOnOverride.java b/old/src/main/java/tschipp/carryon/common/scripting/CarryOnOverride.java similarity index 100% rename from src/main/java/tschipp/carryon/common/scripting/CarryOnOverride.java rename to old/src/main/java/tschipp/carryon/common/scripting/CarryOnOverride.java diff --git a/src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java b/old/src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java similarity index 98% rename from src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java rename to old/src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java index bd40744..9095910 100644 --- a/src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java +++ b/old/src/main/java/tschipp/carryon/common/scripting/ScriptChecker.java @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.util.ObfuscationReflectionHelper; +import net.minecraftforge.registries.ForgeRegistries; import tschipp.carryon.common.config.Configs.Settings; import tschipp.carryon.common.handler.ListHandler; import tschipp.carryon.common.helper.ScriptParseHelper; @@ -58,7 +59,7 @@ public class ScriptChecker if (!Settings.useScripts.get()) return null; - String name = entity.getType().getRegistryName().toString(); + String name = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()).toString(); float height = entity.getBbHeight(); float width = entity.getBbWidth(); float health = entity instanceof LivingEntity ? ((LivingEntity) entity).getHealth() : 0.0f; diff --git a/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java b/old/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java similarity index 100% rename from src/main/java/tschipp/carryon/common/scripting/ScriptReader.java rename to old/src/main/java/tschipp/carryon/common/scripting/ScriptReader.java diff --git a/src/main/java/tschipp/carryon/common/scripting/ScriptReloadListener.java b/old/src/main/java/tschipp/carryon/common/scripting/ScriptReloadListener.java similarity index 100% rename from src/main/java/tschipp/carryon/common/scripting/ScriptReloadListener.java rename to old/src/main/java/tschipp/carryon/common/scripting/ScriptReloadListener.java diff --git a/src/main/java/tschipp/carryon/compat/obfuscate/ObfuscateEvents.java b/old/src/main/java/tschipp/carryon/compat/obfuscate/ObfuscateEvents.java similarity index 71% rename from src/main/java/tschipp/carryon/compat/obfuscate/ObfuscateEvents.java rename to old/src/main/java/tschipp/carryon/compat/obfuscate/ObfuscateEvents.java index 7257461..0974ac7 100644 --- a/src/main/java/tschipp/carryon/compat/obfuscate/ObfuscateEvents.java +++ b/old/src/main/java/tschipp/carryon/compat/obfuscate/ObfuscateEvents.java @@ -34,9 +34,9 @@ // // PlayerModel model = event.getModelPlayer(); // ItemStack stack = player.getMainHandItem(); -// if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && +// if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile.get() && // ItemCarryonBlock.hasTileData(stack) || stack.getItem() == -// RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)) +// RegistrationHandler.itemEntity.get() && ItemCarryonEntity.hasEntityData(stack)) // { // // float rotation = 0; @@ -66,11 +66,11 @@ // else if (renderLeft) // { // renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), -// (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation); +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.2f : 0), +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.15f : 0), rotation); // renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), -// (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation); +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.2f : 0), +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.15f : 0), rotation); // } // // if (renderRight && rotRight != null) @@ -83,28 +83,28 @@ // else if (renderRight) // { // renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation); +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.2f : 0), +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.15f : 0), rotation); // renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) -// - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation); +// - (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.2f : 0), +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.15f : 0), rotation); // } // // } // else // { // renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation); +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.2f : 0), +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.15f : 0), rotation); // renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) -// - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation); +// - (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.2f : 0), +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.15f : 0), rotation); // renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), -// (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation); +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.2f : 0), +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.15f : 0), rotation); // renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - -// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), -// (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation); +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? -0.2f : 0), +// (stack.getItem() == RegistrationHandler.itemEntity.get() ? 0.15f : 0), rotation); // } // // } diff --git a/src/main/java/tschipp/carryon/network/client/CarrySlotPacket.java b/old/src/main/java/tschipp/carryon/network/client/CarrySlotPacket.java similarity index 90% rename from src/main/java/tschipp/carryon/network/client/CarrySlotPacket.java rename to old/src/main/java/tschipp/carryon/network/client/CarrySlotPacket.java index 515fae2..ed15dce 100644 --- a/src/main/java/tschipp/carryon/network/client/CarrySlotPacket.java +++ b/old/src/main/java/tschipp/carryon/network/client/CarrySlotPacket.java @@ -43,21 +43,24 @@ public class CarrySlotPacket buf.writeInt(this.entityid); } - public void handle(Supplier ctx) + public boolean handle(Supplier ctx) { if (ctx.get().getDirection().getReceptionSide().isClient()) { + ctx.get().setPacketHandled(true); + ctx.get().enqueueWork(() -> { Level level = CarryOn.proxy.getLevel(); - + ctx.get().setPacketHandled(true); + if (level != null) { Entity e = level.getEntity(this.entityid); if (e instanceof Player player) { - ctx.get().setPacketHandled(true); + if (this.slot >= 9) { @@ -76,6 +79,8 @@ public class CarrySlotPacket } }); } + + return true; } } diff --git a/src/main/java/tschipp/carryon/network/client/ScriptReloadPacket.java b/old/src/main/java/tschipp/carryon/network/client/ScriptReloadPacket.java similarity index 88% rename from src/main/java/tschipp/carryon/network/client/ScriptReloadPacket.java rename to old/src/main/java/tschipp/carryon/network/client/ScriptReloadPacket.java index 57bea31..a3bfc62 100644 --- a/src/main/java/tschipp/carryon/network/client/ScriptReloadPacket.java +++ b/old/src/main/java/tschipp/carryon/network/client/ScriptReloadPacket.java @@ -14,9 +14,9 @@ public class ScriptReloadPacket { private List overrides = new ArrayList<>(); - public ScriptReloadPacket() - { - } +// public ScriptReloadPacket() +// { +// } public ScriptReloadPacket(Collection collection) { @@ -38,10 +38,11 @@ public class ScriptReloadPacket this.overrides.forEach(override -> override.serialize(buf)); } - public void handle(Supplier ctx) + public boolean handle(Supplier ctx) { if (ctx.get().getDirection().getReceptionSide().isClient()) { + ctx.get().setPacketHandled(true); ctx.get().enqueueWork(() -> { ScriptReader.OVERRIDES.clear(); @@ -50,9 +51,10 @@ public class ScriptReloadPacket ScriptReader.OVERRIDES.put(override.hashCode(), override); }); - ctx.get().setPacketHandled(true); }); } + + return true; } } diff --git a/src/main/java/tschipp/carryon/network/server/SyncKeybindPacket.java b/old/src/main/java/tschipp/carryon/network/server/SyncKeybindPacket.java similarity index 87% rename from src/main/java/tschipp/carryon/network/server/SyncKeybindPacket.java rename to old/src/main/java/tschipp/carryon/network/server/SyncKeybindPacket.java index 9ec499d..90b0367 100644 --- a/src/main/java/tschipp/carryon/network/server/SyncKeybindPacket.java +++ b/old/src/main/java/tschipp/carryon/network/server/SyncKeybindPacket.java @@ -26,19 +26,21 @@ public class SyncKeybindPacket buf.writeBoolean(this.pressed); } - public void handle(Supplier ctx) + public boolean handle(Supplier ctx) { if (ctx.get().getDirection().getReceptionSide().isServer()) { + ctx.get().setPacketHandled(true); ctx.get().enqueueWork(() -> { ServerPlayer player = ctx.get().getSender(); CarryOnKeybinds.setKeyPressed(player, this.pressed); - ctx.get().setPacketHandled(true); }); } + + return true; } } diff --git a/src/main/java/tschipp/carryon/proxy/ClientProxy.java b/old/src/main/java/tschipp/carryon/proxy/ClientProxy.java similarity index 97% rename from src/main/java/tschipp/carryon/proxy/ClientProxy.java rename to old/src/main/java/tschipp/carryon/proxy/ClientProxy.java index fbf0f40..9de6241 100644 --- a/src/main/java/tschipp/carryon/proxy/ClientProxy.java +++ b/old/src/main/java/tschipp/carryon/proxy/ClientProxy.java @@ -17,8 +17,6 @@ public class ClientProxy implements IProxy { RegistrationHandler.regClientEvents(); - CarryOnKeybinds.init(); - new ScrollCallbackWrapper().setup(Minecraft.getInstance()); new KeyboardCallbackWrapper().setup(Minecraft.getInstance()); } diff --git a/src/main/java/tschipp/carryon/proxy/IProxy.java b/old/src/main/java/tschipp/carryon/proxy/IProxy.java similarity index 100% rename from src/main/java/tschipp/carryon/proxy/IProxy.java rename to old/src/main/java/tschipp/carryon/proxy/IProxy.java diff --git a/src/main/java/tschipp/carryon/proxy/ServerProxy.java b/old/src/main/java/tschipp/carryon/proxy/ServerProxy.java similarity index 100% rename from src/main/java/tschipp/carryon/proxy/ServerProxy.java rename to old/src/main/java/tschipp/carryon/proxy/ServerProxy.java diff --git a/src/main/resources/META-INF/mods.toml b/old/src/main/resources/META-INF/mods.toml similarity index 91% rename from src/main/resources/META-INF/mods.toml rename to old/src/main/resources/META-INF/mods.toml index 2260b24..46c77ae 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/old/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[40,)" +loaderVersion="[41,)" issueTrackerURL="https://github.com/Tschipp/CarryOn/issues" logoFile="logo.png" license="GNU LGPLv3" @@ -18,7 +18,7 @@ license="GNU LGPLv3" # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[40.0.3,)" #mandatory + versionRange="[41,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER @@ -27,6 +27,6 @@ license="GNU LGPLv3" [[dependencies.carryon]] modId="minecraft" mandatory=true - versionRange="[1.18.2,1.19)" + versionRange="[1.19,1.20)" ordering="NONE" side="BOTH" diff --git a/src/main/resources/assets/carryon/lang/en_ud.json b/old/src/main/resources/assets/carryon/lang/en_ud.json similarity index 100% rename from src/main/resources/assets/carryon/lang/en_ud.json rename to old/src/main/resources/assets/carryon/lang/en_ud.json diff --git a/src/main/resources/assets/carryon/lang/en_us.json b/old/src/main/resources/assets/carryon/lang/en_us.json similarity index 100% rename from src/main/resources/assets/carryon/lang/en_us.json rename to old/src/main/resources/assets/carryon/lang/en_us.json diff --git a/src/main/resources/assets/carryon/lang/es_es.json b/old/src/main/resources/assets/carryon/lang/es_es.json similarity index 100% rename from src/main/resources/assets/carryon/lang/es_es.json rename to old/src/main/resources/assets/carryon/lang/es_es.json diff --git a/src/main/resources/assets/carryon/lang/it_it.json b/old/src/main/resources/assets/carryon/lang/it_it.json similarity index 100% rename from src/main/resources/assets/carryon/lang/it_it.json rename to old/src/main/resources/assets/carryon/lang/it_it.json diff --git a/src/main/resources/assets/carryon/lang/ko_kr.json b/old/src/main/resources/assets/carryon/lang/ko_kr.json similarity index 100% rename from src/main/resources/assets/carryon/lang/ko_kr.json rename to old/src/main/resources/assets/carryon/lang/ko_kr.json diff --git a/src/main/resources/assets/carryon/lang/ru_ru.json b/old/src/main/resources/assets/carryon/lang/ru_ru.json similarity index 100% rename from src/main/resources/assets/carryon/lang/ru_ru.json rename to old/src/main/resources/assets/carryon/lang/ru_ru.json diff --git a/src/main/resources/assets/carryon/models/item/entity_item.json b/old/src/main/resources/assets/carryon/models/item/entity_item.json similarity index 100% rename from src/main/resources/assets/carryon/models/item/entity_item.json rename to old/src/main/resources/assets/carryon/models/item/entity_item.json diff --git a/src/main/resources/assets/carryon/models/item/tile_item.json b/old/src/main/resources/assets/carryon/models/item/tile_item.json similarity index 100% rename from src/main/resources/assets/carryon/models/item/tile_item.json rename to old/src/main/resources/assets/carryon/models/item/tile_item.json diff --git a/src/main/resources/assets/carryon/textures/item/tile.png b/old/src/main/resources/assets/carryon/textures/item/tile.png similarity index 100% rename from src/main/resources/assets/carryon/textures/item/tile.png rename to old/src/main/resources/assets/carryon/textures/item/tile.png diff --git a/src/main/resources/data/carryon/tags/blocks/block_blacklist.json b/old/src/main/resources/data/carryon/tags/blocks/block_blacklist.json similarity index 100% rename from src/main/resources/data/carryon/tags/blocks/block_blacklist.json rename to old/src/main/resources/data/carryon/tags/blocks/block_blacklist.json diff --git a/src/main/resources/data/carryon/tags/blocks/block_whitelist.json b/old/src/main/resources/data/carryon/tags/blocks/block_whitelist.json similarity index 100% rename from src/main/resources/data/carryon/tags/blocks/block_whitelist.json rename to old/src/main/resources/data/carryon/tags/blocks/block_whitelist.json diff --git a/src/main/resources/data/carryon/tags/entity_types/entity_blacklist.json b/old/src/main/resources/data/carryon/tags/entity_types/entity_blacklist.json similarity index 100% rename from src/main/resources/data/carryon/tags/entity_types/entity_blacklist.json rename to old/src/main/resources/data/carryon/tags/entity_types/entity_blacklist.json diff --git a/src/main/resources/data/carryon/tags/entity_types/entity_whitelist.json b/old/src/main/resources/data/carryon/tags/entity_types/entity_whitelist.json similarity index 100% rename from src/main/resources/data/carryon/tags/entity_types/entity_whitelist.json rename to old/src/main/resources/data/carryon/tags/entity_types/entity_whitelist.json diff --git a/src/main/resources/data/carryon/tags/entity_types/stacking_blacklist.json b/old/src/main/resources/data/carryon/tags/entity_types/stacking_blacklist.json similarity index 100% rename from src/main/resources/data/carryon/tags/entity_types/stacking_blacklist.json rename to old/src/main/resources/data/carryon/tags/entity_types/stacking_blacklist.json diff --git a/src/main/resources/data/carryon/tags/entity_types/stacking_whitelist.json b/old/src/main/resources/data/carryon/tags/entity_types/stacking_whitelist.json similarity index 100% rename from src/main/resources/data/carryon/tags/entity_types/stacking_whitelist.json rename to old/src/main/resources/data/carryon/tags/entity_types/stacking_whitelist.json diff --git a/src/main/resources/logo.png b/old/src/main/resources/logo.png similarity index 100% rename from src/main/resources/logo.png rename to old/src/main/resources/logo.png diff --git a/src/main/resources/pack.mcmeta b/old/src/main/resources/pack.mcmeta similarity index 100% rename from src/main/resources/pack.mcmeta rename to old/src/main/resources/pack.mcmeta diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..496ec7f --- /dev/null +++ b/settings.gradle @@ -0,0 +1,16 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + maven { + name = 'Sponge Snapshots' + url = 'https://repo.spongepowered.org/repository/maven-public/' + } + } +} + +rootProject.name = 'CarryOn' +include("Common", "Fabric", "Forge") \ No newline at end of file diff --git a/src/main/java/tschipp/carryon/common/config/Configs.java b/src/main/java/tschipp/carryon/common/config/Configs.java deleted file mode 100644 index 6b40d45..0000000 --- a/src/main/java/tschipp/carryon/common/config/Configs.java +++ /dev/null @@ -1,247 +0,0 @@ -package tschipp.carryon.common.config; - -import java.util.Arrays; -import java.util.List; - -import com.electronwill.nightconfig.core.CommentedConfig; -import com.electronwill.nightconfig.core.file.CommentedFileConfig; - -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; -import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; -import net.minecraftforge.common.ForgeConfigSpec.IntValue; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; -import net.minecraftforge.fml.event.config.ModConfigEvent; -import tschipp.carryon.CarryOn; -import tschipp.carryon.common.handler.ListHandler; - -@Mod.EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD) -public class Configs -{ - - private static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder(); - private static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder(); - - public static final ForgeConfigSpec SERVER_CONFIG; - public static final ForgeConfigSpec CLIENT_CONFIG; - - static - { - - Settings.init(SERVER_BUILDER, CLIENT_BUILDER); - Blacklist.init(SERVER_BUILDER, CLIENT_BUILDER); - WhiteList.init(SERVER_BUILDER, CLIENT_BUILDER); - ModelOverrides.init(SERVER_BUILDER, CLIENT_BUILDER); - CustomPickupConditions.init(SERVER_BUILDER, CLIENT_BUILDER); - - SERVER_CONFIG = SERVER_BUILDER.build(); - CLIENT_CONFIG = CLIENT_BUILDER.build(); - } - - @SubscribeEvent - public static void onLoad(final ModConfigEvent.Loading event) - { - if (event.getConfig().getModId().equals(CarryOn.MODID)) - { - ListHandler.initConfigLists(); - - CommentedConfig cfg = event.getConfig().getConfigData(); - - if (cfg instanceof CommentedFileConfig) - ((CommentedFileConfig) cfg).load(); - } - } - - @SubscribeEvent - public static void onConfigChanged(ModConfigEvent.Reloading event) - { - if (event.getConfig().getModId().equals(CarryOn.MODID)) - { - ListHandler.initConfigLists(); - - CommentedConfig cfg = event.getConfig().getConfigData(); - - if (cfg instanceof CommentedFileConfig) - ((CommentedFileConfig) cfg).load(); - } - } - - public static class Settings - { - public static BooleanValue facePlayer; - - public static BooleanValue heavyTiles; - - public static BooleanValue pickupAllBlocks; - - public static BooleanValue slownessInCreative; - - public static DoubleValue maxDistance; - - public static DoubleValue maxEntityWidth; - - public static DoubleValue maxEntityHeight; - - public static BooleanValue pickupHostileMobs; - - public static BooleanValue heavyEntities; - - public static DoubleValue blockSlownessMultiplier; - - public static DoubleValue entitySlownessMultiplier; - - public static BooleanValue renderArms; - - public static BooleanValue allowBabies; - - public static BooleanValue useWhitelistBlocks; - - public static BooleanValue useWhitelistEntities; - - public static BooleanValue useWhitelistStacking; - - public static BooleanValue hitWhileCarrying; - - public static BooleanValue dropCarriedWhenHit; - - public static BooleanValue useScripts; - - public static BooleanValue stackableEntities; - - public static IntValue maxEntityStackLimit; - - public static BooleanValue entitySizeMattersStacking; - - public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) - { - c.comment("Settings"); - s.comment("Settings"); - - s.push("settings"); - c.push("settings"); - - maxDistance = s.comment("Maximum distance from where Blocks and Entities can be picked up").defineInRange("maxDistance", 2.5, 0, Double.MAX_VALUE); - - maxEntityWidth = s.comment("Max width of entities that can be picked up in survival mode").defineInRange("maxEntityWidth", 1.5, 0, 10); - - maxEntityHeight = s.comment("Max height of entities that can be picked up in survival mode").defineInRange("maxEntityHeight", 2.0, 0, 10); - - blockSlownessMultiplier = s.comment("Slowness multiplier for blocks").defineInRange("blockSlownessMultiplier", 1, 0, Double.MAX_VALUE); - - entitySlownessMultiplier = s.comment("Slowness multiplier for entities").defineInRange("entitySlownessMultiplier", 1, 0, Double.MAX_VALUE); - - maxEntityStackLimit = s.comment("Maximum stack limit for entities").defineInRange("maxEntityStackLimit", 10, 1, Integer.MAX_VALUE); - - facePlayer = c.comment("If the front of the Tile Entities should face the player or should face outward").define("facePlayer", false); - - heavyTiles = s.comment("More complex Tile Entities slow down the player more").define("heavyTiles", true); - - pickupAllBlocks = s.comment("Allow all blocks to be picked up, not just Tile Entites").define("pickupAllBlocks", false); - - slownessInCreative = s.comment("Whether Blocks and Entities slow the creative player down when carried").define("slownessInCreative", true); - - pickupHostileMobs = s.comment("Whether hostile mobs should be able to picked up in survival mode").define("pickupHostileMobs", false); - - heavyEntities = s.comment("Larger Entities slow down the player more").define("heavyEntities", true); - - renderArms = c.comment("Arms should render on sides when carrying").define("renderArms", true); - - allowBabies = s.comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)").define("allowBabies", false); - - useWhitelistBlocks = s.comment("Use Whitelist instead of Blacklist for Blocks").define("useWhitelistBlocks", false); - - useWhitelistEntities = s.comment("Use Whitelist instead of Blacklist for Entities").define("useWhitelistEntities", false); - - useWhitelistStacking = s.comment("Use Whitelist instead of Blacklist for Stacking").define("useWhitelistStacking", false); - - hitWhileCarrying = s.comment("Whether the player can hit blocks and entities while carrying or not").define("hitWhileCarrying", false); - - dropCarriedWhenHit = s.comment("Whether the player drops the carried object when hit or not").define("dropCarriedWhenHit", false); - - useScripts = s.comment("Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance").worldRestart().define("useScripts", false); - - stackableEntities = s.comment("Allows entities to be stacked using Carry On").define("stackableEntities", true); - - entitySizeMattersStacking = s.comment("Whether entities' size matters when stacking or not").define("stackableEntities", true); - - s.pop(); - c.pop(); - - } - - } - - public static class WhiteList - { - public static ConfigValue> allowedEntities; - - public static ConfigValue> allowedBlocks; - - public static ConfigValue> allowedStacking; - - public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) - { - s.comment("Whitelist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config"); - - allowedEntities = s.comment("Entities that CAN be picked up (useWhitelistEntities must be true)").defineList("whitelist.allowedEntities", Arrays.asList(), obj -> obj instanceof String ? true : false); - - allowedBlocks = s.comment("Blocks that CAN be picked up (useWhitelistBlocks must be true)").defineList("whitelist.allowedBlocks", Arrays.asList(), obj -> obj instanceof String ? true : false); - - allowedStacking = s.comment("Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)").defineList("whitelist.allowedStacking", Arrays.asList(), obj -> obj instanceof String ? true : false); - } - } - - public static class Blacklist - { - public static ConfigValue> forbiddenTiles; - - public static ConfigValue> forbiddenEntities; - - public static ConfigValue> forbiddenStacking; - - public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) - { - s.comment("Blacklist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config"); - - forbiddenTiles = s.comment("Blocks that cannot be picked up").defineList("blacklist.forbiddenTiles", Arrays.asList("#forge:immovable", "#forge:relocation_not_supported", "minecraft:end_portal", "minecraft:end_gateway", "minecraft:tall_grass", "minecraft:large_fern", "minecraft:peony", "minecraft:rose_bush", "minecraft:lilac", "minecraft:sunflower", "minecraft:*_bed", "minecraft:oak_door", "minecraft:iron_door", "minecraft:spruce_door", "minecraft:birch_door", "minecraft:jungle_door", "minecraft:acacia_door", "minecraft:dark_oak_door", "minecraft:waterlily", "minecraft:cake", "minecraft:nether_portal", "minecraft:tall_seagrass", "animania:block_trough", "animania:block_invisiblock", "colossalchests:*", "ic2:*", "bigreactors:*", "forestry:*", "tconstruct:*", "rustic:*", "botania:*", "astralsorcery:*", "quark:colored_bed_*", "immersiveengineering:*", "embers:block_furnace", "embers:ember_bore", "embers:ember_activator", "embers:mixer", "embers:heat_coil", "embers:large_tank", "embers:crystal_cell", "embers:alchemy_pedestal", "embers:boiler", "embers:combustor", "embers:catalzyer", "embers:field_chart", "embers:inferno_forge", "storagedrawers:framingtable", "skyresources:*", "lootbags:*", "exsartagine:*", "aquamunda:tank", "opencomputers:*", "malisisdoors:*", "industrialforegoing:*", "minecolonies:*", "thaumcraft:pillar*", "thaumcraft:infernal_furnace", "thaumcraft:placeholder*", "thaumcraft:infusion_matrix", "thaumcraft:golem_builder", "thaumcraft:thaumatorium*", "magneticraft:oil_heater", "magneticraft:solar_panel", "magneticraft:steam_engine", "magneticraft:shelving_unit", "magneticraft:grinder", "magneticraft:sieve", "magneticraft:solar_tower", "magneticraft:solar_mirror", "magneticraft:container", "magneticraft:pumpjack", "magneticraft:solar_panel", "magneticraft:refinery", "magneticraft:oil_heater", "magneticraft:hydraulic_press", "magneticraft:multiblock_gap", "refinedstorage:*", "mcmultipart:*", "enderstorage:*", "betterstorage:*", "practicallogistics2:*", "wearablebackpacks:*", "rftools:screen", "rftools:creative_screen", "create:*", "magic_doorknob:*", "iceandfire:*", "ftbquests:*", "waystones:*"), obj -> obj instanceof String); - - forbiddenEntities = s.comment("Entities that cannot be picked up").defineList("blacklist.forbiddenEntities", Arrays.asList("minecraft:end_crystal", "minecraft:ender_dragon", "minecraft:ghast", "minecraft:shulker", "minecraft:leash_knot", "minecraft:armor_stand", "minecraft:item_frame", "minecraft:painting", "minecraft:shulker_bullet", "animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart", "animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*"), obj -> obj instanceof String ? true : false); - - forbiddenStacking = s.comment("Entities that cannot have other entities stacked on top of them").defineList("blacklist.forbiddenStacking", Arrays.asList("minecraft:horse"), obj -> obj instanceof String ? true : false); - } - - } - - public static class ModelOverrides - { - public static ConfigValue> modelOverrides; - - public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) - { - c.comment("Model Overrides. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config"); - - modelOverrides = c.comment("Model Overrides based on NBT or on Meta. Advanced Users Only!").defineList("modeloverrides.overrides", Arrays.asList("minecraft:hopper->(block)minecraft:hopper", "minecraft:comparator->(block)minecraft:comparator", "minecraft:repeater->(block)minecraft:repeater", "minecraft:cauldron->(block)minecraft:cauldron", "minecraft:brewing_stand->(item)minecraft:brewing_stand", "minecraft:flower_pot->(block)minecraft:flower_pot", "minecraft:sugar_cane->(block)minecraft:sugar_cane", "minecraft:redstone_wire->(item)minecraft:redstone", "animania:block_nest->(block)animania:block_nest", "animania:cheese_mold;0->(block)animania:cheese_mold;0", "animania:cheese_mold;1->(block)animania:cheese_mold;1", "animania:cheese_mold;2->(block)animania:cheese_mold;2", "animania:cheese_mold;3->(block)animania:cheese_mold;3", "animania:cheese_mold;4->(block)animania:cheese_mold;4", "animania:cheese_mold;5->(block)animania:cheese_mold;5", "animania:cheese_mold;6->(block)animania:cheese_mold;6", "animania:cheese_mold;7->(block)animania:cheese_mold;7", "animania:cheese_mold;8->(block)animania:cheese_mold;8", "animania:cheese_mold;9->(block)animania:cheese_mold;9", "animania:cheese_mold;10->(block)animania:cheese_mold;10"), obj -> obj instanceof String ? true : false); - } - } - - public static class CustomPickupConditions - { - - public static ConfigValue> customPickupConditionsBlocks; - - public static ConfigValue> customPickupConditionsEntities; - - public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c) - { - s.comment("Custom Pickup Conditions. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Custom-Pickup-Condition-Config"); - - customPickupConditionsBlocks = s.comment("Custom Pickup Conditions for Blocks").defineList("custom_pickup_conditions.customPickupConditionsBlocks", Arrays.asList(), obj -> obj instanceof String ? true : false); - - customPickupConditionsEntities = s.comment("Custom Pickup Conditions for Entities").defineList("custom_pickup_conditions.customPickupConditionsEntities", Arrays.asList(), obj -> obj instanceof String ? true : false); - } - } - -}