Some patch cleanup (#9951)

This commit is contained in:
Paint_Ninja authored and GitHub committed 2024-05-09 18:07:41 +01:00
1 parent 0cad6b14d9
commit 58012bfb17
18 files changed
+233 -113

No files matched your search

@@ -226,10 +226,6 @@ public final class ForgeHooks {
return brainBuilder.makeBrain(dynamic);
}
public static boolean onLivingTick(LivingEntity entity) {
return MinecraftForge.EVENT_BUS.post(new LivingTickEvent(entity));
}
public static boolean onLivingAttack(LivingEntity entity, DamageSource src, float amount) {
return entity instanceof Player || !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
}
@@ -252,14 +248,6 @@ public final class ForgeHooks {
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
}
public static boolean onLivingDeath(LivingEntity entity, DamageSource src) {
return MinecraftForge.EVENT_BUS.post(new LivingDeathEvent(entity, src));
}
public static boolean onLivingDrops(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) {
return MinecraftForge.EVENT_BUS.post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit));
}
public static int getLootingLevel(Entity target, @Nullable Entity killer, @Nullable DamageSource cause) {
int looting = 0;
if (killer instanceof LivingEntity living)
@@ -778,7 +766,7 @@ public final class ForgeHooks {
@SuppressWarnings("deprecation")
public static synchronized void updateBurns() {
VANILLA_BURNS.clear();
FurnaceBlockEntity.getFuel().entrySet().forEach(e -> VANILLA_BURNS.put(ForgeRegistries.ITEMS.getDelegateOrThrow(e.getKey()), e.getValue()));
FurnaceBlockEntity.getFuel().forEach((k, v) -> VANILLA_BURNS.put(ForgeRegistries.ITEMS.getDelegateOrThrow(k), v));
}
/**
@@ -1260,4 +1248,19 @@ public final class ForgeHooks {
}
);
}
@Nullable
public static DyeColor getDyeColorFromItemStack(ItemStack stack) {
if (stack.getItem() instanceof DyeItem dye)
return dye.getDyeColor();
for (int x = 0; x < DyeColor.BLACK.getId(); x++) {
var color = DyeColor.byId(x);
if (stack.is(color.getTag())) {
return color;
}
}
return null;
}
}
@@ -0,0 +1,33 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.common.extensions;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import net.minecraftforge.common.world.ModifiableBiomeInfo;
public interface IForgeBiome {
/**
* {@return Cache of original biome data and biome data modified by biome modifiers}
* Modified biome data is set by server after datapacks and serverconfigs load.
* Climate and effects field reads are coremodded to redirect to this.
**/
ModifiableBiomeInfo modifiableBiomeInfo();
/**
* {@return The biome's climate settings, with modifications if called after modifiers are applied in server init.}
*/
default Biome.ClimateSettings getModifiedClimateSettings() {
return modifiableBiomeInfo().get().climateSettings();
}
/**
* {@return The biome's client effects, with modifications if called after modifiers are applied in server init.}
*/
default BiomeSpecialEffects getModifiedSpecialEffects() {
return modifiableBiomeInfo().get().effects();
}
}