Part 1 of reimplementing Ritual Diviner

Finished the placement of the Ritual Stones from the ItemRitualDiviner.
Still need to finish the rendering system for the ghost blocks.
This commit is contained in:
WayofTime 2020-10-24 22:37:04 -04:00
parent 446fe9cef7
commit 85e47dbfa8
40 changed files with 1486 additions and 11 deletions

View file

@ -0,0 +1,66 @@
package wayoftime.bloodmagic.client.render.block;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
public class RenderFakeBlocks
{
public static void drawFakeBlock(TextureAtlasSprite texture, double minX, double minY, double minZ)
{
if (texture == null)
return;
double maxX = minX + 1;
double maxY = minY + 1;
double maxZ = minZ + 1;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder wr = tessellator.getBuffer();
Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(texture.getName());
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
float texMinU = texture.getMinU();
float texMinV = texture.getMinV();
float texMaxU = texture.getMaxU();
float texMaxV = texture.getMaxV();
wr.pos(minX, minY, minZ).tex(texMinU, texMinV).endVertex();
wr.pos(maxX, minY, minZ).tex(texMaxU, texMinV).endVertex();
wr.pos(maxX, minY, maxZ).tex(texMaxU, texMaxV).endVertex();
wr.pos(minX, minY, maxZ).tex(texMinU, texMaxV).endVertex();
wr.pos(minX, maxY, maxZ).tex(texMinU, texMaxV).endVertex();
wr.pos(maxX, maxY, maxZ).tex(texMaxU, texMaxV).endVertex();
wr.pos(maxX, maxY, minZ).tex(texMaxU, texMinV).endVertex();
wr.pos(minX, maxY, minZ).tex(texMinU, texMinV).endVertex();
wr.pos(maxX, minY, minZ).tex(texMinU, texMaxV).endVertex();
wr.pos(minX, minY, minZ).tex(texMaxU, texMaxV).endVertex();
wr.pos(minX, maxY, minZ).tex(texMaxU, texMinV).endVertex();
wr.pos(maxX, maxY, minZ).tex(texMinU, texMinV).endVertex();
wr.pos(minX, minY, maxZ).tex(texMinU, texMaxV).endVertex();
wr.pos(maxX, minY, maxZ).tex(texMaxU, texMaxV).endVertex();
wr.pos(maxX, maxY, maxZ).tex(texMaxU, texMinV).endVertex();
wr.pos(minX, maxY, maxZ).tex(texMinU, texMinV).endVertex();
wr.pos(minX, minY, minZ).tex(texMinU, texMaxV).endVertex();
wr.pos(minX, minY, maxZ).tex(texMaxU, texMaxV).endVertex();
wr.pos(minX, maxY, maxZ).tex(texMaxU, texMinV).endVertex();
wr.pos(minX, maxY, minZ).tex(texMinU, texMinV).endVertex();
wr.pos(maxX, minY, maxZ).tex(texMinU, texMaxV).endVertex();
wr.pos(maxX, minY, minZ).tex(texMaxU, texMaxV).endVertex();
wr.pos(maxX, maxY, minZ).tex(texMaxU, texMinV).endVertex();
wr.pos(maxX, maxY, maxZ).tex(texMinU, texMinV).endVertex();
tessellator.draw();
}
}

View file

@ -66,15 +66,15 @@ public class BlockMasterRitualStone extends Block
}
} else
{
player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notValid"), true);
player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notvalid"), true);
}
} else
{
player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notValid"), true);
player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notvalid"), true);
}
} else
{
player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notValid"), true);
player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notvalid"), true);
}
}
}

View file

@ -58,7 +58,7 @@ public class BlockRitualStone extends Block implements IRitualStone
public void setRuneType(World world, BlockPos pos, EnumRuneType runeType)
{
Block runeBlock = this;
switch (type)
switch (runeType)
{
case AIR:
runeBlock = BloodMagicBlocks.AIR_RITUAL_STONE.get();

View file

@ -45,6 +45,8 @@ public class GeneratorBaseRecipes extends BaseRecipeProvider
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.CAPACITY_RUNE.get()).key('a', Tags.Items.STONE).key('b', Items.BUCKET).key('c', BloodMagicBlocks.BLANK_RUNE.get()).key('d', BloodMagicItems.IMBUED_SLATE.get()).patternLine("aba").patternLine("bcb").patternLine("ada").addCriterion("has_imbued_slate", hasItem(BloodMagicItems.IMBUED_SLATE.get())).build(consumer, BloodMagic.rl("blood_rune_capacity"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.ORB_RUNE.get()).key('a', Tags.Items.STONE).key('b', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_WEAK.get())).key('c', BloodMagicBlocks.BLANK_RUNE.get()).key('d', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MASTER.get())).patternLine("aba").patternLine("cdc").patternLine("aba").addCriterion("has_master_orb", hasItem(BloodMagicItems.MASTER_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("blood_rune_orb"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.CHARGING_RUNE.get()).key('R', Tags.Items.DUSTS_REDSTONE).key('r', BloodMagicBlocks.BLANK_RUNE.get()).key('s', BloodMagicItems.DEMONIC_SLATE.get()).key('e', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MASTER.get())).key('G', Tags.Items.DUSTS_GLOWSTONE).patternLine("RsR").patternLine("GrG").patternLine("ReR").addCriterion("has_master_orb", hasItem(BloodMagicItems.MASTER_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("blood_rune_charging"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.BLANK_RITUAL_STONE.get(), 4).key('a', Tags.Items.OBSIDIAN).key('b', BloodMagicItems.REINFORCED_SLATE.get()).key('c', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_APPRENTICE.get())).patternLine("aba").patternLine("bcb").patternLine("aba").addCriterion("has_apprentice_orb", hasItem(BloodMagicItems.APPRENTICE_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("ritual_stone_blank"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.MASTER_RITUAL_STONE.get()).key('a', Tags.Items.OBSIDIAN).key('b', BloodMagicBlocks.BLANK_RITUAL_STONE.get()).key('c', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MAGICIAN.get())).patternLine("aba").patternLine("bcb").patternLine("aba").addCriterion("has_magician_orb", hasItem(BloodMagicItems.MAGICIAN_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("ritual_stone_master"));
// ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SPEED_RUNE.get()).key('s', Items.GLASS).key('o', Ingredient.fromItems(Items.DIAMOND)).patternLine("sss").patternLine("sos").patternLine("sss").addCriterion("has_diamond", hasItem(Items.DIAMOND)).build(consumer, new ResourceLocation(BloodMagic.MODID, "speed_rune_from_standard"));
// ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SPEED_RUNE.get()).key('s', Items.GLASS).key('o', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_WEAK.get())).patternLine("sss").patternLine("sos").patternLine("sss").addCriterion("has_diamond", hasItem(Items.DIAMOND)).build(consumer, new ResourceLocation(BloodMagic.MODID, "speed_rune_from_orb"));
}

View file

@ -81,8 +81,54 @@ public class GeneratorLanguage extends LanguageProvider
add("tooltip.bloodmagic.sigil.air.desc", "I feel lighter already...");
add("tooltip.bloodmagic.sigil.bloodlight.desc", "I see a light!");
add("tooltip.bloodmagic.activationcrystal.weak", "Activates low-level rituals");
add("tooltip.bloodmagic.activationcrystal.awakened", "Activates more powerful rituals");
add("tooltip.bloodmagic.activationcrystal.creative", "Creative Only - Activates any ritual");
add("itemGroup.bloodmagictab", "Blood Magic");
// Ritual info
add("tooltip.bloodmagic.diviner.currentRitual", "Current Ritual: %s");
add("tooltip.bloodmagic.diviner.blankRune", "Blank Runes: %d");
add("tooltip.bloodmagic.diviner.waterRune", "Water Runes: %d");
add("tooltip.bloodmagic.diviner.airRune", "Air Runes: %d");
add("tooltip.bloodmagic.diviner.fireRune", "Fire Runes: %d");
add("tooltip.bloodmagic.diviner.earthRune", "Earth Runes: %d");
add("tooltip.bloodmagic.diviner.duskRune", "Dusk Runes: %d");
add("tooltip.bloodmagic.diviner.dawnRune", "Dawn Runes: %d");
add("tooltip.bloodmagic.diviner.totalRune", "Total Runes: %d");
add("tooltip.bloodmagic.diviner.extraInfo", "Press shift for extra info");
add("tooltip.bloodmagic.diviner.currentDirection", "Current Direction: %s");
add("ritual.bloodmagic.testRitual", "Test Ritual");
add("ritual.bloodmagic.waterRitual", "Ritual of the Full Spring");
add("ritual.bloodmagic.lavaRitual", "Serenade of the Nether");
add("ritual.bloodmagic.greenGroveRitual", "Ritual of the Green Grove");
add("ritual.bloodmagic.jumpRitual", "Ritual of the High Jump");
add("ritual.bloodmagic.wellOfSufferingRitual", "Well of Suffering");
add("ritual.bloodmagic.featheredKnifeRitual", "Ritual of the Feathered Knife");
add("ritual.bloodmagic.regenerationRitual", "Ritual of Regeneration");
add("ritual.bloodmagic.harvestRitual", "Reap of the Harvest Moon");
add("ritual.bloodmagic.magneticRitual", "Ritual of Magnetism");
add("ritual.bloodmagic.crushingRitual", "Ritual of the Crusher");
add("ritual.bloodmagic.fullStomachRitual", "Ritual of the Satiated Stomach");
add("ritual.bloodmagic.interdictionRitual", "Ritual of Interdiction");
add("ritual.bloodmagic.containmentRitual", "Ritual of Containment");
add("ritual.bloodmagic.speedRitual", "Ritual of Speed");
add("ritual.bloodmagic.suppressionRitual", "Ritual of Suppression");
add("ritual.bloodmagic.expulsionRitual", "Aura of Expulsion");
add("ritual.bloodmagic.zephyrRitual", "Call of the Zephyr");
add("ritual.bloodmagic.upgradeRemoveRitual", "Sound of the Cleansing Soul");
add("ritual.bloodmagic.armourEvolveRitual", "Ritual of Living Evolution");
add("ritual.bloodmagic.animalGrowthRitual", "Ritual of the Shepherd");
add("ritual.bloodmagic.cobblestoneRitual", "Le Vulcanos Frigius");
add("ritual.bloodmagic.placerRitual", "The Filler");
add("ritual.bloodmagic.fellingRitual", "The Timberman");
add("ritual.bloodmagic.pumpRitual", "Hymn of Siphoning");
add("ritual.bloodmagic.altarBuilderRitual", "The Assembly of the High Altar");
add("ritual.bloodmagic.portalRitual", "The Gate of the Fold");
// Block names
addBlock(BloodMagicBlocks.BLANK_RUNE, "Blank Rune");
addBlock(BloodMagicBlocks.SPEED_RUNE, "Speed Rune");
@ -96,6 +142,14 @@ public class GeneratorLanguage extends LanguageProvider
addBlock(BloodMagicBlocks.CHARGING_RUNE, "Charging Rune");
addBlock(BloodMagicBlocks.BLOOD_ALTAR, "Blood Altar");
addBlock(BloodMagicBlocks.SOUL_FORGE, "Hellfire Forge");
addBlock(BloodMagicBlocks.BLANK_RITUAL_STONE, "Ritual Stone");
addBlock(BloodMagicBlocks.AIR_RITUAL_STONE, "Air Ritual Stone");
addBlock(BloodMagicBlocks.WATER_RITUAL_STONE, "Water Ritual Stone");
addBlock(BloodMagicBlocks.FIRE_RITUAL_STONE, "Fire Ritual Stone");
addBlock(BloodMagicBlocks.EARTH_RITUAL_STONE, "Earth Ritual Stone");
addBlock(BloodMagicBlocks.DUSK_RITUAL_STONE, "Dusk Ritual Stone");
addBlock(BloodMagicBlocks.DAWN_RITUAL_STONE, "Dawn Ritual Stone");
addBlock(BloodMagicBlocks.MASTER_RITUAL_STONE, "Master Ritual Stone");
// Item names
addItem(BloodMagicItems.WEAK_BLOOD_ORB, "Weak Blood Orb");
@ -144,6 +198,15 @@ public class GeneratorLanguage extends LanguageProvider
addItem(BloodMagicItems.SOUL_SNARE, "Soul Snare");
addItem(BloodMagicItems.SENTIENT_SWORD, "Sentient Sword");
addItem(BloodMagicItems.WEAK_ACTIVATION_CRYSTAL, "Weak Activation Crystal");
addItem(BloodMagicItems.AWAKENED_ACTIVATION_CRYSTAL, "Awakened Activation Crystal");
addItem(BloodMagicItems.CREATIVE_ACTIVATION_CRYSTAL, "Creative Activation Crystal");
addItem(BloodMagicItems.WATER_INSCRIPTION_TOOL, "Inscription Tool: Water");
addItem(BloodMagicItems.FIRE_INSCRIPTION_TOOL, "Inscription Tool: Fire");
addItem(BloodMagicItems.EARTH_INSCRIPTION_TOOL, "Inscription Tool: Earth");
addItem(BloodMagicItems.AIR_INSCRIPTION_TOOL, "Inscription Tool: Air");
addItem(BloodMagicItems.DUSK_INSCRIPTION_TOOL, "Inscription Tool: Dusk");
// addItem(BloodMagicItems , "");
// JEI
@ -157,5 +220,12 @@ public class GeneratorLanguage extends LanguageProvider
add("jei.bloodmagic.recipe.altar", "Blood Altar");
add("jei.bloodmagic.recipe.soulforge", "Hellfire Forge");
add("jei.bloodmagic.recipe.alchemyarraycrafting", "Alchemy Array");
// Chat
add("chat.bloodmagic.ritual.weak", "You feel a push, but are too weak to perform this ritual.");
add("chat.bloodmagic.ritual.prevent", "The ritual is actively resisting you!");
add("chat.bloodmagic.ritual.activate", "A rush of energy flows through the ritual!");
add("chat.bloodmagic.ritual.notValid", "You feel that these runes are not configured correctly...");
}
}

View file

@ -25,6 +25,7 @@ import wayoftime.bloodmagic.common.item.soul.ItemSoulSnare;
import wayoftime.bloodmagic.common.registration.impl.BloodOrbDeferredRegister;
import wayoftime.bloodmagic.common.registration.impl.BloodOrbRegistryObject;
import wayoftime.bloodmagic.orb.BloodOrb;
import wayoftime.bloodmagic.ritual.EnumRuneType;
import wayoftime.bloodmagic.will.EnumDemonWillType;
public class BloodMagicItems
@ -62,6 +63,8 @@ public class BloodMagicItems
public static final RegistryObject<Item> DUSK_RITUAL_STONE_ITEM = ITEMS.register("duskritualstone", () -> new BlockItem(BloodMagicBlocks.DUSK_RITUAL_STONE.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> DAWN_RITUAL_STONE_ITEM = ITEMS.register("lightritualstone", () -> new BlockItem(BloodMagicBlocks.DAWN_RITUAL_STONE.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> MASTER_RITUAL_STONE_ITEM = ITEMS.register("masterritualstone", () -> new BlockItem(BloodMagicBlocks.MASTER_RITUAL_STONE.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> BLOOD_ALTAR_ITEM = ITEMS.register("altar", () -> new BlockItem(BloodMagicBlocks.BLOOD_ALTAR.get(), new Item.Properties().group(BloodMagic.TAB)));
// TODO: Need to rework the above instantiations for the ItemBlocks so that it's
@ -94,10 +97,19 @@ public class BloodMagicItems
public static final RegistryObject<Item> ARCANE_ASHES = BASICITEMS.register("arcaneashes", () -> new ItemArcaneAshes());
public static final RegistryObject<Item> DAGGER_OF_SACRIFICE = BASICITEMS.register("daggerofsacrifice", () -> new ItemDaggerOfSacrifice());
// Ritual stuffs
public static final RegistryObject<Item> WEAK_ACTIVATION_CRYSTAL = BASICITEMS.register("activationcrystalweak", () -> new ItemActivationCrystal(ItemActivationCrystal.CrystalType.WEAK));
public static final RegistryObject<Item> AWAKENED_ACTIVATION_CRYSTAL = BASICITEMS.register("activationcrystalawakened", () -> new ItemActivationCrystal(ItemActivationCrystal.CrystalType.AWAKENED));
public static final RegistryObject<Item> CREATIVE_ACTIVATION_CRYSTAL = BASICITEMS.register("activationcrystalcreative", () -> new ItemActivationCrystal(ItemActivationCrystal.CrystalType.CREATIVE));
public static final RegistryObject<Item> AIR_INSCRIPTION_TOOL = BASICITEMS.register("airscribetool", () -> new ItemInscriptionTool(EnumRuneType.AIR));
public static final RegistryObject<Item> FIRE_INSCRIPTION_TOOL = BASICITEMS.register("firescribetool", () -> new ItemInscriptionTool(EnumRuneType.FIRE));
public static final RegistryObject<Item> WATER_INSCRIPTION_TOOL = BASICITEMS.register("waterscribetool", () -> new ItemInscriptionTool(EnumRuneType.WATER));
public static final RegistryObject<Item> EARTH_INSCRIPTION_TOOL = BASICITEMS.register("earthscribetool", () -> new ItemInscriptionTool(EnumRuneType.EARTH));
public static final RegistryObject<Item> DUSK_INSCRIPTION_TOOL = BASICITEMS.register("duskscribetool", () -> new ItemInscriptionTool(EnumRuneType.DUSK));
public static final RegistryObject<Item> BASE_RITUAL_DIVINER = BASICITEMS.register("ritualdiviner", () -> new ItemRitualDiviner(0));
// Reagents used to make the Sigils
public static final RegistryObject<Item> REAGENT_WATER = BASICITEMS.register("reagentwater", () -> new ItemBase());
public static final RegistryObject<Item> REAGENT_LAVA = BASICITEMS.register("reagentlava", () -> new ItemBase());

View file

@ -30,7 +30,7 @@ public class ItemActivationCrystal extends Item implements IBindable
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
{
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.activation_crystal." + type.name().toLowerCase()));
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.activationcrystal." + type.name().toLowerCase()));
if (!stack.hasTag())
return;

View file

@ -0,0 +1,66 @@
package wayoftime.bloodmagic.common.item;
import java.util.List;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.common.block.BlockRitualStone;
import wayoftime.bloodmagic.ritual.EnumRuneType;
import wayoftime.bloodmagic.util.helper.TextHelper;
public class ItemInscriptionTool extends Item
{
private final EnumRuneType type;
public ItemInscriptionTool(EnumRuneType type)
{
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB).maxDamage(40));
this.type = type;
}
@Override
public ActionResultType onItemUse(ItemUseContext context)
{
ItemStack stack = context.getItem();
BlockPos pos = context.getPos();
World world = context.getWorld();
PlayerEntity player = context.getPlayer();
BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockRitualStone
&& !((BlockRitualStone) state.getBlock()).isRuneType(world, pos, type))
{
((BlockRitualStone) state.getBlock()).setRuneType(world, pos, type);
if (!player.isCreative())
{
stack.damageItem(1, player, (entity) -> {
entity.sendBreakAnimation(EquipmentSlotType.MAINHAND);
});
}
return ActionResultType.SUCCESS;
}
return ActionResultType.FAIL;
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
{
tooltip.add(new TranslationTextComponent(TextHelper.localizeEffect("tooltip.bloodmagic.inscriber.desc")));
}
}

View file

@ -0,0 +1,591 @@
package wayoftime.bloodmagic.common.item;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.common.block.BlockRitualStone;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.ritual.EnumRuneType;
import wayoftime.bloodmagic.ritual.Ritual;
import wayoftime.bloodmagic.ritual.RitualComponent;
import wayoftime.bloodmagic.tile.TileMasterRitualStone;
import wayoftime.bloodmagic.util.Constants;
import wayoftime.bloodmagic.util.Utils;
import wayoftime.bloodmagic.util.handler.event.ClientHandler;
import wayoftime.bloodmagic.util.helper.RitualHelper;
import wayoftime.bloodmagic.util.helper.TextHelper;
import wayoftime.bloodmagic.will.EnumDemonWillType;
public class ItemRitualDiviner extends Item
{
final int type;
public static final String tooltipBase = "tooltip.bloodmagic.diviner.";
public static String[] names =
{ "normal", "dusk", "dawn" };
public ItemRitualDiviner(int type)
{
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
this.type = type;
}
// @Override
// public String getHighlightTip(ItemStack stack, String displayName)
// {
// if (Strings.isNullOrEmpty(getCurrentRitual(stack)))
// return displayName;
//
// Ritual ritual = BloodMagic.RITUAL_MANAGER.getRitual(getCurrentRitual(stack));
// if (ritual == null)
// return displayName;
//
// return displayName + ": " + TextHelper.localize(ritual.getTranslationKey());
// }
@Override
public ActionResultType onItemUse(ItemUseContext context)
{
ItemStack stack = context.getPlayer().getHeldItem(context.getHand());
if (context.getPlayer().isSneaking())
{
if (context.getWorld().isRemote)
{
trySetDisplayedRitual(stack, context.getWorld(), context.getPos());
}
return ActionResultType.SUCCESS;
} else if (addRuneToRitual(stack, context.getWorld(), context.getPos(), context.getPlayer()))
{
if (context.getWorld().isRemote)
{
spawnParticles(context.getWorld(), context.getPos().offset(context.getFace()), 15);
}
return ActionResultType.SUCCESS;
// TODO: Have the diviner automagically build the ritual
}
return ActionResultType.PASS;
}
/**
* Adds a single rune to the ritual.
*
* @param stack - The Ritual Diviner stack
* @param world - The World
* @param pos - Block Position of the MRS.
* @param player - The Player attempting to place the ritual
* @return - True if a rune was successfully added
*/
public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, PlayerEntity player)
{
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileMasterRitualStone)
{
Ritual ritual = BloodMagic.RITUAL_MANAGER.getRitual(this.getCurrentRitual(stack));
if (ritual != null)
{
Direction direction = getDirection(stack);
List<RitualComponent> components = Lists.newArrayList();
ritual.gatherComponents(components::add);
for (RitualComponent component : components)
{
if (!canPlaceRitualStone(component.getRuneType(), stack))
{
return false;
}
BlockPos offset = component.getOffset(direction);
BlockPos newPos = pos.add(offset);
BlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
if (RitualHelper.isRune(world, newPos))
{
if (RitualHelper.isRuneType(world, newPos, component.getRuneType()))
{
if (world.isRemote)
{
undisplayHologram();
}
} else
{
// Replace existing ritual stone
RitualHelper.setRuneType(world, newPos, component.getRuneType());
return true;
}
} else if (block.isAir(state, world, newPos))// || block.isReplaceable(world, newPos))
{
if (!consumeStone(stack, world, player))
{
return false;
}
((BlockRitualStone) BloodMagicBlocks.BLANK_RITUAL_STONE.get()).setRuneType(world, newPos, component.getRuneType());
return true;
} else
{
return false; // TODO: Possibly replace the block with a
// ritual stone
}
}
}
}
return false;
}
@OnlyIn(Dist.CLIENT)
public void trySetDisplayedRitual(ItemStack itemStack, World world, BlockPos pos)
{
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileMasterRitualStone)
{
Ritual ritual = BloodMagic.RITUAL_MANAGER.getRitual(this.getCurrentRitual(itemStack));
TileMasterRitualStone masterRitualStone = (TileMasterRitualStone) tile;
if (ritual != null)
{
Direction direction = getDirection(itemStack);
ClientHandler.setRitualHolo(masterRitualStone, ritual, direction, true);
}
}
}
@OnlyIn(Dist.CLIENT)
public void undisplayHologram()
{
ClientHandler.setRitualHoloToNull();
}
// TODO: Make this work for any IRitualStone
public boolean consumeStone(ItemStack stack, World world, PlayerEntity player)
{
if (player.isCreative())
{
return true;
}
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
for (ItemStack newStack : inventory)
{
if (newStack.isEmpty())
{
continue;
}
Item item = newStack.getItem();
if (item instanceof BlockItem)
{
Block block = ((BlockItem) item).getBlock();
if (block instanceof BlockRitualStone)
{
newStack.shrink(1);
return true;
}
}
}
return false;
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
{
if (!stack.hasTag())
return;
Ritual ritual = BloodMagic.RITUAL_MANAGER.getRitual(this.getCurrentRitual(stack));
if (ritual != null)
{
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.diviner.currentRitual", new TranslationTextComponent(ritual.getTranslationKey())));
boolean sneaking = Screen.hasShiftDown();
// boolean extraInfo = sneaking && Keyboard.isKeyDown(Keyboard.KEY_M);
boolean extraInfo = Screen.hasAltDown();
if (extraInfo)
{
tooltip.add(new StringTextComponent(""));
for (EnumDemonWillType type : EnumDemonWillType.values())
{
if (TextHelper.canTranslate(ritual.getTranslationKey() + "." + type.name().toLowerCase() + ".info"))
{
tooltip.add(new TranslationTextComponent(ritual.getTranslationKey() + "." + type.name().toLowerCase() + ".info"));
}
}
} else if (sneaking)
{
tooltip.add(new TranslationTextComponent(tooltipBase + "currentDirection", Utils.toFancyCasing(getDirection(stack).name())));
tooltip.add(new StringTextComponent(""));
List<RitualComponent> components = Lists.newArrayList();
ritual.gatherComponents(components::add);
int blankRunes = 0;
int airRunes = 0;
int waterRunes = 0;
int fireRunes = 0;
int earthRunes = 0;
int duskRunes = 0;
int dawnRunes = 0;
int totalRunes = components.size();
for (RitualComponent component : components)
{
switch (component.getRuneType())
{
case BLANK:
blankRunes++;
break;
case AIR:
airRunes++;
break;
case EARTH:
earthRunes++;
break;
case FIRE:
fireRunes++;
break;
case WATER:
waterRunes++;
break;
case DUSK:
duskRunes++;
break;
case DAWN:
dawnRunes++;
break;
}
}
if (blankRunes > 0)
tooltip.add(new TranslationTextComponent(tooltipBase + "blankRune", blankRunes).mergeStyle(EnumRuneType.BLANK.colorCode));
if (waterRunes > 0)
tooltip.add(new TranslationTextComponent(tooltipBase + "waterRune", waterRunes).mergeStyle(EnumRuneType.WATER.colorCode));
if (airRunes > 0)
tooltip.add(new TranslationTextComponent(tooltipBase + "airRune", airRunes).mergeStyle(EnumRuneType.AIR.colorCode));
if (fireRunes > 0)
tooltip.add(new TranslationTextComponent(tooltipBase + "fireRune", fireRunes).mergeStyle(EnumRuneType.FIRE.colorCode));
if (earthRunes > 0)
tooltip.add(new TranslationTextComponent(tooltipBase + "earthRune", earthRunes).mergeStyle(EnumRuneType.EARTH.colorCode));
if (duskRunes > 0)
tooltip.add(new TranslationTextComponent(tooltipBase + "duskRune", duskRunes).mergeStyle(EnumRuneType.DUSK.colorCode));
if (dawnRunes > 0)
tooltip.add(new TranslationTextComponent(tooltipBase + "dawnRune", dawnRunes).mergeStyle(EnumRuneType.DAWN.colorCode));
tooltip.add(new StringTextComponent(""));
tooltip.add(new TranslationTextComponent(tooltipBase + "totalRune", totalRunes));
} else
{
tooltip.add(new StringTextComponent(""));
if (TextHelper.canTranslate(ritual.getTranslationKey() + ".info"))
{
tooltip.add(new TranslationTextComponent(ritual.getTranslationKey() + ".info"));
tooltip.add(new StringTextComponent(""));
}
tooltip.add(new TranslationTextComponent(tooltipBase + "extraInfo"));
tooltip.add(new TranslationTextComponent(tooltipBase + "extraExtraInfo"));
}
}
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
{
ItemStack stack = player.getHeldItem(hand);
RayTraceResult ray = rayTrace(world, player, RayTraceContext.FluidMode.NONE);
if (ray != null && ray.getType() == RayTraceResult.Type.BLOCK)
{
return new ActionResult<>(ActionResultType.PASS, stack);
}
if (player.isSneaking())
{
if (!world.isRemote)
{
cycleRitual(stack, player, false);
}
return new ActionResult<>(ActionResultType.SUCCESS, stack);
}
return new ActionResult<>(ActionResultType.PASS, stack);
}
@Override
public void onUse(World worldIn, LivingEntity entityLiving, ItemStack stack, int count)
{
if (!entityLiving.world.isRemote && entityLiving instanceof PlayerEntity)
{
PlayerEntity player = (PlayerEntity) entityLiving;
RayTraceResult ray = rayTrace(player.world, player, RayTraceContext.FluidMode.NONE);
if (ray != null && ray.getType() == RayTraceResult.Type.BLOCK)
{
return;
// return false;
}
if (!player.isSwingInProgress)
{
if (player.isSneaking())
{
cycleRitual(stack, player, true);
} else
{
cycleDirection(stack, player);
}
}
}
// return false;
}
public void cycleDirection(ItemStack stack, PlayerEntity player)
{
Direction direction = getDirection(stack);
Direction newDirection;
switch (direction)
{
case NORTH:
newDirection = Direction.EAST;
break;
case EAST:
newDirection = Direction.SOUTH;
break;
case SOUTH:
newDirection = Direction.WEST;
break;
case WEST:
newDirection = Direction.NORTH;
break;
default:
newDirection = Direction.NORTH;
}
setDirection(stack, newDirection);
notifyDirectionChange(newDirection, player);
}
public void notifyDirectionChange(Direction direction, PlayerEntity player)
{
player.sendStatusMessage(new TranslationTextComponent(tooltipBase + "currentDirection", Utils.toFancyCasing(direction.name())), true);
}
public void setDirection(ItemStack stack, Direction direction)
{
if (!stack.hasTag())
{
stack.setTag(new CompoundNBT());
}
CompoundNBT tag = stack.getTag();
tag.putInt(Constants.NBT.DIRECTION, direction.getIndex());
}
public Direction getDirection(ItemStack stack)
{
if (!stack.hasTag())
{
stack.setTag(new CompoundNBT());
return Direction.NORTH;
}
CompoundNBT tag = stack.getTag();
int dir = tag.getInt(Constants.NBT.DIRECTION);
if (dir == 0)
{
return Direction.NORTH;
}
return Direction.values()[tag.getInt(Constants.NBT.DIRECTION)];
}
/**
* Cycles the ritual forward or backward
*/
public void cycleRitual(ItemStack stack, PlayerEntity player, boolean reverse)
{
String key = getCurrentRitual(stack);
List<Ritual> rituals = BloodMagic.RITUAL_MANAGER.getSortedRituals();
if (reverse)
Collections.reverse(rituals = Lists.newArrayList(rituals));
String firstId = "";
boolean foundId = false;
boolean foundFirst = false;
for (Ritual ritual : rituals)
{
String id = BloodMagic.RITUAL_MANAGER.getId(ritual);
if (!BloodMagic.RITUAL_MANAGER.enabled(id, false) || !canDivinerPerformRitual(stack, ritual))
{
continue;
}
if (!foundFirst)
{
firstId = id;
foundFirst = true;
}
if (foundId)
{
setCurrentRitual(stack, id);
notifyRitualChange(id, player);
return;
} else if (id.equals(key))
{
foundId = true;
}
}
if (foundFirst)
{
setCurrentRitual(stack, firstId);
notifyRitualChange(firstId, player);
}
}
public boolean canDivinerPerformRitual(ItemStack stack, Ritual ritual)
{
if (ritual == null)
{
return false;
}
List<RitualComponent> components = Lists.newArrayList();
ritual.gatherComponents(components::add);
for (RitualComponent component : components)
{
if (!canPlaceRitualStone(component.getRuneType(), stack))
{
return false;
}
}
return true;
}
public void notifyRitualChange(String key, PlayerEntity player)
{
Ritual ritual = BloodMagic.RITUAL_MANAGER.getRitual(key);
if (ritual != null)
{
player.sendStatusMessage(new TranslationTextComponent(ritual.getTranslationKey()), true);
}
}
public void setCurrentRitual(ItemStack stack, String key)
{
if (!stack.hasTag())
{
stack.setTag(new CompoundNBT());
}
CompoundNBT tag = stack.getTag();
tag.putString("current_ritual", key);
}
public String getCurrentRitual(ItemStack stack)
{
if (!stack.hasTag())
{
stack.setTag(new CompoundNBT());
}
CompoundNBT tag = stack.getTag();
return tag.getString("current_ritual");
}
public boolean canPlaceRitualStone(EnumRuneType rune, ItemStack stack)
{
int meta = type;
switch (rune)
{
case BLANK:
case AIR:
case EARTH:
case FIRE:
case WATER:
return true;
case DUSK:
return meta >= 1;
case DAWN:
return meta >= 2;
}
return false;
}
public static void spawnParticles(World worldIn, BlockPos pos, int amount)
{
BlockState state = worldIn.getBlockState(pos);
Block block = worldIn.getBlockState(pos).getBlock();
if (block.isAir(state, worldIn, pos))
{
for (int i = 0; i < amount; ++i)
{
double d0 = random.nextGaussian() * 0.02D;
double d1 = random.nextGaussian() * 0.02D;
double d2 = random.nextGaussian() * 0.02D;
worldIn.addParticle(ParticleTypes.HAPPY_VILLAGER, (double) ((float) pos.getX()
+ random.nextFloat()), (double) pos.getY()
+ (double) random.nextFloat(), (double) ((float) pos.getZ()
+ random.nextFloat()), d0, d1, d2);
}
} else
{
for (int i1 = 0; i1 < amount; ++i1)
{
double d0 = random.nextGaussian() * 0.02D;
double d1 = random.nextGaussian() * 0.02D;
double d2 = random.nextGaussian() * 0.02D;
worldIn.addParticle(ParticleTypes.HAPPY_VILLAGER, (double) ((float) pos.getX()
+ random.nextFloat()), (double) pos.getY()
+ (double) random.nextFloat()
* 1.0f, (double) ((float) pos.getZ() + random.nextFloat()), d0, d1, d2);
}
}
}
}

View file

@ -33,9 +33,14 @@ public class BloodAltarRecipeProvider implements ISubRecipeProvider
// THREE
BloodAltarRecipeBuilder.altar(Ingredient.fromItems(BloodMagicItems.REINFORCED_SLATE.get()), new ItemStack(BloodMagicItems.IMBUED_SLATE.get()), AltarTier.THREE.ordinal(), 5000, 15, 10).build(consumer, BloodMagic.rl(basePath + "imbuedslate"));
BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_GOLD), new ItemStack(BloodMagicItems.MAGICIAN_BLOOD_ORB.get()), AltarTier.THREE.ordinal(), 25000, 20, 20).build(consumer, BloodMagic.rl(basePath + "magicianbloodorb"));
BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.OBSIDIAN), new ItemStack(BloodMagicItems.EARTH_INSCRIPTION_TOOL.get()), AltarTier.THREE.ordinal(), 1000, 5, 5).build(consumer, BloodMagic.rl(basePath + "earth_tool"));
BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_LAPIS), new ItemStack(BloodMagicItems.WATER_INSCRIPTION_TOOL.get()), AltarTier.THREE.ordinal(), 1000, 5, 5).build(consumer, BloodMagic.rl(basePath + "water_tool"));
BloodAltarRecipeBuilder.altar(Ingredient.fromItems(Items.MAGMA_CREAM), new ItemStack(BloodMagicItems.FIRE_INSCRIPTION_TOOL.get()), AltarTier.THREE.ordinal(), 1000, 5, 5).build(consumer, BloodMagic.rl(basePath + "fire_tool"));
BloodAltarRecipeBuilder.altar(Ingredient.fromItems(Items.GHAST_TEAR), new ItemStack(BloodMagicItems.AIR_INSCRIPTION_TOOL.get()), AltarTier.THREE.ordinal(), 1000, 5, 5).build(consumer, BloodMagic.rl(basePath + "air_tool"));
// FOUR
BloodAltarRecipeBuilder.altar(Ingredient.fromItems(BloodMagicItems.IMBUED_SLATE.get()), new ItemStack(BloodMagicItems.DEMONIC_SLATE.get()), AltarTier.FOUR.ordinal(), 15000, 20, 20).build(consumer, BloodMagic.rl(basePath + "demonicslate"));
BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_COAL), new ItemStack(BloodMagicItems.DUSK_INSCRIPTION_TOOL.get()), AltarTier.FOUR.ordinal(), 2000, 20, 10).build(consumer, BloodMagic.rl(basePath + "dusk_tool"));
// BloodAltarRecipeBuilder.altar(input, output, minimumTier, syphon, consumeRate, drainRate).build(consumer, BloodMagic.rl(basePath + ""));

