fix: some storage monitor related bugs
This commit is contained in:
parent
dea4766634
commit
9295a3a543
|
@ -2,3 +2,5 @@
|
|||
- transition plane doesn't collect items
|
||||
- legacy controller doesn't correctly render energy bar
|
||||
- legacy blocks aren't colorable
|
||||
- storage monitor doesn't update when rotated
|
||||
- storage monitor doesn't display if it's upgraded
|
||||
|
|
|
@ -9,6 +9,7 @@ import appeng.core.Api;
|
|||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.legacy.TileStorageMonitor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -42,13 +43,19 @@ public class BlockStorageMonitor extends BlockLegacyDisplay {
|
|||
TileStorageMonitor tile = (TileStorageMonitor) w.getTileEntity(x, y, z);
|
||||
|
||||
if (player.getHeldItem() != null) {
|
||||
if (Platform.isWrench(player, player.getHeldItem(), x, y, z)
|
||||
&& player.isSneaking()) {
|
||||
tile.isLocked = !tile.isLocked;
|
||||
tile.markForUpdate();
|
||||
return true;
|
||||
}
|
||||
if (player.getHeldItem().getItem()
|
||||
== Api.INSTANCE.definitions()
|
||||
.materials()
|
||||
.conversionMatrix()
|
||||
.maybeItem()
|
||||
.get()
|
||||
&& player.isSneaking() && !tile.upgraded) {
|
||||
&& !tile.upgraded && player.isSneaking()) {
|
||||
if (!w.isRemote) {
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
tile.upgraded = true;
|
||||
|
@ -59,15 +66,16 @@ public class BlockStorageMonitor extends BlockLegacyDisplay {
|
|||
if (!w.isRemote) {
|
||||
tile.myItem = AEItemStack.create(new ItemStack(
|
||||
player.getHeldItem().getItem(),
|
||||
1,
|
||||
0,
|
||||
player.getHeldItem().getItemDamage()
|
||||
));
|
||||
tile.configureWatchers();
|
||||
tile.markForUpdate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return super.onBlockActivated(w, x, y, z, player, side, hitX, hitY, hitZ);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,12 +76,12 @@ public class RenderBlockStorageMonitor extends RenderBlockLegacyDisplay {
|
|||
case UP:
|
||||
GL11.glScalef(1.0f, -1.0f, 1.0f);
|
||||
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glRotatef(tile.getUp().ordinal() * 90.0F, 0, 0, 1);
|
||||
GL11.glRotatef((tile.getUp().ordinal() - 2) * 90.0F, 0, 0, 1);
|
||||
break;
|
||||
case DOWN:
|
||||
GL11.glScalef(1.0f, -1.0f, 1.0f);
|
||||
GL11.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glRotatef(tile.getUp().ordinal() * -90.0F, 0, 0, 1);
|
||||
GL11.glRotatef((tile.getUp().ordinal() - 2) * -90.0F, 0, 0, 1);
|
||||
break;
|
||||
case EAST:
|
||||
GL11.glScalef(-1.0f, -1.0f, -1.0f);
|
||||
|
|
|
@ -4,7 +4,14 @@ import java.io.IOException;
|
|||
import java.util.EnumSet;
|
||||
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IStackWatcher;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
@ -12,12 +19,14 @@ import io.netty.buffer.ByteBuf;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileStorageMonitor extends TileLegacyDisplay {
|
||||
public class TileStorageMonitor extends TileLegacyDisplay implements IStackWatcherHost {
|
||||
public boolean isLocked;
|
||||
public boolean upgraded;
|
||||
public IAEItemStack myItem;
|
||||
public boolean updateDisplayList;
|
||||
|
||||
private IStackWatcher watcher;
|
||||
|
||||
public TileStorageMonitor() {
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
this.getProxy().setIdlePowerUsage(0.5);
|
||||
|
@ -87,4 +96,54 @@ public class TileStorageMonitor extends TileLegacyDisplay {
|
|||
this.myItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void configureWatchers() {
|
||||
if (this.watcher == null)
|
||||
return;
|
||||
|
||||
this.watcher.clear();
|
||||
|
||||
if (this.myItem != null) {
|
||||
this.watcher.add(this.myItem);
|
||||
|
||||
try {
|
||||
IAEItemStack meitem = this.getProxy()
|
||||
.getStorage()
|
||||
.getItemInventory()
|
||||
.getStorageList()
|
||||
.findPrecise(this.myItem);
|
||||
|
||||
this.myItem.setStackSize(meitem == null ? 0 : meitem.getStackSize());
|
||||
} catch (GridAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWatcher(IStackWatcher newWatcher) {
|
||||
this.watcher = newWatcher;
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStackChange(
|
||||
IItemList o,
|
||||
IAEStack fullStack,
|
||||
IAEStack diffStack,
|
||||
BaseActionSource src,
|
||||
StorageChannel chan
|
||||
) {
|
||||
if (this.myItem == null)
|
||||
return;
|
||||
|
||||
if (fullStack == null) {
|
||||
this.myItem.setStackSize(0);
|
||||
} else {
|
||||
this.myItem.setStackSize(fullStack.getStackSize());
|
||||
}
|
||||
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue