Skip to content

Commit

Permalink
fix: Fix hopper not extracting from auto compressor #363
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jun 30, 2024
1 parent de38483 commit 6eac4e4
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.blay09.mods.excompressum.registry.ExRegistries;
import net.blay09.mods.excompressum.registry.compressor.CompressedRecipe;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -82,18 +83,18 @@ public int get(int id) {
return (int) (100f * AutoCompressorBlockEntity.this.getProgress());
} else if (id == 1) {
return AutoCompressorBlockEntity.this.getEnergyStorage().getEnergy();
} else if (id == 2) {
} else if (id == 2) {
return AutoCompressorBlockEntity.this.isDisabledByRedstone() ? 1 : 0;
}
return 0;
}

public void set(int id, int value) {
if (id == 0) {
AutoCompressorBlockEntity.this.setProgress( value / 100f);
AutoCompressorBlockEntity.this.setProgress(value / 100f);
} else if (id == 1) {
AutoCompressorBlockEntity.this.getEnergyStorage().setEnergy(value);
} else if (id == 2) {
} else if (id == 2) {
AutoCompressorBlockEntity.this.setDisabledByRedstone(value == 1);
}
}
Expand Down Expand Up @@ -190,7 +191,11 @@ public void serverTick() {
if (compressedRecipe != null) {
ItemStack resultStack = compressedRecipe.getResultStack().copy();
if (!addItemToOutput(resultStack)) {
ItemEntity entityItem = new ItemEntity(level, worldPosition.getX() + 0.5, worldPosition.getY() + 1.5, worldPosition.getZ() + 0.5, resultStack);
ItemEntity entityItem = new ItemEntity(level,
worldPosition.getX() + 0.5,
worldPosition.getY() + 1.5,
worldPosition.getZ() + 0.5,
resultStack);
double motion = 0.05;
entityItem.setDeltaMovement(level.random.nextGaussian() * motion, 0.2, level.random.nextGaussian() * motion);
level.addFreshEntity(entityItem);
Expand Down Expand Up @@ -301,6 +306,15 @@ public Container getContainer() {
return container;
}

@Override
public Container getContainer(Direction side) {
if (side == Direction.DOWN) {
return outputSlots;
}

return BalmContainerProvider.super.getContainer(side);
}

@Override
public EnergyStorage getEnergyStorage() {
return energyStorage;
Expand Down

0 comments on commit 6eac4e4

Please sign in to comment.