Added X button to Processing Pattern Encoder to clear configuration of inputs and outputs, fixes #204
This commit is contained in:
@@ -6,6 +6,9 @@
|
|||||||
- Fixed exporter crafting upgrades taking priority over other tasks
|
- Fixed exporter crafting upgrades taking priority over other tasks
|
||||||
- Fixed NPE with incorrectly initialized disks
|
- Fixed NPE with incorrectly initialized disks
|
||||||
|
|
||||||
|
**Features**
|
||||||
|
- Added X button to Processing Pattern Encoder to clear configuration of inputs and outputs
|
||||||
|
|
||||||
### 0.8.10
|
### 0.8.10
|
||||||
**Bugfixes**
|
**Bugfixes**
|
||||||
- Fixed not being able to get some items out of Grid
|
- Fixed not being able to get some items out of Grid
|
||||||
|
|||||||
@@ -176,11 +176,11 @@ public class GuiGrid extends GuiBase {
|
|||||||
getScrollbar().setScrollDelta((float) getScrollbar().getScrollbarHeight() / (float) getRows());
|
getScrollbar().setScrollDelta((float) getScrollbar().getScrollbarHeight() / (float) getRows());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOffset() {
|
private int getOffset() {
|
||||||
return (int) Math.ceil(getScrollbar().getCurrentScroll() / 70f * (float) getRows());
|
return (int) Math.ceil(getScrollbar().getCurrentScroll() / 70f * (float) getRows());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRows() {
|
private int getRows() {
|
||||||
int max = (int) Math.ceil((float) items.size() / 9f);
|
int max = (int) Math.ceil((float) items.size() / 9f);
|
||||||
|
|
||||||
return max < 0 ? 0 : max;
|
return max < 0 ? 0 : max;
|
||||||
@@ -198,11 +198,11 @@ public class GuiGrid extends GuiBase {
|
|||||||
return inBounds(7, 19, 162, 18 * getVisibleRows(), mouseX, mouseY);
|
return inBounds(7, 19, 162, 18 * getVisibleRows(), mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibleRows() {
|
private int getVisibleRows() {
|
||||||
return (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 4 : 5;
|
return (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 4 : 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOverClear(int mouseX, int mouseY) {
|
private boolean isOverClear(int mouseX, int mouseY) {
|
||||||
switch (grid.getType()) {
|
switch (grid.getType()) {
|
||||||
case CRAFTING:
|
case CRAFTING:
|
||||||
return inBounds(82, 95, 7, 7, mouseX, mouseY);
|
return inBounds(82, 95, 7, 7, mouseX, mouseY);
|
||||||
@@ -213,7 +213,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOverCreatePattern(int mouseX, int mouseY) {
|
private boolean isOverCreatePattern(int mouseX, int mouseY) {
|
||||||
return grid.getType() == EnumGridType.PATTERN && inBounds(152, 114, 16, 16, mouseX, mouseY) && ((TileGrid) grid).canCreatePattern();
|
return grid.getType() == EnumGridType.PATTERN && inBounds(152, 114, 16, 16, mouseX, mouseY) && ((TileGrid) grid).canCreatePattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.minecraft.init.SoundEvents;
|
|||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.container.ContainerProcessingPatternEncoder;
|
import refinedstorage.container.ContainerProcessingPatternEncoder;
|
||||||
import refinedstorage.network.MessageGridPatternCreate;
|
import refinedstorage.network.MessageGridPatternCreate;
|
||||||
|
import refinedstorage.network.MessageProcessingPatternEncoderClear;
|
||||||
import refinedstorage.tile.TileProcessingPatternEncoder;
|
import refinedstorage.tile.TileProcessingPatternEncoder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -26,10 +27,14 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
public void update(int x, int y) {
|
public void update(int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHoveringOverCreatePattern(int mouseX, int mouseY) {
|
private boolean isOverCreatePattern(int mouseX, int mouseY) {
|
||||||
return inBounds(152, 38, 16, 16, mouseX, mouseY) && processingPatternEncoder.canCreatePattern();
|
return inBounds(152, 38, 16, 16, mouseX, mouseY) && processingPatternEncoder.canCreatePattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isOverClear(int mouseX, int mouseY) {
|
||||||
|
return inBounds(136, 75, 7, 7, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
@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/processing_pattern_encoder.png");
|
bindTexture("gui/processing_pattern_encoder.png");
|
||||||
@@ -38,7 +43,7 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
|
|
||||||
int ty = 0;
|
int ty = 0;
|
||||||
|
|
||||||
if (isHoveringOverCreatePattern(mouseX - guiLeft, mouseY - guiTop)) {
|
if (isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop)) {
|
||||||
ty = 1;
|
ty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,18 +59,26 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
drawString(7, 7, t("gui.refinedstorage:processing_pattern_encoder"));
|
drawString(7, 7, t("gui.refinedstorage:processing_pattern_encoder"));
|
||||||
drawString(7, 78, t("container.inventory"));
|
drawString(7, 78, t("container.inventory"));
|
||||||
|
|
||||||
if (isHoveringOverCreatePattern(mouseX, mouseY)) {
|
if (isOverCreatePattern(mouseX, mouseY)) {
|
||||||
drawTooltip(mouseX, mouseY, t("gui.refinedstorage:processing_pattern_encoder.pattern_create"));
|
drawTooltip(mouseX, mouseY, t("gui.refinedstorage:processing_pattern_encoder.pattern_create"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOverClear(mouseX, mouseY)) {
|
||||||
|
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:clear"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
if (isHoveringOverCreatePattern(mouseX - guiLeft, mouseY - guiTop)) {
|
if (isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop)) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridPatternCreate(processingPatternEncoder.getPos().getX(), processingPatternEncoder.getPos().getY(), processingPatternEncoder.getPos().getZ()));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridPatternCreate(processingPatternEncoder.getPos().getX(), processingPatternEncoder.getPos().getY(), processingPatternEncoder.getPos().getZ()));
|
||||||
|
|
||||||
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
|
} else if (isOverClear(mouseX - guiLeft, mouseY - guiTop)) {
|
||||||
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageProcessingPatternEncoderClear(processingPatternEncoder));
|
||||||
|
|
||||||
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package refinedstorage.network;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import refinedstorage.tile.TileProcessingPatternEncoder;
|
||||||
|
|
||||||
|
public class MessageProcessingPatternEncoderClear extends MessageHandlerPlayerToServer<MessageProcessingPatternEncoderClear> implements IMessage {
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
|
||||||
|
public MessageProcessingPatternEncoderClear() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageProcessingPatternEncoderClear(TileProcessingPatternEncoder processingPatternEncoder) {
|
||||||
|
this.x = processingPatternEncoder.getPos().getX();
|
||||||
|
this.y = processingPatternEncoder.getPos().getY();
|
||||||
|
this.z = processingPatternEncoder.getPos().getZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
x = buf.readInt();
|
||||||
|
y = buf.readInt();
|
||||||
|
z = buf.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf) {
|
||||||
|
buf.writeInt(x);
|
||||||
|
buf.writeInt(y);
|
||||||
|
buf.writeInt(z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(MessageProcessingPatternEncoderClear message, EntityPlayerMP player) {
|
||||||
|
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||||
|
|
||||||
|
if (tile instanceof TileProcessingPatternEncoder) {
|
||||||
|
TileProcessingPatternEncoder processingPatternEncoder = (TileProcessingPatternEncoder) tile;
|
||||||
|
|
||||||
|
for (int i = 0; i < processingPatternEncoder.getConfiguration().getSlots(); ++i) {
|
||||||
|
processingPatternEncoder.getConfiguration().setStackInSlot(i, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -57,6 +57,7 @@ public class CommonProxy {
|
|||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageCraftingMonitorCancel.class, MessageCraftingMonitorCancel.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageCraftingMonitorCancel.class, MessageCraftingMonitorCancel.class, id++, Side.SERVER);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridUpdate.class, MessageGridUpdate.class, id++, Side.CLIENT);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridUpdate.class, MessageGridUpdate.class, id++, Side.CLIENT);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridDelta.class, MessageGridDelta.class, id++, Side.CLIENT);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridDelta.class, MessageGridDelta.class, id++, Side.CLIENT);
|
||||||
|
RefinedStorage.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderClear.class, MessageProcessingPatternEncoderClear.class, id++, Side.SERVER);
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(RefinedStorage.INSTANCE, new GuiHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(RefinedStorage.INSTANCE, new GuiHandler());
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Reference in New Issue
Block a user