forked from AE2-UEL/AE2FluidCraft-Rework
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add infinity lava cell
- Loading branch information
zy
committed
Jan 4, 2024
1 parent
d2c6455
commit 2c005e1
Showing
11 changed files
with
225 additions
and
86 deletions.
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
src/main/java/com/glodblock/github/common/item/ItemBaseInfinityStorageCell.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,123 @@ | ||
package com.glodblock.github.common.item; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.inventory.IInventory; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.StatCollector; | ||
|
||
import com.glodblock.github.api.FluidCraftAPI; | ||
import com.glodblock.github.common.storage.IFluidCellInventory; | ||
import com.glodblock.github.common.storage.IFluidCellInventoryHandler; | ||
import com.glodblock.github.common.storage.IStorageFluidCell; | ||
import com.glodblock.github.util.NameConst; | ||
|
||
import appeng.api.AEApi; | ||
import appeng.api.config.FuzzyMode; | ||
import appeng.api.storage.IMEInventoryHandler; | ||
import appeng.api.storage.StorageChannel; | ||
import appeng.api.storage.data.IAEFluidStack; | ||
import appeng.items.AEBaseItem; | ||
import appeng.items.contents.CellUpgrades; | ||
import appeng.tile.inventory.AppEngInternalInventory; | ||
|
||
public abstract class ItemBaseInfinityStorageCell extends AEBaseItem implements IStorageFluidCell { | ||
|
||
protected static class InfinityConfig extends AppEngInternalInventory { | ||
|
||
public InfinityConfig(final ItemStack is) { | ||
super(null, 1); | ||
this.setInventorySlotContents(0, is); | ||
} | ||
|
||
@Override | ||
public void markDirty() {} | ||
} | ||
|
||
@Override | ||
public long getBytes(ItemStack cellItem) { | ||
return Integer.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
public int getBytesPerType(ItemStack cellItem) { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) { | ||
return requestedAddition == null || requestedAddition.getFluid() == null | ||
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass()); | ||
} | ||
|
||
@Override | ||
public abstract IInventory getConfigInventory(ItemStack is); | ||
|
||
@Override | ||
public boolean storableInStorageCell() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isStorageCell(ItemStack i) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public double getIdleDrain(ItemStack is) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getTotalTypes(ItemStack cellItem) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean isEditable(ItemStack is) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public IInventory getUpgradesInventory(ItemStack is) { | ||
return new CellUpgrades(is, 0); | ||
} | ||
|
||
@Override | ||
public FuzzyMode getFuzzyMode(ItemStack is) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) { | ||
|
||
} | ||
|
||
@Override | ||
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines, | ||
final boolean displayMoreInfo) { | ||
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell() | ||
.getCellInventory(stack, null, StorageChannel.FLUIDS); | ||
|
||
if (inventory instanceof final IFluidCellInventoryHandler handler) { | ||
final IFluidCellInventory cellInventory = handler.getCellInv(); | ||
|
||
if (GuiScreen.isCtrlKeyDown()) { | ||
if (!cellInventory.getContents().isEmpty()) { | ||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS)); | ||
for (IAEFluidStack fluid : cellInventory.getContents()) { | ||
if (fluid != null) { | ||
lines.add(String.format(" %s", fluid.getFluidStack().getLocalizedName())); | ||
} | ||
} | ||
} else { | ||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY)); | ||
} | ||
} else { | ||
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE)); | ||
} | ||
} | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/glodblock/github/common/item/ItemInfinityLavaStorageCell.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,41 @@ | ||
package com.glodblock.github.common.item; | ||
|
||
import static com.glodblock.github.util.Util.FluidUtil.lava_bucket; | ||
|
||
import java.util.EnumSet; | ||
|
||
import net.minecraft.inventory.IInventory; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import com.glodblock.github.FluidCraft; | ||
import com.glodblock.github.common.storage.IStorageFluidCell; | ||
import com.glodblock.github.common.tabs.FluidCraftingTabs; | ||
import com.glodblock.github.loader.IRegister; | ||
import com.glodblock.github.util.NameConst; | ||
|
||
import appeng.core.features.AEFeature; | ||
import cpw.mods.fml.common.registry.GameRegistry; | ||
|
||
public class ItemInfinityLavaStorageCell extends ItemBaseInfinityStorageCell | ||
implements IStorageFluidCell, IRegister<ItemInfinityLavaStorageCell> { | ||
|
||
@Override | ||
public IInventory getConfigInventory(ItemStack is) { | ||
return new InfinityConfig(lava_bucket); | ||
} | ||
|
||
public ItemInfinityLavaStorageCell() { | ||
super(); | ||
setUnlocalizedName(NameConst.ITEM_INFINITY_LAVA_FLUID_STORAGE); | ||
setTextureName(FluidCraft.resource(NameConst.ITEM_INFINITY_FLUID_STORAGE).toString()); | ||
this.setFeature(EnumSet.of(AEFeature.StorageCells)); | ||
this.setMaxStackSize(1); | ||
} | ||
|
||
@Override | ||
public ItemInfinityLavaStorageCell register() { | ||
GameRegistry.registerItem(this, NameConst.ITEM_INFINITY_LAVA_FLUID_STORAGE, FluidCraft.MODID); | ||
setCreativeTab(FluidCraftingTabs.INSTANCE); | ||
return this; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/glodblock/github/common/item/ItemInfinityWaterStorageCell.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,41 @@ | ||
package com.glodblock.github.common.item; | ||
|
||
import static com.glodblock.github.util.Util.FluidUtil.water_bucket; | ||
|
||
import java.util.EnumSet; | ||
|
||
import net.minecraft.inventory.IInventory; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import com.glodblock.github.FluidCraft; | ||
import com.glodblock.github.common.storage.IStorageFluidCell; | ||
import com.glodblock.github.common.tabs.FluidCraftingTabs; | ||
import com.glodblock.github.loader.IRegister; | ||
import com.glodblock.github.util.NameConst; | ||
|
||
import appeng.core.features.AEFeature; | ||
import cpw.mods.fml.common.registry.GameRegistry; | ||
|
||
public class ItemInfinityWaterStorageCell extends ItemBaseInfinityStorageCell | ||
implements IStorageFluidCell, IRegister<ItemInfinityWaterStorageCell> { | ||
|
||
@Override | ||
public IInventory getConfigInventory(ItemStack is) { | ||
return new InfinityConfig(water_bucket); | ||
} | ||
|
||
public ItemInfinityWaterStorageCell() { | ||
super(); | ||
setUnlocalizedName(NameConst.ITEM_INFINITY_WATER_FLUID_STORAGE); | ||
setTextureName(FluidCraft.resource(NameConst.ITEM_INFINITY_FLUID_STORAGE).toString()); | ||
this.setFeature(EnumSet.of(AEFeature.StorageCells)); | ||
this.setMaxStackSize(1); | ||
} | ||
|
||
@Override | ||
public ItemInfinityWaterStorageCell register() { | ||
GameRegistry.registerItem(this, NameConst.ITEM_INFINITY_WATER_FLUID_STORAGE, FluidCraft.MODID); | ||
setCreativeTab(FluidCraftingTabs.INSTANCE); | ||
return this; | ||
} | ||
} |
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
Oops, something went wrong.