-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
187 additions
and
5 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
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
95 changes: 95 additions & 0 deletions
95
src/main/java/gregtech/common/covers/CoverEnergyWireless.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,95 @@ | ||
package gregtech.common.covers; | ||
|
||
import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; | ||
import static java.lang.Long.min; | ||
|
||
import java.util.UUID; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
|
||
import gregtech.api.interfaces.tileentity.ICoverable; | ||
import gregtech.api.interfaces.tileentity.IWirelessEnergyHatchInformation; | ||
import gregtech.api.metatileentity.BaseMetaTileEntity; | ||
import gregtech.api.util.CoverBehavior; | ||
import gregtech.api.util.ISerializableObject; | ||
|
||
public class CoverEnergyWireless extends CoverBehavior implements IWirelessEnergyHatchInformation { | ||
|
||
private final long transferred_energy_per_operation; | ||
|
||
public CoverEnergyWireless(int voltage) { | ||
this.transferred_energy_per_operation = 2 * voltage * ticks_between_energy_addition; | ||
} | ||
|
||
@Override | ||
public boolean isRedstoneSensitive(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, | ||
long aTimer) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean allowsCopyPasteTool() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean allowsTickRateAddition() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean hasCoverGUI() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, | ||
ICoverable aTileEntity, long aTimer) { | ||
if (aCoverVariable == 0 || aTimer % ticks_between_energy_addition == 0) { | ||
tryFetchingEnergy(aTileEntity); | ||
} | ||
return 1; | ||
} | ||
|
||
private static UUID getOwner(Object te) { | ||
if (te instanceof BaseMetaTileEntity igte) { | ||
return igte.getOwnerUuid(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
private void tryFetchingEnergy(ICoverable tileEntity) { | ||
if (tileEntity instanceof BaseMetaTileEntity bmte) { | ||
long currentEU = bmte.getStoredEUuncapped(); | ||
long euToTransfer = min(transferred_energy_per_operation - currentEU, transferred_energy_per_operation); | ||
if (euToTransfer <= 0) return; // nothing to transfer | ||
if (!addEUToGlobalEnergyMap(getOwner(tileEntity), -euToTransfer)) return; | ||
bmte.increaseStoredEnergyUnits(euToTransfer, true); | ||
} | ||
} | ||
|
||
@Override | ||
protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, | ||
ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, | ||
float aY, float aZ) { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected boolean isGUIClickableImpl(ForgeDirection side, int aCoverID, | ||
ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean alwaysLookConnected(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { | ||
return 20; | ||
} | ||
} |
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
Binary file added
BIN
+561 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/383.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+640 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+715 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/385.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+733 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/386.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+618 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/387.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+666 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/388.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+708 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/389.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+725 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+687 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/391.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+615 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/392.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+606 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/393.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+611 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/394.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+615 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/395.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+610 Bytes
src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/396.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.