fixed a bunch of server crashing issues

Closes #122
This commit is contained in:
Ellpeck 2020-05-22 12:26:35 +02:00
parent 062579ba37
commit 3b37ba0c30
2 changed files with 14 additions and 1 deletions

View file

@ -12,6 +12,8 @@ import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.AnvilUpdateEvent; import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent;
@ -57,6 +59,7 @@ public class ItemBreakPrevention extends ItemImpl {
} }
@SubscribeEvent @SubscribeEvent
@OnlyIn(Dist.CLIENT)
public void onTooltip(ItemTooltipEvent event) { public void onTooltip(ItemTooltipEvent event) {
ItemStack stack = event.getItemStack(); ItemStack stack = event.getItemStack();
if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention")) if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention"))

View file

@ -32,6 +32,8 @@ import net.minecraft.block.FlowerPotBlock;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.SpriteRenderer; import net.minecraft.client.renderer.entity.SpriteRenderer;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityClassification;
@ -54,6 +56,7 @@ import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.common.extensions.IForgeContainerType; import net.minecraftforge.common.extensions.IForgeContainerType;
import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
@ -263,6 +266,7 @@ public final class ModRegistry {
Helper.populateObjectHolders(ModEnchantments.class, event.getRegistry()); Helper.populateObjectHolders(ModEnchantments.class, event.getRegistry());
} }
@SuppressWarnings("Convert2Lambda")
@SubscribeEvent @SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) { public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
event.getRegistry().registerAll( event.getRegistry().registerAll(
@ -288,7 +292,13 @@ public final class ModRegistry {
NaturesAura.proxy.registerEntityRenderer(ModEntities.MOVER_CART, () -> RenderMoverMinecart::new); NaturesAura.proxy.registerEntityRenderer(ModEntities.MOVER_CART, () -> RenderMoverMinecart::new);
NaturesAura.proxy.registerEntityRenderer(ModEntities.EFFECT_INHIBITOR, () -> RenderEffectInhibitor::new); NaturesAura.proxy.registerEntityRenderer(ModEntities.EFFECT_INHIBITOR, () -> RenderEffectInhibitor::new);
NaturesAura.proxy.registerEntityRenderer(ModEntities.LIGHT_PROJECTILE, () -> RenderStub::new); NaturesAura.proxy.registerEntityRenderer(ModEntities.LIGHT_PROJECTILE, () -> RenderStub::new);
NaturesAura.proxy.registerEntityRenderer(ModEntities.STRUCTURE_FINDER, () -> m -> new SpriteRenderer<>(m, Minecraft.getInstance().getItemRenderer())); // for some reason, only this one causes classloading issues if shortened to a lambda, what
NaturesAura.proxy.registerEntityRenderer(ModEntities.STRUCTURE_FINDER, () -> new IRenderFactory<EntityStructureFinder>() {
@Override
public EntityRenderer<? super EntityStructureFinder> createRenderFor(EntityRendererManager m) {
return new SpriteRenderer<>(m, Minecraft.getInstance().getItemRenderer());
}
});
} }
@SubscribeEvent @SubscribeEvent