Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.

Commit

Permalink
Move config to annotation system
Browse files Browse the repository at this point in the history
All old configs must be deleted for this to work properly. Since the rest
of the update is filled with world breaking changes, this should be fine.

Also some mapping updates

(cherry picked from commit d587a8c)
  • Loading branch information
TehNut committed Feb 5, 2018
1 parent a10b2ec commit d99cf77
Show file tree
Hide file tree
Showing 45 changed files with 318 additions and 559 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ buildscript {
plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
id 'com.matthewprenger.cursegradle' version '1.0.9'
id 'io.franzbecker.gradle-lombok' version '1.6'
id 'maven-publish'
}

Expand All @@ -34,8 +35,8 @@ repositories {

dependencies {
deobfCompile "mezz.jei:jei_${mc_version}:${jei_version}"
deobfCompile "mcp.mobius.waila:Hwyla:${waila_version}_${mc_version}"
deobfCompile "info.amerifrance.guideapi:Guide-API:${mc_version}-${guideapi_version}"
deobfCompile "mcp.mobius.waila:Hwyla:${waila_version}"
deobfCompile "info.amerifrance.guideapi:Guide-API:${guideapi_version}"
}

minecraft {
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mod_name=BloodMagic
package_group=com.wayoftime.bloodmagic
mod_version=2.2.0
mc_version=1.12
forge_version=14.21.1.2443
mc_version=1.12.2
forge_version=14.23.2.2611
curse_id=224791

mappings_version=snapshot_20170814
mappings_version=snapshot_20180201

jei_version=4.7.5.85
waila_version=1.8.20-B35
guideapi_version=2.1.4-56
jei_version=4.8.5.147
waila_version=1.8.23-B38_1.12
guideapi_version=1.12-2.1.4-57
5 changes: 2 additions & 3 deletions src/main/java/WayofTime/bloodmagic/BloodMagic.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.io.File;
import java.util.List;

@Mod(modid = BloodMagic.MODID, name = BloodMagic.NAME, version = BloodMagic.VERSION, dependencies = BloodMagic.DEPEND, guiFactory = "WayofTime.bloodmagic.client.gui.config.ConfigGuiFactory")
@Mod(modid = BloodMagic.MODID, name = BloodMagic.NAME, version = BloodMagic.VERSION, dependencies = BloodMagic.DEPEND)
public class BloodMagic {
public static final String MODID = "bloodmagic";
public static final String NAME = "Blood Magic: Alchemical Wizardry";
Expand Down Expand Up @@ -73,8 +73,7 @@ public boolean hasSearchBar() {

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
configDir = new File(event.getModConfigurationDirectory(), "BloodMagic");
ConfigHandler.init(new File(configDir, "BloodMagic.cfg"));
configDir = new File(event.getModConfigurationDirectory(), "bloodmagic");

PLUGINS.addAll(PluginUtil.getPlugins(event.getAsmData()));

Expand Down
421 changes: 92 additions & 329 deletions src/main/java/WayofTime/bloodmagic/ConfigHandler.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static boolean sacrificePlayerHealth(EntityPlayer player) {

if (health > maxHealth / 10.0) {
float sacrificedHealth = health - maxHealth / 10.0f;
int lpAdded = (int) (sacrificedHealth * ConfigHandler.sacrificialDaggerConversion * getModifier(amount));
int lpAdded = (int) (sacrificedHealth * ConfigHandler.values.sacrificialDaggerConversion * getModifier(amount));

SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, (int) sacrificedHealth, lpAdded);
if (MinecraftForge.EVENT_BUS.post(evt))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.ResourceLocation;

import javax.annotation.Nonnull;
import java.util.Set;

public class BloodMagicBlacklist implements IBloodMagicBlacklist {
Expand All @@ -26,49 +27,49 @@ public BloodMagicBlacklist() {
}

@Override
public void addTeleposer(IBlockState state) {
public void addTeleposer(@Nonnull IBlockState state) {
if (!teleposer.contains(state))
teleposer.add(state);
}

@Override
public void addTeleposer(Block block) {
public void addTeleposer(@Nonnull Block block) {
for (IBlockState state : block.getBlockState().getValidStates())
addTeleposer(state);
}

@Override
public void addTeleposer(ResourceLocation entityId) {
public void addTeleposer(@Nonnull ResourceLocation entityId) {
if (!teleposerEntities.contains(entityId))
teleposerEntities.add(entityId);
}

@Override
public void addTransposition(IBlockState state) {
public void addTransposition(@Nonnull IBlockState state) {
if (!transposition.contains(state))
transposition.add(state);
}

@Override
public void addTransposition(Block block) {
public void addTransposition(@Nonnull Block block) {
for (IBlockState state : block.getBlockState().getValidStates())
addTransposition(state);
}

@Override
public void addGreenGrove(IBlockState state) {
public void addGreenGrove(@Nonnull IBlockState state) {
if (!greenGrove.contains(state))
greenGrove.add(state);
}

@Override
public void addGreenGrove(Block block) {
public void addGreenGrove(@Nonnull Block block) {
for (IBlockState state : block.getBlockState().getValidStates())
addGreenGrove(state);
}

@Override
public void addSacrifice(ResourceLocation entityId) {
public void addWellOfSuffering(@Nonnull ResourceLocation entityId) {
if (!sacrifice.contains(entityId))
sacrifice.add(entityId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package WayofTime.bloodmagic.api_impl;

import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.ConfigHandler;
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
import WayofTime.bloodmagic.apiv2.BloodMagicPlugin;
import WayofTime.bloodmagic.apiv2.IBloodMagicAPI;
Expand All @@ -10,8 +11,14 @@
import WayofTime.bloodmagic.block.enums.EnumBloodRune;
import WayofTime.bloodmagic.block.enums.EnumDecorative;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.ForgeRegistries;

@BloodMagicPlugin
public class BloodMagicCorePlugin implements IBloodMagicPlugin {
Expand All @@ -31,10 +38,13 @@ public void register(IBloodMagicAPI api) {
api.getBlacklist().addTransposition(RegistrarBloodMagicBlocks.DEMON_CRYSTAL);
api.getBlacklist().addTeleposer(RegistrarBloodMagicBlocks.INVERSION_PILLAR);
api.getBlacklist().addTransposition(RegistrarBloodMagicBlocks.INVERSION_PILLAR);
api.getBlacklist().addSacrifice(new ResourceLocation("armor_stand"));
api.getBlacklist().addSacrifice(new ResourceLocation(BloodMagic.MODID, "sentient_specter"));
api.getBlacklist().addWellOfSuffering(new ResourceLocation("armor_stand"));
api.getBlacklist().addWellOfSuffering(new ResourceLocation(BloodMagic.MODID, "sentient_specter"));

// TODO - Register things from config
api.setSacrificialValue(new ResourceLocation("armor_stand"), 0);
api.setSacrificialValue(new ResourceLocation(BloodMagic.MODID, "sentient_specter"), 0);

handleConfigValues(api);

// Add standard blocks for altar components
api.registerAltarComponent(Blocks.GLOWSTONE.getDefaultState(), EnumAltarComponent.GLOWSTONE.name());
Expand All @@ -51,4 +61,79 @@ public void register(IBloodMagicAPI api) {
for (EnumBloodRune runeType : EnumBloodRune.values())
api.registerAltarComponent(bloodRune.getDefaultState().withProperty(bloodRune.getProperty(), runeType), EnumAltarComponent.BLOODRUNE.name());
}

private static void handleConfigValues(IBloodMagicAPI api) {
for (String value : ConfigHandler.values.sacrificialValues) {
String[] split = value.split(";");
if (split.length != 2) // Not valid format
continue;

api.setSacrificialValue(new ResourceLocation(split[0]), Integer.parseInt(split[1]));
}

for (String value : ConfigHandler.blacklist.teleposer) {
EntityEntry entityEntry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(value));
if (entityEntry == null) { // It's not an entity (or at least not a valid one), so let's try a block.
String[] blockData = value.split("\\[");
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockData[0]));
if (block == Blocks.AIR || block == null) // Not a valid block either
continue;

if (blockData.length > 1) { // We have properties listed, so let's build a state.
api.getBlacklist().addTeleposer(parseState(value));
continue;
}

api.getBlacklist().addTeleposer(block);
continue;
}

api.getBlacklist().addTeleposer(entityEntry.getRegistryName());
}

for (String value : ConfigHandler.blacklist.transposer) {
String[] blockData = value.split("\\[");
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockData[0]));
if (block == Blocks.AIR || block == null) // Not a valid block
continue;

if (blockData.length > 1) { // We have properties listed, so let's build a state.
api.getBlacklist().addTeleposer(parseState(value));
continue;
}

api.getBlacklist().addTeleposer(block);
}

for (String value : ConfigHandler.blacklist.wellOfSuffering) {
EntityEntry entityEntry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(value));
if (entityEntry == null) // Not a valid entity
continue;

api.getBlacklist().addWellOfSuffering(entityEntry.getRegistryName());
}
}

private static IBlockState parseState(String blockInfo) {
String[] split = blockInfo.split("\\[");
split[1] = split[1].substring(0, split[1].lastIndexOf("]")); // Make sure brackets are removed from state

Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(split[0])); // Find the block
if (block == Blocks.AIR)
return Blocks.AIR.getDefaultState(); // The block is air, so we're looking at invalid data

BlockStateContainer blockState = block.getBlockState();
IBlockState returnState = blockState.getBaseState();

// Force our values into the state
String[] stateValues = split[1].split(","); // Splits up each value
for (String value : stateValues) {
String[] valueSplit = value.split("="); // Separates property and value
IProperty property = blockState.getProperty(valueSplit[0]);
if (property != null)
returnState = returnState.withProperty(property, (Comparable) property.parseValue(valueSplit[1]).get()); // Force the property into the state
}

return returnState;
}
}
18 changes: 10 additions & 8 deletions src/main/java/WayofTime/bloodmagic/apiv2/IBloodMagicBlacklist.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.ResourceLocation;

import javax.annotation.Nonnull;

public interface IBloodMagicBlacklist {

void addTeleposer(IBlockState state);
void addTeleposer(@Nonnull IBlockState state);

void addTeleposer(Block block);
void addTeleposer(@Nonnull Block block);

void addTeleposer(ResourceLocation entityId);
void addTeleposer(@Nonnull ResourceLocation entityId);

void addTransposition(IBlockState state);
void addTransposition(@Nonnull IBlockState state);

void addTransposition(Block block);
void addTransposition(@Nonnull Block block);

void addGreenGrove(IBlockState state);
void addGreenGrove(@Nonnull IBlockState state);

void addGreenGrove(Block block);
void addGreenGrove(@Nonnull Block block);

void addSacrifice(ResourceLocation entityId);
void addWellOfSuffering(@Nonnull ResourceLocation entityId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public BlockRenderLayer getBlockLayer() {

@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
return ConfigHandler.invisibleSpectralBlocks ? EnumBlockRenderType.INVISIBLE : EnumBlockRenderType.MODEL;
return ConfigHandler.client.invisibleSpectralBlocks ? EnumBlockRenderType.INVISIBLE : EnumBlockRenderType.MODEL;
}

@Override
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RenderItemRoutingNode extends TileEntitySpecialRenderer<TileRouting

@Override
public void render(TileRoutingNode tileNode, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
if (mc.player.getHeldItemMainhand().getItem() instanceof INodeRenderer || ConfigHandler.alwaysRenderRoutingLines) {
if (mc.player.getHeldItemMainhand().getItem() instanceof INodeRenderer || ConfigHandler.client.alwaysRenderRoutingLines) {
List<BlockPos> connectionList = tileNode.getConnected();
for (BlockPos wantedPos : connectionList) {
BlockPos offsetPos = wantedPos.subtract(tileNode.getPos());
Expand Down
Loading

0 comments on commit d99cf77

Please sign in to comment.