Initial set of fixes

This commit is contained in:
Raoul Van den Berge
2016-05-24 21:18:59 +02:00
parent 84bca8f22c
commit 1fc2b12193
9 changed files with 45 additions and 29 deletions

View File

@@ -1,5 +1,11 @@
# Refined Storage Changelog
### 0.7.1
**Bugfixes**
- Fixed NPE in some tiles
- Fixed going out of crafting GUI not restoring state (scrollbar and search term)
- Fixed not being able to create a pattern in disconnected Pattern Grid
### 0.7
**Bugfixes**
- Fixed Crafting Grid / Pattern Grid not throwing items on break

View File

@@ -54,6 +54,7 @@ public abstract class BlockMachine extends BlockBase {
super.neighborChanged(state, world, pos, block);
if (!world.isRemote) {
System.out.println("NeighbourChange");
((TileMachine) world.getTileEntity(pos)).searchController(world);
}
}

View File

@@ -62,7 +62,7 @@ public class GuiCraftingSettings extends GuiBase {
if (keyCode == Keyboard.KEY_RETURN) {
startRequest();
} else if (keyCode == Keyboard.KEY_ESCAPE) {
FMLClientHandler.instance().showGuiScreen(gridGui);
close();
} else {
super.keyTyped(character, keyCode);
}
@@ -84,7 +84,11 @@ public class GuiCraftingSettings extends GuiBase {
if (quantity != null && quantity > 0 && quantity <= TileController.MAX_CRAFTING_QUANTITY_PER_REQUEST) {
gridGui.getGrid().onCraftingRequested(id, quantity);
close();
}
}
private void close() {
FMLClientHandler.instance().showGuiScreen(gridGui);
}
}
}

View File

@@ -56,12 +56,20 @@ public class GuiGrid extends GuiBase {
addSideButton(new SideButtonRedstoneMode(grid.getRedstoneModeSetting()));
}
searchField = new GuiTextField(0, fontRendererObj, x + 80 + 1, y + 6 + 1, 88 - 6, fontRendererObj.FONT_HEIGHT);
int sx = x + 80 + 1;
int sy = y + 6 + 1;
if (searchField == null) {
searchField = new GuiTextField(0, fontRendererObj, sx, sy, 88 - 6, fontRendererObj.FONT_HEIGHT);
searchField.setEnableBackgroundDrawing(false);
searchField.setVisible(true);
searchField.setTextColor(16777215);
searchField.setCanLoseFocus(!TileGrid.isSearchBoxModeWithAutoselection(grid.getSearchBoxMode()));
searchField.setFocused(TileGrid.isSearchBoxModeWithAutoselection(grid.getSearchBoxMode()));
} else {
searchField.xPosition = sx;
searchField.yPosition = sy;
}
addSideButton(new SideButtonGridSortingDirection(grid));
addSideButton(new SideButtonGridSortingType(grid));
@@ -300,13 +308,12 @@ public class GuiGrid extends GuiBase {
boolean clickedClear = clickedButton == 0 && isHoveringOverClear(mouseX - guiLeft, mouseY - guiTop);
boolean clickedCreatePattern = clickedButton == 0 && isHoveringOverCreatePattern(mouseX - guiLeft, mouseY - guiTop);
boolean playClickSound = clickedClear || clickedCreatePattern;
if (grid.isConnected()) {
if (clickedCreatePattern) {
BlockPos gridPos = ((TileGrid) grid).getPos();
RefinedStorage.NETWORK.sendToServer(new MessageGridPatternCreate(gridPos.getX(), gridPos.getY(), gridPos.getZ()));
} else if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null && (clickedButton == 0 || clickedButton == 1)) {
} else if (grid.isConnected()) {
if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null && (clickedButton == 0 || clickedButton == 1)) {
grid.onItemPush(-1, clickedButton == 1);
} else if (isHoveringOverItemInSlot() && container.getPlayer().inventory.getItemStack() == null) {
if (items.get(hoveringSlot).getQuantity() == 0 || (GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown())) {
@@ -328,7 +335,7 @@ public class GuiGrid extends GuiBase {
grid.onItemPull(hoveringItemId, flags);
}
} else if (clickedClear && grid.isConnected()) {
} else if (clickedClear) {
RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingClear((TileGrid) grid));
} else {
for (Slot slot : container.getPlayerInventorySlots()) {
@@ -351,7 +358,7 @@ public class GuiGrid extends GuiBase {
}
}
if (playClickSound) {
if (clickedClear || clickedCreatePattern) {
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
}

View File

@@ -8,32 +8,29 @@ import refinedstorage.tile.autocrafting.CraftingPattern;
public class CraftingTaskScheduler {
public static String NBT_SCHEDULED = "CraftingTaskScheduled";
private ItemStack scheduledFor;
private ItemStack scheduledItem;
public boolean canSchedule(int compare, ItemStack item) {
// We can only reschedule if:
// - we didn't schedule anything before
// - the item we can't to schedule is another item
return scheduledFor == null || !RefinedStorageUtils.compareStack(scheduledFor, item, compare);
return scheduledItem == null || !RefinedStorageUtils.compareStack(scheduledItem, item, compare);
}
public void schedule(TileController controller, int compare, ItemStack item) {
CraftingPattern pattern = controller.getPattern(item, compare);
if (pattern != null) {
scheduledFor = item;
scheduledItem = item;
controller.addCraftingTask(pattern);
}
}
public void resetSchedule() {
this.scheduledFor = null;
this.scheduledItem = null;
}
public void writeToNBT(NBTTagCompound tag) {
if (scheduledFor != null) {
tag.setTag(NBT_SCHEDULED, scheduledFor.serializeNBT());
if (scheduledItem != null) {
tag.setTag(NBT_SCHEDULED, scheduledItem.serializeNBT());
} else {
tag.removeTag(NBT_SCHEDULED);
}
@@ -41,7 +38,7 @@ public class CraftingTaskScheduler {
public void read(NBTTagCompound tag) {
if (tag.hasKey(NBT_SCHEDULED)) {
scheduledFor = ItemStack.loadItemStackFromNBT(tag.getCompoundTag(NBT_SCHEDULED));
scheduledItem = ItemStack.loadItemStackFromNBT(tag.getCompoundTag(NBT_SCHEDULED));
}
}
}

View File

@@ -78,6 +78,7 @@ public abstract class TileBase extends TileEntity implements ITickable {
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
System.out.println("READ FROM NBT " + pos);
if (tag.hasKey(NBT_UPDATE)) {
readUpdate(tag);
} else {

View File

@@ -261,7 +261,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
this.type = (EnumControllerType) worldObj.getBlockState(pos).getValue(BlockController.TYPE);
}
return type;
return type == null ? EnumControllerType.NORMAL : type;
}
public int getWirelessGridRange() {

View File

@@ -107,7 +107,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
this.type = ((EnumStorageType) worldObj.getBlockState(pos).getValue(BlockStorage.TYPE));
}
return type;
return type == null ? EnumStorageType.TYPE_1K : type;
}
@Override

View File

@@ -83,7 +83,7 @@ public class TileGrid extends TileMachine implements IGrid {
this.type = (EnumGridType) worldObj.getBlockState(pos).getValue(BlockGrid.TYPE);
}
return type;
return type == null ? EnumGridType.NORMAL : type;
}
@Override