Fixed the Lava Crystal crash

Maybe not the most elegant method? But it works.
This commit is contained in:
WayofTime 2020-11-21 10:24:35 -05:00
parent 295488f144
commit 9b79acaad6
5 changed files with 33 additions and 26 deletions

View file

@ -6,8 +6,6 @@ import org.apache.logging.log4j.Logger;
import com.google.gson.Gson;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemGroup;
@ -37,7 +35,6 @@ import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import wayoftime.bloodmagic.client.ClientEvents;
import wayoftime.bloodmagic.client.hud.Elements;
import wayoftime.bloodmagic.client.model.MimicColor;
import wayoftime.bloodmagic.client.model.MimicModelLoader;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.common.data.GeneratorBaseRecipes;
@ -225,6 +222,7 @@ public class BloodMagic
packetHandler.initialize();
}
// @OnlyIn(Dist.CLIENT)
private void doClientStuff(final FMLClientSetupEvent event)
{
// do something that can only be done on the client
@ -232,8 +230,6 @@ public class BloodMagic
ClientEvents.initClientEvents(event);
Elements.registerElements();
Minecraft.getInstance().getBlockColors().register(new MimicColor(), BloodMagicBlocks.MIMIC.get());
RenderTypeLookup.setRenderLayer(BloodMagicBlocks.MIMIC.get(), (RenderType) -> true);
}
private void enqueueIMC(final InterModEnqueueEvent event)

View file

@ -1,5 +1,6 @@
package wayoftime.bloodmagic.client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScreenManager;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
@ -19,6 +20,7 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.api.item.IMultiWillTool;
import wayoftime.bloodmagic.client.model.MimicColor;
import wayoftime.bloodmagic.client.render.block.RenderAlchemyArray;
import wayoftime.bloodmagic.client.render.block.RenderAltar;
import wayoftime.bloodmagic.client.render.block.RenderDemonCrucible;
@ -91,6 +93,9 @@ public class ClientEvents
return ((ItemSentientSword) stack.getItem()).getActivated(stack) ? 1 : 0;
}
});
Minecraft.getInstance().getBlockColors().register(new MimicColor(), BloodMagicBlocks.MIMIC.get());
RenderTypeLookup.setRenderLayer(BloodMagicBlocks.MIMIC.get(), (RenderType) -> true);
});
}

View file

@ -14,6 +14,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.thread.EffectiveSide;
import wayoftime.bloodmagic.core.data.Binding;
import wayoftime.bloodmagic.core.data.SoulTicket;
import wayoftime.bloodmagic.util.helper.NetworkHelper;
@ -52,14 +53,21 @@ public class ItemLavaCrystal extends ItemBindableBase
if (binding == null)
return -1;
// if (NetworkHelper.syphonFromContainer(stack, SoulTicket.item(stack, 25)))
if (NetworkHelper.canSyphonFromContainer(stack, 50))
return 200;
else
if (EffectiveSide.get().isServer())
{
PlayerEntity player = PlayerHelper.getPlayerFromUUID(binding.getOwnerId());
if (player != null)
player.addPotionEffect(new EffectInstance(Effects.NAUSEA, 99));
if (NetworkHelper.canSyphonFromContainer(stack, 50))
return 200;
else
{
PlayerEntity player = PlayerHelper.getPlayerFromUUID(binding.getOwnerId());
if (player != null)
{
player.addPotionEffect(new EffectInstance(Effects.NAUSEA, 99));
}
}
} else
{
return 200;
}
return -1;
@ -100,11 +108,9 @@ public class ItemLavaCrystal extends ItemBindableBase
if (!player.canPlayerEdit(pos, facing, itemstack))
return ActionResultType.FAIL;
if (context.getWorld().isAirBlock(pos)
&& NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(player.getHeldItem(hand), 100)).isSuccess())
if (context.getWorld().isAirBlock(pos) && NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, SoulTicket.item(player.getHeldItem(hand), 100)).isSuccess())
{
context.getWorld().playSound(player, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, random.nextFloat()
* 0.4F + 0.8F);
context.getWorld().playSound(player, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, random.nextFloat() * 0.4F + 0.8F);
context.getWorld().setBlockState(pos, Blocks.FIRE.getDefaultState(), 11);
} else
return ActionResultType.FAIL;

View file

@ -9,13 +9,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.storage.DimensionSavedDataManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import wayoftime.bloodmagic.api.item.IBindable;
import wayoftime.bloodmagic.core.data.BMWorldSavedData;
import wayoftime.bloodmagic.core.data.Binding;
import wayoftime.bloodmagic.core.data.SoulNetwork;
import wayoftime.bloodmagic.core.data.SoulTicket;
import wayoftime.bloodmagic.core.registry.OrbRegistry;
import wayoftime.bloodmagic.event.SoulNetworkEvent;
import wayoftime.bloodmagic.api.item.IBindable;
import wayoftime.bloodmagic.orb.BloodOrb;
import wayoftime.bloodmagic.orb.IBloodOrb;
@ -161,6 +161,9 @@ public class NetworkHelper
return false;
SoulNetwork network = getSoulNetwork(binding);
if (network == null)
return false;
return network.getCurrentEssence() >= toSyphon;
}

View file

@ -22,13 +22,11 @@ public class PlayerHelper
public static PlayerEntity getPlayerFromId(UUID uuid)
{
// TODO: Need to find a reliable way to get whether the side is Client or Server
// if (FMLCommonHandler.instance().)
// return null;
//
// World w;
// Dist d;
//
// if(ServerLifecycleHooks.getCurrentServer().get)
if (ServerLifecycleHooks.getCurrentServer() == null)
{
return null;
}
return ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayerByUUID(uuid);
@ -58,7 +56,6 @@ public class PlayerHelper
*/
public static boolean isFakePlayer(PlayerEntity player)
{
return player instanceof FakePlayer
|| (player != null && knownFakePlayers.contains(player.getClass().getCanonicalName()));
return player instanceof FakePlayer || (player != null && knownFakePlayers.contains(player.getClass().getCanonicalName()));
}
}