Merge pull request #1 from raoulvdberge/mc1.9

Update to master
This commit is contained in:
GustoniaEagle
2016-03-29 15:23:58 +01:00
296 changed files with 8837 additions and 10046 deletions

1
.gitignore vendored Normal file → Executable file
View File

@@ -13,3 +13,4 @@ run/
*.ipr *.ipr
*.iws *.iws
.idea/ .idea/
out/

50
CHANGELOG.md Executable file
View File

@@ -0,0 +1,50 @@
# Refined Storage Changelog
### 0.5
**Bugfixes**
- Fixed clicking sound in Grid
- Fixed a bunch of crashes
- Fixed exporter not exporting is some cases
- Fixed importer not importing in some cases
- Fixed controller drawing RF every 20 ticks instead of every tick
- Fixed not being able to shift click from Crafting Grid crafting slots
- Fixed new items inserted after crafting in Grid being laggy
- Fixed flickering of items in Grid
- Fixed getting a stack of unstackable stuff from Grid
- Check if the Constructor can actually place said block in the world
**Features**
- New textures
- Updated to the latest Forge and JEI
- Renamed Drives to Disk Drives
- Renamed Storage Cells to Storage Disks
- Drives have a better interface and there are now blacklist and whitelist filters for the Storage Disks in it too.
- Destructors have the ability to whitelist and blacklist certain items now
- Shift clicking stuff in the Interface
- Scrollbar in Grid and Crafting Grid
- Made the normal Grid 1 row larger
- Display of connected machines in the Controller GUI
- Deep Storage Unit integration (with this several barrel mods are now supported too!)
- Machines don't need to be connected with cables anymore, they can be next to each other too
- Made the amount text in the Grid for items smaller
- Nice formatting for items >= 1K (pressing shift while hovering over an item will still display the real item count)
- When placing Importer, Exporter or External Storage with SHIFT, it will have the opposite direction. This is for easy placement behind other blocks (furnaces for example)
### 0.4.1
**Bugfixes**
- Fix ID duplication issues
### 0.4
**Bugfixes**
- Cables now have actual collision
- Fullness percentage in Creative Storage Blocks going under 0%
- The Controller shouldn't display the base usage when not working
- Fix Minecraft reporting that retrieving Grid type fails
- Check isItemValidForSlot on trying to push to inventories
**Features**
- Relays
- Interfaces
### 0.3
- Initial release

2
LICENSE.md Normal file → Executable file
View File

@@ -1,6 +1,6 @@
# The MIT License (MIT) # The MIT License (MIT)
Copyright © 2015 - 2016 Raoul Van den Berge Copyright © 2015 - 2016 Refined Storage contributors
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation

8
README.md Normal file → Executable file
View File

@@ -2,4 +2,10 @@
A Minecraft mod all about storage. A Minecraft mod all about storage.
[Check this project out on CurseForge](http://minecraft.curseforge.com/projects/refined-storage). This project is available on [CurseForge](http://minecraft.curseforge.com/projects/refined-storage).
## What are you interested in?
- [How this mod works and how to use it](https://github.com/raoulvdberge/refinedstorage/wiki)
- [Reporting a bug](https://github.com/raoulvdberge/refinedstorage/issues)
- [Sending a feature request](https://github.com/raoulvdberge/refinedstorage/issues)

6
build.gradle Normal file → Executable file
View File

@@ -17,9 +17,9 @@ group = "refinedstorage"
archivesBaseName = "refinedstorage" archivesBaseName = "refinedstorage"
minecraft { minecraft {
version = "1.9-12.16.0.1770-1.9" version = "1.9-12.16.0.1811-1.9"
runDir = "run" runDir = "run"
useDepAts = true useDepAts = true
mappings = "snapshot_20160312" mappings = "snapshot_20160312"
} }
@@ -30,7 +30,7 @@ repositories {
} }
dependencies { dependencies {
deobfCompile "mezz.jei:jei_1.9:3.0.+" deobfCompile "mezz.jei:jei_1.9:3.1.+"
} }
processResources { processResources {

0
gradlew vendored Normal file → Executable file
View File

0
gradlew.bat vendored Normal file → Executable file
View File

BIN
logo.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

0
screenshots/crafting_grid.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 90 KiB

0
screenshots/interface.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

0
screenshots/overview.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 558 KiB

After

Width:  |  Height:  |  Size: 558 KiB

0
screenshots/relays.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB

0
screenshots/storage_block.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

6
src/main/java/cofh/api/CoFHAPIProps.java Normal file → Executable file
View File

@@ -2,10 +2,10 @@ package cofh.api;
public class CoFHAPIProps { public class CoFHAPIProps {
private CoFHAPIProps() { private CoFHAPIProps() {
} }
public static final String VERSION = "1.8.9R1.2.0B1"; public static final String VERSION = "1.8.9R1.2.0B1";
} }

217
src/main/java/cofh/api/energy/EnergyStorage.java Normal file → Executable file
View File

@@ -6,157 +6,156 @@ import net.minecraft.nbt.NBTTagCompound;
* Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own. * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own.
* *
* @author King Lemming * @author King Lemming
*
*/ */
public class EnergyStorage implements IEnergyStorage { public class EnergyStorage implements IEnergyStorage {
protected int energy; protected int energy;
protected int capacity; protected int capacity;
protected int maxReceive; protected int maxReceive;
protected int maxExtract; protected int maxExtract;
public EnergyStorage(int capacity) { public EnergyStorage(int capacity) {
this(capacity, capacity, capacity); this(capacity, capacity, capacity);
} }
public EnergyStorage(int capacity, int maxTransfer) { public EnergyStorage(int capacity, int maxTransfer) {
this(capacity, maxTransfer, maxTransfer); this(capacity, maxTransfer, maxTransfer);
} }
public EnergyStorage(int capacity, int maxReceive, int maxExtract) { public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
this.capacity = capacity; this.capacity = capacity;
this.maxReceive = maxReceive; this.maxReceive = maxReceive;
this.maxExtract = maxExtract; this.maxExtract = maxExtract;
} }
public EnergyStorage readFromNBT(NBTTagCompound nbt) { public EnergyStorage readFromNBT(NBTTagCompound nbt) {
this.energy = nbt.getInteger("Energy"); this.energy = nbt.getInteger("Energy");
if (energy > capacity) { if (energy > capacity) {
energy = capacity; energy = capacity;
} }
return this; return this;
} }
public NBTTagCompound writeToNBT(NBTTagCompound nbt) { public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
if (energy < 0) { if (energy < 0) {
energy = 0; energy = 0;
} }
nbt.setInteger("Energy", energy); nbt.setInteger("Energy", energy);
return nbt; return nbt;
} }
public EnergyStorage setCapacity(int capacity) { public EnergyStorage setCapacity(int capacity) {
this.capacity = capacity; this.capacity = capacity;
if (energy > capacity) { if (energy > capacity) {
energy = capacity; energy = capacity;
} }
return this; return this;
} }
public EnergyStorage setMaxTransfer(int maxTransfer) { public EnergyStorage setMaxTransfer(int maxTransfer) {
setMaxReceive(maxTransfer); setMaxReceive(maxTransfer);
setMaxExtract(maxTransfer); setMaxExtract(maxTransfer);
return this; return this;
} }
public EnergyStorage setMaxReceive(int maxReceive) { public EnergyStorage setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive; this.maxReceive = maxReceive;
return this; return this;
} }
public EnergyStorage setMaxExtract(int maxExtract) { public EnergyStorage setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract; this.maxExtract = maxExtract;
return this; return this;
} }
public int getMaxReceive() { public int getMaxReceive() {
return maxReceive; return maxReceive;
} }
public int getMaxExtract() { public int getMaxExtract() {
return maxExtract; return maxExtract;
} }
/** /**
* This function is included to allow for server to client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers * This function is included to allow for server to client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers
* are guaranteed to have it. * are guaranteed to have it.
* *
* @param energy * @param energy
*/ */
public void setEnergyStored(int energy) { public void setEnergyStored(int energy) {
this.energy = energy; this.energy = energy;
if (this.energy > capacity) { if (this.energy > capacity) {
this.energy = capacity; this.energy = capacity;
} else if (this.energy < 0) { } else if (this.energy < 0) {
this.energy = 0; this.energy = 0;
} }
} }
/** /**
* This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this
* externally, as not all IEnergyHandlers are guaranteed to have it. * externally, as not all IEnergyHandlers are guaranteed to have it.
* *
* @param energy * @param energy
*/ */
public void modifyEnergyStored(int energy) { public void modifyEnergyStored(int energy) {
this.energy += energy; this.energy += energy;
if (this.energy > capacity) { if (this.energy > capacity) {
this.energy = capacity; this.energy = capacity;
} else if (this.energy < 0) { } else if (this.energy < 0) {
this.energy = 0; this.energy = 0;
} }
} }
/* IEnergyStorage */ /* IEnergyStorage */
@Override @Override
public int receiveEnergy(int maxReceive, boolean simulate) { public int receiveEnergy(int maxReceive, boolean simulate) {
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
if (!simulate) { if (!simulate) {
energy += energyReceived; energy += energyReceived;
} }
return energyReceived; return energyReceived;
} }
@Override @Override
public int extractEnergy(int maxExtract, boolean simulate) { public int extractEnergy(int maxExtract, boolean simulate) {
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
if (!simulate) { if (!simulate) {
energy -= energyExtracted; energy -= energyExtracted;
} }
return energyExtracted; return energyExtracted;
} }
@Override @Override
public int getEnergyStored() { public int getEnergyStored() {
return energy; return energy;
} }
@Override @Override
public int getMaxEnergyStored() { public int getMaxEnergyStored() {
return capacity; return capacity;
} }
} }

9
src/main/java/cofh/api/energy/IEnergyConnection.java Normal file → Executable file
View File

@@ -10,13 +10,12 @@ import net.minecraft.util.EnumFacing;
* Note that {@link IEnergyHandler} is an extension of this. * Note that {@link IEnergyHandler} is an extension of this.
* *
* @author King Lemming * @author King Lemming
*
*/ */
public interface IEnergyConnection { public interface IEnergyConnection {
/** /**
* Returns TRUE if the TileEntity can connect on a given side. * Returns TRUE if the TileEntity can connect on a given side.
*/ */
boolean canConnectEnergy(EnumFacing from); boolean canConnectEnergy(EnumFacing from);
} }

61
src/main/java/cofh/api/energy/IEnergyContainerItem.java Normal file → Executable file
View File

@@ -8,45 +8,38 @@ import net.minecraft.item.ItemStack;
* A reference implementation is provided {@link ItemEnergyContainer}. * A reference implementation is provided {@link ItemEnergyContainer}.
* *
* @author King Lemming * @author King Lemming
*
*/ */
public interface IEnergyContainerItem { public interface IEnergyContainerItem {
/** /**
* Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged. * Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged.
* *
* @param container * @param container ItemStack to be charged.
* ItemStack to be charged. * @param maxReceive Maximum amount of energy to be sent into the item.
* @param maxReceive * @param simulate If TRUE, the charge will only be simulated.
* Maximum amount of energy to be sent into the item. * @return Amount of energy that was (or would have been, if simulated) received by the item.
* @param simulate */
* If TRUE, the charge will only be simulated. int receiveEnergy(ItemStack container, int maxReceive, boolean simulate);
* @return Amount of energy that was (or would have been, if simulated) received by the item.
*/
int receiveEnergy(ItemStack container, int maxReceive, boolean simulate);
/** /**
* Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally * Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally
* discharged. * discharged.
* *
* @param container * @param container ItemStack to be discharged.
* ItemStack to be discharged. * @param maxExtract Maximum amount of energy to be extracted from the item.
* @param maxExtract * @param simulate If TRUE, the discharge will only be simulated.
* Maximum amount of energy to be extracted from the item. * @return Amount of energy that was (or would have been, if simulated) extracted from the item.
* @param simulate */
* If TRUE, the discharge will only be simulated. int extractEnergy(ItemStack container, int maxExtract, boolean simulate);
* @return Amount of energy that was (or would have been, if simulated) extracted from the item.
*/
int extractEnergy(ItemStack container, int maxExtract, boolean simulate);
/** /**
* Get the amount of energy currently stored in the container item. * Get the amount of energy currently stored in the container item.
*/ */
int getEnergyStored(ItemStack container); int getEnergyStored(ItemStack container);
/** /**
* Get the max amount of energy that can be stored in the container item. * Get the max amount of energy that can be stored in the container item.
*/ */
int getMaxEnergyStored(ItemStack container); int getMaxEnergyStored(ItemStack container);
} }

17
src/main/java/cofh/api/energy/IEnergyHandler.java Normal file → Executable file
View File

@@ -10,18 +10,17 @@ import net.minecraft.util.EnumFacing;
* Note that {@link IEnergyReceiver} and {@link IEnergyProvider} are extensions of this. * Note that {@link IEnergyReceiver} and {@link IEnergyProvider} are extensions of this.
* *
* @author King Lemming * @author King Lemming
*
*/ */
public interface IEnergyHandler extends IEnergyConnection { public interface IEnergyHandler extends IEnergyConnection {
/** /**
* Returns the amount of energy currently stored. * Returns the amount of energy currently stored.
*/ */
int getEnergyStored(EnumFacing from); int getEnergyStored(EnumFacing from);
/** /**
* Returns the maximum amount of energy that can be stored. * Returns the maximum amount of energy that can be stored.
*/ */
int getMaxEnergyStored(EnumFacing from); int getMaxEnergyStored(EnumFacing from);
} }

22
src/main/java/cofh/api/energy/IEnergyProvider.java Normal file → Executable file
View File

@@ -9,21 +9,17 @@ import net.minecraft.util.EnumFacing;
* A reference implementation is provided {@link TileEnergyHandler}. * A reference implementation is provided {@link TileEnergyHandler}.
* *
* @author King Lemming * @author King Lemming
*
*/ */
public interface IEnergyProvider extends IEnergyHandler { public interface IEnergyProvider extends IEnergyHandler {
/** /**
* Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider. * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
* *
* @param from * @param from Orientation the energy is extracted from.
* Orientation the energy is extracted from. * @param maxExtract Maximum amount of energy to extract.
* @param maxExtract * @param simulate If TRUE, the extraction will only be simulated.
* Maximum amount of energy to extract. * @return Amount of energy that was (or would have been, if simulated) extracted.
* @param simulate */
* If TRUE, the extraction will only be simulated. int extractEnergy(EnumFacing from, int maxExtract, boolean simulate);
* @return Amount of energy that was (or would have been, if simulated) extracted.
*/
int extractEnergy(EnumFacing from, int maxExtract, boolean simulate);
} }

22
src/main/java/cofh/api/energy/IEnergyReceiver.java Normal file → Executable file
View File

@@ -9,21 +9,17 @@ import net.minecraft.util.EnumFacing;
* A reference implementation is provided {@link TileEnergyHandler}. * A reference implementation is provided {@link TileEnergyHandler}.
* *
* @author King Lemming * @author King Lemming
*
*/ */
public interface IEnergyReceiver extends IEnergyHandler { public interface IEnergyReceiver extends IEnergyHandler {
/** /**
* Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver. * Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver.
* *
* @param from * @param from Orientation the energy is received from.
* Orientation the energy is received from. * @param maxReceive Maximum amount of energy to receive.
* @param maxReceive * @param simulate If TRUE, the charge will only be simulated.
* Maximum amount of energy to receive. * @return Amount of energy that was (or would have been, if simulated) received.
* @param simulate */
* If TRUE, the charge will only be simulated. int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate);
* @return Amount of energy that was (or would have been, if simulated) received.
*/
int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate);
} }

53
src/main/java/cofh/api/energy/IEnergyStorage.java Normal file → Executable file
View File

@@ -7,40 +7,35 @@ package cofh.api.energy;
* A reference implementation can be found at {@link EnergyStorage}. * A reference implementation can be found at {@link EnergyStorage}.
* *
* @author King Lemming * @author King Lemming
*
*/ */
public interface IEnergyStorage { public interface IEnergyStorage {
/** /**
* Adds energy to the storage. Returns quantity of energy that was accepted. * Adds energy to the storage. Returns quantity of energy that was accepted.
* *
* @param maxReceive * @param maxReceive Maximum amount of energy to be inserted.
* Maximum amount of energy to be inserted. * @param simulate If TRUE, the insertion will only be simulated.
* @param simulate * @return Amount of energy that was (or would have been, if simulated) accepted by the storage.
* If TRUE, the insertion will only be simulated. */
* @return Amount of energy that was (or would have been, if simulated) accepted by the storage. int receiveEnergy(int maxReceive, boolean simulate);
*/
int receiveEnergy(int maxReceive, boolean simulate);
/** /**
* Removes energy from the storage. Returns quantity of energy that was removed. * Removes energy from the storage. Returns quantity of energy that was removed.
* *
* @param maxExtract * @param maxExtract Maximum amount of energy to be extracted.
* Maximum amount of energy to be extracted. * @param simulate If TRUE, the extraction will only be simulated.
* @param simulate * @return Amount of energy that was (or would have been, if simulated) extracted from the storage.
* If TRUE, the extraction will only be simulated. */
* @return Amount of energy that was (or would have been, if simulated) extracted from the storage. int extractEnergy(int maxExtract, boolean simulate);
*/
int extractEnergy(int maxExtract, boolean simulate);
/** /**
* Returns the amount of energy currently stored. * Returns the amount of energy currently stored.
*/ */
int getEnergyStored(); int getEnergyStored();
/** /**
* Returns the maximum amount of energy that can be stored. * Returns the maximum amount of energy that can be stored.
*/ */
int getMaxEnergyStored(); int getMaxEnergyStored();
} }

143
src/main/java/cofh/api/energy/ItemEnergyContainer.java Normal file → Executable file
View File

@@ -8,106 +8,105 @@ import net.minecraft.nbt.NBTTagCompound;
* Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own. * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own.
* *
* @author King Lemming * @author King Lemming
*
*/ */
public class ItemEnergyContainer extends Item implements IEnergyContainerItem { public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
protected int capacity; protected int capacity;
protected int maxReceive; protected int maxReceive;
protected int maxExtract; protected int maxExtract;
public ItemEnergyContainer() { public ItemEnergyContainer() {
} }
public ItemEnergyContainer(int capacity) { public ItemEnergyContainer(int capacity) {
this(capacity, capacity, capacity); this(capacity, capacity, capacity);
} }
public ItemEnergyContainer(int capacity, int maxTransfer) { public ItemEnergyContainer(int capacity, int maxTransfer) {
this(capacity, maxTransfer, maxTransfer); this(capacity, maxTransfer, maxTransfer);
} }
public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) { public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {
this.capacity = capacity; this.capacity = capacity;
this.maxReceive = maxReceive; this.maxReceive = maxReceive;
this.maxExtract = maxExtract; this.maxExtract = maxExtract;
} }
public ItemEnergyContainer setCapacity(int capacity) { public ItemEnergyContainer setCapacity(int capacity) {
this.capacity = capacity; this.capacity = capacity;
return this; return this;
} }
public ItemEnergyContainer setMaxTransfer(int maxTransfer) { public ItemEnergyContainer setMaxTransfer(int maxTransfer) {
setMaxReceive(maxTransfer); setMaxReceive(maxTransfer);
setMaxExtract(maxTransfer); setMaxExtract(maxTransfer);
return this; return this;
} }
public ItemEnergyContainer setMaxReceive(int maxReceive) { public ItemEnergyContainer setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive; this.maxReceive = maxReceive;
return this; return this;
} }
public ItemEnergyContainer setMaxExtract(int maxExtract) { public ItemEnergyContainer setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract; this.maxExtract = maxExtract;
return this; return this;
} }
/* IEnergyContainerItem */ /* IEnergyContainerItem */
@Override @Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
if (!container.hasTagCompound()) { if (!container.hasTagCompound()) {
container.setTagCompound(new NBTTagCompound()); container.setTagCompound(new NBTTagCompound());
} }
int energy = container.getTagCompound().getInteger("Energy"); int energy = container.getTagCompound().getInteger("Energy");
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
if (!simulate) { if (!simulate) {
energy += energyReceived; energy += energyReceived;
container.getTagCompound().setInteger("Energy", energy); container.getTagCompound().setInteger("Energy", energy);
} }
return energyReceived; return energyReceived;
} }
@Override @Override
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) { if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) {
return 0; return 0;
} }
int energy = container.getTagCompound().getInteger("Energy"); int energy = container.getTagCompound().getInteger("Energy");
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
if (!simulate) { if (!simulate) {
energy -= energyExtracted; energy -= energyExtracted;
container.getTagCompound().setInteger("Energy", energy); container.getTagCompound().setInteger("Energy", energy);
} }
return energyExtracted; return energyExtracted;
} }
@Override @Override
public int getEnergyStored(ItemStack container) { public int getEnergyStored(ItemStack container) {
if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) { if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) {
return 0; return 0;
} }
return container.getTagCompound().getInteger("Energy"); return container.getTagCompound().getInteger("Energy");
} }
@Override @Override
public int getMaxEnergyStored(ItemStack container) { public int getMaxEnergyStored(ItemStack container) {
return capacity; return capacity;
} }
} }

73
src/main/java/cofh/api/energy/TileEnergyHandler.java Normal file → Executable file
View File

@@ -6,62 +6,61 @@ import net.minecraft.util.EnumFacing;
/** /**
* Reference implementation of {@link IEnergyReceiver} and {@link IEnergyProvider}. Use/extend this or implement your own. * Reference implementation of {@link IEnergyReceiver} and {@link IEnergyProvider}. Use/extend this or implement your own.
* * <p>
* This class is really meant to summarize how each interface is properly used. * This class is really meant to summarize how each interface is properly used.
* *
* @author King Lemming * @author King Lemming
*
*/ */
public class TileEnergyHandler extends TileEntity implements IEnergyReceiver, IEnergyProvider { public class TileEnergyHandler extends TileEntity implements IEnergyReceiver, IEnergyProvider {
protected EnergyStorage storage = new EnergyStorage(32000); protected EnergyStorage storage = new EnergyStorage(32000);
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
storage.readFromNBT(nbt); storage.readFromNBT(nbt);
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
storage.writeToNBT(nbt); storage.writeToNBT(nbt);
} }
/* IEnergyConnection */ /* IEnergyConnection */
@Override @Override
public boolean canConnectEnergy(EnumFacing from) { public boolean canConnectEnergy(EnumFacing from) {
return true; return true;
} }
/* IEnergyReceiver */ /* IEnergyReceiver */
@Override @Override
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) { public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) {
return storage.receiveEnergy(maxReceive, simulate); return storage.receiveEnergy(maxReceive, simulate);
} }
/* IEnergyProvider */ /* IEnergyProvider */
@Override @Override
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) {
return storage.extractEnergy(maxExtract, simulate); return storage.extractEnergy(maxExtract, simulate);
} }
/* IEnergyHandler */ /* IEnergyHandler */
@Override @Override
public int getEnergyStored(EnumFacing from) { public int getEnergyStored(EnumFacing from) {
return storage.getEnergyStored(); return storage.getEnergyStored();
} }
@Override @Override
public int getMaxEnergyStored(EnumFacing from) { public int getMaxEnergyStored(EnumFacing from) {
return storage.getMaxEnergyStored(); return storage.getMaxEnergyStored();
} }
} }

2
src/main/java/cofh/api/energy/package-info.java Normal file → Executable file
View File

@@ -5,6 +5,6 @@
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy") @API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy")
package cofh.api.energy; package cofh.api.energy;
import net.minecraftforge.fml.common.API;
import cofh.api.CoFHAPIProps; import cofh.api.CoFHAPIProps;
import net.minecraftforge.fml.common.API;

0
src/main/java/cofh/api/package-info.java Normal file → Executable file
View File

View File

@@ -0,0 +1,25 @@
package powercrystals.minefactoryreloaded.api;
import net.minecraft.item.ItemStack;
public interface IDeepStorageUnit {
/**
* @return A populated ItemStack with stackSize for the full amount of materials in the DSU. May have a stackSize > getMaxStackSize().
*/
ItemStack getStoredItemType();
/**
* Sets the total amount of the item currently being stored, or zero if it wants to remove all items.
*/
void setStoredItemCount(int amount);
/**
* Sets the type of the stored item and initializes the number of stored items to amount. Will overwrite any existing stored items.
*/
void setStoredItemType(ItemStack type, int amount);
/**
* @return The maximum number of items the DSU can hold.
*/
int getMaxStoredCount();
}

69
src/main/java/refinedstorage/RefinedStorage.java Normal file → Executable file
View File

@@ -12,53 +12,46 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import refinedstorage.item.ItemStorageCell; import refinedstorage.item.ItemStorageDisk;
import refinedstorage.proxy.CommonProxy; import refinedstorage.proxy.CommonProxy;
@Mod(modid = RefinedStorage.ID, version = RefinedStorage.VERSION) @Mod(modid = RefinedStorage.ID, version = RefinedStorage.VERSION)
public final class RefinedStorage public final class RefinedStorage {
{ public static final String ID = "refinedstorage";
public static final String ID = "refinedstorage"; public static final String VERSION = "0.5";
public static final String VERSION = "0.5";
public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(ID); public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(ID);
public static final CreativeTabs TAB = new CreativeTabs(ID) public static final CreativeTabs TAB = new CreativeTabs(ID) {
{ @Override
@Override public ItemStack getIconItemStack() {
public ItemStack getIconItemStack() return new ItemStack(RefinedStorageItems.STORAGE_DISK, 1, ItemStorageDisk.TYPE_1K);
{ }
return new ItemStack(RefinedStorageItems.STORAGE_CELL, 1, ItemStorageCell.TYPE_1K);
}
@Override @Override
public Item getTabIconItem() public Item getTabIconItem() {
{ return null;
return null; }
} };
};
@SidedProxy(clientSide = "refinedstorage.proxy.ClientProxy", serverSide = "refinedstorage.proxy.ServerProxy") @SidedProxy(clientSide = "refinedstorage.proxy.ClientProxy", serverSide = "refinedstorage.proxy.ServerProxy")
public static CommonProxy PROXY; public static CommonProxy PROXY;
@Instance @Instance
public static RefinedStorage INSTANCE; public static RefinedStorage INSTANCE;
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent e) public void preInit(FMLPreInitializationEvent e) {
{ PROXY.preInit(e);
PROXY.preInit(e); }
}
@EventHandler @EventHandler
public void init(FMLInitializationEvent e) public void init(FMLInitializationEvent e) {
{ PROXY.init(e);
PROXY.init(e); }
}
@EventHandler @EventHandler
public void postInit(FMLPostInitializationEvent e) public void postInit(FMLPostInitializationEvent e) {
{ PROXY.postInit(e);
PROXY.postInit(e); }
}
} }

34
src/main/java/refinedstorage/RefinedStorageBlocks.java Normal file → Executable file
View File

@@ -2,22 +2,20 @@ package refinedstorage;
import refinedstorage.block.*; import refinedstorage.block.*;
public final class RefinedStorageBlocks public final class RefinedStorageBlocks {
{ public static final BlockController CONTROLLER = new BlockController();
public static final BlockController CONTROLLER = new BlockController(); public static final BlockCable CABLE = new BlockCable();
public static final BlockCable CABLE = new BlockCable(); public static final BlockGrid GRID = new BlockGrid();
public static final BlockGrid GRID = new BlockGrid(); public static final BlockDiskDrive DISK_DRIVE = new BlockDiskDrive();
public static final BlockDrive DRIVE = new BlockDrive(); public static final BlockExternalStorage EXTERNAL_STORAGE = new BlockExternalStorage();
public static final BlockExternalStorage EXTERNAL_STORAGE = new BlockExternalStorage(); public static final BlockImporter IMPORTER = new BlockImporter();
public static final BlockImporter IMPORTER = new BlockImporter(); public static final BlockExporter EXPORTER = new BlockExporter();
public static final BlockExporter EXPORTER = new BlockExporter(); public static final BlockDetector DETECTOR = new BlockDetector();
public static final BlockDetector DETECTOR = new BlockDetector(); public static final BlockMachineCasing MACHINE_CASING = new BlockMachineCasing();
public static final BlockMachineCasing MACHINE_CASING = new BlockMachineCasing(); public static final BlockSolderer SOLDERER = new BlockSolderer();
public static final BlockSolderer SOLDERER = new BlockSolderer(); public static final BlockDestructor DESTRUCTOR = new BlockDestructor();
public static final BlockWirelessTransmitter WIRELESS_TRANSMITTER = new BlockWirelessTransmitter(); public static final BlockConstructor CONSTRUCTOR = new BlockConstructor();
public static final BlockDestructor DESTRUCTOR = new BlockDestructor(); public static final BlockStorage STORAGE = new BlockStorage();
public static final BlockConstructor CONSTRUCTOR = new BlockConstructor(); public static final BlockRelay RELAY = new BlockRelay();
public static final BlockStorage STORAGE = new BlockStorage(); public static final BlockInterface INTERFACE = new BlockInterface();
public static final BlockRelay RELAY = new BlockRelay();
public static final BlockInterface INTERFACE = new BlockInterface();
} }

28
src/main/java/refinedstorage/RefinedStorageGui.java Normal file → Executable file
View File

@@ -1,18 +1,16 @@
package refinedstorage; package refinedstorage;
public final class RefinedStorageGui public final class RefinedStorageGui {
{ public static final int CONTROLLER = 0;
public static final int CONTROLLER = 0; public static final int GRID = 1;
public static final int GRID = 1; public static final int DISK_DRIVE = 2;
public static final int DRIVE = 2; public static final int IMPORTER = 4;
public static final int IMPORTER = 4; public static final int EXPORTER = 5;
public static final int EXPORTER = 5; public static final int DETECTOR = 6;
public static final int DETECTOR = 6; public static final int SOLDERER = 7;
public static final int SOLDERER = 7; public static final int DESTRUCTOR = 9;
public static final int WIRELESS_TRANSMITTER = 8; public static final int CONSTRUCTOR = 10;
public static final int DESTRUCTOR = 9; public static final int STORAGE = 11;
public static final int CONSTRUCTOR = 10; public static final int RELAY = 12;
public static final int STORAGE = 11; public static final int INTERFACE = 13;
public static final int RELAY = 12;
public static final int INTERFACE = 13;
} }

18
src/main/java/refinedstorage/RefinedStorageItems.java Normal file → Executable file
View File

@@ -2,14 +2,12 @@ package refinedstorage;
import refinedstorage.item.*; import refinedstorage.item.*;
public final class RefinedStorageItems public final class RefinedStorageItems {
{ public static final ItemStorageDisk STORAGE_DISK = new ItemStorageDisk();
public static final ItemStorageCell STORAGE_CELL = new ItemStorageCell(); public static final ItemWirelessGrid WIRELESS_GRID = new ItemWirelessGrid();
public static final ItemWirelessGrid WIRELESS_GRID = new ItemWirelessGrid(); public static final ItemQuartzEnrichedIron QUARTZ_ENRICHED_IRON = new ItemQuartzEnrichedIron();
public static final ItemWirelessGridPlate WIRELESS_GRID_PLATE = new ItemWirelessGridPlate(); public static final ItemCore CORE = new ItemCore();
public static final ItemQuartzEnrichedIron QUARTZ_ENRICHED_IRON = new ItemQuartzEnrichedIron(); public static final ItemSilicon SILICON = new ItemSilicon();
public static final ItemCore CORE = new ItemCore(); public static final ItemProcessor PROCESSOR = new ItemProcessor();
public static final ItemSilicon SILICON = new ItemSilicon(); public static final ItemStoragePart STORAGE_PART = new ItemStoragePart();
public static final ItemProcessor PROCESSOR = new ItemProcessor();
public static final ItemStoragePart STORAGE_PART = new ItemStoragePart();
} }

167
src/main/java/refinedstorage/block/BlockBase.java Normal file → Executable file
View File

@@ -15,120 +15,113 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageBlocks;
import refinedstorage.tile.TileBase; import refinedstorage.tile.TileBase;
import refinedstorage.util.InventoryUtils; import refinedstorage.util.InventoryUtils;
public abstract class BlockBase extends Block public abstract class BlockBase extends Block {
{ public static final PropertyDirection DIRECTION = PropertyDirection.create("direction");
public static final PropertyDirection DIRECTION = PropertyDirection.create("direction");
private String name; private String name;
public BlockBase(String name) public BlockBase(String name) {
{ super(Material.rock);
super(Material.rock);
this.name = name; this.name = name;
setHardness(0.6F); setHardness(0.6F);
setCreativeTab(RefinedStorage.TAB); setCreativeTab(RefinedStorage.TAB);
} }
@Override @Override
public String getUnlocalizedName() public String getUnlocalizedName() {
{ return "block." + RefinedStorage.ID + ":" + name;
return "block." + RefinedStorage.ID + ":" + name; }
}
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState() {
{ return new BlockStateContainer(this, new IProperty[]
return new BlockStateContainer(this, new IProperty[] {
{ DIRECTION,
DIRECTION, });
}); }
}
@Override @Override
public IBlockState getStateFromMeta(int meta) public IBlockState getStateFromMeta(int meta) {
{ return getDefaultState();
return getDefaultState(); }
}
@Override @Override
public int getMetaFromState(IBlockState state) public int getMetaFromState(IBlockState state) {
{ return 0;
return 0; }
}
@Override @Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ TileEntity tile = world.getTileEntity(pos);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileBase) if (tile instanceof TileBase) {
{ return state.withProperty(DIRECTION, ((TileBase) tile).getDirection());
return state.withProperty(DIRECTION, ((TileBase) tile).getDirection()); }
}
return state; return state;
} }
@Override @Override
public int damageDropped(IBlockState state) public int damageDropped(IBlockState state) {
{ return getMetaFromState(state);
return getMetaFromState(state); }
}
@Override @Override
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) {
{ TileEntity tile = world.getTileEntity(pos);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileBase) if (tile instanceof TileBase) {
{ EnumFacing dir = ((TileBase) tile).getDirection();
EnumFacing dir = ((TileBase) tile).getDirection();
int newDir = dir.ordinal() + 1; int newDir = dir.ordinal() + 1;
if (newDir > EnumFacing.VALUES.length - 1) if (newDir > EnumFacing.VALUES.length - 1) {
{ newDir = 0;
newDir = 0; }
}
((TileBase) tile).setDirection(EnumFacing.getFront(newDir)); ((TileBase) tile).setDirection(EnumFacing.getFront(newDir));
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 2 | 4); world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 2 | 4);
return true; return true;
} }
return false; return false;
} }
@Override @Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack itemStack) public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack itemStack) {
{ super.onBlockPlacedBy(world, pos, state, player, itemStack);
super.onBlockPlacedBy(world, pos, state, player, itemStack);
TileEntity tile = world.getTileEntity(pos); Block blockPlaced = state.getBlock();
if (tile instanceof TileBase) TileEntity tile = world.getTileEntity(pos);
{
((TileBase) tile).setDirection(BlockPistonBase.getFacingFromEntity(pos, player));
}
}
@Override if (tile instanceof TileBase) {
public void breakBlock(World world, BlockPos pos, IBlockState state) EnumFacing facing = BlockPistonBase.getFacingFromEntity(pos, player);
{
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileBase && ((TileBase) tile).getDroppedInventory() != null) if (player.isSneaking() && (blockPlaced == RefinedStorageBlocks.IMPORTER || blockPlaced == RefinedStorageBlocks.EXPORTER || blockPlaced == RefinedStorageBlocks.EXTERNAL_STORAGE)) {
{ facing = facing.getOpposite();
InventoryUtils.dropInventory(world, ((TileBase) tile).getDroppedInventory(), pos.getX(), pos.getY(), pos.getZ()); }
}
super.breakBlock(world, pos, state); ((TileBase) tile).setDirection(facing);
} }
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileBase && ((TileBase) tile).getDroppedInventory() != null) {
InventoryUtils.dropInventory(world, ((TileBase) tile).getDroppedInventory(), pos.getX(), pos.getY(), pos.getZ());
}
super.breakBlock(world, pos, state);
}
} }

132
src/main/java/refinedstorage/block/BlockCable.java Normal file → Executable file
View File

@@ -1,5 +1,6 @@
package refinedstorage.block; package refinedstorage.block;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
@@ -9,84 +10,77 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.tile.TileCable; import refinedstorage.tile.TileController;
import refinedstorage.tile.TileMachine;
public class BlockCable extends BlockBase public class BlockCable extends BlockBase {
{ public static final PropertyBool NORTH = PropertyBool.create("north");
public static final PropertyBool NORTH = PropertyBool.create("north"); public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool EAST = PropertyBool.create("east"); public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool SOUTH = PropertyBool.create("south"); public static final PropertyBool WEST = PropertyBool.create("west");
public static final PropertyBool WEST = PropertyBool.create("west"); public static final PropertyBool UP = PropertyBool.create("up");
public static final PropertyBool UP = PropertyBool.create("up"); public static final PropertyBool DOWN = PropertyBool.create("down");
public static final PropertyBool DOWN = PropertyBool.create("down");
public BlockCable() public BlockCable() {
{ super("cable");
super("cable"); }
}
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState() {
{ return new BlockStateContainer(this, new IProperty[]
return new BlockStateContainer(this, new IProperty[] {
{ DIRECTION,
DIRECTION, NORTH,
NORTH, EAST,
EAST, SOUTH,
SOUTH, WEST,
WEST, UP,
UP, DOWN,
DOWN, });
}); }
}
@Override @Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ return super.getActualState(state, world, pos)
return super.getActualState(state, world, pos) .withProperty(NORTH, hasConnectionWith(world, pos.north()))
.withProperty(NORTH, TileCable.hasConnectionWith(world, pos.north())) .withProperty(EAST, hasConnectionWith(world, pos.east()))
.withProperty(EAST, TileCable.hasConnectionWith(world, pos.east())) .withProperty(SOUTH, hasConnectionWith(world, pos.south()))
.withProperty(SOUTH, TileCable.hasConnectionWith(world, pos.south())) .withProperty(WEST, hasConnectionWith(world, pos.west()))
.withProperty(WEST, TileCable.hasConnectionWith(world, pos.west())) .withProperty(UP, hasConnectionWith(world, pos.up()))
.withProperty(UP, TileCable.hasConnectionWith(world, pos.up())) .withProperty(DOWN, hasConnectionWith(world, pos.down()));
.withProperty(DOWN, TileCable.hasConnectionWith(world, pos.down())); }
}
@Override public static boolean hasConnectionWith(IBlockAccess world, BlockPos pos) {
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) Block block = world.getBlockState(pos).getBlock();
{
float pixel = 1F / 16F;
return new AxisAlignedBB(4 * pixel, 4 * pixel, 4 * pixel, 1 - 4 * pixel, 1 - 4 * pixel, 1 - 4 * pixel); if (block instanceof BlockCable) {
} return true;
}
@Override TileEntity tile = world.getTileEntity(pos);
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos)
{
return getBoundingBox(state, world, pos);
}
@Override return tile instanceof TileMachine || tile instanceof TileController;
public boolean hasTileEntity(IBlockState state) }
{
return true;
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
{ float pixel = 1F / 16F;
return new TileCable();
}
@Override return new AxisAlignedBB(4 * pixel, 4 * pixel, 4 * pixel, 1 - 4 * pixel, 1 - 4 * pixel, 1 - 4 * pixel);
public boolean isOpaqueCube(IBlockState state) }
{
return false;
}
@Override @Override
public boolean isFullCube(IBlockState state) public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos) {
{ return getBoundingBox(state, world, pos);
return false; }
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
} }

View File

@@ -6,32 +6,28 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileConstructor; import refinedstorage.tile.TileConstructor;
public class BlockConstructor extends BlockMachine public class BlockConstructor extends BlockMachine {
{ public BlockConstructor() {
public BlockConstructor() super("constructor");
{ }
super("constructor");
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileConstructor();
return new TileConstructor(); }
}
@Override @Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
{ if (!world.isRemote) {
if (!world.isRemote) player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.CONSTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
{ }
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.CONSTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; return true;
} }
} }

142
src/main/java/refinedstorage/block/BlockController.java Normal file → Executable file
View File

@@ -1,6 +1,5 @@
package refinedstorage.block; package refinedstorage.block;
import java.util.List;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.properties.PropertyInteger;
@@ -20,95 +19,82 @@ import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileController; import refinedstorage.tile.TileController;
public class BlockController extends BlockBase import java.util.List;
{
public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumControllerType.class);
public static final PropertyInteger ENERGY = PropertyInteger.create("energy", 0, 8);
public BlockController() public class BlockController extends BlockBase {
{ public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumControllerType.class);
super("controller"); public static final PropertyInteger ENERGY = PropertyInteger.create("energy", 0, 8);
}
@Override public BlockController() {
public void getSubBlocks(Item item, CreativeTabs tab, List subItems) super("controller");
{ }
for (int i = 0; i <= 1; i++)
{
subItems.add(new ItemStack(item, 1, i));
}
}
@Override @Override
protected BlockStateContainer createBlockState() public void getSubBlocks(Item item, CreativeTabs tab, List subItems) {
{ for (int i = 0; i <= 1; i++) {
return new BlockStateContainer(this, new IProperty[] subItems.add(new ItemStack(item, 1, i));
{ }
DIRECTION, }
TYPE,
ENERGY
});
}
@Override @Override
public IBlockState getStateFromMeta(int meta) protected BlockStateContainer createBlockState() {
{ return new BlockStateContainer(this, new IProperty[]
return getDefaultState().withProperty(TYPE, meta == 0 ? EnumControllerType.NORMAL : EnumControllerType.CREATIVE); {
} DIRECTION,
TYPE,
ENERGY
});
}
@Override @Override
public int getMetaFromState(IBlockState state) public IBlockState getStateFromMeta(int meta) {
{ return getDefaultState().withProperty(TYPE, meta == 0 ? EnumControllerType.NORMAL : EnumControllerType.CREATIVE);
return state.getValue(TYPE) == EnumControllerType.NORMAL ? 0 : 1; }
}
@Override @Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) public int getMetaFromState(IBlockState state) {
{ return state.getValue(TYPE) == EnumControllerType.NORMAL ? 0 : 1;
return super.getActualState(state, world, pos) }
.withProperty(ENERGY, ((TileController) world.getTileEntity(pos)).getEnergyScaled(8));
}
@Override @Override
public boolean hasTileEntity(IBlockState state) public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ return super.getActualState(state, world, pos)
return true; .withProperty(ENERGY, ((TileController) world.getTileEntity(pos)).getEnergyScaled(8));
} }
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public boolean hasTileEntity(IBlockState state) {
{ return true;
return new TileController(); }
}
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileController();
if (!world.isRemote) }
{
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.CONTROLLER, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; @Override
} public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.CONTROLLER, world, pos.getX(), pos.getY(), pos.getZ());
}
@Override return true;
public void breakBlock(World world, BlockPos pos, IBlockState state) }
{
((TileController) world.getTileEntity(pos)).onDestroyed();
super.breakBlock(world, pos, state); @Override
} public void breakBlock(World world, BlockPos pos, IBlockState state) {
((TileController) world.getTileEntity(pos)).onDestroyed();
@Override super.breakBlock(world, pos, state);
public boolean hasComparatorInputOverride(IBlockState state) }
{
return true;
}
@Override @Override
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) public boolean hasComparatorInputOverride(IBlockState state) {
{ return true;
return ((TileController) world.getTileEntity(pos)).getEnergyScaled(15); }
}
@Override
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
return ((TileController) world.getTileEntity(pos)).getEnergyScaled(15);
}
} }

36
src/main/java/refinedstorage/block/BlockDestructor.java Normal file → Executable file
View File

@@ -6,32 +6,28 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileDestructor; import refinedstorage.tile.TileDestructor;
public class BlockDestructor extends BlockMachine public class BlockDestructor extends BlockMachine {
{ public BlockDestructor() {
public BlockDestructor() super("destructor");
{ }
super("destructor");
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileDestructor();
return new TileDestructor(); }
}
@Override @Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
{ if (!world.isRemote) {
if (!world.isRemote) player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DESTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
{ }
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DESTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; return true;
} }
} }

103
src/main/java/refinedstorage/block/BlockDetector.java Normal file → Executable file
View File

@@ -16,72 +16,61 @@ import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileDetector; import refinedstorage.tile.TileDetector;
public class BlockDetector extends BlockMachine public class BlockDetector extends BlockMachine {
{ public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyBool POWERED = PropertyBool.create("powered");
public BlockDetector() public BlockDetector() {
{ super("detector");
super("detector"); }
}
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState() {
{ return new BlockStateContainer(this, new IProperty[]
return new BlockStateContainer(this, new IProperty[] {
{ DIRECTION,
DIRECTION, CONNECTED,
CONNECTED, POWERED
POWERED });
}); }
}
@Override @Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ return super.getActualState(state, world, pos)
return super.getActualState(state, world, pos) .withProperty(POWERED, ((TileDetector) world.getTileEntity(pos)).isPowered());
.withProperty(POWERED, ((TileDetector) world.getTileEntity(pos)).isPowered()); }
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileDetector();
return new TileDetector(); }
}
@Override @Override
public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
{ TileDetector detector = (TileDetector) world.getTileEntity(pos);
TileDetector detector = (TileDetector) world.getTileEntity(pos);
if (detector.getDirection() == side.getOpposite()) if (detector.getDirection() == side.getOpposite()) {
{ return detector.isPowered() ? 15 : 0;
return detector.isPowered() ? 15 : 0; }
}
return 0; return 0;
} }
@Override @Override
public int getStrongPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) public int getStrongPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
{ return getWeakPower(state, world, pos, side);
return getWeakPower(state, world, pos, side); }
}
@Override @Override
public boolean canProvidePower(IBlockState state) public boolean canProvidePower(IBlockState state) {
{ return true;
return true; }
}
@Override @Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
{ if (!world.isRemote) {
if (!world.isRemote) player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DETECTOR, world, pos.getX(), pos.getY(), pos.getZ());
{ }
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DETECTOR, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; return true;
} }
} }

View File

@@ -0,0 +1,33 @@
package refinedstorage.block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileDiskDrive;
public class BlockDiskDrive extends BlockMachine {
public BlockDiskDrive() {
super("disk_drive");
}
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
return new TileDiskDrive();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DISK_DRIVE, world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
}

View File

@@ -1,37 +0,0 @@
package refinedstorage.block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileDrive;
public class BlockDrive extends BlockMachine
{
public BlockDrive()
{
super("drive");
}
@Override
public TileEntity createTileEntity(World world, IBlockState state)
{
return new TileDrive();
}
@Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote)
{
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DRIVE, world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
}

36
src/main/java/refinedstorage/block/BlockExporter.java Normal file → Executable file
View File

@@ -6,32 +6,28 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileExporter; import refinedstorage.tile.TileExporter;
public class BlockExporter extends BlockMachine public class BlockExporter extends BlockMachine {
{ public BlockExporter() {
public BlockExporter() super("exporter");
{ }
super("exporter");
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileExporter();
return new TileExporter(); }
}
@Override @Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
{ if (!world.isRemote) {
if (!world.isRemote) player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.EXPORTER, world, pos.getX(), pos.getY(), pos.getZ());
{ }
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.EXPORTER, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; return true;
} }
} }

View File

@@ -6,32 +6,28 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileExternalStorage; import refinedstorage.tile.TileExternalStorage;
public class BlockExternalStorage extends BlockMachine public class BlockExternalStorage extends BlockMachine {
{ public BlockExternalStorage() {
public BlockExternalStorage() super("external_storage");
{ }
super("external_storage");
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileExternalStorage();
return new TileExternalStorage(); }
}
@Override @Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
{ if (!world.isRemote) {
if (!world.isRemote) player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.STORAGE, world, pos.getX(), pos.getY(), pos.getZ());
{ }
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.STORAGE, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; return true;
} }
} }

91
src/main/java/refinedstorage/block/BlockGrid.java Normal file → Executable file
View File

@@ -1,6 +1,5 @@
package refinedstorage.block; package refinedstorage.block;
import java.util.List;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
@@ -18,61 +17,53 @@ import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileGrid; import refinedstorage.tile.TileGrid;
public class BlockGrid extends BlockMachine import java.util.List;
{
public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumGridType.class);
public BlockGrid() public class BlockGrid extends BlockMachine {
{ public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumGridType.class);
super("grid");
}
@Override public BlockGrid() {
public TileEntity createTileEntity(World world, IBlockState state) super("grid");
{ }
return new TileGrid();
}
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tab, List subItems) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileGrid();
for (int i = 0; i <= 1; i++) }
{
subItems.add(new ItemStack(item, 1, i));
}
}
@Override @Override
protected BlockStateContainer createBlockState() public void getSubBlocks(Item item, CreativeTabs tab, List subItems) {
{ for (int i = 0; i <= 1; i++) {
return new BlockStateContainer(this, new IProperty[] subItems.add(new ItemStack(item, 1, i));
{ }
DIRECTION, }
CONNECTED,
TYPE
});
}
@Override @Override
public IBlockState getStateFromMeta(int meta) protected BlockStateContainer createBlockState() {
{ return new BlockStateContainer(this, new IProperty[]
return getDefaultState().withProperty(TYPE, meta == 0 ? EnumGridType.NORMAL : EnumGridType.CRAFTING); {
} DIRECTION,
CONNECTED,
TYPE
});
}
@Override @Override
public int getMetaFromState(IBlockState state) public IBlockState getStateFromMeta(int meta) {
{ return getDefaultState().withProperty(TYPE, meta == 0 ? EnumGridType.NORMAL : EnumGridType.CRAFTING);
return state.getValue(TYPE) == EnumGridType.NORMAL ? 0 : 1; }
}
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public int getMetaFromState(IBlockState state) {
{ return state.getValue(TYPE) == EnumGridType.NORMAL ? 0 : 1;
if (!world.isRemote) }
{
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.GRID, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; @Override
} public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.GRID, world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
} }

36
src/main/java/refinedstorage/block/BlockImporter.java Normal file → Executable file
View File

@@ -6,32 +6,28 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileImporter; import refinedstorage.tile.TileImporter;
public class BlockImporter extends BlockMachine public class BlockImporter extends BlockMachine {
{ public BlockImporter() {
public BlockImporter() super("importer");
{ }
super("importer");
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileImporter();
return new TileImporter(); }
}
@Override @Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
{ if (!world.isRemote) {
if (!world.isRemote) player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.IMPORTER, world, pos.getX(), pos.getY(), pos.getZ());
{ }
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.IMPORTER, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; return true;
} }
} }

36
src/main/java/refinedstorage/block/BlockInterface.java Normal file → Executable file
View File

@@ -6,32 +6,28 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileInterface; import refinedstorage.tile.TileInterface;
public class BlockInterface extends BlockMachine public class BlockInterface extends BlockMachine {
{ public BlockInterface() {
public BlockInterface() super("interface");
{ }
super("interface");
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileInterface();
return new TileInterface(); }
}
@Override @Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
{ if (!world.isRemote) {
if (!world.isRemote) player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.INTERFACE, world, pos.getX(), pos.getY(), pos.getZ());
{ }
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.INTERFACE, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; return true;
} }
} }

49
src/main/java/refinedstorage/block/BlockMachine.java Normal file → Executable file
View File

@@ -8,35 +8,30 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import refinedstorage.tile.TileMachine; import refinedstorage.tile.TileMachine;
public abstract class BlockMachine extends BlockBase public abstract class BlockMachine extends BlockBase {
{ public static final PropertyBool CONNECTED = PropertyBool.create("connected");
public static final PropertyBool CONNECTED = PropertyBool.create("connected");
public BlockMachine(String name) public BlockMachine(String name) {
{ super(name);
super(name); }
}
@Override @Override
public boolean hasTileEntity(IBlockState state) public boolean hasTileEntity(IBlockState state) {
{ return true;
return true; }
}
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState() {
{ return new BlockStateContainer(this, new IProperty[]
return new BlockStateContainer(this, new IProperty[] {
{ DIRECTION,
DIRECTION, CONNECTED
CONNECTED });
}); }
}
@Override @Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ return super.getActualState(state, world, pos)
return super.getActualState(state, world, pos) .withProperty(CONNECTED, ((TileMachine) world.getTileEntity(pos)).isConnected());
.withProperty(CONNECTED, ((TileMachine) world.getTileEntity(pos)).isConnected()); }
}
} }

View File

@@ -1,9 +1,7 @@
package refinedstorage.block; package refinedstorage.block;
public class BlockMachineCasing extends BlockBase public class BlockMachineCasing extends BlockBase {
{ public BlockMachineCasing() {
public BlockMachineCasing() super("machine_casing");
{ }
super("machine_casing");
}
} }

35
src/main/java/refinedstorage/block/BlockRelay.java Normal file → Executable file
View File

@@ -12,27 +12,22 @@ import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileRelay; import refinedstorage.tile.TileRelay;
public class BlockRelay extends BlockMachine public class BlockRelay extends BlockMachine {
{ public BlockRelay() {
public BlockRelay() super("relay");
{ }
super("relay");
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileRelay();
return new TileRelay(); }
}
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
{ if (!world.isRemote) {
if (!world.isRemote) player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.RELAY, world, pos.getX(), pos.getY(), pos.getZ());
{ }
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.RELAY, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; return true;
} }
} }

36
src/main/java/refinedstorage/block/BlockSolderer.java Normal file → Executable file
View File

@@ -6,32 +6,28 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileSolderer; import refinedstorage.tile.TileSolderer;
public class BlockSolderer extends BlockMachine public class BlockSolderer extends BlockMachine {
{ public BlockSolderer() {
public BlockSolderer() super("solderer");
{ }
super("solderer");
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileSolderer();
return new TileSolderer(); }
}
@Override @Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
{ if (!world.isRemote) {
if (!world.isRemote) player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.SOLDERER, world, pos.getX(), pos.getY(), pos.getZ());
{ }
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.SOLDERER, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; return true;
} }
} }

159
src/main/java/refinedstorage/block/BlockStorage.java Normal file → Executable file
View File

@@ -1,7 +1,5 @@
package refinedstorage.block; package refinedstorage.block;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
@@ -24,111 +22,98 @@ import refinedstorage.RefinedStorageGui;
import refinedstorage.item.ItemBlockStorage; import refinedstorage.item.ItemBlockStorage;
import refinedstorage.tile.TileStorage; import refinedstorage.tile.TileStorage;
public class BlockStorage extends BlockMachine import java.util.ArrayList;
{ import java.util.List;
public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumStorageType.class);
public BlockStorage() public class BlockStorage extends BlockMachine {
{ public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumStorageType.class);
super("storage");
}
@Override public BlockStorage() {
public void getSubBlocks(Item item, CreativeTabs tab, List subItems) super("storage");
{ }
for (int i = 0; i <= 4; i++)
{
subItems.add(ItemBlockStorage.initNBT(new ItemStack(item, 1, i)));
}
}
@Override @Override
protected BlockStateContainer createBlockState() public void getSubBlocks(Item item, CreativeTabs tab, List subItems) {
{ for (int i = 0; i <= 4; i++) {
return new BlockStateContainer(this, new IProperty[] subItems.add(ItemBlockStorage.initNBT(new ItemStack(item, 1, i)));
{ }
DIRECTION, }
CONNECTED,
TYPE
});
}
@Override @Override
public IBlockState getStateFromMeta(int meta) protected BlockStateContainer createBlockState() {
{ return new BlockStateContainer(this, new IProperty[]
return getDefaultState().withProperty(TYPE, EnumStorageType.getById(meta)); {
} DIRECTION,
CONNECTED,
TYPE
});
}
@Override @Override
public int getMetaFromState(IBlockState state) public IBlockState getStateFromMeta(int meta) {
{ return getDefaultState().withProperty(TYPE, EnumStorageType.getById(meta));
return ((EnumStorageType) state.getValue(TYPE)).getId(); }
}
@Override @Override
public TileEntity createTileEntity(World world, IBlockState state) public int getMetaFromState(IBlockState state) {
{ return ((EnumStorageType) state.getValue(TYPE)).getId();
return new TileStorage(); }
}
@Override @Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public TileEntity createTileEntity(World world, IBlockState state) {
{ return new TileStorage();
if (!world.isRemote) }
{
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.STORAGE, world, pos.getX(), pos.getY(), pos.getZ());
}
return true; @Override
} public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.STORAGE, world, pos.getX(), pos.getY(), pos.getZ());
}
@Override return true;
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) }
{
super.onBlockPlacedBy(world, pos, state, player, stack);
NBTTagCompound tag = stack.getTagCompound(); @Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, player, stack);
if (tag != null && tag.hasKey(TileStorage.NBT_STORAGE)) NBTTagCompound tag = stack.getTagCompound();
{
((TileStorage) world.getTileEntity(pos)).setStorageTag((NBTTagCompound) tag.getTag(TileStorage.NBT_STORAGE));
}
}
@Override if (tag != null && tag.hasKey(TileStorage.NBT_STORAGE)) {
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) ((TileStorage) world.getTileEntity(pos)).setStorageTag((NBTTagCompound) tag.getTag(TileStorage.NBT_STORAGE));
{ }
List<ItemStack> drops = new ArrayList<ItemStack>(); }
ItemStack stack = new ItemStack(RefinedStorageBlocks.STORAGE, 1, RefinedStorageBlocks.STORAGE.getMetaFromState(state)); @Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
List<ItemStack> drops = new ArrayList<ItemStack>();
NBTTagCompound tag = new NBTTagCompound(); ItemStack stack = new ItemStack(RefinedStorageBlocks.STORAGE, 1, RefinedStorageBlocks.STORAGE.getMetaFromState(state));
tag.setTag(TileStorage.NBT_STORAGE, ((TileStorage) world.getTileEntity(pos)).getStorageTag()); NBTTagCompound tag = new NBTTagCompound();
stack.setTagCompound(tag); tag.setTag(TileStorage.NBT_STORAGE, ((TileStorage) world.getTileEntity(pos)).getStorageTag());
drops.add(stack); stack.setTagCompound(tag);
return drops; drops.add(stack);
}
@Override return drops;
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) }
{
if (willHarvest)
{
return true;
}
return super.removedByPlayer(state, world, pos, player, willHarvest); @Override
} public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
if (willHarvest) {
return true;
}
@Override return super.removedByPlayer(state, world, pos, player, willHarvest);
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack stack) }
{
super.harvestBlock(world, player, pos, state, tile, stack);
world.setBlockToAir(pos); @Override
} public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack stack) {
super.harvestBlock(world, player, pos, state, tile, stack);
world.setBlockToAir(pos);
}
} }

View File

@@ -1,62 +0,0 @@
package refinedstorage.block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileWirelessTransmitter;
public class BlockWirelessTransmitter extends BlockMachine
{
public static final PropertyBool WORKING = PropertyBool.create("working");
public BlockWirelessTransmitter()
{
super("wireless_transmitter");
}
@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[]
{
DIRECTION,
CONNECTED,
WORKING
});
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
{
return super.getActualState(state, world, pos)
.withProperty(WORKING, ((TileWirelessTransmitter) world.getTileEntity(pos)).isWorking());
}
@Override
public TileEntity createTileEntity(World world, IBlockState state)
{
return new TileWirelessTransmitter();
}
@Override
public boolean onBlockActivated(World world, net.minecraft.util.math.BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote)
{
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.WIRELESS_TRANSMITTER, world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
}

View File

@@ -2,34 +2,29 @@ package refinedstorage.block;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
public enum EnumControllerType implements IStringSerializable public enum EnumControllerType implements IStringSerializable {
{ NORMAL(0, "normal"),
NORMAL(0, "normal"), CREATIVE(1, "creative");
CREATIVE(1, "creative");
private int id; private int id;
private String name; private String name;
EnumControllerType(int id, String name) EnumControllerType(int id, String name) {
{ this.id = id;
this.id = id; this.name = name;
this.name = name; }
}
@Override @Override
public String getName() public String getName() {
{ return name;
return name; }
}
public int getId() public int getId() {
{ return id;
return id; }
}
@Override @Override
public String toString() public String toString() {
{ return name;
return name; }
}
} }

45
src/main/java/refinedstorage/block/EnumGridType.java Normal file → Executable file
View File

@@ -2,35 +2,30 @@ package refinedstorage.block;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
public enum EnumGridType implements IStringSerializable public enum EnumGridType implements IStringSerializable {
{ NORMAL(0, "normal"),
NORMAL(0, "normal"), CRAFTING(1, "crafting");
CRAFTING(1, "crafting");
private int id; private int id;
private String name; private String name;
EnumGridType(int id, String name) EnumGridType(int id, String name) {
{ this.id = id;
this.id = id; this.name = name;
this.name = name; }
}
@Override @Override
public String getName() public String getName() {
{ return name;
return name; }
}
public int getId() public int getId() {
{ return id;
return id; }
}
@Override @Override
public String toString() public String toString() {
{ return name;
return name; }
}
} }

81
src/main/java/refinedstorage/block/EnumStorageType.java Normal file → Executable file
View File

@@ -2,57 +2,48 @@ package refinedstorage.block;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
public enum EnumStorageType implements IStringSerializable public enum EnumStorageType implements IStringSerializable {
{ TYPE_1K(0, 1000, "1k"),
TYPE_1K(0, 1000, "1k"), TYPE_4K(1, 4000, "4k"),
TYPE_4K(1, 4000, "4k"), TYPE_16K(2, 16000, "16k"),
TYPE_16K(2, 16000, "16k"), TYPE_64K(3, 64000, "64k"),
TYPE_64K(3, 64000, "64k"), TYPE_CREATIVE(4, -1, "creative");
TYPE_CREATIVE(4, -1, "creative");
private int id; private int id;
private int capacity; private int capacity;
private String name; private String name;
EnumStorageType(int id, int capacity, String name) EnumStorageType(int id, int capacity, String name) {
{ this.id = id;
this.id = id; this.capacity = capacity;
this.capacity = capacity; this.name = name;
this.name = name; }
}
@Override @Override
public String getName() public String getName() {
{ return name;
return name; }
}
public int getId() public int getId() {
{ return id;
return id; }
}
public int getCapacity() public int getCapacity() {
{ return capacity;
return capacity; }
}
@Override @Override
public String toString() public String toString() {
{ return name;
return name; }
}
public static EnumStorageType getById(int id) public static EnumStorageType getById(int id) {
{ for (EnumStorageType type : EnumStorageType.values()) {
for (EnumStorageType type : EnumStorageType.values()) if (type.getId() == id) {
{ return type;
if (type.getId() == id) }
{ }
return type;
}
}
return null; return null;
} }
} }

201
src/main/java/refinedstorage/container/ContainerBase.java Normal file → Executable file
View File

@@ -1,7 +1,5 @@
package refinedstorage.container; package refinedstorage.container;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ClickType; import net.minecraft.inventory.ClickType;
@@ -9,143 +7,120 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import refinedstorage.container.slot.SlotDisabled; import refinedstorage.container.slot.SlotDisabled;
import refinedstorage.container.slot.SlotGridCraftingResult;
import refinedstorage.container.slot.SlotSpecimen; import refinedstorage.container.slot.SlotSpecimen;
public abstract class ContainerBase extends Container import java.util.ArrayList;
{ import java.util.List;
private EntityPlayer player;
private List<Slot> playerInventorySlots = new ArrayList<Slot>(); public abstract class ContainerBase extends Container {
private EntityPlayer player;
public ContainerBase(EntityPlayer player) private List<Slot> playerInventorySlots = new ArrayList<Slot>();
{
this.player = player;
}
public EntityPlayer getPlayer() public ContainerBase(EntityPlayer player) {
{ this.player = player;
return player; }
}
protected void addPlayerInventory(int xInventory, int yInventory) public EntityPlayer getPlayer() {
{ return player;
int id = 0; }
for (int i = 0; i < 9; i++) protected void addPlayerInventory(int xInventory, int yInventory) {
{ int id = 0;
Slot slot = new Slot(player.inventory, id, xInventory + i * 18, yInventory + 4 + (3 * 18));
playerInventorySlots.add(slot); for (int i = 0; i < 9; i++) {
Slot slot = new Slot(player.inventory, id, xInventory + i * 18, yInventory + 4 + (3 * 18));
addSlotToContainer(slot); playerInventorySlots.add(slot);
id++; addSlotToContainer(slot);
}
for (int y = 0; y < 3; y++) id++;
{ }
for (int x = 0; x < 9; x++)
{
Slot slot = new Slot(player.inventory, id, xInventory + x * 18, yInventory + y * 18);
playerInventorySlots.add(slot); for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
Slot slot = new Slot(player.inventory, id, xInventory + x * 18, yInventory + y * 18);
addSlotToContainer(slot); playerInventorySlots.add(slot);
id++; addSlotToContainer(slot);
}
}
}
@Override id++;
public ItemStack func_184996_a(int id, int clickedButton, ClickType clickType, EntityPlayer player) }
{ }
Slot slot = id >= 0 ? getSlot(id) : null; }
if (slot instanceof SlotSpecimen) @Override
{ public ItemStack func_184996_a(int id, int clickedButton, ClickType clickType, EntityPlayer player) {
if (((SlotSpecimen) slot).isSizeAllowed()) Slot slot = id >= 0 ? getSlot(id) : null;
{
if (player.inventory.getItemStack() != null)
{
int amount = player.inventory.getItemStack().stackSize;
if (clickedButton == 1) if (slot instanceof SlotSpecimen) {
{ if (((SlotSpecimen) slot).isSizeAllowed()) {
amount = 1; if (slot.getStack() != null) {
} if (GuiScreen.isShiftKeyDown()) {
slot.putStack(null);
} else {
int amount = slot.getStack().stackSize;
ItemStack toPut = player.inventory.getItemStack().copy(); if (clickedButton == 0) {
toPut.stackSize = amount; amount--;
slot.putStack(toPut); if (amount < 1) {
} amount = 1;
else if (slot.getStack() != null) }
{ } else if (clickedButton == 1) {
if (GuiScreen.isShiftKeyDown()) amount++;
{
slot.putStack(null);
}
else
{
int amount = slot.getStack().stackSize;
if (clickedButton == 0) if (amount > 64) {
{ amount = 64;
amount++; }
}
if (amount > 64) slot.getStack().stackSize = amount;
{ }
amount = 64; } else if (player.inventory.getItemStack() != null) {
} int amount = player.inventory.getItemStack().stackSize;
}
else if (clickedButton == 1)
{
amount--;
if (amount < 1) if (clickedButton == 1) {
{ amount = 1;
amount = 1; }
}
}
slot.getStack().stackSize = amount; ItemStack toPut = player.inventory.getItemStack().copy();
} toPut.stackSize = amount;
}
}
else if (player.inventory.getItemStack() == null)
{
slot.putStack(null);
}
else if (slot.isItemValid(player.inventory.getItemStack()))
{
slot.putStack(player.inventory.getItemStack().copy());
}
return player.inventory.getItemStack(); slot.putStack(toPut);
} }
else if (slot instanceof SlotDisabled) } else if (player.inventory.getItemStack() == null) {
{ slot.putStack(null);
return null; } else if (slot.isItemValid(player.inventory.getItemStack())) {
} slot.putStack(player.inventory.getItemStack().copy());
}
return super.func_184996_a(id, clickedButton, clickType, player); return player.inventory.getItemStack();
} } else if (slot instanceof SlotGridCraftingResult && slot.getHasStack() && GuiScreen.isShiftKeyDown()) {
((SlotGridCraftingResult) slot).onShiftClick(player);
@Override return null;
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) } else if (slot instanceof SlotDisabled) {
{ return null;
return null; }
}
@Override return super.func_184996_a(id, clickedButton, clickType, player);
public boolean canInteractWith(EntityPlayer player) }
{
return true;
}
public List<Slot> getPlayerInventorySlots() @Override
{ public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
return playerInventorySlots; return null;
} }
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
public List<Slot> getPlayerInventorySlots() {
return playerInventorySlots;
}
} }

View File

@@ -1,34 +1,16 @@
package refinedstorage.container; package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import refinedstorage.container.slot.SlotSpecimenItemBlock;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import refinedstorage.container.slot.SlotSpecimen;
import refinedstorage.tile.TileConstructor; import refinedstorage.tile.TileConstructor;
public class ContainerConstructor extends ContainerBase public class ContainerConstructor extends ContainerBase {
{
class SlotConstructor extends SlotSpecimen
{
public SlotConstructor(IInventory inventory, int id, int x, int y)
{
super(inventory, id, x, y, false);
}
@Override public ContainerConstructor(EntityPlayer player, TileConstructor constructor) {
public boolean isItemValid(ItemStack stack) super(player);
{
return stack.getItem() instanceof ItemBlock;
}
}
public ContainerConstructor(EntityPlayer player, TileConstructor constructor) addSlotToContainer(new SlotSpecimenItemBlock(constructor.getInventory(), 0, 80, 20));
{
super(player);
addSlotToContainer(new SlotConstructor(constructor.getInventory(), 0, 80, 20)); addPlayerInventory(8, 55);
}
addPlayerInventory(8, 55);
}
} }

View File

@@ -2,12 +2,10 @@ package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
public class ContainerController extends ContainerBase public class ContainerController extends ContainerBase {
{ public ContainerController(EntityPlayer player) {
public ContainerController(EntityPlayer player) super(player);
{
super(player);
addPlayerInventory(8, 99); addPlayerInventory(8, 99);
} }
} }

View File

@@ -1,13 +1,17 @@
package refinedstorage.container; package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import refinedstorage.container.slot.SlotSpecimenItemBlock;
import refinedstorage.tile.TileDestructor;
public class ContainerDestructor extends ContainerBase public class ContainerDestructor extends ContainerBase {
{ public ContainerDestructor(EntityPlayer player, TileDestructor destructor) {
public ContainerDestructor(EntityPlayer player) super(player);
{
super(player);
addPlayerInventory(8, 50); for (int i = 0; i < 9; ++i) {
} addSlotToContainer(new SlotSpecimenItemBlock(destructor.getInventory(), i, 8 + (18 * i), 20));
}
addPlayerInventory(8, 55);
}
} }

View File

@@ -4,14 +4,12 @@ import net.minecraft.entity.player.EntityPlayer;
import refinedstorage.container.slot.SlotSpecimen; import refinedstorage.container.slot.SlotSpecimen;
import refinedstorage.tile.TileDetector; import refinedstorage.tile.TileDetector;
public class ContainerDetector extends ContainerBase public class ContainerDetector extends ContainerBase {
{ public ContainerDetector(EntityPlayer player, TileDetector detector) {
public ContainerDetector(EntityPlayer player, TileDetector detector) super(player);
{
super(player);
addSlotToContainer(new SlotSpecimen(detector.getInventory(), 0, 107, 20, false)); addSlotToContainer(new SlotSpecimen(detector.getInventory(), 0, 107, 20, false));
addPlayerInventory(8, 55); addPlayerInventory(8, 55);
} }
} }

View File

@@ -0,0 +1,52 @@
package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import refinedstorage.RefinedStorageItems;
import refinedstorage.container.slot.BasicItemValidator;
import refinedstorage.container.slot.SlotFiltered;
import refinedstorage.tile.TileDiskDrive;
public class ContainerDiskDrive extends ContainerStorage {
public ContainerDiskDrive(EntityPlayer player, TileDiskDrive drive) {
super(player);
for (int i = 0; i < 4; ++i) {
addSlotToContainer(new SlotFiltered(drive, i, 98 + (i * 18), 78, new BasicItemValidator(RefinedStorageItems.STORAGE_DISK)));
}
for (int i = 0; i < 4; ++i) {
addSlotToContainer(new SlotFiltered(drive, 4 + i, 98 + (i * 18), 96, new BasicItemValidator(RefinedStorageItems.STORAGE_DISK)));
}
addSpecimenAndPlayerInventorySlots(drive.getInventory());
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
ItemStack stack = null;
Slot slot = getSlot(index);
if (slot != null && slot.getHasStack()) {
stack = slot.getStack().copy();
if (index < 8) {
if (!mergeItemStack(stack, 8, inventorySlots.size(), true)) {
return null;
}
} else if (!mergeItemStack(stack, 0, 8, false)) {
return null;
}
if (stack.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
}
return stack;
}
}

View File

@@ -1,25 +0,0 @@
package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer;
import refinedstorage.RefinedStorageItems;
import refinedstorage.container.slot.BasicItemValidator;
import refinedstorage.container.slot.SlotFiltered;
import refinedstorage.tile.TileDrive;
public class ContainerDrive extends ContainerStorage
{
public ContainerDrive(EntityPlayer player, TileDrive drive)
{
super(player, drive.getInventory());
for (int i = 0; i < 4; ++i)
{
addSlotToContainer(new SlotFiltered(drive, i, 98 + (i * 18), 78, new BasicItemValidator(RefinedStorageItems.STORAGE_CELL)));
}
for (int i = 0; i < 4; ++i)
{
addSlotToContainer(new SlotFiltered(drive, 4 + i, 98 + (i * 18), 96, new BasicItemValidator(RefinedStorageItems.STORAGE_CELL)));
}
}
}

View File

@@ -4,17 +4,14 @@ import net.minecraft.entity.player.EntityPlayer;
import refinedstorage.container.slot.SlotSpecimen; import refinedstorage.container.slot.SlotSpecimen;
import refinedstorage.tile.TileExporter; import refinedstorage.tile.TileExporter;
public class ContainerExporter extends ContainerBase public class ContainerExporter extends ContainerBase {
{ public ContainerExporter(EntityPlayer player, TileExporter exporter) {
public ContainerExporter(EntityPlayer player, TileExporter exporter) super(player);
{
super(player);
for (int i = 0; i < 9; ++i) for (int i = 0; i < 9; ++i) {
{ addSlotToContainer(new SlotSpecimen(exporter.getInventory(), i, 8 + (18 * i), 20, false));
addSlotToContainer(new SlotSpecimen(exporter.getInventory(), i, 8 + (18 * i), 20, false)); }
}
addPlayerInventory(8, 55); addPlayerInventory(8, 55);
} }
} }

View File

@@ -1,42 +1,76 @@
package refinedstorage.container; package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import refinedstorage.block.EnumGridType; import refinedstorage.block.EnumGridType;
import refinedstorage.container.slot.SlotGridCraftingResult; import refinedstorage.container.slot.SlotGridCraftingResult;
import refinedstorage.tile.TileGrid; import refinedstorage.tile.TileGrid;
public class ContainerGrid extends ContainerBase import java.util.ArrayList;
{ import java.util.List;
private TileGrid grid;
public ContainerGrid(EntityPlayer player, TileGrid grid) public class ContainerGrid extends ContainerBase {
{ private List<Slot> craftingSlots = new ArrayList<Slot>();
super(player);
this.grid = grid; private TileGrid grid;
addPlayerInventory(8, grid.getType() == EnumGridType.CRAFTING ? 174 : 108); public ContainerGrid(EntityPlayer player, TileGrid grid) {
super(player);
if (grid.getType() == EnumGridType.CRAFTING) this.grid = grid;
{
int x = 25;
int y = 106;
for (int i = 0; i < 9; ++i) addPlayerInventory(8, grid.getType() == EnumGridType.CRAFTING ? 174 : 126);
{
addSlotToContainer(new Slot(grid.getCraftingInventory(), i, x, y));
x += 18; if (grid.getType() == EnumGridType.CRAFTING) {
int x = 25;
int y = 106;
if ((i + 1) % 3 == 0) for (int i = 0; i < 9; ++i) {
{ Slot slot = new Slot(grid.getCraftingInventory(), i, x, y);
y += 18;
x = 25;
}
}
addSlotToContainer(new SlotGridCraftingResult(player, grid.getCraftingInventory(), grid.getCraftingResultInventory(), grid, 0, 133 + 4, 120 + 4)); craftingSlots.add(slot);
}
} addSlotToContainer(slot);
x += 18;
if ((i + 1) % 3 == 0) {
y += 18;
x = 25;
}
}
addSlotToContainer(new SlotGridCraftingResult(this, player, grid.getCraftingInventory(), grid.getCraftingResultInventory(), grid, 0, 133 + 4, 120 + 4));
}
}
public TileGrid getGrid() {
return grid;
}
public List<Slot> getCraftingSlots() {
return craftingSlots;
}
// I'm overriding detectAndSendChanges() here because the default check
// checks if the item stacks are equal, and if so, then it will only send the new slot contents.
// The thing is though, when the grid replaces the slots with new items from the storage
// system, the item stack replaced WILL be the same and thus changes will not be sent!
// That is why we override here to get rid of the check and ALWAYS send slot changes.
@Override
public void detectAndSendChanges() {
for (int i = 0; i < this.inventorySlots.size(); ++i) {
ItemStack itemstack = ((Slot) this.inventorySlots.get(i)).getStack();
ItemStack itemstack1 = (ItemStack) this.inventoryItemStacks.get(i);
itemstack1 = itemstack == null ? null : itemstack.copy();
this.inventoryItemStacks.set(i, itemstack1);
for (int j = 0; j < this.crafters.size(); ++j) {
((ICrafting) this.crafters.get(j)).sendSlotContents(this, i, itemstack1);
}
}
}
} }

View File

@@ -4,17 +4,14 @@ import net.minecraft.entity.player.EntityPlayer;
import refinedstorage.container.slot.SlotSpecimen; import refinedstorage.container.slot.SlotSpecimen;
import refinedstorage.tile.TileImporter; import refinedstorage.tile.TileImporter;
public class ContainerImporter extends ContainerBase public class ContainerImporter extends ContainerBase {
{ public ContainerImporter(EntityPlayer player, TileImporter importer) {
public ContainerImporter(EntityPlayer player, TileImporter importer) super(player);
{
super(player);
for (int i = 0; i < 9; ++i) for (int i = 0; i < 9; ++i) {
{ addSlotToContainer(new SlotSpecimen(importer.getInventory(), i, 8 + (18 * i), 20, false));
addSlotToContainer(new SlotSpecimen(importer.getInventory(), i, 8 + (18 * i), 20, false)); }
}
addPlayerInventory(8, 55); addPlayerInventory(8, 55);
} }
} }

View File

@@ -7,63 +7,49 @@ import refinedstorage.container.slot.SlotOutput;
import refinedstorage.container.slot.SlotSpecimen; import refinedstorage.container.slot.SlotSpecimen;
import refinedstorage.tile.TileInterface; import refinedstorage.tile.TileInterface;
public class ContainerInterface extends ContainerBase public class ContainerInterface extends ContainerBase {
{ public ContainerInterface(EntityPlayer player, TileInterface tile) {
public ContainerInterface(EntityPlayer player, TileInterface tile) super(player);
{
super(player);
for (int i = 0; i < 9; ++i) for (int i = 0; i < 9; ++i) {
{ addSlotToContainer(new Slot(tile, i, 8 + (18 * i), 20));
addSlotToContainer(new Slot(tile, i, 8 + (18 * i), 20)); }
}
for (int i = 9; i < 18; ++i) for (int i = 9; i < 18; ++i) {
{ addSlotToContainer(new SlotSpecimen(tile, i, 8 + (18 * (i - 9)), 54, true));
addSlotToContainer(new SlotSpecimen(tile, i, 8 + (18 * (i - 9)), 54, true)); }
}
for (int i = 18; i < 27; ++i) for (int i = 18; i < 27; ++i) {
{ addSlotToContainer(new SlotOutput(tile, i, 8 + (18 * (i - 18)), 100));
addSlotToContainer(new SlotOutput(tile, i, 8 + (18 * (i - 18)), 100)); }
}
addPlayerInventory(8, 136); addPlayerInventory(8, 136);
} }
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) public ItemStack transferStackInSlot(EntityPlayer player, int index) {
{ ItemStack stack = null;
ItemStack stack = null;
Slot slot = getSlot(index); Slot slot = getSlot(index);
if (slot != null && slot.getHasStack()) if (slot != null && slot.getHasStack()) {
{ stack = slot.getStack().copy();
stack = slot.getStack().copy();
if (index < 9) if (index < 9) {
{ if (!mergeItemStack(stack, 9, inventorySlots.size(), true)) {
if (!mergeItemStack(stack, 9, inventorySlots.size(), true)) return null;
{ }
return null; } else if (!mergeItemStack(stack, 0, 9, false)) {
} return null;
} }
else if (!mergeItemStack(stack, 0, 9, false))
{
return null;
}
if (stack.stackSize == 0) if (stack.stackSize == 0) {
{ slot.putStack(null);
slot.putStack(null); } else {
} slot.onSlotChanged();
else }
{ }
slot.onSlotChanged();
}
}
return stack; return stack;
} }
} }

View File

@@ -2,12 +2,10 @@ package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
public class ContainerRelay extends ContainerBase public class ContainerRelay extends ContainerBase {
{ public ContainerRelay(EntityPlayer player) {
public ContainerRelay(EntityPlayer player) super(player);
{
super(player);
addPlayerInventory(8, 50); addPlayerInventory(8, 50);
} }
} }

View File

@@ -6,60 +6,48 @@ import net.minecraft.item.ItemStack;
import refinedstorage.container.slot.SlotOutput; import refinedstorage.container.slot.SlotOutput;
import refinedstorage.tile.TileSolderer; import refinedstorage.tile.TileSolderer;
public class ContainerSolderer extends ContainerBase public class ContainerSolderer extends ContainerBase {
{ public ContainerSolderer(EntityPlayer player, TileSolderer solderer) {
public ContainerSolderer(EntityPlayer player, TileSolderer solderer) super(player);
{
super(player);
int x = 44; int x = 44;
int y = 20; int y = 20;
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i) {
{ addSlotToContainer(new Slot(solderer, i, x, y));
addSlotToContainer(new Slot(solderer, i, x, y));
y += 18; y += 18;
} }
addSlotToContainer(new SlotOutput(solderer, 3, 134, 38)); addSlotToContainer(new SlotOutput(solderer, 3, 134, 38));
addPlayerInventory(8, 95); addPlayerInventory(8, 95);
} }
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) public ItemStack transferStackInSlot(EntityPlayer player, int index) {
{ ItemStack stack = null;
ItemStack stack = null;
Slot slot = getSlot(index); Slot slot = getSlot(index);
if (slot != null && slot.getHasStack()) if (slot != null && slot.getHasStack()) {
{ stack = slot.getStack().copy();
stack = slot.getStack().copy();
if (index < 3) if (index < 3) {
{ if (!mergeItemStack(stack, 3, inventorySlots.size(), true)) {
if (!mergeItemStack(stack, 3, inventorySlots.size(), true)) return null;
{ }
return null; } else if (!mergeItemStack(stack, 0, 3, false)) {
} return null;
} }
else if (!mergeItemStack(stack, 0, 3, false))
{
return null;
}
if (stack.stackSize == 0) if (stack.stackSize == 0) {
{ slot.putStack(null);
slot.putStack(null); } else {
} slot.onSlotChanged();
else }
{ }
slot.onSlotChanged();
}
}
return stack; return stack;
} }
} }

View File

@@ -4,17 +4,22 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import refinedstorage.container.slot.SlotSpecimen; import refinedstorage.container.slot.SlotSpecimen;
public class ContainerStorage extends ContainerBase public class ContainerStorage extends ContainerBase {
{ public ContainerStorage(EntityPlayer player) {
public ContainerStorage(EntityPlayer player, IInventory inventory) super(player);
{ }
super(player);
for (int i = 0; i < 9; ++i) public ContainerStorage(EntityPlayer player, IInventory inventory) {
{ this(player);
addSlotToContainer(new SlotSpecimen(inventory, i, 8 + (18 * i), 20, false));
}
addPlayerInventory(8, 129); addSpecimenAndPlayerInventorySlots(inventory);
} }
protected void addSpecimenAndPlayerInventorySlots(IInventory inventory) {
for (int i = 0; i < 9; ++i) {
addSlotToContainer(new SlotSpecimen(inventory, i, 8 + (18 * i), 20, false));
}
addPlayerInventory(8, 129);
}
} }

View File

@@ -1,61 +0,0 @@
package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import refinedstorage.RefinedStorageItems;
import refinedstorage.container.slot.BasicItemValidator;
import refinedstorage.container.slot.SlotFiltered;
import refinedstorage.container.slot.SlotOutput;
import refinedstorage.tile.TileWirelessTransmitter;
public class ContainerWirelessTransmitter extends ContainerBase
{
public ContainerWirelessTransmitter(EntityPlayer player, TileWirelessTransmitter wirelessTransmitter)
{
super(player);
addSlotToContainer(new SlotFiltered(wirelessTransmitter, 0, 8, 20, new BasicItemValidator(Items.ender_pearl)));
addSlotToContainer(new SlotFiltered(wirelessTransmitter, 1, 101, 20, new BasicItemValidator(RefinedStorageItems.WIRELESS_GRID)));
addSlotToContainer(new SlotOutput(wirelessTransmitter, 2, 152, 20));
addPlayerInventory(8, 55);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index)
{
ItemStack stack = null;
Slot slot = getSlot(index);
if (slot != null && slot.getHasStack())
{
stack = slot.getStack().copy();
if (index < 3)
{
if (!mergeItemStack(stack, 3, inventorySlots.size(), true))
{
return null;
}
}
else if (!mergeItemStack(stack, 0, 3, false))
{
return null;
}
if (stack.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
}

View File

@@ -3,18 +3,15 @@ package refinedstorage.container.slot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class BasicItemValidator implements IItemValidator public class BasicItemValidator implements IItemValidator {
{ private Item item;
private Item item;
public BasicItemValidator(Item item) public BasicItemValidator(Item item) {
{ this.item = item;
this.item = item; }
}
@Override @Override
public boolean isValid(ItemStack stack) public boolean isValid(ItemStack stack) {
{ return item == stack.getItem();
return item == stack.getItem(); }
}
} }

View File

@@ -2,7 +2,6 @@ package refinedstorage.container.slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public interface IItemValidator public interface IItemValidator {
{ boolean isValid(ItemStack stack);
public boolean isValid(ItemStack stack);
} }

View File

@@ -4,16 +4,13 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class SlotDisabled extends Slot public class SlotDisabled extends Slot {
{ public SlotDisabled(IInventory inventory, int id, int x, int y) {
public SlotDisabled(IInventory inventory, int id, int x, int y) super(inventory, id, x, y);
{ }
super(inventory, id, x, y);
}
@Override @Override
public boolean isItemValid(ItemStack stack) public boolean isItemValid(ItemStack stack) {
{ return false;
return false; }
}
} }

View File

@@ -4,20 +4,17 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class SlotFiltered extends Slot public class SlotFiltered extends Slot {
{ private IItemValidator validator;
private IItemValidator validator;
public SlotFiltered(IInventory inventory, int id, int x, int y, IItemValidator validator) public SlotFiltered(IInventory inventory, int id, int x, int y, IItemValidator validator) {
{ super(inventory, id, x, y);
super(inventory, id, x, y);
this.validator = validator; this.validator = validator;
} }
@Override @Override
public boolean isItemValid(ItemStack item) public boolean isItemValid(ItemStack item) {
{ return validator.isValid(item);
return validator.isValid(item); }
}
} }

View File

@@ -5,36 +5,33 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.SlotCrafting; import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import refinedstorage.container.ContainerGrid;
import refinedstorage.tile.TileGrid; import refinedstorage.tile.TileGrid;
public class SlotGridCraftingResult extends SlotCrafting public class SlotGridCraftingResult extends SlotCrafting {
{ private ContainerGrid container;
private IInventory craftingMatrix; private IInventory craftingMatrix;
private TileGrid grid; private TileGrid grid;
public SlotGridCraftingResult(EntityPlayer player, InventoryCrafting craftingMatrix, IInventory craftingResult, TileGrid grid, int id, int x, int y) public SlotGridCraftingResult(ContainerGrid container, EntityPlayer player, InventoryCrafting craftingMatrix, IInventory craftingResult, TileGrid grid, int id, int x, int y) {
{ super(player, craftingMatrix, craftingResult, id, x, y);
super(player, craftingMatrix, craftingResult, id, x, y);
this.craftingMatrix = craftingMatrix; this.container = container;
this.grid = grid; this.craftingMatrix = craftingMatrix;
} this.grid = grid;
}
@Override @Override
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
{ FMLCommonHandler.instance().firePlayerCraftingEvent(player, stack, craftingMatrix);
ItemStack[] matrixSlots = new ItemStack[craftingMatrix.getSizeInventory()];
for (int i = 0; i < craftingMatrix.getSizeInventory(); ++i) onCrafting(stack);
{
if (craftingMatrix.getStackInSlot(i) != null)
{
matrixSlots[i] = craftingMatrix.getStackInSlot(i).copy();
}
}
super.onPickupFromSlot(player, stack); grid.onCrafted(container);
}
grid.onCrafted(matrixSlots); public void onShiftClick(EntityPlayer player) {
} grid.onCraftedShift(container, player);
}
} }

View File

@@ -4,16 +4,13 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class SlotOutput extends Slot public class SlotOutput extends Slot {
{ public SlotOutput(IInventory inventory, int id, int x, int y) {
public SlotOutput(IInventory inventory, int id, int x, int y) super(inventory, id, x, y);
{ }
super(inventory, id, x, y);
}
@Override @Override
public boolean isItemValid(ItemStack stack) public boolean isItemValid(ItemStack stack) {
{ return false;
return false; }
}
} }

View File

@@ -5,42 +5,35 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class SlotSpecimen extends Slot public class SlotSpecimen extends Slot {
{ private boolean sizeAllowed;
private boolean sizeAllowed;
public SlotSpecimen(IInventory inventory, int id, int x, int y, boolean allowSize) public SlotSpecimen(IInventory inventory, int id, int x, int y, boolean allowSize) {
{ super(inventory, id, x, y);
super(inventory, id, x, y);
this.sizeAllowed = allowSize; this.sizeAllowed = allowSize;
} }
@Override @Override
public boolean canTakeStack(EntityPlayer player) public boolean canTakeStack(EntityPlayer player) {
{ return false;
return false; }
}
@Override @Override
public boolean isItemValid(ItemStack stack) public boolean isItemValid(ItemStack stack) {
{ return true;
return true; }
}
@Override @Override
public void putStack(ItemStack stack) public void putStack(ItemStack stack) {
{ if (stack != null && !sizeAllowed) {
if (stack != null && !sizeAllowed) stack.stackSize = 1;
{ }
stack.stackSize = 1;
}
super.putStack(stack); super.putStack(stack);
} }
public boolean isSizeAllowed() public boolean isSizeAllowed() {
{ return sizeAllowed;
return sizeAllowed; }
}
} }

View File

@@ -0,0 +1,16 @@
package refinedstorage.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class SlotSpecimenItemBlock extends SlotSpecimen {
public SlotSpecimenItemBlock(IInventory inventory, int id, int x, int y) {
super(inventory, id, x, y, false);
}
@Override
public boolean isItemValid(ItemStack stack) {
return stack.getItem() instanceof ItemBlock;
}
}

334
src/main/java/refinedstorage/gui/GuiBase.java Normal file → Executable file
View File

@@ -1,12 +1,8 @@
package refinedstorage.gui; package refinedstorage.gui;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@@ -15,222 +11,216 @@ import org.lwjgl.opengl.GL11;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.gui.sidebutton.SideButton; import refinedstorage.gui.sidebutton.SideButton;
public abstract class GuiBase extends GuiContainer import java.io.IOException;
{ import java.util.ArrayList;
public static final int SIDE_BUTTON_WIDTH = 20; import java.util.Arrays;
public static final int SIDE_BUTTON_HEIGHT = 20; import java.util.List;
private List<SideButton> sideButtons = new ArrayList<SideButton>(); public abstract class GuiBase extends GuiContainer {
public static final int SIDE_BUTTON_WIDTH = 20;
public static final int SIDE_BUTTON_HEIGHT = 20;
private int lastButtonId = 0; private List<SideButton> sideButtons = new ArrayList<SideButton>();
private int lastSideButtonY = 6;
protected int width; private int lastButtonId = 0;
protected int height; private int lastSideButtonY = 6;
public GuiBase(Container container, int width, int height) protected int width;
{ protected int height;
super(container);
this.width = width; public GuiBase(Container container, int width, int height) {
this.height = height; super(container);
this.xSize = width;
this.ySize = height;
}
@Override this.width = width;
public void initGui() this.height = height;
{ this.xSize = width;
if (sideButtons.size() > 0) this.ySize = height;
{ }
xSize -= SIDE_BUTTON_WIDTH;
}
super.initGui(); @Override
public void initGui() {
if (sideButtons.size() > 0) {
xSize -= SIDE_BUTTON_WIDTH;
}
sideButtons.clear(); super.initGui();
lastButtonId = 0; sideButtons.clear();
lastSideButtonY = 6;
init(guiLeft, guiTop); lastButtonId = 0;
lastSideButtonY = 6;
if (sideButtons.size() > 0) init(guiLeft, guiTop);
{
xSize += SIDE_BUTTON_WIDTH;
}
}
@Override if (sideButtons.size() > 0) {
public void updateScreen() xSize += SIDE_BUTTON_WIDTH;
{ }
super.updateScreen(); }
update(guiLeft, guiTop); @Override
} public void updateScreen() {
super.updateScreen();
@Override update(guiLeft, guiTop);
protected void drawGuiContainerBackgroundLayer(float renderPartialTicks, int mouseX, int mouseY) }
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
drawBackground(guiLeft, guiTop, mouseX, mouseY); @Override
} protected void drawGuiContainerBackgroundLayer(float renderPartialTicks, int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@Override drawBackground(guiLeft, guiTop, mouseX, mouseY);
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) }
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mouseX -= guiLeft; @Override
mouseY -= guiTop; protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
for (SideButton sideButton : sideButtons) mouseX -= guiLeft;
{ mouseY -= guiTop;
GL11.glDisable(GL11.GL_LIGHTING);
sideButton.draw(this, sideButton.getX() + 2, sideButton.getY() + 1);
GL11.glEnable(GL11.GL_LIGHTING);
if (inBounds(sideButton.getX(), sideButton.getY(), SIDE_BUTTON_WIDTH, SIDE_BUTTON_HEIGHT, mouseX, mouseY)) for (SideButton sideButton : sideButtons) {
{ GL11.glDisable(GL11.GL_LIGHTING);
drawTooltip(mouseX, mouseY, sideButton.getTooltip(this)); sideButton.draw(this, sideButton.getX() + 2, sideButton.getY() + 1);
} GL11.glEnable(GL11.GL_LIGHTING);
}
drawForeground(mouseX, mouseY); if (inBounds(sideButton.getX(), sideButton.getY(), SIDE_BUTTON_WIDTH, SIDE_BUTTON_HEIGHT, mouseX, mouseY)) {
} drawTooltip(mouseX, mouseY, sideButton.getTooltip(this));
}
}
@Override drawForeground(mouseX, mouseY);
protected void actionPerformed(GuiButton button) throws IOException }
{
super.actionPerformed(button);
for (SideButton sideButton : sideButtons) @Override
{ protected void actionPerformed(GuiButton button) throws IOException {
if (sideButton.getId() == button.id) super.actionPerformed(button);
{
sideButton.actionPerformed();
}
}
}
public GuiButton addButton(int x, int y, int w, int h) for (SideButton sideButton : sideButtons) {
{ if (sideButton.getId() == button.id) {
return addButton(x, y, w, h, ""); sideButton.actionPerformed();
} }
}
}
public GuiButton addButton(int x, int y, int w, int h, String text) public GuiButton addButton(int x, int y, int w, int h) {
{ return addButton(x, y, w, h, "");
GuiButton button = new GuiButton(lastButtonId++, x, y, w, h, text); }
buttonList.add(button); public GuiButton addButton(int x, int y, int w, int h, String text) {
GuiButton button = new GuiButton(lastButtonId++, x, y, w, h, text);
return button; buttonList.add(button);
}
public void addSideButton(SideButton button) return button;
{ }
button.setX(xSize - 1);
button.setY(lastSideButtonY);
button.setId(addButton(guiLeft + button.getX(), guiTop + button.getY(), SIDE_BUTTON_WIDTH, SIDE_BUTTON_HEIGHT).id);
lastSideButtonY += SIDE_BUTTON_HEIGHT + 4; public void addSideButton(SideButton button) {
button.setX(xSize - 1);
button.setY(lastSideButtonY);
button.setId(addButton(guiLeft + button.getX(), guiTop + button.getY(), SIDE_BUTTON_WIDTH, SIDE_BUTTON_HEIGHT).id);
sideButtons.add(button); lastSideButtonY += SIDE_BUTTON_HEIGHT + 4;
}
public boolean inBounds(int x, int y, int w, int h, int ox, int oy) sideButtons.add(button);
{ }
return ox >= x && ox <= x + w && oy >= y && oy <= y + h;
}
public void bindTexture(String file) public boolean inBounds(int x, int y, int w, int h, int ox, int oy) {
{ return ox >= x && ox <= x + w && oy >= y && oy <= y + h;
bindTexture(RefinedStorage.ID, file); }
}
public void bindTexture(String base, String file) public void bindTexture(String file) {
{ bindTexture(RefinedStorage.ID, file);
mc.getTextureManager().bindTexture(new ResourceLocation(base, "textures/" + file)); }
}
public void drawItem(int x, int y, ItemStack stack) public void bindTexture(String base, String file) {
{ mc.getTextureManager().bindTexture(new ResourceLocation(base, "textures/" + file));
drawItem(x, y, stack, false, null); }
}
public void drawItem(int x, int y, ItemStack stack, boolean withOverlay) public void drawItem(int x, int y, ItemStack stack) {
{ drawItem(x, y, stack, false);
drawItem(x, y, stack, withOverlay, null); }
}
public void drawItem(int x, int y, ItemStack stack, boolean withOverlay, String message) public void drawItem(int x, int y, ItemStack stack, boolean withOverlay) {
{ drawItem(x, y, stack, withOverlay, null);
zLevel = 200.0F; }
itemRender.zLevel = 200.0F;
FontRenderer font = null; public void drawItem(int x, int y, ItemStack stack, boolean withOverlay, String message) {
zLevel = 200.0F;
itemRender.zLevel = 200.0F;
if (stack != null) itemRender.renderItemIntoGUI(stack, x, y);
{
font = stack.getItem().getFontRenderer(stack);
}
if (font == null) if (withOverlay) {
{ drawItemOverlay(stack, message, x, y);
font = fontRendererObj; }
}
itemRender.renderItemIntoGUI(stack, x, y); zLevel = 0.0F;
itemRender.zLevel = 0.0F;
}
if (withOverlay) public void drawItemOverlay(ItemStack stack, String text, int x, int y) {
{ itemRender.renderItemOverlayIntoGUI(fontRendererObj, stack, x, y, "");
itemRender.renderItemOverlayIntoGUI(font, stack, x, y, message);
}
zLevel = 0.0F; if (text != null) {
itemRender.zLevel = 0.0F; GlStateManager.pushMatrix();
} GlStateManager.translate(x, y, 1);
GL11.glScalef(0.5f, 0.5f, 1);
public void drawString(int x, int y, String message) int stringWidth = fontRendererObj.getStringWidth(text);
{
drawString(x, y, message, 4210752);
}
public void drawString(int x, int y, String message, int color) GlStateManager.disableLighting();
{ GlStateManager.disableRescaleNormal();
GL11.glDisable(GL11.GL_LIGHTING); GlStateManager.depthMask(false);
fontRendererObj.drawString(message, x, y, color); GlStateManager.enableBlend();
GL11.glEnable(GL11.GL_LIGHTING); GlStateManager.blendFunc(770, 771);
} GlStateManager.disableDepth();
public void drawTooltip(int x, int y, String message) fontRendererObj.drawStringWithShadow(text, 30 - stringWidth, 22, 16777215);
{
GL11.glDisable(GL11.GL_LIGHTING);
drawHoveringText(Arrays.asList(message.split("\n")), x, y);
GL11.glEnable(GL11.GL_LIGHTING);
}
public void drawTooltip(int x, int y, ItemStack stack) GlStateManager.enableDepth();
{ GlStateManager.enableTexture2D();
renderToolTip(stack, x, y); GlStateManager.depthMask(true);
} GlStateManager.enableLighting();
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
public void drawTexture(int x, int y, int textureX, int textureY, int width, int height) public void drawString(int x, int y, String message) {
{ drawString(x, y, message, 4210752);
drawTexturedModalRect(x, y, textureX, textureY, width, height); }
}
public String t(String name, Object... format) public void drawString(int x, int y, String message, int color) {
{ GL11.glDisable(GL11.GL_LIGHTING);
return I18n.translateToLocalFormatted(name, format); fontRendererObj.drawString(message, x, y, color);
} GL11.glEnable(GL11.GL_LIGHTING);
}
public abstract void init(int x, int y); public void drawTooltip(int x, int y, String message) {
GL11.glDisable(GL11.GL_LIGHTING);
drawHoveringText(Arrays.asList(message.split("\n")), x, y);
GL11.glEnable(GL11.GL_LIGHTING);
}
public abstract void update(int x, int y); public void drawTooltip(int x, int y, ItemStack stack) {
GL11.glDisable(GL11.GL_LIGHTING);
renderToolTip(stack, x, y);
GL11.glEnable(GL11.GL_LIGHTING);
}
public abstract void drawBackground(int x, int y, int mouseX, int mouseY); public void drawTexture(int x, int y, int textureX, int textureY, int width, int height) {
drawTexturedModalRect(x, y, textureX, textureY, width, height);
}
public abstract void drawForeground(int mouseX, int mouseY); public String t(String name, Object... format) {
return I18n.translateToLocalFormatted(name, format);
}
public abstract void init(int x, int y);
public abstract void update(int x, int y);
public abstract void drawBackground(int x, int y, int mouseX, int mouseY);
public abstract void drawForeground(int mouseX, int mouseY);
} }

56
src/main/java/refinedstorage/gui/GuiConstructor.java Normal file → Executable file
View File

@@ -6,43 +6,37 @@ import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileConstructor; import refinedstorage.tile.TileConstructor;
import refinedstorage.util.InventoryUtils; import refinedstorage.util.InventoryUtils;
public class GuiConstructor extends GuiBase public class GuiConstructor extends GuiBase {
{ private TileConstructor constructor;
private TileConstructor constructor;
public GuiConstructor(ContainerConstructor container, TileConstructor constructor) public GuiConstructor(ContainerConstructor container, TileConstructor constructor) {
{ super(container, 176, 137);
super(container, 176, 137);
this.constructor = constructor; this.constructor = constructor;
} }
@Override @Override
public void init(int x, int y) public void init(int x, int y) {
{ addSideButton(new SideButtonRedstoneMode(constructor));
addSideButton(new SideButtonRedstoneMode(constructor));
addSideButton(new SideButtonCompare(constructor, InventoryUtils.COMPARE_DAMAGE)); addSideButton(new SideButtonCompare(constructor, InventoryUtils.COMPARE_DAMAGE));
addSideButton(new SideButtonCompare(constructor, InventoryUtils.COMPARE_NBT)); addSideButton(new SideButtonCompare(constructor, InventoryUtils.COMPARE_NBT));
} }
@Override @Override
public void update(int x, int y) public void update(int x, int y) {
{ }
}
@Override @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) public void drawBackground(int x, int y, int mouseX, int mouseY) {
{ bindTexture("gui/constructor.png");
bindTexture("gui/constructor.png");
drawTexture(x, y, 0, 0, width, height); drawTexture(x, y, 0, 0, width, height);
} }
@Override @Override
public void drawForeground(int mouseX, int mouseY) public void drawForeground(int mouseX, int mouseY) {
{ drawString(7, 7, t("gui.refinedstorage:constructor"));
drawString(7, 7, t("gui.refinedstorage:constructor")); drawString(7, 43, t("container.inventory"));
drawString(7, 43, t("container.inventory")); }
}
} }

179
src/main/java/refinedstorage/gui/GuiController.java Normal file → Executable file
View File

@@ -2,119 +2,134 @@ package refinedstorage.gui;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.translation.I18n;
import refinedstorage.container.ContainerController; import refinedstorage.container.ContainerController;
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode; import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileController; import refinedstorage.tile.TileController;
import refinedstorage.tile.TileMachine; import refinedstorage.tile.TileMachine;
public class GuiController extends GuiBase import java.util.ArrayList;
{ import java.util.List;
private TileController controller;
private int barX = 8; public class GuiController extends GuiBase {
private int barY = 20; public static final int VISIBLE_ROWS = 2;
private int barWidth = 16;
private int barHeight = 59;
private Scrollbar scrollbar = new Scrollbar(157, 20, 12, 59); private TileController controller;
public GuiController(ContainerController container, TileController controller) private int barX = 8;
{ private int barY = 20;
super(container, 176, 181); private int barWidth = 16;
private int barHeight = 59;
this.controller = controller; private Scrollbar scrollbar = new Scrollbar(157, 20, 12, 59);
}
@Override public GuiController(ContainerController container, TileController controller) {
public void init(int x, int y) super(container, 176, 181);
{
addSideButton(new SideButtonRedstoneMode(controller));
}
@Override this.controller = controller;
public void update(int x, int y) }
{
scrollbar.setCanScroll(getRows() > getVisibleRows());
}
@Override @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) public void init(int x, int y) {
{ addSideButton(new SideButtonRedstoneMode(controller));
bindTexture("gui/controller.png"); }
drawTexture(x, y, 0, 0, width, height); @Override
public void update(int x, int y) {
scrollbar.setCanScroll(getRows() > VISIBLE_ROWS);
}
int barHeightNew = (int) ((float) controller.getEnergyStored(null) / (float) controller.getMaxEnergyStored(null) * (float) barHeight); @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) {
bindTexture("gui/controller.png");
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 178, 0 + (barHeight - barHeightNew), barWidth, barHeightNew); drawTexture(x, y, 0, 0, width, height);
scrollbar.draw(this); int barHeightNew = (int) ((float) controller.getEnergyStored(null) / (float) controller.getMaxEnergyStored(null) * (float) barHeight);
}
@Override drawTexture(x + barX, y + barY + barHeight - barHeightNew, 178, barHeight - barHeightNew, barWidth, barHeightNew);
public void drawForeground(int mouseX, int mouseY)
{
scrollbar.update(this, mouseX, mouseY);
drawString(7, 7, t("gui.refinedstorage:controller." + controller.getType().getId())); scrollbar.draw(this);
drawString(7, 87, t("container.inventory")); }
int x = 33; private int calculateOffsetOnScale(int pos, float scale) {
int y = 26; float multiplier = (pos / scale);
return (int) multiplier;
}
int slot = getOffset() * 2; @Override
public void drawForeground(int mouseX, int mouseY) {
scrollbar.update(this, mouseX, mouseY);
RenderHelper.enableGUIStandardItemLighting(); drawString(7, 7, t("gui.refinedstorage:controller." + controller.getType().getId()));
drawString(7, 87, t("container.inventory"));
for (int i = 0; i < 4; ++i) int x = 33;
{ int y = 26;
if (slot < controller.getMachines().size())
{
TileMachine machine = controller.getMachines().get(slot);
IBlockState machineState = machine.getWorld().getBlockState(machine.getPos());
Block machineBlock = machineState.getBlock();
ItemStack machineStack = new ItemStack(machineBlock, 1, machineBlock.getMetaFromState(machineState)); int slot = getOffset() * 2;
drawItem(x, y, machineStack); RenderHelper.enableGUIStandardItemLighting();
drawString(x + 21, y + 5, t("misc.refinedstorage:energy_usage_minimal", machine.getEnergyUsage()));
}
if (i == 1) List<TileMachine> machines = new ArrayList<TileMachine>(controller.getMachines());
{
x = 33;
y += 30;
}
else
{
x += 60;
}
slot++; TileMachine machineHovering = null;
}
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) for (int i = 0; i < 4; ++i) {
{ if (slot < machines.size()) {
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_usage", controller.getEnergyUsage()) + "\n" + t("misc.refinedstorage:energy_stored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null))); TileMachine machine = machines.get(slot);
} IBlockState machineState = machine.getWorld().getBlockState(machine.getPos());
} Block machineBlock = machineState.getBlock();
public int getOffset() ItemStack machineStack = new ItemStack(machineBlock, 1, machineBlock.getMetaFromState(machineState));
{
return (int) (scrollbar.getCurrentScroll() / 59f * (float) getRows());
}
private int getRows() drawItem(x, y + 5, machineStack);
{ GlStateManager.pushMatrix();
int max = (int) Math.ceil((float) controller.getMachines().size() / (float) 2); float scale = 0.5f;
return max < 0 ? 0 : max; GlStateManager.scale(scale, scale, 1);
} drawString(calculateOffsetOnScale(x + 1, scale), calculateOffsetOnScale(y - 3, scale), machineStack.getDisplayName());
drawString(calculateOffsetOnScale(x + 21, scale), calculateOffsetOnScale(y + 10, scale), t("misc.refinedstorage:energy_usage_minimal", machine.getEnergyUsage()));
GlStateManager.popMatrix();
private int getVisibleRows() if (inBounds(x, y, 16, 16, mouseX, mouseY)) {
{ machineHovering = machine;
return 2; }
} }
if (i == 1) {
x = 33;
y += 30;
} else {
x += 60;
}
slot++;
}
if (machineHovering != null) {
String message = I18n.translateToLocalFormatted("gui.refinedstorage:controller.machine_position.x", machineHovering.getPos().getX());
message += "\n" + I18n.translateToLocalFormatted("gui.refinedstorage:controller.machine_position.y", machineHovering.getPos().getY());
message += "\n" + I18n.translateToLocalFormatted("gui.refinedstorage:controller.machine_position.z", machineHovering.getPos().getZ());
drawTooltip(mouseX, mouseY, message);
}
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) {
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_usage", controller.getEnergyUsage()) + "\n" + t("misc.refinedstorage:energy_stored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null)));
}
}
public int getOffset() {
return (int) (scrollbar.getCurrentScroll() / 59f * (float) getRows());
}
private int getRows() {
int max = (int) Math.ceil((float) controller.getMachines().size() / (float) 2);
return max < 0 ? 0 : max;
}
} }

60
src/main/java/refinedstorage/gui/GuiDestructor.java Normal file → Executable file
View File

@@ -1,43 +1,45 @@
package refinedstorage.gui; package refinedstorage.gui;
import refinedstorage.container.ContainerDestructor; import refinedstorage.container.ContainerDestructor;
import refinedstorage.gui.sidebutton.SideButtonCompare;
import refinedstorage.gui.sidebutton.SideButtonMode;
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode; import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileDestructor; import refinedstorage.tile.TileDestructor;
import refinedstorage.util.InventoryUtils;
public class GuiDestructor extends GuiBase public class GuiDestructor extends GuiBase {
{ private TileDestructor destructor;
private TileDestructor destructor;
public GuiDestructor(ContainerDestructor container, TileDestructor destructor) public GuiDestructor(ContainerDestructor container, TileDestructor destructor) {
{ super(container, 176, 137);
super(container, 176, 131);
this.destructor = destructor; this.destructor = destructor;
} }
@Override @Override
public void init(int x, int y) public void init(int x, int y) {
{ addSideButton(new SideButtonRedstoneMode(destructor));
addSideButton(new SideButtonRedstoneMode(destructor));
}
@Override addSideButton(new SideButtonMode(destructor));
public void update(int x, int y)
{
}
@Override addSideButton(new SideButtonCompare(destructor, InventoryUtils.COMPARE_DAMAGE));
public void drawBackground(int x, int y, int mouseX, int mouseY) addSideButton(new SideButtonCompare(destructor, InventoryUtils.COMPARE_NBT));
{ }
bindTexture("gui/destructor.png");
drawTexture(x, y, 0, 0, width, height); @Override
} public void update(int x, int y) {
}
@Override @Override
public void drawForeground(int mouseX, int mouseY) public void drawBackground(int x, int y, int mouseX, int mouseY) {
{ bindTexture("gui/destructor.png");
drawString(7, 7, t("gui.refinedstorage:destructor"));
drawString(7, 39, t("container.inventory")); drawTexture(x, y, 0, 0, width, height);
} }
@Override
public void drawForeground(int mouseX, int mouseY) {
drawString(7, 7, t("gui.refinedstorage:destructor"));
drawString(7, 43, t("container.inventory"));
}
} }

104
src/main/java/refinedstorage/gui/GuiDetector.java Normal file → Executable file
View File

