mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 15:46:01 +00:00
16 files changed
+357
-107
No files matched your search
+25
-12
@@ -25,6 +25,7 @@ jobs:
|
||||
minecraft_version: ${{ steps.artifacts.outputs.minecraft_version }}
|
||||
release_files: ${{ steps.artifacts.outputs.release_files }}
|
||||
main_files: ${{ steps.artifacts.outputs.main_files }}
|
||||
release_type: ${{ steps.release_type.outputs.value }}
|
||||
|
||||
steps:
|
||||
- name: Check out release tag
|
||||
@@ -63,6 +64,18 @@ jobs:
|
||||
- name: Grant execute permission for Gradle
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Determine publishing release type
|
||||
id: release_type
|
||||
shell: bash
|
||||
env:
|
||||
IS_PRERELEASE: ${{ github.event.release.prerelease }}
|
||||
run: |
|
||||
if [[ "$IS_PRERELEASE" == 'true' ]]; then
|
||||
echo 'value=beta' >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo 'value=release' >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Determine exact artifact names
|
||||
id: artifacts
|
||||
shell: bash
|
||||
@@ -185,7 +198,7 @@ jobs:
|
||||
files: ${{ needs.build.outputs.main_files }}
|
||||
name: Mekanism CE - CORE ${{ github.event.release.tag_name }}
|
||||
version: ${{ github.event.release.tag_name }}
|
||||
version-type: ${{ github.event.release.prerelease && 'beta' || 'release' }}
|
||||
version-type: ${{ needs.build.outputs.release_type }}
|
||||
changelog: ${{ github.event.release.body }}
|
||||
loaders: forge
|
||||
game-versions: ${{ needs.build.outputs.minecraft_version }}
|
||||
@@ -207,22 +220,22 @@ jobs:
|
||||
- name: DefenseTech
|
||||
project-id: qBExn86I
|
||||
classifier: DefenseTech
|
||||
beta-only: false
|
||||
release_policy: follow_release
|
||||
only_version: '1.7.10'
|
||||
- name: Generators
|
||||
project-id: ksSEAhTL
|
||||
classifier: Generators
|
||||
beta-only: false
|
||||
release_policy: follow_release
|
||||
only_version: ''
|
||||
- name: Tools
|
||||
project-id: CD05L8Jr
|
||||
classifier: Tools
|
||||
beta-only: false
|
||||
release_policy: follow_release
|
||||
only_version: ''
|
||||
- name: Ultimate
|
||||
project-id: Q6fY4JVC
|
||||
classifier: Ultimate
|
||||
beta-only: true
|
||||
release_policy: beta_only
|
||||
only_version: ''
|
||||
|
||||
steps:
|
||||
@@ -242,7 +255,7 @@ jobs:
|
||||
files: output/${{ needs.build.outputs.artifact_prefix }}-${{ matrix.classifier }}.jar
|
||||
name: Mekanism CE - ${{ matrix.name }} ${{ github.event.release.tag_name }}
|
||||
version: ${{ github.event.release.tag_name }}
|
||||
version-type: ${{ matrix.beta-only && 'beta' || (github.event.release.prerelease && 'beta' || 'release') }}
|
||||
version-type: ${{ matrix.release_policy == 'beta_only' && 'beta' || needs.build.outputs.release_type }}
|
||||
changelog: ${{ github.event.release.body }}
|
||||
loaders: forge
|
||||
game-versions: ${{ needs.build.outputs.minecraft_version }}
|
||||
@@ -266,31 +279,31 @@ jobs:
|
||||
project-id: '399904'
|
||||
classifier: Core
|
||||
dependencies: ''
|
||||
beta-only: false
|
||||
release_policy: follow_release
|
||||
only_version: ''
|
||||
- name: DefenseTech
|
||||
project-id: '1488821'
|
||||
classifier: DefenseTech
|
||||
dependencies: mekanism-ce(required)
|
||||
beta-only: false
|
||||
release_policy: follow_release
|
||||
only_version: '1.7.10'
|
||||
- name: Generators
|
||||
project-id: '813408'
|
||||
classifier: Generators
|
||||
dependencies: mekanism-ce(required)
|
||||
beta-only: false
|
||||
release_policy: follow_release
|
||||
only_version: ''
|
||||
- name: Tools
|
||||
project-id: '813407'
|
||||
classifier: Tools
|
||||
dependencies: mekanism-ce(required)
|
||||
beta-only: false
|
||||
release_policy: follow_release
|
||||
only_version: ''
|
||||
- name: Ultimate
|
||||
project-id: '872280'
|
||||
classifier: Ultimate
|
||||
dependencies: mekanism-ce(required)
|
||||
beta-only: true
|
||||
release_policy: beta_only
|
||||
only_version: ''
|
||||
|
||||
steps:
|
||||
@@ -310,7 +323,7 @@ jobs:
|
||||
files: output/${{ needs.build.outputs.artifact_prefix }}-${{ matrix.classifier }}.jar
|
||||
name: Mekanism CE - ${{ matrix.name }} ${{ github.event.release.tag_name }}
|
||||
version: ${{ github.event.release.tag_name }}
|
||||
version-type: ${{ matrix.beta-only && 'beta' || (github.event.release.prerelease && 'beta' || 'release') }}
|
||||
version-type: ${{ matrix.release_policy == 'beta_only' && 'beta' || needs.build.outputs.release_type }}
|
||||
changelog: ${{ github.event.release.body }}
|
||||
loaders: forge
|
||||
game-versions: ${{ needs.build.outputs.minecraft_version }}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
minecraft_version=1.12.2
|
||||
mappings_version=stable_39
|
||||
forge_version=14.23.5.2847
|
||||
mod_version=9.12.15
|
||||
mod_version=9.12.16
|
||||
|
||||
mcmp_version=2.5.3
|
||||
jei_version=4.16.1.302
|
||||
|
||||
@@ -7,7 +7,7 @@ import mekanism.client.gui.element.GuiRateBar.IRateInfoHandler;
|
||||
import mekanism.client.gui.element.gauge.GuiEnergyGauge;
|
||||
import mekanism.client.gui.element.tab.GuiMatrixTab;
|
||||
import mekanism.client.gui.element.tab.GuiMatrixTab.MatrixTab;
|
||||
import mekanism.common.inventory.container.ContainerNull;
|
||||
import mekanism.common.inventory.container.ContainerInductionMatrixStats;
|
||||
import mekanism.common.tile.TileEntityInductionCasing;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -21,7 +21,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
public class GuiMatrixStats extends GuiMekanismTile<TileEntityInductionCasing> {
|
||||
|
||||
public GuiMatrixStats(InventoryPlayer inventory, TileEntityInductionCasing tile) {
|
||||
super(tile, new ContainerNull(inventory.player, tile));
|
||||
super(tile, new ContainerInductionMatrixStats(inventory, tile));
|
||||
ResourceLocation resource = getGuiLocation();
|
||||
addGuiElement(new GuiMatrixTab(this, tileEntity, MatrixTab.MAIN, resource));
|
||||
addGuiElement(new GuiEnergyGauge(() -> tileEntity, GuiEnergyGauge.Type.STANDARD, this, resource, 6, 13));
|
||||
@@ -77,4 +77,4 @@ public class GuiMatrixStats extends GuiMekanismTile<TileEntityInductionCasing> {
|
||||
protected ResourceLocation getGuiLocation() {
|
||||
return MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,6 @@ public class RenderResizableCuboid {
|
||||
tess.draw();
|
||||
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.disableAlpha();
|
||||
}
|
||||
|
||||
private void renderCuboidFace(BufferBuilder wr, EnumFacing face, TextureAtlasSprite[] sprites, int[] flips, Vec3d textureStart, Vec3d textureSize,
|
||||
@@ -669,4 +668,4 @@ public class RenderResizableCuboid {
|
||||
return new RenderInfo(uv, xyz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import mekanism.common.inventory.container.ContainerFormulaicAssemblicator;
|
||||
import mekanism.common.inventory.container.ContainerFuelwoodHeater;
|
||||
import mekanism.common.inventory.container.ContainerGasTank;
|
||||
import mekanism.common.inventory.container.ContainerInductionMatrix;
|
||||
import mekanism.common.inventory.container.ContainerInductionMatrixStats;
|
||||
import mekanism.common.inventory.container.ContainerLaserAmplifier;
|
||||
import mekanism.common.inventory.container.ContainerLaserTractorBeam;
|
||||
import mekanism.common.inventory.container.ContainerMetallurgicInfuser;
|
||||
@@ -371,7 +372,7 @@ public class CommonProxy implements IGuiProvider {
|
||||
case 49:
|
||||
return new ContainerInductionMatrix(player.inventory, (TileEntityInductionCasing) tileEntity);
|
||||
case 50:
|
||||
return new ContainerNull(player, (TileEntityContainerBlock) tileEntity);
|
||||
return new ContainerInductionMatrixStats(player.inventory, (TileEntityInductionCasing) tileEntity);
|
||||
case 51:
|
||||
return new ContainerNull(player, (TileEntityContainerBlock) tileEntity);
|
||||
case 52:
|
||||
@@ -470,4 +471,4 @@ public class CommonProxy implements IGuiProvider {
|
||||
public void throwApiPresentException() {
|
||||
throw new RuntimeException(String.join(" ", API_PRESENT_MESSAGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package mekanism.common.content.matrix;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.multiblock.SynchronizedData;
|
||||
import mekanism.common.tile.TileEntityInductionCell;
|
||||
import mekanism.common.tile.TileEntityInductionProvider;
|
||||
@@ -201,37 +199,6 @@ public class SynchronizedMatrixData extends SynchronizedData<SynchronizedMatrixD
|
||||
}
|
||||
}
|
||||
|
||||
public TileNetworkList addStructureData(TileNetworkList data) {
|
||||
data.add(cachedTotal);
|
||||
data.add(storageCap);
|
||||
data.add(transferCap);
|
||||
data.add(lastInput);
|
||||
data.add(lastOutput);
|
||||
|
||||
data.add(volWidth);
|
||||
data.add(volHeight);
|
||||
data.add(volLength);
|
||||
|
||||
data.add(cells.size());
|
||||
data.add(providers.size());
|
||||
return data;
|
||||
}
|
||||
|
||||
public void readStructureData(ByteBuf dataStream) {
|
||||
cachedTotal = dataStream.readDouble();
|
||||
storageCap = dataStream.readDouble();
|
||||
transferCap = dataStream.readDouble();
|
||||
lastInput = dataStream.readDouble();
|
||||
lastOutput = dataStream.readDouble();
|
||||
|
||||
volWidth = dataStream.readInt();
|
||||
volHeight = dataStream.readInt();
|
||||
volLength = dataStream.readInt();
|
||||
|
||||
clientCells = dataStream.readInt();
|
||||
clientProviders = dataStream.readInt();
|
||||
}
|
||||
|
||||
public double getStorageCap() {
|
||||
return storageCap;
|
||||
}
|
||||
@@ -267,4 +234,53 @@ public class SynchronizedMatrixData extends SynchronizedData<SynchronizedMatrixD
|
||||
public int getProviderCount() {
|
||||
return providers.isEmpty() ? clientProviders : providers.size();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from the client when synchronizing container data.
|
||||
*/
|
||||
public void setCachedTotal(double cachedTotal) {
|
||||
this.cachedTotal = cachedTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from the client when synchronizing container data.
|
||||
*/
|
||||
public void setStorageCap(double storageCap) {
|
||||
this.storageCap = storageCap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from the client when synchronizing container data.
|
||||
*/
|
||||
public void setTransferCap(double transferCap) {
|
||||
this.transferCap = transferCap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from the client when synchronizing container data.
|
||||
*/
|
||||
public void setLastInput(double lastInput) {
|
||||
this.lastInput = lastInput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from the client when synchronizing container data.
|
||||
*/
|
||||
public void setLastOutput(double lastOutput) {
|
||||
this.lastOutput = lastOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from the client when synchronizing container data.
|
||||
*/
|
||||
public void setClientCells(int clientCells) {
|
||||
this.clientCells = clientCells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from the client when synchronizing container data.
|
||||
*/
|
||||
public void setClientProviders(int clientProviders) {
|
||||
this.clientProviders = clientProviders;
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,20 @@ public class TankCache extends MultiblockCache<SynchronizedTankData> {
|
||||
@Override
|
||||
public void apply(SynchronizedTankData data) {
|
||||
data.inventory = inventory;
|
||||
data.fluidStored = fluid;
|
||||
data.fluidStored = fluid == null ? null : fluid.copy();
|
||||
data.editMode = editMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync(SynchronizedTankData data) {
|
||||
inventory = data.inventory;
|
||||
fluid = data.fluidStored;
|
||||
if (data.fluidStored == null) {
|
||||
fluid = null;
|
||||
} else if (fluid == null || !fluid.isFluidEqual(data.fluidStored)) {
|
||||
fluid = data.fluidStored.copy();
|
||||
} else {
|
||||
fluid.amount = data.fluidStored.amount;
|
||||
}
|
||||
editMode = data.editMode;
|
||||
}
|
||||
|
||||
@@ -66,4 +72,4 @@ public class TankCache extends MultiblockCache<SynchronizedTankData> {
|
||||
nbtTags.setTag("cachedFluid", fluid.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class TankUpdateProtocol extends UpdateProtocol<SynchronizedTankData> {
|
||||
TankCache tankCache = (TankCache) cache;
|
||||
TankCache mergeCache = (TankCache) merge;
|
||||
if (tankCache.fluid == null) {
|
||||
tankCache.fluid = mergeCache.fluid;
|
||||
tankCache.fluid = mergeCache.fluid == null ? null : mergeCache.fluid.copy();
|
||||
} else if (mergeCache.fluid != null && tankCache.fluid.isFluidEqual(mergeCache.fluid)) {
|
||||
tankCache.fluid.amount += mergeCache.fluid.amount;
|
||||
}
|
||||
@@ -82,4 +82,4 @@ public class TankUpdateProtocol extends UpdateProtocol<SynchronizedTankData> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,169 @@
|
||||
package mekanism.common.inventory.container;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.common.content.matrix.SynchronizedMatrixData;
|
||||
import mekanism.common.inventory.slot.SlotEnergy.SlotCharge;
|
||||
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
|
||||
import mekanism.common.tile.TileEntityInductionCasing;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
|
||||
public class ContainerInductionMatrix extends ContainerEnergyStorage<TileEntityInductionCasing> {
|
||||
|
||||
private static final int DOUBLE_PARTS = 4;
|
||||
private static final int DOUBLE_PROPERTIES = 5;
|
||||
private static final int FIRST_INT_PROPERTY = DOUBLE_PARTS * DOUBLE_PROPERTIES;
|
||||
|
||||
private final long[] lastDoubleValues = new long[DOUBLE_PROPERTIES];
|
||||
private final int[] lastIntValues = new int[5];
|
||||
|
||||
public ContainerInductionMatrix(InventoryPlayer inventory, TileEntityInductionCasing tile) {
|
||||
super(tile, inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(@Nonnull IContainerListener listener) {
|
||||
super.addListener(listener);
|
||||
sendAllMatrixData(listener);
|
||||
cacheMatrixData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
long[] doubleValues = getDoubleValues();
|
||||
int[] intValues = getIntValues();
|
||||
for (IContainerListener listener : listeners) {
|
||||
for (int valueIndex = 0; valueIndex < doubleValues.length; valueIndex++) {
|
||||
if (doubleValues[valueIndex] != lastDoubleValues[valueIndex]) {
|
||||
sendDouble(listener, valueIndex, doubleValues[valueIndex]);
|
||||
}
|
||||
}
|
||||
for (int valueIndex = 0; valueIndex < intValues.length; valueIndex++) {
|
||||
if (intValues[valueIndex] != lastIntValues[valueIndex]) {
|
||||
listener.sendWindowProperty(this, FIRST_INT_PROPERTY + valueIndex, intValues[valueIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.arraycopy(doubleValues, 0, lastDoubleValues, 0, doubleValues.length);
|
||||
System.arraycopy(intValues, 0, lastIntValues, 0, intValues.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int property, int value) {
|
||||
SynchronizedMatrixData structure = getOrCreateClientStructure();
|
||||
if (property < FIRST_INT_PROPERTY) {
|
||||
int valueIndex = property / DOUBLE_PARTS;
|
||||
int part = property % DOUBLE_PARTS;
|
||||
long oldBits = getDoubleValues()[valueIndex];
|
||||
int shift = part * Short.SIZE;
|
||||
long mask = 0xFFFFL << shift;
|
||||
long newBits = (oldBits & ~mask) | (((long) value & 0xFFFFL) << shift);
|
||||
setDoubleValue(structure, valueIndex, Double.longBitsToDouble(newBits));
|
||||
} else {
|
||||
setIntValue(structure, property - FIRST_INT_PROPERTY, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendAllMatrixData(IContainerListener listener) {
|
||||
long[] doubleValues = getDoubleValues();
|
||||
for (int valueIndex = 0; valueIndex < doubleValues.length; valueIndex++) {
|
||||
sendDouble(listener, valueIndex, doubleValues[valueIndex]);
|
||||
}
|
||||
int[] intValues = getIntValues();
|
||||
for (int valueIndex = 0; valueIndex < intValues.length; valueIndex++) {
|
||||
listener.sendWindowProperty(this, FIRST_INT_PROPERTY + valueIndex, intValues[valueIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendDouble(IContainerListener listener, int valueIndex, long value) {
|
||||
int firstProperty = valueIndex * DOUBLE_PARTS;
|
||||
for (int part = 0; part < DOUBLE_PARTS; part++) {
|
||||
listener.sendWindowProperty(this, firstProperty + part, (int) (value >>> (part * Short.SIZE) & 0xFFFFL));
|
||||
}
|
||||
}
|
||||
|
||||
private void cacheMatrixData() {
|
||||
long[] doubleValues = getDoubleValues();
|
||||
int[] intValues = getIntValues();
|
||||
System.arraycopy(doubleValues, 0, lastDoubleValues, 0, doubleValues.length);
|
||||
System.arraycopy(intValues, 0, lastIntValues, 0, intValues.length);
|
||||
}
|
||||
|
||||
private long[] getDoubleValues() {
|
||||
SynchronizedMatrixData structure = tileEntity.structure;
|
||||
return new long[]{
|
||||
Double.doubleToRawLongBits(structure == null ? 0 : structure.getEnergy()),
|
||||
Double.doubleToRawLongBits(structure == null ? 0 : structure.getStorageCap()),
|
||||
Double.doubleToRawLongBits(structure == null ? 0 : structure.getTransferCap()),
|
||||
Double.doubleToRawLongBits(structure == null ? 0 : structure.getLastInput()),
|
||||
Double.doubleToRawLongBits(structure == null ? 0 : structure.getLastOutput())
|
||||
};
|
||||
}
|
||||
|
||||
private int[] getIntValues() {
|
||||
SynchronizedMatrixData structure = tileEntity.structure;
|
||||
return new int[]{
|
||||
structure == null ? 0 : structure.volWidth,
|
||||
structure == null ? 0 : structure.volHeight,
|
||||
structure == null ? 0 : structure.volLength,
|
||||
structure == null ? 0 : structure.getCellCount(),
|
||||
structure == null ? 0 : structure.getProviderCount()
|
||||
};
|
||||
}
|
||||
|
||||
private SynchronizedMatrixData getOrCreateClientStructure() {
|
||||
if (tileEntity.structure == null) {
|
||||
tileEntity.structure = new SynchronizedMatrixData();
|
||||
}
|
||||
return tileEntity.structure;
|
||||
}
|
||||
|
||||
private void setDoubleValue(SynchronizedMatrixData structure, int valueIndex, double value) {
|
||||
switch (valueIndex) {
|
||||
case 0:
|
||||
structure.setCachedTotal(value);
|
||||
break;
|
||||
case 1:
|
||||
structure.setStorageCap(value);
|
||||
break;
|
||||
case 2:
|
||||
structure.setTransferCap(value);
|
||||
break;
|
||||
case 3:
|
||||
structure.setLastInput(value);
|
||||
break;
|
||||
case 4:
|
||||
structure.setLastOutput(value);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
private void setIntValue(SynchronizedMatrixData structure, int valueIndex, int value) {
|
||||
switch (valueIndex) {
|
||||
case 0:
|
||||
structure.volWidth = value;
|
||||
break;
|
||||
case 1:
|
||||
structure.volHeight = value;
|
||||
break;
|
||||
case 2:
|
||||
structure.volLength = value;
|
||||
break;
|
||||
case 3:
|
||||
structure.setClientCells(value);
|
||||
break;
|
||||
case 4:
|
||||
structure.setClientProviders(value);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addSlots() {
|
||||
addSlotToContainer(new SlotCharge(tileEntity, 0, 146, 20));
|
||||
addSlotToContainer(new SlotDischarge(tileEntity, 1, 146, 51));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package mekanism.common.inventory.container;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.common.tile.TileEntityInductionCasing;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerInductionMatrixStats extends ContainerInductionMatrix {
|
||||
|
||||
public ContainerInductionMatrixStats(InventoryPlayer inventory, TileEntityInductionCasing tile) {
|
||||
super(inventory, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addSlots() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addInventorySlots(InventoryPlayer inventory) {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,12 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
@@ -40,6 +42,7 @@ import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.util.Constants.WorldEvents;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -139,16 +142,7 @@ public class ItemAtomicDisassembler extends ItemEnergized {
|
||||
if (coord.equals(orig)) {
|
||||
continue;
|
||||
}
|
||||
int destroyEnergy = getDestroyEnergy(itemstack, coord.getBlockState(player.world).getBlockHardness(player.world, coord.getPos()));
|
||||
if (getEnergy(itemstack) < destroyEnergy) {
|
||||
continue;
|
||||
}
|
||||
Block block2 = coord.getBlock(player.world);
|
||||
block2.onBlockHarvested(player.world, coord.getPos(), state, player);
|
||||
player.world.playEvent(WorldEvents.BREAK_BLOCK_EFFECTS, coord.getPos(), Block.getStateId(state));
|
||||
block2.dropBlockAsItem(player.world, coord.getPos(), state, 0);
|
||||
player.world.setBlockToAir(coord.getPos());
|
||||
setEnergy(itemstack, getEnergy(itemstack) - destroyEnergy);
|
||||
tryHarvestBlock(itemstack, coord.getPos(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,6 +150,41 @@ public class ItemAtomicDisassembler extends ItemEnergized {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void tryHarvestBlock(ItemStack itemstack, BlockPos pos, EntityPlayer player) {
|
||||
World world = player.world;
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
int destroyEnergy = getDestroyEnergy(itemstack, state.getBlockHardness(world, pos));
|
||||
if (getEnergy(itemstack) < destroyEnergy) {
|
||||
return;
|
||||
}
|
||||
|
||||
int experience = 0;
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
experience = ForgeHooks.onBlockBreakEvent(world, playerMP.interactionManager.getGameType(), playerMP, pos);
|
||||
if (experience == -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Block block = state.getBlock();
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
boolean canHarvest = block.canHarvestBlock(world, pos, player);
|
||||
ItemStack harvestTool = itemstack.copy();
|
||||
itemstack.onBlockDestroyed(world, state, pos, player);
|
||||
player.world.playEvent(WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getStateId(state));
|
||||
|
||||
if (block.removedByPlayer(state, world, pos, player, canHarvest)) {
|
||||
block.onPlayerDestroy(world, pos, state);
|
||||
if (canHarvest) {
|
||||
block.harvestBlock(world, player, pos, state, tile, harvestTool);
|
||||
}
|
||||
if (experience > 0) {
|
||||
block.dropXpOnBlockBreak(world, pos, experience);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
@@ -434,4 +463,4 @@ public class ItemAtomicDisassembler extends ItemEnergized {
|
||||
//Used to reference useHoe and useShovel via lambda references
|
||||
EnumActionResult use(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing facing);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,11 @@ public class MultiblockManager<T extends SynchronizedData<T>> {
|
||||
tile.cachedData.locations.add(Coord4D.get(tile));
|
||||
inventories.put(tile.cachedID, tile.cachedData);
|
||||
} else {
|
||||
inventories.get(tile.cachedID).locations.add(Coord4D.get(tile));
|
||||
MultiblockCache<T> cache = inventories.get(tile.cachedID);
|
||||
cache.locations.add(Coord4D.get(tile));
|
||||
if (tile.structure != null) {
|
||||
cache.sync(tile.structure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
@@ -20,7 +18,6 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
public class TileEntityInductionCasing extends TileEntityMultiblock<SynchronizedMatrixData> implements IStrictEnergyStorage, IComputerIntegration {
|
||||
@@ -61,25 +58,6 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileNetworkList getNetworkedData(TileNetworkList data) {
|
||||
super.getNetworkedData(data);
|
||||
if (structure != null) {
|
||||
structure.addStructureData(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream) {
|
||||
super.handlePacketData(dataStream);
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
if (clientHasStructure) {
|
||||
structure.readStructureData(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SynchronizedMatrixData getNewStructure() {
|
||||
return new SynchronizedMatrixData();
|
||||
@@ -208,4 +186,4 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,15 +126,27 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
|
||||
if (structure != null) {
|
||||
structure.didTick = false;
|
||||
if (structure.inventoryID != null) {
|
||||
cachedData.sync(structure);
|
||||
cachedID = structure.inventoryID;
|
||||
getManager().updateCache(this);
|
||||
}
|
||||
syncStructureToCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void syncStructureToCache() {
|
||||
if (structure != null && structure.inventoryID != null) {
|
||||
cachedData.sync(structure);
|
||||
cachedID = structure.inventoryID;
|
||||
getManager().updateCache(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (world != null && !world.isRemote) {
|
||||
syncStructureToCache();
|
||||
}
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doUpdate() {
|
||||
if (!world.isRemote && (structure == null || !structure.didTick)) {
|
||||
@@ -232,6 +244,9 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) {
|
||||
if (world != null && !world.isRemote) {
|
||||
syncStructureToCache();
|
||||
}
|
||||
super.writeToNBT(nbtTags);
|
||||
if (cachedID != null) {
|
||||
nbtTags.setString("cachedID", cachedID);
|
||||
@@ -266,4 +281,4 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
public T getSynchronizedData() {
|
||||
return structure;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,9 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
configComponent.getOutputs(TransmissionType.FLUID).get(2).availableSlots = new int[]{0};
|
||||
configComponent.getOutputs(TransmissionType.GAS).get(2).availableSlots = new int[]{1};
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent = new TileComponentEjector(this,
|
||||
() -> MekanismConfig.current().general.quantumEntangloporterGasBuffer.val(),
|
||||
() -> MekanismConfig.current().general.quantumEntangloporterFluidBuffer.val());
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
ejectorComponent.setOutputData(TransmissionType.FLUID, configComponent.getOutputs(TransmissionType.FLUID).get(2));
|
||||
ejectorComponent.setOutputData(TransmissionType.GAS, configComponent.getOutputs(TransmissionType.GAS).get(2));
|
||||
@@ -613,4 +615,4 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
public TileComponentUpgrade getComponent() {
|
||||
return this.upgradeComponent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.IntSupplier;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.api.gas.GasStack;
|
||||
@@ -38,6 +39,8 @@ public class TileComponentEjector implements ITileComponent {
|
||||
private static final int GAS_OUTPUT = 256;
|
||||
private static final int FLUID_OUTPUT = 256;
|
||||
private TileEntityContainerBlock tileEntity;
|
||||
private final IntSupplier gasOutput;
|
||||
private final IntSupplier fluidOutput;
|
||||
private boolean strictInput;
|
||||
private EnumColor outputColor;
|
||||
private EnumColor[] inputColors = new EnumColor[]{null, null, null, null, null, null};
|
||||
@@ -45,7 +48,13 @@ public class TileComponentEjector implements ITileComponent {
|
||||
private Map<TransmissionType, SideData> sideData = new EnumMap<>(TransmissionType.class);
|
||||
|
||||
public TileComponentEjector(TileEntityContainerBlock tile) {
|
||||
this(tile, () -> GAS_OUTPUT, () -> FLUID_OUTPUT);
|
||||
}
|
||||
|
||||
public TileComponentEjector(TileEntityContainerBlock tile, IntSupplier gasOutput, IntSupplier fluidOutput) {
|
||||
tileEntity = tile;
|
||||
this.gasOutput = gasOutput;
|
||||
this.fluidOutput = fluidOutput;
|
||||
tile.components.add(this);
|
||||
}
|
||||
|
||||
@@ -92,7 +101,7 @@ public class TileComponentEjector implements ITileComponent {
|
||||
|
||||
private void ejectGas(Set<EnumFacing> outputSides, GasTank tank) {
|
||||
if (tank.getGas() != null && tank.getStored() > 0) {
|
||||
GasStack toEmit = tank.getGas().copy().withAmount(Math.min(GAS_OUTPUT, tank.getStored()));
|
||||
GasStack toEmit = tank.getGas().copy().withAmount(Math.min(gasOutput.getAsInt(), tank.getStored()));
|
||||
int emit = GasUtils.emit(toEmit, tileEntity, outputSides);
|
||||
tank.draw(emit, true);
|
||||
}
|
||||
@@ -100,7 +109,7 @@ public class TileComponentEjector implements ITileComponent {
|
||||
|
||||
private void ejectFluid(Set<EnumFacing> outputSides, FluidTank tank) {
|
||||
if (tank.getFluid() != null && tank.getFluidAmount() > 0) {
|
||||
FluidStack toEmit = PipeUtils.copy(tank.getFluid(), Math.min(FLUID_OUTPUT, tank.getFluidAmount()));
|
||||
FluidStack toEmit = PipeUtils.copy(tank.getFluid(), Math.min(fluidOutput.getAsInt(), tank.getFluidAmount()));
|
||||
int emit = PipeUtils.emit(outputSides, toEmit, tileEntity);
|
||||
tank.drain(emit, true);
|
||||
}
|
||||
@@ -261,4 +270,4 @@ public class TileComponentEjector implements ITileComponent {
|
||||
private boolean getEjecting(TransmissionType type) {
|
||||
return ((ISideConfiguration) tileEntity).getConfig().isEjecting(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user