use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class KnownDimletConfiguration method initMaterialDimlet.
private static void initMaterialDimlet(Block block) {
if (block instanceof BlockLiquid || block == Blocks.LIT_REDSTONE_ORE) {
return;
}
Set<Filter.Feature> features = getBlockFeatures(block);
ResourceLocation nameForObject = Block.REGISTRY.getNameForObject(block);
String mod = nameForObject.getResourceDomain();
for (IBlockState state : block.getBlockState().getValidStates()) {
int meta = state.getBlock().getMetaFromState(state);
ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
if (stack.getItem() != null) {
// Protection
List<IProperty<?>> propertyNames = new ArrayList<>(state.getPropertyKeys());
propertyNames.sort(Comparator.comparing(IProperty::getName));
ImmutableMap<IProperty<?>, Comparable<?>> properties = state.getProperties();
Map<String, String> props = new HashMap<>();
for (Map.Entry<IProperty<?>, Comparable<?>> entry : properties.entrySet()) {
props.put(entry.getKey().getName(), entry.getValue().toString());
}
DimletKey key = new DimletKey(DimletType.DIMLET_MATERIAL, block.getRegistryName() + "@" + meta);
Settings settings = DimletRules.getSettings(key, mod, features, props);
if (!settings.isBlacklisted()) {
knownDimlets.put(key, settings);
}
}
}
}
use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class KnownDimletConfiguration method dumpMob.
private static void dumpMob(String id) {
EntityEntry entry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(id));
Class<? extends Entity> entityClass = entry == null ? null : entry.getEntityClass();
if (entry != null) {
DimletKey key = new DimletKey(DimletType.DIMLET_MOB, id);
String mod = entry.getRegistryName().getResourceDomain();
Settings settings = DimletRules.getSettings(key, mod);
String resourceName = EntityTools.findEntityIdByClass(entityClass);
String readableName = EntityTools.findEntityLocNameByClass(entityClass);
Logging.log(resourceName + " (" + resourceName + ", " + readableName + "): " + settings.toString());
}
}
use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class DimletCraftingTools method matchDimletRecipe.
public static boolean matchDimletRecipe(DimletKey key, ItemStack stackController, ItemStack stackMemory, ItemStack stackEnergy) {
Settings settings = KnownDimletConfiguration.getSettings(key);
if (settings == null) {
return false;
}
int rarity = settings.getRarity();
if (stackController.getItemDamage() != rarity) {
return false;
}
int level = calculateItemLevelFromRarity(rarity);
if (stackMemory.getItemDamage() != level) {
return false;
}
if (stackEnergy.getItemDamage() != level) {
return false;
}
return true;
}
use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class PacketSyncRules method toBytes.
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(rules.size());
for (Pair<Filter, Settings> rule : rules) {
Filter filter = rule.getLeft();
Settings settings = rule.getRight();
filter.toBytes(buf);
settings.toBytes(buf);
}
Logging.log("Rules packet size: " + buf.writerIndex() + " of " + buf.array().length);
}
use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.
the class DimensionEnscriberTileEntity method convertToDimensionDescriptor.
/**
* Convert the dimlets in the inventory to a dimension descriptor.
*/
private DimensionDescriptor convertToDimensionDescriptor() {
List<DimletKey> descriptors = new ArrayList<>();
long forcedSeed = 0;
for (int i = 0; i < DimensionEnscriberContainer.SIZE_DIMLETS; i++) {
ItemStack stack = inventoryHelper.getStackInSlot(i + DimensionEnscriberContainer.SLOT_DIMLETS);
if (ItemStackTools.isValid(stack)) {
DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
Settings settings = KnownDimletConfiguration.getSettings(key);
if (settings != null) {
// Make sure the dimlet is not blacklisted.
descriptors.add(key);
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound != null && tagCompound.getLong("forcedSeed") != 0) {
forcedSeed = tagCompound.getLong("forcedSeed");
}
}
}
inventoryHelper.setStackInSlot(i + DimensionEnscriberContainer.SLOT_DIMLETS, ItemStackTools.getEmptyStack());
}
return new DimensionDescriptor(descriptors, forcedSeed);
}
Aggregations