mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-03-18 21:40:34 +01:00
Proper create impl pt 1
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
package com.ticticboooom.mods.mm.block;
|
||||
|
||||
import com.ticticboooom.mods.mm.block.tile.ControllerBlockEntity;
|
||||
import com.ticticboooom.mods.mm.model.ModelOverrideModel;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
@@ -17,10 +15,6 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.IBooleanFunction;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
@@ -28,16 +22,15 @@ import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ControllerBlock extends DirectionalBlock {
|
||||
private RegistryObject<TileEntityType<?>> type;
|
||||
private final RegistryObject<TileEntityType<?>> type;
|
||||
@Getter
|
||||
private String controllerName;
|
||||
private final String controllerName;
|
||||
@Getter
|
||||
private String controllerId;
|
||||
private final String controllerId;
|
||||
@Getter
|
||||
private String texOverride;
|
||||
private final String texOverride;
|
||||
|
||||
public ControllerBlock(RegistryObject<TileEntityType<?>> type, String name, String id, String texOverride) {
|
||||
super(AbstractBlock.Properties.create(Material.IRON).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestLevel(0)
|
||||
@@ -82,5 +75,16 @@ public class ControllerBlock extends DirectionalBlock {
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (!worldIn.isRemote()) {
|
||||
TileEntity blockEntity = worldIn.getTileEntity(pos);
|
||||
if (blockEntity instanceof ControllerBlockEntity) {
|
||||
// Send an update to ports notifying that the current recipe was interrupted
|
||||
ControllerBlockEntity controller = (ControllerBlockEntity) blockEntity;
|
||||
controller.invalidateRecipe();
|
||||
}
|
||||
}
|
||||
super.onReplaced(state, worldIn, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ import java.util.List;
|
||||
public class ControllerBlockEntity extends UpdatableTile implements ITickableTileEntity, INamedContainerProvider {
|
||||
|
||||
|
||||
private RegistryObject<ContainerType<ControllerBlockContainer>> container;
|
||||
private String controllerId;
|
||||
private final RegistryObject<ContainerType<ControllerBlockContainer>> container;
|
||||
private final String controllerId;
|
||||
@Getter
|
||||
private ProcessUpdate update = new ProcessUpdate(0, "", "", "", new ArrayList<>());
|
||||
private ProcessUpdate processData = new ProcessUpdate();
|
||||
|
||||
public ControllerBlockEntity(RegistryObject<TileEntityType<?>> type, RegistryObject<ContainerType<ControllerBlockContainer>> container, String controllerId) {
|
||||
super(type.get());
|
||||
@@ -46,62 +46,94 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
|
||||
return;
|
||||
}
|
||||
|
||||
update.setMsg("Failed to construct \nthe machine");
|
||||
processData.setMsg("Failed to construct \nthe machine");
|
||||
List<MachineStructureRecipe> structures = world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
|
||||
// TODO Maybe check if our structure is still matching before finding a new structure?
|
||||
boolean foundStructure = false;
|
||||
for (MachineStructureRecipe structure : structures) {
|
||||
int index = structure.matches(this.pos, world, controllerId);
|
||||
if (index != -1) {
|
||||
if (!update.getSid().equals(structure.getId().toString())) {
|
||||
update.setTicksTaken(0);
|
||||
if (!structure.equals(processData.getStructureDefinition().getStructure())) {
|
||||
processData.setTicksTaken(0);
|
||||
}
|
||||
update.setSid(structure.getId().toString());
|
||||
update.setMsg("Found structure");
|
||||
processData.getStructureDefinition().setStructure(structure);
|
||||
processData.setMsg("Found structure");
|
||||
onStructureFound(structure, index);
|
||||
foundStructure = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
update();
|
||||
|
||||
if (!foundStructure) {
|
||||
invalidateRecipe();
|
||||
processData.getStructureDefinition().setStructure(null);
|
||||
processData.setRecipe(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void onStructureFound(MachineStructureRecipe structure, int index) {
|
||||
ArrayList<BlockPos> ports = structure.getPorts(pos, world, index);
|
||||
ArrayList<BlockPos> portPoses = structure.getPorts(pos, world, index);
|
||||
List<PortStorage> inputPorts = new ArrayList<>();
|
||||
List<PortStorage> outputPorts = new ArrayList<>();
|
||||
for (BlockPos port : ports) {
|
||||
TileEntity blockEntity = world.getTileEntity(port);
|
||||
for (BlockPos pos : portPoses) {
|
||||
TileEntity blockEntity = world.getTileEntity(pos);
|
||||
if (blockEntity instanceof IMachinePortTile) {
|
||||
IMachinePortTile portBE = (IMachinePortTile) blockEntity;
|
||||
IMachinePortTile port = (IMachinePortTile) blockEntity;
|
||||
|
||||
if (portBE.isInput()) {
|
||||
inputPorts.add(portBE.getStorage());
|
||||
if (port.isInput()) {
|
||||
inputPorts.add(port.getStorage());
|
||||
} else {
|
||||
outputPorts.add(portBE.getStorage());
|
||||
outputPorts.add(port.getStorage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processData.getStructureDefinition().setInputPorts(inputPorts);
|
||||
processData.getStructureDefinition().setOutputPorts(outputPorts);
|
||||
onPortsEstablished(inputPorts, outputPorts, structure);
|
||||
}
|
||||
|
||||
private void onPortsEstablished(List<PortStorage> inputPorts, List<PortStorage> outputPorts, MachineStructureRecipe structure) {
|
||||
List<MachineProcessRecipe> processRecipes = world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_PROCESS);
|
||||
boolean processed = false;
|
||||
for (MachineProcessRecipe recipe : processRecipes) {
|
||||
if (recipe.matches(inputPorts, structure.getStructureId(), update)) {
|
||||
if (!update.getId().equals(recipe.getId().toString())) {
|
||||
update.setTicksTaken(0);
|
||||
// Maybe instead of checking all recipe again first check if our current recipe is still valid?
|
||||
if (processData.getRecipe() != null && processData.getRecipe().matches(inputPorts, structure.getStructureId(), processData)) {
|
||||
processData.getRecipe().process(inputPorts, outputPorts, processData);
|
||||
processed = true;
|
||||
}
|
||||
|
||||
if (!processed) {
|
||||
// If we havent processed the previous recipe that means it needs to be invalidated
|
||||
invalidateRecipe();
|
||||
for (MachineProcessRecipe recipe : processRecipes) {
|
||||
if (recipe.matches(inputPorts, structure.getStructureId(), processData)) {
|
||||
// TODO Make sure the recipe doesn't stop progress when some inputs aren't present
|
||||
if (!recipe.equals(processData.getRecipe())) {
|
||||
if (processData.getRecipe() != null){
|
||||
processData.getRecipe().onInterrupted(inputPorts, outputPorts);
|
||||
}
|
||||
processData.setTicksTaken(0);
|
||||
}
|
||||
processData.setRecipe(recipe);
|
||||
recipe.process(inputPorts, outputPorts, processData);
|
||||
processed = true;
|
||||
break;
|
||||
}
|
||||
this.update.setId(recipe.getId().toString());
|
||||
this.update = recipe.process(inputPorts, outputPorts, this.update);
|
||||
processed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!processed) {
|
||||
this.update.setTicksTaken(0);
|
||||
this.processData.setRecipe(null);
|
||||
this.processData.setTicksTaken(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void invalidateRecipe() {
|
||||
if (processData.getStructureDefinition().getStructure() != null && processData.getRecipe() != null) {
|
||||
processData.getRecipe().onInterrupted(processData.getStructureDefinition().getInputPorts(), processData.getStructureDefinition().getOutputPorts());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
@@ -116,15 +148,15 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT nbt) {
|
||||
nbt.putInt("ticks", update.getTicksTaken());
|
||||
nbt.putString("msg", update.getMsg());
|
||||
nbt.putInt("ticks", processData.getTicksTaken());
|
||||
nbt.putString("msg", processData.getMsg());
|
||||
return super.write(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(BlockState p_230337_1_, CompoundNBT nbt) {
|
||||
super.read(p_230337_1_, nbt);
|
||||
update.setTicksTaken(nbt.getInt("ticks"));
|
||||
update.setMsg(nbt.getString("msg"));
|
||||
processData.setTicksTaken(nbt.getInt("ticks"));
|
||||
processData.setMsg(nbt.getString("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,8 @@ import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
public interface IMachinePortTile extends INamedContainerProvider {
|
||||
PortStorage getStorage();
|
||||
boolean isInput();
|
||||
|
||||
default <T> T getTile() {
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.ticticboooom.mods.mm.block.tile;
|
||||
|
||||
import com.simibubi.create.content.contraptions.KineticNetwork;
|
||||
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
|
||||
import com.ticticboooom.mods.mm.network.PacketHandler;
|
||||
import com.ticticboooom.mods.mm.network.packets.TileClientUpdatePacket;
|
||||
@@ -15,7 +14,6 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
@@ -23,12 +21,12 @@ import net.minecraftforge.fml.network.PacketDistributor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class RotationGenMachinePortBlockEntity extends GeneratingKineticTileEntity implements IMachinePortTile, ITickableTileEntity {
|
||||
public class RotationGenMachinePortBlockEntity extends GeneratingKineticTileEntity implements IMachinePortTile {
|
||||
private final ContainerType<?> container;
|
||||
@Getter
|
||||
private final PortStorage storage;
|
||||
@Getter
|
||||
private boolean input;
|
||||
private final boolean input;
|
||||
|
||||
public RotationGenMachinePortBlockEntity(TileEntityType<?> typeIn, ContainerType<?> container, PortStorage storage, boolean input) {
|
||||
super(typeIn);
|
||||
@@ -38,7 +36,6 @@ public class RotationGenMachinePortBlockEntity extends GeneratingKineticTileEnti
|
||||
if (input) {
|
||||
this.stress = ((RotationPortStorage) storage).getStress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,26 +54,6 @@ public class RotationGenMachinePortBlockEntity extends GeneratingKineticTileEnti
|
||||
this.reActivateSource = true;
|
||||
super.tick();
|
||||
this.storage.tick(this);
|
||||
// if (storage instanceof RotationPortStorage) {
|
||||
// RotationPortStorage stor = (RotationPortStorage) this.storage;
|
||||
// float prev = this.speed;
|
||||
// float speed = stor.getSpeed();
|
||||
// if (speed != prev) {
|
||||
// if (!hasSource()) {
|
||||
// effects.queueRotationIndicators();
|
||||
// }
|
||||
// applyNewSpeed(prev, speed);
|
||||
// }
|
||||
// if (hasNetwork() && speed != 0) {
|
||||
// KineticNetwork network = getOrCreateNetwork();
|
||||
// notifyStressCapacityChange(calculateAddedStressCapacity());
|
||||
// getOrCreateNetwork().updateCapacityFor(this, calculateStressApplied());
|
||||
// network.updateStress();
|
||||
// }
|
||||
//
|
||||
// onSpeedChanged(prev);
|
||||
// sendData();
|
||||
// }
|
||||
|
||||
if (!world.isRemote()) {
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new TileClientUpdatePacket.Data(pos, write(new CompoundNBT())));
|
||||
@@ -86,6 +63,7 @@ public class RotationGenMachinePortBlockEntity extends GeneratingKineticTileEnti
|
||||
@Override
|
||||
protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
|
||||
this.storage.load(compound.getCompound("inv"));
|
||||
super.fromTag(state, compound, clientPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,6 +72,17 @@ public class RotationGenMachinePortBlockEntity extends GeneratingKineticTileEnti
|
||||
super.write(compound, clientPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calculateAddedStressCapacity() {
|
||||
float stress = 0;
|
||||
if (!input && storage instanceof RotationPortStorage) {
|
||||
RotationPortStorage stor = (RotationPortStorage) this.storage;
|
||||
stress = stor.getStress();
|
||||
}
|
||||
|
||||
lastCapacityProvided = stress;
|
||||
return stress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneratedSpeed() {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.ticticboooom.mods.mm.block.tile;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.contraptions.KineticNetwork;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
|
||||
import com.ticticboooom.mods.mm.network.PacketHandler;
|
||||
@@ -38,7 +36,6 @@ public class RotationMachinePortBlockEntity extends KineticTileEntity implements
|
||||
if (input) {
|
||||
this.stress = ((RotationPortStorage) storage).getStress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,24 +52,39 @@ public class RotationMachinePortBlockEntity extends KineticTileEntity implements
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
this.storage.tick(this);
|
||||
|
||||
if (this.world.isRemote) {
|
||||
/*if (this.world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (storage instanceof RotationPortStorage) {
|
||||
RotationPortStorage storage = (RotationPortStorage) this.storage;
|
||||
if (input) {
|
||||
storage.setSpeed(Math.abs(getSpeed()));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (!world.isRemote()) {
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new TileClientUpdatePacket.Data(pos, write(new CompoundNBT())));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calculateStressApplied() {
|
||||
float stress = 0;
|
||||
if (input && storage instanceof RotationPortStorage) {
|
||||
RotationPortStorage stor = (RotationPortStorage) this.storage;
|
||||
stress = stor.getStress();
|
||||
}
|
||||
|
||||
this.lastStressApplied = stress;
|
||||
return stress;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
|
||||
this.storage.load(compound.getCompound("inv"));
|
||||
super.fromTag(state, compound, clientPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.ticticboooom.mods.mm.client.screen;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.block.container.ControllerBlockContainer;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -31,7 +30,7 @@ public class ControllerBlockContainerScreen extends ContainerScreen<ControllerBl
|
||||
this.minecraft.fontRenderer.func_238418_a_(container.getTile().getDisplayName(), 10, -10, 176, 0xfefefe);
|
||||
drawString(stack, this.minecraft.fontRenderer, "Inventory", 7, 110, 0xfefefe);
|
||||
int y = 50;
|
||||
for (String s : container.getTile().getUpdate().getMsg().split("\n")) {
|
||||
for (String s : container.getTile().getProcessData().getMsg().split("\n")) {
|
||||
drawString(stack, this.minecraft.fontRenderer, s, 12, y, 0xfefefe);
|
||||
y += 12;
|
||||
}
|
||||
|
||||
@@ -30,20 +30,19 @@ import java.util.Random;
|
||||
|
||||
public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
|
||||
|
||||
@Getter
|
||||
private final List<PortState> inputs;
|
||||
@Getter
|
||||
private final List<PortState> outputs;
|
||||
@Getter
|
||||
private int ticks;
|
||||
private final int ticks;
|
||||
@Getter
|
||||
private String structureId;
|
||||
private ResourceLocation rl;
|
||||
private final String structureId;
|
||||
private final ResourceLocation rl;
|
||||
|
||||
private List<Double> inputRolls = new ArrayList<>();
|
||||
private List<Double> outputRolls = new ArrayList<>();
|
||||
private Random rand = new Random();
|
||||
private final List<Double> inputRolls = new ArrayList<>();
|
||||
private final List<Double> outputRolls = new ArrayList<>();
|
||||
private final Random rand = new Random();
|
||||
|
||||
public MachineProcessRecipe(List<PortState> inputs, List<PortState> outputs, int ticks, String structureId, ResourceLocation rl) {
|
||||
this.inputs = inputs;
|
||||
@@ -101,17 +100,18 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
}
|
||||
}
|
||||
|
||||
public ProcessUpdate process(List<PortStorage> inputPorts, List<PortStorage> outputPorts, ProcessUpdate update) {
|
||||
public void process(List<PortStorage> inputPorts, List<PortStorage> outputPorts, ProcessUpdate update) {
|
||||
resetChances();
|
||||
boolean canTake = canTake(inputPorts, update.getTakenIndices());
|
||||
boolean canPut = canPut(outputPorts);
|
||||
|
||||
if (!canTake || !canPut) {
|
||||
update.setMsg("Found Structure");
|
||||
return update;
|
||||
return;
|
||||
}
|
||||
|
||||
int takenIndex = 0;
|
||||
// Update instantly consumed inputs when recipe starts
|
||||
if (update.getTicksTaken() <= 0) {
|
||||
for (PortState input : inputs) {
|
||||
if (input.isInstantConsume() && input.validateRequirement(inputPorts)) {
|
||||
@@ -123,9 +123,11 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
// When the recipe has finished
|
||||
if (update.getTicksTaken() >= ticks) {
|
||||
update.getTakenIndices().clear();
|
||||
for (PortState input : inputs) {
|
||||
// Don't consume when recipe is finished if the input is consumePerTick or consumeInstant
|
||||
if (input.isConsumePerTick() || input.isInstantConsume()) {
|
||||
continue;
|
||||
}
|
||||
@@ -136,6 +138,7 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
}
|
||||
index = 0;
|
||||
for (PortState output : outputs) {
|
||||
// Don't produce output when recipe is finished if the output is consumePerTick
|
||||
if (output.isConsumePerTick()) {
|
||||
continue;
|
||||
}
|
||||
@@ -145,13 +148,12 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
}
|
||||
update.setMsg("");
|
||||
update.setTicksTaken(0);
|
||||
update.setTakenIndices(new ArrayList<>());
|
||||
return update;
|
||||
update.getTakenIndices().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean canTick = true;
|
||||
|
||||
|
||||
index = 0;
|
||||
for (PortState input : inputs) {
|
||||
if (input.isConsumePerTick()) {
|
||||
@@ -191,7 +193,7 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
update.setTicksTaken(update.getTicksTaken() + 1);
|
||||
}
|
||||
update.setMsg((int) (((float) update.getTicksTaken() / (float) ticks) * 100) + "%");
|
||||
return update;
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,6 +231,16 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
return RecipeTypes.MACHINE_PROCESS;
|
||||
}
|
||||
|
||||
public void onInterrupted(List<PortStorage> inputPorts, List<PortStorage> outputPorts) {
|
||||
for (PortStorage port : inputPorts) {
|
||||
port.onRecipeInterrupted(this);
|
||||
}
|
||||
|
||||
for (PortStorage port : outputPorts) {
|
||||
port.onRecipeInterrupted(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Serializer implements IRecipeSerializer<MachineProcessRecipe> {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
package com.ticticboooom.mods.mm.model;
|
||||
|
||||
import com.ticticboooom.mods.mm.data.MachineProcessRecipe;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class ProcessUpdate {
|
||||
private int ticksTaken;
|
||||
private String msg;
|
||||
private String id;
|
||||
private String sid;
|
||||
private List<Integer> takenIndices;
|
||||
private String msg = "";
|
||||
private MachineProcessRecipe recipe;
|
||||
private WorldStructureDefinition structureDefinition = new WorldStructureDefinition();
|
||||
private List<Integer> takenIndices = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ticticboooom.mods.mm.model;
|
||||
|
||||
import com.ticticboooom.mods.mm.data.MachineStructureRecipe;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class WorldStructureDefinition {
|
||||
private MachineStructureRecipe structure;
|
||||
private List<PortStorage> inputPorts;
|
||||
private List<PortStorage> outputPorts;
|
||||
}
|
||||
@@ -27,8 +27,8 @@ public class RotationPortState extends PortState {
|
||||
|
||||
private float speed;
|
||||
|
||||
public RotationPortState(float pressure) {
|
||||
this.speed = pressure;
|
||||
public RotationPortState(float speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,7 +41,7 @@ public class RotationPortState extends PortState {
|
||||
for (PortStorage portStorage : storage) {
|
||||
if (portStorage instanceof RotationPortStorage){
|
||||
RotationPortStorage rot = (RotationPortStorage) portStorage;
|
||||
if (rot.getSpeed() >= speed) {
|
||||
if (!rot.isOverStressed() && rot.getSpeed() >= speed) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
|
||||
import com.ticticboooom.mods.mm.block.tile.IMachinePortTile;
|
||||
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
|
||||
import com.ticticboooom.mods.mm.data.MachineProcessRecipe;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
@@ -50,4 +51,8 @@ public abstract class PortStorage {
|
||||
public boolean onPortActivated(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onRecipeInterrupted(MachineProcessRecipe recipe) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +1,25 @@
|
||||
package com.ticticboooom.mods.mm.ports.storage;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.contraptions.KineticNetwork;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.block.tile.IMachinePortTile;
|
||||
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
|
||||
import com.ticticboooom.mods.mm.block.tile.RotationMachinePortBlockEntity;
|
||||
import com.ticticboooom.mods.mm.data.MachineProcessRecipe;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.desht.pneumaticcraft.api.PNCCapabilities;
|
||||
import me.desht.pneumaticcraft.api.tileentity.IAirHandlerMachine;
|
||||
import me.desht.pneumaticcraft.common.capabilities.MachineAirHandler;
|
||||
import me.desht.pneumaticcraft.common.util.DirectionUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RotationPortStorage extends PortStorage {
|
||||
public static final Codec<RotationPortStorage> CODEC = RecordCodecBuilder.create(x -> x.group(
|
||||
@@ -42,11 +29,13 @@ public class RotationPortStorage extends PortStorage {
|
||||
@Setter
|
||||
private float speed;
|
||||
|
||||
@Getter
|
||||
private boolean isOverStressed;
|
||||
|
||||
@Getter
|
||||
private int stress;
|
||||
|
||||
public RotationPortStorage(int stress) {
|
||||
|
||||
this.stress = stress;
|
||||
}
|
||||
|
||||
@@ -84,6 +73,13 @@ public class RotationPortStorage extends PortStorage {
|
||||
|
||||
@Override
|
||||
public void tick(IMachinePortTile tile) {
|
||||
KineticTileEntity kinetic = tile.getTile();
|
||||
this.isOverStressed = kinetic.isOverStressed();
|
||||
this.speed = Math.abs(kinetic.getSpeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipeInterrupted(MachineProcessRecipe recipe) {
|
||||
this.speed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
"layout": [
|
||||
[
|
||||
"1C2"
|
||||
],
|
||||
[
|
||||
" T "
|
||||
]
|
||||
],
|
||||
"legend": {
|
||||
@@ -17,9 +14,6 @@
|
||||
},
|
||||
"2": {
|
||||
"block": "masterfulmachinery:basic_simple_port_create_rotation_output"
|
||||
},
|
||||
"T": {
|
||||
"block": "create:deployer"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "masterfulmachinery:machine_process",
|
||||
"structureId": "test_rotation",
|
||||
"controllerId": "basic",
|
||||
"ticks": 200,
|
||||
"ticks": 60,
|
||||
"inputs": [
|
||||
{
|
||||
"type": "masterfulmachinery:create_rotation",
|
||||
@@ -16,7 +16,8 @@
|
||||
{
|
||||
"type": "masterfulmachinery:create_rotation",
|
||||
"data": {
|
||||
"speed": 64
|
||||
"capacity": 256,
|
||||
"speed": 24
|
||||
},
|
||||
"perTick": true
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#Sun Nov 28 19:05:29 GMT 2021
|
||||
VERSION_CODE=866
|
||||
#Sun Dec 12 21:28:07 GMT 2021
|
||||
VERSION_CODE=883
|
||||
|
||||
Reference in New Issue
Block a user