use of WayofTime.bloodmagic.tile.TileMasterRitualStone in project BloodMagic by WayofTime.
the class DataProviderRitualController method getNBTData.
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te instanceof TileMasterRitualStone) {
TileMasterRitualStone mrs = (TileMasterRitualStone) te;
tag.setBoolean("master", true);
if (mrs.getCurrentRitual() != null) {
tag.setString("ritual", mrs.getCurrentRitual().getUnlocalizedName());
tag.setBoolean("active", mrs.isActive());
if (mrs.getOwner() != null)
tag.setString("owner", PlayerHelper.getUsernameFromUUID(mrs.getOwner()));
tag.setBoolean("enabled", RitualRegistry.ritualEnabled(mrs.getCurrentRitual()));
}
} else {
tag.setBoolean("master", false);
ImperfectRitual ritual = ImperfectRitualRegistry.getRitualForBlock(world.getBlockState(pos.up()));
if (ritual != null) {
tag.setString("ritual", ritual.getUnlocalizedName());
tag.setBoolean("enabled", ImperfectRitualRegistry.ritualEnabled(ritual));
}
}
return tag;
}
use of WayofTime.bloodmagic.tile.TileMasterRitualStone in project BloodMagic by WayofTime.
the class ItemRitualDiviner method addRuneToRitual.
/**
* 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, EntityPlayer player) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileMasterRitualStone) {
Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack));
if (ritual != null) {
EnumFacing 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);
IBlockState 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;
}
int meta = component.getRuneType().ordinal();
IBlockState newState = RegistrarBloodMagicBlocks.RITUAL_STONE.getStateFromMeta(meta);
world.setBlockState(newPos, newState);
return true;
} else {
// TODO: Possibly replace the block with a
return false;
// ritual stone
}
}
}
}
return false;
}
use of WayofTime.bloodmagic.tile.TileMasterRitualStone in project BloodMagic by WayofTime.
the class ItemRitualDiviner method trySetDisplayedRitual.
@SideOnly(Side.CLIENT)
public void trySetDisplayedRitual(ItemStack itemStack, World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileMasterRitualStone) {
Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(itemStack));
TileMasterRitualStone masterRitualStone = (TileMasterRitualStone) tile;
if (ritual != null) {
EnumFacing direction = getDirection(itemStack);
ClientHandler.setRitualHolo(masterRitualStone, ritual, direction, true);
}
}
}
use of WayofTime.bloodmagic.tile.TileMasterRitualStone in project BloodMagic by WayofTime.
the class BlockRitualController method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack heldItem = player.getHeldItem(hand);
TileEntity tile = world.getTileEntity(pos);
if (state.getValue(getProperty()) != EnumRitualController.IMPERFECT && tile instanceof TileMasterRitualStone) {
if (heldItem.getItem() == RegistrarBloodMagicItems.ACTIVATION_CRYSTAL) {
if (((IBindable) heldItem.getItem()).getBinding(heldItem) == null)
return false;
String key = RitualHelper.getValidRitual(world, pos);
EnumFacing direction = RitualHelper.getDirectionOfRitual(world, pos, key);
// TODO: Give a message stating that this ritual is not a valid ritual.
if (!key.isEmpty() && direction != null && RitualHelper.checkValidRitual(world, pos, key, direction)) {
if (((TileMasterRitualStone) tile).activateRitual(heldItem, player, RitualRegistry.getRitualForId(key))) {
((TileMasterRitualStone) tile).setDirection(direction);
if (state.getValue(getProperty()) == EnumRitualController.INVERTED)
((TileMasterRitualStone) tile).setInverted(true);
}
} else {
player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.notValid"), true);
}
}
} else if (state.getValue(getProperty()) == EnumRitualController.IMPERFECT && tile instanceof TileImperfectRitualStone) {
IBlockState ritualBlock = world.getBlockState(pos.up());
ImperfectRitual ritual = ImperfectRitualRegistry.getRitualForBlock(ritualBlock);
if (ritual == null)
return false;
RitualEvent.ImperfectRitualActivatedEvent event = new RitualEvent.ImperfectRitualActivatedEvent((IImperfectRitualStone) tile, player, ritual);
return !MinecraftForge.EVENT_BUS.post(event) && ((TileImperfectRitualStone) tile).performRitual(world, pos, ritual, player);
}
return false;
}
use of WayofTime.bloodmagic.tile.TileMasterRitualStone in project BloodMagic by WayofTime.
the class ClientHandler method render.
@SubscribeEvent
public static void render(RenderWorldLastEvent event) {
EntityPlayerSP player = minecraft.player;
World world = player.getEntityWorld();
if (mrsHoloTile != null) {
if (world.getTileEntity(mrsHoloTile.getPos()) instanceof TileMasterRitualStone) {
if (mrsHoloDisplay)
renderRitualStones(mrsHoloTile, event.getPartialTicks());
else
ClientHandler.setRitualHoloToNull();
} else {
ClientHandler.setRitualHoloToNull();
}
}
if (minecraft.objectMouseOver == null || minecraft.objectMouseOver.typeOfHit != RayTraceResult.Type.BLOCK)
return;
TileEntity tileEntity = world.getTileEntity(minecraft.objectMouseOver.getBlockPos());
if (tileEntity instanceof TileMasterRitualStone && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner)
renderRitualStones(player, event.getPartialTicks());
}
Aggregations