@@ -1,7 +1,6 @@
package refinedstorage.gui; package refinedstorage.gui;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import java.io.IOException;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiTextField;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.container.ContainerDetector; import refinedstorage.container.ContainerDetector;
@@ -11,73 +10,64 @@ import refinedstorage.network.MessageDetectorAmountUpdate;
import refinedstorage.tile.TileDetector; import refinedstorage.tile.TileDetector;
import refinedstorage.util.InventoryUtils; import refinedstorage.util.InventoryUtils;
public class GuiDetector extends GuiBase import java.io.IOException;
{
private TileDetector detector;
private GuiTextField amountField; public class GuiDetector extends GuiBase {
private TileDetector detector;
public GuiDetector(ContainerDetector container, TileDetector detector) private GuiTextField amountField;
{
super(container, 176, 137);
this.detector = detector; public GuiDetector(ContainerDetector container, TileDetector detector) {
} super(container, 176, 137);
@Override this.detector = detector;
public void init(int x, int y) }
{
addSideButton(new SideButtonCompare(detector, InventoryUtils.COMPARE_DAMAGE));
addSideButton(new SideButtonCompare(detector, InventoryUtils.COMPARE_NBT));
addSideButton(new SideButtonDetectorMode(detector)); @Override
public void init(int x, int y) {
addSideButton(new SideButtonCompare(detector, InventoryUtils.COMPARE_DAMAGE));
addSideButton(new SideButtonCompare(detector, InventoryUtils.COMPARE_NBT));
amountField = new GuiTextField(0, fontRendererObj, x + 62 + 1, y + 23 + 1, 25, fontRendererObj.FONT_HEIGHT); addSideButton(new SideButtonDetectorMode(detector));
amountField.setText(String.valueOf(detector.getAmount()));
amountField.setEnableBackgroundDrawing(false);
amountField.setVisible(true);
amountField.setTextColor(16777215);
amountField.setCanLoseFocus(false);
amountField.setFocused(true);
}
@Override amountField = new GuiTextField(0, fontRendererObj, x + 62 + 1, y + 23 + 1, 25, fontRendererObj.FONT_HEIGHT);
public void update(int x, int y) amountField.setText(String.valueOf(detector.getAmount()));
{ amountField.setEnableBackgroundDrawing(false);
} amountField.setVisible(true);
amountField.setTextColor(16777215);
amountField.setCanLoseFocus(false);
amountField.setFocused(true);
}
@Override @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) public void update(int x, int y) {
{ }
bindTexture("gui/detector.png");
drawTexture(x, y, 0, 0, width, height); @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) {
bindTexture("gui/detector.png");
amountField.drawTextBox(); drawTexture(x, y, 0, 0, width, height);
}
@Override amountField.drawTextBox();
public void drawForeground(int mouseX, int mouseY) }
{
drawString(7, 7, t("gui.refinedstorage:detector"));
drawString(7, 43, t("container.inventory"));
}
@Override @Override
protected void keyTyped(char character, int keyCode) throws IOException public void drawForeground(int mouseX, int mouseY) {
{ drawString(7, 7, t("gui.refinedstorage:detector"));
if (!checkHotbarKeys(keyCode) && amountField.textboxKeyTyped(character, keyCode)) drawString(7, 43, t("container.inventory"));
{ }
Integer result = Ints.tryParse(amountField.getText());
if (result != null) @Override
{ protected void keyTyped(char character, int keyCode) throws IOException {
RefinedStorage.NETWORK.sendToServer(new MessageDetectorAmountUpdate(detector, result)); if (!checkHotbarKeys(keyCode) && amountField.textboxKeyTyped(character, keyCode)) {
} Integer result = Ints.tryParse(amountField.getText());
}
else if (result != null) {
{ RefinedStorage.NETWORK.sendToServer(new MessageDetectorAmountUpdate(detector, result));
super.keyTyped(character, keyCode); }
} } else {
} super.keyTyped(character, keyCode);
}
}
} }

56
src/main/java/refinedstorage/gui/GuiExporter.java Normal file → Executable file
View File

@@ -6,43 +6,37 @@ import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileExporter; import refinedstorage.tile.TileExporter;
import refinedstorage.util.InventoryUtils; import refinedstorage.util.InventoryUtils;
public class GuiExporter extends GuiBase public class GuiExporter extends GuiBase {
{ private TileExporter exporter;
private TileExporter exporter;
public GuiExporter(ContainerExporter container, TileExporter exporter) public GuiExporter(ContainerExporter container, TileExporter exporter) {
{ super(container, 176, 137);
super(container, 176, 137);
this.exporter = exporter; this.exporter = exporter;
} }
@Override @Override
public void init(int x, int y) public void init(int x, int y) {
{ addSideButton(new SideButtonRedstoneMode(exporter));
addSideButton(new SideButtonRedstoneMode(exporter));
addSideButton(new SideButtonCompare(exporter, InventoryUtils.COMPARE_DAMAGE)); addSideButton(new SideButtonCompare(exporter, InventoryUtils.COMPARE_DAMAGE));
addSideButton(new SideButtonCompare(exporter, InventoryUtils.COMPARE_NBT)); addSideButton(new SideButtonCompare(exporter, InventoryUtils.COMPARE_NBT));
} }
@Override @Override
public void update(int x, int y) public void update(int x, int y) {
{ }
}
@Override @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) public void drawBackground(int x, int y, int mouseX, int mouseY) {
{ bindTexture("gui/exporter.png");
bindTexture("gui/exporter.png");
drawTexture(x, y, 0, 0, width, height); drawTexture(x, y, 0, 0, width, height);
} }
@Override @Override
public void drawForeground(int mouseX, int mouseY) public void drawForeground(int mouseX, int mouseY) {
{ drawString(7, 7, t("gui.refinedstorage:exporter"));
drawString(7, 7, t("gui.refinedstorage:exporter")); drawString(7, 43, t("container.inventory"));
drawString(7, 43, t("container.inventory")); }
}
} }

485
src/main/java/refinedstorage/gui/GuiGrid.java Normal file → Executable file
View File

@@ -1,10 +1,5 @@
package refinedstorage.gui; package refinedstorage.gui;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiTextField;
@@ -19,339 +14,285 @@ import refinedstorage.gui.sidebutton.SideButtonGridSortingDirection;
import refinedstorage.gui.sidebutton.SideButtonGridSortingType; import refinedstorage.gui.sidebutton.SideButtonGridSortingType;
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode; import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.network.MessageGridCraftingClear; import refinedstorage.network.MessageGridCraftingClear;
import refinedstorage.network.MessageGridCraftingPush;
import refinedstorage.network.MessageStoragePull; import refinedstorage.network.MessageStoragePull;
import refinedstorage.network.MessageStoragePush; import refinedstorage.network.MessageStoragePush;
import refinedstorage.storage.StorageItem; import refinedstorage.storage.StorageItem;
import refinedstorage.tile.TileController; import refinedstorage.tile.TileController;
import refinedstorage.tile.TileGrid; import refinedstorage.tile.TileGrid;
public class GuiGrid extends GuiBase import java.io.IOException;
{ import java.util.*;
private ContainerGrid container;
private TileGrid grid;
private GuiTextField searchField; public class GuiGrid extends GuiBase {
private ContainerGrid container;
private TileGrid grid;
private int hoveringSlotId; private List<StorageItem> items = new ArrayList<StorageItem>();
private int hoveringId;
private Scrollbar scrollbar = new Scrollbar(174, 20, 12, 70); private GuiTextField searchField;
public GuiGrid(ContainerGrid container, TileGrid grid) private int hoveringSlot;
{ private int hoveringItemId;
super(container, 193, grid.getType() == EnumGridType.CRAFTING ? 256 : 190);
this.container = container; private Scrollbar scrollbar;
this.grid = grid;
}
@Override public GuiGrid(ContainerGrid container, TileGrid grid) {
public void init(int x, int y) super(container, 193, grid.getType() == EnumGridType.CRAFTING ? 256 : 208);
{
addSideButton(new SideButtonRedstoneMode(grid));
addSideButton(new SideButtonGridSortingDirection(grid)); this.container = container;
addSideButton(new SideButtonGridSortingType(grid)); this.grid = grid;
this.scrollbar = new Scrollbar(174, 20, 12, grid.getType() == EnumGridType.CRAFTING ? 70 : 88);
}
searchField = new GuiTextField(0, fontRendererObj, x + 80 + 1, y + 6 + 1, 88 - 6, fontRendererObj.FONT_HEIGHT); @Override
searchField.setEnableBackgroundDrawing(false); public void init(int x, int y) {
searchField.setVisible(true); addSideButton(new SideButtonRedstoneMode(grid));
searchField.setTextColor(16777215);
searchField.setCanLoseFocus(false);
searchField.setFocused(true);
}
@Override addSideButton(new SideButtonGridSortingDirection(grid));
public void update(int x, int y) addSideButton(new SideButtonGridSortingType(grid));
{
scrollbar.setCanScroll(getRows() > getVisibleRows());
}
public int getOffset() searchField = new GuiTextField(0, fontRendererObj, x + 80 + 1, y + 6 + 1, 88 - 6, fontRendererObj.FONT_HEIGHT);
{ searchField.setEnableBackgroundDrawing(false);
return (int) (scrollbar.getCurrentScroll() / 70f * (float) getRows()); searchField.setVisible(true);
} searchField.setTextColor(16777215);
searchField.setCanLoseFocus(false);
searchField.setFocused(true);
}
public int getVisibleRows() @Override
{ public void update(int x, int y) {
return 4; items.clear();
}
public int getRows() if (grid.isConnected()) {
{ items.addAll(grid.getController().getItems());
if (!grid.isConnected())
{
return 0;
}
int max = (int) Math.ceil((float) getItems().size() / (float) 9); if (!searchField.getText().trim().isEmpty()) {
Iterator<StorageItem> t = items.iterator();
return max < 0 ? 0 : max; while (t.hasNext()) {
} StorageItem item = t.next();
private boolean isHoveringOverValidSlot(List<StorageItem> items) if (!item.toItemStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
{ t.remove();
return grid.isConnected() && isHoveringOverSlot() && hoveringSlotId < items.size(); }
} }
}
private boolean isHoveringOverSlot() Collections.sort(items, new Comparator<StorageItem>() {
{ @Override
return hoveringSlotId >= 0; public int compare(StorageItem o1, StorageItem o2) {
} if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
return o2.toItemStack().getDisplayName().compareTo(o1.toItemStack().getDisplayName());
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
return o1.toItemStack().getDisplayName().compareTo(o2.toItemStack().getDisplayName());
}
public boolean isHoveringOverClear(int mouseX, int mouseY) return 0;
{ }
if (grid.getType() == EnumGridType.CRAFTING) });
{
return inBounds(81, 105, 7, 7, mouseX, mouseY);
}
return false; if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) {
} Collections.sort(items, new Comparator<StorageItem>() {
@Override
public int compare(StorageItem o1, StorageItem o2) {
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
return Integer.valueOf(o2.getQuantity()).compareTo(o1.getQuantity());
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
return Integer.valueOf(o1.getQuantity()).compareTo(o2.getQuantity());
}
@Override return 0;
public void drawBackground(int x, int y, int mouseX, int mouseY) }
{ });
if (grid.getType() == EnumGridType.CRAFTING) }
{ }
bindTexture("gui/crafting_grid.png");
}
else
{
bindTexture("gui/grid.png");
}
drawTexture(x, y, 0, 0, width, height); scrollbar.setCanScroll(getRows() > getVisibleRows());
}
scrollbar.draw(this); public int getOffset() {
return (int) (scrollbar.getCurrentScroll() / 70f * (float) getRows());
}
searchField.drawTextBox(); public int getRows() {
} int max = (int) Math.ceil((float) items.size() / (float) 9);
@Override return max < 0 ? 0 : max;
public void drawForeground(int mouseX, int mouseY) }
{
scrollbar.update(this, mouseX, mouseY);
drawString(7, 7, t("gui.refinedstorage:grid")); private boolean isHoveringOverItemInSlot() {
return grid.isConnected() && isHoveringOverSlot() && hoveringSlot < items.size();
}
if (grid.getType() == EnumGridType.CRAFTING) private boolean isHoveringOverSlot() {
{ return hoveringSlot >= 0;
drawString(7, 94, t("container.crafting")); }
}
drawString(7, grid.getType() == EnumGridType.CRAFTING ? 163 : 96, t("container.inventory")); public boolean isHoveringOverClear(int mouseX, int mouseY) {
if (grid.getType() == EnumGridType.CRAFTING) {
return inBounds(81, 105, 7, 7, mouseX, mouseY);
}
int x = 8; return false;
int y = 20; }
List<StorageItem> items = getItems(); @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) {
if (grid.getType() == EnumGridType.CRAFTING) {
bindTexture("gui/crafting_grid.png");
} else {
bindTexture("gui/grid.png");
}
hoveringSlotId = -1; drawTexture(x, y, 0, 0, width, height);
int slot = getOffset() * 9; scrollbar.draw(this);
RenderHelper.enableGUIStandardItemLighting(); searchField.drawTextBox();
}
for (int i = 0; i < 9 * getVisibleRows(); ++i) @Override
{ public void drawForeground(int mouseX, int mouseY) {
if (slot < items.size()) scrollbar.update(this, mouseX, mouseY);
{
int qty = items.get(slot).getQuantity();
String text; drawString(7, 7, t("gui.refinedstorage:grid"));
if (qty >= 1000000) if (grid.getType() == EnumGridType.CRAFTING) {
{ drawString(7, 94, t("container.crafting"));
text = String.valueOf((int) Math.floor(qty / 1000000)) + "M"; }
}
else if (qty >= 1000)
{
text = String.valueOf((int) Math.floor(qty / 1000)) + "K";
}
else if (qty == 1)
{
text = null;
}
else
{
text = String.valueOf(qty);
}
drawItem(x, y, items.get(slot).toItemStack(), true, text); drawString(7, grid.getType() == EnumGridType.CRAFTING ? 163 : 113, t("container.inventory"));
}
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) int x = 8;
{ int y = 20;
hoveringSlotId = slot;
if (slot < items.size()) hoveringSlot = -1;
{
// We need to use the ID, because if we filter, the client-side index will change
// while the serverside's index will still be the same.
hoveringId = items.get(slot).getId();
}
int color = grid.isConnected() ? -2130706433 : 0xFF5B5B5B; int slot = getOffset() * 9;
GlStateManager.disableLighting(); RenderHelper.enableGUIStandardItemLighting();
GlStateManager.disableDepth();
zLevel = 190;
GlStateManager.colorMask(true, true, true, false);
drawGradientRect(x, y, x + 16, y + 16, color, color);
zLevel = 0;
GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
}
slot++; for (int i = 0; i < 9 * getVisibleRows(); ++i) {
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
hoveringSlot = slot;
x += 18; if (slot < items.size()) {
// We need to use the ID, because if we filter, the client-side index will change
// while the server-side's index will still be the same.
hoveringItemId = items.get(slot).getId();
}
}
if ((i + 1) % 9 == 0) if (slot < items.size()) {
{ int qty = items.get(slot).getQuantity();
x = 8;
y += 18;
}
}
if (isHoveringOverValidSlot(items)) String text;
{
drawTooltip(mouseX, mouseY, items.get(hoveringSlotId).toItemStack());
}
if (isHoveringOverClear(mouseX, mouseY)) if (qty >= 1000000) {
{ text = String.format("%.1f", (float) qty / 1000000).replace(",", ".").replace(".0", "") + "M";
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:clear")); } else if (qty >= 1000) {
} text = String.format("%.1f", (float) qty / 1000).replace(",", ".").replace(".0", "") + "K";
} } else if (qty == 1) {
text = null;
} else {
text = String.valueOf(qty);
}
public List<StorageItem> getItems() if (hoveringSlot == slot && GuiScreen.isShiftKeyDown() && qty > 1) {
{ text = String.valueOf(qty);
List<StorageItem> items = new ArrayList<StorageItem>(); }
if (!grid.isConnected()) drawItem(x, y, items.get(slot).toItemStack(), true, text);
{ }
return items;
}
items.addAll(grid.getController().getItems()); if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
int color = grid.isConnected() ? -2130706433 : 0xFF5B5B5B;
if (!searchField.getText().trim().isEmpty()) GlStateManager.disableLighting();
{ GlStateManager.disableDepth();
Iterator<StorageItem> t = items.iterator(); zLevel = 190;
GlStateManager.colorMask(true, true, true, false);
drawGradientRect(x, y, x + 16, y + 16, color, color);
zLevel = 0;
GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
}
while (t.hasNext()) slot++;
{
StorageItem item = t.next();
if (!item.toItemStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) x += 18;
{
t.remove();
}
}
}
items.sort(new Comparator<StorageItem>() if ((i + 1) % 9 == 0) {
{ x = 8;
@Override y += 18;
public int compare(StorageItem o1, StorageItem o2) }
{ }
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING)
{
return o2.toItemStack().getDisplayName().compareTo(o1.toItemStack().getDisplayName());
}
else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING)
{
return o1.toItemStack().getDisplayName().compareTo(o2.toItemStack().getDisplayName());
}
return 0; if (isHoveringOverItemInSlot()) {
} drawTooltip(mouseX, mouseY, items.get(hoveringSlot).toItemStack());
}); }
if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) if (isHoveringOverClear(mouseX, mouseY)) {
{ drawTooltip(mouseX, mouseY, t("misc.refinedstorage:clear"));
items.sort(new Comparator<StorageItem>() }
{ }
@Override
public int compare(StorageItem o1, StorageItem o2)
{
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING)
{
return Integer.valueOf(o2.getQuantity()).compareTo(o1.getQuantity());
}
else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING)
{
return Integer.valueOf(o1.getQuantity()).compareTo(o2.getQuantity());
}
return 0; @Override
} public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException {
}); super.mouseClicked(mouseX, mouseY, clickedButton);
}
return items; boolean clickedClear = clickedButton == 0 && isHoveringOverClear(mouseX - guiLeft, mouseY - guiTop);
}
@Override if (grid.isConnected()) {
public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException TileController controller = grid.getController();
{
super.mouseClicked(mouseX, mouseY, clickedButton);
boolean clickedClear = clickedButton == 0 && isHoveringOverClear(mouseX - guiLeft, mouseY - guiTop); if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null && (clickedButton == 0 || clickedButton == 1)) {
RefinedStorage.NETWORK.sendToServer(new MessageStoragePush(controller.getPos().getX(), controller.getPos().getY(), controller.getPos().getZ(), -1, clickedButton == 1));
} else if (isHoveringOverItemInSlot() && container.getPlayer().inventory.getItemStack() == null) {
boolean half = clickedButton == 1;
boolean shift = GuiScreen.isShiftKeyDown();
boolean one = clickedButton == 2;
if (grid.isConnected()) RefinedStorage.NETWORK.sendToServer(new MessageStoragePull(controller.getPos().getX(), controller.getPos().getY(), controller.getPos().getZ(), hoveringItemId, half, one, shift));
{ } else if (clickedClear) {
TileController controller = grid.getController(); RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingClear(grid));
} else {
for (Slot slot : container.getPlayerInventorySlots()) {
if (inBounds(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX - guiLeft, mouseY - guiTop)) {
if (GuiScreen.isShiftKeyDown()) {
RefinedStorage.NETWORK.sendToServer(new MessageStoragePush(controller.getPos().getX(), controller.getPos().getY(), controller.getPos().getZ(), slot.slotNumber, clickedButton == 1));
}
}
}
if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null) if (grid.getType() == EnumGridType.CRAFTING) {
{ for (Slot slot : container.getCraftingSlots()) {
RefinedStorage.NETWORK.sendToServer(new MessageStoragePush(controller.getPos().getX(), controller.getPos().getY(), controller.getPos().getZ(), -1, clickedButton == 1)); if (inBounds(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX - guiLeft, mouseY - guiTop)) {
} if (GuiScreen.isShiftKeyDown()) {
else if (isHoveringOverValidSlot(getItems()) && container.getPlayer().inventory.getItemStack() == null) RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingPush(grid, slot.getSlotIndex()));
{ }
boolean half = clickedButton == 1; }
boolean shift = GuiScreen.isShiftKeyDown(); }
boolean one = clickedButton == 2; }
}
}
RefinedStorage.NETWORK.sendToServer(new MessageStoragePull(controller.getPos().getX(), controller.getPos().getY(), controller.getPos().getZ(), hoveringId, half, one, shift)); if (clickedClear) {
} mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.ui_button_click, 1.0F));
else if (clickedClear) }
{ }
RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingClear(grid));
}
else
{
for (Slot slot : container.getPlayerInventorySlots())
{
if (inBounds(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX - guiLeft, mouseY - guiTop))
{
if (GuiScreen.isShiftKeyDown())
{
RefinedStorage.NETWORK.sendToServer(new MessageStoragePush(controller.getPos().getX(), controller.getPos().getY(), controller.getPos().getZ(), slot.slotNumber, clickedButton == 1));
}
}
}
}
}
if (clickedClear) @Override
{ protected void keyTyped(char character, int keyCode) throws IOException {
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.ui_button_click, 1.0F)); if (!checkHotbarKeys(keyCode) && searchField.textboxKeyTyped(character, keyCode)) {
} } else {
} super.keyTyped(character, keyCode);
}
}
@Override public int getVisibleRows() {
protected void keyTyped(char character, int keyCode) throws IOException return grid.getType() == EnumGridType.CRAFTING ? 4 : 5;
{ }
if (!checkHotbarKeys(keyCode) && searchField.textboxKeyTyped(character, keyCode))
{
}
else
{
super.keyTyped(character, keyCode);
}
}
} }

144
src/main/java/refinedstorage/gui/GuiHandler.java Normal file → Executable file
View File

