mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-02 21:47:40 -05:00
Update to 24w40a
This commit is contained in:
@@ -128,7 +128,7 @@ unifiedPublishing {
|
||||
curseforge {
|
||||
token = CURSE_API_KEY
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 21", project.minecraft_version
|
||||
gameVersions.addAll "Java 21", "1.21.2-Snapshot"//, project.minecraft_version
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ public class EventHandlerImpl {
|
||||
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registry, selection) -> CommandRegistrationEvent.EVENT.invoker().register(dispatcher, registry, selection));
|
||||
|
||||
UseItemCallback.EVENT.register((player, world, hand) -> InteractionEvent.RIGHT_CLICK_ITEM.invoker().click(player, hand).asMinecraft());
|
||||
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> InteractionEvent.RIGHT_CLICK_BLOCK.invoker().click(player, hand, hitResult.getBlockPos(), hitResult.getDirection()).asMinecraft());
|
||||
AttackBlockCallback.EVENT.register((player, world, hand, pos, face) -> InteractionEvent.LEFT_CLICK_BLOCK.invoker().click(player, hand, pos, face).asMinecraft());
|
||||
UseItemCallback.EVENT.register((player, world, hand) -> InteractionEvent.RIGHT_CLICK_ITEM.invoker().click(player, hand));
|
||||
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> InteractionEvent.RIGHT_CLICK_BLOCK.invoker().click(player, hand, hitResult.getBlockPos(), hitResult.getDirection()));
|
||||
AttackBlockCallback.EVENT.register((player, world, hand, pos, face) -> InteractionEvent.LEFT_CLICK_BLOCK.invoker().click(player, hand, pos, face));
|
||||
AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> PlayerEvent.ATTACK_ENTITY.invoker().attack(player, world, entity, hand, hitResult).asMinecraft());
|
||||
|
||||
LootTableEvents.MODIFY.register((key, tableBuilder, source) -> LootEvent.MODIFY_LOOT_TABLE.invoker().modifyLootTable(key, new LootTableModificationContextImpl(tableBuilder), source.isBuiltin()));
|
||||
|
||||
@@ -19,18 +19,15 @@
|
||||
|
||||
package dev.architectury.hooks.item.fabric;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
public class ItemStackHooksImpl {
|
||||
public static boolean hasCraftingRemainingItem(ItemStack stack) {
|
||||
return stack.getItem().hasCraftingRemainingItem();
|
||||
return !getCraftingRemainingItem(stack).isEmpty();
|
||||
}
|
||||
|
||||
public static ItemStack getCraftingRemainingItem(ItemStack stack) {
|
||||
if (!hasCraftingRemainingItem(stack)) return ItemStack.EMPTY;
|
||||
Item item = stack.getItem().getCraftingRemainingItem();
|
||||
return item == null || item == Items.AIR ? ItemStack.EMPTY : item.getDefaultInstance();
|
||||
ItemStack remainder = stack.getItem().getRecipeRemainder(stack);
|
||||
return remainder == null || remainder.isEmpty() ? ItemStack.EMPTY : remainder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021, 2022 architectury
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.hooks.item.food.fabric;
|
||||
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FoodPropertiesHooksImpl {
|
||||
public static void effect(FoodProperties.Builder builder,
|
||||
Supplier<? extends MobEffectInstance> effectSupplier, float chance) {
|
||||
// Fabric doesn't have deferred registration, so the mob effect should always be available anyway
|
||||
builder.effect(effectSupplier.get(), chance);
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,8 @@
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.EntityEvent;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.level.BaseSpawner;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
@@ -35,17 +35,17 @@ public abstract class MixinBaseSpawner {
|
||||
method = "serverTick",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/Mob;checkSpawnRules(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/entity/MobSpawnType;)Z",
|
||||
target = "Lnet/minecraft/world/entity/Mob;checkSpawnRules(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/entity/EntitySpawnReason;)Z",
|
||||
ordinal = 0
|
||||
)
|
||||
)
|
||||
private boolean checkSpawnerSpawn(Mob mob, LevelAccessor level, MobSpawnType type) {
|
||||
private boolean checkSpawnerSpawn(Mob mob, LevelAccessor level, EntitySpawnReason reason) {
|
||||
var result = EntityEvent.LIVING_CHECK_SPAWN.invoker()
|
||||
.canSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), type, (BaseSpawner) (Object) this);
|
||||
.canSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), reason, (BaseSpawner) (Object) this);
|
||||
if (result.value() != null) {
|
||||
return result.value();
|
||||
}
|
||||
return mob.checkSpawnRules(level, type) && mob.checkSpawnObstruction(level);
|
||||
return mob.checkSpawnRules(level, reason) && mob.checkSpawnObstruction(level);
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
|
||||
@@ -21,7 +21,7 @@ package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.PlayerEvent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -46,10 +46,10 @@ public class MixinBucketItem {
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
cancellable = true
|
||||
)
|
||||
public void fillBucket(Level level, Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir, ItemStack stack, BlockHitResult target) {
|
||||
public void fillBucket(Level level, Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir, ItemStack stack, BlockHitResult target) {
|
||||
var result = PlayerEvent.FILL_BUCKET.invoker().fill(player, level, stack, target);
|
||||
if (result.interruptsFurtherEvaluation() && result.value() != null) {
|
||||
cir.setReturnValue(result.asMinecraft());
|
||||
if (result != InteractionResult.PASS) {
|
||||
cir.setReturnValue(result);
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.architectury.event.events.common.EntityEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import net.minecraft.world.entity.npc.CatSpawner;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(CatSpawner.class)
|
||||
public abstract class MixinCatSpawner {
|
||||
@@ -37,14 +37,15 @@ public abstract class MixinCatSpawner {
|
||||
method = "spawnCat",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/animal/Cat;finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;",
|
||||
ordinal = 0
|
||||
target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/EntitySpawnReason;)Lnet/minecraft/world/entity/Entity;",
|
||||
ordinal = 0,
|
||||
shift = At.Shift.BY,
|
||||
by = 3
|
||||
),
|
||||
cancellable = true,
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
cancellable = true
|
||||
)
|
||||
private void checkCatSpawn(BlockPos pos, ServerLevel level, CallbackInfoReturnable<Integer> cir, Cat entity) {
|
||||
if (EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), MobSpawnType.NATURAL, null).value() == Boolean.FALSE) {
|
||||
private void checkCatSpawn(BlockPos pos, ServerLevel level, CallbackInfoReturnable<Integer> cir, @Local Cat entity) {
|
||||
if (EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), EntitySpawnReason.NATURAL, null).value() == Boolean.FALSE) {
|
||||
cir.setReturnValue(0);
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@@ -20,12 +20,9 @@
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.ChunkEvent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -42,10 +39,10 @@ public class MixinChunkMap {
|
||||
|
||||
@Inject(
|
||||
method = "save",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;write(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/nbt/CompoundTag;)Ljava/util/concurrent/CompletableFuture;", ordinal = 0),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;write(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/Supplier;)Ljava/util/concurrent/CompletableFuture;", ordinal = 0),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
private void save(ChunkAccess chunkAccess, CallbackInfoReturnable<Boolean> cir, ChunkPos pos, ChunkStatus chunkStatus, CompoundTag nbt) {
|
||||
ChunkEvent.SAVE_DATA.invoker().save(chunkAccess, this.level, nbt);
|
||||
private void save(ChunkAccess chunkAccess, CallbackInfoReturnable<Boolean> cir) {
|
||||
ChunkEvent.SAVE_DATA.invoker().save(chunkAccess, this.level);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021, 2022 architectury
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import dev.architectury.event.events.common.ChunkEvent;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiManager;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.*;
|
||||
import net.minecraft.world.level.chunk.status.ChunkType;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||
import net.minecraft.world.level.chunk.storage.RegionStorageInfo;
|
||||
import net.minecraft.world.level.levelgen.blending.BlendingData;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(ChunkSerializer.class)
|
||||
public class MixinChunkSerializer {
|
||||
@Inject(method = "read", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void load(ServerLevel serverLevel, PoiManager poiManager, RegionStorageInfo regionStorageInfo, ChunkPos chunkPos, CompoundTag compoundTag,
|
||||
CallbackInfoReturnable<ProtoChunk> cir, ChunkPos chunkPos2, UpgradeData upgradeData,
|
||||
boolean bl, ListTag listTag, int i, LevelChunkSection[] levelChunkSections, boolean bl2,
|
||||
ChunkSource chunkSource, LevelLightEngine levelLightEngine, Registry<Biome> registry,
|
||||
Codec<PalettedContainer<Holder<Biome>>> codec, boolean bl3, long m,
|
||||
ChunkType chunkType, BlendingData blendingData, ChunkAccess chunkAccess) {
|
||||
ChunkEvent.LOAD_DATA.invoker().load(chunkAccess, serverLevel, compoundTag);
|
||||
}
|
||||
}
|
||||
@@ -19,15 +19,29 @@
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.EntityEvent;
|
||||
import dev.architectury.hooks.level.entity.fabric.EntityHooksImpl;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.entity.EntityInLevelCallback;
|
||||
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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public class MixinEntity {
|
||||
@Inject(method = "hurtClient", at = @At("HEAD"), cancellable = true)
|
||||
private void hurtClient(DamageSource damageSource, CallbackInfoReturnable<Boolean> cir) {
|
||||
if ((Object) this instanceof Player) return;
|
||||
if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, 0).isFalse()) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "setLevelCallback", argsOnly = true, ordinal = 0, at = @At("HEAD"))
|
||||
public EntityInLevelCallback modifyLevelCallback_setLevelCallback(EntityInLevelCallback callback) {
|
||||
return EntityHooksImpl.wrapEntityInLevelCallback((Entity) (Object) this, callback);
|
||||
|
||||
@@ -19,20 +19,19 @@
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.architectury.event.events.common.BlockEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.item.FallingBlockEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(FallingBlockEntity.class)
|
||||
public abstract class MixinFallingBlockEntity extends Entity {
|
||||
@@ -44,9 +43,8 @@ public abstract class MixinFallingBlockEntity extends Entity {
|
||||
private BlockState blockState;
|
||||
|
||||
@Inject(method = "tick", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/block/Fallable;onLand(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/item/FallingBlockEntity;)V"),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void handleLand(CallbackInfo ci, Block block, BlockPos blockPos2, boolean bl, boolean bl2, double d, BlockState blockState) {
|
||||
BlockEvent.FALLING_LAND.invoker().onLand(this.level(), blockPos2, this.blockState, blockState, (FallingBlockEntity) (Object) this);
|
||||
target = "Lnet/minecraft/world/level/block/Fallable;onLand(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/item/FallingBlockEntity;)V"))
|
||||
public void handleLand(CallbackInfo ci, @Local BlockPos blockPos, @Local BlockState blockState) {
|
||||
BlockEvent.FALLING_LAND.invoker().onLand(this.level(), blockPos, this.blockState, blockState, (FallingBlockEntity) (Object) this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.InteractionEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.FarmBlock;
|
||||
@@ -54,7 +55,7 @@ public abstract class MixinFarmBlock {
|
||||
var triple = turnToDirtLocal.get();
|
||||
turnToDirtLocal.remove();
|
||||
if (triple != null && triple.getLeft() == pos.asLong() && triple.getRight() == entity) {
|
||||
if (InteractionEvent.FARMLAND_TRAMPLE.invoker().trample(level, pos, state, triple.getMiddle(), entity).value() != null) {
|
||||
if (InteractionEvent.FARMLAND_TRAMPLE.invoker().trample(level, pos, state, triple.getMiddle(), entity) != InteractionResult.PASS) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021, 2022 architectury
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.ExplosionEvent;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
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.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(Level.class)
|
||||
public class MixinLevel {
|
||||
@Inject(method = "explode(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Level$ExplosionInteraction;ZLnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/Holder;)Lnet/minecraft/world/level/Explosion;",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Explosion;explode()V"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void explodePre(Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionDamageCalculator, double d, double e, double f, float g, boolean bl, Level.ExplosionInteraction explosionInteraction, boolean bl2, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder<SoundEvent> soundEvent, CallbackInfoReturnable<Explosion> cir, Explosion.BlockInteraction blockInteraction, Explosion explosion) {
|
||||
if (ExplosionEvent.PRE.invoker().explode((Level) (Object) this, explosion).isFalse()) {
|
||||
cir.setReturnValue(explosion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.EntityEvent;
|
||||
import dev.architectury.extensions.ItemExtension;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -33,8 +34,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public class MixinLivingEntity {
|
||||
@Inject(method = "hurt", at = @At("HEAD"), cancellable = true)
|
||||
private void hurt(DamageSource damageSource, float f, CallbackInfoReturnable<Boolean> cir) {
|
||||
@Inject(method = "hurtServer", at = @At("HEAD"), cancellable = true)
|
||||
private void hurtServer(ServerLevel level, DamageSource damageSource, float f, CallbackInfoReturnable<Boolean> cir) {
|
||||
if ((Object) this instanceof Player) return;
|
||||
if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, f).isFalse()) {
|
||||
cir.setReturnValue(false);
|
||||
|
||||
@@ -21,8 +21,8 @@ package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.EntityEvent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.NaturalSpawner;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -46,7 +46,7 @@ public abstract class MixinNaturalSpawner {
|
||||
)
|
||||
)
|
||||
private static boolean overrideNaturalSpawnCondition(ServerLevel level, Mob entity, double f) {
|
||||
var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, entity.xOld, entity.yOld, entity.zOld, MobSpawnType.NATURAL, null);
|
||||
var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, entity.xOld, entity.yOld, entity.zOld, EntitySpawnReason.NATURAL, null);
|
||||
if (result.value() != null) {
|
||||
return result.value();
|
||||
} else {
|
||||
@@ -58,16 +58,16 @@ public abstract class MixinNaturalSpawner {
|
||||
method = "spawnMobsForChunkGeneration",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/Mob;checkSpawnRules(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/entity/MobSpawnType;)Z",
|
||||
target = "Lnet/minecraft/world/entity/Mob;checkSpawnRules(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/entity/EntitySpawnReason;)Z",
|
||||
ordinal = 0
|
||||
)
|
||||
)
|
||||
private static boolean overrideChunkGenSpawnCondition(Mob mob, LevelAccessor level, MobSpawnType type) {
|
||||
var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(mob, level, mob.xOld, mob.yOld, mob.zOld, MobSpawnType.CHUNK_GENERATION, null);
|
||||
private static boolean overrideChunkGenSpawnCondition(Mob mob, LevelAccessor level, EntitySpawnReason reason) {
|
||||
var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(mob, level, mob.xOld, mob.yOld, mob.zOld, reason, null);
|
||||
if (result.value() != null) {
|
||||
return result.value();
|
||||
} else {
|
||||
return mob.checkSpawnRules(level, type);
|
||||
return mob.checkSpawnRules(level, reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,21 +19,18 @@
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.architectury.event.events.common.EntityEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.monster.PatrollingMonster;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.PatrolSpawner;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(PatrolSpawner.class)
|
||||
public abstract class MixinPatrolSpawner {
|
||||
@@ -42,16 +39,15 @@ public abstract class MixinPatrolSpawner {
|
||||
method = "spawnPatrolMember",
|
||||
at = @At(
|
||||
value = "INVOKE_ASSIGN",
|
||||
target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;)Lnet/minecraft/world/entity/Entity;",
|
||||
target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/EntitySpawnReason;)Lnet/minecraft/world/entity/Entity;",
|
||||
ordinal = 0,
|
||||
shift = At.Shift.BY,
|
||||
by = 2
|
||||
),
|
||||
cancellable = true,
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
cancellable = true
|
||||
)
|
||||
private void checkPatrolSpawn(ServerLevel level, BlockPos pos, RandomSource r, boolean b, CallbackInfoReturnable<Boolean> cir, BlockState blockState, PatrollingMonster entity) {
|
||||
var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), MobSpawnType.PATROL, null);
|
||||
private void checkPatrolSpawn(ServerLevel level, BlockPos pos, RandomSource r, boolean b, CallbackInfoReturnable<Boolean> cir, @Local PatrollingMonster entity) {
|
||||
var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), EntitySpawnReason.PATROL, null);
|
||||
if (result.value() != null) {
|
||||
cir.setReturnValue(result.value());
|
||||
}
|
||||
|
||||
@@ -19,26 +19,17 @@
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.architectury.event.events.common.EntityEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.ServerStatsCounter;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.EntitySpawnReason;
|
||||
import net.minecraft.world.entity.monster.Phantom;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.PhantomSpawner;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@Mixin(PhantomSpawner.class)
|
||||
public abstract class MixinPhantomSpawner {
|
||||
@@ -47,18 +38,15 @@ public abstract class MixinPhantomSpawner {
|
||||
method = "tick",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/monster/Phantom;finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;",
|
||||
target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/EntitySpawnReason;)Lnet/minecraft/world/entity/Entity;",
|
||||
ordinal = 0,
|
||||
shift = At.Shift.BEFORE
|
||||
shift = At.Shift.BY,
|
||||
by = 3
|
||||
),
|
||||
cancellable = true,
|
||||
locals = LocalCapture.CAPTURE_FAILSOFT // SOFT, because this will break in 2 seconds
|
||||
cancellable = true
|
||||
)
|
||||
private void checkPhantomSpawn(ServerLevel level, boolean bl, boolean bl2, CallbackInfoReturnable<Integer> cir,
|
||||
RandomSource random, int i, Iterator<ServerPlayer> it, ServerPlayer player, BlockPos pos, DifficultyInstance diff,
|
||||
ServerStatsCounter serverStatsCounter, int j, int k, BlockPos pos2,
|
||||
BlockState blockState, FluidState fluidState, SpawnGroupData sgd, int l, int m, Phantom entity) {
|
||||
if (EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), MobSpawnType.NATURAL, null).value() == Boolean.FALSE) {
|
||||
private void checkPhantomSpawn(ServerLevel level, boolean bl, boolean bl2, CallbackInfoReturnable<Integer> cir, @Local(ordinal = 1) BlockPos pos, @Local Phantom entity) {
|
||||
if (EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), EntitySpawnReason.NATURAL, null).value() == Boolean.FALSE) {
|
||||
cir.setReturnValue(0);
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021, 2022 architectury
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.architectury.event.events.common.ChunkEvent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiManager;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.chunk.storage.RegionStorageInfo;
|
||||
import net.minecraft.world.level.chunk.storage.SerializableChunkData;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(SerializableChunkData.class)
|
||||
public class MixinSerializableChunkData {
|
||||
@Inject(method = "read", at = @At("RETURN"))
|
||||
private void load(ServerLevel serverLevel, PoiManager poiManager, RegionStorageInfo regionStorageInfo, ChunkPos chunkPos,
|
||||
CallbackInfoReturnable<ProtoChunk> cir,
|
||||
@Local ChunkAccess chunkAccess) {
|
||||
// TODO: Get the CompoundTag from constructor somewhere
|
||||
ChunkEvent.LOAD_DATA.invoker().load(chunkAccess, serverLevel);
|
||||
}
|
||||
}
|
||||
@@ -19,32 +19,27 @@
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.architectury.event.events.common.ExplosionEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import net.minecraft.world.level.ServerExplosion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Mixin(Explosion.class)
|
||||
public class MixinExplosion {
|
||||
@Mixin(ServerExplosion.class)
|
||||
public abstract class MixinServerExplosion {
|
||||
@Shadow
|
||||
@Final
|
||||
private Level level;
|
||||
public abstract ServerLevel level();
|
||||
|
||||
@SuppressWarnings("InvalidInjectorMethodSignature")
|
||||
@Inject(method = "explode", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;<init>(DDD)V", ordinal = 1),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void explodePost(CallbackInfo ci, Set<BlockPos> set, int i, float q, int r, int s, int t, int u, int v, int w, List<Entity> list) {
|
||||
ExplosionEvent.DETONATE.invoker().explode(level, (Explosion) (Object) this, list);
|
||||
@Inject(method = "hurtEntities", at = @At(value = "INVOKE", target = "Ljava/util/List;iterator()Ljava/util/Iterator;", ordinal = 0))
|
||||
private void explodePost(CallbackInfo ci, @Local List<Entity> list) {
|
||||
ExplosionEvent.DETONATE.invoker().explode(level(), (ServerExplosion) (Object) this, list);
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,21 @@
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.architectury.event.events.common.ExplosionEvent;
|
||||
import dev.architectury.event.events.common.LifecycleEvent;
|
||||
import dev.architectury.hooks.fabric.PersistentEntitySectionManagerHooks;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.ProgressListener;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerExplosion;
|
||||
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -50,4 +60,12 @@ public class MixinServerLevel {
|
||||
private void addEntity(Entity entity, CallbackInfoReturnable<Boolean> cir) {
|
||||
((PersistentEntitySectionManagerHooks) this.entityManager).architectury_attachLevel((ServerLevel) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "explode(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Level$ExplosionInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/Holder;)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ServerExplosion;explode()V"), cancellable = true)
|
||||
private void explodePre(Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionDamageCalculator, double d, double e, double f, float g, boolean bl, Level.ExplosionInteraction explosionInteraction, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder<SoundEvent> soundEvent, CallbackInfo ci, @Local Explosion.BlockInteraction blockInteraction, @Local ServerExplosion explosion) {
|
||||
if (ExplosionEvent.PRE.invoker().explode((Level) (Object) this, explosion).isFalse()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import dev.architectury.event.events.common.EntityEvent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -30,8 +31,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(value = {Player.class})
|
||||
public class PlayerAttackInvoker {
|
||||
@Inject(method = "hurt", at = @At("HEAD"), cancellable = true)
|
||||
private void hurt(DamageSource damageSource, float f, CallbackInfoReturnable<Boolean> cir) {
|
||||
@Inject(method = "hurtServer", at = @At("HEAD"), cancellable = true)
|
||||
private void hurtServer(ServerLevel level, DamageSource damageSource, float f, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, f).isFalse() && (Object) this instanceof Player) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import dev.architectury.event.events.common.EntityEvent;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.player.RemotePlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -30,11 +29,11 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(value = {LocalPlayer.class, RemotePlayer.class})
|
||||
@Mixin(value = {RemotePlayer.class})
|
||||
public class ClientPlayerAttackInvoker {
|
||||
@Inject(method = "hurt", at = @At("HEAD"), cancellable = true)
|
||||
private void hurt(DamageSource damageSource, float f, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, f).isFalse() && (Object) this instanceof Player) {
|
||||
@Inject(method = "hurtClient", at = @At("HEAD"), cancellable = true)
|
||||
private void hurt(DamageSource damageSource, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, 0).isFalse() && (Object) this instanceof Player) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,21 +26,19 @@ import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
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 java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Mixin(ClientLevel.class)
|
||||
public class MixinClientLevel {
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void construct(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey<Level> resourceKey, Holder<DimensionType> holder, int i, int j, Supplier<ProfilerFiller> supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) {
|
||||
private void construct(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey<Level> resourceKey, Holder<DimensionType> holder, int i, int j, LevelRenderer levelRenderer, boolean bl, long l, int k, CallbackInfo ci) {
|
||||
ClientLifecycleEvent.CLIENT_LEVEL_LOAD.invoker().act((ClientLevel) (Object) this);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,8 @@ import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.multiplayer.CommonListenerCookie;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.game.ClientboundLoginPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundRespawnPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.world.item.crafting.RecipeAccess;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@@ -44,11 +41,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ClientPacketListener.class)
|
||||
public abstract class MixinClientPacketListener extends ClientCommonPacketListenerImpl {
|
||||
@Shadow
|
||||
@Final
|
||||
private RecipeManager recipeManager;
|
||||
@Shadow
|
||||
private ClientLevel level;
|
||||
|
||||
@Shadow
|
||||
public abstract RecipeAccess recipes();
|
||||
|
||||
@Unique
|
||||
private LocalPlayer tmpPlayer;
|
||||
|
||||
@@ -75,7 +73,17 @@ public abstract class MixinClientPacketListener extends ClientCommonPacketListen
|
||||
|
||||
@Inject(method = "handleUpdateRecipes", at = @At("RETURN"))
|
||||
private void handleUpdateRecipes(ClientboundUpdateRecipesPacket clientboundUpdateRecipesPacket, CallbackInfo ci) {
|
||||
ClientRecipeUpdateEvent.EVENT.invoker().update(recipeManager);
|
||||
ClientRecipeUpdateEvent.EVENT.invoker().update(recipes());
|
||||
}
|
||||
|
||||
@Inject(method = "handleRecipeBookAdd", at = @At("RETURN"))
|
||||
private void handleRecipeBookAdd(ClientboundRecipeBookAddPacket packet, CallbackInfo ci) {
|
||||
ClientRecipeUpdateEvent.ADD.invoker().add(recipes(), packet.entries());
|
||||
}
|
||||
|
||||
@Inject(method = "handleRecipeBookRemove", at = @At("RETURN"))
|
||||
private void handleRecipeBookRemove(ClientboundRecipeBookRemovePacket packet, CallbackInfo ci) {
|
||||
ClientRecipeUpdateEvent.REMOVE.invoker().remove(recipes(), packet.recipes());
|
||||
}
|
||||
|
||||
@Inject(method = "sendChat(Ljava/lang/String;)V", at = @At(value = "HEAD"), cancellable = true)
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021, 2022 architectury
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import com.mojang.blaze3d.shaders.Program;
|
||||
import net.minecraft.client.renderer.EffectInstance;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Unique
|
||||
@Mixin(value = EffectInstance.class, priority = 950)
|
||||
public class MixinEffectInstance {
|
||||
@Redirect(
|
||||
method = "<init>",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/resources/ResourceLocation;withDefaultNamespace(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;",
|
||||
ordinal = 0)
|
||||
)
|
||||
private ResourceLocation mojangPls(String _0, ResourceProvider rm, String str) {
|
||||
return mojangPls(ResourceLocation.parse(str), ".json");
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "getOrCreate",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/resources/ResourceLocation;withDefaultNamespace(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;",
|
||||
ordinal = 0)
|
||||
)
|
||||
private static ResourceLocation mojangPls(String _0, ResourceProvider rm, Program.Type type, String str) {
|
||||
return mojangPls(ResourceLocation.parse(str), type.getExtension());
|
||||
}
|
||||
|
||||
private static ResourceLocation mojangPls(ResourceLocation rl, String ext) {
|
||||
return ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "shaders/program/" + rl.getPath() + ext);
|
||||
}
|
||||
}
|
||||
@@ -19,29 +19,18 @@
|
||||
|
||||
package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.shaders.Program;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.architectury.event.events.client.ClientGuiEvent;
|
||||
import dev.architectury.event.events.client.ClientReloadShadersEvent;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fStack;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(value = GameRenderer.class, priority = 1100)
|
||||
public abstract class MixinGameRenderer {
|
||||
@@ -54,8 +43,8 @@ public abstract class MixinGameRenderer {
|
||||
|
||||
@Inject(method = "render(Lnet/minecraft/client/DeltaTracker;Z)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lnet/minecraft/client/gui/GuiGraphics;IIF)V",
|
||||
ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION, cancellable = true)
|
||||
public void renderScreenPre(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) {
|
||||
ordinal = 0), cancellable = true)
|
||||
public void renderScreenPre(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int mouseX, @Local(ordinal = 1) int mouseY, @Local GuiGraphics graphics) {
|
||||
if (ClientGuiEvent.RENDER_PRE.invoker().render(minecraft.screen, graphics, mouseX, mouseY, tickDelta).isFalse()) {
|
||||
ci.cancel();
|
||||
}
|
||||
@@ -63,16 +52,8 @@ public abstract class MixinGameRenderer {
|
||||
|
||||
@Inject(method = "render(Lnet/minecraft/client/DeltaTracker;Z)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lnet/minecraft/client/gui/GuiGraphics;IIF)V",
|
||||
shift = At.Shift.AFTER, ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
|
||||
public void renderScreenPost(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) {
|
||||
shift = At.Shift.AFTER, ordinal = 0))
|
||||
public void renderScreenPost(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int mouseX, @Local(ordinal = 1) int mouseY, @Local GuiGraphics graphics) {
|
||||
ClientGuiEvent.RENDER_POST.invoker().render(minecraft.screen, graphics, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
|
||||
@Inject(method = "reloadShaders",
|
||||
at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
|
||||
public void reloadShaders(ResourceProvider provider, CallbackInfo ci, List<Program> programs, List<Pair<ShaderInstance, Consumer<ShaderInstance>>> shaders) {
|
||||
ClientReloadShadersEvent.EVENT.invoker().reload(provider, (shader, callback) -> {
|
||||
shaders.add(Pair.of(shader, callback));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,14 @@
|
||||
package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import dev.architectury.event.events.client.ClientTooltipEvent;
|
||||
import dev.architectury.impl.TooltipEventColorContextImpl;
|
||||
import dev.architectury.impl.TooltipEventPositionContextImpl;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -52,28 +53,25 @@ public abstract class MixinGuiGraphics {
|
||||
}
|
||||
|
||||
@Inject(method = "renderTooltipInternal", at = @At("HEAD"), cancellable = true)
|
||||
private void renderTooltip(Font font, List<? extends ClientTooltipComponent> list, int x, int y, ClientTooltipPositioner positioner, CallbackInfo ci) {
|
||||
private void renderTooltip(Font font, List<ClientTooltipComponent> list, int x, int y, ClientTooltipPositioner positioner, @Nullable ResourceLocation background, CallbackInfo ci) {
|
||||
if (!list.isEmpty()) {
|
||||
var colorContext = TooltipEventColorContextImpl.CONTEXT.get();
|
||||
colorContext.reset();
|
||||
var positionContext = tooltipPositionContext.get();
|
||||
positionContext.reset(x, y);
|
||||
if (ClientTooltipEvent.RENDER_PRE.invoker().renderTooltip((GuiGraphics) (Object) this, list, x, y).isFalse()) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
ClientTooltipEvent.RENDER_MODIFY_COLOR.invoker().renderTooltip((GuiGraphics) (Object) this, x, y, colorContext);
|
||||
ClientTooltipEvent.RENDER_MODIFY_POSITION.invoker().renderTooltip((GuiGraphics) (Object) this, positionContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V",
|
||||
@ModifyVariable(method = "renderTooltipInternal",
|
||||
at = @At(value = "HEAD"), ordinal = 0, argsOnly = true)
|
||||
private int modifyTooltipX(int original) {
|
||||
return tooltipPositionContext.get().getTooltipX();
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V",
|
||||
@ModifyVariable(method = "renderTooltipInternal",
|
||||
at = @At(value = "HEAD"), ordinal = 1, argsOnly = true)
|
||||
private int modifyTooltipY(int original) {
|
||||
return tooltipPositionContext.get().getTooltipY();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.architectury.event.EventResult;
|
||||
import dev.architectury.event.events.client.ClientRawInputEvent;
|
||||
import dev.architectury.event.events.client.ClientScreenInputEvent;
|
||||
@@ -34,7 +35,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(KeyboardHandler.class)
|
||||
public class MixinKeyboardHandler {
|
||||
@@ -42,7 +42,7 @@ public class MixinKeyboardHandler {
|
||||
@Final
|
||||
private Minecraft minecraft;
|
||||
|
||||
@ModifyVariable(method = {"method_1458", "lambda$charTyped$5"}, at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
@ModifyVariable(method = {"method_1458", "lambda$charTyped$6"}, at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private static GuiEventListener wrapCharTypedFirst(GuiEventListener screen) {
|
||||
if (screen instanceof ScreenInputDelegate delegate) {
|
||||
return delegate.architectury_delegateInputs();
|
||||
@@ -50,7 +50,7 @@ public class MixinKeyboardHandler {
|
||||
return screen;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = {"method_1473", "lambda$charTyped$6"}, at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
@ModifyVariable(method = {"method_1473", "lambda$charTyped$7"}, at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private static GuiEventListener wrapCharTypedSecond(GuiEventListener screen) {
|
||||
if (screen instanceof ScreenInputDelegate delegate) {
|
||||
return delegate.architectury_delegateInputs();
|
||||
@@ -79,9 +79,9 @@ public class MixinKeyboardHandler {
|
||||
|
||||
@Inject(method = "keyPress", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/gui/screens/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V",
|
||||
ordinal = 0, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
ordinal = 0, shift = At.Shift.AFTER),
|
||||
cancellable = true)
|
||||
public void onKeyAfter(long long_1, int int_1, int int_2, int int_3, int int_4, CallbackInfo info, boolean f3Pressed, Screen screen, boolean[] bls) {
|
||||
public void onKeyAfter(long long_1, int int_1, int int_2, int int_3, int int_4, CallbackInfo info, @Local Screen screen, @Local boolean[] bls) {
|
||||
if (!info.isCancelled() && !bls[0]) {
|
||||
EventResult result;
|
||||
if (int_3 != 1 && int_3 != 2) {
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021, 2022 architectury
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import dev.architectury.impl.TooltipEventColorContextImpl;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(TooltipRenderUtil.class)
|
||||
public abstract class MixinTooltipRenderUtil {
|
||||
@ModifyConstant(method = "renderTooltipBackground", constant = @Constant(intValue = 0xf0100010))
|
||||
private static int modifyTooltipBackgroundColor(int original) {
|
||||
return TooltipEventColorContextImpl.CONTEXT.get().getBackgroundColor();
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "renderTooltipBackground", constant = @Constant(intValue = 0x505000ff))
|
||||
private static int modifyTooltipOutlineGradientTopColor(int original) {
|
||||
return TooltipEventColorContextImpl.CONTEXT.get().getOutlineGradientTopColor();
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "renderTooltipBackground", constant = @Constant(intValue = 0x5028007f))
|
||||
private static int modifyTooltipOutlineGradientBottomColor(int original) {
|
||||
return TooltipEventColorContextImpl.CONTEXT.get().getOutlineGradientBottomColor();
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class CreativeTabRegistryImpl {
|
||||
|
||||
private void resolve() {
|
||||
if (this.tab == null) {
|
||||
this.tab = BuiltInRegistries.CREATIVE_MODE_TAB.get(name);
|
||||
this.tab = BuiltInRegistries.CREATIVE_MODE_TAB.getValue(name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -59,8 +59,8 @@ public class ReloadListenerRegistryImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, ProfilerFiller profilerFiller, ProfilerFiller profilerFiller2, Executor executor, Executor executor2) {
|
||||
return listener.reload(preparationBarrier, resourceManager, profilerFiller, profilerFiller2, executor, executor2);
|
||||
public CompletableFuture<Void> reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, Executor executor, Executor executor2) {
|
||||
return listener.reload(preparationBarrier, resourceManager, executor, executor2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,23 +19,23 @@
|
||||
|
||||
package dev.architectury.registry.fuel.fabric;
|
||||
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
|
||||
public class FuelRegistryImpl {
|
||||
public static void register(int time, ItemLike... items) {
|
||||
for (var item : items) {
|
||||
/*for (var item : items) {
|
||||
if (time >= 0) {
|
||||
FuelRegistry.INSTANCE.add(item, time);
|
||||
} else {
|
||||
FuelRegistry.INSTANCE.remove(item);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public static int get(ItemStack stack) {
|
||||
var time = FuelRegistry.INSTANCE.get(stack.getItem());
|
||||
return time == null ? 0 : time;
|
||||
/*var time = FuelRegistry.INSTANCE.get(stack.getItem());
|
||||
return time == null ? 0 : time;*/
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,10 +154,10 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable addCarver(GenerationStep.Carving carving, Holder<ConfiguredWorldCarver<?>> feature) {
|
||||
public Mutable addCarver(Holder<ConfiguredWorldCarver<?>> feature) {
|
||||
Either<ResourceKey<ConfiguredWorldCarver<?>>, ConfiguredWorldCarver<?>> unwrap = feature.unwrap();
|
||||
if (unwrap.left().isPresent()) {
|
||||
this.context.addCarver(carving, unwrap.left().get());
|
||||
this.context.addCarver(unwrap.left().get());
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Cannot add a carver that is not registered: " + unwrap.right().orElseThrow());
|
||||
}
|
||||
@@ -165,8 +165,8 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable addCarver(GenerationStep.Carving carving, ResourceKey<ConfiguredWorldCarver<?>> feature) {
|
||||
this.context.addCarver(carving, feature);
|
||||
public Mutable addCarver(ResourceKey<ConfiguredWorldCarver<?>> feature) {
|
||||
this.context.addCarver(feature);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -177,8 +177,8 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable removeCarver(GenerationStep.Carving carving, ResourceKey<ConfiguredWorldCarver<?>> feature) {
|
||||
context.removeCarver(carving, feature);
|
||||
public Mutable removeCarver(ResourceKey<ConfiguredWorldCarver<?>> feature) {
|
||||
context.removeCarver(feature);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class RegistrarManagerImpl {
|
||||
|
||||
private static void listen(ResourceKey<?> resourceKey, ResourceLocation id, Consumer<?> listener) {
|
||||
if (LISTENED_REGISTRIES.add(resourceKey)) {
|
||||
Registry<?> registry = java.util.Objects.requireNonNull(BuiltInRegistries.REGISTRY.get(resourceKey.location()), "Registry " + resourceKey + " not found!");
|
||||
Registry<?> registry = java.util.Objects.requireNonNull(BuiltInRegistries.REGISTRY.getValue(resourceKey.location()), "Registry " + resourceKey + " not found!");
|
||||
RegistryEntryAddedCallback.event(registry).register((rawId, entryId, object) -> {
|
||||
RegistryEntryId<?> registryEntryId = new RegistryEntryId<>(resourceKey, entryId);
|
||||
for (Consumer<?> consumer : LISTENERS.get(registryEntryId)) {
|
||||
@@ -78,7 +78,7 @@ public class RegistrarManagerImpl {
|
||||
|
||||
@Override
|
||||
public <T> Registrar<T> get(ResourceKey<Registry<T>> key) {
|
||||
return new RegistrarImpl<>(modId, (Registry<T>) java.util.Objects.requireNonNull(BuiltInRegistries.REGISTRY.get(key.location()), "Registry " + key + " not found!"));
|
||||
return new RegistrarImpl<>(modId, (Registry<T>) java.util.Objects.requireNonNull(BuiltInRegistries.REGISTRY.getValue(key.location()), "Registry " + key + " not found!"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,7 +250,7 @@ public class RegistrarManagerImpl {
|
||||
|
||||
@Override
|
||||
public @Nullable T get(ResourceLocation id) {
|
||||
return delegate.get(id);
|
||||
return delegate.getValue(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -286,7 +286,7 @@ public class RegistrarManagerImpl {
|
||||
@Override
|
||||
@Nullable
|
||||
public Holder<T> getHolder(ResourceKey<T> key) {
|
||||
return delegate.getHolder(key).orElse(null);
|
||||
return delegate.get(key).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
"client.MixinClientLevel",
|
||||
"client.MixinClientPacketListener",
|
||||
"client.MixinDebugScreenOverlay",
|
||||
"client.MixinEffectInstance",
|
||||
"client.MixinFabricClientCommandSource",
|
||||
"client.MixinGameRenderer",
|
||||
"client.MixinGuiGraphics",
|
||||
@@ -20,8 +19,7 @@
|
||||
"client.MixinMinecraft",
|
||||
"client.MixinMouseHandler",
|
||||
"client.MixinMultiPlayerGameMode",
|
||||
"client.MixinScreen",
|
||||
"client.MixinTooltipRenderUtil"
|
||||
"client.MixinScreen"
|
||||
],
|
||||
"mixins": [
|
||||
"BiomeAccessor",
|
||||
@@ -34,17 +32,14 @@
|
||||
"MixinBucketItem",
|
||||
"MixinCatSpawner",
|
||||
"MixinChunkMap",
|
||||
"MixinChunkSerializer",
|
||||
"MixinCommands",
|
||||
"MixinDedicatedServer",
|
||||
"MixinEntity",
|
||||
"MixinExplosion",
|
||||
"MixinFallingBlockEntity",
|
||||
"MixinFarmBlock",
|
||||
"MixinFurnaceResultSlot",
|
||||
"MixinInventory",
|
||||
"MixinItemEntity",
|
||||
"MixinLevel",
|
||||
"MixinLivingEntity",
|
||||
"MixinNaturalSpawner",
|
||||
"MixinOcelot",
|
||||
@@ -55,6 +50,8 @@
|
||||
"MixinPlayerAdvancements",
|
||||
"MixinPlayerList",
|
||||
"MixinResultSlot",
|
||||
"MixinSerializableChunkData",
|
||||
"MixinServerExplosion",
|
||||
"MixinServerLevel",
|
||||
"MixinServerPlayer",
|
||||
"MixinServerPlayerGameMode",
|
||||
|
||||
Reference in New Issue
Block a user