Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ dependencies {
compileOnly("com.github.GTNewHorizons:BloodMagic:1.8.5") {transitive = false}
compileOnly("com.github.GTNewHorizons:CraftTweaker:3.4.2:dev") {transitive = false}
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.11:dev") {transitive = false}
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.97:dev") {transitive = false}
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.97:dev") {
exclude module: "Avaritia"
}
compileOnly("com.github.GTNewHorizons:ModularUI2:2.3.25-1.7.10:dev")
compileOnly("com.github.GTNewHorizons:GTNHLib:0.9.0:dev")

compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {transitive = false}
compileOnly("curse.maven:cofh-lib-220333:2388748") {transitive = false}
compileOnly("curse.maven:cofh-core-69162:2388751") {transitive = false}
compileOnly("curse.maven:witchery-69673:2234410") {transitive = false}

runtimeOnly("com.github.GTNewHorizons:GTNHLib:0.7.7:dev")
runtimeOnly("com.github.GTNewHorizons:GTNHLib:0.9.0:dev")
}
78 changes: 78 additions & 0 deletions src/main/java/fox/spiteful/avaritia/Mods.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package fox.spiteful.avaritia;

import java.util.Locale;

import net.minecraft.util.ResourceLocation;

import org.jetbrains.annotations.NotNull;

import com.gtnewhorizon.gtnhlib.util.data.IMod;
import com.gtnewhorizon.gtnhmixins.builders.ITargetMod;
import com.gtnewhorizon.gtnhmixins.builders.TargetModBuilder;

import cpw.mods.fml.common.Loader;

@SuppressWarnings("unused")
public enum Mods implements IMod, ITargetMod {

AE2FluidCraft(Names.A_E2_FLUID_CRAFT),
ModularUI2(Names.MODULAR_U_I_2),

;

public static class Names {

// spotless:off

public static final String A_E2_FLUID_CRAFT = "ae2fc";
public static final String MODULAR_U_I_2 = "modularui2";

// spotless:on
}

public final String ID;
public final String resourceDomain;
protected boolean checkedMod, modLoaded;
protected final TargetModBuilder builder;

Mods(String ID) {
this.ID = ID;
this.resourceDomain = ID.toLowerCase(Locale.ENGLISH);
this.builder = new TargetModBuilder().setModId(getEffectiveModID());
}

@Override
public @NotNull TargetModBuilder getBuilder() {
return builder;
}

@Override
public String getID() {
return ID;
}

protected String getEffectiveModID() {
return ID;
}

public boolean isModLoaded() {
if (!checkedMod) {
this.modLoaded = Loader.isModLoaded(getEffectiveModID());
checkedMod = true;
}
return this.modLoaded;
}

@Override
public String getResourceLocation() {
return resourceDomain;
}

public String getResourcePath(String... path) {
return this.getResourceLocation(path).toString();
}

public ResourceLocation getResourceLocation(String... path) {
return new ResourceLocation(this.resourceDomain, String.join("/", path));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package fox.spiteful.avaritia.blocks;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

import com.cleanroommc.modularui.factory.GuiManager;
import com.cleanroommc.modularui.factory.PosGuiData;
import com.cleanroommc.modularui.factory.TileEntityGuiFactory;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fox.spiteful.avaritia.items.ItemMatterClusterOpener;
import fox.spiteful.avaritia.tile.TileMatterClusterOpener;

public class BlockMatterClusterOpener extends BlockContainer {

public BlockMatterClusterOpener() {
super(Material.iron);

setBlockName("cluster_opener");
setHardness(2f);
setResistance(2f);
}

public static void register() {
LudicrousBlocks.clusterOpener = new BlockMatterClusterOpener();
GameRegistry.registerBlock(LudicrousBlocks.clusterOpener, ItemMatterClusterOpener.class, "cluster_opener");
GameRegistry.registerTileEntity(TileMatterClusterOpener.class, "cluster_opener");
}

@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileMatterClusterOpener();
}

@Override
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX,
float subY, float subZ) {
if (!worldIn.isRemote) {
PosGuiData data = new PosGuiData(player, x, y, z);
GuiManager.open(TileEntityGuiFactory.INSTANCE, data, (EntityPlayerMP) player);
}

return true;
}

@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

world.setBlockMetadataWithNotify(x, y, z, l, 2);
}

@Override
public void onBlockPreDestroy(World worldIn, int x, int y, int z, int meta) {
super.onBlockPreDestroy(worldIn, x, y, z, meta);

((TileMatterClusterOpener) worldIn.getTileEntity(x, y, z)).dropContents();
}

@SideOnly(Side.CLIENT)
private IIcon top, side, front;

