use of WayofTime.bloodmagic.orb.BloodOrb in project BloodMagic by WayofTime.
the class ItemBloodOrb method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.orb.desc"));
BloodOrb orb = getOrb(stack);
if (flag.isAdvanced() && orb != null)
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.orb.owner", orb.getRegistryName().getResourceDomain()));
super.addInformation(stack, world, tooltip, flag);
}
use of WayofTime.bloodmagic.orb.BloodOrb in project BloodMagic by WayofTime.
the class ItemBloodOrb method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
BloodOrb orb = getOrb(stack);
if (orb == null)
return ActionResult.newResult(EnumActionResult.FAIL, stack);
if (world == null)
return super.onItemRightClick(world, player, hand);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
if (PlayerHelper.isFakePlayer(player))
return super.onItemRightClick(world, player, hand);
if (!stack.hasTagCompound())
return super.onItemRightClick(world, player, hand);
Binding binding = getBinding(stack);
if (binding == null)
return super.onItemRightClick(world, player, hand);
if (world.isRemote)
return super.onItemRightClick(world, player, hand);
SoulNetwork ownerNetwork = NetworkHelper.getSoulNetwork(binding);
if (binding.getOwnerId().equals(player.getGameProfile().getId()))
ownerNetwork.setOrbTier(orb.getTier());
// Add LP to owner's network
ownerNetwork.add(200, orb.getCapacity());
// Hurt whoever is using it
ownerNetwork.hurtPlayer(player, 200);
return super.onItemRightClick(world, player, hand);
}
use of WayofTime.bloodmagic.orb.BloodOrb in project BloodMagic by WayofTime.
the class BloodAltar method updateAltar.
private void updateAltar() {
if (!isActive) {
if (cooldownAfterCrafting > 0)
cooldownAfterCrafting--;
return;
}
ItemStack input = tileAltar.getStackInSlot(0);
if (input.isEmpty())
return;
World world = tileAltar.getWorld();
BlockPos pos = tileAltar.getPos();
if (world.isRemote)
return;
if (!canBeFilled) {
boolean hasOperated = false;
int stackSize = input.getCount();
if (totalCharge > 0) {
int chargeDrained = Math.min(liquidRequired * stackSize - progress, totalCharge);
totalCharge -= chargeDrained;
progress += chargeDrained;
hasOperated = true;
}
if (fluid != null && fluid.amount >= 1) {
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
if (liquidDrained > (liquidRequired * stackSize - progress))
liquidDrained = liquidRequired * stackSize - progress;
fluid.amount = fluid.amount - liquidDrained;
progress += liquidDrained;
hasOperated = true;
if (internalCounter % 4 == 0 && world instanceof WorldServer) {
WorldServer server = (WorldServer) world;
server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.2, 0, 0.2, 0);
}
} else if (!hasOperated && progress > 0) {
progress -= (int) (efficiencyMultiplier * drainRate);
if (internalCounter % 2 == 0 && world instanceof WorldServer) {
WorldServer server = (WorldServer) world;
server.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.1, 0, 0.1, 0);
}
}
if (hasOperated) {
if (progress >= liquidRequired * stackSize) {
ItemStack result = ItemHandlerHelper.copyStackWithSize(recipe.getOutput(), stackSize);
BloodMagicCraftedEvent.Altar event = new BloodMagicCraftedEvent.Altar(recipe.getInput(), result);
MinecraftForge.EVENT_BUS.post(event);
tileAltar.setInventorySlotContents(0, event.getOutput());
progress = 0;
if (world instanceof WorldServer) {
WorldServer server = (WorldServer) world;
server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 40, 0.3, 0, 0.3, 0);
}
this.cooldownAfterCrafting = 30;
this.isActive = false;
}
}
} else {
ItemStack contained = tileAltar.getStackInSlot(0);
if (contained.isEmpty() || !(contained.getItem() instanceof IBloodOrb) || !(contained.getItem() instanceof IBindable))
return;
BloodOrb orb = ((IBloodOrb) contained.getItem()).getOrb(contained);
Binding binding = ((IBindable) contained.getItem()).getBinding(contained);
if (binding == null || orb == null)
return;
if (fluid != null && fluid.amount >= 1) {
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? orb.getFillRate() * (1 + consumptionMultiplier) : orb.getFillRate()), fluid.amount);
int drain = NetworkHelper.getSoulNetwork(binding).add(liquidDrained, (int) (orb.getCapacity() * this.orbCapacityMultiplier));
fluid.amount = fluid.amount - drain;
if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer) {
WorldServer server = (WorldServer) world;
server.spawnParticle(EnumParticleTypes.SPELL_WITCH, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.001);
}
}
}
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
}
use of WayofTime.bloodmagic.orb.BloodOrb in project BloodMagic by WayofTime.
the class RegistrarBloodMagic method registerModels.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event) {
for (BloodOrb orb : BLOOD_ORBS) {
ModelResourceLocation modelLocation = orb.getModelLocation();
if (modelLocation == null)
modelLocation = new ModelResourceLocation(orb.getRegistryName(), "inventory");
ModelLoader.registerItemVariants(RegistrarBloodMagicItems.BLOOD_ORB, modelLocation);
}
ModelLoader.setCustomMeshDefinition(RegistrarBloodMagicItems.BLOOD_ORB, stack -> {
if (!stack.hasTagCompound())
return new ModelResourceLocation(ORB_WEAK.getRegistryName(), "inventory");
BloodOrb orb = BLOOD_ORBS.getValue(new ResourceLocation(stack.getTagCompound().getString("orb")));
if (orb == null || orb.getModelLocation() == null)
return new ModelResourceLocation(ORB_WEAK.getRegistryName(), "inventory");
return orb.getModelLocation();
});
}
use of WayofTime.bloodmagic.orb.BloodOrb in project BloodMagic by WayofTime.
the class GenericHandler method onInteract.
// Handles binding of IBindable's as well as setting a player's highest orb tier
@SubscribeEvent
public static void onInteract(PlayerInteractEvent.RightClickItem event) {
if (event.getWorld().isRemote)
return;
EntityPlayer player = event.getEntityPlayer();
if (PlayerHelper.isFakePlayer(player))
return;
ItemStack held = event.getItemStack();
if (!held.isEmpty() && held.getItem() instanceof IBindable) {
// Make sure it's bindable
IBindable bindable = (IBindable) held.getItem();
Binding binding = bindable.getBinding(held);
if (binding == null) {
// If the binding is null, let's create one
if (bindable.onBind(player, held)) {
ItemBindEvent toPost = new ItemBindEvent(player, held);
if (// Allow cancellation of binding
MinecraftForge.EVENT_BUS.post(toPost))
return;
// Bind item to the player
BindableHelper.applyBinding(held, player);
}
// 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())) {
binding.setOwnerName(player.getGameProfile().getName());
BindableHelper.applyBinding(held, binding);
}
}
if (!held.isEmpty() && held.getItem() instanceof IBloodOrb) {
IBloodOrb bloodOrb = (IBloodOrb) held.getItem();
SoulNetwork network = NetworkHelper.getSoulNetwork(player);
BloodOrb orb = bloodOrb.getOrb(held);
if (orb == null)
return;
if (orb.getTier() > network.getOrbTier())
network.setOrbTier(orb.getTier());
}
}
Aggregations