-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cheese void cells & generalize void cells
- Loading branch information
Showing
12 changed files
with
274 additions
and
65 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
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
34 changes: 34 additions & 0 deletions
34
src/main/java/co/neeve/nae2/common/items/cells/vc/VoidGasCell.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,34 @@ | ||
package co.neeve.nae2.common.items.cells.vc; | ||
|
||
import appeng.api.AEApi; | ||
import appeng.api.storage.IStorageChannel; | ||
import appeng.items.contents.CellConfig; | ||
import com.mekeng.github.common.item.ItemDummyGas; | ||
import com.mekeng.github.common.me.data.IAEGasStack; | ||
import com.mekeng.github.common.me.data.impl.AEGasStack; | ||
import com.mekeng.github.common.me.storage.IGasStorageChannel; | ||
import com.mekeng.github.util.helpers.GasCellConfig; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class VoidGasCell extends VoidCell<IAEGasStack> { | ||
@Override | ||
public IStorageChannel<IAEGasStack> getStorageChannel() { | ||
return AEApi.instance().storage().getStorageChannel(IGasStorageChannel.class); | ||
} | ||
|
||
@Override | ||
public CellConfig getCellConfig(ItemStack o) { | ||
return new GasCellConfig(o); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public IAEGasStack handleConfigStack(ItemStack stack) { | ||
if (stack.getItem() instanceof ItemDummyGas gasItem) { | ||
return AEGasStack.of(gasItem.getGasStack(stack)); | ||
} | ||
return null; | ||
} | ||
} |
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
60 changes: 60 additions & 0 deletions
60
src/main/java/co/neeve/nae2/common/recipes/handlers/VoidConversionRecipe.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,60 @@ | ||
package co.neeve.nae2.common.recipes.handlers; | ||
|
||
import co.neeve.nae2.common.items.cells.vc.VoidCell; | ||
import net.minecraft.inventory.InventoryCrafting; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.crafting.Ingredient; | ||
import net.minecraft.item.crafting.ShapelessRecipes; | ||
import net.minecraft.util.NonNullList; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class VoidConversionRecipe extends ShapelessRecipes { | ||
private final ItemStack from; | ||
private final ItemStack to; | ||
|
||
public VoidConversionRecipe(ItemStack from, ItemStack to) { | ||
super("", to, NonNullList.create()); | ||
this.getIngredients().add(Ingredient.fromStacks(from)); | ||
this.from = from; | ||
this.to = to; | ||
} | ||
|
||
@Override | ||
public boolean matches(@NotNull InventoryCrafting inv, @NotNull World worldIn) { | ||
return !this.getOutput(inv).isEmpty(); | ||
} | ||
|
||
@Override | ||
public @NotNull ItemStack getCraftingResult(@NotNull InventoryCrafting inv) { | ||
return this.getOutput(inv); | ||
} | ||
|
||
public ItemStack getOutput(InventoryCrafting inv) { | ||
var output = ItemStack.EMPTY; | ||
for (var i = 0; i < inv.getSizeInventory(); i++) { | ||
var stack = inv.getStackInSlot(i); | ||
if (stack.isEmpty()) { | ||
continue; | ||
} | ||
|
||
if (stack.isItemEqual(this.from)) { | ||
output = this.to.copy(); | ||
// Copy power over. | ||
((VoidCell<?>) output.getItem()) | ||
.setCondenserPower(output, ((VoidCell<?>) stack.getItem()).getCondenserPower(stack)); | ||
continue; | ||
} | ||
|
||
if (!output.isEmpty()) { | ||
return ItemStack.EMPTY; | ||
} | ||
} | ||
return output; | ||
} | ||
|
||
@Override | ||
public @NotNull NonNullList<ItemStack> getRemainingItems(@NotNull InventoryCrafting inv) { | ||
return NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY); | ||
} | ||
} |
Oops, something went wrong.