Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #40 from GTNewHorizons/bees
Browse files Browse the repository at this point in the history
Render bees inside Mega Apiary
  • Loading branch information
kuba6000 authored Dec 29, 2022
2 parents c90a01a + ae53bfb commit d9e5195
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/kubatech/api/enums/ItemList.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public enum ItemList implements IItemContainer {
BruisedTeaLeaf,
PartiallyOxidizedTeaLeaf,
TeaAcceptorResearchNote,
TeaAcceptor;
TeaAcceptor,
Beeeeee;

private ItemStack mStack;
private boolean mHasNotBeenSet = true;
Expand Down
100 changes: 100 additions & 0 deletions src/main/java/kubatech/client/effect/MegaApiaryBeesRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package kubatech.client.effect;

import static net.minecraft.client.renderer.entity.RenderManager.*;

import kubatech.api.enums.ItemList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

public class MegaApiaryBeesRenderer extends EntityFX {
public MegaApiaryBeesRenderer(World world, double x, double y, double z, int age) {
super(world, x, y + 2, z);
this.particleMaxAge = age;
}

@Override
public void onUpdate() {
if (this.particleAge++ == this.particleMaxAge) this.setDead();
if (this.particleAge % 4 == 0)
if (this.particleAge % 8 == 0) this.posY += 0.1;
else this.posY -= 0.1;
}

@Override
public boolean shouldRenderInPass(int pass) {
return pass == 3;
}

@Override
public int getFXLayer() {
return 3;
}

@Override
public void renderParticle(
Tessellator p_70539_1_,
float p_70539_2_,
float p_70539_3_,
float p_70539_4_,
float p_70539_5_,
float p_70539_6_,
float p_70539_7_) {

GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);

GL11.glPushMatrix();
GL11.glTranslatef(
(float) (this.posX - renderPosX), (float) (this.posY - renderPosY), (float) (this.posZ - renderPosZ));
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glRotatef(180f, 1f, 0f, 0f);

Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationItemsTexture);

GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);

GL11.glColor4f(1f, 1f, 1f, 1F);

IIcon icon = ItemList.Beeeeee.get(1).getIconIndex();

GL11.glPushMatrix();
GL11.glTranslatef(0f, 0f, -4f);
GL11.glScalef(0.1f, 0.1f, 0.1f);
RenderItem.getInstance().renderIcon(0, 0, icon, 16, 16);
GL11.glPopMatrix();

GL11.glPushMatrix();
GL11.glTranslatef(1f, 0f, 3f);
GL11.glRotatef(180f, 0f, 1f, 0f);
GL11.glScalef(0.1f, 0.1f, 0.1f);
RenderItem.getInstance().renderIcon(0, 0, icon, 16, 16);
GL11.glPopMatrix();

GL11.glPushMatrix();
GL11.glTranslatef(4f, 0f, -1f);
GL11.glRotatef(-90f, 0f, 1f, 0f);
GL11.glScalef(0.1f, 0.1f, 0.1f);
RenderItem.getInstance().renderIcon(0, 0, icon, 16, 16);
GL11.glPopMatrix();

GL11.glPushMatrix();
GL11.glTranslatef(-3f, 0f, 1f);
GL11.glRotatef(90f, 0f, 1f, 0f);
GL11.glScalef(0.1f, 0.1f, 0.1f);
RenderItem.getInstance().renderIcon(0, 0, icon, 16, 16);
GL11.glPopMatrix();

GL11.glPopMatrix();
}
}
6 changes: 2 additions & 4 deletions src/main/java/kubatech/loaders/ItemLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
import cpw.mods.fml.common.registry.GameRegistry;
import kubatech.loaders.item.ItemProxy;
import kubatech.loaders.item.KubaItems;
import kubatech.loaders.item.items.Tea;
import kubatech.loaders.item.items.TeaCollection;
import kubatech.loaders.item.items.TeaIngredient;
import kubatech.loaders.item.items.TeaUltimate;
import kubatech.loaders.item.items.*;

public class ItemLoader {
public static final KubaItems kubaitems = new KubaItems();
Expand Down Expand Up @@ -79,5 +76,6 @@ public static void registerItems() {

TeaAcceptorResearchNote.set(
kubaitems.registerProxyItem(new ItemProxy("tea_acceptor_research_note", "research_note")));
Beeeeee.set(kubaitems.registerProxyItem(new ItemProxy("beeeeee", "beeeeee")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
import com.gtnewhorizons.modularui.api.widget.Widget;
import com.gtnewhorizons.modularui.common.widget.*;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.*;
import forestry.apiculture.blocks.BlockAlveary;
import forestry.apiculture.blocks.BlockApicultureType;
Expand Down Expand Up @@ -69,6 +71,8 @@
import kubatech.api.helpers.GTHelper;
import kubatech.api.network.CustomTileEntityPacket;
import kubatech.api.tileentity.CustomTileEntityPacketHandler;
import kubatech.client.effect.MegaApiaryBeesRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
Expand Down Expand Up @@ -339,8 +343,23 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
packet.resetHelperData();
packet.addData(mMaxSlots);
packet.sendToAllAround(20);
} else {
if (aBaseMetaTileEntity.isActive() && aTick % 100 == 0) {
int[] abc = new int[] {0, -2, 7};
int[] xyz = new int[] {0, 0, 0};
this.getExtendedFacing().getWorldOffset(abc, xyz);
xyz[0] += aBaseMetaTileEntity.getXCoord();
xyz[1] += aBaseMetaTileEntity.getYCoord();
xyz[2] += aBaseMetaTileEntity.getZCoord();
showBees(aBaseMetaTileEntity.getWorld(), xyz[0], xyz[1], xyz[2], 100);
}
}
// Beeeee rendering inside ?
}

@SideOnly(Side.CLIENT)
private void showBees(World world, int x, int y, int z, int age) {
MegaApiaryBeesRenderer bee = new MegaApiaryBeesRenderer(world, x, y, z, age);
Minecraft.getMinecraft().effectRenderer.addEffect(bee);
}

@Override
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d9e5195

Please sign in to comment.