Factory dropper fixes and logic simplifications.
This commit is contained in:
parent
c05ae72491
commit
f8442e36bf
13 changed files with 101 additions and 60 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.6
|
||||
version_engineersdecor=1.0.7-b1
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/",
|
||||
"1.12.2": {
|
||||
"1.0.7-b1": "[A] Factory dropper (config:experimental) button placement fixed, GUI vs external view x/y markers added, internal trigger logic simplified. Thx @overchoice for beta testing!",
|
||||
"1.0.6": "[R] Release based on v1.0.6-b1. Release-to-release changes: * Fixed FML remapping issue (COULD CAUSE CRASHES). * Small waste incinerator added. * Lang files updated/corrections. * Metal ladder easier to break.\n[A] Added factory dropper (config:experimental).\n[C] Thx to abdurraslan for the detailed issue #25.",
|
||||
"1.0.6-b1": "[A] Added small waste incinerator (delayed fifo-buffered item disposal).\n[M] Fixed item/block name capitalization (by Voxelo).\n[M] Metal ladders are easier to break/harvest.\n[F] Fixed FML remapping issue by using dedicated IItemHandler instances.",
|
||||
"1.0.5": "[R] Release based on v1.0.5-b1. Release-to-release changes: * Small electrical passthrough-furnace added. * Passive fluid accumulator added. * Config options added. * Sign plates added. * Minor bug fixes.\n[A] Added sign \"Electrical hazzard\"/\"Caution hot wire\".\n[A] Added sign \"Caution dangerous there\" (skull/bones).",
|
||||
|
@ -38,6 +39,6 @@
|
|||
},
|
||||
"promos": {
|
||||
"1.12.2-recommended": "1.0.6",
|
||||
"1.12.2-latest": "1.0.6"
|
||||
"1.12.2-latest": "1.0.7-b1"
|
||||
}
|
||||
}
|
|
@ -10,6 +10,10 @@ Mod sources for Minecraft version 1.12.2.
|
|||
----
|
||||
## Revision history
|
||||
|
||||
- v1.0.7-b1 [A] Factory dropper (config:experimental) button placement fixed,
|
||||
GUI vs external view x/y markers added, internal trigger logic
|
||||
simplified. Thx @overchoice for beta testing!
|
||||
|
||||
-------------------------------------------------------------------
|
||||
- v1.0.6 [R] Release based on v1.0.6-b1. Release-to-release changes:
|
||||
* Fixed FML remapping issue (COULD CAUSE CRASHES).
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.detail.Networking;
|
||||
|
@ -47,7 +49,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BlockDecorDropper extends BlockDecorDirected
|
||||
{
|
||||
|
@ -56,6 +57,10 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
public BlockDecorDropper(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound, @Nonnull AxisAlignedBB unrotatedAABB)
|
||||
{ super(registryName, config, material, hardness, resistance, sound, unrotatedAABB); }
|
||||
|
||||
@Override
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face)
|
||||
{ return BlockFaceShape.SOLID; }
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{ return new BlockStateContainer(this, FACING, OPEN); }
|
||||
|
@ -94,12 +99,13 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||
{
|
||||
if(world.isRemote) return;
|
||||
if((!stack.hasTagCompound()) || (!stack.getTagCompound().hasKey("inventory"))) return;
|
||||
NBTTagCompound inventory_nbt = stack.getTagCompound().getCompoundTag("inventory");
|
||||
if(inventory_nbt.isEmpty()) return;
|
||||
if((!stack.hasTagCompound()) || (!stack.getTagCompound().hasKey("tedata"))) return;
|
||||
NBTTagCompound te_nbt = stack.getTagCompound().getCompoundTag("tedata");
|
||||
if(te_nbt.isEmpty()) return;
|
||||
final TileEntity te = world.getTileEntity(pos);
|
||||
if(!(te instanceof BlockDecorDropper.BTileEntity)) return;
|
||||
((BlockDecorDropper.BTileEntity)te).readnbt(inventory_nbt, false);
|
||||
((BlockDecorDropper.BTileEntity)te).readnbt(te_nbt, false);
|
||||
((BlockDecorDropper.BTileEntity)te).reset_rtstate();
|
||||
((BlockDecorDropper.BTileEntity)te).markDirty();
|
||||
}
|
||||
|
||||
|
@ -110,11 +116,11 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
TileEntity te = world.getTileEntity(pos);
|
||||
if(!(te instanceof BTileEntity)) return super.removedByPlayer(state, world, pos, player, willHarvest);
|
||||
ItemStack stack = new ItemStack(this, 1);
|
||||
NBTTagCompound inventory_nbt = new NBTTagCompound();
|
||||
ItemStackHelper.saveAllItems(inventory_nbt, ((BTileEntity)te).stacks_, false);
|
||||
if(!inventory_nbt.isEmpty()) {
|
||||
NBTTagCompound te_nbt = new NBTTagCompound();
|
||||
((BTileEntity) te).writenbt(te_nbt, false);
|
||||
if(!te_nbt.isEmpty()) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setTag("inventory", inventory_nbt);
|
||||
nbt.setTag("tedata", te_nbt);
|
||||
stack.setTagCompound(nbt);
|
||||
}
|
||||
world.spawnEntity(new EntityItem(world, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, stack));
|
||||
|
@ -132,7 +138,7 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
for(ItemStack stack: ((BTileEntity)te).stacks_) {
|
||||
if(!stack.isEmpty()) world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack));
|
||||
}
|
||||
((BTileEntity)te).reset();
|
||||
((BTileEntity)te).reset_rtstate();
|
||||
super.onBlockExploded(world, pos, explosion);
|
||||
}
|
||||
|
||||
|
@ -465,8 +471,8 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
private int drop_xdev_ = 0;
|
||||
private int drop_ydev_ = 0;
|
||||
private int drop_count_ = 1;
|
||||
private int drop_logic_ = 0;
|
||||
private int drop_period_ = 20;
|
||||
private int drop_logic_ = DROPLOGIC_EXTERN_ANDGATE;
|
||||
private int drop_period_ = 0;
|
||||
private int drop_slot_index_ = 0;
|
||||
private int tick_timer_ = 0;
|
||||
protected NonNullList<ItemStack> stacks_;
|
||||
|
@ -477,16 +483,15 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
}
|
||||
|
||||
public BTileEntity()
|
||||
{ reset(); }
|
||||
|
||||
protected void reset()
|
||||
{
|
||||
stacks_ = NonNullList.<ItemStack>withSize(NUM_OF_SLOTS, ItemStack.EMPTY);
|
||||
reset_rtstate();
|
||||
}
|
||||
|
||||
public void reset_rtstate()
|
||||
{
|
||||
block_power_signal_ = false;
|
||||
block_power_updated_ = false;
|
||||
drop_count_ = 1;
|
||||
drop_period_ = 20;
|
||||
drop_logic_ = DROPLOGIC_EXTERN_ANDGATE;
|
||||
for(int i=0; i<filter_matches_.length; ++i) filter_matches_[i] = 0;
|
||||
}
|
||||
|
||||
|
@ -736,7 +741,7 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
double vdx = 1e-2 * MathHelper.clamp(xdeviation, -100, 100);
|
||||
double vdy = 1e-2 * MathHelper.clamp(ydeviation, -100, 100);
|
||||
switch(facing) { // switch-case faster than coorsys fwd transform
|
||||
case DOWN: v0 = v0.add( vdx, 0, vdy); break; // down/up: use xz
|
||||
case DOWN: v0 = v0.add( vdx, 0,-vdy); break;
|
||||
case NORTH: v0 = v0.add( vdx, vdy, 0); break;
|
||||
case SOUTH: v0 = v0.add(-vdx, vdy, 0); break;
|
||||
case EAST: v0 = v0.add(0, vdy, vdx); break;
|
||||
|
@ -796,7 +801,6 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
boolean redstone_trigger = (block_power_signal_ && block_power_updated_);
|
||||
boolean filter_trigger;
|
||||
boolean trigger;
|
||||
int filter_trigger_slots[] = {-1,-1,-1};
|
||||
// Trigger logic
|
||||
{
|
||||
boolean droppable_slot_found = false;
|
||||
|
@ -814,12 +818,14 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
if(cmp_stack.isEmpty()) continue;
|
||||
filter_matches_[ci] = 1;
|
||||
final int cmp_stack_count = cmp_stack.getCount();
|
||||
int inventory_item_count = 0;
|
||||
int slot = drop_slot_index_;
|
||||
for(int i=INPUT_SLOTS_FIRST; i<(INPUT_SLOTS_FIRST+INPUT_SLOTS_SIZE); ++i) {
|
||||
final ItemStack inp_stack = stacks_.get(slot);
|
||||
if((inp_stack.getCount() < cmp_stack_count) || (!inp_stack.isItemEqual(cmp_stack))) { slot = next_slot(slot); continue; }
|
||||
if(!inp_stack.isItemEqual(cmp_stack)) { slot = next_slot(slot); continue; }
|
||||
inventory_item_count += inp_stack.getCount();
|
||||
if(inventory_item_count < cmp_stack_count) { slot = next_slot(slot); continue; }
|
||||
filter_matches_[ci] = 2;
|
||||
filter_trigger_slots[ci] = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -847,58 +853,71 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
}
|
||||
}
|
||||
// edge detection for next cycle
|
||||
if(trigger) {
|
||||
{
|
||||
boolean tr = world.isBlockPowered(pos);
|
||||
block_power_updated_ = (block_power_signal_ != tr);
|
||||
block_power_signal_ = tr;
|
||||
dirty = true;
|
||||
if(block_power_updated_) dirty = true;
|
||||
}
|
||||
}
|
||||
// block state update
|
||||
final IBlockState state = update_blockstate();
|
||||
if(state == null) { block_power_signal_= false; return; }
|
||||
// dispense action
|
||||
if(trigger) {
|
||||
if(trigger && (drop_timer_ <= 0)) {
|
||||
// drop stack for non-filter triggers
|
||||
ItemStack drop_stacks[] = {ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY};
|
||||
if(!filter_trigger) {
|
||||
Arrays.fill(filter_trigger_slots,-1);
|
||||
for(int i=0; i<INPUT_SLOTS_SIZE; ++i) {
|
||||
if(drop_slot_index_ >= INPUT_SLOTS_SIZE) drop_slot_index_ = 0;
|
||||
int ic = drop_slot_index_;
|
||||
drop_slot_index_ = next_slot(drop_slot_index_);
|
||||
ItemStack ds = stacks_.get(ic);
|
||||
if((!ds.isEmpty()) && (ds.getCount() >= drop_count_)) {
|
||||
filter_trigger_slots[0] = ic;
|
||||
drop_stacks[0] = ds.splitStack(drop_count_);
|
||||
stacks_.set(ic, ds);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(int fi=0; fi<filter_matches_.length; ++fi) {
|
||||
if(filter_matches_[fi] > 1) {
|
||||
drop_stacks[fi] = stacks_.get(CTRL_SLOTS_FIRST+fi).copy();
|
||||
int ntoremove = drop_stacks[fi].getCount();
|
||||
for(int i=INPUT_SLOTS_SIZE-1; (i>=0) && (ntoremove>0); --i) {
|
||||
ItemStack stack = stacks_.get(i);
|
||||
if(!stack.isItemEqual(drop_stacks[fi])) continue;
|
||||
if(stack.getCount() <= ntoremove) {
|
||||
ntoremove -= stack.getCount();
|
||||
stacks_.set(i, ItemStack.EMPTY);
|
||||
} else {
|
||||
stack.shrink(ntoremove);
|
||||
ntoremove = 0;
|
||||
stacks_.set(i, stack);
|
||||
}
|
||||
}
|
||||
if(ntoremove > 0) drop_stacks[fi].shrink(ntoremove);
|
||||
}
|
||||
}
|
||||
}
|
||||
// drop action
|
||||
if(drop_timer_ <= 0) {
|
||||
boolean dropped = false;
|
||||
for(int i = 0; i < filter_trigger_slots.length; ++i) {
|
||||
if(filter_trigger_slots[i] < 0) continue;
|
||||
ItemStack ds = stacks_.get(filter_trigger_slots[i]);
|
||||
if(ds.getCount() >= drop_count_) {
|
||||
ItemStack drop_stack = ds.splitStack(drop_count_);
|
||||
if(!drop_stack.isEmpty()) {
|
||||
dirty = true;
|
||||
drop(world, pos, state.getValue(FACING), drop_stack, drop_speed_, drop_xdev_, drop_ydev_, drop_noise_);
|
||||
dropped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// cooldown
|
||||
if(dropped) drop_timer_ = DROP_PERIOD_OFFSET + drop_period_ * 2; // 0.1s time base -> 100%===10s
|
||||
// drop sound
|
||||
if(dropped && ((drop_logic_ & DROPLOGIC_SILENT_DROP) == 0)) {
|
||||
world.playSound(null, pos, SoundEvents.BLOCK_CLOTH_STEP, SoundCategory.BLOCKS, 0.1f, 4f);
|
||||
}
|
||||
// advance to next nonempty slot.
|
||||
for(int i = 0; i < INPUT_SLOTS_SIZE; ++i) {
|
||||
if(!stacks_.get(drop_slot_index_).isEmpty()) break;
|
||||
drop_slot_index_ = next_slot(drop_slot_index_);
|
||||
}
|
||||
boolean dropped = false;
|
||||
for(int i = 0; i < drop_stacks.length; ++i) {
|
||||
if(drop_stacks[i].isEmpty()) continue;
|
||||
dirty = true;
|
||||
drop(world, pos, state.getValue(FACING), drop_stacks[i], drop_speed_, drop_xdev_, drop_ydev_, drop_noise_);
|
||||
dropped = true;
|
||||
}
|
||||
// cooldown
|
||||
if(dropped) drop_timer_ = DROP_PERIOD_OFFSET + drop_period_ * 2; // 0.1s time base -> 100%===10s
|
||||
// drop sound
|
||||
if(dropped && ((drop_logic_ & DROPLOGIC_SILENT_DROP) == 0)) {
|
||||
world.playSound(null, pos, SoundEvents.BLOCK_CLOTH_STEP, SoundCategory.BLOCKS, 0.1f, 4f);
|
||||
}
|
||||
// advance to next nonempty slot.
|
||||
for(int i = 0; i < INPUT_SLOTS_SIZE; ++i) {
|
||||
if(!stacks_.get(drop_slot_index_).isEmpty()) break;
|
||||
drop_slot_index_ = next_slot(drop_slot_index_);
|
||||
}
|
||||
}
|
||||
if(dirty) markDirty();
|
||||
|
|
|
@ -45,7 +45,6 @@ public class BlockDecorHorizontalSupport extends BlockDecor
|
|||
public BlockDecorHorizontalSupport(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound, @Nonnull AxisAlignedBB unrotatedAABB)
|
||||
{
|
||||
super(registryName, config|CFG_HORIZIONTAL, material, hardness, resistance, sound);
|
||||
final boolean is_horizontal = ((config & CFG_HORIZIONTAL)!=0);
|
||||
AABBs = new ArrayList<AxisAlignedBB>(Arrays.asList(
|
||||
// Effective bounding box
|
||||
ModAuxiliaries.getRotatedAABB(unrotatedAABB.grow(2.0/16, 0, 0), EnumFacing.NORTH, true),
|
||||
|
|
|
@ -122,7 +122,12 @@ tile.engineersdecor.passive_fluid_accumulator.help=§6Vacuum suction based fluid
|
|||
Drains fluids from adjacent tanks when being drained from the output port by a pump.
|
||||
#-----------------------------------------------------------------------------------------------------------
|
||||
tile.engineersdecor.factory_dropper.name=Factory Dropper
|
||||
tile.engineersdecor.factory_dropper.help=§6Dropper suitable for advanced factory automation.§r
|
||||
tile.engineersdecor.factory_dropper.help=§6Dropper suitable for advanced factory automation.§r Has twelve round-robin selected slots. \
|
||||
Drop force, angle, stack size, and cool-down delay adjustable in the GUI. Three stack compare \
|
||||
solts with logical AND or OR can be used as internal trigger source. Internal trigger can be \
|
||||
AND'ed or OR'ed with the external redstone signal trigger. Trigger simulation buttons for testing. \
|
||||
Pre-opens shutter door when internal trigger conditions are met. Drops all matching stacks \
|
||||
simultaneously. Click on all elements in the GUI to see how it works.
|
||||
#-----------------------------------------------------------------------------------------------------------
|
||||
tile.engineersdecor.sign_decor.name=Sign Plate (Engineer's decor)
|
||||
tile.engineersdecor.sign_decor.help=§6This should not be craftable or visible in JEI. Used for creative tab and screenshots.
|
||||
|
|
|
@ -115,7 +115,12 @@ tile.engineersdecor.passive_fluid_accumulator.name=Passive fluid accumulator
|
|||
Drains fluids from adjacent tanks when being drained from the output port by a pump.
|
||||
#-----------------------------------------------------------------------------------------------------------
|
||||
tile.engineersdecor.factory_dropper.name=Factory dropper
|
||||
#tile.engineersdecor.factory_dropper.help=§6Dropper suitable for advanced factory automation.§r
|
||||
#tile.engineersdecor.factory_dropper.help=§6Dropper suitable for advanced factory automation.§r Has twelve round-robin selected slots. \
|
||||
Drop force, angle, stack size, and cool-down delay adjustable in the GUI. Three stack compare \
|
||||
solts with logical AND or OR can be used as internal trigger source. Internal trigger can be \
|
||||
AND'ed or OR'ed with the external redstone signal trigger. Trigger simulation buttons for testing. \
|
||||
Pre-opens shutter door when internal trigger conditions are met. Drops all matching stacks \
|
||||
simultaneously. Click on all elements in the GUI to see how it works.
|
||||
#-----------------------------------------------------------------------------------------------------------
|
||||
tile.engineersdecor.sign_decor.name=Sign plate (Engineer's decor logo)
|
||||
#tile.engineersdecor.sign_decor.help=§6This should not be craftable or visible in JEI. Used for creative tab and screenshots.
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 556 B |
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Loading…
Add table
Add a link
Reference in a new issue