use of lumien.randomthings.entitys.EntityArtificialEndPortal in project Random-Things by lumien231.
the class RenderArtificialEndPortal method doRender.
@Override
public void doRender(Entity entity, double x, double y, double z, float entityYaw, float partialTicks) {
EntityArtificialEndPortal portal = (EntityArtificialEndPortal) entity;
double size = Math.min(3, 3f / 115 * (portal.actionTimer + partialTicks - 85));
if (portal.actionTimer > 85) {
GlStateManager.disableLighting();
RANDOM.setSeed(31100L);
GlStateManager.getFloat(2982, MODELVIEW);
GlStateManager.getFloat(2983, PROJECTION);
double d0 = x * x + y * y + z * z;
int i = this.getPasses(d0);
float f = this.getOffset();
boolean flag = false;
for (int j = 0; j < i; ++j) {
GlStateManager.pushMatrix();
float f1 = 2.0F / (float) (18 - j);
if (j == 0) {
this.bindTexture(END_SKY_TEXTURE);
f1 = 0.15F;
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
}
if (j >= 1) {
this.bindTexture(END_PORTAL_TEXTURE);
flag = true;
Minecraft.getMinecraft().entityRenderer.setupFogColor(true);
}
if (j == 1) {
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
}
GlStateManager.texGen(GlStateManager.TexGen.S, 9216);
GlStateManager.texGen(GlStateManager.TexGen.T, 9216);
GlStateManager.texGen(GlStateManager.TexGen.R, 9216);
GlStateManager.texGen(GlStateManager.TexGen.S, 9474, this.getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, 9474, this.getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.R, 9474, this.getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.R);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.translate(0.5F, 0.5F, 0.0F);
GlStateManager.scale(0.5F, 0.5F, 1.0F);
float f2 = (float) (j + 1);
GlStateManager.translate(17.0F / f2, (2.0F + f2 / 1.5F) * ((float) Minecraft.getSystemTime() % 800000.0F / 800000.0F), 0.0F);
GlStateManager.rotate((f2 * f2 * 4321.0F + f2 * 9.0F) * 2.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.scale(4.5F - f2 / 4.0F, 4.5F - f2 / 4.0F, 1.0F);
GlStateManager.multMatrix(PROJECTION);
GlStateManager.multMatrix(MODELVIEW);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
float f3 = (RANDOM.nextFloat() * 0.5F + 0.1F) * f1;
float f4 = (RANDOM.nextFloat() * 0.5F + 0.4F) * f1;
float f5 = (RANDOM.nextFloat() * 0.5F + 0.5F) * f1;
double size_half = size / 2;
bufferbuilder.pos(x - size_half, y + (double) f, z + size_half).color(f3, f4, f5, 1.0F).endVertex();
bufferbuilder.pos(x + size_half, y + (double) f, z + size_half).color(f3, f4, f5, 1.0F).endVertex();
bufferbuilder.pos(x + size_half, y + (double) f, z - size_half).color(f3, f4, f5, 1.0F).endVertex();
bufferbuilder.pos(x - size_half, y + (double) f, z - size_half).color(f3, f4, f5, 1.0F).endVertex();
tessellator.draw();
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
this.bindTexture(END_SKY_TEXTURE);
}
GlStateManager.disableBlend();
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R);
GlStateManager.enableLighting();
if (flag) {
Minecraft.getMinecraft().entityRenderer.setupFogColor(false);
}
}
}
use of lumien.randomthings.entitys.EntityArtificialEndPortal in project Random-Things by lumien231.
the class ItemIngredient method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(hand);
if (getIngredient(stack) == INGREDIENT.ECTO_PLASM) {
IBlockState state = worldIn.getBlockState(pos);
int saplingID = OreDictionary.getOreID("treeSapling");
if (state.getBlock() != ModBlocks.spectreSapling) {
for (int id : OreDictionary.getOreIDs(new ItemStack(state.getBlock()))) {
if (id == saplingID) {
if (!worldIn.isRemote) {
stack.shrink(1);
worldIn.setBlockState(pos, ModBlocks.spectreSapling.getDefaultState());
}
return EnumActionResult.SUCCESS;
}
}
}
} else if (getIngredient(stack) == INGREDIENT.EVIL_TEAR && Features.ARTIFICIAL_END_PORTAL) {
IBlockState state = worldIn.getBlockState(pos);
if (state.getBlock() == Blocks.END_ROD) {
if (EntityArtificialEndPortal.isValidPosition(worldIn, pos.down(3), true)) {
if (!worldIn.isRemote) {
BlockPos portalCenter = pos.down(3);
worldIn.spawnEntity(new EntityArtificialEndPortal(worldIn, portalCenter.getX() + 0.5, portalCenter.getY(), portalCenter.getZ() + 0.5));
stack.shrink(1);
}
return EnumActionResult.SUCCESS;
}
}
}
return EnumActionResult.PASS;
}
Aggregations