More moves and compilation fixes
This commit is contained in:
@@ -29,7 +29,7 @@ import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -474,9 +474,9 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
AEItemStack.fromItemStack(this.inputInventory.getInvStack(0)), this.mySrc);
|
||||
|
||||
if (returns == null) {
|
||||
this.inputInventory.setStackInSlot(0, ItemStack.EMPTY);
|
||||
this.inputInventory.setInvStack(0, ItemStack.EMPTY);
|
||||
} else {
|
||||
this.inputInventory.setStackInSlot(0, returns.createItemStack());
|
||||
this.inputInventory.setInvStack(0, returns.createItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -714,7 +714,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidVolume getFluid() {
|
||||
return FluidVolume.EMPTY;
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -740,7 +740,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidVolume getFluidInTank(int tank) {
|
||||
return FluidVolume.EMPTY;
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -773,13 +773,13 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidVolume drain(FluidVolume resource, FluidAction action) {
|
||||
return FluidVolume.EMPTY;
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidVolume drain(int maxDrain, FluidAction action) {
|
||||
return FluidVolume.EMPTY;
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ public class ChestBlockEntity extends AENetworkPowerBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType() {
|
||||
public ScreenHandlerType<?> getContainerType() {
|
||||
this.updateHandler();
|
||||
if (this.cellHandler != null) {
|
||||
if (this.cellHandler.getChannel() == AEApi.instance().storage()
|
||||
|
||||
@@ -26,13 +26,12 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -335,7 +334,7 @@ public class DriveBlockEntity extends AENetworkInvBlockEntity implements IChestO
|
||||
|
||||
double power = 2.0;
|
||||
|
||||
for (int x = 0; x < this.inv.getSlots(); x++) {
|
||||
for (int x = 0; x < this.inv.getSlotCount(); x++) {
|
||||
final ItemStack is = this.inv.getInvStack(x);
|
||||
this.invBySlot[x] = null;
|
||||
this.handlersBySlot[x] = null;
|
||||
@@ -444,7 +443,7 @@ public class DriveBlockEntity extends AENetworkInvBlockEntity implements IChestO
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType() {
|
||||
public ScreenHandlerType<?> getContainerType() {
|
||||
return DriveContainer.TYPE;
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ public class IOPortBlockEntity extends AENetworkInvBlockEntity
|
||||
private boolean moveSlot(final int x) {
|
||||
final InventoryAdaptor ad = new AdaptorFixedInv(this.outputCells);
|
||||
if (ad.addItems(this.inputCells.getInvStack(x)).isEmpty()) {
|
||||
this.inputCells.setStackInSlot(x, ItemStack.EMPTY);
|
||||
this.inputCells.setInvStack(x, ItemStack.EMPTY);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -437,7 +437,7 @@ public class IOPortBlockEntity extends AENetworkInvBlockEntity
|
||||
public void getDrops(final World w, final BlockPos pos, final List<ItemStack> drops) {
|
||||
super.getDrops(w, pos, drops);
|
||||
|
||||
for (int upgradeIndex = 0; upgradeIndex < this.upgrades.getSlots(); upgradeIndex++) {
|
||||
for (int upgradeIndex = 0; upgradeIndex < this.upgrades.getSlotCount(); upgradeIndex++) {
|
||||
final ItemStack stackInSlot = this.upgrades.getInvStack(upgradeIndex);
|
||||
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.tile.storage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.tileentity.IChestLid;
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.block.storage.SkyChestBlock;
|
||||
import appeng.tile.AEBaseInvBlockEntity;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
public class SkyChestBlockEntity extends AEBaseInvBlockEntity implements Tickable, IChestLid {
|
||||
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 9 * 4);
|
||||
|
||||
// server
|
||||
private int numPlayersUsing;
|
||||
// client..
|
||||
private long lastEvent;
|
||||
private float lidAngle;
|
||||
private float prevLidAngle;
|
||||
|
||||
public SkyChestBlockEntity(BlockEntityType<? extends SkyChestBlockEntity> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream(final PacketByteBuf data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
data.writeBoolean(this.getPlayerOpen() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream(final PacketByteBuf data) throws IOException {
|
||||
final boolean c = super.readFromStream(data);
|
||||
final int wasOpen = this.getPlayerOpen();
|
||||
this.setPlayerOpen(data.readBoolean() ? 1 : 0);
|
||||
|
||||
if (wasOpen != this.getPlayerOpen()) {
|
||||
this.setLastEvent(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
return c; // TESR yo!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderBreaking() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FixedItemInv getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
public void openInventory(final PlayerEntity player) {
|
||||
if (!player.isSpectator()) {
|
||||
this.setPlayerOpen(this.getPlayerOpen() + 1);
|
||||
onOpenOrClose();
|
||||
|
||||
if (this.getPlayerOpen() == 1) {
|
||||
this.getWorld().playSound(player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D,
|
||||
this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F,
|
||||
this.getWorld().rand.nextFloat() * 0.1F + 0.9F);
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void closeInventory(final PlayerEntity player) {
|
||||
if (!player.isSpectator()) {
|
||||
this.setPlayerOpen(this.getPlayerOpen() - 1);
|
||||
onOpenOrClose();
|
||||
|
||||
if (this.getPlayerOpen() < 0) {
|
||||
this.setPlayerOpen(0);
|
||||
}
|
||||
|
||||
if (this.getPlayerOpen() == 0) {
|
||||
this.getWorld().playSound(player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D,
|
||||
this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F,
|
||||
this.getWorld().rand.nextFloat() * 0.1F + 0.9F);
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See ChestTileEntity
|
||||
private void onOpenOrClose() {
|
||||
Block block = getCachedState().getBlock();
|
||||
if (block instanceof SkyChestBlock) {
|
||||
this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing);
|
||||
this.world.updateNeighborsAlways(this.pos, block);
|
||||
// FIXME: Uhm, we are we doing this?
|
||||
this.world.updateNeighborsAlways(this.pos.down(), block);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.prevLidAngle = this.lidAngle;
|
||||
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
|
||||
if (this.numPlayersUsing > 0) {
|
||||
this.lidAngle += 0.1F;
|
||||
} else {
|
||||
this.lidAngle -= 0.1F;
|
||||
}
|
||||
|
||||
this.lidAngle = MathHelper.clamp(this.lidAngle, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
|
||||
}
|
||||
|
||||
public int getPlayerOpen() {
|
||||
return this.numPlayersUsing;
|
||||
}
|
||||
|
||||
private void setPlayerOpen(final int playerOpen) {
|
||||
this.numPlayersUsing = playerOpen;
|
||||
}
|
||||
|
||||
public long getLastEvent() {
|
||||
return this.lastEvent;
|
||||
}
|
||||
|
||||
private void setLastEvent(final long lastEvent) {
|
||||
this.lastEvent = lastEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLidAngle(float partialTicks) {
|
||||
return MathHelper.lerp(partialTicks, this.prevLidAngle, this.lidAngle);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user