Allow players to color the Super Stock Replenisher/OptimizeImages (#480)
No files matched your search
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.6 KiB |
@@ -1,7 +1,10 @@
|
||||
package com.glodblock.github.common.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -12,11 +15,17 @@ import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockSuperStockReplenisher extends FCBaseBlock {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] coloredTextures;
|
||||
|
||||
public BlockSuperStockReplenisher() {
|
||||
super(Material.web, NameConst.BLOCK_SUPER_STOCK_REPLENISHER);
|
||||
setTileEntity(TileSuperStockReplenisher.class);
|
||||
@@ -25,6 +34,28 @@ public class BlockSuperStockReplenisher extends FCBaseBlock {
|
||||
this.lightOpacity = 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(final IIconRegister iconRegistry) {
|
||||
super.registerBlockIcons(iconRegistry);
|
||||
this.coloredTextures = new IIcon[AEColor.VALUES.length];
|
||||
|
||||
for (final AEColor color : AEColor.VALID_COLORS) {
|
||||
this.coloredTextures[color.ordinal()] = iconRegistry
|
||||
.registerIcon(this.getTextureName().replace(":", ":replenisher/") + "_" + color.name());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(final IBlockAccess world, final int x, final int y, final int z, final int side) {
|
||||
final TileSuperStockReplenisher tile = this.getTileEntity(world, x, y, z);
|
||||
if (tile != null && tile.getColor() != AEColor.Transparent) {
|
||||
return this.coloredTextures[tile.getColor().ordinal()];
|
||||
}
|
||||
return super.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX,
|
||||
float hitY, float hitZ) {
|
||||
|
||||
@@ -5,10 +5,12 @@ import java.util.stream.IntStream;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -28,6 +30,7 @@ import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
@@ -45,6 +48,7 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AELog;
|
||||
@@ -63,7 +67,7 @@ import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileSuperStockReplenisher extends AENetworkInvTile implements IAEFluidInventory, IFluidHandler,
|
||||
IPowerChannelState, IGridTickable, ITerminalHost, IIAEStackInventory {
|
||||
IPowerChannelState, IGridTickable, ITerminalHost, IIAEStackInventory, IColorableTile {
|
||||
|
||||
private final AppEngInternalInventory cell = new AppEngInternalInventory(this, 1);
|
||||
private final BiggerAppEngInventory invItems = new BiggerAppEngInventory(this, 63);
|
||||
@@ -87,6 +91,7 @@ public class TileSuperStockReplenisher extends AENetworkInvTile implements IAEFl
|
||||
};
|
||||
private final BaseActionSource source;
|
||||
private boolean isPowered;
|
||||
private AEColor paintedColor = AEColor.Transparent;
|
||||
private long totalBytes;
|
||||
private long storedFluidCount;
|
||||
private long storedItemCount;
|
||||
@@ -601,17 +606,26 @@ public class TileSuperStockReplenisher extends AENetworkInvTile implements IAEFl
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSuperStockReplenisher(final ByteBuf data) {
|
||||
final boolean oldPower = isPowered;
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
isPowered = data.readBoolean();
|
||||
return isPowered != oldPower;
|
||||
this.paintedColor = AEColor.fromOrdinal(data.readByte());
|
||||
this.getProxy().setColor(this.paintedColor);
|
||||
return isPowered != oldPower || this.paintedColor != oldPaintedColor;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileSuperStockReplenisher(final ByteBuf data) {
|
||||
data.writeBoolean(isActive());
|
||||
data.writeByte(this.paintedColor.ordinal());
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBTEvent(NBTTagCompound data) {
|
||||
final int color = data.hasKey("paintedColor", Constants.NBT.TAG_BYTE) ? data.getByte("paintedColor")
|
||||
: AEColor.Transparent.ordinal();
|
||||
this.paintedColor = color >= 0 && color < AEColor.VALUES.length ? AEColor.fromOrdinal(color)
|
||||
: AEColor.Transparent;
|
||||
this.getProxy().setColor(this.paintedColor);
|
||||
invItems.readFromNBT(data, "ItemInv");
|
||||
invFluids.readFromNBT(data, "FluidInv");
|
||||
configItems.readFromNBT(data, "configItems");
|
||||
@@ -626,6 +640,7 @@ public class TileSuperStockReplenisher extends AENetworkInvTile implements IAEFl
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
|
||||
data.setByte("paintedColor", (byte) this.paintedColor.ordinal());
|
||||
invItems.writeToNBT(data, "ItemInv");
|
||||
invFluids.writeToNBT(data, "FluidInv");
|
||||
configItems.writeToNBT(data, "configItems");
|
||||
@@ -638,6 +653,27 @@ public class TileSuperStockReplenisher extends AENetworkInvTile implements IAEFl
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor() {
|
||||
return this.paintedColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(final ForgeDirection side, final AEColor newPaintedColor, final EntityPlayer who) {
|
||||
if (this.paintedColor == newPaintedColor) {
|
||||
return false;
|
||||
}
|
||||
this.paintedColor = newPaintedColor;
|
||||
this.getProxy().setColor(this.paintedColor);
|
||||
final IGridNode node = this.getGridNode(side);
|
||||
if (node != null) {
|
||||
node.updateState();
|
||||
}
|
||||
this.markDirty();
|
||||
this.markForUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(final MENetworkPowerStatusChange p) {
|
||||
this.updatePowerState();
|
||||
|
||||
|
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 126 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 126 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 126 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 122 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 197 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 133 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 133 B |
|
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 321 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 350 B |
|
After Width: | Height: | Size: 366 B |