@@ -11,84 +11,74 @@ import refinedstorage.container.*;
import refinedstorage.storage.IStorageGui; import refinedstorage.storage.IStorageGui;
import refinedstorage.tile.*; import refinedstorage.tile.*;
public class GuiHandler implements IGuiHandler public class GuiHandler implements IGuiHandler {
{ private Container getContainer(int ID, EntityPlayer player, TileEntity tile) {
private Container getContainer(int ID, EntityPlayer player, TileEntity tile) switch (ID) {
{ case RefinedStorageGui.CONTROLLER:
switch (ID) return new ContainerController(player);
{ case RefinedStorageGui.GRID:
case RefinedStorageGui.CONTROLLER: return new ContainerGrid(player, (TileGrid) tile);
return new ContainerController(player); case RefinedStorageGui.DISK_DRIVE:
case RefinedStorageGui.GRID: return new ContainerDiskDrive(player, (TileDiskDrive) tile);
return new ContainerGrid(player, (TileGrid) tile); case RefinedStorageGui.IMPORTER:
case RefinedStorageGui.DRIVE: return new ContainerImporter(player, (TileImporter) tile);
return new ContainerDrive(player, (TileDrive) tile); case RefinedStorageGui.EXPORTER:
case RefinedStorageGui.IMPORTER: return new ContainerExporter(player, (TileExporter) tile);
return new ContainerImporter(player, (TileImporter) tile); case RefinedStorageGui.DETECTOR:
case RefinedStorageGui.EXPORTER: return new ContainerDetector(player, (TileDetector) tile);
return new ContainerExporter(player, (TileExporter) tile); case RefinedStorageGui.SOLDERER:
case RefinedStorageGui.DETECTOR: return new ContainerSolderer(player, (TileSolderer) tile);
return new ContainerDetector(player, (TileDetector) tile); case RefinedStorageGui.DESTRUCTOR:
case RefinedStorageGui.SOLDERER: return new ContainerDestructor(player, (TileDestructor) tile);
return new ContainerSolderer(player, (TileSolderer) tile); case RefinedStorageGui.CONSTRUCTOR:
case RefinedStorageGui.WIRELESS_TRANSMITTER: return new ContainerConstructor(player, (TileConstructor) tile);
return new ContainerWirelessTransmitter(player, (TileWirelessTransmitter) tile); case RefinedStorageGui.STORAGE:
case RefinedStorageGui.DESTRUCTOR: return new ContainerStorage(player, ((IStorageGui) tile).getInventory());
return new ContainerDestructor(player); case RefinedStorageGui.RELAY:
case RefinedStorageGui.CONSTRUCTOR: return new ContainerRelay(player);
return new ContainerConstructor(player, (TileConstructor) tile); case RefinedStorageGui.INTERFACE:
case RefinedStorageGui.STORAGE: return new ContainerInterface(player, (TileInterface) tile);
return new ContainerStorage(player, ((IStorageGui) tile).getInventory()); default:
case RefinedStorageGui.RELAY: return null;
return new ContainerRelay(player); }
case RefinedStorageGui.INTERFACE: }
return new ContainerInterface(player, (TileInterface) tile);
default:
return null;
}
}
@Override @Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
{ return getContainer(ID, player, world.getTileEntity(new BlockPos(x, y, z)));
return getContainer(ID, player, world.getTileEntity(new BlockPos(x, y, z))); }
}
@Override @Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
{ TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
switch (ID) switch (ID) {
{ case RefinedStorageGui.CONTROLLER:
case RefinedStorageGui.CONTROLLER: return new GuiController((ContainerController) getContainer(ID, player, tile), (TileController) tile);
return new GuiController((ContainerController) getContainer(ID, player, tile), (TileController) tile); case RefinedStorageGui.GRID:
case RefinedStorageGui.GRID: return new GuiGrid((ContainerGrid) getContainer(ID, player, tile), (TileGrid) tile);
return new GuiGrid((ContainerGrid) getContainer(ID, player, tile), (TileGrid) tile); case RefinedStorageGui.DISK_DRIVE:
case RefinedStorageGui.DRIVE: return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile, "gui/disk_drive.png");
return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile, "gui/drive.png"); case RefinedStorageGui.IMPORTER:
case RefinedStorageGui.IMPORTER: return new GuiImporter((ContainerImporter) getContainer(ID, player, tile), (TileImporter) tile);
return new GuiImporter((ContainerImporter) getContainer(ID, player, tile), (TileImporter) tile); case RefinedStorageGui.EXPORTER:
case RefinedStorageGui.EXPORTER: return new GuiExporter((ContainerExporter) getContainer(ID, player, tile), (TileExporter) tile);
return new GuiExporter((ContainerExporter) getContainer(ID, player, tile), (TileExporter) tile); case RefinedStorageGui.DETECTOR:
case RefinedStorageGui.DETECTOR: return new GuiDetector((ContainerDetector) getContainer(ID, player, tile), (TileDetector) tile);
return new GuiDetector((ContainerDetector) getContainer(ID, player, tile), (TileDetector) tile); case RefinedStorageGui.SOLDERER:
case RefinedStorageGui.SOLDERER: return new GuiSolderer((ContainerSolderer) getContainer(ID, player, tile), (TileSolderer) tile);
return new GuiSolderer((ContainerSolderer) getContainer(ID, player, tile), (TileSolderer) tile); case RefinedStorageGui.DESTRUCTOR:
case RefinedStorageGui.WIRELESS_TRANSMITTER: return new GuiDestructor((ContainerDestructor) getContainer(ID, player, tile), (TileDestructor) tile);
return new GuiWirelessTransmitter((ContainerWirelessTransmitter) getContainer(ID, player, tile), (TileWirelessTransmitter) tile); case RefinedStorageGui.CONSTRUCTOR:
case RefinedStorageGui.DESTRUCTOR: return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile), (TileConstructor) tile);
return new GuiDestructor((ContainerDestructor) getContainer(ID, player, tile), (TileDestructor) tile); case RefinedStorageGui.STORAGE:
case RefinedStorageGui.CONSTRUCTOR: return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile);
return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile), (TileConstructor) tile); case RefinedStorageGui.RELAY:
case RefinedStorageGui.STORAGE: return new GuiRelay((ContainerRelay) getContainer(ID, player, tile), (TileRelay) tile);
return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile); case RefinedStorageGui.INTERFACE:
case RefinedStorageGui.RELAY: return new GuiInterface((ContainerInterface) getContainer(ID, player, tile), (TileInterface) tile);
return new GuiRelay((ContainerRelay) getContainer(ID, player, tile), (TileRelay) tile); default:
case RefinedStorageGui.INTERFACE: return null;
return new GuiInterface((ContainerInterface) getContainer(ID, player, tile), (TileInterface) tile); }
default: }
return null;
}
}
} }

58
src/main/java/refinedstorage/gui/GuiImporter.java Normal file → Executable file
View File

@@ -7,45 +7,39 @@ import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileImporter; import refinedstorage.tile.TileImporter;
import refinedstorage.util.InventoryUtils; import refinedstorage.util.InventoryUtils;
public class GuiImporter extends GuiBase public class GuiImporter extends GuiBase {
{ private TileImporter importer;
private TileImporter importer;
public GuiImporter(ContainerImporter container, TileImporter importer) public GuiImporter(ContainerImporter container, TileImporter importer) {
{ super(container, 176, 137);
super(container, 176, 137);
this.importer = importer; this.importer = importer;
} }
@Override @Override
public void init(int x, int y) public void init(int x, int y) {
{ addSideButton(new SideButtonRedstoneMode(importer));
addSideButton(new SideButtonRedstoneMode(importer));
addSideButton(new SideButtonMode(importer)); addSideButton(new SideButtonMode(importer));
addSideButton(new SideButtonCompare(importer, InventoryUtils.COMPARE_DAMAGE)); addSideButton(new SideButtonCompare(importer, InventoryUtils.COMPARE_DAMAGE));
addSideButton(new SideButtonCompare(importer, InventoryUtils.COMPARE_NBT)); addSideButton(new SideButtonCompare(importer, InventoryUtils.COMPARE_NBT));
} }
@Override @Override
public void update(int x, int y) public void update(int x, int y) {
{ }
}
@Override @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) public void drawBackground(int x, int y, int mouseX, int mouseY) {
{ bindTexture("gui/importer.png");
bindTexture("gui/importer.png");
drawTexture(x, y, 0, 0, width, height); drawTexture(x, y, 0, 0, width, height);
} }
@Override @Override
public void drawForeground(int mouseX, int mouseY) public void drawForeground(int mouseX, int mouseY) {
{ drawString(7, 7, t("gui.refinedstorage:importer"));
drawString(7, 7, t("gui.refinedstorage:importer")); drawString(7, 43, t("container.inventory"));
drawString(7, 43, t("container.inventory")); }
}
} }

67
src/main/java/refinedstorage/gui/GuiInterface.java Normal file → Executable file
View File

@@ -6,53 +6,38 @@ import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileInterface; import refinedstorage.tile.TileInterface;
import refinedstorage.util.InventoryUtils; import refinedstorage.util.InventoryUtils;
public class GuiInterface extends GuiBase public class GuiInterface extends GuiBase {
{ private TileInterface tile;
private TileInterface tile;
public GuiInterface(ContainerInterface container, TileInterface tile) public GuiInterface(ContainerInterface container, TileInterface tile) {
{ super(container, 176, 218);
super(container, 176, 218);
this.tile = tile; this.tile = tile;
} }
@Override @Override
public void init(int x, int y) public void init(int x, int y) {
{ addSideButton(new SideButtonRedstoneMode(tile));
addSideButton(new SideButtonRedstoneMode(tile));
addSideButton(new SideButtonCompare(tile, InventoryUtils.COMPARE_DAMAGE)); addSideButton(new SideButtonCompare(tile, InventoryUtils.COMPARE_DAMAGE));
addSideButton(new SideButtonCompare(tile, InventoryUtils.COMPARE_NBT)); addSideButton(new SideButtonCompare(tile, InventoryUtils.COMPARE_NBT));
} }
@Override @Override
public void update(int x, int y) public void update(int x, int y) {
{ }
}
@Override @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) public void drawBackground(int x, int y, int mouseX, int mouseY) {
{ bindTexture("gui/interface.png");
bindTexture("gui/interface.png");
drawTexture(x, y, 0, 0, width, height); drawTexture(x, y, 0, 0, width, height);
} }
@Override @Override
public void drawForeground(int mouseX, int mouseY) public void drawForeground(int mouseX, int mouseY) {
{ drawString(7, 7, t("gui.refinedstorage:interface.import"));
drawString(7, 7, t("gui.refinedstorage:interface.import")); drawString(7, 42, t("gui.refinedstorage:interface.export"));
drawString(7, 42, t("gui.refinedstorage:interface.export")); drawString(7, 123, t("container.inventory"));
drawString(7, 123, t("container.inventory")); }
if (inBounds(162, 42, 7, 7, mouseX, mouseY))
{
String message = t("gui.refinedstorage:interface.export.explanation.0");
message += "\n" + t("gui.refinedstorage:interface.export.explanation.1");
message += "\n" + t("gui.refinedstorage:interface.export.explanation.2");
drawTooltip(mouseX, mouseY, message);
}
}
} }

52
src/main/java/refinedstorage/gui/GuiRelay.java Normal file → Executable file
View File

@@ -4,40 +4,34 @@ import refinedstorage.container.ContainerRelay;
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode; import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileRelay; import refinedstorage.tile.TileRelay;
public class GuiRelay extends GuiBase public class GuiRelay extends GuiBase {
{ private TileRelay relay;
private TileRelay relay;
public GuiRelay(ContainerRelay container, TileRelay relay) public GuiRelay(ContainerRelay container, TileRelay relay) {
{ super(container, 176, 131);
super(container, 176, 131);
this.relay = relay; this.relay = relay;
} }
@Override @Override
public void init(int x, int y) public void init(int x, int y) {
{ addSideButton(new SideButtonRedstoneMode(relay));
addSideButton(new SideButtonRedstoneMode(relay)); }
}
@Override @Override
public void update(int x, int y) public void update(int x, int y) {
{ }
}
@Override @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) public void drawBackground(int x, int y, int mouseX, int mouseY) {
{ bindTexture("gui/relay.png");
bindTexture("gui/relay.png");
drawTexture(x, y, 0, 0, width, height); drawTexture(x, y, 0, 0, width, height);
} }
@Override @Override
public void drawForeground(int mouseX, int mouseY) public void drawForeground(int mouseX, int mouseY) {
{ drawString(7, 7, t("gui.refinedstorage:relay"));
drawString(7, 7, t("gui.refinedstorage:relay")); drawString(7, 39, t("container.inventory"));
drawString(7, 39, t("container.inventory")); }
}
} }

61
src/main/java/refinedstorage/gui/GuiSolderer.java Normal file → Executable file
View File

@@ -1,48 +1,41 @@
package refinedstorage.gui; package refinedstorage.gui;
import net.minecraft.inventory.Container; import refinedstorage.container.ContainerSolderer;
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode; import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileSolderer; import refinedstorage.tile.TileSolderer;
public class GuiSolderer extends GuiBase public class GuiSolderer extends GuiBase {
{ private TileSolderer solderer;
private TileSolderer solderer;
public GuiSolderer(Container container, TileSolderer solderer) public GuiSolderer(ContainerSolderer container, TileSolderer solderer) {
{ super(container, 176, 177);
super(container, 176, 177);
this.solderer = solderer; this.solderer = solderer;
} }
@Override @Override
public void init(int x, int y) public void init(int x, int y) {
{ addSideButton(new SideButtonRedstoneMode(solderer));
addSideButton(new SideButtonRedstoneMode(solderer)); }
}
@Override @Override
public void update(int x, int y) public void update(int x, int y) {
{ }
}
@Override @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) public void drawBackground(int x, int y, int mouseX, int mouseY) {
{ bindTexture("gui/solderer.png");
bindTexture("gui/solderer.png");
drawTexture(x, y, 0, 0, width, height); drawTexture(x, y, 0, 0, width, height);
if (solderer.isWorking()) if (solderer.isWorking()) {
{ drawTexture(x + 83, y + 40 - 1, 177, 0, solderer.getProgressScaled(22), 15);
drawTexture(x + 83, y + 40 - 1, 177, 0, solderer.getProgressScaled(22), 15); }
} }
}
@Override @Override
public void drawForeground(int mouseX, int mouseY) public void drawForeground(int mouseX, int mouseY) {
{ drawString(7, 7, t("gui.refinedstorage:solderer"));
drawString(7, 7, t("gui.refinedstorage:solderer")); drawString(7, 82, t("container.inventory"));
drawString(7, 82, t("container.inventory")); }
}
} }

164
src/main/java/refinedstorage/gui/GuiStorage.java Normal file → Executable file
View File

@@ -1,7 +1,6 @@
package refinedstorage.gui; package refinedstorage.gui;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import java.io.IOException;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiTextField;
import refinedstorage.container.ContainerStorage; import refinedstorage.container.ContainerStorage;
import refinedstorage.gui.sidebutton.SideButtonCompare; import refinedstorage.gui.sidebutton.SideButtonCompare;
@@ -10,114 +9,99 @@ import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.storage.IStorageGui; import refinedstorage.storage.IStorageGui;
import refinedstorage.util.InventoryUtils; import refinedstorage.util.InventoryUtils;
public class GuiStorage extends GuiBase import java.io.IOException;
{
private IStorageGui gui;
private String texture;
private GuiTextField priorityField; public class GuiStorage extends GuiBase {
private IStorageGui gui;
private String texture;
private int barX = 8; private GuiTextField priorityField;
private int barY = 54;
private int barWidth = 16;
private int barHeight = 58;
public GuiStorage(ContainerStorage container, IStorageGui gui, String texture) private int barX = 8;
{ private int barY = 54;
super(container, 176, 211); private int barWidth = 16;
private int barHeight = 58;
this.gui = gui; public GuiStorage(ContainerStorage container, IStorageGui gui, String texture) {
this.texture = texture; super(container, 176, 211);
}
public GuiStorage(ContainerStorage container, IStorageGui gui) this.gui = gui;
{ this.texture = texture;
this(container, gui, "gui/storage.png"); }
}
@Override public GuiStorage(ContainerStorage container, IStorageGui gui) {
public void init(int x, int y) this(container, gui, "gui/storage.png");
{ }
if (gui.getRedstoneModeSetting() != null)
{
addSideButton(new SideButtonRedstoneMode(gui.getRedstoneModeSetting()));
}
if (gui.getModeSetting() != null) @Override
{ public void init(int x, int y) {
addSideButton(new SideButtonMode(gui.getModeSetting())); if (gui.getRedstoneModeSetting() != null) {
} addSideButton(new SideButtonRedstoneMode(gui.getRedstoneModeSetting()));
}
if (gui.getCompareSetting() != null) if (gui.getModeSetting() != null) {
{ addSideButton(new SideButtonMode(gui.getModeSetting()));
addSideButton(new SideButtonCompare(gui.getCompareSetting(), InventoryUtils.COMPARE_DAMAGE)); }
addSideButton(new SideButtonCompare(gui.getCompareSetting(), InventoryUtils.COMPARE_NBT));
}
priorityField = new GuiTextField(0, fontRendererObj, x + 98 + 1, y + 54 + 1, 25, fontRendererObj.FONT_HEIGHT); if (gui.getCompareSetting() != null) {
priorityField.setText(String.valueOf(gui.getPriority())); addSideButton(new SideButtonCompare(gui.getCompareSetting(), InventoryUtils.COMPARE_DAMAGE));
priorityField.setEnableBackgroundDrawing(false); addSideButton(new SideButtonCompare(gui.getCompareSetting(), InventoryUtils.COMPARE_NBT));
priorityField.setVisible(true); }
priorityField.setTextColor(16777215);
priorityField.setCanLoseFocus(false);
priorityField.setFocused(true);
}
@Override priorityField = new GuiTextField(0, fontRendererObj, x + 98 + 1, y + 54 + 1, 25, fontRendererObj.FONT_HEIGHT);
public void update(int x, int y) priorityField.setText(String.valueOf(gui.getPriority()));
{ priorityField.setEnableBackgroundDrawing(false);
} priorityField.setVisible(true);
priorityField.setTextColor(16777215);
priorityField.setCanLoseFocus(false);
priorityField.setFocused(true);
}
@Override @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) public void update(int x, int y) {
{ }
bindTexture(texture);
drawTexture(x, y, 0, 0, width, height); @Override
public void drawBackground(int x, int y, int mouseX, int mouseY) {
bindTexture(texture);
int barHeightNew = (int) ((float) gui.getStored() / (float) gui.getCapacity() * (float) barHeight); drawTexture(x, y, 0, 0, width, height);
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 179, 0 + (barHeight - barHeightNew), barWidth, barHeightNew); int barHeightNew = (int) ((float) gui.getStored() / (float) gui.getCapacity() * (float) barHeight);
priorityField.drawTextBox(); drawTexture(x + barX, y + barY + barHeight - barHeightNew, 179, barHeight - barHeightNew, barWidth, barHeightNew);
}
@Override priorityField.drawTextBox();
public void drawForeground(int mouseX, int mouseY) }
{
drawString(7, 7, t(gui.getName()));
drawString(7, 42, gui.getCapacity() == -1 ? t("misc.refinedstorage:storage.stored_minimal", gui.getStored()) : t("misc.refinedstorage:storage.stored_capacity_minimal", gui.getStored(), gui.getCapacity()));
drawString(97, 42, t("misc.refinedstorage:priority"));
drawString(7, 117, t("container.inventory"));
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) @Override
{ public void drawForeground(int mouseX, int mouseY) {
int full = 0; drawString(7, 7, t(gui.getName()));
drawString(7, 42, gui.getCapacity() == -1 ? t("misc.refinedstorage:storage.stored_minimal", gui.getStored()) : t("misc.refinedstorage:storage.stored_capacity_minimal", gui.getStored(), gui.getCapacity()));
drawString(97, 42, t("misc.refinedstorage:priority"));
drawString(7, 117, t("container.inventory"));
if (gui.getCapacity() >= 0) if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) {
{ int full = 0;
full = (int) ((float) gui.getStored() / (float) gui.getCapacity() * 100f);
}
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:storage.full", full)); if (gui.getCapacity() >= 0) {
} full = (int) ((float) gui.getStored() / (float) gui.getCapacity() * 100f);
} }
@Override drawTooltip(mouseX, mouseY, t("misc.refinedstorage:storage.full", full));
protected void keyTyped(char character, int keyCode) throws IOException }
{ }
if (!checkHotbarKeys(keyCode) && priorityField.textboxKeyTyped(character, keyCode))
{
Integer result = Ints.tryParse(priorityField.getText());
if (result != null) @Override
{ protected void keyTyped(char character, int keyCode) throws IOException {
gui.onPriorityChanged(result); if (!checkHotbarKeys(keyCode) && priorityField.textboxKeyTyped(character, keyCode)) {
} Integer result = Ints.tryParse(priorityField.getText());
}
else if (result != null) {
{ gui.onPriorityChanged(result);
super.keyTyped(character, keyCode); }
} } else {
} super.keyTyped(character, keyCode);
}
}
} }

View File

@@ -1,57 +0,0 @@
package refinedstorage.gui;
import net.minecraft.inventory.Container;
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileWirelessTransmitter;
public class GuiWirelessTransmitter extends GuiBase
{
private TileWirelessTransmitter wirelessTransmitter;
public GuiWirelessTransmitter(Container container, TileWirelessTransmitter wirelessTransmitter)
{
super(container, 176, 137);
this.wirelessTransmitter = wirelessTransmitter;
}
@Override
public void init(int x, int y)
{
addSideButton(new SideButtonRedstoneMode(wirelessTransmitter));
}
@Override
public void update(int x, int y)
{
}
@Override
public void drawBackground(int x, int y, int mouseX, int mouseY)
{
bindTexture("gui/wireless_transmitter.png");
drawTexture(x, y, 0, 0, width, height);
if (wirelessTransmitter.isWorking())
{
int progress = (int) ((float) wirelessTransmitter.getProgress() / (float) TileWirelessTransmitter.TOTAL_PROGRESS * 14f);
drawTexture(x + 36 - 1, y + 21 - 1 + progress, 178, 0 + progress, 14, 14);
}
}
@Override
public void drawForeground(int mouseX, int mouseY)
{
drawString(7, 7, t("gui.refinedstorage:wireless_transmitter"));
drawString(7, 43, t("container.inventory"));
if (inBounds(36, 21, 14, 14, mouseX, mouseY) && wirelessTransmitter.isWorking())
{
int workRemaining = (int) (((float) (TileWirelessTransmitter.TOTAL_PROGRESS - wirelessTransmitter.getProgress())) / (float) TileWirelessTransmitter.TOTAL_PROGRESS * 100f);
drawTooltip(mouseX, mouseY, workRemaining + "%");
}
}
}

151
src/main/java/refinedstorage/gui/Scrollbar.java Normal file → Executable file
View File

@@ -2,110 +2,91 @@ package refinedstorage.gui;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
public class Scrollbar public class Scrollbar {
{ private boolean canScroll = true;
private boolean canScroll = true;
private int x; private int x;
private int y; private int y;
private int scrollbarWidth; private int scrollbarWidth;
private int scrollbarHeight; private int scrollbarHeight;
private float currentScroll; private float currentScroll;
private boolean wasClicking = false; private boolean wasClicking = false;
private boolean isScrolling = false; private boolean isScrolling = false;
public Scrollbar(int x, int y, int scrollbarWidth, int scrollbarHeight) public Scrollbar(int x, int y, int scrollbarWidth, int scrollbarHeight) {
{ this.x = x;
this.x = x; this.y = y;
this.y = y; this.scrollbarWidth = scrollbarWidth;
this.scrollbarWidth = scrollbarWidth; this.scrollbarHeight = scrollbarHeight;
this.scrollbarHeight = scrollbarHeight; }
}
public void setCanScroll(boolean canScroll) public void setCanScroll(boolean canScroll) {
{ this.canScroll = canScroll;
this.canScroll = canScroll; }
}
public boolean canScroll() public boolean canScroll() {
{ return canScroll;
return canScroll; }
}
public float getCurrentScroll() public float getCurrentScroll() {
{ return currentScroll;
return currentScroll; }
}
public void setCurrentScroll(float newCurrentScroll) public void setCurrentScroll(float newCurrentScroll) {
{ if (newCurrentScroll < 0) {
if (newCurrentScroll < 0) newCurrentScroll = 0;
{ }
newCurrentScroll = 0;
}
int scrollbarItselfHeight = 12; int scrollbarItselfHeight = 12;
int max = scrollbarHeight - scrollbarItselfHeight - 3; int max = scrollbarHeight - scrollbarItselfHeight - 3;
if (newCurrentScroll > max) if (newCurrentScroll > max) {
{ newCurrentScroll = max;
newCurrentScroll = max; }
}
currentScroll = newCurrentScroll; currentScroll = newCurrentScroll;
} }
public void draw(GuiBase gui) public void draw(GuiBase gui) {
{ gui.bindTexture("icons.png");
gui.bindTexture("icons.png"); gui.drawTexture(gui.guiLeft + x, gui.guiTop + y + (int) currentScroll, canScroll() ? 232 : 244, 0, 12, 15);
gui.drawTexture(gui.guiLeft + x, gui.guiTop + y + (int) currentScroll, canScroll() ? 232 : 244, 0, 12, 15); }
}
public void update(GuiBase gui, int mouseX, int mouseY) public void update(GuiBase gui, int mouseX, int mouseY) {
{ if (!canScroll()) {
if (!canScroll()) isScrolling = false;
{ wasClicking = false;
isScrolling = false; currentScroll = 0;
wasClicking = false; } else {
currentScroll = 0; int wheel = Mouse.getDWheel();
}
else
{
int wheel = Mouse.getDWheel();
wheel = Math.max(Math.min(-wheel, 1), -1); wheel = Math.max(Math.min(-wheel, 1), -1);
float delta = 15; float delta = 15;
if (wheel == -1) if (wheel == -1) {
{ setCurrentScroll(currentScroll - delta);
setCurrentScroll(currentScroll - delta); } else if (wheel == 1) {
} setCurrentScroll(currentScroll + delta);
else if (wheel == 1) }
{
setCurrentScroll(currentScroll + delta);
}
boolean down = Mouse.isButtonDown(0); boolean down = Mouse.isButtonDown(0);
if (!wasClicking && down && gui.inBounds(x, y, scrollbarWidth, scrollbarHeight, mouseX, mouseY)) if (!wasClicking && down && gui.inBounds(x, y, scrollbarWidth, scrollbarHeight, mouseX, mouseY)) {
{ isScrolling = true;
isScrolling = true; }
}
if (!down) if (!down) {
{ isScrolling = false;
isScrolling = false; }
}
wasClicking = down; wasClicking = down;
if (isScrolling) if (isScrolling) {
{ setCurrentScroll(mouseY - 20);
setCurrentScroll(mouseY - 20); }
} }
} }
}
} }

