-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: laser cables * fix: remove laser recipe capability, recipes * fix: add 16A dynamo hatch recipes. * remove todo * fix: steam machines only allow GT steam to be inserted. * reviews
- Loading branch information
Showing
73 changed files
with
1,694 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
common/src/main/java/com/gregtechceu/gtceu/api/capability/ILaserContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.gregtechceu.gtceu.api.capability; | ||
|
||
/** | ||
* It is its own separate interface to make piping work easier | ||
*/ | ||
public interface ILaserContainer extends IEnergyContainer { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
common/src/main/java/com/gregtechceu/gtceu/api/item/LaserPipeBlockItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.gregtechceu.gtceu.api.item; | ||
|
||
import com.gregtechceu.gtceu.api.block.PipeBlock; | ||
import com.gregtechceu.gtceu.common.block.LaserPipeBlock; | ||
import com.lowdragmc.lowdraglib.client.renderer.IItemRendererProvider; | ||
import com.lowdragmc.lowdraglib.client.renderer.IRenderer; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.color.item.ItemColor; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class LaserPipeBlockItem extends PipeBlockItem implements IItemRendererProvider { | ||
|
||
public LaserPipeBlockItem(PipeBlock block, Properties properties) { | ||
super(block, properties); | ||
} | ||
|
||
@Override | ||
public LaserPipeBlock getBlock() { | ||
return (LaserPipeBlock) super.getBlock(); | ||
} | ||
|
||
@Environment(EnvType.CLIENT) | ||
public static ItemColor tintColor() { | ||
return (itemStack, index) -> { | ||
if (itemStack.getItem() instanceof LaserPipeBlockItem materialBlockItem) { | ||
return materialBlockItem.getBlock().tinted(materialBlockItem.getBlock().defaultBlockState(), null, null, index); | ||
} | ||
return -1; | ||
}; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
@Environment(EnvType.CLIENT) | ||
public IRenderer getRenderer(ItemStack stack) { | ||
return getBlock().getRenderer(getBlock().defaultBlockState()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableLaserContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.gregtechceu.gtceu.api.machine.trait; | ||
|
||
import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; | ||
import com.gregtechceu.gtceu.api.capability.ILaserContainer; | ||
import com.gregtechceu.gtceu.api.machine.MetaMachine; | ||
import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
|
||
public class NotifiableLaserContainer extends NotifiableEnergyContainer implements ILaserContainer { | ||
|
||
public static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(NotifiableEnergyContainer.class, NotifiableRecipeHandlerTrait.MANAGED_FIELD_HOLDER); | ||
|
||
public NotifiableLaserContainer(MetaMachine machine, long maxCapacity, long maxInputVoltage, long maxInputAmperage, long maxOutputVoltage, long maxOutputAmperage) { | ||
super(machine, maxCapacity, maxInputVoltage, maxInputAmperage, maxOutputVoltage, maxOutputAmperage); | ||
} | ||
|
||
public static NotifiableLaserContainer emitterContainer(MetaMachine machine, long maxCapacity, long maxOutputVoltage, long maxOutputAmperage) { | ||
return new NotifiableLaserContainer(machine, maxCapacity, 0L, 0L, maxOutputVoltage, maxOutputAmperage); | ||
} | ||
|
||
public static NotifiableLaserContainer receiverContainer(MetaMachine machine, long maxCapacity, long maxInputVoltage, long maxInputAmperage) { | ||
return new NotifiableLaserContainer(machine, maxCapacity, maxInputVoltage, maxInputAmperage, 0L, 0L); | ||
} | ||
|
||
@Override | ||
public void serverTick() { | ||
amps = 0; | ||
if (getMachine().getLevel().isClientSide) | ||
return; | ||
if (getEnergyStored() < getOutputVoltage() || getOutputVoltage() <= 0 || getOutputAmperage() <= 0) | ||
return; | ||
long outputVoltage = getOutputVoltage(); | ||
long outputAmperes = Math.min(getEnergyStored() / outputVoltage, getOutputAmperage()); | ||
if (outputAmperes == 0) return; | ||
long amperesUsed = 0; | ||
for (Direction side : Direction.values()) { | ||
if (!outputsEnergy(side)) continue; | ||
BlockEntity tileEntity = getMachine().getLevel().getBlockEntity(getMachine().getPos().relative(side)); | ||
Direction oppositeSide = side.getOpposite(); | ||
ILaserContainer laserContainer = GTCapabilityHelper.getLaser(getMachine().getLevel(), getMachine().getPos().relative(side), oppositeSide); | ||
if (tileEntity != null && laserContainer != null) { | ||
if (laserContainer == null || !laserContainer.inputsEnergy(oppositeSide)) continue; | ||
amperesUsed += laserContainer.acceptEnergyFromNetwork(oppositeSide, outputVoltage, outputAmperes - amperesUsed); | ||
if (amperesUsed == outputAmperes) break; | ||
} | ||
} | ||
if (amperesUsed > 0) { | ||
setEnergyStored(getEnergyStored() - amperesUsed * outputVoltage); | ||
} | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
common/src/main/java/com/gregtechceu/gtceu/api/misc/LaserContainerList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.gregtechceu.gtceu.api.misc; | ||
|
||
import com.gregtechceu.gtceu.api.capability.IEnergyContainer; | ||
import com.gregtechceu.gtceu.api.capability.ILaserContainer; | ||
import net.minecraft.core.Direction; | ||
|
||
import java.util.List; | ||
|
||
public class LaserContainerList implements ILaserContainer { | ||
|
||
private final List<? extends ILaserContainer> energyContainerList; | ||
|
||
public LaserContainerList(List<? extends ILaserContainer> energyContainerList) { | ||
this.energyContainerList = energyContainerList; | ||
} | ||
|
||
@Override | ||
public long acceptEnergyFromNetwork(Direction side, long voltage, long amperage) { | ||
long amperesUsed = 0L; | ||
List<? extends ILaserContainer> energyContainerList = this.energyContainerList; | ||
for (ILaserContainer iEnergyContainer : energyContainerList) { | ||
amperesUsed += iEnergyContainer.acceptEnergyFromNetwork(null, voltage, amperage); | ||
if (amperage == amperesUsed) { | ||
return amperesUsed; | ||
} | ||
} | ||
return amperesUsed; | ||
} | ||
|
||
@Override | ||
public long changeEnergy(long energyToAdd) { | ||
long energyAdded = 0L; | ||
List<? extends ILaserContainer> energyContainerList = this.energyContainerList; | ||
for (ILaserContainer iEnergyContainer : energyContainerList) { | ||
energyAdded += iEnergyContainer.changeEnergy(energyToAdd - energyAdded); | ||
if (energyAdded == energyToAdd) { | ||
return energyAdded; | ||
} | ||
} | ||
return energyAdded; | ||
} | ||
|
||
@Override | ||
public long getEnergyStored() { | ||
long energyStored = 0L; | ||
for (ILaserContainer iEnergyContainer : energyContainerList) { | ||
energyStored += iEnergyContainer.getEnergyStored(); | ||
} | ||
return energyStored; | ||
} | ||
|
||
@Override | ||
public long getEnergyCapacity() { | ||
long energyCapacity = 0L; | ||
for (ILaserContainer iEnergyContainer : energyContainerList) { | ||
energyCapacity += iEnergyContainer.getEnergyCapacity(); | ||
} | ||
return energyCapacity; | ||
} | ||
|
||
@Override | ||
public long getInputAmperage() { | ||
return 1L; | ||
} | ||
|
||
@Override | ||
public long getOutputAmperage() { | ||
return 1L; | ||
} | ||
|
||
@Override | ||
public long getInputVoltage() { | ||
long inputVoltage = 0L; | ||
for (ILaserContainer container : energyContainerList) { | ||
inputVoltage += container.getInputVoltage() * container.getInputAmperage(); | ||
} | ||
return inputVoltage; | ||
} | ||
|
||
@Override | ||
public long getOutputVoltage() { | ||
long outputVoltage = 0L; | ||
for (ILaserContainer container : energyContainerList) { | ||
outputVoltage += container.getOutputVoltage() * container.getOutputAmperage(); | ||
} | ||
return outputVoltage; | ||
} | ||
|
||
@Override | ||
public boolean inputsEnergy(Direction side) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean outputsEnergy(Direction side) { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.