mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
NTL storage manifest, a bit more compat
This commit is contained in:
parent
f2f317eed3
commit
b0d7b16da3
6
src/main/java/api/hbm/ntl/EnumStorageType.java
Normal file
6
src/main/java/api/hbm/ntl/EnumStorageType.java
Normal file
@ -0,0 +1,6 @@
|
||||
package api.hbm.ntl;
|
||||
|
||||
public enum EnumStorageType {
|
||||
CLUTTER, //potentially unsorted storage (like crates) with many slots that have low capacity
|
||||
MASS //storage with very few lots (usually 1) and very high capacity
|
||||
}
|
||||
29
src/main/java/api/hbm/ntl/IStorageComponent.java
Normal file
29
src/main/java/api/hbm/ntl/IStorageComponent.java
Normal file
@ -0,0 +1,29 @@
|
||||
package api.hbm.ntl;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IStorageComponent {
|
||||
|
||||
/**
|
||||
* @return The type of storage this tile entity represents.
|
||||
*/
|
||||
public EnumStorageType getType();
|
||||
|
||||
/**
|
||||
* @return A StorageManifest instance containing all managed stacks
|
||||
*/
|
||||
public StorageManifest getManifest();
|
||||
|
||||
/**
|
||||
* @return An integer representing the version of the manifest. The higher the numberm, the more recent the manifest
|
||||
* (i.e. always count up), the version has to change every time the manifest updates.
|
||||
*/
|
||||
public int getManifestVersion();
|
||||
|
||||
/**
|
||||
* @param stack The stack to be stored
|
||||
* @param simulate Whether the changes should actually be written or if the operation is only for checking
|
||||
* @return The remainder of the stack after being stored, null if nothing remains
|
||||
*/
|
||||
public ItemStack storeStack(ItemStack stack, boolean simulate);
|
||||
}
|
||||
46
src/main/java/api/hbm/ntl/StorageManifest.java
Normal file
46
src/main/java/api/hbm/ntl/StorageManifest.java
Normal file
@ -0,0 +1,46 @@
|
||||
package api.hbm.ntl;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class StorageManifest {
|
||||
|
||||
public HashMap<Integer, MetaNode> itemMeta = new HashMap();
|
||||
|
||||
public void writeStack(ItemStack stack) {
|
||||
int id = Item.getIdFromItem(stack.getItem());
|
||||
|
||||
MetaNode meta = itemMeta.get(id);
|
||||
|
||||
if(meta == null) {
|
||||
meta = new MetaNode();
|
||||
itemMeta.put(id, meta);
|
||||
}
|
||||
|
||||
NBTNode nbt = meta.metaNBT.get(stack.getItemDamage());
|
||||
|
||||
if(nbt == null) {
|
||||
nbt = new NBTNode();
|
||||
meta.metaNBT.put(stack.getItemDamage(), nbt);
|
||||
}
|
||||
|
||||
long amount = nbt.nbtAmount.containsKey(stack.stackTagCompound) ? nbt.nbtAmount.get(stack.stackTagCompound) : 0;
|
||||
|
||||
amount += stack.stackSize;
|
||||
|
||||
nbt.nbtAmount.put(stack.stackTagCompound, amount);
|
||||
}
|
||||
|
||||
public class MetaNode {
|
||||
|
||||
public HashMap<Integer, NBTNode> metaNBT = new HashMap();
|
||||
}
|
||||
|
||||
public class NBTNode {
|
||||
|
||||
public HashMap<NBTTagCompound, Long> nbtAmount = new HashMap();
|
||||
}
|
||||
}
|
||||
27
src/main/java/api/hbm/ntl/StorageStack.java
Normal file
27
src/main/java/api/hbm/ntl/StorageStack.java
Normal file
@ -0,0 +1,27 @@
|
||||
package api.hbm.ntl;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class StorageStack {
|
||||
|
||||
private ItemStack type;
|
||||
private long amount;
|
||||
|
||||
public StorageStack(ItemStack type) {
|
||||
this(type, type.stackSize);
|
||||
}
|
||||
|
||||
public StorageStack(ItemStack type, long amount) {
|
||||
this.type = type.copy();
|
||||
this.amount = amount;
|
||||
this.type.stackSize = 0;
|
||||
}
|
||||
|
||||
public ItemStack getType() {
|
||||
return this.type.copy();
|
||||
}
|
||||
|
||||
public long getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
}
|
||||
@ -164,11 +164,11 @@ public class FalloutConfigJSON {
|
||||
public FalloutEntry max(double max) { this.maxDist = max; return this; }
|
||||
public FalloutEntry sol(boolean solid) { this.isSolid = solid; return this; }
|
||||
|
||||
public boolean eval(World world, int x, int y, int z, Block b, double dist) {
|
||||
public boolean eval(World world, int x, int y, int z, Block b, int meta, double dist) {
|
||||
|
||||
if(matchesBlock != null && b != matchesBlock) return false;
|
||||
if(matchesMaterial != null && b.getMaterial() != matchesMaterial) return false;
|
||||
if(matchesMeta != -1 && world.getBlockMetadata(x, y, z) != matchesMeta) return false;
|
||||
if(matchesMeta != -1 && meta != matchesMeta) return false;
|
||||
if(matchesOpaque && !b.isOpaqueCube()) return false;
|
||||
if(dist > maxDist || dist < minDist) return false;
|
||||
|
||||
|
||||
@ -2,6 +2,8 @@ package com.hbm.entity.effect;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.BombConfig;
|
||||
import com.hbm.config.FalloutConfigJSON;
|
||||
import com.hbm.config.FalloutConfigJSON.FalloutEntry;
|
||||
import com.hbm.config.VersatileConfig;
|
||||
import com.hbm.saveddata.AuxSavedData;
|
||||
import com.hbm.util.Tuple.Quintet;
|
||||
@ -46,7 +48,6 @@ public class EntityFalloutRain extends Entity {
|
||||
|
||||
if(firstTick) {
|
||||
if (chunksToProcess.isEmpty() && outerChunksToProcess.isEmpty()) gatherChunks();
|
||||
//initConversion();
|
||||
firstTick = false;
|
||||
}
|
||||
|
||||
@ -130,6 +131,9 @@ public class EntityFalloutRain extends Entity {
|
||||
int depth = 0;
|
||||
|
||||
for(int y = 255; y >= 0; y--) {
|
||||
|
||||
if(depth >= 3)
|
||||
return;
|
||||
|
||||
Block b = worldObj.getBlock(x, y, z);
|
||||
Block ab = worldObj.getBlock(x, y + 1, z);
|
||||
@ -152,6 +156,24 @@ public class EntityFalloutRain extends Entity {
|
||||
if(rand.nextInt(5) == 0)
|
||||
worldObj.setBlock(x, y + 1, z, Blocks.fire);
|
||||
}
|
||||
|
||||
boolean eval = false;
|
||||
|
||||
for(FalloutEntry entry : FalloutConfigJSON.entries) {
|
||||
|
||||
if(entry.eval(worldObj, x, y, z, b, meta, dist)) {
|
||||
if(entry.isSolid()) {
|
||||
depth++;
|
||||
}
|
||||
|
||||
eval = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!eval && b.isNormalCube()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (b == Blocks.leaves || b == Blocks.leaves2) {
|
||||
worldObj.setBlock(x, y, z, Blocks.air);
|
||||
@ -244,24 +266,6 @@ public class EntityFalloutRain extends Entity {
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/*public HashMap<Block, BlockConversion> directConversions = new HashMap();
|
||||
|
||||
private void initConversion() {
|
||||
|
||||
directConversions.put(Blocks.stone, new BlockConversion() { @Override public boolean convert() {
|
||||
if(dist < 5) set(ModBlocks.sellafield_1);
|
||||
else if(dist < 15) set(ModBlocks.sellafield_0);
|
||||
else if(dist < 75) set(ModBlocks.sellafield_slaked);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
directConversions.put(Blocks.grass, new BlockConversion() { boolean convert() { set(ModBlocks.waste_earth); return false; }});
|
||||
directConversions.put(Blocks.mycelium, new BlockConversion() { boolean convert() { set(ModBlocks.waste_mycelium); return false; }});
|
||||
directConversions.put(Blocks.leaves, new BlockConversion() { boolean convert() { destroy(); return false; }});
|
||||
directConversions.put(Blocks.leaves2, new BlockConversion() { boolean convert() { destroy(); return false; }});
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
@ -311,41 +315,4 @@ public class EntityFalloutRain extends Entity {
|
||||
int scale = this.dataWatcher.getWatchableObjectInt(16);
|
||||
return scale == 0 ? 1 : scale;
|
||||
}
|
||||
|
||||
/*private abstract class BlockConversion {
|
||||
|
||||
protected World world;
|
||||
protected int x;
|
||||
protected int y;
|
||||
protected int z;
|
||||
protected double dist;
|
||||
|
||||
public boolean invoke(World world, int x, int y, int z, double dist) {
|
||||
this.world = world;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.dist = dist;
|
||||
|
||||
return convert();
|
||||
}
|
||||
|
||||
abstract boolean convert();
|
||||
|
||||
protected void destroy() {
|
||||
world.setBlock(x, y, z, Blocks.air);
|
||||
}
|
||||
|
||||
protected void set(Block b) {
|
||||
world.setBlock(x, y, z, b);
|
||||
}
|
||||
|
||||
protected void setChance(Block b, float f) {
|
||||
if(world.rand.nextFloat() < f) world.setBlock(x, y, z, b);
|
||||
}
|
||||
|
||||
protected void setConditional(Block b, float f) {
|
||||
if(world.rand.nextFloat() < f) world.setBlock(x, y, z, b);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@ -67,24 +67,6 @@ public class HazmatRegistry {
|
||||
HazmatRegistry.registerHazmat(ModItems.hazmat_legs_grey, hazGray * legs);
|
||||
HazmatRegistry.registerHazmat(ModItems.hazmat_boots_grey, hazGray * boots);
|
||||
|
||||
Item rec_helmet = Compat.tryLoadItem(Compat.MOD_REC, "reactorcraft_item_hazhelmet");
|
||||
Item rec_chest = Compat.tryLoadItem(Compat.MOD_REC, "reactorcraft_item_hazchest");
|
||||
Item rec_legs = Compat.tryLoadItem(Compat.MOD_REC, "reactorcraft_item_hazlegs");
|
||||
Item rec_boots = Compat.tryLoadItem(Compat.MOD_REC, "reactorcraft_item_hazboots");
|
||||
if(rec_helmet != null) HazmatRegistry.registerHazmat(rec_helmet, hazGray * helmet);
|
||||
if(rec_chest != null) HazmatRegistry.registerHazmat(rec_chest, hazGray * chest);
|
||||
if(rec_legs != null) HazmatRegistry.registerHazmat(rec_legs, hazGray * legs);
|
||||
if(rec_boots != null) HazmatRegistry.registerHazmat(rec_boots, hazGray * boots);
|
||||
|
||||
Item efn_helmet = Compat.tryLoadItem(Compat.MOD_EF, "netherite_helmet");
|
||||
Item efn_chest = Compat.tryLoadItem(Compat.MOD_EF, "netherite_chestplate");
|
||||
Item efn_legs = Compat.tryLoadItem(Compat.MOD_EF, "netherite_leggings");
|
||||
Item efn_boots = Compat.tryLoadItem(Compat.MOD_EF, "netherite_boots");
|
||||
if(efn_helmet != null) HazmatRegistry.registerHazmat(efn_helmet, star * helmet);
|
||||
if(efn_chest != null) HazmatRegistry.registerHazmat(efn_chest, star * chest);
|
||||
if(efn_legs != null) HazmatRegistry.registerHazmat(efn_legs, star * legs);
|
||||
if(efn_boots != null) HazmatRegistry.registerHazmat(efn_boots, star * boots);
|
||||
|
||||
HazmatRegistry.registerHazmat(ModItems.liquidator_helmet, liquidator * helmet);
|
||||
HazmatRegistry.registerHazmat(ModItems.liquidator_plate, liquidator * chest);
|
||||
HazmatRegistry.registerHazmat(ModItems.liquidator_legs, liquidator * legs);
|
||||
@ -204,6 +186,8 @@ public class HazmatRegistry {
|
||||
HazmatRegistry.registerHazmat(ModItems.euphemium_plate, euph * chest);
|
||||
HazmatRegistry.registerHazmat(ModItems.euphemium_legs, euph * legs);
|
||||
HazmatRegistry.registerHazmat(ModItems.euphemium_boots, euph * boots);
|
||||
|
||||
Compat.registerCompatHazmat();
|
||||
}
|
||||
|
||||
private static HashMap<Item, Double> entries = new HashMap();
|
||||
|
||||
@ -3,6 +3,7 @@ package com.hbm.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.handler.HazmatRegistry;
|
||||
import com.hbm.hazard.HazardRegistry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
@ -93,4 +94,42 @@ public class Compat {
|
||||
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public static void registerCompatHazmat() {
|
||||
|
||||
double helmet = 0.2D;
|
||||
double chest = 0.4D;
|
||||
double legs = 0.3D;
|
||||
double boots = 0.1D;
|
||||
|
||||
double p90 = 1.0D; // 90%
|
||||
double p99 = 2D; // 99%
|
||||
|
||||
tryRegisterHazmat(Compat.MOD_GT6, "gt.armor.hazmat.radiation.head", p90 * helmet);
|
||||
tryRegisterHazmat(Compat.MOD_GT6, "gt.armor.hazmat.radiation.chest", p90 * chest);
|
||||
tryRegisterHazmat(Compat.MOD_GT6, "gt.armor.hazmat.radiation.legs", p90 * legs);
|
||||
tryRegisterHazmat(Compat.MOD_GT6, "gt.armor.hazmat.radiation.boots", p90 * boots);
|
||||
|
||||
tryRegisterHazmat(Compat.MOD_GT6, "gt.armor.hazmat.universal.head", p99 * helmet);
|
||||
tryRegisterHazmat(Compat.MOD_GT6, "gt.armor.hazmat.universal.chest", p99 * chest);
|
||||
tryRegisterHazmat(Compat.MOD_GT6, "gt.armor.hazmat.universal.legs", p99 * legs);
|
||||
tryRegisterHazmat(Compat.MOD_GT6, "gt.armor.hazmat.universal.boots", p99 * boots);
|
||||
|
||||
tryRegisterHazmat(Compat.MOD_REC, "reactorcraft_item_hazhelmet", p99 * helmet);
|
||||
tryRegisterHazmat(Compat.MOD_REC, "reactorcraft_item_hazchest", p99 * chest);
|
||||
tryRegisterHazmat(Compat.MOD_REC, "reactorcraft_item_hazlegs", p99 * legs);
|
||||
tryRegisterHazmat(Compat.MOD_REC, "reactorcraft_item_hazboots", p99 * boots);
|
||||
|
||||
tryRegisterHazmat(Compat.MOD_EF, "netherite_helmet", p90 * helmet);
|
||||
tryRegisterHazmat(Compat.MOD_EF, "netherite_chestplate", p90 * chest);
|
||||
tryRegisterHazmat(Compat.MOD_EF, "netherite_leggings", p90 * legs);
|
||||
tryRegisterHazmat(Compat.MOD_EF, "netherite_boots", p90 * boots);
|
||||
}
|
||||
|
||||
private static void tryRegisterHazmat(String mod, String name, double resistance) {
|
||||
Item item = Compat.tryLoadItem(mod, name);
|
||||
if(item != null) {
|
||||
HazmatRegistry.registerHazmat(item, resistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 285 B |
Binary file not shown.
|
After Width: | Height: | Size: 292 B |
Loading…
x
Reference in New Issue
Block a user