Initial work on DemonWillGauge
Includes the PacketHandler as well as the base system for HUDElements. Still need a replacement for the GuiConfig.
This commit is contained in:
parent
648b96601d
commit
b6931a3116
17 changed files with 858 additions and 33 deletions
|
@ -28,6 +28,8 @@ import net.minecraftforge.fluids.IFluidBlock;
|
|||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
|
||||
import wayoftime.bloodmagic.common.item.IDemonWillViewer;
|
||||
import wayoftime.bloodmagic.tile.TileInventory;
|
||||
|
||||
public class Utils
|
||||
|
@ -92,9 +94,7 @@ public class Utils
|
|||
public static boolean isFlowingLiquid(World world, BlockPos pos, BlockState state)
|
||||
{
|
||||
Block block = state.getBlock();
|
||||
return ((block instanceof IFluidBlock && Math.abs(((IFluidBlock) block).getFilledPercentage(world, pos)) == 1)
|
||||
|| (block instanceof FlowingFluidBlock
|
||||
&& !((FlowingFluidBlock) block).getFluidState(state).isSource()));
|
||||
return ((block instanceof IFluidBlock && Math.abs(((IFluidBlock) block).getFilledPercentage(world, pos)) == 1) || (block instanceof FlowingFluidBlock && !((FlowingFluidBlock) block).getFluidState(state).isSource()));
|
||||
}
|
||||
|
||||
public static boolean spawnStackAtBlock(World world, BlockPos pos, @Nullable Direction pushDirection, ItemStack stack)
|
||||
|
@ -174,9 +174,7 @@ public class Utils
|
|||
BlockState initialState = initialWorld.getBlockState(initialPos);
|
||||
BlockState finalState = finalWorld.getBlockState(finalPos);
|
||||
|
||||
if ((initialState.getBlock().equals(Blocks.AIR) && finalState.getBlock().equals(Blocks.AIR))
|
||||
|| initialState.getBlock() instanceof NetherPortalBlock
|
||||
|| finalState.getBlock() instanceof NetherPortalBlock)
|
||||
if ((initialState.getBlock().equals(Blocks.AIR) && finalState.getBlock().equals(Blocks.AIR)) || initialState.getBlock() instanceof NetherPortalBlock || finalState.getBlock() instanceof NetherPortalBlock)
|
||||
return false;
|
||||
|
||||
if (playSound)
|
||||
|
@ -302,8 +300,7 @@ public class Utils
|
|||
int[] array = ((ISidedInventory) inventory).getSlotsForFace(dir);
|
||||
for (int in : array)
|
||||
{
|
||||
canBeInserted[in] = inventory.isItemValidForSlot(in, stack)
|
||||
&& ((ISidedInventory) inventory).canInsertItem(in, stack, dir);
|
||||
canBeInserted[in] = inventory.isItemValidForSlot(in, stack) && ((ISidedInventory) inventory).canInsertItem(in, stack, dir);
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
@ -349,8 +346,7 @@ public class Utils
|
|||
int[] array = ((ISidedInventory) inventory).getSlotsForFace(dir);
|
||||
for (int in : array)
|
||||
{
|
||||
canBeInserted[in] = inventory.isItemValidForSlot(in, stack)
|
||||
&& ((ISidedInventory) inventory).canInsertItem(in, stack, dir);
|
||||
canBeInserted[in] = inventory.isItemValidForSlot(in, stack) && ((ISidedInventory) inventory).canInsertItem(in, stack, dir);
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
@ -445,4 +441,46 @@ public class Utils
|
|||
|
||||
return returned;
|
||||
}
|
||||
|
||||
public static boolean canPlayerSeeDemonWill(PlayerEntity player)
|
||||
{
|
||||
IItemHandler inventory = new PlayerMainInvWrapper(player.inventory);
|
||||
|
||||
for (int i = 0; i < inventory.getSlots(); i++)
|
||||
{
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static double getDemonWillResolution(PlayerEntity player)
|
||||
{
|
||||
IItemHandler inventory = new PlayerMainInvWrapper(player.inventory);
|
||||
|
||||
for (int i = 0; i < inventory.getSlots(); i++)
|
||||
{
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player))
|
||||
{
|
||||
return ((IDemonWillViewer) stack.getItem()).getDemonWillAuraResolution(player.getEntityWorld(), stack, player);
|
||||
}
|
||||
}
|
||||
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ import wayoftime.bloodmagic.ritual.EnumRitualReaderState;
|
|||
import wayoftime.bloodmagic.ritual.Ritual;
|
||||
import wayoftime.bloodmagic.ritual.RitualComponent;
|
||||
import wayoftime.bloodmagic.tile.TileMasterRitualStone;
|
||||
import wayoftime.bloodmagic.will.DemonWillHolder;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID, value = Dist.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
@ -85,6 +86,8 @@ public class ClientHandler
|
|||
private static boolean mrsHoloDisplay;
|
||||
private static boolean mrsRangeDisplay;
|
||||
|
||||
public static DemonWillHolder currentAura;
|
||||
|
||||
static HashMap<String, ResourceLocation> resourceMap = new HashMap<String, ResourceLocation>();
|
||||
|
||||
public static Minecraft mc()
|
||||
|
@ -186,8 +189,7 @@ public class ClientHandler
|
|||
|
||||
TileEntity tileEntity = world.getTileEntity(((BlockRayTraceResult) minecraft.objectMouseOver).getPos());
|
||||
|
||||
if (tileEntity instanceof TileMasterRitualStone && !player.getHeldItemMainhand().isEmpty()
|
||||
&& player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner)
|
||||
if (tileEntity instanceof TileMasterRitualStone && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner)
|
||||
{
|
||||
IRenderTypeBuffer.Impl buffers = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
|
||||
MatrixStack stack = event.getMatrixStack();
|
||||
|
@ -344,8 +346,7 @@ public class ClientHandler
|
|||
ClientPlayerEntity player = minecraft.player;
|
||||
World world = player.getEntityWorld();
|
||||
|
||||
if (!player.getHeldItemMainhand().isEmpty()
|
||||
&& player.getHeldItemMainhand().getItem() instanceof ItemRitualReader)
|
||||
if (!player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemRitualReader)
|
||||
{
|
||||
ItemStack itemStack = player.getHeldItemMainhand();
|
||||
EnumRitualReaderState state = ((ItemRitualReader) itemStack.getItem()).getState(itemStack);
|
||||
|
@ -375,8 +376,7 @@ public class ClientHandler
|
|||
stack.translate(minX, minY, minZ);
|
||||
|
||||
ResourceLocation rl = boarder;
|
||||
Model3D model = getBlockModelWithSize(rl, aabb.getXSize() - 2 * sizeOffset, aabb.getYSize() - 2
|
||||
* sizeOffset, aabb.getZSize() - 2 * sizeOffset);
|
||||
Model3D model = getBlockModelWithSize(rl, aabb.getXSize() - 2 * sizeOffset, aabb.getYSize() - 2 * sizeOffset, aabb.getZSize() - 2 * sizeOffset);
|
||||
RenderResizableCuboid.INSTANCE.renderCube(model, stack, buffer, 0x99FF4444, 0x00F000F0, OverlayTexture.NO_OVERLAY);
|
||||
stack.pop();
|
||||
}
|
||||
|
@ -483,8 +483,7 @@ public class ClientHandler
|
|||
int iW = sprite.getWidth();
|
||||
int iH = sprite.getHeight();
|
||||
if (iW > 0 && iH > 0)
|
||||
drawRepeatedSprite(builder, transform, x, y, w, h, iW, iH, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV(), (col >> 16
|
||||
& 255) / 255.0f, (col >> 8 & 255) / 255.0f, (col & 255) / 255.0f, 1);
|
||||
drawRepeatedSprite(builder, transform, x, y, w, h, iW, iH, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV(), (col >> 16 & 255) / 255.0f, (col >> 8 & 255) / 255.0f, (col & 255) / 255.0f, 1);
|
||||
}
|
||||
|
||||
public static void drawRepeatedSprite(IVertexBuilder builder, MatrixStack transform, float x, float y, float w, float h, int iconWidth, int iconHeight, float uMin, float uMax, float vMin, float vMax, float r, float g, float b, float alpha)
|
||||
|
@ -499,20 +498,15 @@ public class ClientHandler
|
|||
float iconVDif = vMax - vMin;
|
||||
for (int ww = 0; ww < iterMaxW; ww++)
|
||||
{
|
||||
for (int hh = 0; hh < iterMaxH; hh++) drawTexturedRect(builder, transform, x + ww * iconWidth, y + hh
|
||||
* iconHeight, iconWidth, iconHeight, r, g, b, alpha, uMin, uMax, vMin, vMax);
|
||||
drawTexturedRect(builder, transform, x + ww * iconWidth, y + iterMaxH
|
||||
* iconHeight, iconWidth, leftoverH, r, g, b, alpha, uMin, uMax, vMin, (vMin + iconVDif
|
||||
* leftoverHf));
|
||||
for (int hh = 0; hh < iterMaxH; hh++)
|
||||
drawTexturedRect(builder, transform, x + ww * iconWidth, y + hh * iconHeight, iconWidth, iconHeight, r, g, b, alpha, uMin, uMax, vMin, vMax);
|
||||
drawTexturedRect(builder, transform, x + ww * iconWidth, y + iterMaxH * iconHeight, iconWidth, leftoverH, r, g, b, alpha, uMin, uMax, vMin, (vMin + iconVDif * leftoverHf));
|
||||
}
|
||||
if (leftoverW > 0)
|
||||
{
|
||||
for (int hh = 0; hh < iterMaxH; hh++) drawTexturedRect(builder, transform, x + iterMaxW * iconWidth, y + hh
|
||||
* iconHeight, leftoverW, iconHeight, r, g, b, alpha, uMin, (uMin + iconUDif
|
||||
* leftoverWf), vMin, vMax);
|
||||
drawTexturedRect(builder, transform, x + iterMaxW * iconWidth, y + iterMaxH
|
||||
* iconHeight, leftoverW, leftoverH, r, g, b, alpha, uMin, (uMin + iconUDif
|
||||
* leftoverWf), vMin, (vMin + iconVDif * leftoverHf));
|
||||
for (int hh = 0; hh < iterMaxH; hh++)
|
||||
drawTexturedRect(builder, transform, x + iterMaxW * iconWidth, y + hh * iconHeight, leftoverW, iconHeight, r, g, b, alpha, uMin, (uMin + iconUDif * leftoverWf), vMin, vMax);
|
||||
drawTexturedRect(builder, transform, x + iterMaxW * iconWidth, y + iterMaxH * iconHeight, leftoverW, leftoverH, r, g, b, alpha, uMin, (uMin + iconUDif * leftoverWf), vMin, (vMin + iconVDif * leftoverHf));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,8 +521,7 @@ public class ClientHandler
|
|||
|
||||
public static void drawTexturedRect(IVertexBuilder builder, MatrixStack transform, int x, int y, int w, int h, float picSize, int u0, int u1, int v0, int v1)
|
||||
{
|
||||
drawTexturedRect(builder, transform, x, y, w, h, 1, 1, 1, 1, u0 / picSize, u1 / picSize, v0 / picSize, v1
|
||||
/ picSize);
|
||||
drawTexturedRect(builder, transform, x, y, w, h, 1, 1, 1, 1, u0 / picSize, u1 / picSize, v0 / picSize, v1 / picSize);
|
||||
}
|
||||
|
||||
public static void addFluidTooltip(FluidStack fluid, List<ITextComponent> tooltip, int tankCapacity)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package wayoftime.bloodmagic.util.handler.event;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@ -9,13 +11,16 @@ import net.minecraftforge.fml.common.Mod;
|
|||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.core.data.SoulNetwork;
|
||||
import wayoftime.bloodmagic.demonaura.WorldDemonWillHandler;
|
||||
import wayoftime.bloodmagic.event.ItemBindEvent;
|
||||
import wayoftime.bloodmagic.iface.IBindable;
|
||||
import wayoftime.bloodmagic.network.DemonAuraClientPacket;
|
||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
||||
import wayoftime.bloodmagic.orb.IBloodOrb;
|
||||
import wayoftime.bloodmagic.util.helper.BindableHelper;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
import wayoftime.bloodmagic.will.DemonWillHolder;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class GenericHandler
|
||||
|
@ -49,8 +54,7 @@ public class GenericHandler
|
|||
}
|
||||
// If the binding exists, we'll check if the player's name has changed since
|
||||
// they last used it and update that if so.
|
||||
} else if (binding.getOwnerId().equals(player.getGameProfile().getId())
|
||||
&& !binding.getOwnerName().equals(player.getGameProfile().getName()))
|
||||
} else if (binding.getOwnerId().equals(player.getGameProfile().getId()) && !binding.getOwnerName().equals(player.getGameProfile().getName()))
|
||||
{
|
||||
binding.setOwnerName(player.getGameProfile().getName());
|
||||
BindableHelper.applyBinding(held, binding);
|
||||
|
@ -70,4 +74,20 @@ public class GenericHandler
|
|||
network.setOrbTier(orb.getTier());
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPlayerDemonWillAura(PlayerEntity player)
|
||||
{
|
||||
if (player instanceof ServerPlayerEntity)
|
||||
{
|
||||
BlockPos pos = player.getPosition();
|
||||
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(WorldDemonWillHandler.getDimensionResourceLocation(player.world), pos.getX() >> 4, pos.getZ() >> 4);
|
||||
if (holder != null)
|
||||
{
|
||||
BloodMagic.packetHandler.sendTo(new DemonAuraClientPacket(holder), (ServerPlayerEntity) player);
|
||||
} else
|
||||
{
|
||||
BloodMagic.packetHandler.sendTo(new DemonAuraClientPacket(new DemonWillHolder()), (ServerPlayerEntity) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue