mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-24 14:06:42 +01:00
Playtest Issues, Part III
- Made /KillTPS unavailable for release dist - Shafts now place correctly again - Doors and Pressure Plates are now portable - Fixed crash when using the Mechanical Saw for item processing - Belts and other item insertion can now insert into crushing wheels directly
This commit is contained in:
parent
1edda9b564
commit
f26c80560d
15 changed files with 187 additions and 175 deletions
|
@ -8,11 +8,7 @@ import net.minecraft.command.Commands;
|
|||
public class CreateCommand {
|
||||
|
||||
public CreateCommand(CommandDispatcher<CommandSource> dispatcher) {
|
||||
|
||||
KillTPSCommand.register(dispatcher);
|
||||
|
||||
dispatcher.register(Commands.literal("create")
|
||||
.then(ToggleDebugCommand.register())
|
||||
);
|
||||
// KillTPSCommand.register(dispatcher); Commented out for release
|
||||
dispatcher.register(Commands.literal("create").then(ToggleDebugCommand.register()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,58 +10,59 @@ import net.minecraft.command.Commands;
|
|||
|
||||
public class KillTPSCommand {
|
||||
|
||||
|
||||
|
||||
public static void register(CommandDispatcher<CommandSource> dispatcher) {
|
||||
dispatcher.register(
|
||||
Commands.literal(Lang.translate("command.killTPSCommand"))
|
||||
.requires(cs -> cs.hasPermissionLevel(2))
|
||||
.executes(ctx -> {
|
||||
dispatcher.register(Commands.literal(Lang.translate("command.killTPSCommand"))
|
||||
.requires(cs -> cs.hasPermissionLevel(2)).executes(ctx -> {
|
||||
// killtps no arguments
|
||||
ctx.getSource().sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.0", Create.lagger.isLagging() ? Create.lagger.getTickTime() : 0), true);
|
||||
ctx.getSource().sendFeedback(
|
||||
Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.0",
|
||||
Create.lagger.isLagging() ? Create.lagger.getTickTime() : 0),
|
||||
true);
|
||||
if (Create.lagger.isLagging())
|
||||
ctx.getSource().sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), true);
|
||||
ctx.getSource().sendFeedback(
|
||||
Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), true);
|
||||
else
|
||||
ctx.getSource().sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.1"),true);
|
||||
ctx.getSource().sendFeedback(
|
||||
Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.1"), true);
|
||||
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.literal("start")
|
||||
.executes(ctx -> {
|
||||
}).then(Commands.literal("start").executes(ctx -> {
|
||||
// killtps start no time
|
||||
int tickTime = Create.lagger.getTickTime();
|
||||
if (tickTime > 0) {
|
||||
Create.lagger.setLagging(true);
|
||||
ctx.getSource().sendFeedback((Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.1", tickTime)),true);
|
||||
ctx.getSource().sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"),true);
|
||||
ctx.getSource().sendFeedback((Lang
|
||||
.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.1", tickTime)),
|
||||
true);
|
||||
ctx.getSource().sendFeedback(
|
||||
Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), true);
|
||||
} else {
|
||||
ctx.getSource().sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.1"),true);
|
||||
ctx.getSource().sendFeedback(
|
||||
Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.1"), true);
|
||||
}
|
||||
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument(Lang.translate("command.killTPSCommand.argument.tickTime"), IntegerArgumentType.integer(1))
|
||||
.executes(ctx -> {
|
||||
}).then(Commands.argument(Lang.translate("command.killTPSCommand.argument.tickTime"),
|
||||
IntegerArgumentType.integer(1)).executes(ctx -> {
|
||||
// killtps start tickTime
|
||||
int tickTime = IntegerArgumentType.getInteger(ctx, Lang.translate("command.killTPSCommand.argument.tickTime"));
|
||||
int tickTime = IntegerArgumentType.getInteger(ctx,
|
||||
Lang.translate("command.killTPSCommand.argument.tickTime"));
|
||||
Create.lagger.setTickTime(tickTime);
|
||||
Create.lagger.setLagging(true);
|
||||
ctx.getSource().sendFeedback((Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.1", tickTime)),true);
|
||||
ctx.getSource().sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"),true);
|
||||
ctx.getSource().sendFeedback((Lang.createTranslationTextComponent(
|
||||
"command.killTPSCommand.status.slowed_by.1", tickTime)), true);
|
||||
ctx.getSource().sendFeedback(
|
||||
Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), true);
|
||||
|
||||
return 1;
|
||||
})
|
||||
)
|
||||
)
|
||||
.then(Commands.literal("stop")
|
||||
.executes(ctx -> {
|
||||
})))
|
||||
.then(Commands.literal("stop").executes(ctx -> {
|
||||
// killtps stop
|
||||
Create.lagger.setLagging(false);
|
||||
ctx.getSource().sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.2"), false);
|
||||
ctx.getSource().sendFeedback(
|
||||
Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.2"), false);
|
||||
|
||||
return 1;
|
||||
})
|
||||
)
|
||||
);
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock {
|
|||
Axis preferredAxis = getPreferredAxis(context);
|
||||
if (preferredAxis != null && !context.isPlacerSneaking())
|
||||
return this.getDefaultState().with(AXIS, preferredAxis);
|
||||
return this.getDefaultState().with(AXIS,
|
||||
preferredAxis == null ? context.getFace().getAxis() : context.getNearestLookingDirection().getAxis());
|
||||
return this.getDefaultState().with(AXIS, context.isPlacerSneaking() ? context.getFace().getAxis()
|
||||
: context.getNearestLookingDirection().getAxis());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,10 +5,12 @@ import com.simibubi.create.modules.contraptions.components.actors.HarvesterBlock
|
|||
import com.simibubi.create.modules.contraptions.components.actors.PortableStorageInterfaceBlock;
|
||||
import com.simibubi.create.modules.contraptions.components.contraptions.chassis.AbstractChassisBlock;
|
||||
|
||||
import net.minecraft.block.AbstractPressurePlateBlock;
|
||||
import net.minecraft.block.AbstractRailBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.DoorBlock;
|
||||
import net.minecraft.block.HorizontalFaceBlock;
|
||||
import net.minecraft.block.LadderBlock;
|
||||
import net.minecraft.block.RedstoneWallTorchBlock;
|
||||
|
@ -59,6 +61,10 @@ public class BlockMovementTraits {
|
|||
return true;
|
||||
if (block instanceof TorchBlock)
|
||||
return true;
|
||||
if (block instanceof AbstractPressurePlateBlock)
|
||||
return true;
|
||||
if (block instanceof DoorBlock)
|
||||
return true;
|
||||
if (block instanceof HorizontalFaceBlock)
|
||||
return true;
|
||||
if (block instanceof AbstractRailBlock)
|
||||
|
@ -75,6 +81,10 @@ public class BlockMovementTraits {
|
|||
return state.get(LadderBlock.FACING) == direction.getOpposite();
|
||||
if (block instanceof WallTorchBlock)
|
||||
return state.get(WallTorchBlock.HORIZONTAL_FACING) == direction.getOpposite();
|
||||
if (block instanceof AbstractPressurePlateBlock)
|
||||
return direction == Direction.DOWN;
|
||||
if (block instanceof DoorBlock)
|
||||
return direction == Direction.DOWN;
|
||||
if (block instanceof RedstoneWallTorchBlock)
|
||||
return state.get(RedstoneWallTorchBlock.FACING) == direction.getOpposite();
|
||||
if (block instanceof TorchBlock)
|
||||
|
|
|
@ -35,11 +35,13 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ChestBlock;
|
||||
import net.minecraft.block.DoorBlock;
|
||||
import net.minecraft.block.SlimeBlock;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.state.properties.ChestType;
|
||||
import net.minecraft.state.properties.DoubleBlockHalf;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Direction;
|
||||
|
@ -157,6 +159,11 @@ public abstract class Contraption {
|
|||
if (prevPos != null && !visited.contains(prevPos))
|
||||
frontier.add(prevPos);
|
||||
}
|
||||
if (state.getBlock() instanceof DoorBlock) {
|
||||
BlockPos otherPartPos = pos.up(state.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? 1 : -1);
|
||||
if (!visited.contains(otherPartPos))
|
||||
frontier.add(otherPartPos);
|
||||
}
|
||||
|
||||
boolean isSlimeBlock = state.getBlock() instanceof SlimeBlock;
|
||||
for (Direction offset : Direction.values()) {
|
||||
|
@ -388,7 +395,8 @@ public abstract class Contraption {
|
|||
if (customRemoval.test(add, block.state))
|
||||
continue;
|
||||
world.getWorld().removeTileEntity(add);
|
||||
world.setBlockState(add, Blocks.AIR.getDefaultState(), 67);
|
||||
int flags = 67 | 32 | 16;
|
||||
world.setBlockState(add, Blocks.AIR.getDefaultState(), flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -410,9 +418,11 @@ public abstract class Contraption {
|
|||
if (customPlacement.test(targetPos, state))
|
||||
continue;
|
||||
|
||||
if (nonBrittles)
|
||||
for (Direction face : Direction.values())
|
||||
state = state.updatePostPlacement(face, world.getBlockState(targetPos.offset(face)), world,
|
||||
targetPos, targetPos.offset(face));
|
||||
|
||||
if (AllBlocks.SAW.typeOf(state))
|
||||
state = state.with(SawBlock.RUNNING, false);
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ import java.util.List;
|
|||
|
||||
import com.simibubi.create.AllRecipes;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingIngredient;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingInventory;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingOutput;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingRecipe;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
|
||||
public class CrushingRecipe extends ProcessingRecipe<ProcessingInventory> {
|
||||
public class CrushingRecipe extends ProcessingRecipe<RecipeWrapper> {
|
||||
|
||||
public CrushingRecipe(ResourceLocation id, String group, List<ProcessingIngredient> ingredients,
|
||||
List<ProcessingOutput> results, int processingDuration) {
|
||||
|
@ -19,7 +19,7 @@ public class CrushingRecipe extends ProcessingRecipe<ProcessingInventory> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ProcessingInventory inv, World worldIn) {
|
||||
public boolean matches(RecipeWrapper inv, World worldIn) {
|
||||
if (inv.isEmpty())
|
||||
return false;
|
||||
return ingredients.get(0).test(inv.getStackInSlot(0));
|
||||
|
|
|
@ -176,7 +176,7 @@ public class CrushingWheelControllerBlock extends Block implements IHaveNoBlockI
|
|||
if (worldIn.getTileEntity(pos) == null)
|
||||
return;
|
||||
CrushingWheelControllerTileEntity te = (CrushingWheelControllerTileEntity) worldIn.getTileEntity(pos);
|
||||
for (int slot = 0; slot < te.inventory.getSizeInventory(); slot++) {
|
||||
for (int slot = 0; slot < te.inventory.getSlots(); slot++) {
|
||||
InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(),
|
||||
te.inventory.getStackInSlot(slot));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simibubi.create.modules.contraptions.components.crusher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
@ -9,6 +10,7 @@ import com.simibubi.create.AllRecipes;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
||||
import com.simibubi.create.foundation.item.ItemHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingInventory;
|
||||
|
||||
|
@ -23,9 +25,15 @@ import net.minecraft.particles.IParticleData;
|
|||
import net.minecraft.particles.ItemParticleData;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
|
||||
public class CrushingWheelControllerTileEntity extends SyncedTileEntity implements ITickableTileEntity {
|
||||
|
||||
|
@ -34,11 +42,21 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
|
|||
protected boolean searchForEntity;
|
||||
|
||||
public ProcessingInventory inventory;
|
||||
protected LazyOptional<IItemHandlerModifiable> handler = LazyOptional.of(() -> inventory);
|
||||
private RecipeWrapper wrapper;
|
||||
public float crushingspeed;
|
||||
|
||||
public CrushingWheelControllerTileEntity() {
|
||||
super(AllTileEntities.CRUSHING_WHEEL_CONTROLLER.type);
|
||||
inventory = new ProcessingInventory();
|
||||
inventory = new ProcessingInventory(this::itemInserted) {
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, ItemStack stack) {
|
||||
return super.isItemValid(slot, stack) && processingEntity == null;
|
||||
}
|
||||
|
||||
};
|
||||
wrapper = new RecipeWrapper(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,7 +100,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
|
|||
}
|
||||
|
||||
if (inventory.remainingTime <= 0) {
|
||||
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
|
||||
for (int slot = 0; slot < inventory.getSlots(); slot++) {
|
||||
ItemStack stack = inventory.getStackInSlot(slot);
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
|
@ -127,7 +145,9 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
|
|||
ItemEntity itemEntity = (ItemEntity) processingEntity;
|
||||
itemEntity.setPickupDelay(20);
|
||||
if (processingEntity.posY < pos.getY() + .25f) {
|
||||
insertItem(itemEntity);
|
||||
inventory.clear();
|
||||
inventory.setStackInSlot(0, itemEntity.getItem().copy());
|
||||
itemInserted(inventory.getStackInSlot(0));
|
||||
itemEntity.remove();
|
||||
world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 2 | 16);
|
||||
}
|
||||
|
@ -140,8 +160,8 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
|
|||
|
||||
IParticleData particleData = null;
|
||||
if (stack.getItem() instanceof BlockItem)
|
||||
particleData = new BlockParticleData(ParticleTypes.BLOCK,
|
||||
((BlockItem) stack.getItem()).getBlock().getDefaultState());
|
||||
particleData =
|
||||
new BlockParticleData(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock().getDefaultState());
|
||||
else
|
||||
particleData = new ItemParticleData(ParticleTypes.ITEM, stack);
|
||||
|
||||
|
@ -152,28 +172,22 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
|
|||
}
|
||||
|
||||
private void applyRecipe() {
|
||||
Optional<CrushingRecipe> recipe = world.getRecipeManager().getRecipe(AllRecipes.CRUSHING.getType(), inventory,
|
||||
world);
|
||||
Optional<CrushingRecipe> recipe =
|
||||
world.getRecipeManager().getRecipe(AllRecipes.CRUSHING.getType(), wrapper, world);
|
||||
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
if (recipe.isPresent()) {
|
||||
int rolls = inventory.getStackInSlot(0).getCount();
|
||||
inventory.clear();
|
||||
|
||||
for (int roll = 0; roll < rolls; roll++) {
|
||||
List<ItemStack> rolledResults = recipe.get().rollResults();
|
||||
|
||||
for (int i = 0; i < rolledResults.size(); i++) {
|
||||
ItemStack stack = rolledResults.get(i);
|
||||
|
||||
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
|
||||
stack = inventory.getItems().insertItem(slot, stack, false);
|
||||
|
||||
if (stack.isEmpty())
|
||||
break;
|
||||
ItemHelper.addToList(stack, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int slot = 0; slot < list.size() && slot + 1 < inventory.getSlots(); slot++)
|
||||
inventory.setStackInSlot(slot + 1, list.get(slot));
|
||||
} else {
|
||||
inventory.clear();
|
||||
}
|
||||
|
@ -184,7 +198,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
|
|||
public CompoundNBT write(CompoundNBT compound) {
|
||||
if (hasEntity() && !isFrozen())
|
||||
compound.put("Entity", NBTUtil.writeUniqueId(entityUUID));
|
||||
inventory.write(compound);
|
||||
compound.put("Inventory", inventory.serializeNBT());
|
||||
compound.putFloat("Speed", crushingspeed);
|
||||
|
||||
return super.write(compound);
|
||||
|
@ -199,8 +213,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
|
|||
this.searchForEntity = true;
|
||||
}
|
||||
crushingspeed = compound.getFloat("Speed");
|
||||
inventory = ProcessingInventory.read(compound);
|
||||
|
||||
inventory.deserializeNBT(compound.getCompound("Inventory"));
|
||||
}
|
||||
|
||||
public void startCrushing(Entity entity) {
|
||||
|
@ -208,16 +221,20 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
|
|||
entityUUID = entity.getUniqueID();
|
||||
}
|
||||
|
||||
private void insertItem(ItemEntity entity) {
|
||||
inventory.clear();
|
||||
inventory.setInventorySlotContents(0, entity.getItem());
|
||||
Optional<CrushingRecipe> recipe = world.getRecipeManager().getRecipe(AllRecipes.CRUSHING.getType(), inventory,
|
||||
world);
|
||||
|
||||
private void itemInserted(ItemStack stack) {
|
||||
Optional<CrushingRecipe> recipe =
|
||||
world.getRecipeManager().getRecipe(AllRecipes.CRUSHING.getType(), wrapper, world);
|
||||
inventory.remainingTime = recipe.isPresent() ? recipe.get().getProcessingDuration() : 100;
|
||||
inventory.appliedRecipe = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
return handler.cast();
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
processingEntity = null;
|
||||
entityUUID = null;
|
||||
|
|
|
@ -4,14 +4,14 @@ import java.util.List;
|
|||
|
||||
import com.simibubi.create.AllRecipes;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingIngredient;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingInventory;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingOutput;
|
||||
import com.simibubi.create.modules.contraptions.processing.ProcessingRecipe;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
|
||||
public class CuttingRecipe extends ProcessingRecipe<ProcessingInventory> {
|
||||
public class CuttingRecipe extends ProcessingRecipe<RecipeWrapper> {
|
||||
|
||||
public CuttingRecipe(ResourceLocation id, String group, List<ProcessingIngredient> ingredients,
|
||||
List<ProcessingOutput> results, int processingDuration) {
|
||||
|
@ -19,7 +19,7 @@ public class CuttingRecipe extends ProcessingRecipe<ProcessingInventory> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ProcessingInventory inv, World worldIn) {
|
||||
public boolean matches(RecipeWrapper inv, World worldIn) {
|
||||
if (inv.isEmpty())
|
||||
return false;
|
||||
return ingredients.get(0).test(inv.getStackInSlot(0));
|
||||
|
|
|
@ -129,7 +129,7 @@ public class SawBlock extends DirectionalAxisKineticBlock implements IWithTileEn
|
|||
|
||||
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
||||
withTileEntityDo(worldIn, pos, te -> {
|
||||
for (int slot = 0; slot < te.inventory.getSizeInventory(); slot++) {
|
||||
for (int slot = 0; slot < te.inventory.getSlots(); slot++) {
|
||||
InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(),
|
||||
te.inventory.getStackInSlot(slot));
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.components.saw;
|
|||
|
||||
import static com.simibubi.create.modules.contraptions.components.saw.SawBlock.RUNNING;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
@ -12,6 +13,7 @@ import com.simibubi.create.AllRecipes;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour;
|
||||
import com.simibubi.create.foundation.item.ItemHelper;
|
||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||
import com.simibubi.create.foundation.utility.TreeCutter;
|
||||
import com.simibubi.create.foundation.utility.TreeCutter.Tree;
|
||||
|
@ -37,7 +39,6 @@ import net.minecraft.particles.ParticleTypes;
|
|||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -57,7 +58,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
|
||||
public SawTileEntity() {
|
||||
super(AllTileEntities.SAW.type);
|
||||
inventory = new ProcessingInventory();
|
||||
inventory = new ProcessingInventory(this::start);
|
||||
inventory.remainingTime = -1;
|
||||
recipeIndex = 0;
|
||||
invProvider = LazyOptional.of(() -> inventory);
|
||||
|
@ -86,7 +87,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT compound) {
|
||||
inventory.write(compound);
|
||||
compound.put("Inventory", inventory.serializeNBT());
|
||||
compound.putInt("RecipeIndex", recipeIndex);
|
||||
return super.write(compound);
|
||||
}
|
||||
|
@ -94,7 +95,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
@Override
|
||||
public void read(CompoundNBT compound) {
|
||||
super.read(compound);
|
||||
inventory = ProcessingInventory.read(compound);
|
||||
inventory.deserializeNBT(compound.getCompound("Inventory"));
|
||||
recipeIndex = compound.getInt("RecipeIndex");
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
return;
|
||||
if (inventory.remainingTime == -1) {
|
||||
if (!inventory.isEmpty() && !inventory.appliedRecipe)
|
||||
start();
|
||||
start(inventory.getStackInSlot(0));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -142,15 +143,15 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
if (AllBlocks.BELT.typeOf(world.getBlockState(nextPos))) {
|
||||
TileEntity te = world.getTileEntity(nextPos);
|
||||
if (te != null && te instanceof BeltTileEntity) {
|
||||
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
|
||||
for (int slot = 0; slot < inventory.getSlots(); slot++) {
|
||||
ItemStack stack = inventory.getStackInSlot(slot);
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
|
||||
if (itemMovementFacing.getAxis() == Axis.Z)
|
||||
itemMovementFacing = itemMovementFacing.getOpposite();
|
||||
// if (itemMovementFacing.getAxis() == Axis.Z)
|
||||
// itemMovementFacing = itemMovementFacing.getOpposite();
|
||||
if (((BeltTileEntity) te).tryInsertingFromSide(itemMovementFacing, stack, false))
|
||||
inventory.setInventorySlotContents(slot, ItemStack.EMPTY);
|
||||
inventory.setStackInSlot(slot, ItemStack.EMPTY);
|
||||
else {
|
||||
inventory.remainingTime = 0;
|
||||
return;
|
||||
|
@ -170,7 +171,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
Vec3d otherMovement = sawTileEntity.getItemMovementVec();
|
||||
if (Direction.getFacingFromVector(otherMovement.x, otherMovement.y,
|
||||
otherMovement.z) != itemMovementFacing.getOpposite()) {
|
||||
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
|
||||
for (int slot = 0; slot < inventory.getSlots(); slot++) {
|
||||
ItemStack stack = inventory.getStackInSlot(slot);
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
|
@ -178,7 +179,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
ProcessingInventory sawInv = sawTileEntity.inventory;
|
||||
if (sawInv.isEmpty()) {
|
||||
sawInv.insertItem(0, stack, false);
|
||||
inventory.setInventorySlotContents(slot, ItemStack.EMPTY);
|
||||
inventory.setStackInSlot(slot, ItemStack.EMPTY);
|
||||
|
||||
} else {
|
||||
inventory.remainingTime = 0;
|
||||
|
@ -193,7 +194,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
}
|
||||
|
||||
// Eject Items
|
||||
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
|
||||
for (int slot = 0; slot < inventory.getSlots(); slot++) {
|
||||
ItemStack stack = inventory.getStackInSlot(slot);
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
|
@ -231,8 +232,8 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
IParticleData particleData = null;
|
||||
float speed = 1;
|
||||
if (stack.getItem() instanceof BlockItem)
|
||||
particleData = new BlockParticleData(ParticleTypes.BLOCK,
|
||||
((BlockItem) stack.getItem()).getBlock().getDefaultState());
|
||||
particleData =
|
||||
new BlockParticleData(ParticleTypes.BLOCK, ((BlockItem) stack.getItem()).getBlock().getDefaultState());
|
||||
else {
|
||||
particleData = new ItemParticleData(ParticleTypes.ITEM, stack);
|
||||
speed = .125f;
|
||||
|
@ -265,6 +266,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
int rolls = inventory.getStackInSlot(0).getCount();
|
||||
inventory.clear();
|
||||
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
for (int roll = 0; roll < rolls; roll++) {
|
||||
List<ItemStack> results = new LinkedList<ItemStack>();
|
||||
if (recipe instanceof CuttingRecipe)
|
||||
|
@ -274,15 +276,11 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
ItemStack stack = results.get(i);
|
||||
|
||||
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
|
||||
stack = inventory.getItems().insertItem(slot, stack, false);
|
||||
|
||||
if (stack.isEmpty())
|
||||
break;
|
||||
}
|
||||
ItemHelper.addToList(stack, list);
|
||||
}
|
||||
}
|
||||
for (int slot = 0; slot < list.size() && slot + 1 < inventory.getSlots(); slot++)
|
||||
inventory.setStackInSlot(slot + 1, list.get(slot));
|
||||
|
||||
}
|
||||
|
||||
|
@ -303,12 +301,11 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
return;
|
||||
|
||||
inventory.clear();
|
||||
inventory.setInventorySlotContents(0, entity.getItem().copy());
|
||||
inventory.insertItem(0, entity.getItem().copy(), false);
|
||||
entity.remove();
|
||||
start();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
public void start(ItemStack inserted) {
|
||||
if (!canProcess())
|
||||
return;
|
||||
if (inventory.isEmpty())
|
||||
|
@ -338,7 +335,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
|||
time = ((CuttingRecipe) recipe).getProcessingDuration();
|
||||
}
|
||||
|
||||
inventory.remainingTime = time * Math.max(1, (inventory.getStackInSlot(0).getCount() / 5));
|
||||
inventory.remainingTime = time * Math.max(1, (inserted.getCount() / 5));
|
||||
inventory.recipeDuration = inventory.remainingTime;
|
||||
inventory.appliedRecipe = false;
|
||||
sendData();
|
||||
|
|
|
@ -85,8 +85,8 @@ public class BasinTileEntity extends SyncedTileEntity implements ITickableTileEn
|
|||
|
||||
}
|
||||
|
||||
protected LazyOptional<IItemHandlerModifiable> inventory = LazyOptional
|
||||
.of(() -> new BasinInventory(inputInventory, outputInventory));
|
||||
protected LazyOptional<IItemHandlerModifiable> inventory =
|
||||
LazyOptional.of(() -> new BasinInventory(inputInventory, outputInventory));
|
||||
public BasinInputInventory recipeInventory;
|
||||
|
||||
public BasinTileEntity() {
|
||||
|
|
|
@ -1,75 +1,60 @@
|
|||
package com.simibubi.create.modules.contraptions.processing;
|
||||
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
|
||||
public class ProcessingInventory extends RecipeWrapper implements IItemHandler {
|
||||
public class ProcessingInventory extends ItemStackHandler {
|
||||
public float remainingTime;
|
||||
public float recipeDuration;
|
||||
public boolean appliedRecipe;
|
||||
public Consumer<ItemStack> callback;
|
||||
|
||||
public ProcessingInventory() {
|
||||
super(new ItemStackHandler(10));
|
||||
public ProcessingInventory(Consumer<ItemStack> callback) {
|
||||
super(10);
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
for (int i = 0; i < getSlots(); i++)
|
||||
setStackInSlot(i, ItemStack.EMPTY);
|
||||
remainingTime = 0;
|
||||
recipeDuration = 0;
|
||||
appliedRecipe = false;
|
||||
}
|
||||
|
||||
public void write(CompoundNBT nbt) {
|
||||
NonNullList<ItemStack> stacks = NonNullList.create();
|
||||
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
||||
ItemStack stack = inv.getStackInSlot(slot);
|
||||
stacks.add(stack);
|
||||
}
|
||||
ItemStackHelper.saveAllItems(nbt, stacks);
|
||||
nbt.putFloat("ProcessingTime", remainingTime);
|
||||
nbt.putFloat("RecipeTime", recipeDuration);
|
||||
nbt.putBoolean("AppliedRecipe", appliedRecipe);
|
||||
}
|
||||
|
||||
public static ProcessingInventory read(CompoundNBT nbt) {
|
||||
ProcessingInventory inventory = new ProcessingInventory();
|
||||
NonNullList<ItemStack> stacks = NonNullList.withSize(10, ItemStack.EMPTY);
|
||||
ItemStackHelper.loadAllItems(nbt, stacks);
|
||||
|
||||
for (int slot = 0; slot < stacks.size(); slot++)
|
||||
inventory.setInventorySlotContents(slot, stacks.get(slot));
|
||||
inventory.remainingTime = nbt.getFloat("ProcessingTime");
|
||||
inventory.recipeDuration = nbt.getFloat("RecipeTime");
|
||||
inventory.appliedRecipe = nbt.getBoolean("AppliedRecipe");
|
||||
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
public ItemStackHandler getItems() {
|
||||
return (ItemStackHandler) inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return 9;
|
||||
public boolean isEmpty() {
|
||||
for (int i = 0; i < getSlots(); i++)
|
||||
if (!getStackInSlot(i).isEmpty())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||
if (!isItemValid(slot, stack))
|
||||
return stack;
|
||||
return inv.insertItem(slot, stack, simulate);
|
||||
ItemStack insertItem = super.insertItem(slot, stack, simulate);
|
||||
if (slot == 0 && !insertItem.equals(stack, true))
|
||||
callback.accept(insertItem.copy());
|
||||
return insertItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serializeNBT() {
|
||||
CompoundNBT nbt = super.serializeNBT();
|
||||
nbt.putFloat("ProcessingTime", remainingTime);
|
||||
nbt.putFloat("RecipeTime", recipeDuration);
|
||||
nbt.putBoolean("AppliedRecipe", appliedRecipe);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundNBT nbt) {
|
||||
remainingTime = nbt.getFloat("ProcessingTime");
|
||||
recipeDuration = nbt.getFloat("RecipeTime");
|
||||
appliedRecipe = nbt.getBoolean("AppliedRecipe");
|
||||
super.deserializeNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,11 +62,6 @@ public class ProcessingInventory extends RecipeWrapper implements IItemHandler {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, ItemStack stack) {
|
||||
return slot == 0 && isEmpty();
|
||||
|
|
|
@ -201,7 +201,8 @@ public class BeltInventory {
|
|||
BlockState state = world.getBlockState(nextPosition);
|
||||
|
||||
// next block is a basin or a saw
|
||||
if (AllBlocks.BASIN.typeOf(state) || AllBlocks.SAW.typeOf(state)) {
|
||||
if (AllBlocks.BASIN.typeOf(state) || AllBlocks.SAW.typeOf(state)
|
||||
|| AllBlocks.CRUSHING_WHEEL_CONTROLLER.typeOf(state)) {
|
||||
TileEntity te = world.getTileEntity(nextPosition);
|
||||
if (te != null) {
|
||||
LazyOptional<IItemHandler> optional =
|
||||
|
|
|
@ -122,7 +122,7 @@ public class BeltTileEntity extends KineticTileEntity {
|
|||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
if (!isController())
|
||||
return super.getRenderBoundingBox();
|
||||
return super.getRenderBoundingBox().grow(beltLength);
|
||||
return super.getRenderBoundingBox().grow(beltLength + 1);
|
||||
}
|
||||
|
||||
protected void initializeItemHandler() {
|
||||
|
|
Loading…
Reference in a new issue