Factory Hopper entity insertion/extraction added (issue #125). Re-enabled JEI. Forge dependency updated to 1.16.3-34.1.0.
This commit is contained in:
parent
16ad286f59
commit
1753624e2a
10 changed files with 87 additions and 53 deletions
|
@ -65,8 +65,8 @@ minecraft {
|
|||
|
||||
dependencies {
|
||||
minecraft "net.minecraftforge:forge:${version_forge_minecraft}"
|
||||
//compileOnly fg.deobf("mezz.jei:jei-${version_jei}:api")
|
||||
//runtimeOnly fg.deobf("mezz.jei:jei-${version_jei}")
|
||||
compileOnly fg.deobf("mezz.jei:jei-${version_jei}:api")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-${version_jei}")
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
org.gradle.daemon=false
|
||||
org.gradle.jvmargs=-Xmx8G
|
||||
version_minecraft=1.16.3
|
||||
version_forge_minecraft=1.16.3-34.0.1
|
||||
version_forge_minecraft=1.16.3-34.1.0
|
||||
version_fml_mappings=20200723-1.16.1
|
||||
version_jei=1.16.3:7.1.3.19
|
||||
version_engineersdecor=1.1.2-b8
|
||||
version_jei=1.16.3:7.3.2.36
|
||||
version_engineersdecor=1.1.2
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/",
|
||||
"1.16.3": {
|
||||
"1.1.2": "[U] Updated to Forge 1.16.3-34.1.0.\n[A] Added Factory Hopper insertion/extraction for entities like Minecarts (issue #125, ty boneskull).",
|
||||
"1.1.2-b8": "[F] Fixed Double-T support thick steel pole connection (thx @CastCrafter).\n[A] Concrete and Clinker walls connect to windows and glass panes.",
|
||||
"1.1.2-b7": "[U] Ported to MC1.16.3.\n[F] Roof lighting improved.",
|
||||
"1.1.2-b6": "[A] Signs added: Generic Caution, Magical Hazard, Radioactive Hazard, Laser Hazard, Fire Hazard, Caution Hot Surface, Magnetic Field Caution, Frost Warning.\n[A] Water Freezer added (generates Ice, Packed Ice, Blue Ice from water).\n[F] Mineral Smelter GUI model facing fixed.\n[M] Hatch handling improved.\n[M] Ladder fast-move improved.\n[F] Roof Chimney Trunk shape hollow to allow feeding IE Wire power over the roof into the building.\n[A] Roof Chimney added (smoking offset for Dark Shingle Roof Chimney Trunk block).\n[A] Metal Bar (ingredient item) added to circumvent recipe collisions with other mods.\n[M] Recipes for metallic blocks modified accordingly to depend on Metal Bars.",
|
||||
|
@ -11,7 +12,7 @@
|
|||
"1.1.2-b1": "[U] Ported to MC1.16.2."
|
||||
},
|
||||
"promos": {
|
||||
"1.16.3-recommended": "1.1.2-b8",
|
||||
"1.16.3-latest": "1.1.2-b8"
|
||||
"1.16.3-recommended": "1.1.2",
|
||||
"1.16.3-latest": "1.1.2"
|
||||
}
|
||||
}
|
|
@ -11,6 +11,9 @@ Mod sources for Minecraft version 1.16.3.
|
|||
|
||||
## Version history
|
||||
|
||||
- v1.1.2 [U] Updated to Forge 1.16.3-34.1.0.
|
||||
[A] Added Factory Hopper insertion/extraction for entities like Minecarts (issue #125, ty boneskull).
|
||||
|
||||
- v1.1.2-b8 [F] Fixed Double-T support thick steel pole connection (thx @CastCrafter).
|
||||
[A] Concrete and Clinker walls connect to windows and glass panes.
|
||||
|
||||
|
|
|
@ -8,14 +8,7 @@
|
|||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import wile.engineersdecor.ModContent;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.libmc.detail.Auxiliaries;
|
||||
import wile.engineersdecor.libmc.detail.Inventories;
|
||||
import wile.engineersdecor.libmc.detail.Networking;
|
||||
import wile.engineersdecor.libmc.detail.Inventories.SlotRange;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -52,7 +45,14 @@ import net.minecraftforge.common.util.LazyOptional;
|
|||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import wile.engineersdecor.ModContent;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.libmc.detail.Auxiliaries;
|
||||
import wile.engineersdecor.libmc.detail.Inventories;
|
||||
import wile.engineersdecor.libmc.detail.Networking;
|
||||
import wile.engineersdecor.libmc.detail.Inventories.SlotRange;
|
||||
import wile.engineersdecor.libmc.detail.TooltipDisplay;
|
||||
import wile.engineersdecor.libmc.detail.TooltipDisplay.TipRange;
|
||||
|
||||
|
@ -459,6 +459,12 @@ public class EdHopper
|
|||
|
||||
// ITickable and aux methods ---------------------------------------------------------------------
|
||||
|
||||
private IItemHandler inventory_entity_handler(BlockPos where)
|
||||
{
|
||||
final List<Entity> entities = world.getEntitiesInAABBexcluding(null, (new AxisAlignedBB(where)), EntityPredicates.HAS_INVENTORY);
|
||||
return entities.isEmpty() ? null : Inventories.itemhandler(entities.get(0));
|
||||
}
|
||||
|
||||
private static int next_slot(int i)
|
||||
{ return (i<NUM_OF_SLOTS-1) ? (i+1) : 0; }
|
||||
|
||||
|
@ -505,42 +511,54 @@ public class EdHopper
|
|||
current_slot_index_ = 0;
|
||||
return false;
|
||||
}
|
||||
final TileEntity te = world.getTileEntity(pos.offset(facing));
|
||||
if(te == null) { delay_timer_ = TICK_INTERVAL+2; return false; } // no reason to recalculate this all the time if there is nothere to insert.
|
||||
final IItemHandler ih = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()).orElse(null);
|
||||
if(ih == null) { delay_timer_ = TICK_INTERVAL+2; return false; }
|
||||
if(te instanceof net.minecraft.tileentity.HopperTileEntity) {
|
||||
Direction f = world.getBlockState(pos.offset(facing)).get(net.minecraft.block.HopperBlock.FACING);
|
||||
if(f==facing.getOpposite()) return false; // no back transfer
|
||||
} else if(te instanceof EdHopper.HopperTileEntity) {
|
||||
Direction f = world.getBlockState(pos.offset(facing)).get(EdHopper.HopperBlock.FACING);
|
||||
if(f==facing.getOpposite()) return false;
|
||||
final BlockPos facing_pos = pos.offset(facing);
|
||||
IItemHandler ih = null;
|
||||
// Tile entity insertion check
|
||||
{
|
||||
final TileEntity te = world.getTileEntity(facing_pos);
|
||||
if(te != null) {
|
||||
ih = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()).orElse(null);
|
||||
if(ih == null) { delay_timer_ = TICK_INTERVAL+2; return false; }
|
||||
if(te instanceof net.minecraft.tileentity.HopperTileEntity) {
|
||||
Direction f = world.getBlockState(facing_pos).get(net.minecraft.block.HopperBlock.FACING);
|
||||
if(f==facing.getOpposite()) return false; // no back transfer
|
||||
} else if(te instanceof EdHopper.HopperTileEntity) {
|
||||
Direction f = world.getBlockState(facing_pos).get(EdHopper.HopperBlock.FACING);
|
||||
if(f==facing.getOpposite()) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemStack insert_stack = current_stack.copy();
|
||||
if(insert_stack.getCount() > transfer_count_) insert_stack.setCount(transfer_count_);
|
||||
final int initial_insert_stack_size = insert_stack.getCount();
|
||||
if((ih == null) || ih.getSlots() <= 0) return false;
|
||||
// First stack comletion insert run.
|
||||
for(int i=0; i<ih.getSlots(); ++i) {
|
||||
final ItemStack target_stack = ih.getStackInSlot(i);
|
||||
if(Inventories.areItemStacksDifferent(target_stack, insert_stack)) continue;
|
||||
insert_stack = ih.insertItem(i, insert_stack.copy(), false);
|
||||
if(insert_stack.isEmpty()) break;
|
||||
}
|
||||
// First-available insert run.
|
||||
if(!insert_stack.isEmpty()) {
|
||||
// Entity insertion check
|
||||
if(ih == null) ih = inventory_entity_handler(facing_pos);
|
||||
if(ih == null) { delay_timer_ = TICK_INTERVAL+2; return false; } // no reason to recalculate this all the time if there is nowhere to insert.
|
||||
// Handler insertion
|
||||
{
|
||||
ItemStack insert_stack = current_stack.copy();
|
||||
if(insert_stack.getCount() > transfer_count_) insert_stack.setCount(transfer_count_);
|
||||
final int initial_insert_stack_size = insert_stack.getCount();
|
||||
if((ih == null) || ih.getSlots() <= 0) return false;
|
||||
// First stack comletion insert run.
|
||||
for(int i=0; i<ih.getSlots(); ++i) {
|
||||
final ItemStack target_stack = ih.getStackInSlot(i);
|
||||
if(Inventories.areItemStacksDifferent(target_stack, insert_stack)) continue;
|
||||
insert_stack = ih.insertItem(i, insert_stack.copy(), false);
|
||||
if(insert_stack.isEmpty()) break;
|
||||
}
|
||||
// First-available insert run.
|
||||
if(!insert_stack.isEmpty()) {
|
||||
for(int i=0; i<ih.getSlots(); ++i) {
|
||||
insert_stack = ih.insertItem(i, insert_stack.copy(), false);
|
||||
if(insert_stack.isEmpty()) break;
|
||||
}
|
||||
}
|
||||
final int num_inserted = initial_insert_stack_size-insert_stack.getCount();
|
||||
if(num_inserted > 0) {
|
||||
current_stack.shrink(num_inserted);
|
||||
stacks_.set(current_slot_index_, current_stack);
|
||||
}
|
||||
if(!insert_stack.isEmpty()) current_slot_index_ = next_slot(current_slot_index_);
|
||||
return (num_inserted > 0);
|
||||
}
|
||||
final int num_inserted = initial_insert_stack_size-insert_stack.getCount();
|
||||
if(num_inserted > 0) {
|
||||
current_stack.shrink(num_inserted);
|
||||
stacks_.set(current_slot_index_, current_stack);
|
||||
}
|
||||
if(!insert_stack.isEmpty()) current_slot_index_ = next_slot(current_slot_index_);
|
||||
return (num_inserted > 0);
|
||||
}
|
||||
|
||||
private boolean try_item_handler_extract(final IItemHandler ih)
|
||||
|
@ -643,15 +661,20 @@ public class EdHopper
|
|||
if(rssignal || pulse_mode) {
|
||||
Direction hopper_input_facing = (hopper_facing==Direction.UP) ? Direction.DOWN : Direction.UP;
|
||||
TileEntity te = world.getTileEntity(pos.offset(hopper_input_facing));
|
||||
final IItemHandler ih = (te==null) ? (null) : (te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, hopper_input_facing.getOpposite()).orElse(null));
|
||||
IItemHandler ih = (te==null) ? (null) : (te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, hopper_input_facing.getOpposite()).orElse(null));
|
||||
if((ih != null) || (te instanceof ISidedInventory)) {
|
||||
// IItemHandler pulling
|
||||
// Tile Entity pulling
|
||||
if((ih != null)) {
|
||||
if(try_item_handler_extract(ih)) dirty = true;
|
||||
} else {
|
||||
if(try_inventory_extract((IInventory)te)) dirty = true;
|
||||
}
|
||||
} else if((collection_timer_ -= TICK_INTERVAL) <= 0) {
|
||||
}
|
||||
if(ih==null) {
|
||||
ih = inventory_entity_handler(pos.offset(hopper_input_facing));
|
||||
if((ih!=null) && (try_item_handler_extract(ih))) dirty = true;
|
||||
}
|
||||
if((ih==null) && (collection_timer_ -= TICK_INTERVAL) <= 0) {
|
||||
// Ranged collection
|
||||
collection_timer_ = COLLECTION_INTERVAL;
|
||||
if(try_collect(hopper_input_facing)) dirty = true;
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
* JEI plugin (see https://github.com/mezz/JustEnoughItems/wiki/Creating-Plugins)
|
||||
*/
|
||||
package wile.engineersdecor.eapi.jei;
|
||||
public class JEIPlugin {}
|
||||
//public class JEIPlugin {}
|
||||
|
||||
/*
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.ModConfig;
|
||||
import wile.engineersdecor.ModContent;
|
||||
|
@ -75,4 +74,3 @@ public class JEIPlugin implements mezz.jei.api.IModPlugin
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package wile.engineersdecor.libmc.detail;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
|
@ -50,6 +51,12 @@ public class Inventories
|
|||
return null;
|
||||
}
|
||||
|
||||
public static IItemHandler itemhandler(Entity entity)
|
||||
{ return (entity instanceof IInventory) ? (new InvWrapper((IInventory)entity)) : null; }
|
||||
|
||||
public static IItemHandler itemhandler(Entity entity, @Nullable Direction side)
|
||||
{ return (entity instanceof IInventory) ? (new InvWrapper((IInventory)entity)) : null; } // in case a sided entity insertion pops up.
|
||||
|
||||
public static ItemStack insert(IItemHandler handler, ItemStack stack , boolean simulate)
|
||||
{ return ItemHandlerHelper.insertItemStacked(handler, stack, simulate); }
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ logoFile="logo.png"
|
|||
[[dependencies.engineersdecor]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[34.0.1,)"
|
||||
versionRange="[34.1.0,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"engineersdecor:rebar_concrete_slab",
|
||||
"engineersdecor:rebar_concrete_tile_slab",
|
||||
"engineersdecor:gas_concrete_slab",
|
||||
"engineersdecor:panzerglass_slab"
|
||||
"engineersdecor:panzerglass_slab",
|
||||
"engineersdecor:old_industrial_wood_slab"
|
||||
]
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
"engineersdecor:slag_brick_stairs",
|
||||
"engineersdecor:rebar_concrete_stairs",
|
||||
"engineersdecor:rebar_concrete_tile_stairs",
|
||||
"engineersdecor:gas_concrete_stairs"
|
||||
"engineersdecor:gas_concrete_stairs",
|
||||
"engineersdecor:old_industrial_wood_stairs"
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue