Crafting Table shift-ctrl tweaks added. Crafting table mouse wheel stack inc/dec added. Lang file en_en updated (issue #76). Fixed tree cutter progress reset (issue #77). Added Solar Panel energy cap export (issue #78). Build system json-lang sanatized added.
This commit is contained in:
parent
11e985b8db
commit
d4488df2b7
39 changed files with 1339 additions and 569 deletions
|
@ -4,4 +4,4 @@ org.gradle.jvmargs=-Xmx8G
|
|||
version_minecraft=1.12.2
|
||||
version_forge=14.23.5.2768
|
||||
version_jei=4.10.0.198
|
||||
version_engineersdecor=1.0.18-b1
|
||||
version_engineersdecor=1.0.18-b2
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/",
|
||||
"1.12.2": {
|
||||
"1.0.18-b2": "[A] Added Treated Wood Crafting table tweaks (ctrl-shift moves all same stacks from the inventory, mouse wheel over crafting slot increases/decreases crafting grid stacks).\n[F] EN Lang file fixed (issue #76, thx Riverstar907).\n[F] Fixed Tree Cutter not respecting power-required config (thx federsavo, issue #77).",
|
||||
"1.0.18-b1": "[M] Lang ru_ru updated (Smollet777).",
|
||||
"1.0.17": "[R] Release based on v1.0.17-b3. Release-to-release changes: * Milking machine added. * Reverse recipes for slab slices added. * Texture and model improvements. * Lang file updates. * Minor bug fixes. * Config options added.\n[M] Updated zh_cn lang file (scikirbypoke).\n[A] Added opt-out config for the Small Tree Cutter.",
|
||||
"1.0.17-b3": "[F] Fixed Small Block Breaker facings to the horizontal range (issue #70, thx JimMiningWorm).",
|
||||
|
@ -75,6 +76,6 @@
|
|||
},
|
||||
"promos": {
|
||||
"1.12.2-recommended": "1.0.17",
|
||||
"1.12.2-latest": "1.0.18-b1"
|
||||
"1.12.2-latest": "1.0.18-b2"
|
||||
}
|
||||
}
|
|
@ -10,6 +10,11 @@ Mod sources for Minecraft version 1.12.2.
|
|||
----
|
||||
## Version history
|
||||
|
||||
- v1.0.18-b2 [A] Added Treated Wood Crafting table tweaks (ctrl-shift moves all same stacks from the
|
||||
inventory, mouse wheel over crafting slot increases/decreases crafting grid stacks).
|
||||
[F] EN Lang file fixed (issue #76, thx Riverstar907).
|
||||
[F] Fixed Tree Cutter not respecting power-required config (thx federsavo, issue #77).
|
||||
|
||||
- v1.0.18-b1 [M] Lang ru_ru updated (Smollet777).
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
|
|
@ -11,7 +11,10 @@ package wile.engineersdecor.blocks;
|
|||
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.detail.ModAuxiliaries;
|
||||
import wile.engineersdecor.detail.Networking;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.Explosion;
|
||||
|
@ -52,6 +55,8 @@ import net.minecraftforge.registries.IForgeRegistry;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.sound.midi.SysexMessage;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -62,12 +67,15 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
public static boolean with_assist = true;
|
||||
public static boolean with_assist_direct_history_refab = false;
|
||||
public static boolean with_assist_quickmove_buttons = false;
|
||||
public static boolean with_crafting_slot_mouse_scrolling = true;
|
||||
|
||||
public static final void on_config(boolean without_crafting_assist, boolean with_assist_immediate_history_refab, boolean with_quickmove_buttons)
|
||||
public static final void on_config(boolean without_crafting_assist, boolean with_assist_immediate_history_refab,
|
||||
boolean with_quickmove_buttons, boolean without_crafting_slot_mouse_scrolling)
|
||||
{
|
||||
with_assist = !without_crafting_assist;
|
||||
with_assist_direct_history_refab = with_assist_immediate_history_refab;
|
||||
with_assist_quickmove_buttons = with_quickmove_buttons;
|
||||
with_crafting_slot_mouse_scrolling = !without_crafting_slot_mouse_scrolling;
|
||||
CraftingHistory.max_history_size(32);
|
||||
}
|
||||
|
||||
|
@ -354,6 +362,9 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
protected static final int BUTTON_TO_PLAYER = 7;
|
||||
protected static final int ACTION_PLACE_CURRENT_HISTORY_SEL = 8;
|
||||
protected static final int ACTION_PLACE_SHIFTCLICKED_STACK = 9;
|
||||
protected static final int ACTION_MOVE_ALL_STACKS = 10;
|
||||
protected static final int ACTION_INCREASE_CRAFTING_STACKS = 11;
|
||||
protected static final int ACTION_DECREASE_CRAFTING_STACKS = 12;
|
||||
|
||||
protected static final ResourceLocation BACKGROUND = new ResourceLocation(ModEngineersDecor.MODID, "textures/gui/treated_wood_crafting_table.png");
|
||||
protected final BTileEntity te;
|
||||
|
@ -385,6 +396,18 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() throws IOException
|
||||
{
|
||||
super.handleMouseInput();
|
||||
final int wheel = Mouse.getDWheel();
|
||||
if(wheel != 0) {
|
||||
int x = Mouse.getEventX() * width / mc.displayWidth;
|
||||
int y = this.height - Mouse.getEventY() * height / mc.displayHeight - 1;
|
||||
if(wheel != 0) mouseScrolled(x, y, (wheel>0) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
@ -507,25 +530,75 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
if(place_refab && (!with_assist_direct_history_refab)) onHistoryItemPlacement(); // place after crafting -> confirmation first
|
||||
return;
|
||||
}
|
||||
if((type == ClickType.QUICK_MOVE) && (slotId > 9) && (slot.getHasStack())) { // container slots 0..9 are crafting output and grid
|
||||
List<ItemStack> history = te.history.current();
|
||||
boolean palce_in_crafting_grid = (!history.isEmpty());
|
||||
if(!palce_in_crafting_grid) {
|
||||
for(int i=0; i<9; ++i) {
|
||||
if(!(te.getStackInSlot(i).isEmpty())) { palce_in_crafting_grid = true; break; }
|
||||
if((type == ClickType.QUICK_MOVE) && (slotId > 0) && (slot.getHasStack())) { // container slots 0 is crafting output
|
||||
if(with_assist) {
|
||||
List<ItemStack> history = te.history.current();
|
||||
boolean palce_in_crafting_grid = false;
|
||||
if(slotId > 9) { // container slots 1..9 are crafting grid
|
||||
palce_in_crafting_grid = (!history.isEmpty());
|
||||
if(!palce_in_crafting_grid) {
|
||||
for(int i = 0; i < 9; ++i) {
|
||||
if(!(te.getStackInSlot(i).isEmpty())) {
|
||||
palce_in_crafting_grid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(palce_in_crafting_grid) {
|
||||
// Explicit grid placement.
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("action", ACTION_PLACE_SHIFTCLICKED_STACK);
|
||||
nbt.setInteger("containerslot", slotId);
|
||||
if(ModAuxiliaries.isCtrlDown()) nbt.setBoolean("move-all", true);
|
||||
Networking.PacketTileNotify.sendToServer(te, nbt);
|
||||
return;
|
||||
} else if(ModAuxiliaries.isCtrlDown()) {
|
||||
// Move all same items from the inventory of the clicked slot
|
||||
// (or the crafting grid) to the corresponding target inventory.
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("action", ACTION_MOVE_ALL_STACKS);
|
||||
nbt.setInteger("containerslot", slotId);
|
||||
Networking.PacketTileNotify.sendToServer(te, nbt);
|
||||
return;
|
||||
} else {
|
||||
// Let the normal slot click handle that.
|
||||
}
|
||||
}
|
||||
if(palce_in_crafting_grid) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("action", ACTION_PLACE_SHIFTCLICKED_STACK);
|
||||
nbt.setInteger("containerslot", slotId);
|
||||
Networking.PacketTileNotify.sendToServer(te, nbt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.handleMouseClick(slot, slotId, mouseButton, type);
|
||||
}
|
||||
|
||||
private boolean mouseScrolled(int mouseX, int mouseY, int wheel_inc)
|
||||
{
|
||||
final Slot resultSlot = getSlotUnderMouse();
|
||||
if((!with_crafting_slot_mouse_scrolling) || (!(resultSlot instanceof BSlotCrafting))) return false;
|
||||
int count = resultSlot.getStack().getCount();
|
||||
int limit = (ModAuxiliaries.isShiftDown() ? 2 : 1) * (ModAuxiliaries.isCtrlDown() ? 4 : 1);
|
||||
if(wheel_inc > 0) {
|
||||
if(count > 0) {
|
||||
if((count < resultSlot.getStack().getMaxStackSize()) && (count < resultSlot.getSlotStackLimit())) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("action", ACTION_INCREASE_CRAFTING_STACKS);
|
||||
if(limit > 1) nbt.setInteger("limit", limit);
|
||||
Networking.PacketTileNotify.sendToServer(te, nbt);
|
||||
}
|
||||
} else if(!te.history.current().isEmpty()) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("action", ACTION_PLACE_CURRENT_HISTORY_SEL);
|
||||
Networking.PacketTileNotify.sendToServer(te, nbt);
|
||||
}
|
||||
} else if(wheel_inc < 0) {
|
||||
if(count > 0) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
if(limit > 1) nbt.setInteger("limit", limit);
|
||||
nbt.setInteger("action", ACTION_DECREASE_CRAFTING_STACKS);
|
||||
Networking.PacketTileNotify.sendToServer(te, nbt);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void onHistoryItemPlacement()
|
||||
{
|
||||
if(te.history.current().isEmpty()) return;
|
||||
|
@ -790,6 +863,13 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
}
|
||||
}
|
||||
|
||||
private static class SlotRange
|
||||
{
|
||||
public final IInventory inventory;
|
||||
public int start_slot, end_slot;
|
||||
public SlotRange(IInventory inv, int start, int end) { inventory=inv; start_slot=start; end_slot=end; }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
// Tile entity
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -826,6 +906,8 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
|
||||
// private aux methods ---------------------------------------------------------------------
|
||||
|
||||
enum PlacementResult { UNCHANGED, INCOMPLETE, PLACED }
|
||||
|
||||
private boolean has_recipe_collision()
|
||||
{ return has_recipe_collision_; }
|
||||
|
||||
|
@ -845,7 +927,7 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
return false;
|
||||
}
|
||||
|
||||
private List<ItemStack> crafting_slot_stacks_to_add()
|
||||
private List<ItemStack> refab_crafting_stacks()
|
||||
{
|
||||
final ArrayList<ItemStack> slots = new ArrayList<ItemStack>();
|
||||
final List<ItemStack> tocraft = history.current();
|
||||
|
@ -887,30 +969,46 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
return slots;
|
||||
}
|
||||
|
||||
private List<ItemStack> incr_crafting_grid_stacks(int count)
|
||||
{
|
||||
final ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
for(int i=0; i<9; ++i) {
|
||||
final ItemStack palced = getStackInSlot(i+CRAFTING_SLOTS_BEGIN).copy();
|
||||
if(!palced.isEmpty()) palced.setCount(count);
|
||||
stacks.add(palced);
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves as much items from the stack to the slots in range [first_slot, last_slot] of the inventory,
|
||||
* filling up existing stacks first, then (player inventory only) checks appropriate empty slots next
|
||||
* to stacks that have that item already, and last uses any empty slot that can be found.
|
||||
* Returns the stack that is still remaining in the referenced `stack`.
|
||||
*/
|
||||
private ItemStack move_stack_to_inventory(final ItemStack stack_to_move, IInventory inventory, final int slot_begin, final int slot_end, boolean only_fillup)
|
||||
private ItemStack move_stack_to_inventory(final ItemStack stack_to_move, SlotRange range, boolean only_fillup, int limit)
|
||||
{
|
||||
final IInventory inventory = range.inventory;
|
||||
final int slot_begin = range.start_slot;
|
||||
final int slot_end = range.end_slot;
|
||||
final ItemStack mvstack = stack_to_move.copy();
|
||||
if((mvstack.isEmpty()) || (slot_begin < 0) || (slot_end > inventory.getSizeInventory())) return mvstack;
|
||||
int limit_left = (limit>0) ? (Math.min(limit, mvstack.getMaxStackSize())) : (mvstack.getMaxStackSize());
|
||||
// first iteration: fillup existing stacks
|
||||
for(int i = slot_begin; i < slot_end; ++i) {
|
||||
final ItemStack stack = inventory.getStackInSlot(i);
|
||||
if((stack.isEmpty()) || (!isItemExactlyEqual(stack,mvstack))) continue;
|
||||
int nmax = stack.getMaxStackSize() - stack.getCount();
|
||||
if((stack.isEmpty()) || (!stack.isItemEqual(mvstack))) continue;
|
||||
int nmax = Math.min(limit_left, stack.getMaxStackSize() - stack.getCount());
|
||||
if(mvstack.getCount() <= nmax) {
|
||||
stack.setCount(stack.getCount()+mvstack.getCount());
|
||||
mvstack.setCount(0);
|
||||
inventory.setInventorySlotContents(i, stack);
|
||||
return mvstack;
|
||||
} else {
|
||||
stack.setCount(stack.getMaxStackSize());
|
||||
stack.grow(nmax);
|
||||
mvstack.shrink(nmax);
|
||||
inventory.setInventorySlotContents(i, stack);
|
||||
limit_left -= nmax;
|
||||
}
|
||||
}
|
||||
if(only_fillup) return mvstack;
|
||||
|
@ -920,8 +1018,11 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
final ItemStack stack = inventory.getStackInSlot(i);
|
||||
if(!stack.isEmpty()) continue;
|
||||
if((!inventory.getStackInSlot(i+1).isItemEqual(mvstack)) && (!inventory.getStackInSlot(i-1).isItemEqual(mvstack))) continue;
|
||||
inventory.setInventorySlotContents(i, mvstack.copy());
|
||||
mvstack.setCount(0);
|
||||
int nmax = Math.min(limit_left, mvstack.getCount());
|
||||
ItemStack placed = mvstack.copy();
|
||||
placed.setCount(nmax);
|
||||
mvstack.shrink(nmax);
|
||||
inventory.setInventorySlotContents(i, placed);
|
||||
return mvstack;
|
||||
}
|
||||
}
|
||||
|
@ -929,8 +1030,11 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
for(int i = slot_begin; i < slot_end; ++i) {
|
||||
final ItemStack stack = inventory.getStackInSlot(i);
|
||||
if(!stack.isEmpty()) continue;
|
||||
inventory.setInventorySlotContents(i, mvstack.copy());
|
||||
mvstack.setCount(0);
|
||||
int nmax = Math.min(limit_left, mvstack.getCount());
|
||||
ItemStack placed = mvstack.copy();
|
||||
placed.setCount(nmax);
|
||||
mvstack.shrink(nmax);
|
||||
inventory.setInventorySlotContents(i, placed);
|
||||
return mvstack;
|
||||
}
|
||||
return mvstack;
|
||||
|
@ -958,8 +1062,11 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
* Moves as much items from the slots in range [first_slot, last_slot] of the inventory into a new stack.
|
||||
* Implicitly shrinks the inventory stacks and the `request_stack`.
|
||||
*/
|
||||
private ItemStack move_stack_from_inventory(IInventory inventory, final ItemStack request_stack, final int slot_begin, final int slot_end)
|
||||
private ItemStack move_stack_from_inventory(SlotRange range, final ItemStack request_stack)
|
||||
{
|
||||
final IInventory inventory = range.inventory;
|
||||
final int slot_begin = range.start_slot;
|
||||
final int slot_end = range.end_slot;
|
||||
ItemStack fetched_stack = request_stack.copy();
|
||||
fetched_stack.setCount(0);
|
||||
int n_left = request_stack.getCount();
|
||||
|
@ -968,10 +1075,16 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
int smallest_stack_index = -1;
|
||||
for(int i = slot_begin; i < slot_end; ++i) {
|
||||
final ItemStack stack = inventory.getStackInSlot(i);
|
||||
if((!stack.isEmpty()) && (isItemExactlyEqual(stack, request_stack))) {
|
||||
if((!stack.isEmpty()) && (stack.isItemEqual(request_stack))) {
|
||||
// Never automatically place stuff with nbt (except a few allowed like "Damage"),
|
||||
// as this could be a full crate, a valuable tool item, etc. For these recipes
|
||||
// the user has to place this item manually.
|
||||
if(stack.hasTagCompound()) {
|
||||
final NBTTagCompound nbt = stack.getTagCompound();
|
||||
int n = nbt.getSize();
|
||||
if((n > 0) && (nbt.hasKey("Damage"))) --n;
|
||||
if(n > 0) continue;
|
||||
}
|
||||
fetched_stack = stack.copy(); // copy exact stack with nbt and tool damage, otherwise we have an automagical repair of items.
|
||||
fetched_stack.setCount(0);
|
||||
int n = stack.getCount();
|
||||
|
@ -998,10 +1111,10 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
private boolean clear_grid_to_storage(EntityPlayer player)
|
||||
{
|
||||
boolean changed = false;
|
||||
for(int grid_i = CRAFTING_SLOTS_BEGIN; grid_i < (CRAFTING_SLOTS_BEGIN + NUM_OF_CRAFTING_SLOTS); ++grid_i) {
|
||||
for(int grid_i = CRAFTING_SLOTS_BEGIN; grid_i < (CRAFTING_SLOTS_BEGIN+NUM_OF_CRAFTING_SLOTS); ++grid_i) {
|
||||
ItemStack stack = getStackInSlot(grid_i);
|
||||
if(stack.isEmpty()) continue;
|
||||
ItemStack remaining = move_stack_to_inventory(stack, this, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS, false);
|
||||
ItemStack remaining = move_stack_to_inventory(stack, new SlotRange(this, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS), false, 0);
|
||||
setInventorySlotContents(grid_i, remaining);
|
||||
changed = true;
|
||||
}
|
||||
|
@ -1011,67 +1124,72 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
private boolean clear_grid_to_player(EntityPlayer player)
|
||||
{
|
||||
boolean changed = false;
|
||||
for(int grid_i = CRAFTING_SLOTS_BEGIN; grid_i < (CRAFTING_SLOTS_BEGIN + NUM_OF_CRAFTING_SLOTS); ++grid_i) {
|
||||
for(int grid_i = CRAFTING_SLOTS_BEGIN; grid_i < (CRAFTING_SLOTS_BEGIN+NUM_OF_CRAFTING_SLOTS); ++grid_i) {
|
||||
ItemStack remaining = getStackInSlot(grid_i);
|
||||
if(remaining.isEmpty()) continue;
|
||||
remaining = move_stack_to_inventory(remaining, player.inventory,9, 36, true); // prefer filling up inventory stacks
|
||||
remaining = move_stack_to_inventory(remaining, player.inventory,0, 9, true); // then fill up the hotbar stacks
|
||||
remaining = move_stack_to_inventory(remaining, player.inventory,9, 36, false); // then allow empty stacks in inventory
|
||||
remaining = move_stack_to_inventory(remaining, player.inventory,0, 9, false); // then new stacks in the hotbar
|
||||
this.setInventorySlotContents(grid_i, remaining);
|
||||
remaining = move_stack_to_inventory(remaining, new SlotRange(player.inventory,9, 36), true, 0); // prefer filling up inventory stacks
|
||||
remaining = move_stack_to_inventory(remaining, new SlotRange(player.inventory,0, 9), true, 0); // then fill up the hotbar stacks
|
||||
remaining = move_stack_to_inventory(remaining, new SlotRange(player.inventory,9, 36), false, 0); // then allow empty stacks in inventory
|
||||
remaining = move_stack_to_inventory(remaining, new SlotRange(player.inventory,0, 9), false, 0); // then new stacks in the hotbar
|
||||
setInventorySlotContents(grid_i, remaining);
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
enum EnumRefabPlacement { UNCHANGED, INCOMPLETE, PLACED }
|
||||
private EnumRefabPlacement place_refab_stacks(IInventory inventory, final int slot_begin, final int slot_end, @Nullable EntityPlayer player)
|
||||
private PlacementResult place_stacks(final SlotRange[] ranges, final List<ItemStack> to_fill, @Nullable EntityPlayer player)
|
||||
{
|
||||
List<ItemStack> to_fill = crafting_slot_stacks_to_add();
|
||||
boolean slots_changed = false;
|
||||
boolean missing_item = false;
|
||||
int num_slots_placed = 0;
|
||||
if(!to_fill.isEmpty()) {
|
||||
for(int it_guard=63; it_guard>=0; --it_guard) {
|
||||
boolean slots_updated = false;
|
||||
for(int i = 0; i < 9; ++i) {
|
||||
final ItemStack req_stack = to_fill.get(i).copy();
|
||||
if(req_stack.isEmpty()) continue;
|
||||
req_stack.setCount(1);
|
||||
to_fill.get(i).shrink(1);
|
||||
final ItemStack mv_stack = move_stack_from_inventory(inventory, req_stack, slot_begin, slot_end);
|
||||
if(mv_stack.isEmpty()) { missing_item=true; continue; }
|
||||
// sizes already checked
|
||||
ItemStack grid_stack = getStackInSlot(i + CRAFTING_SLOTS_BEGIN).copy();
|
||||
if(grid_stack.isEmpty()) {
|
||||
grid_stack = mv_stack.copy();
|
||||
} else {
|
||||
grid_stack.grow(mv_stack.getCount());
|
||||
for(SlotRange slot_range: ranges) {
|
||||
for(int it_guard=63; it_guard>=0; --it_guard) {
|
||||
boolean slots_updated = false;
|
||||
for(int i = 0; i < 9; ++i) {
|
||||
if(to_fill.get(i).isEmpty()) continue;
|
||||
ItemStack grid_stack = getStackInSlot(i + CRAFTING_SLOTS_BEGIN).copy();
|
||||
if(grid_stack.getCount() >= grid_stack.getMaxStackSize()) continue;
|
||||
final ItemStack req_stack = to_fill.get(i).copy();
|
||||
req_stack.setCount(1);
|
||||
final ItemStack mv_stack = move_stack_from_inventory(slot_range, req_stack);
|
||||
if(mv_stack.isEmpty()) continue;
|
||||
to_fill.get(i).shrink(1);
|
||||
if(grid_stack.isEmpty()) {
|
||||
grid_stack = mv_stack.copy();
|
||||
} else {
|
||||
grid_stack.grow(mv_stack.getCount());
|
||||
}
|
||||
setInventorySlotContents(i + CRAFTING_SLOTS_BEGIN, grid_stack);
|
||||
slots_changed = true;
|
||||
slots_updated = true;
|
||||
}
|
||||
setInventorySlotContents(i + CRAFTING_SLOTS_BEGIN, grid_stack);
|
||||
slots_changed = true;
|
||||
slots_updated = true;
|
||||
if(!slots_updated) break;
|
||||
}
|
||||
if(!slots_updated) break;
|
||||
}
|
||||
}
|
||||
boolean missing_item = false;
|
||||
for(ItemStack st:to_fill) {
|
||||
if(!st.isEmpty()) {
|
||||
missing_item = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if((history.current_recipe() != null) && (player!=null) && (player.openContainer instanceof BContainer)) {
|
||||
((BContainer)player.openContainer).craftResult.setRecipeUsed(history.current_recipe());
|
||||
}
|
||||
if(!slots_changed) {
|
||||
return EnumRefabPlacement.UNCHANGED;
|
||||
return PlacementResult.UNCHANGED;
|
||||
} else if(missing_item) {
|
||||
return EnumRefabPlacement.INCOMPLETE;
|
||||
return PlacementResult.INCOMPLETE;
|
||||
} else {
|
||||
return EnumRefabPlacement.PLACED;
|
||||
return PlacementResult.PLACED;
|
||||
}
|
||||
}
|
||||
|
||||
private EnumRefabPlacement distribute_stack(IInventory inventory, final int slotno)
|
||||
private PlacementResult distribute_stack(IInventory inventory, final int slotno)
|
||||
{
|
||||
List<ItemStack> to_refab = crafting_slot_stacks_to_add();
|
||||
List<ItemStack> to_refab = refab_crafting_stacks();
|
||||
ItemStack to_distribute = inventory.getStackInSlot(slotno).copy();
|
||||
if(to_distribute.isEmpty()) return EnumRefabPlacement.UNCHANGED;
|
||||
if(to_distribute.isEmpty()) return PlacementResult.UNCHANGED;
|
||||
int matching_grid_stack_sizes[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1};
|
||||
int max_matching_stack_size = -1;
|
||||
int min_matching_stack_size = 65;
|
||||
|
@ -1098,9 +1216,9 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
}
|
||||
}
|
||||
}
|
||||
if(min_matching_stack_size < 0) return EnumRefabPlacement.UNCHANGED;
|
||||
if(min_matching_stack_size < 0) return PlacementResult.UNCHANGED;
|
||||
final int stack_limit_size = Math.min(to_distribute.getMaxStackSize(), getInventoryStackLimit());
|
||||
if(min_matching_stack_size >= stack_limit_size) return EnumRefabPlacement.UNCHANGED;
|
||||
if(min_matching_stack_size >= stack_limit_size) return PlacementResult.UNCHANGED;
|
||||
int n_to_distribute = to_distribute.getCount();
|
||||
for(int it_guard=63; it_guard>=0; --it_guard) {
|
||||
if(n_to_distribute <= 0) break;
|
||||
|
@ -1119,7 +1237,7 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
}
|
||||
if(min_matching_stack_size >= stack_limit_size) break; // all full
|
||||
}
|
||||
if(n_to_distribute == to_distribute.getCount()) return EnumRefabPlacement.UNCHANGED; // was already full
|
||||
if(n_to_distribute == to_distribute.getCount()) return PlacementResult.UNCHANGED; // was already full
|
||||
if(n_to_distribute <= 0) {
|
||||
inventory.setInventorySlotContents(slotno, ItemStack.EMPTY);
|
||||
} else {
|
||||
|
@ -1133,9 +1251,30 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
grid_stack.setCount(matching_grid_stack_sizes[i]);
|
||||
setInventorySlotContents(i + CRAFTING_SLOTS_BEGIN, grid_stack);
|
||||
}
|
||||
return EnumRefabPlacement.PLACED;
|
||||
return PlacementResult.PLACED;
|
||||
}
|
||||
|
||||
private boolean decrease_grid_stacks(SlotRange[] ranges, int limit)
|
||||
{
|
||||
boolean changed = false;
|
||||
for(int i=0; i<9; ++i) {
|
||||
ItemStack stack = getStackInSlot(i+CRAFTING_SLOTS_BEGIN).copy();
|
||||
if(stack.isEmpty()) continue;
|
||||
for(SlotRange range:ranges) {
|
||||
ItemStack remaining = move_stack_to_inventory(stack, range, false, limit);
|
||||
if(remaining.getCount() < stack.getCount()) changed = true;
|
||||
boolean stop = (remaining.getCount() <= Math.max(0, (stack.getCount()-limit)));
|
||||
stack = remaining;
|
||||
if(stop) break;
|
||||
}
|
||||
setInventorySlotContents(i+CRAFTING_SLOTS_BEGIN, stack.isEmpty() ? ItemStack.EMPTY : stack);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean increase_grid_stacks(SlotRange[] ranges, int limit, EntityPlayer player)
|
||||
{ return place_stacks(ranges, incr_crafting_grid_stacks(limit), player) != PlacementResult.UNCHANGED; }
|
||||
|
||||
// Networking.IPacketReceiver --------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
|
@ -1174,42 +1313,99 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
if(clear_grid_to_player(player)) { te_changed = true; player_inventory_changed = true; }
|
||||
} break;
|
||||
case BGui.BUTTON_FROM_STORAGE: {
|
||||
EnumRefabPlacement from_storage = place_refab_stacks(this, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN + NUM_OF_STORAGE_SLOTS, player);
|
||||
if(from_storage != EnumRefabPlacement.UNCHANGED) te_changed = true;
|
||||
if(place_stacks(new SlotRange[]{
|
||||
new SlotRange(this, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS)
|
||||
}, refab_crafting_stacks(), player) != PlacementResult.UNCHANGED) {
|
||||
te_changed = true;
|
||||
}
|
||||
} break;
|
||||
case BGui.BUTTON_FROM_PLAYER: {
|
||||
EnumRefabPlacement from_player_inv = place_refab_stacks(player.inventory, 9, 36, player);
|
||||
if(from_player_inv != EnumRefabPlacement.UNCHANGED) { te_changed = true; player_inventory_changed = true; }
|
||||
if(from_player_inv != EnumRefabPlacement.PLACED) {
|
||||
EnumRefabPlacement from_hotbar = place_refab_stacks(player.inventory, 0, 9, player);
|
||||
if(from_hotbar != EnumRefabPlacement.UNCHANGED) { te_changed = true; player_inventory_changed = true; }
|
||||
if(place_stacks(new SlotRange[]{
|
||||
new SlotRange(player.inventory, 9, 36),
|
||||
new SlotRange(player.inventory, 0, 9)
|
||||
}, refab_crafting_stacks(), player) != PlacementResult.UNCHANGED) {
|
||||
te_changed = true; player_inventory_changed = true;
|
||||
}
|
||||
} break;
|
||||
case BGui.ACTION_PLACE_CURRENT_HISTORY_SEL: {
|
||||
EnumRefabPlacement from_storage = place_refab_stacks(this, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN + NUM_OF_STORAGE_SLOTS, player);
|
||||
if(from_storage != EnumRefabPlacement.UNCHANGED) te_changed = true;
|
||||
if(from_storage != EnumRefabPlacement.PLACED) {
|
||||
EnumRefabPlacement from_player_inv = place_refab_stacks(player.inventory, 9, 36, player);
|
||||
if(from_player_inv != EnumRefabPlacement.UNCHANGED) { te_changed = true; player_inventory_changed = true; }
|
||||
if(from_player_inv != EnumRefabPlacement.PLACED) {
|
||||
EnumRefabPlacement from_hotbar = place_refab_stacks(player.inventory, 0, 9, player);
|
||||
if(from_hotbar != EnumRefabPlacement.UNCHANGED) { te_changed = true; player_inventory_changed = true; }
|
||||
}
|
||||
if(place_stacks(new SlotRange[]{
|
||||
new SlotRange(player.inventory, 0, 9),
|
||||
new SlotRange(player.inventory, 9, 36),
|
||||
new SlotRange(this, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS)
|
||||
}, refab_crafting_stacks(), player) != PlacementResult.UNCHANGED) {
|
||||
te_changed = true;
|
||||
}
|
||||
} break;
|
||||
case BGui.ACTION_PLACE_SHIFTCLICKED_STACK: {
|
||||
final int container_slot_id = nbt.getInteger("containerslot");
|
||||
if((container_slot_id < 10) || (container_slot_id > 53)) break; // out of range
|
||||
if((container_slot_id < 10) || (container_slot_id > 53)) {
|
||||
break; // out of range
|
||||
}
|
||||
if(container_slot_id >= 46) {
|
||||
// from storage
|
||||
final int storage_slot = container_slot_id - 46 + STORAGE_SLOTS_BEGIN;
|
||||
EnumRefabPlacement stat = distribute_stack(this, storage_slot);
|
||||
if(stat != EnumRefabPlacement.UNCHANGED) te_changed = true;
|
||||
PlacementResult stat = distribute_stack(this, storage_slot);
|
||||
if(stat != PlacementResult.UNCHANGED) te_changed = true;
|
||||
} else {
|
||||
// from player
|
||||
int player_slot = (container_slot_id >= 37) ? (container_slot_id-37) : (container_slot_id-10+9);
|
||||
EnumRefabPlacement stat = distribute_stack(player.inventory, player_slot);
|
||||
if(stat != EnumRefabPlacement.UNCHANGED) { player_inventory_changed = true; te_changed = true; }
|
||||
final ItemStack reference_stack = player.inventory.getStackInSlot(player_slot).copy();
|
||||
if((!reference_stack.isEmpty()) && (distribute_stack(player.inventory, player_slot) != PlacementResult.UNCHANGED)) {
|
||||
player_inventory_changed = true;
|
||||
te_changed = true;
|
||||
if(nbt.hasKey("move-all")) {
|
||||
for(int i=0; i < player.inventory.getSizeInventory(); ++i) {
|
||||
final ItemStack stack = player.inventory.getStackInSlot(i);
|
||||
if(!reference_stack.isItemEqual(stack)) continue;
|
||||
if(distribute_stack(player.inventory, i) == PlacementResult.UNCHANGED) break; // grid is full
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case BGui.ACTION_MOVE_ALL_STACKS: {
|
||||
final int container_slot_id = nbt.getInteger("containerslot");
|
||||
if((container_slot_id < 1) || (container_slot_id > 53)) {
|
||||
break; // out of range
|
||||
} else if(container_slot_id < 10) {
|
||||
// from crafting grid to player inventory, we clear the grid here as this is most likely
|
||||
// what is wanted in the end. Saves clicking the other grid stacks.
|
||||
if(clear_grid_to_player(player)) { te_changed = true; player_inventory_changed = true; }
|
||||
if(clear_grid_to_storage(player)) te_changed = true;
|
||||
break;
|
||||
}
|
||||
IInventory from_inventory;
|
||||
SlotRange[] to_ranges;
|
||||
int from_slot;
|
||||
if(container_slot_id >= 46) {
|
||||
// from storage to player inventory
|
||||
from_inventory = this;
|
||||
from_slot = container_slot_id - 46 + STORAGE_SLOTS_BEGIN;
|
||||
to_ranges = new SlotRange[] {new SlotRange(player.inventory, 9, 36), new SlotRange(player.inventory, 0, 9)};
|
||||
} else {
|
||||
// from player to storage (otherwise ACTION_PLACE_SHIFTCLICKED_STACK would have been used)
|
||||
from_inventory = player.inventory;
|
||||
from_slot = (container_slot_id >= 37) ? (container_slot_id-37) : (container_slot_id-10+9);
|
||||
to_ranges = new SlotRange[] {new SlotRange(this, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS)};
|
||||
}
|
||||
final ItemStack reference_stack = from_inventory.getStackInSlot(from_slot).copy();
|
||||
if(!reference_stack.isEmpty()) {
|
||||
boolean abort = false;
|
||||
for(int i=0; (i < from_inventory.getSizeInventory()) && (!abort); ++i) {
|
||||
final ItemStack stack = from_inventory.getStackInSlot(i);
|
||||
if(!reference_stack.isItemEqual(stack)) continue;
|
||||
ItemStack remaining = from_inventory.getStackInSlot(i);
|
||||
for(SlotRange range:to_ranges) {
|
||||
remaining = move_stack_to_inventory(remaining, range, false, 0);
|
||||
if(!remaining.isEmpty()) {
|
||||
abort = true; // no space left
|
||||
break;
|
||||
} else {
|
||||
te_changed = player_inventory_changed = true;
|
||||
}
|
||||
}
|
||||
from_inventory.setInventorySlotContents(i, remaining);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case BGui.BUTTON_NEXT_COLLISION_RECIPE: {
|
||||
|
@ -1217,6 +1413,20 @@ public class BlockDecorCraftingTable extends BlockDecorDirected
|
|||
((BContainer)player.openContainer).select_next_collision_recipe(this, player);
|
||||
}
|
||||
} break;
|
||||
case BGui.ACTION_DECREASE_CRAFTING_STACKS: {
|
||||
te_changed = player_inventory_changed = decrease_grid_stacks(new SlotRange[]{
|
||||
new SlotRange(player.inventory, 9, 36),
|
||||
new SlotRange(player.inventory, 0, 9),
|
||||
new SlotRange(this, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS)
|
||||
}, MathHelper.clamp(nbt.getInteger("limit"), 1, 8));
|
||||
} break;
|
||||
case BGui.ACTION_INCREASE_CRAFTING_STACKS: {
|
||||
te_changed = player_inventory_changed = increase_grid_stacks(new SlotRange[]{
|
||||
new SlotRange(player.inventory, 9, 36),
|
||||
new SlotRange(player.inventory, 0, 9),
|
||||
new SlotRange(this, STORAGE_SLOTS_BEGIN, STORAGE_SLOTS_BEGIN+NUM_OF_STORAGE_SLOTS)
|
||||
}, MathHelper.clamp(nbt.getInteger("limit"), 1, 8), player);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
if(te_changed) markDirty();
|
||||
|
|
|
@ -207,6 +207,9 @@ public class BlockDecorTreeCutter extends BlockDecorDirectedHorizontal
|
|||
--active_timer_;
|
||||
}
|
||||
boolean active = (active_timer_ > 0);
|
||||
if(requires_power && !active) {
|
||||
proc_time_elapsed_ = Math.max(0, proc_time_elapsed_ - 2*TICK_INTERVAL);
|
||||
}
|
||||
if(proc_time_elapsed_ >= cutting_time_needed) {
|
||||
proc_time_elapsed_ = 0;
|
||||
TreeCutting.chopTree(world, tree_state, tree_pos, 2048, false);
|
||||
|
|
|
@ -76,6 +76,14 @@ public class ModAuxiliaries
|
|||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static final boolean isShiftDown()
|
||||
{ return (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)||Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)); }
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static final boolean isCtrlDown()
|
||||
{ return ((Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)||Keyboard.isKeyDown(Keyboard.KEY_RCONTROL))); }
|
||||
|
||||
/**
|
||||
* Returns true if a given key is translated for the current language.
|
||||
*/
|
||||
|
@ -87,11 +95,11 @@ public class ModAuxiliaries
|
|||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean extendedTipCondition()
|
||||
{ return (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)||Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)); }
|
||||
{ return isShiftDown(); }
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean helpCondition()
|
||||
{ return extendedTipCondition() && ((Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)||Keyboard.isKeyDown(Keyboard.KEY_RCONTROL))); }
|
||||
{ return isShiftDown() && isCtrlDown(); }
|
||||
|
||||
/**
|
||||
* Adds an extended tooltip or help tooltip depending on the key states of CTRL and SHIFT.
|
||||
|
|
|
@ -328,11 +328,15 @@ public class ModConfig
|
|||
@Config.RangeDouble(min=0.001, max=10)
|
||||
public double chair_mob_standup_probability_percent = 1;
|
||||
|
||||
@Config.Comment({"Disables increasing/decreasing the crafting grid items by scrolling over the crafting result slot."})
|
||||
@Config.Name("Crafting table: Move buttons")
|
||||
public boolean with_crafting_quickmove_buttons = false;
|
||||
|
||||
@Config.Comment({"Enables small quick-move arrows from/to player/block storage. " +
|
||||
"Makes the UI a bit too busy, therefore disabled by default."
|
||||
})
|
||||
@Config.Name("Crafting table: Move buttons")
|
||||
public boolean with_crafting_quickmove_buttons = false;
|
||||
@Config.Name("Crafting table: Mouse scrolling")
|
||||
public boolean without_crafting_mouse_scrolling = false;
|
||||
|
||||
@Config.Comment({
|
||||
"Defines how many millibuckets can be transferred (per tick) through the valves. " +
|
||||
|
@ -600,7 +604,7 @@ public class ModConfig
|
|||
BlockDecorFurnace.BTileEntity.on_config(tweaks.furnace_smelting_speed_percent, tweaks.furnace_fuel_efficiency_percent, tweaks.furnace_boost_energy_consumption);
|
||||
BlockDecorChair.on_config(optout.without_chair_sitting, optout.without_mob_chair_sitting, tweaks.chair_mob_sitting_probability_percent, tweaks.chair_mob_standup_probability_percent);
|
||||
BlockDecorLadder.on_config(optout.without_ladder_speed_boost);
|
||||
BlockDecorCraftingTable.on_config(optout.without_crafting_table_history, false, tweaks.with_crafting_quickmove_buttons);
|
||||
BlockDecorCraftingTable.on_config(optout.without_crafting_table_history, false, tweaks.with_crafting_quickmove_buttons, tweaks.without_crafting_mouse_scrolling);
|
||||
BlockDecorPipeValve.on_config(tweaks.pipevalve_max_flowrate, tweaks.pipevalve_redstone_slope);
|
||||
BlockDecorFurnaceElectrical.BTileEntity.on_config(tweaks.e_furnace_speed_percent, tweaks.e_furnace_power_consumption);
|
||||
BlockDecorSolarPanel.BTileEntity.on_config(tweaks.solar_panel_peak_power);
|
||||
|
|
|
@ -66,8 +66,8 @@ tile.engineersdecor.clinker_brick_stairs.name=Clinker Brick Stairs
|
|||
tile.engineersdecor.clinker_brick_stairs.help=§6Looks slightly darker and more color intensive than the vanilla brick block.
|
||||
tile.engineersdecor.clinker_brick_stained_stairs.name=Stained Clinker Brick Stairs
|
||||
tile.engineersdecor.clinker_brick_stained_stairs.help=§6Looks slightly darker and more color intensive than the vanilla brick block. Has more visible traces of grime or stain.
|
||||
tile.engineersdecor.slag_brick_stairs.name=Clinker Brick Stairs
|
||||
tile.engineersdecor.slag_brick_stairs.help=§6Looks slightly darker and more color intensive than the vanilla brick block.
|
||||
tile.engineersdecor.slag_brick_stairs.name=Slag Brick Stairs
|
||||
tile.engineersdecor.slag_brick_stairs.help=§6Gray-brown brick stairs.
|
||||
tile.engineersdecor.rebar_concrete_stairs.name=Rebar Concrete Stairs
|
||||
tile.engineersdecor.rebar_concrete_stairs.help=§6Steel reinforced concrete stairs.§r Expensive but Creeper-proof like obsidian.
|
||||
tile.engineersdecor.rebar_concrete_tile_stairs.name=Rebar Concrete Tile Stairs
|
||||
|
@ -106,7 +106,8 @@ tile.engineersdecor.treated_wood_crafting_table.name=Treated Wood Crafting Table
|
|||
tile.engineersdecor.treated_wood_crafting_table.help=§6Robust and weather-proof.§r Eight storage slots, keeps inventory, no vanilla recipe book.\n\
|
||||
Click up/down arrow buttons for crafting history selection, output slot for item placement, X-button \
|
||||
to clear crafting grid and history. Shift-click stack: player-to-storage stack transfer when crafting \
|
||||
grid empty, otherwise player-to-grid stack transfer. Automatically distributes the clicked stack.
|
||||
grid empty, otherwise player-to-grid stack transfer. Automatically distributes the clicked stack. \
|
||||
Shift-Ctrl-click stack: Move all same stacks. Mouse wheel over crafting slot: Increase/decrease crafting grid items.
|
||||
tile.engineersdecor.treated_wood_side_table.name=Treated Wood Side Table
|
||||
tile.engineersdecor.treated_wood_side_table.help=§6Needed after the work's done.
|
||||
tile.engineersdecor.iron_inset_light.name=Inset Light
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue