-
Notifications
You must be signed in to change notification settings - Fork 9
Port Ender Collector #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9774e1f
1770c80
1f42ab5
292ea60
c294ad7
b91f5d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| import com.fouristhenumber.utilitiesinexcess.common.renderers.BlackoutCurtainsRenderer; | ||
| import com.fouristhenumber.utilitiesinexcess.common.renderers.LapisAetheriusRenderer; | ||
| import com.fouristhenumber.utilitiesinexcess.common.renderers.SpikeRenderer; | ||
| import com.fouristhenumber.utilitiesinexcess.common.tileentities.*; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing here |
||
| import com.fouristhenumber.utilitiesinexcess.common.tileentities.TileEntityBlockUpdateDetector; | ||
| import com.fouristhenumber.utilitiesinexcess.common.tileentities.TileEntityConveyor; | ||
| import com.fouristhenumber.utilitiesinexcess.common.tileentities.TileEntityDrum; | ||
|
|
@@ -81,7 +82,6 @@ public void preInit(FMLPreInitializationEvent event) { | |
| @Mod.EventHandler | ||
| public void init(FMLInitializationEvent event) { | ||
| proxy.init(event); | ||
|
|
||
| RecipeLoader.run(); | ||
|
|
||
| MinecraftForge.EVENT_BUS.register(new ForgeEventHandler()); | ||
|
|
@@ -102,6 +102,7 @@ public void init(FMLInitializationEvent event) { | |
| GameRegistry.registerTileEntity(TileEntityBlockUpdateDetector.class, "TileEntityBlockUpdateDetector"); | ||
| GameRegistry.registerTileEntity(TileEntityConveyor.class, "TileEntityConveyor"); | ||
| GameRegistry.registerTileEntity(TileEntityPortalUnderWorld.class, "TileEntityPortalUnderWorld"); | ||
| GameRegistry.registerTileEntity(TileEntityCollector.class, "TileEntityCollector"); | ||
|
|
||
| GameRegistry.registerTileEntity( | ||
| TileEntityLowTemperatureFurnaceGenerator.class, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.common.blocks; | ||
|
|
||
| import net.minecraft.block.BlockContainer; | ||
| import net.minecraft.block.material.Material; | ||
| import net.minecraft.entity.player.EntityPlayer; | ||
| import net.minecraft.tileentity.TileEntity; | ||
| import net.minecraft.world.World; | ||
|
|
||
| import com.fouristhenumber.utilitiesinexcess.common.tileentities.TileEntityCollector; | ||
|
|
||
| public class BlockCollector extends BlockContainer { | ||
|
|
||
| public BlockCollector() { | ||
| super(Material.rock); | ||
| setBlockName("Collector"); | ||
| } | ||
|
|
||
| @Override | ||
| public TileEntity createNewTileEntity(World worldIn, int meta) { | ||
| return new TileEntityCollector(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, | ||
| float subY, float subZ) { | ||
| TileEntity tile = worldIn.getTileEntity(x, y, z); | ||
| if (!(tile instanceof TileEntityCollector)) { | ||
| return true; | ||
| } | ||
| TileEntityCollector collector = (TileEntityCollector) tile; | ||
|
|
||
| collector.incrementSize(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe incrementing size initially just displays the border and then sequential activation of the TE grow the border (given the display is active) also a little bit of a feature req in shift-click decrementing the size, if its not a pain |
||
| collector.showBorderFor(20); | ||
| worldIn.markBlockForUpdate(x, y, z); | ||
|
|
||
| return true; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.common.tileentities; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import net.minecraft.entity.item.EntityItem; | ||
| import net.minecraft.inventory.IInventory; | ||
| import net.minecraft.item.ItemStack; | ||
| import net.minecraft.tileentity.TileEntity; | ||
| import net.minecraft.util.AxisAlignedBB; | ||
| import net.minecraft.util.Vec3; | ||
| import net.minecraftforge.common.util.ForgeDirection; | ||
|
|
||
| import com.gtnewhorizon.gtnhlib.capability.item.ItemSink; | ||
| import com.gtnewhorizon.gtnhlib.item.InsertionItemStack; | ||
| import com.gtnewhorizon.gtnhlib.util.ItemUtil; | ||
|
|
||
| public class TileEntityCollector extends TileEntity { | ||
|
|
||
| public boolean showBorder = false; | ||
| public int borderTimer = 0; | ||
| public List<Vec3> itemPositions = new ArrayList<>(); | ||
| private float size = 6f; | ||
|
|
||
| public float getSize() { | ||
| return size; | ||
| } | ||
|
|
||
| public void incrementSize() { | ||
| size++; | ||
| if (size > 9) size = 1; | ||
| } | ||
|
|
||
| public void showBorderFor(int ticks) { | ||
| this.showBorder = true; | ||
| this.borderTimer = ticks; | ||
| } | ||
|
|
||
| @Override | ||
| public void updateEntity() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method could be divided. @Override
public void updateEntity() {
AxisAlignedBB area = getRadiusAABB();
if (worldObj.isRemote) {
updateClientEffects(area);
return;
}
updateServerItemInsertion(area);
}
private void updateClientEffects(AxisAlignedBB area) {
if (borderTimer > 0 && --borderTimer <= 0) {
showBorder = false;
}
itemPositions.clear();
for (EntityItem item :
worldObj.getEntitiesWithinAABB(EntityItem.class, area)) {
if (item.isDead || !item.onGround) {
continue;
}
itemPositions.add(
Vec3.createVectorHelper(
item.posX,
item.posY + 0.25,
item.posZ
)
);
}
}
private void updateServerItemInsertion(AxisAlignedBB area) {
TileEntity te = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
if (!(te instanceof IInventory chest)) {
return;
}
ItemSink sink = ItemUtil.getItemSink(chest, ForgeDirection.UP);
if (sink == null) {
return;
}
for (EntityItem item :
worldObj.getEntitiesWithinAABB(EntityItem.class, area)) {
if (item.isDead || !item.onGround || item.delayBeforeCanPickup > 0) {
continue;
}
ItemStack stack = item.getEntityItem();
if (stack == null) {
continue;
}
int leftover = sink.store(new InsertionItemStack(stack));
if (leftover <= 0) {
item.setDead();
} else {
stack.stackSize = leftover;
}
}
} |
||
|
|
||
| if (worldObj.isRemote) { | ||
| if (borderTimer > 0) { | ||
| borderTimer--; | ||
| if (borderTimer <= 0) showBorder = false; | ||
| } | ||
|
|
||
| itemPositions.clear(); | ||
| List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, getRadiusAABB()); | ||
| for (EntityItem item : items) { | ||
| if (!item.isDead && item.onGround) { | ||
| itemPositions.add(Vec3.createVectorHelper(item.posX, item.posY + 0.25, item.posZ)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (!worldObj.isRemote) { | ||
| List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, getRadiusAABB()); | ||
| TileEntity chest = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); | ||
| if (!(chest instanceof IInventory)) return; | ||
|
|
||
| for (EntityItem item : items) { | ||
| if (item.isDead || !item.onGround || item.delayBeforeCanPickup > 0) continue; | ||
|
|
||
| ItemStack stackInsert = item.getEntityItem(); | ||
| if (stackInsert == null) continue; | ||
|
|
||
| ItemSink sink = ItemUtil.getItemSink(chest, ForgeDirection.UP); | ||
| if (sink != null) { | ||
| int leftover = sink.store(new InsertionItemStack(stackInsert)); | ||
| if (leftover <= 0) item.setDead(); | ||
| else stackInsert.stackSize = leftover; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private AxisAlignedBB getRadiusAABB() { | ||
| return AxisAlignedBB.getBoundingBox( | ||
| xCoord - size, | ||
| yCoord - size, | ||
| zCoord - size, | ||
| xCoord + size + 1, | ||
| yCoord + size + 1, | ||
| zCoord + size + 1); | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: i think this name can be more specific. it doesn't just draw a line. it draws the box and lines(plural)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah agreed, it was originally just going to draw the line but it evolved and the name never changed 🙃 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.render; | ||
|
|
||
| import java.util.Iterator; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.Map; | ||
|
|
||
| import net.minecraft.client.renderer.OpenGlHelper; | ||
| import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; | ||
| import net.minecraft.tileentity.TileEntity; | ||
| import net.minecraft.util.Vec3; | ||
|
|
||
| import org.lwjgl.opengl.GL11; | ||
|
|
||
| import com.fouristhenumber.utilitiesinexcess.common.tileentities.TileEntityCollector; | ||
|
|
||
| public class CollectorLine extends TileEntitySpecialRenderer { | ||
|
|
||
| private final Map<Vec3, Integer> lines = new LinkedHashMap<>(); | ||
|
|
||
| @Override | ||
| public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks) { | ||
| if (!(te instanceof TileEntityCollector collector)) return; | ||
|
|
||
| if (collector.itemPositions != null) { | ||
| for (Vec3 pos : collector.itemPositions) { | ||
| lines.put(pos, 20); | ||
| } | ||
| } | ||
|
|
||
| // WHATEVER GO MY OPENGL STATE FLAGS | ||
| // how to write open gl a fundamental guide \/ | ||
| GL11.glPushMatrix(); | ||
| GL11.glDisable(GL11.GL_LIGHTING); | ||
| GL11.glDisable(GL11.GL_TEXTURE_2D); | ||
| GL11.glEnable(GL11.GL_BLEND); | ||
| GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); | ||
| GL11.glEnable(GL11.GL_LINE_SMOOTH); | ||
| GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); | ||
| GL11.glLineWidth(6.0f); | ||
| GL11.glTranslated(x, y, z); | ||
|
|
||
| // force fullbright (fun fact this is what night vision does so i didn't realize that this needed to be set | ||
| // UNTIL AFTER IT WORE OFF) | ||
| OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); | ||
|
|
||
| GL11.glBegin(GL11.GL_LINES); | ||
| Iterator<Map.Entry<Vec3, Integer>> it = lines.entrySet() | ||
| .iterator(); | ||
| while (it.hasNext()) { | ||
| Map.Entry<Vec3, Integer> entry = it.next(); | ||
| Vec3 target = entry.getKey(); | ||
| int life = entry.getValue(); | ||
|
|
||
| float alpha = Math.max(0f, life / 20.0f); | ||
| GL11.glColor4f(1.0f, 0f, 0f, alpha); | ||
|
|
||
| double dx = target.xCoord - (te.xCoord); | ||
| double dy = target.yCoord - (te.yCoord); | ||
| double dz = target.zCoord - (te.zCoord); | ||
|
|
||
| GL11.glVertex3d(.5, .5, .5); | ||
| GL11.glVertex3d(dx, dy, dz); | ||
|
|
||
| entry.setValue(life - 1); | ||
| if (life <= 0) it.remove(); | ||
| } | ||
| GL11.glEnd(); | ||
|
|
||
| if (collector.showBorder) { | ||
| float r = collector.getSize(); | ||
| GL11.glLineWidth(3.0f); | ||
| GL11.glBegin(GL11.GL_LINES); | ||
|
|
||
| double[][] edges = { { -r, -r, -r }, { r + 1, -r, -r }, { -r, -r, -r }, { -r, r + 1, -r }, { -r, -r, -r }, | ||
| { -r, -r, r + 1 }, { r + 1, r + 1, r + 1 }, { -r, r + 1, r + 1 }, { r + 1, r + 1, r + 1 }, | ||
| { r + 1, -r, r + 1 }, { r + 1, r + 1, r + 1 }, { r + 1, r + 1, -r }, { r + 1, -r, -r }, | ||
| { r + 1, r + 1, -r }, { r + 1, -r, -r }, { r + 1, -r, r + 1 }, { -r, r + 1, -r }, { -r, r + 1, r + 1 }, | ||
| { -r, r + 1, -r }, { r + 1, r + 1, -r }, { -r, -r, r + 1 }, { r + 1, -r, r + 1 }, { -r, -r, r + 1 }, | ||
| { -r, r + 1, r + 1 } }; | ||
|
|
||
| long time = System.currentTimeMillis(); | ||
| for (int i = 0; i < edges.length; i += 2) { | ||
| // wainbow :3 | ||
| float hue = (float) ((time * 0.001 + i * 0.1) % 1.0); | ||
| float[] rgb = java.awt.Color.getHSBColor(hue, 1.0f, 1.0f) | ||
| .getRGBColorComponents(null); | ||
| GL11.glColor4f(rgb[0], rgb[1], rgb[2], 0.8f); | ||
|
|
||
| GL11.glVertex3d(edges[i][0], edges[i][1], edges[i][2]); | ||
| GL11.glVertex3d(edges[i + 1][0], edges[i + 1][1], edges[i + 1][2]); | ||
| } | ||
|
|
||
| GL11.glEnd(); | ||
| } | ||
|
|
||
| GL11.glDisable(GL11.GL_LINE_SMOOTH); | ||
| GL11.glDisable(GL11.GL_BLEND); | ||
| GL11.glEnable(GL11.GL_TEXTURE_2D); | ||
| GL11.glEnable(GL11.GL_LIGHTING); | ||
| GL11.glPopMatrix(); | ||
|
|
||
| // clear only new item positions | ||
| if (collector.itemPositions != null) collector.itemPositions.clear(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no star imports (change ur intellij settings?)