use of pokefenn.totemic.api.ceremony.Ceremony in project Totemic by TeamTotemic.
the class ModContent method createRegistries.
@SubscribeEvent
public static void createRegistries(RegistryEvent.NewRegistry event) {
// RegistryEvents are fired in alphabetic order.
// Instruments have to be registered before Ceremonies.
new RegistryBuilder<MusicInstrument>().setName(new ResourceLocation(Totemic.MOD_ID, "a_music_instruments")).setType(MusicInstrument.class).setMaxID(Byte.MAX_VALUE).disableSaving().create();
new RegistryBuilder<TotemEffect>().setName(new ResourceLocation(Totemic.MOD_ID, "b_totem_effects")).setType(TotemEffect.class).setMaxID(Byte.MAX_VALUE).disableSaving().create();
new RegistryBuilder<Ceremony>().setName(new ResourceLocation(Totemic.MOD_ID, "c_ceremonies")).setType(Ceremony.class).setMaxID(Byte.MAX_VALUE).disableSaving().create();
}
use of pokefenn.totemic.api.ceremony.Ceremony in project Totemic by TeamTotemic.
the class GameOverlay method renderHUD.
@SubscribeEvent
public void renderHUD(RenderGameOverlayEvent.Post event) {
if (event.getType() != ElementType.ALL)
return;
Minecraft mc = Minecraft.getMinecraft();
mc.mcProfiler.startSection("totemicHUD");
if (activeTotem != null) {
if (activeTotem.isInvalid() || !(activeTotem.getState() instanceof StateStartup || activeTotem.getState() instanceof StateCeremonyEffect))
activeTotem = null;
}
if (activeTotem != null) {
int w = 117;
int h = 30;
double texW = 128;
double texH = 64;
float hudX = (event.getResolution().getScaledWidth() - w) / 2 + ModConfig.client.ceremonyHudPositionX;
float hudY = (event.getResolution().getScaledHeight() - h) / 2 + ModConfig.client.ceremonyHudPositionY;
Tessellator tes = Tessellator.getInstance();
BufferBuilder buf = tes.getBuffer();
FontRenderer font = mc.fontRenderer;
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.pushMatrix();
GlStateManager.translate(hudX, hudY, 0);
// Background
mc.renderEngine.bindTexture(hudTexture);
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
RenderHelper.addQuad(buf, 0, 0, 0, w, h, 0, 0, w / texW, h / texH);
tes.draw();
int barW = 104;
int barH = 7;
if (activeTotem.getState() instanceof StateStartup) {
StateStartup state = (StateStartup) activeTotem.getState();
Ceremony cer = state.getCeremony();
String locName = I18n.format(cer.getUnlocalizedName());
int nameX = (w - font.getStringWidth(locName)) / 2;
font.drawString(locName, nameX, 1, 0xC8000000);
GlStateManager.color(1, 1, 1);
mc.renderEngine.bindTexture(hudTexture);
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
// Note
RenderHelper.addQuad(buf, 1, 10, 0, 9, 9, 16 / texW, 48 / texH, 8 / texW, 8 / texH);
// Clock
RenderHelper.addQuad(buf, 1, 20, 0, 9, 9, 0 / texW, 48 / texH, 16 / texW, 16 / texH);
float musicW = state.getTotalMusic() / (float) cer.getMusicNeeded() * barW;
float timeW = Math.min(state.getTime() / (float) cer.getAdjustedMaxStartupTime(mc.world.getDifficulty()), 1.0f) * barW;
// Music bar
RenderHelper.addQuad(buf, 11, 11, 0, musicW, barH, 0, 32 / texH, musicW / texW, barH / texH);
// Time bar
RenderHelper.addQuad(buf, 11, 21, 0, timeW, barH, 0, 32 / texH, timeW / texW, barH / texH);
tes.draw();
} else if (activeTotem.getState() instanceof StateCeremonyEffect) {
StateCeremonyEffect state = (StateCeremonyEffect) activeTotem.getState();
Ceremony cer = state.getCeremony();
String locName = I18n.format(cer.getUnlocalizedName());
int nameX = (w - font.getStringWidth(locName)) / 2;
font.drawString(locName, nameX, 1, 0xC8000000);
}
GlStateManager.popMatrix();
GL11.glPopAttrib();
}
mc.mcProfiler.endSection();
}
use of pokefenn.totemic.api.ceremony.Ceremony in project Totemic by TeamTotemic.
the class BlockTotemBase method onTotemicStaffRightClick.
@Override
public EnumActionResult onTotemicStaffRightClick(World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!world.isRemote)
return EnumActionResult.SUCCESS;
TileTotemBase tile = (TileTotemBase) world.getTileEntity(pos);
if (tile.getState() instanceof StateTotemEffect) {
player.sendStatusMessage(new TextComponentTranslation("totemicmisc.isDoingNoCeremony"), true);
} else if (tile.getState() instanceof StateSelection) {
String selectors = ((StateSelection) tile.getState()).getSelectors().stream().map(instr -> I18n.format(instr.getUnlocalizedName())).collect(Collectors.joining(", "));
player.sendStatusMessage(new TextComponentTranslation("totemicmisc.isDoingSelection"), false);
player.sendStatusMessage(new TextComponentTranslation("totemicmisc.selection", selectors), false);
} else if (tile.getState() instanceof StateStartup) {
Ceremony ceremony = ((StateStartup) tile.getState()).getCeremony();
player.sendStatusMessage(new TextComponentTranslation("totemicmisc.isDoingStartup"), false);
player.sendStatusMessage(new TextComponentTranslation(ceremony.getUnlocalizedName()), false);
} else if (tile.getState() instanceof StateCeremonyEffect) {
Ceremony ceremony = ((StateCeremonyEffect) tile.getState()).getCeremony();
player.sendStatusMessage(new TextComponentTranslation("totemicmisc.isDoingCeremony"), false);
player.sendStatusMessage(new TextComponentTranslation(ceremony.getUnlocalizedName()), false);
}
return EnumActionResult.SUCCESS;
}
use of pokefenn.totemic.api.ceremony.Ceremony in project Totemic by TeamTotemic.
the class CeremonyTrigger method deserializeInstance.
@Override
public Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) {
String name = JsonUtils.getString(json, "ceremony");
Ceremony ceremony = TotemicRegistries.ceremonies().getValue(new ResourceLocation(name));
if (ceremony == null)
throw new JsonSyntaxException("Unknown ceremony: '" + name + "'");
else
return new Instance(ceremony);
}
use of pokefenn.totemic.api.ceremony.Ceremony in project Totemic by TeamTotemic.
the class StateSelection method addSelector.
@Override
void addSelector(@Nullable Entity entity, MusicInstrument instr) {
BlockPos pos = tile.getPos();
WorldServer world = (WorldServer) tile.getWorld();
world.spawnParticle(EnumParticleTypes.NOTE, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 6, 0.5, 0.5, 0.5, 0.0);
selectors.add(instr);
time = 0;
tile.markDirty();
if (selectors.size() >= Ceremony.MIN_SELECTORS) {
Optional<Ceremony> match = Streams.stream(TotemicRegistries.ceremonies()).filter(this::selectorsMatch).findAny();
if (match.isPresent() && match.get().canSelect(world, pos)) {
world.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 16, 0.7D, 0.5D, 0.7D, 0.0D);
tile.setState(new StateStartup(tile, initiator, match.get()));
} else if (// No match found - only reset if the maximum number of selectors is reached
selectors.size() >= ACTUAL_MAX_SELECTORS) {
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 16, 0.6D, 0.5D, 0.6D, 0.0D);
tile.setState(new StateTotemEffect(tile));
}
}
}
Aggregations