Skip to content

Commit

Permalink
Follow up the main repositories (#6)
Browse files Browse the repository at this point in the history
* update

* update

* Cell microscope additions (GTNewHorizons#64)

* Add the ability for the cell microscope to scan ME drives and ME Chests.

* Moved inventory render of cell microscope to the left slightly.

* spotless

* Fix outdated import issue.

---------

Co-authored-by: Kyium <[email protected]>
Co-authored-by: GTNH-Colen <[email protected]>

* update

---------

Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Kyium <[email protected]>
Co-authored-by: Kyium <[email protected]>
Co-authored-by: GTNH-Colen <[email protected]>
  • Loading branch information
5 people authored Jun 22, 2024
1 parent 2937b6d commit 9fb5d42
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 44 deletions.
10 changes: 5 additions & 5 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Add your dependencies here

dependencies {
implementation("com.github.GTNewHorizons:NotEnoughItems:2.5.24-GTNH:dev")
implementation("com.github.GTNewHorizons:NotEnoughItems:2.6.0-GTNH:dev")
implementation("com.github.GTNewHorizons:CodeChickenLib:1.2.1:dev")
implementation("com.github.GTNewHorizons:CodeChickenCore:1.2.1:dev")
implementation("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-342-GTNH:dev")
implementation("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-400-GTNH:dev")
implementation("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
implementation("curse.maven:thaumcraft-nei-plugin-225095:2241913") { transitive = false }

compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:AE2FluidCraft-Rework:1.2.21-gtnh:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:waila:1.7.1:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.106:dev") { transitive = false }
compileOnly('com.github.GTNewHorizons:AE2FluidCraft-Rework:1.3.0-gtnh:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:waila:1.7.3:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.46.16:dev") { transitive = false }
compileOnly("curse.maven:computercraft-67504:2269339") { transitive = false }
compileOnly("curse.maven:cofh-lib-220333:2388748") { transitive = false }
compileOnly("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev") { transitive = false }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.21'

id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'

}


Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glRotatef(90.0F, -1.0F, 0.0F, 0.0F);
GL11.glRotatef(30.0F, 0.0F, 0.0F, -1.0F);
} else if (type == ItemRenderType.INVENTORY) {
GL11.glTranslatef(0.5F, 0.2F, 0F);
GL11.glScalef(2.5F, 2.5F, 2.5F);
GL11.glRotatef(60.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(30.0F, 0.0F, 0.0F, -1.0F);
Expand Down
110 changes: 72 additions & 38 deletions src/main/java/thaumicenergistics/common/items/ItemCellMicroscope.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package thaumicenergistics.common.items;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

import appeng.api.AEApi;
import appeng.api.storage.ICellContainer;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
Expand All @@ -33,7 +41,8 @@ public ItemCellMicroscope() {
super();
}

ItemStack startCell = null;
List<ItemStack> startCells = new ArrayList<ItemStack>();
TileEntity cellSaveManager = null;

@SideOnly(Side.CLIENT)
@Override
Expand All @@ -59,9 +68,9 @@ public int getMaxItemUseDuration(ItemStack itemstack) {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer p) {
if (world.isRemote) {
ItemStack cell = this.doScan(stack, world, p, 0);
if (cell != null) {
this.startCell = cell;
ArrayList<ItemStack> cells = this.doScan(stack, world, p, 0);
if (cells.size() != 0) {
this.startCells = cells;
}
}

Expand All @@ -71,34 +80,18 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer p)

@Override
public void onUsingTick(ItemStack stack, EntityPlayer p, int count) {
if (p.worldObj.isRemote
&& p.getCommandSenderName() == Minecraft.getMinecraft().thePlayer.getCommandSenderName()) {
if (p.worldObj.isRemote && Objects
.equals(p.getCommandSenderName(), Minecraft.getMinecraft().thePlayer.getCommandSenderName())) {

ItemStack cell = this.doScan(stack, p.worldObj, p, count);
ArrayList<ItemStack> cells = this.doScan(stack, p.worldObj, p, count);

if (cell != null && cell.equals(this.startCell)) {
if (cells.size() != 0 && cells.equals(this.startCells)) {

if (count <= 5) {
this.startCell = null;
p.stopUsingItem();

IMEInventory<IAEItemStack> inv = AEApi.instance().registries().cell()
.getCellInventory(cell, null, StorageChannel.ITEMS);
IItemList<IAEItemStack> itemList = inv
.getAvailableItems(AEApi.instance().storage().createItemList());

for (final IAEItemStack i : itemList) {
ScanResult sr = new ScanResult(
(byte) 1,
Item.getIdFromItem(i.getItem()),
i.getItemDamage(),
(Entity) null,
"");
if (ScanManager.isValidScanTarget(p, sr, "@")) {

ScanManager.completeScan(p, sr, "@");
PacketHandler.INSTANCE.sendToServer(new PacketScannedToServer(sr, p, "@"));
}
this.startCells.clear();
for (ItemStack cell : cells) {
doCellScan(p, cell);
}
}

Expand All @@ -113,14 +106,30 @@ public void onUsingTick(ItemStack stack, EntityPlayer p, int count) {
false);
}
} else {
this.startCell = null;
this.startCells.clear();
}
}

}

private ItemStack doScan(ItemStack stack, World world, EntityPlayer p, int count) {
private void doCellScan(EntityPlayer p, ItemStack cell) {
IMEInventory<IAEItemStack> inv = AEApi.instance().registries().cell()
.getCellInventory(cell, (ISaveProvider) cellSaveManager, StorageChannel.ITEMS);
IItemList<IAEItemStack> itemList = inv.getAvailableItems(AEApi.instance().storage().createItemList());

for (final IAEItemStack i : itemList) {
ScanResult sr = new ScanResult((byte) 1, Item.getIdFromItem(i.getItem()), i.getItemDamage(), null, "");
if (ScanManager.isValidScanTarget(p, sr, "@")) {

ScanManager.completeScan(p, sr, "@");
PacketHandler.INSTANCE.sendToServer(new PacketScannedToServer(sr, p, "@"));
}
}
}

private ArrayList<ItemStack> doScan(ItemStack stack, World world, EntityPlayer p, int count) {

ArrayList<ItemStack> cellsOutput = new ArrayList<>();
Entity pointedEntity = EntityUtils.getPointedEntity(p.worldObj, p, 0.5D, 10.0D, 0.0F, true);

if (pointedEntity != null) {
Expand All @@ -130,29 +139,54 @@ private ItemStack doScan(ItemStack stack, World world, EntityPlayer p, int count
try {
Thaumcraft.proxy.blockRunes(
world,
(double) mop.blockX,
mop.blockX,
(double) mop.blockY + 0.50D,
(double) mop.blockZ,
mop.blockZ,
0.3F,
0.3F,
0.7F + world.rand.nextFloat() * 0.7F,
15,
-0.03F);
} catch (Exception e) {}

ItemStack cell = (((EntityItem) pointedEntity).getEntityItem());
return cell;
} catch (Exception ignored) {}
cellSaveManager = null;
cellsOutput.add(((EntityItem) pointedEntity).getEntityItem());
return cellsOutput;
}
}
}

return null;

MovingObjectPosition lookingAtBlock = Minecraft.getMinecraft().objectMouseOver;
TileEntity blockAtPos = world
.getTileEntity(lookingAtBlock.blockX, lookingAtBlock.blockY, lookingAtBlock.blockZ);
if (blockAtPos instanceof ICellContainer) {
((ICellContainer) blockAtPos).getCellArray(StorageChannel.ITEMS);
IInventory inv = (IInventory) blockAtPos;
cellSaveManager = blockAtPos;
try {
Thaumcraft.proxy.blockRunes(
world,
lookingAtBlock.blockX,
lookingAtBlock.blockY,
lookingAtBlock.blockZ,
0.3F,
0.3F,
0.7F + world.rand.nextFloat() * 0.7F,
15,
-0.03F);
} catch (Exception ignored) {}
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack itemStack = inv.getStackInSlot(i);
if (itemStack != null) {
cellsOutput.add(itemStack);
}
}
}
return cellsOutput;
}

public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer,
int par4) {
super.onPlayerStoppedUsing(par1ItemStack, par2World, par3EntityPlayer, par4);
this.startCell = null;
this.startCells.clear();
}
}

0 comments on commit 9fb5d42

Please sign in to comment.