Fixed multiple render crashes, fixed fabric config loading, improved mixin compatibility
This commit is contained in:
parent
1bb75a9b8e
commit
3339a68564
|
|
@ -21,9 +21,15 @@ minecraft {
|
|||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
|
||||
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
|
||||
implementation("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")
|
||||
annotationProcessor("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
|
|
|||
|
|
@ -37,10 +37,16 @@ public class CarriedObjectRender
|
|||
return false;
|
||||
|
||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if(carry.isCarrying(CarryType.BLOCK))
|
||||
drawFirstPersonBlock(player, buffer, matrix, light, CarryRenderHelper.getRenderState(player));
|
||||
else if (carry.isCarrying(CarryType.ENTITY))
|
||||
drawFirstPersonEntity(player, buffer, matrix, light, partialTicks);
|
||||
try {
|
||||
if (carry.isCarrying(CarryType.BLOCK))
|
||||
drawFirstPersonBlock(player, buffer, matrix, light, CarryRenderHelper.getRenderState(player));
|
||||
else if (carry.isCarrying(CarryType.ENTITY))
|
||||
drawFirstPersonEntity(player, buffer, matrix, light, partialTicks);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//hehe
|
||||
}
|
||||
|
||||
if(carry.getActiveScript().isPresent())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ public class CarryRenderHelper
|
|||
{
|
||||
BlockState state = getRenderState(player);
|
||||
VoxelShape shape = state.getShape(player.level, player.blockPosition());
|
||||
if(shape == null)
|
||||
if(shape == null || shape.isEmpty())
|
||||
return 1f;
|
||||
Optional<ModelOverride> ov = ModelOverrideHandler.getModelOverride(state, carry.getContentNbt());
|
||||
if(ov.isPresent())
|
||||
|
|
@ -342,7 +342,7 @@ public class CarryRenderHelper
|
|||
{
|
||||
BlockState state = getRenderState(player);
|
||||
VoxelShape shape = state.getShape(player.level, player.blockPosition());
|
||||
if(shape == null)
|
||||
if(shape == null || shape.isEmpty())
|
||||
return 1f;
|
||||
Optional<ModelOverride> ov = ModelOverrideHandler.getModelOverride(state, carry.getContentNbt());
|
||||
if(ov.isPresent())
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package tschipp.carryon.common.config;
|
||||
|
||||
import com.mojang.datafixers.kinds.Const;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
|
@ -141,8 +142,6 @@ public class ListHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static <T> void addTag(String tag, Map<ResourceLocation, TagKey<T>> tagMap, List<TagKey<T>> tags) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -27,15 +29,15 @@ public class InventoryMixin
|
|||
@Shadow
|
||||
public NonNullList<ItemStack> items;
|
||||
|
||||
@Redirect(method = "getFreeSlot()I", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/core/NonNullList;get(I)Ljava/lang/Object;"))
|
||||
private <E> E getFreeSlotEmptyCheck(NonNullList<E> instance, int i)
|
||||
@WrapOperation(method = "getFreeSlot()I", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/core/NonNullList;get(I)Ljava/lang/Object;"))
|
||||
private Object getFreeSlotEmptyCheck(NonNullList<Object> instance, int slot, Operation<Object> original)
|
||||
{
|
||||
if(i == selected && CarryOnDataManager.getCarryData(player).isCarrying())
|
||||
if(slot == selected && CarryOnDataManager.getCarryData(player).isCarrying())
|
||||
{
|
||||
return (E) DUMMY_STACK;
|
||||
return DUMMY_STACK;
|
||||
}
|
||||
else
|
||||
return instance.get(i);
|
||||
return original.call(instance, slot);
|
||||
}
|
||||
|
||||
@Inject(method = "setPickedItem(Lnet/minecraft/world/item/ItemStack;)V", at = @At("HEAD"), cancellable = true)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
|
@ -10,10 +11,9 @@ import tschipp.carryon.common.carry.CarryOnDataManager;
|
|||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin
|
||||
{
|
||||
@Redirect(method = "handleKeybinds()V", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/player/Inventory;selected:I", ordinal = 0, opcode = 181)) //Opcode for PUTFIELD
|
||||
private void onSlotSelected(Inventory inv,int slot)
|
||||
@WrapWithCondition(method = "handleKeybinds()V", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/player/Inventory;selected:I", ordinal = 0, opcode = 181)) //Opcode for PUTFIELD
|
||||
private boolean allowSlotSelection(Inventory inv,int slot)
|
||||
{
|
||||
if(!CarryOnDataManager.getCarryData(inv.player).isCarrying())
|
||||
inv.selected = slot;
|
||||
return !CarryOnDataManager.getCarryData(inv.player).isCarrying();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
],
|
||||
"server": [
|
||||
],
|
||||
"plugin": "tschipp.carryon.mixin.CarryOnMixinConfigPlugin",
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ if (project.hasProperty('secretFile')) {
|
|||
if (System.getenv('BUILD_NUMBER') != null) {
|
||||
version += "." + System.getenv('BUILD_NUMBER')
|
||||
}
|
||||
repositories {
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||
|
|
@ -22,6 +26,8 @@ dependencies {
|
|||
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
|
||||
implementation project(":Common")
|
||||
include implementation("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")
|
||||
annotationProcessor("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")
|
||||
}
|
||||
|
||||
loom {
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ public class ConfigLoaderImpl {
|
|||
FileUtils.write(cfgFile, GSON.toJson(loadConfig(entry.getValue(), cfgJson)), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
ConfigLoader.onConfigLoaded();
|
||||
}
|
||||
|
||||
private static JsonObject loadConfig(BuiltCategory category, JsonObject config) {
|
||||
|
|
@ -90,7 +88,6 @@ public class ConfigLoaderImpl {
|
|||
}
|
||||
}
|
||||
});
|
||||
ConfigLoader.onConfigLoaded();
|
||||
return config;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package tschipp.carryon.events;
|
|||
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.player.*;
|
||||
|
|
@ -18,12 +19,18 @@ import tschipp.carryon.common.carry.CarryOnDataManager;
|
|||
import tschipp.carryon.common.carry.PickupHandler;
|
||||
import tschipp.carryon.common.carry.PlacementHandler;
|
||||
import tschipp.carryon.common.scripting.ScriptReloadListener;
|
||||
import tschipp.carryon.config.ConfigLoader;
|
||||
import tschipp.carryon.scripting.IdentifiableScriptReloadListener;
|
||||
|
||||
public class CommonEvents {
|
||||
|
||||
public static void registerEvents() {
|
||||
|
||||
CommonLifecycleEvents.TAGS_LOADED.register((registries, client) -> {
|
||||
if(!client)
|
||||
ConfigLoader.onConfigLoaded();
|
||||
});
|
||||
|
||||
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
|
||||
|
||||
if(world.isClientSide)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
|
||||
import com.llamalad7.mixinextras.MixinExtrasBootstrap;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CarryOnMixinConfigPlugin implements IMixinConfigPlugin {
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
MixinExtrasBootstrap.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postApply(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preApply(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -4,11 +4,13 @@ buildscript {
|
|||
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
|
||||
maven { url = 'https://maven.parchmentmc.org' }
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
dependencies {
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
|
||||
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
||||
classpath 'org.parchmentmc:librarian:1.+'
|
||||
classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
|
||||
}
|
||||
}
|
||||
apply plugin: 'java'
|
||||
|
|
@ -17,6 +19,7 @@ apply plugin: 'eclipse'
|
|||
apply plugin: 'org.spongepowered.mixin'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'org.parchmentmc.librarian.forgegradle'
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
|
||||
|
||||
|
|
@ -97,6 +100,11 @@ minecraft {
|
|||
|
||||
sourceSets.main.resources.srcDir 'src/generated/resources'
|
||||
|
||||
configurations {
|
||||
shade
|
||||
implementation.extendsFrom shade
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://maven.blamejared.com'
|
||||
|
|
@ -104,6 +112,8 @@ repositories {
|
|||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
@ -111,7 +121,10 @@ dependencies {
|
|||
compileOnly project(":Common")
|
||||
implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.19.2:11.0.2")
|
||||
implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.19.2:16.1.9")
|
||||
minecraftLibrary("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")
|
||||
annotationProcessor("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
|
||||
shade("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")
|
||||
|
||||
fileTree("libs").matching {
|
||||
include "*.jar"
|
||||
|
|
@ -124,6 +137,19 @@ dependencies {
|
|||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shade]
|
||||
relocate 'com.github.llamalad7.mixinextras', 'tschipp.carryon.shaded.mixinextras'
|
||||
finalizedBy 'reobfShadowJar'
|
||||
classifier = ""
|
||||
}
|
||||
|
||||
assemble.dependsOn shadowJar
|
||||
|
||||
reobf {
|
||||
shadowJar {}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
source(project(":Common").sourceSets.main.allSource)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,9 +110,9 @@ public class CommonEvents
|
|||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||
if (!carry.isCarrying()) {
|
||||
if (PickupHandler.tryPickupEntity((ServerPlayer) player, target, (toPickup) -> {
|
||||
AttackEntityEvent attackEvent = new AttackEntityEvent(player, toPickup);
|
||||
MinecraftForge.EVENT_BUS.post(attackEvent);
|
||||
return !attackEvent.isCanceled();
|
||||
EntityPickupEvent pickupEvent = new EntityPickupEvent((ServerPlayer) player, toPickup);
|
||||
MinecraftForge.EVENT_BUS.post(pickupEvent);
|
||||
return !pickupEvent.isCanceled();
|
||||
})) {
|
||||
event.setResult(Result.DENY);
|
||||
event.setCancellationResult(InteractionResult.SUCCESS);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@Cancelable
|
||||
public class EntityPickupEvent extends Event {
|
||||
|
||||
public final ServerPlayer player;
|
||||
public final Entity target;
|
||||
|
||||
public EntityPickupEvent(ServerPlayer player, Entity target) {
|
||||
this.player = player;
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package tschipp.carryon.mixin;
|
||||
|
||||
|
||||
import com.llamalad7.mixinextras.MixinExtrasBootstrap;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CarryOnMixinConfigPlugin implements IMixinConfigPlugin {
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
MixinExtrasBootstrap.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postApply(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preApply(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# Project
|
||||
version=2.0.2
|
||||
version=2.0.3
|
||||
group=tschipp.carryon
|
||||
|
||||
# Common
|
||||
|
|
@ -28,4 +28,6 @@ mod_id=carryon
|
|||
|
||||
# Gradle
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
org.gradle.daemon=false
|
||||
|
||||
mixinextras_version=0.2.0-beta.1
|
||||
|
|
@ -9,6 +9,9 @@ pluginManagement {
|
|||
name = 'Sponge Snapshots'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
||||
}
|
||||
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user