@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister reg) {
top = reg.registerIcon("avaritia:cluster_opener/top");
side = reg.registerIcon("avaritia:cluster_opener/side");
front = reg.registerIcon("avaritia:cluster_opener/front");
}

@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) {
// In-world rendering
ForgeDirection dir = ForgeDirection.getOrientation(side);

if (dir == ForgeDirection.UP) return top;
if (dir == ForgeDirection.DOWN) return top;

ForgeDirection front = switch (worldIn.getBlockMetadata(x, y, z)) {
case 0 -> ForgeDirection.NORTH;
case 1 -> ForgeDirection.EAST;
case 2 -> ForgeDirection.SOUTH;
case 3 -> ForgeDirection.WEST;
default -> ForgeDirection.UNKNOWN;
};

return dir == front ? this.front : this.side;
}

@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
// In-hand rendering
ForgeDirection dir = ForgeDirection.getOrientation(side);

if (dir == ForgeDirection.UP) return top;
if (dir == ForgeDirection.DOWN) return top;

return dir == ForgeDirection.SOUTH ? this.front : this.side;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.block.Block;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import fox.spiteful.avaritia.Config;
import fox.spiteful.avaritia.tile.TileEntityCompressor;
Expand All @@ -23,6 +24,8 @@ public class LudicrousBlocks {

public static Block infinitato;

public static Block clusterOpener;

public static void voxelize() {
double_craft = GameRegistry.registerBlock(new BlockDoubleCraft(), "Double_Craft");
triple_craft = GameRegistry.registerBlock(new BlockTripleCraft(), "Triple_Craft");
Expand All @@ -37,5 +40,9 @@ public static void voxelize() {
GameRegistry.registerTileEntity(TileEntityNeutron.class, "Avaritia_Neutron");
compressor = GameRegistry.registerBlock(new BlockCompressor(), "Neutronium_Compressor");
GameRegistry.registerTileEntity(TileEntityCompressor.class, "Avaritia_Compressor");

if (Loader.isModLoaded("gtnhlib") && Loader.isModLoaded("modularui2")) {
BlockMatterClusterOpener.register();
}
}
}
25 changes: 25 additions & 0 deletions src/main/java/fox/spiteful/avaritia/crafting/Grinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,31 @@ public static void artsAndCrafts() {
new ItemStack(Blocks.redstone_block, 1),
'O',
new ItemStack(LudicrousBlocks.resource_block, 1, 0));

if (LudicrousBlocks.clusterOpener != null) {
ExtremeCraftingManager.getInstance().addRecipe(
new ItemStack(LudicrousBlocks.clusterOpener),
"BBBIBIBBB",
"I I",
"E X E",
"IIIIXIIII",
"E X E",
"I I",
"E IXXXI E",
"I I I I",
"BBBHHHBBB",
'X',
// Crystal matrix ingot
new ItemStack(LudicrousItems.resource, 1, 1),
'B',
new ItemStack(Blocks.iron_block, 1),
'I',
new ItemStack(Items.iron_ingot, 1),
'H',
new ItemStack(Blocks.hopper, 1),
'E',
new ItemStack(Blocks.emerald_block, 1));
}
}

}
37 changes: 23 additions & 14 deletions src/main/java/fox/spiteful/avaritia/items/ItemMatterCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ public class ItemMatterCluster extends Item implements ICosmicRenderItem {
public static final String COUNTTAG = "count";
public static final String MAINCOUNTTAG = "total";

public static final int MAX_CAPACITY = 64 * 256;
/// The max number of items a normal cluster will store. Avaritia tools cannot generate clusters bigger than this,
/// and this is the maximum that clusters will automatically combine into.
/// <p/>
/// It's possible to generate a super-critical (>max capacity) cluster via [#makeCluster(ItemStack)] for situations
/// where this limit is too low, but care should be taken to avoid allowing the player to automate those clusters
/// since they can easily be used for near-infinite item storage.
public static final int MAX_NORMAL_CAPACITY = 64 * 256;
public static final int MAX_SUPER_CRITICAL_CAPACITY = Integer.MAX_VALUE;

public IIcon iconFull;
public IIcon cosmicIcon;
Expand Down Expand Up @@ -70,7 +77,9 @@ public void addInformation(ItemStack stack, EntityPlayer player, List<String> to

tooltip.add(
clustertag.getInteger(MAINCOUNTTAG) + "/"
+ Math.max(MAX_CAPACITY, clustertag.getInteger(MAINCOUNTTAG))
+ (clustertag.getInteger(MAINCOUNTTAG) > MAX_SUPER_CRITICAL_CAPACITY
? MAX_SUPER_CRITICAL_CAPACITY
: MAX_NORMAL_CAPACITY)
+ " "
+ StatCollector.translateToLocal("tooltip.matter_cluster.counter"));
tooltip.add("");
Expand Down Expand Up @@ -113,7 +122,7 @@ public static List<ItemStack> makeClusters(List<ItemStack> input) {
ItemStackWrapper wrap = e.getKey();
int wrapcount = e.getValue();

int count = Math.min(MAX_CAPACITY - currentTotal, wrapcount);
int count = Math.min(MAX_NORMAL_CAPACITY - currentTotal, wrapcount);

if (!currentItems.containsKey(e.getKey())) {
currentItems.put(wrap, count);
Expand All @@ -127,7 +136,7 @@ public static List<ItemStack> makeClusters(List<ItemStack> input) {
itemlist.remove(0);
}

if (currentTotal >= MAX_CAPACITY) {
if (currentTotal == MAX_NORMAL_CAPACITY) {
ItemStack cluster = makeCluster(currentItems);

clusters.add(cluster);
Expand Down Expand Up @@ -199,7 +208,7 @@ public static int getClusterSize(ItemStack cluster) {
}

public static boolean isClusterFull(ItemStack cluster) {
return getClusterSize(cluster) >= MAX_CAPACITY;
return getClusterSize(cluster) >= MAX_NORMAL_CAPACITY;
}

public static void setClusterData(ItemStack stack, Map<ItemStackWrapper, Integer> data, int count) {
Expand All @@ -225,20 +234,20 @@ public static void mergeClusters(ItemStack donor, ItemStack recipient) {
int donorcount = getClusterSize(donor);
int recipientcount = getClusterSize(recipient);

if (donorcount == 0 || donorcount >= MAX_CAPACITY || recipientcount >= MAX_CAPACITY) {
if (donorcount == 0 || donorcount >= MAX_NORMAL_CAPACITY || recipientcount >= MAX_NORMAL_CAPACITY) {
return;
}

Map<ItemStackWrapper, Integer> donordata = getClusterData(donor);
Map<ItemStackWrapper, Integer> recipientdata = getClusterData(recipient);
List<Entry<ItemStackWrapper, Integer>> datalist = new ArrayList<>(donordata.entrySet());

while (recipientcount < MAX_CAPACITY && donorcount > 0) {
while (recipientcount < MAX_NORMAL_CAPACITY && donorcount > 0) {
Entry<ItemStackWrapper, Integer> e = datalist.get(0);
ItemStackWrapper wrap = e.getKey();
int wrapcount = e.getValue();

int count = Math.min(MAX_CAPACITY - recipientcount, wrapcount);
int count = Math.min(MAX_NORMAL_CAPACITY - recipientcount, wrapcount);

if (!recipientdata.containsKey(wrap)) {
recipientdata.put(wrap, count);
Expand Down Expand Up @@ -269,7 +278,7 @@ public static void mergeClusters(ItemStack donor, ItemStack recipient) {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
// Do nothing for super critical clusters
if (getClusterSize(stack) > MAX_CAPACITY) return stack;
if (getClusterSize(stack) > MAX_NORMAL_CAPACITY) return stack;

if (!world.isRemote) {
List<ItemStack> drops = ToolHelper.collateMatterClusterContents(ItemMatterCluster.getClusterData(stack));
Expand All @@ -291,7 +300,7 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla
@Override
public IIcon getMaskTexture(ItemStack stack, EntityPlayer player) {
int count = getClusterSize(stack);
if (count >= MAX_CAPACITY) {
if (count >= MAX_NORMAL_CAPACITY) {
return cosmicIconFull;
}
return cosmicIcon;
Expand All @@ -300,13 +309,13 @@ public IIcon getMaskTexture(ItemStack stack, EntityPlayer player) {
@Override
public float getMaskMultiplier(ItemStack stack, EntityPlayer player) {
int count = getClusterSize(stack);
return Math.min(1f, count / (float) MAX_CAPACITY);
return Math.min(1f, count / (float) MAX_NORMAL_CAPACITY);
}

@Override
public IIcon getIcon(ItemStack stack, int pass) {
int count = getClusterSize(stack);
if (count >= MAX_CAPACITY) {
if (count >= MAX_NORMAL_CAPACITY) {
return iconFull;
}
return super.getIcon(stack, pass);
Expand All @@ -320,10 +329,10 @@ public IIcon getIconIndex(ItemStack stack) {
@Override
public String getUnlocalizedName(ItemStack stack) {
int count = getClusterSize(stack);
if (count == MAX_CAPACITY) {
if (count == MAX_NORMAL_CAPACITY) {
return super.getUnlocalizedName(stack) + ".full";
}
if (count > MAX_CAPACITY) {
if (count > MAX_NORMAL_CAPACITY) {
return super.getUnlocalizedName(stack) + ".veryfull";
}
return super.getUnlocalizedName(stack);
Expand Down
Loading