-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add battery item provider - Allow inserts into battery buffers - String formatting from names - Fix name for pattern item providers - Fix colouring for planning warnings/errors - Skip bacvat renderer - Transform strong redstone sides
- Loading branch information
Showing
9 changed files
with
108 additions
and
12 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
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
66 changes: 66 additions & 0 deletions
66
...recursive_pineapple/matter_manipulator/common/building/providers/BatteryItemProvider.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,66 @@ | ||
package com.recursive_pineapple.matter_manipulator.common.building.providers; | ||
|
||
import java.util.Arrays; | ||
|
||
import net.minecraft.init.Items; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import net.minecraftforge.oredict.OreDictionary; | ||
|
||
import com.recursive_pineapple.matter_manipulator.common.building.IItemProvider; | ||
import com.recursive_pineapple.matter_manipulator.common.building.IPseudoInventory; | ||
import com.recursive_pineapple.matter_manipulator.common.utils.BigItemStack; | ||
import com.recursive_pineapple.matter_manipulator.common.utils.ImmutableItemMeta; | ||
import com.recursive_pineapple.matter_manipulator.common.utils.ItemMeta; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class BatteryItemProvider implements IItemProvider { | ||
|
||
public ImmutableItemMeta battery; | ||
|
||
public BatteryItemProvider() {} | ||
|
||
public static BatteryItemProvider fromStack(ItemStack stack) { | ||
if (stack == null) return null; | ||
|
||
boolean isBattery = false; | ||
|
||
for (int oreId : OreDictionary.getOreIDs(stack)) { | ||
if (OreDictionary.getOreName(oreId).startsWith("battery")) { | ||
isBattery = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!isBattery) return null; | ||
|
||
BatteryItemProvider provider = new BatteryItemProvider(); | ||
|
||
provider.battery = new ItemMeta(stack.getItem(), Items.feather.getDamage(stack)); | ||
|
||
return provider; | ||
} | ||
|
||
@Override | ||
public @Nullable ItemStack getStack(IPseudoInventory inv, boolean consume) { | ||
ItemStack stack = new ItemStack(battery.getItem(), 1, battery.getMeta()); | ||
|
||
if (!consume) return stack; | ||
|
||
var result = inv.tryConsumeItems(Arrays.asList(new BigItemStack(stack)), IPseudoInventory.CONSUME_FUZZY); | ||
|
||
if (!result.leftBoolean()) return null; | ||
|
||
return result.right().get(0).getItemStack(); | ||
} | ||
|
||
@Override | ||
public IItemProvider clone() { | ||
BatteryItemProvider provider = new BatteryItemProvider(); | ||
|
||
provider.battery = new ItemMeta(battery.getItem(), battery.getMeta()); | ||
|
||
return provider; | ||
} | ||
} |
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