mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
Bad impression
- Mechanical Press can no longer create sheets in bulk, unless configured to - Fixed Mechanical Press missing items passing on a belt while retracting
This commit is contained in:
parent
d249318b80
commit
e92e9a7139
3 changed files with 70 additions and 22 deletions
|
@ -7,18 +7,25 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity.Mode;
|
import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity.Mode;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.BeltHelper;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
||||||
import com.simibubi.create.content.logistics.InWorldProcessing;
|
import com.simibubi.create.content.logistics.InWorldProcessing;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult;
|
import com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
|
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
|
||||||
|
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
|
||||||
|
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
public class BeltPressingCallbacks {
|
public class BeltPressingCallbacks {
|
||||||
|
|
||||||
static ProcessingResult onItemReceived(TransportedItemStack transported,
|
static ProcessingResult onItemReceived(TransportedItemStack transported,
|
||||||
TransportedItemStackHandlerBehaviour handler, MechanicalPressTileEntity press) {
|
TransportedItemStackHandlerBehaviour handler, MechanicalPressTileEntity press) {
|
||||||
if (press.getSpeed() == 0 || press.running)
|
if (press.getSpeed() == 0)
|
||||||
return PASS;
|
return PASS;
|
||||||
|
if (press.running)
|
||||||
|
return HOLD;
|
||||||
if (!press.getRecipe(transported.stack)
|
if (!press.getRecipe(transported.stack)
|
||||||
.isPresent())
|
.isPresent())
|
||||||
return PASS;
|
return PASS;
|
||||||
|
@ -44,25 +51,38 @@ public class BeltPressingCallbacks {
|
||||||
if (!recipe.isPresent())
|
if (!recipe.isPresent())
|
||||||
return PASS;
|
return PASS;
|
||||||
|
|
||||||
List<TransportedItemStack> collect = InWorldProcessing.applyRecipeOn(transported.stack, recipe.get())
|
boolean bulk = MechanicalPressTileEntity.canProcessInBulk() || transported.stack.getCount() == 1;
|
||||||
.stream()
|
|
||||||
.map(stack -> {
|
List<TransportedItemStack> collect = InWorldProcessing
|
||||||
TransportedItemStack copy = transported.copy();
|
.applyRecipeOn(bulk ? transported.stack : ItemHandlerHelper.copyStackWithSize(transported.stack, 1),
|
||||||
copy.stack = stack;
|
recipe.get())
|
||||||
return copy;
|
.stream()
|
||||||
}).collect(Collectors.toList());
|
.map(stack -> {
|
||||||
|
TransportedItemStack copy = transported.copy();
|
||||||
|
boolean centered = BeltHelper.isItemUpright(stack);
|
||||||
|
copy.stack = stack;
|
||||||
|
copy.locked = true;
|
||||||
|
copy.angle = centered ? 180 : Create.random.nextInt(360);
|
||||||
|
return copy;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (bulk) {
|
||||||
|
if (collect.isEmpty())
|
||||||
|
handler.handleProcessingOnItem(transported, TransportedResult.removeItem());
|
||||||
|
else
|
||||||
|
handler.handleProcessingOnItem(transported, TransportedResult.convertTo(collect));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
TransportedItemStack left = transported.copy();
|
||||||
|
left.stack.shrink(1);
|
||||||
|
|
||||||
|
if (collect.isEmpty())
|
||||||
|
handler.handleProcessingOnItem(transported, TransportedResult.convertTo(left));
|
||||||
|
else
|
||||||
|
handler.handleProcessingOnItem(transported, TransportedResult.convertToAndLeaveHeld(collect, left));
|
||||||
|
}
|
||||||
|
|
||||||
if (collect.isEmpty())
|
|
||||||
handler.handleProcessingOnItem(transported, TransportedItemStackHandlerBehaviour.TransportedResult.removeItem());
|
|
||||||
else
|
|
||||||
handler.handleProcessingOnItem(transported, TransportedItemStackHandlerBehaviour.TransportedResult.convertTo(collect));
|
|
||||||
/*ItemStack out = recipe.get()
|
|
||||||
.getRecipeOutput()
|
|
||||||
.copy();
|
|
||||||
List<ItemStack> multipliedOutput = ItemHelper.multipliedOutput(transported.stack, out);
|
|
||||||
if (multipliedOutput.isEmpty())
|
|
||||||
transported.stack = ItemStack.EMPTY;
|
|
||||||
transported.stack = multipliedOutput.get(0);*/
|
|
||||||
pressTe.sendData();
|
pressTe.sendData();
|
||||||
return HOLD;
|
return HOLD;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Optional;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllRecipeTypes;
|
import com.simibubi.create.AllRecipeTypes;
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.content.contraptions.processing.BasinOperatingTileEntity;
|
import com.simibubi.create.content.contraptions.processing.BasinOperatingTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.processing.BasinTileEntity;
|
import com.simibubi.create.content.contraptions.processing.BasinTileEntity;
|
||||||
import com.simibubi.create.content.logistics.InWorldProcessing;
|
import com.simibubi.create.content.logistics.InWorldProcessing;
|
||||||
|
@ -39,6 +40,7 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraftforge.common.util.Constants.NBT;
|
import net.minecraftforge.common.util.Constants.NBT;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||||
|
|
||||||
|
@ -231,6 +233,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
|
||||||
|
|
||||||
protected void applyPressingInWorld() {
|
protected void applyPressingInWorld() {
|
||||||
AxisAlignedBB bb = new AxisAlignedBB(pos.down(1));
|
AxisAlignedBB bb = new AxisAlignedBB(pos.down(1));
|
||||||
|
boolean bulk = canProcessInBulk();
|
||||||
pressedItems.clear();
|
pressedItems.clear();
|
||||||
if (world.isRemote)
|
if (world.isRemote)
|
||||||
return;
|
return;
|
||||||
|
@ -240,16 +243,39 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
|
||||||
if (!entity.isAlive() || !entity.isOnGround())
|
if (!entity.isAlive() || !entity.isOnGround())
|
||||||
continue;
|
continue;
|
||||||
ItemEntity itemEntity = (ItemEntity) entity;
|
ItemEntity itemEntity = (ItemEntity) entity;
|
||||||
pressedItems.add(itemEntity.getItem());
|
ItemStack item = itemEntity.getItem();
|
||||||
|
pressedItems.add(item);
|
||||||
sendData();
|
sendData();
|
||||||
Optional<PressingRecipe> recipe = getRecipe(itemEntity.getItem());
|
Optional<PressingRecipe> recipe = getRecipe(item);
|
||||||
if (!recipe.isPresent())
|
if (!recipe.isPresent())
|
||||||
continue;
|
continue;
|
||||||
InWorldProcessing.applyRecipeOn(itemEntity, recipe.get());
|
|
||||||
|
if (bulk || item.getCount() == 1) {
|
||||||
|
InWorldProcessing.applyRecipeOn(itemEntity, recipe.get());
|
||||||
|
} else {
|
||||||
|
for (ItemStack result : InWorldProcessing.applyRecipeOn(ItemHandlerHelper.copyStackWithSize(item, 1),
|
||||||
|
recipe.get())) {
|
||||||
|
ItemEntity created =
|
||||||
|
new ItemEntity(world, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), result);
|
||||||
|
created.setDefaultPickupDelay();
|
||||||
|
created.setMotion(VecHelper.offsetRandomly(Vector3d.ZERO, Create.random, .05f));
|
||||||
|
world.addEntity(created);
|
||||||
|
}
|
||||||
|
item.shrink(1);
|
||||||
|
}
|
||||||
|
|
||||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.BONK, world, pos, 4);
|
AllTriggers.triggerForNearbyPlayers(AllTriggers.BONK, world, pos, 4);
|
||||||
|
entityScanCooldown = 0;
|
||||||
|
|
||||||
|
if (!bulk)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean canProcessInBulk() {
|
||||||
|
return AllConfigs.SERVER.recipes.bulkPressing.get();
|
||||||
|
}
|
||||||
|
|
||||||
public int getRunningTickSpeed() {
|
public int getRunningTickSpeed() {
|
||||||
if (getSpeed() == 0)
|
if (getSpeed() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.foundation.config;
|
||||||
|
|
||||||
public class CRecipes extends ConfigBase {
|
public class CRecipes extends ConfigBase {
|
||||||
|
|
||||||
|
public ConfigBool bulkPressing = b(false, "bulkPressing", Comments.bulkPressing);
|
||||||
public ConfigBool allowShapelessInMixer = b(true, "allowShapelessInMixer", Comments.allowShapelessInMixer);
|
public ConfigBool allowShapelessInMixer = b(true, "allowShapelessInMixer", Comments.allowShapelessInMixer);
|
||||||
public ConfigBool allowShapedSquareInPress = b(true, "allowShapedSquareInPress", Comments.allowShapedSquareInPress);
|
public ConfigBool allowShapedSquareInPress = b(true, "allowShapedSquareInPress", Comments.allowShapedSquareInPress);
|
||||||
public ConfigBool allowRegularCraftingInCrafter =
|
public ConfigBool allowRegularCraftingInCrafter =
|
||||||
|
@ -20,6 +21,7 @@ public class CRecipes extends ConfigBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Comments {
|
private static class Comments {
|
||||||
|
static String bulkPressing = "When true, allows the Mechanical Press to process entire stacks at a time.";
|
||||||
static String allowShapelessInMixer =
|
static String allowShapelessInMixer =
|
||||||
"When true, allows any shapeless crafting recipes to be processed by a Mechanical Mixer + Basin.";
|
"When true, allows any shapeless crafting recipes to be processed by a Mechanical Mixer + Basin.";
|
||||||
static String allowShapedSquareInPress =
|
static String allowShapedSquareInPress =
|
||||||
|
|
Loading…
Reference in a new issue