Update to 24w40a

This commit is contained in:
shedaniel
2024-10-06 05:07:39 +08:00
parent a14036d12b
commit fe43bbddc9
73 changed files with 377 additions and 838 deletions

View File

@@ -23,11 +23,11 @@ import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.architectury.platform.Platform;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
@@ -78,7 +78,7 @@ public abstract class ArchitecturyFlowingFluid extends FlowingFluid {
}
@Override
protected boolean canConvertToSource(Level level) {
protected boolean canConvertToSource(ServerLevel level) {
return attributes.canConvertToSource();
}

View File

@@ -24,9 +24,9 @@ import net.minecraft.core.Direction;
import net.minecraft.core.dispenser.BlockSource;
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.core.dispenser.DispenseItemBehavior;
import net.minecraft.world.entity.EntitySpawnReason;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SpawnEggItem;
import net.minecraft.world.level.block.DispenserBlock;
@@ -50,7 +50,7 @@ public class ArchitecturySpawnEggItem extends SpawnEggItem {
EntityType<?> entityType = ((SpawnEggItem) stack.getItem()).getType(stack);
try {
entityType.spawn(source.level(), stack, null, source.pos().relative(direction), MobSpawnType.DISPENSER, direction != Direction.UP, false);
entityType.spawn(source.level(), stack, null, source.pos().relative(direction), EntitySpawnReason.DISPENSER, direction != Direction.UP, false);
} catch (Exception var6) {
LOGGER.error("Error while dispensing spawn egg from dispenser at {}", source.pos(), var6);
return ItemStack.EMPTY;

View File

@@ -19,8 +19,6 @@
package dev.architectury.event;
import net.minecraft.world.InteractionResultHolder;
/**
* A result from an event, determines if the event should continue to other listeners,
* determines the outcome of the event, and provides extra result for the outcome.
@@ -170,13 +168,4 @@ public class CompoundEventResult<T> {
public T object() {
return object;
}
/**
* Returns the Minecraft-facing result, however ignores {@link #interruptsFurtherEvaluation()}.
*
* @return the Minecraft-facing result
*/
public InteractionResultHolder<T> asMinecraft() {
return new InteractionResultHolder<>(result.asMinecraft(), object);
}
}

View File

@@ -23,6 +23,7 @@ import com.google.common.reflect.AbstractInvocationHandler;
import dev.architectury.annotations.ForgeEvent;
import dev.architectury.annotations.ForgeEventCancellable;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.InteractionResult;
import org.jetbrains.annotations.ApiStatus;
import java.lang.invoke.MethodHandles;
@@ -110,6 +111,28 @@ public final class EventFactory {
}));
}
@SafeVarargs
public static <T> Event<T> createInteractionResult(T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");
return createInteractionResult((Class<T>) typeGetter.getClass().getComponentType());
}
@SuppressWarnings("UnstableApiUsage")
public static <T> Event<T> createInteractionResult(Class<T> clazz) {
return of(listeners -> (T) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{clazz}, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
for (var listener : listeners) {
var result = (InteractionResult) Objects.requireNonNull(invokeMethod(listener, method, args));
if (result != InteractionResult.PASS) {
return result;
}
}
return InteractionResult.PASS;
}
}));
}
@SafeVarargs
public static <T> Event<Consumer<T>> createConsumerLoop(T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");

View File

@@ -23,20 +23,47 @@ import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.network.protocol.game.ClientboundRecipeBookAddPacket;
import net.minecraft.world.item.crafting.RecipeAccess;
import net.minecraft.world.item.crafting.display.RecipeDisplayId;
import org.jetbrains.annotations.ApiStatus;
import java.util.List;
@Environment(EnvType.CLIENT)
public interface ClientRecipeUpdateEvent {
/**
* @see ClientRecipeUpdateEvent#update(RecipeManager)
* @see ClientRecipeUpdateEvent#update(RecipeAccess)
*/
Event<ClientRecipeUpdateEvent> EVENT = EventFactory.createLoop();
/**
* @see ClientRecipeUpdateEvent.Add#add(RecipeAccess, List)
*/
@ApiStatus.Experimental
Event<Add> ADD = EventFactory.createLoop();
/**
* @see ClientRecipeUpdateEvent.Remove#remove(RecipeAccess, List)
*/
@ApiStatus.Experimental
Event<Remove> REMOVE = EventFactory.createLoop();
/**
* Invoked when the client has received an updated list of recipes from the server.
* Equivalent to Forge's {@code RecipesUpdatedEvent} event.
*
* @param recipeManager The recipe manager.
* @param recipeAccess The recipe access.
*/
void update(RecipeManager recipeManager);
void update(RecipeAccess recipeAccess);
@ApiStatus.Experimental
interface Add {
void add(RecipeAccess recipeAccess, List<ClientboundRecipeBookAddPacket.Entry> entries);
}
@ApiStatus.Experimental
interface Remove {
void remove(RecipeAccess recipeAccess, List<RecipeDisplayId> ids);
}
}

View File

@@ -1,47 +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.event.events.client;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.server.packs.resources.ResourceProvider;
import java.util.function.Consumer;
@Environment(EnvType.CLIENT)
@FunctionalInterface
public interface ClientReloadShadersEvent {
/**
* Invoked when client reloads shaders.
*
* @see net.minecraft.client.renderer.GameRenderer#reloadShaders(ResourceProvider)
*/
Event<ClientReloadShadersEvent> EVENT = EventFactory.createLoop();
void reload(ResourceProvider provider, ShadersSink sink);
@FunctionalInterface
interface ShadersSink {
void registerShader(ShaderInstance shader, Consumer<ShaderInstance> callback);
}
}

View File

@@ -49,10 +49,6 @@ public interface ClientTooltipEvent {
* @see RenderModifyPosition#renderTooltip(GuiGraphics, PositionContext)
*/
Event<RenderModifyPosition> RENDER_MODIFY_POSITION = EventFactory.createLoop();
/**
* @see RenderModifyColor#renderTooltip(GuiGraphics, int, int, ColorContext)
*/
Event<RenderModifyColor> RENDER_MODIFY_COLOR = EventFactory.createLoop();
static AdditionalContexts additionalContexts() {
return TooltipAdditionalContextsImpl.get();
@@ -107,19 +103,6 @@ public interface ClientTooltipEvent {
void renderTooltip(GuiGraphics graphics, PositionContext context);
}
@Environment(EnvType.CLIENT)
interface RenderModifyColor {
/**
* Event to manipulate the color of the tooltip.
*
* @param graphics The graphics context.
* @param x The x-coordinate of the tooltip.
* @param y The y-coordinate of the tooltip.
* @param context The current color context.
*/
void renderTooltip(GuiGraphics graphics, int x, int y, ColorContext context);
}
@Environment(EnvType.CLIENT)
interface PositionContext {
int getTooltipX();
@@ -130,19 +113,4 @@ public interface ClientTooltipEvent {
void setTooltipY(int y);
}
@Environment(EnvType.CLIENT)
interface ColorContext {
int getBackgroundColor();
void setBackgroundColor(int color);
int getOutlineGradientTopColor();
void setOutlineGradientTopColor(int color);
int getOutlineGradientBottomColor();
void setOutlineGradientBottomColor(int color);
}
}

View File

@@ -28,11 +28,11 @@ import org.jetbrains.annotations.Nullable;
public interface ChunkEvent {
/**
* @see SaveData#save(ChunkAccess, ServerLevel, CompoundTag)
* @see SaveData#save(ChunkAccess, ServerLevel)
*/
Event<SaveData> SAVE_DATA = EventFactory.createLoop();
/**
* @see LoadData#load(ChunkAccess, ServerLevel, CompoundTag)
* @see LoadData#load(ChunkAccess, ServerLevel)
*/
Event<LoadData> LOAD_DATA = EventFactory.createLoop();
@@ -44,9 +44,8 @@ public interface ChunkEvent {
*
* @param chunk The chunk that is saved.
* @param level The level the chunk is in.
* @param nbt The chunk data that is written to the save file.
*/
void save(ChunkAccess chunk, ServerLevel level, CompoundTag nbt);
void save(ChunkAccess chunk, ServerLevel level);
}
interface LoadData {
@@ -57,8 +56,7 @@ public interface ChunkEvent {
*
* @param chunk The chunk that is loaded.
* @param level The level the chunk is in, may be {@code null}.
* @param nbt The chunk data that was read from the save file.
*/
void load(ChunkAccess chunk, @Nullable ServerLevel level, CompoundTag nbt);
void load(ChunkAccess chunk, @Nullable ServerLevel level);
}
}

View File

@@ -22,11 +22,10 @@ package dev.architectury.event.events.common;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntitySpawnReason;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BaseSpawner;
@@ -44,7 +43,7 @@ public interface EntityEvent {
*/
Event<LivingHurt> LIVING_HURT = EventFactory.createEventResult();
/**
* @see LivingCheckSpawn#canSpawn(LivingEntity, LevelAccessor, double, double, double, MobSpawnType, BaseSpawner)
* @see LivingCheckSpawn#canSpawn(LivingEntity, LevelAccessor, double, double, double, EntitySpawnReason, BaseSpawner)
*/
Event<LivingCheckSpawn> LIVING_CHECK_SPAWN = EventFactory.createEventResult();
/**
@@ -102,10 +101,10 @@ public interface EntityEvent {
* @param z The z-coordinate the spawn position.
* @param type The source of spawning.
* @param spawner The spawner. Can be {@code null}.
* @return A {@link InteractionResultHolder} determining the outcome of the event,
* @return A {@link EventResult} determining the outcome of the event,
* if an outcome is set, the vanilla result is overridden.
*/
EventResult canSpawn(LivingEntity entity, LevelAccessor world, double x, double y, double z, MobSpawnType type, @Nullable BaseSpawner spawner);
EventResult canSpawn(LivingEntity entity, LevelAccessor world, double x, double y, double z, EntitySpawnReason type, @Nullable BaseSpawner spawner);
}
interface Add {

View File

@@ -19,16 +19,15 @@
package dev.architectury.event.events.common;
import dev.architectury.event.CompoundEventResult;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
@@ -36,15 +35,15 @@ public interface InteractionEvent {
/**
* @see LeftClickBlock#click(Player, InteractionHand, BlockPos, Direction)
*/
Event<LeftClickBlock> LEFT_CLICK_BLOCK = EventFactory.createEventResult();
Event<LeftClickBlock> LEFT_CLICK_BLOCK = EventFactory.createInteractionResult();
/**
* @see RightClickBlock#click(Player, InteractionHand, BlockPos, Direction)
*/
Event<RightClickBlock> RIGHT_CLICK_BLOCK = EventFactory.createEventResult();
Event<RightClickBlock> RIGHT_CLICK_BLOCK = EventFactory.createInteractionResult();
/**
* @see RightClickItem#click(Player, InteractionHand)
*/
Event<RightClickItem> RIGHT_CLICK_ITEM = EventFactory.createCompoundEventResult();
Event<RightClickItem> RIGHT_CLICK_ITEM = EventFactory.createInteractionResult();
/**
* @see ClientLeftClickAir#click(Player, InteractionHand)
*/
@@ -60,7 +59,7 @@ public interface InteractionEvent {
/**
* @see FarmlandTrample#trample(Level, BlockPos, BlockState, float, Entity)
*/
Event<FarmlandTrample> FARMLAND_TRAMPLE = EventFactory.createEventResult();
Event<FarmlandTrample> FARMLAND_TRAMPLE = EventFactory.createInteractionResult();
interface RightClickBlock {
/**
@@ -71,10 +70,10 @@ public interface InteractionEvent {
* @param hand The hand that is used.
* @param pos The position of the block in the level.
* @param face The face of the block clicked.
* @return A {@link EventResult} determining the outcome of the event,
* @return A {@link InteractionResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
EventResult click(Player player, InteractionHand hand, BlockPos pos, Direction face);
InteractionResult click(Player player, InteractionHand hand, BlockPos pos, Direction face);
}
interface LeftClickBlock {
@@ -86,10 +85,10 @@ public interface InteractionEvent {
* @param hand The hand that is used.
* @param pos The position of the block in the level. Use {@link Player#getCommandSenderWorld()} to get the level.
* @param face The face of the block clicked.
* @return A {@link EventResult} determining the outcome of the event,
* @return A {@link InteractionResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
EventResult click(Player player, InteractionHand hand, BlockPos pos, Direction face);
InteractionResult click(Player player, InteractionHand hand, BlockPos pos, Direction face);
}
interface RightClickItem {
@@ -99,10 +98,10 @@ public interface InteractionEvent {
*
* @param player The player right clicking the block.
* @param hand The hand that is used.
* @return A {@link EventResult} determining the outcome of the event,
* @return A {@link InteractionResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
CompoundEventResult<ItemStack> click(Player player, InteractionHand hand);
InteractionResult click(Player player, InteractionHand hand);
}
interface ClientRightClickAir {
@@ -153,9 +152,9 @@ public interface InteractionEvent {
* @param state The state of the block.
* @param distance The distance of the player to the block.
* @param entity The entity trampling.
* @return A {@link EventResult} determining the outcome of the event,
* @return A {@link InteractionResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
EventResult trample(Level world, BlockPos pos, BlockState state, float distance, Entity entity);
InteractionResult trample(Level world, BlockPos pos, BlockState state, float distance, Entity entity);
}
}

View File

@@ -19,7 +19,6 @@
package dev.architectury.event.events.common;
import dev.architectury.event.CompoundEventResult;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
@@ -28,6 +27,7 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.Container;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
@@ -94,7 +94,7 @@ public interface PlayerEvent {
/**
* @see FillBucket#fill(Player, Level, ItemStack, HitResult)
*/
Event<FillBucket> FILL_BUCKET = EventFactory.createCompoundEventResult();
Event<FillBucket> FILL_BUCKET = EventFactory.createInteractionResult();
/**
* @see AttackEntity#attack(Player, Level, Entity, InteractionHand, EntityHitResult)
*/
@@ -265,9 +265,9 @@ public interface PlayerEvent {
* @param level The level the player is in.
* @param stack The bucket stack.
* @param target The target which the player has aimed at.
* @return A {@link CompoundEventResult} determining the outcome of the event.
* @return A {@link InteractionResult} determining the outcome of the event.
*/
CompoundEventResult<ItemStack> fill(Player player, Level level, ItemStack stack, @Nullable HitResult target);
InteractionResult fill(Player player, Level level, ItemStack stack, @Nullable HitResult target);
}
interface AttackEntity {

View File

@@ -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.extensions.injected;
import dev.architectury.hooks.item.food.FoodPropertiesHooks;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.food.FoodProperties;
import java.util.function.Supplier;
public interface InjectedFoodPropertiesBuilderExtension {
default FoodProperties.Builder arch$effect(Supplier<? extends MobEffectInstance> effectSupplier, float chance) {
FoodPropertiesHooks.effect((FoodProperties.Builder) this, effectSupplier, chance);
return (FoodProperties.Builder) this;
}
}

View File

@@ -1,37 +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;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.food.FoodProperties;
import java.util.function.Supplier;
public final class FoodPropertiesHooks {
private FoodPropertiesHooks() {
}
@ExpectPlatform
public static void effect(FoodProperties.Builder builder,
Supplier<? extends MobEffectInstance> effectSupplier, float chance) {
throw new AssertionError();
}
}

View File

@@ -1,41 +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.level;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.phys.Vec3;
/**
* @deprecated no longer needed.
*/
@Deprecated(forRemoval = true)
public final class ExplosionHooks {
private ExplosionHooks() {
}
/**
* @deprecated no longer needed.
* @see Explosion#center()
*/
@Deprecated(forRemoval = true)
public static Vec3 getPosition(Explosion explosion) {
return explosion.center();
}
}

View File

@@ -349,8 +349,8 @@ public final class BiomeHooks {
}
@Override
public Iterable<Holder<ConfiguredWorldCarver<?>>> getCarvers(GenerationStep.Carving carving) {
return settings.getCarvers(carving);
public Iterable<Holder<ConfiguredWorldCarver<?>>> getCarvers() {
return settings.getCarvers();
}
@Override

View File

@@ -29,7 +29,7 @@ import org.jetbrains.annotations.ApiStatus;
import java.util.List;
public interface GenerationProperties {
Iterable<Holder<ConfiguredWorldCarver<?>>> getCarvers(GenerationStep.Carving carving);
Iterable<Holder<ConfiguredWorldCarver<?>>> getCarvers();
Iterable<Holder<PlacedFeature>> getFeatures(GenerationStep.Decoration decoration);
@@ -41,13 +41,13 @@ public interface GenerationProperties {
@ApiStatus.Experimental
Mutable addFeature(GenerationStep.Decoration decoration, ResourceKey<PlacedFeature> feature);
Mutable addCarver(GenerationStep.Carving carving, Holder<ConfiguredWorldCarver<?>> feature);
Mutable addCarver(Holder<ConfiguredWorldCarver<?>> feature);
@ApiStatus.Experimental
Mutable addCarver(GenerationStep.Carving carving, ResourceKey<ConfiguredWorldCarver<?>> feature);
Mutable addCarver(ResourceKey<ConfiguredWorldCarver<?>> feature);
Mutable removeFeature(GenerationStep.Decoration decoration, ResourceKey<PlacedFeature> feature);
Mutable removeCarver(GenerationStep.Carving carving, ResourceKey<ConfiguredWorldCarver<?>> feature);
Mutable removeCarver(ResourceKey<ConfiguredWorldCarver<?>> feature);
}
}

View File

@@ -1,69 +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.impl;
import dev.architectury.event.events.client.ClientTooltipEvent;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal
public class TooltipEventColorContextImpl implements ClientTooltipEvent.ColorContext {
public static final ThreadLocal<TooltipEventColorContextImpl> CONTEXT = ThreadLocal.withInitial(TooltipEventColorContextImpl::new);
private int backgroundColor;
private int outlineGradientTopColor;
private int outlineGradientBottomColor;
public TooltipEventColorContextImpl reset() {
this.backgroundColor = 0xf0100010;
this.outlineGradientTopColor = 0x505000ff;
this.outlineGradientBottomColor = 0x5028007f;
return this;
}
@Override
public int getBackgroundColor() {
return backgroundColor;
}
@Override
public void setBackgroundColor(int color) {
this.backgroundColor = color;
}
@Override
public int getOutlineGradientTopColor() {
return outlineGradientTopColor;
}
@Override
public void setOutlineGradientTopColor(int color) {
this.outlineGradientTopColor = color;
}
@Override
public int getOutlineGradientBottomColor() {
return outlineGradientBottomColor;
}
@Override
public void setOutlineGradientBottomColor(int color) {
this.outlineGradientBottomColor = color;
}
}

View File

@@ -1,28 +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.inject;
import dev.architectury.extensions.injected.InjectedFoodPropertiesBuilderExtension;
import net.minecraft.world.food.FoodProperties;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(FoodProperties.Builder.class)
public class MixinFoodPropertiesBuilder implements InjectedFoodPropertiesBuilderExtension {
}

View File

@@ -37,6 +37,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntitySpawnReason;
import net.minecraft.world.entity.EntityType;
import java.util.UUID;
@@ -74,7 +75,7 @@ public class SpawnEntityPacket {
if (Minecraft.getInstance().level == null) {
throw new IllegalStateException("Client world is null!");
}
var entity = payload.entityType().create(Minecraft.getInstance().level);
var entity = payload.entityType().create(Minecraft.getInstance().level, EntitySpawnReason.LOAD);
if (entity == null) {
throw new IllegalStateException("Created entity is null!");
}

View File

@@ -19,9 +19,7 @@
package dev.architectury.registry.fuel;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;
public final class FuelRegistry {
private FuelRegistry() {
@@ -34,10 +32,10 @@ public final class FuelRegistry {
* and {@code -1} to use vanilla logic
* @param items the array of items to register for
*/
@ExpectPlatform
/*@ExpectPlatform
public static void register(int time, ItemLike... items) {
throw new AssertionError();
}
}*/
/**
* Returns the burn time of an {@link ItemStack}.
@@ -45,8 +43,8 @@ public final class FuelRegistry {
* @param stack the stack
* @return the burn time of the stack, returns {@code 0} if not a fuel
*/
@ExpectPlatform
/*@ExpectPlatform
public static int get(ItemStack stack) {
throw new AssertionError();
}
}*/
}

View File

@@ -84,7 +84,7 @@ public final class RegistrarManager {
public static <T> ResourceLocation getId(T object, @Nullable ResourceKey<Registry<T>> fallback) {
if (fallback == null)
return null;
return getId(object, (Registry<T>) BuiltInRegistries.REGISTRY.get(fallback.location()));
return getId(object, (Registry<T>) BuiltInRegistries.REGISTRY.getValue(fallback.location()));
}
/**

View File

@@ -10,7 +10,6 @@
"inject.MixinBucketItem",
"inject.MixinEntityType",
"inject.MixinFluid",
"inject.MixinFoodPropertiesBuilder",
"inject.MixinItem",
"inject.MixinItemProperties",
"inject.MixinLiquidBlock",

View File

@@ -113,10 +113,6 @@ accessible field net/minecraft/world/item/ShovelItem FLATTENABLES Ljava/util/Map
mutable field net/minecraft/world/item/ShovelItem FLATTENABLES Ljava/util/Map;
accessible field net/minecraft/world/item/HoeItem TILLABLES Ljava/util/Map;
mutable field net/minecraft/world/item/HoeItem TILLABLES Ljava/util/Map;
transitive-accessible field net/minecraft/world/level/Explosion source Lnet/minecraft/world/entity/Entity;
transitive-mutable field net/minecraft/world/level/Explosion source Lnet/minecraft/world/entity/Entity;
transitive-accessible field net/minecraft/world/level/Explosion radius F
transitive-mutable field net/minecraft/world/level/Explosion radius F
transitive-accessible method net/minecraft/world/entity/player/Player closeContainer ()V
transitive-accessible method net/minecraft/client/renderer/RenderType create (Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;ILnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType;
transitive-accessible method net/minecraft/client/renderer/RenderType create (Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;IZZLnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType;
@@ -139,7 +135,7 @@ accessible field net/minecraft/client/multiplayer/MultiPlayerGameMode connection
##############################
# Constructors of non-abstract item classes
transitive-accessible method net/minecraft/world/item/DiggerItem <init> (Lnet/minecraft/world/item/Tier;Lnet/minecraft/tags/TagKey;Lnet/minecraft/world/item/Item$Properties;)V
transitive-accessible method net/minecraft/world/item/DiggerItem <init> (Lnet/minecraft/world/item/ToolMaterial;Lnet/minecraft/tags/TagKey;FFLnet/minecraft/world/item/Item$Properties;)V
# Constructors of non-abstract block classes
transitive-accessible method net/minecraft/world/level/block/AttachedStemBlock <init> (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
@@ -157,13 +153,14 @@ transitive-accessible method net/minecraft/world/level/block/CakeBlock <init> (L
transitive-accessible method net/minecraft/world/level/block/CandleCakeBlock <init> (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/CartographyTableBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/CarvedPumpkinBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/ChestBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Ljava/util/function/Supplier;)V
transitive-accessible method net/minecraft/world/level/block/ChestBlock <init> (Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/ChorusFlowerBlock <init> (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/ChorusPlantBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/CoralFanBlock <init> (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/CoralPlantBlock <init> (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/CoralWallFanBlock <init> (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/CraftingTableBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/CreakingHeartBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/CropBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/DeadBushBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/DecoratedPotBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
@@ -175,7 +172,6 @@ transitive-accessible method net/minecraft/world/level/block/EndGatewayBlock <in
transitive-accessible method net/minecraft/world/level/block/EndPortalBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/EndRodBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/EnderChestBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/EquipableCarvedPumpkinBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/FarmBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/FletchingTableBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
transitive-accessible method net/minecraft/world/level/block/FungusBlock <init> (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V
@@ -248,12 +244,17 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard LIGHT
transitive-accessible field net/minecraft/client/renderer/RenderStateShard GLINT_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard CRUMBLING_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard TRANSLUCENT_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard VIGNETTE_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard CROSSHAIR_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard MOJANG_LOGO_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard NAUSEA_OVERLAY_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_LIGHTMAP_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_TEX_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_TEX_LIGHTMAP_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_TEXTURE_COLOR_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_SOLID_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_CUTOUT_MIPPED_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_CUTOUT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
@@ -265,7 +266,6 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDE
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_CUTOUT_NO_CULL_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_CUTOUT_NO_CULL_Z_OFFSET_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ITEM_ENTITY_TRANSLUCENT_CULL_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_EMISSIVE_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_SMOOTH_CUTOUT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
@@ -283,7 +283,6 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDE
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GLINT_TRANSLUCENT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GLINT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_GLINT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_GLINT_DIRECT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_CRUMBLING_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_TEXT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_TEXT_BACKGROUND_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
@@ -324,6 +323,7 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard DEPTH
transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_LAYERING Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POLYGON_OFFSET_LAYERING Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard VIEW_OFFSET_Z_LAYERING Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard VIEW_OFFSET_Z_LAYERING_FORWARD Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard MAIN_TARGET Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard OUTLINE_TARGET Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard;
transitive-accessible field net/minecraft/client/renderer/RenderStateShard TRANSLUCENT_TARGET Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard;

View File

@@ -19,9 +19,6 @@
"net/minecraft/class_1755": [
"dev/architectury/extensions/injected/InjectedBucketItemExtension"
],
"net/minecraft/class_4174$class_4175": [
"dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension"
],
"net/minecraft/class_2404": [
"dev/architectury/extensions/injected/InjectedLiquidBlockExtension"
]