View File

@@ -2,45 +2,38 @@ package refinedstorage.gui.sidebutton;
import refinedstorage.gui.GuiBase; import refinedstorage.gui.GuiBase;
public abstract class SideButton public abstract class SideButton {
{ private int id;
private int id; private int x;
private int x; private int y;
private int y;
public int getId() public int getId() {
{ return id;
return id; }
}
public void setId(int id) public void setId(int id) {
{ this.id = id;
this.id = id; }
}
public int getX() public int getX() {
{ return x;
return x; }
}
public void setX(int x) public void setX(int x) {
{ this.x = x;
this.x = x; }
}
public int getY() public int getY() {
{ return y;
return y; }
}
public void setY(int y) public void setY(int y) {
{ this.y = y;
this.y = y; }
}
public abstract String getTooltip(GuiBase gui); public abstract String getTooltip(GuiBase gui);
public abstract void draw(GuiBase gui, int x, int y); public abstract void draw(GuiBase gui, int x, int y);
public abstract void actionPerformed(); public abstract void actionPerformed();
} }

View File

@@ -7,60 +7,49 @@ import refinedstorage.network.MessageCompareUpdate;
import refinedstorage.tile.settings.ICompareSetting; import refinedstorage.tile.settings.ICompareSetting;
import refinedstorage.util.InventoryUtils; import refinedstorage.util.InventoryUtils;
public class SideButtonCompare extends SideButton public class SideButtonCompare extends SideButton {
{ private ICompareSetting setting;
private ICompareSetting setting; private int mask;
private int mask;
public SideButtonCompare(ICompareSetting setting, int mask) public SideButtonCompare(ICompareSetting setting, int mask) {
{ this.setting = setting;
this.setting = setting; this.mask = mask;
this.mask = mask; }
}
@Override @Override
public String getTooltip(GuiBase gui) public String getTooltip(GuiBase gui) {
{ StringBuilder builder = new StringBuilder();
StringBuilder builder = new StringBuilder();
builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:compare." + mask)).append(TextFormatting.RESET).append("\n"); builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:compare." + mask)).append(TextFormatting.RESET).append("\n");
if ((setting.getCompare() & mask) == mask) if ((setting.getCompare() & mask) == mask) {
{ builder.append(gui.t("misc.refinedstorage:yes"));
builder.append(gui.t("misc.refinedstorage:yes")); } else {
} builder.append(gui.t("misc.refinedstorage:no"));
else }
{
builder.append(gui.t("misc.refinedstorage:no"));
}
return builder.toString(); return builder.toString();
} }
@Override @Override
public void draw(GuiBase gui, int x, int y) public void draw(GuiBase gui, int x, int y) {
{ gui.bindTexture("icons.png");
gui.bindTexture("icons.png");
int ty = 0; int ty = 0;
if (mask == InventoryUtils.COMPARE_DAMAGE) if (mask == InventoryUtils.COMPARE_DAMAGE) {
{ ty = 80;
ty = 80; } else if (mask == InventoryUtils.COMPARE_NBT) {
} ty = 48;
else if (mask == InventoryUtils.COMPARE_NBT) }
{
ty = 48;
}
int tx = (setting.getCompare() & mask) == mask ? 0 : 16; int tx = (setting.getCompare() & mask) == mask ? 0 : 16;
gui.drawTexture(x, y + 2, tx, ty, 16, 16); gui.drawTexture(x, y + 2, tx, ty, 16, 16);
} }
@Override @Override
public void actionPerformed() public void actionPerformed() {
{ RefinedStorage.NETWORK.sendToServer(new MessageCompareUpdate(setting, setting.getCompare() ^ mask));
RefinedStorage.NETWORK.sendToServer(new MessageCompareUpdate(setting, setting.getCompare() ^ mask)); }
}
} }

View File

@@ -8,36 +8,30 @@ import refinedstorage.gui.GuiBase;
import refinedstorage.network.MessageDetectorModeUpdate; import refinedstorage.network.MessageDetectorModeUpdate;
import refinedstorage.tile.TileDetector; import refinedstorage.tile.TileDetector;
public class SideButtonDetectorMode extends SideButton public class SideButtonDetectorMode extends SideButton {
{ private TileDetector detector;
private TileDetector detector;
public SideButtonDetectorMode(TileDetector detector) public SideButtonDetectorMode(TileDetector detector) {
{ this.detector = detector;
this.detector = detector; }
}
@Override @Override
public String getTooltip(GuiBase gui) public String getTooltip(GuiBase gui) {
{ StringBuilder builder = new StringBuilder();
StringBuilder builder = new StringBuilder();
builder.append(TextFormatting.GREEN).append(gui.t("sidebutton.refinedstorage:detector.mode")).append(TextFormatting.RESET).append("\n"); builder.append(TextFormatting.GREEN).append(gui.t("sidebutton.refinedstorage:detector.mode")).append(TextFormatting.RESET).append("\n");
builder.append(gui.t("sidebutton.refinedstorage:detector.mode." + detector.getMode()));
builder.append(gui.t("sidebutton.refinedstorage:detector.mode." + detector.getMode())); return builder.toString();
}
return builder.toString(); @Override
} public void draw(GuiBase gui, int x, int y) {
gui.drawItem(x, y, new ItemStack(Items.redstone, 1));
}
@Override @Override
public void draw(GuiBase gui, int x, int y) public void actionPerformed() {
{ RefinedStorage.NETWORK.sendToServer(new MessageDetectorModeUpdate(detector));
gui.drawItem(x, y, new ItemStack(Items.redstone, 1)); }
}
@Override
public void actionPerformed()
{
RefinedStorage.NETWORK.sendToServer(new MessageDetectorModeUpdate(detector));
}
} }

View File

@@ -6,48 +6,39 @@ import refinedstorage.gui.GuiBase;
import refinedstorage.network.MessageGridSortingUpdate; import refinedstorage.network.MessageGridSortingUpdate;
import refinedstorage.tile.TileGrid; import refinedstorage.tile.TileGrid;
public class SideButtonGridSortingDirection extends SideButton public class SideButtonGridSortingDirection extends SideButton {
{ private TileGrid grid;
private TileGrid grid;
public SideButtonGridSortingDirection(TileGrid grid) public SideButtonGridSortingDirection(TileGrid grid) {
{ this.grid = grid;
this.grid = grid; }
}
@Override @Override
public String getTooltip(GuiBase gui) public String getTooltip(GuiBase gui) {
{ StringBuilder builder = new StringBuilder();
StringBuilder builder = new StringBuilder();
builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:sorting.direction")).append(TextFormatting.RESET).append("\n"); builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:sorting.direction")).append(TextFormatting.RESET).append("\n");
builder.append(gui.t("sidebutton.refinedstorage:sorting.direction." + grid.getSortingDirection()));
builder.append(gui.t("sidebutton.refinedstorage:sorting.direction." + grid.getSortingDirection())); return builder.toString();
}
return builder.toString(); @Override
} public void draw(GuiBase gui, int x, int y) {
gui.bindTexture("icons.png");
gui.drawTexture(x, y + 2 - 1, grid.getSortingDirection() * 16, 16, 16, 16);
}
@Override @Override
public void draw(GuiBase gui, int x, int y) public void actionPerformed() {
{ int dir = grid.getSortingDirection();
gui.bindTexture("icons.png");
gui.drawTexture(x, y + 2 - 1, grid.getSortingDirection() * 16, 16, 16, 16);
}
@Override if (dir == TileGrid.SORTING_DIRECTION_ASCENDING) {
public void actionPerformed() dir = TileGrid.SORTING_DIRECTION_DESCENDING;
{ } else if (dir == TileGrid.SORTING_DIRECTION_DESCENDING) {
int dir = grid.getSortingDirection(); dir = TileGrid.SORTING_DIRECTION_ASCENDING;
}
if (dir == TileGrid.SORTING_DIRECTION_ASCENDING) RefinedStorage.NETWORK.sendToServer(new MessageGridSortingUpdate(grid, dir, grid.getSortingType()));
{ }
dir = TileGrid.SORTING_DIRECTION_DESCENDING;
}
else if (dir == TileGrid.SORTING_DIRECTION_DESCENDING)
{
dir = TileGrid.SORTING_DIRECTION_ASCENDING;
}
RefinedStorage.NETWORK.sendToServer(new MessageGridSortingUpdate(grid, dir, grid.getSortingType()));
}
} }

View File

@@ -6,48 +6,39 @@ import refinedstorage.gui.GuiBase;
import refinedstorage.network.MessageGridSortingUpdate; import refinedstorage.network.MessageGridSortingUpdate;
import refinedstorage.tile.TileGrid; import refinedstorage.tile.TileGrid;
public class SideButtonGridSortingType extends SideButton public class SideButtonGridSortingType extends SideButton {
{ private TileGrid grid;
private TileGrid grid;
public SideButtonGridSortingType(TileGrid grid) public SideButtonGridSortingType(TileGrid grid) {
{ this.grid = grid;
this.grid = grid; }
}
@Override @Override
public String getTooltip(GuiBase gui) public String getTooltip(GuiBase gui) {
{ StringBuilder builder = new StringBuilder();
StringBuilder builder = new StringBuilder();
builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:sorting.type")).append(TextFormatting.RESET).append("\n"); builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:sorting.type")).append(TextFormatting.RESET).append("\n");
builder.append(gui.t("sidebutton.refinedstorage:sorting.type." + grid.getSortingType()));
builder.append(gui.t("sidebutton.refinedstorage:sorting.type." + grid.getSortingType())); return builder.toString();
}
return builder.toString(); @Override
} public void draw(GuiBase gui, int x, int y) {
gui.bindTexture("icons.png");
gui.drawTexture(x - 1, y + 2 - 1, grid.getSortingType() * 16, 32, 16, 16);
}
@Override @Override
public void draw(GuiBase gui, int x, int y) public void actionPerformed() {
{ int type = grid.getSortingType();
gui.bindTexture("icons.png");
gui.drawTexture(x - 1, y + 2 - 1, grid.getSortingType() * 16, 32, 16, 16);
}
@Override if (type == TileGrid.SORTING_TYPE_QUANTITY) {
public void actionPerformed() type = TileGrid.SORTING_TYPE_NAME;
{ } else if (type == TileGrid.SORTING_TYPE_NAME) {
int type = grid.getSortingType(); type = TileGrid.SORTING_TYPE_QUANTITY;
}
if (type == TileGrid.SORTING_TYPE_QUANTITY) RefinedStorage.NETWORK.sendToServer(new MessageGridSortingUpdate(grid, grid.getSortingDirection(), type));
{ }
type = TileGrid.SORTING_TYPE_NAME;
}
else if (type == TileGrid.SORTING_TYPE_NAME)
{
type = TileGrid.SORTING_TYPE_QUANTITY;
}
RefinedStorage.NETWORK.sendToServer(new MessageGridSortingUpdate(grid, grid.getSortingDirection(), type));
}
} }

View File

@@ -6,49 +6,40 @@ import refinedstorage.gui.GuiBase;
import refinedstorage.network.MessageModeToggle; import refinedstorage.network.MessageModeToggle;
import refinedstorage.tile.settings.IModeSetting; import refinedstorage.tile.settings.IModeSetting;
public class SideButtonMode extends SideButton public class SideButtonMode extends SideButton {
{ private IModeSetting mode;
private IModeSetting mode;
public SideButtonMode(IModeSetting mode) public SideButtonMode(IModeSetting mode) {
{ this.mode = mode;
this.mode = mode; }
}
@Override @Override
public String getTooltip(GuiBase gui) public String getTooltip(GuiBase gui) {
{ StringBuilder builder = new StringBuilder();
StringBuilder builder = new StringBuilder();
builder.append(TextFormatting.GREEN).append(gui.t("sidebutton.refinedstorage:mode")).append(TextFormatting.RESET).append("\n"); builder.append(TextFormatting.GREEN).append(gui.t("sidebutton.refinedstorage:mode")).append(TextFormatting.RESET).append("\n");
builder.append(gui.t("sidebutton.refinedstorage:mode." + (mode.isWhitelist() ? "whitelist" : "blacklist")));
builder.append(gui.t("sidebutton.refinedstorage:mode." + (mode.isWhitelist() ? "whitelist" : "blacklist"))); return builder.toString();
}
return builder.toString(); @Override
} public void draw(GuiBase gui, int x, int y) {
gui.bindTexture("icons.png");
@Override int tx = 0;
public void draw(GuiBase gui, int x, int y)
{
gui.bindTexture("icons.png");
int tx = 0; if (mode.isWhitelist()) {
tx = 0;
} else if (mode.isBlacklist()) {
tx = 16;
}
if (mode.isWhitelist()) gui.drawTexture(x, y + 1, tx, 64, 16, 16);
{ }
tx = 0;
}
else if (mode.isBlacklist())
{
tx = 16;
}
gui.drawTexture(x, y + 1, tx, 64, 16, 16); @Override
} public void actionPerformed() {
RefinedStorage.NETWORK.sendToServer(new MessageModeToggle(mode));
@Override }
public void actionPerformed()
{
RefinedStorage.NETWORK.sendToServer(new MessageModeToggle(mode));
}
} }

View File

@@ -6,37 +6,31 @@ import refinedstorage.gui.GuiBase;
import refinedstorage.network.MessageRedstoneModeUpdate; import refinedstorage.network.MessageRedstoneModeUpdate;
import refinedstorage.tile.settings.IRedstoneModeSetting; import refinedstorage.tile.settings.IRedstoneModeSetting;
public class SideButtonRedstoneMode extends SideButton public class SideButtonRedstoneMode extends SideButton {
{ private IRedstoneModeSetting setting;
private IRedstoneModeSetting setting;
public SideButtonRedstoneMode(IRedstoneModeSetting setting) public SideButtonRedstoneMode(IRedstoneModeSetting setting) {
{ this.setting = setting;
this.setting = setting; }
}
@Override @Override
public String getTooltip(GuiBase gui) public String getTooltip(GuiBase gui) {
{ StringBuilder builder = new StringBuilder();
StringBuilder builder = new StringBuilder();
builder.append(TextFormatting.RED).append(gui.t("sidebutton.refinedstorage:redstone_mode")).append(TextFormatting.RESET).append("\n"); builder.append(TextFormatting.RED).append(gui.t("sidebutton.refinedstorage:redstone_mode")).append(TextFormatting.RESET).append("\n");
builder.append(gui.t("sidebutton.refinedstorage:redstone_mode." + setting.getRedstoneMode().id));
builder.append(gui.t("sidebutton.refinedstorage:redstone_mode." + setting.getRedstoneMode().id)); return builder.toString();
}
return builder.toString(); @Override
} public void draw(GuiBase gui, int x, int y) {
gui.bindTexture("icons.png");
gui.drawTexture(x, y + 1, setting.getRedstoneMode().id * 16, 0, 16, 16);
}
@Override @Override
public void draw(GuiBase gui, int x, int y) public void actionPerformed() {
{ RefinedStorage.NETWORK.sendToServer(new MessageRedstoneModeUpdate(setting));
gui.bindTexture("icons.png"); }
gui.drawTexture(x, y + 1, setting.getRedstoneMode().id * 16, 0, 16, 16);
}
@Override
public void actionPerformed()
{
RefinedStorage.NETWORK.sendToServer(new MessageRedstoneModeUpdate(setting));
}
} }

View File

@@ -6,162 +6,133 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
public class InventorySimple implements IInventory public class InventorySimple implements IInventory {
{ private TileEntity tile;
private TileEntity tile; private ItemStack[] inventory;
private ItemStack[] inventory; private int size;
private int size; private String name;
private String name;
public InventorySimple(String name, int size) public InventorySimple(String name, int size) {
{ this.name = name;
this.name = name; this.size = size;
this.size = size; this.inventory = new ItemStack[size];
this.inventory = new ItemStack[size]; }
}
public InventorySimple(String name, int size, TileEntity tile) public InventorySimple(String name, int size, TileEntity tile) {
{ this(name, size);
this(name, size);
this.tile = tile; this.tile = tile;
} }
@Override @Override
public int getSizeInventory() public int getSizeInventory() {
{ return size;
return size; }
}
@Override @Override
public ItemStack getStackInSlot(int slotIndex) public ItemStack getStackInSlot(int slotIndex) {
{ return inventory[slotIndex];
return inventory[slotIndex]; }
}
@Override @Override
public ItemStack decrStackSize(int slot, int amount) public ItemStack decrStackSize(int slot, int amount) {
{ ItemStack stack = getStackInSlot(slot);
ItemStack stack = getStackInSlot(slot);
if (stack != null) if (stack != null) {
{ if (stack.stackSize <= amount) {
if (stack.stackSize <= amount) setInventorySlotContents(slot, null);
{ } else {
setInventorySlotContents(slot, null); stack = stack.splitStack(amount);
}
else
{
stack = stack.splitStack(amount);
if (stack.stackSize == 0) if (stack.stackSize == 0) {
{ setInventorySlotContents(slot, null);
setInventorySlotContents(slot, null); }
} }
} }
}
return stack; return stack;
} }
@Override @Override
public ItemStack removeStackFromSlot(int slot) public ItemStack removeStackFromSlot(int slot) {
{ ItemStack stack = getStackInSlot(slot);
ItemStack stack = getStackInSlot(slot);
if (stack != null) if (stack != null) {
{ setInventorySlotContents(slot, null);
setInventorySlotContents(slot, null); }
}
return stack; return stack;
} }
@Override @Override
public void setInventorySlotContents(int slot, ItemStack stack) public void setInventorySlotContents(int slot, ItemStack stack) {
{ if (stack != null && stack.stackSize > getInventoryStackLimit()) {
if (stack != null && stack.stackSize > getInventoryStackLimit()) stack.stackSize = getInventoryStackLimit();
{ }
stack.stackSize = getInventoryStackLimit();
}
inventory[slot] = stack; inventory[slot] = stack;
} }
@Override @Override
public String getName() public String getName() {
{ return this.name;
return this.name; }
}
@Override @Override
public boolean hasCustomName() public boolean hasCustomName() {
{ return true;
return true; }
}
@Override @Override
public int getInventoryStackLimit() public int getInventoryStackLimit() {
{ return 64;
return 64; }
}
@Override @Override
public boolean isUseableByPlayer(EntityPlayer player) public boolean isUseableByPlayer(EntityPlayer player) {
{ return true;
return true; }
}
@Override @Override
public boolean isItemValidForSlot(int slot, ItemStack stack) public boolean isItemValidForSlot(int slot, ItemStack stack) {
{ return true;
return true; }
}
@Override @Override
public void markDirty() public void markDirty() {
{ if (tile != null) {
if (tile != null) tile.markDirty();
{ }
tile.markDirty(); }
}
}
@Override @Override
public void openInventory(EntityPlayer playerIn) public void openInventory(EntityPlayer playerIn) {
{ }
}
@Override @Override
public void closeInventory(EntityPlayer playerIn) public void closeInventory(EntityPlayer playerIn) {
{ }
}
@Override @Override
public int getField(int id) public int getField(int id) {
{ return 0;
return 0; }
}
@Override @Override
public void setField(int id, int value) public void setField(int id, int value) {
{ }
}
@Override @Override
public int getFieldCount() public int getFieldCount() {
{ return 0;
return 0; }
}
@Override @Override
public void clear() public void clear() {
{ }
}
@Override @Override
public ITextComponent getDisplayName() public ITextComponent getDisplayName() {
{ return null;
return null; }
}
} }

39
src/main/java/refinedstorage/item/ItemBase.java Normal file → Executable file
View File

@@ -4,31 +4,26 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
public abstract class ItemBase extends Item public abstract class ItemBase extends Item {
{ private String name;
private String name;
public ItemBase(String name) public ItemBase(String name) {
{ this.name = name;
this.name = name;
setCreativeTab(RefinedStorage.TAB); setCreativeTab(RefinedStorage.TAB);
} }
@Override @Override
public String getUnlocalizedName() public String getUnlocalizedName() {
{ return "item." + RefinedStorage.ID + ":" + name;
return "item." + RefinedStorage.ID + ":" + name; }
}
@Override @Override
public String getUnlocalizedName(ItemStack stack) public String getUnlocalizedName(ItemStack stack) {
{ if (getHasSubtypes()) {
if (getHasSubtypes()) return getUnlocalizedName() + "." + stack.getItemDamage();
{ }
return getUnlocalizedName() + "." + stack.getItemDamage();
}
return getUnlocalizedName(); return getUnlocalizedName();
} }
} }

19
src/main/java/refinedstorage/item/ItemBlockBase.java Normal file → Executable file
View File

@@ -4,16 +4,13 @@ import net.minecraft.block.Block;
import net.minecraft.item.ItemColored; import net.minecraft.item.ItemColored;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public abstract class ItemBlockBase extends ItemColored public abstract class ItemBlockBase extends ItemColored {
{ public ItemBlockBase(Block block) {
public ItemBlockBase(Block block) super(block, true);
{ }
super(block, true);
}
@Override @Override
public String getUnlocalizedName(ItemStack stack) public String getUnlocalizedName(ItemStack stack) {
{ return getUnlocalizedName() + "." + stack.getItemDamage();
return getUnlocalizedName() + "." + stack.getItemDamage(); }
}
} }

Some files were not shown because too many files have changed in this diff Show More