View file

@ -220,7 +220,7 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS
} else
{
if (activator != null)
activator.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notValid"), true);
activator.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notvalid"), true);
}
return false;

View file

@ -1,7 +1,7 @@
package wayoftime.bloodmagic.tile.base;
import net.minecraft.client.renderer.texture.ITickable;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
/**
@ -9,7 +9,7 @@ import net.minecraft.tileentity.TileEntityType;
* programmatically.
*/
// TODO - Move implementations that depend on existed ticks to new methods from here.
public abstract class TileTicking extends TileBase implements ITickable
public abstract class TileTicking extends TileBase implements ITickableTileEntity
{
private int ticksExisted;
private boolean shouldTick = true;

View file

@ -0,0 +1,303 @@
package wayoftime.bloodmagic.util.handler.event;
import java.util.List;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.Atlases;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.client.render.BloodMagicRenderer;
import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model3D;
import wayoftime.bloodmagic.client.render.RenderResizableCuboid;
import wayoftime.bloodmagic.client.render.block.RenderFakeBlocks;
import wayoftime.bloodmagic.common.item.ItemRitualDiviner;
import wayoftime.bloodmagic.ritual.Ritual;
import wayoftime.bloodmagic.ritual.RitualComponent;
import wayoftime.bloodmagic.tile.TileMasterRitualStone;
@Mod.EventBusSubscriber(modid = BloodMagic.MODID, value = Dist.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ClientHandler
{
public static final boolean SUPPRESS_ASSET_ERRORS = true;
public static ResourceLocation ritualStoneBlank = BloodMagic.rl("block/ritualstone");;
public static ResourceLocation ritualStoneWater = BloodMagic.rl("block/waterritualstone");;
public static ResourceLocation ritualStoneFire = BloodMagic.rl("block/fireritualstone");;
public static ResourceLocation ritualStoneEarth = BloodMagic.rl("block/earthritualstone");;
public static ResourceLocation ritualStoneAir = BloodMagic.rl("block/airritualstone");;
public static ResourceLocation ritualStoneDawn = BloodMagic.rl("block/dawnritualstone");;
public static ResourceLocation ritualStoneDusk = BloodMagic.rl("block/lightritualstone");;
public static TextureAtlasSprite blankBloodRune;
public static TextureAtlasSprite stoneBrick;
public static TextureAtlasSprite glowstone;
// public static TextureAtlasSprite bloodStoneBrick;
public static TextureAtlasSprite beacon;
// public static TextureAtlasSprite crystalCluster;
public static Minecraft minecraft = Minecraft.getInstance();
private static TileMasterRitualStone mrsHoloTile;
private static Ritual mrsHoloRitual;
private static Direction mrsHoloDirection;
private static boolean mrsHoloDisplay;
@SubscribeEvent
public static void onTextureStitch(TextureStitchEvent.Pre event)
{
final String BLOCKS = "block/";
// ritualStoneBlank = Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(BloodMagic.rl(block//" + "blankrune"));
//// ritualStoneBlank = forName(event.getMap(), "ritualstone", BLOCKS);
// ritualStoneWater = forName(event.getMap(), "waterritualstone", BLOCKS);
// ritualStoneFire = forName(event.getMap(), "fireritualstone", BLOCKS);
// ritualStoneEarth = forName(event.getMap(), "earthritualstone", BLOCKS);
// ritualStoneAir = forName(event.getMap(), "airritualstone", BLOCKS);
// ritualStoneDawn = forName(event.getMap(), "lightritualstone", BLOCKS);
// ritualStoneDusk = forName(event.getMap(), "duskritualstone", BLOCKS);
blankBloodRune = forName(event.getMap(), "blankrune", BLOCKS);
stoneBrick = event.getMap().getSprite(new ResourceLocation("minecraft:block/stonebrick"));
glowstone = event.getMap().getSprite(new ResourceLocation("minecraft:block/glowstone"));
// bloodStoneBrick = forName(event.getMap(), "BloodStoneBrick", BLOCKS);
beacon = event.getMap().getSprite(new ResourceLocation("minecraft:block/beacon"));
// crystalCluster = forName(event.getMap(), "ShardCluster", BLOCKS);
}
@SubscribeEvent
public static void render(RenderWorldLastEvent event)
{
ClientPlayerEntity player = minecraft.player;
World world = player.getEntityWorld();
if (mrsHoloTile != null)
{
if (world.getTileEntity(mrsHoloTile.getPos()) instanceof TileMasterRitualStone)
{
if (mrsHoloDisplay)
{
IRenderTypeBuffer.Impl buffers = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
MatrixStack stack = event.getMatrixStack();
renderRitualStones(stack, buffers, mrsHoloTile, event.getPartialTicks());
RenderSystem.disableDepthTest();
buffers.finish();
} else
ClientHandler.setRitualHoloToNull();
} else
{
ClientHandler.setRitualHoloToNull();
}
}
if (minecraft.objectMouseOver == null || minecraft.objectMouseOver.getType() != RayTraceResult.Type.BLOCK)
return;
TileEntity tileEntity = world.getTileEntity(((BlockRayTraceResult) minecraft.objectMouseOver).getPos());
if (tileEntity instanceof TileMasterRitualStone && !player.getHeldItemMainhand().isEmpty()
&& player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner)
renderRitualStones(player, event.getPartialTicks());
}
private static TextureAtlasSprite forName(AtlasTexture textureMap, String name, String dir)
{
return textureMap.getSprite(new ResourceLocation(BloodMagic.MODID + dir + "/" + name));
}
private static void renderRitualStones(ClientPlayerEntity player, float partialTicks)
{
World world = player.getEntityWorld();
ItemRitualDiviner ritualDiviner = (ItemRitualDiviner) player.inventory.getCurrentItem().getItem();
Direction direction = ritualDiviner.getDirection(player.inventory.getCurrentItem());
Ritual ritual = BloodMagic.RITUAL_MANAGER.getRitual(ritualDiviner.getCurrentRitual(player.inventory.getCurrentItem()));
if (ritual == null)
return;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
// GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// GlStateManager.color4f(1F, 1F, 1F, 0.6125F);
BlockPos vec3, vX;
vec3 = ((BlockRayTraceResult) minecraft.objectMouseOver).getPos();
double posX = player.lastTickPosX + (player.getPosX() - player.lastTickPosX) * partialTicks;
double posY = player.lastTickPosY + (player.getPosY() - player.lastTickPosY) * partialTicks;
double posZ = player.lastTickPosZ + (player.getPosZ() - player.lastTickPosZ) * partialTicks;
List<RitualComponent> components = Lists.newArrayList();
ritual.gatherComponents(components::add);
for (RitualComponent ritualComponent : components)
{
vX = vec3.add(ritualComponent.getOffset(direction));
double minX = vX.getX() - posX;
double minY = vX.getY() - posY;
double minZ = vX.getZ() - posZ;
if (!world.getBlockState(vX).isOpaqueCube(world, vX))
{
TextureAtlasSprite texture = null;
// switch (ritualComponent.getRuneType())
// {
// case BLANK:
// texture = ritualStoneBlank;
// break;
// case WATER:
// texture = ritualStoneWater;
// break;
// case FIRE:
// texture = ritualStoneFire;
// break;
// case EARTH:
// texture = ritualStoneEarth;
// break;
// case AIR:
// texture = ritualStoneAir;
// break;
// case DAWN:
// texture = ritualStoneDawn;
// break;
// case DUSK:
// texture = ritualStoneDusk;
// break;
// }
RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ);
}
}
GlStateManager.popMatrix();
}
public static void renderRitualStones(MatrixStack stack, IRenderTypeBuffer renderer, TileMasterRitualStone masterRitualStone, float partialTicks)
{
IVertexBuilder buffer = renderer.getBuffer(Atlases.getTranslucentCullBlockType());
System.out.println("Attempting to render stones");
ClientPlayerEntity player = minecraft.player;
World world = player.getEntityWorld();
Direction direction = mrsHoloDirection;
Ritual ritual = mrsHoloRitual;
if (ritual == null)
{
return;
}
// GlStateManager.pushMatrix();
// GlStateManager.enableBlend();
// GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// GlStateManager.color4f(1F, 1F, 1F, 0.5F);
BlockPos vec3, vX;
vec3 = masterRitualStone.getPos();
double posX = player.lastTickPosX + (player.getPosX() - player.lastTickPosX) * partialTicks;
double posY = player.lastTickPosY + (player.getPosY() - player.lastTickPosY) * partialTicks;
double posZ = player.lastTickPosZ + (player.getPosZ() - player.lastTickPosZ) * partialTicks;
List<RitualComponent> components = Lists.newArrayList();
ritual.gatherComponents(components::add);
for (RitualComponent ritualComponent : components)
{
stack.push();
vX = vec3.add(ritualComponent.getOffset(direction));
Vector3d eyePos = player.getEyePosition(partialTicks);
double minX = vX.getX() - eyePos.x;
double minY = vX.getY() - eyePos.y;
double minZ = vX.getZ() - eyePos.z;
stack.translate(minX, minY, minZ);
if (!world.getBlockState(vX).isOpaqueCube(world, vX))
{
ResourceLocation rl = null;
switch (ritualComponent.getRuneType())
{
case BLANK:
rl = ritualStoneBlank;
break;
case WATER:
rl = ritualStoneWater;
break;
case FIRE:
rl = ritualStoneFire;
break;
case EARTH:
rl = ritualStoneEarth;
break;
case AIR:
rl = ritualStoneAir;
break;
case DAWN:
rl = ritualStoneDawn;
break;
case DUSK:
rl = ritualStoneDusk;
break;
}
Model3D model = getBlockModel(rl);
RenderResizableCuboid.INSTANCE.renderCube(model, stack, buffer, 0xDDFFFFFF, 0x00F000F0, OverlayTexture.NO_OVERLAY);
// RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ);
}
stack.pop();
}
// GlStateManager.popMatrix();
}
private static Model3D getBlockModel(ResourceLocation rl)
{
Model3D model = new BloodMagicRenderer.Model3D();
model.setTexture(Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(rl));
model.minX = 0;
model.minY = 0;
model.minZ = 0;
model.maxX = 1;
model.maxY = 1;
model.maxZ = 1;
return model;
}
public static void setRitualHolo(TileMasterRitualStone masterRitualStone, Ritual ritual, Direction direction, boolean displayed)
{
mrsHoloDisplay = displayed;
mrsHoloTile = masterRitualStone;
mrsHoloRitual = ritual;
mrsHoloDirection = direction;
}
public static void setRitualHoloToNull()
{
mrsHoloDisplay = false;
mrsHoloTile = null;
mrsHoloRitual = null;
mrsHoloDirection = Direction.NORTH;
}
}