Several mimic fixes, with actually cleaned up commit history. (#1379)

* Reimplemented a lot of mimic logic and did a first run of changing how mimics store their states.

* Finished removing all metadata calls for blocks replaced by mimics.

* Update EntityMimic.java

* Update ItemBlockMimic.java

* Update TileMimic.java

* How did I even replace a semicolon with a slash.

* Changed all tabs to 4 spaces. Changed Serializer to StateUtil

* Fixed spacing again, hopefully for the last time
This commit is contained in:
KohaiKhaos 2018-08-07 18:28:55 -05:00 committed by Nick Ignoffo
parent 7954d04421
commit ebfd8ce9a3
6 changed files with 238 additions and 52 deletions

View file

@ -15,6 +15,7 @@ import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.core.RegistrarBloodMagicRecipes;
import WayofTime.bloodmagic.incense.EnumTranquilityType;
import WayofTime.bloodmagic.incense.TranquilityStack;
import WayofTime.bloodmagic.util.StateUtil;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
@ -116,7 +117,7 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin
if (blockData.length > 1)
{ // We have properties listed, so let's build a state.
api.getBlacklist().addTeleposer(parseState(value));
api.getBlacklist().addTeleposer(StateUtil.parseState(value));
continue;
}
@ -136,7 +137,7 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin
if (blockData.length > 1)
{ // We have properties listed, so let's build a state.
api.getBlacklist().addTeleposer(parseState(value));
api.getBlacklist().addTeleposer(StateUtil.parseState(value));
continue;
}
@ -152,29 +153,4 @@ public class BloodMagicCorePlugin implements IBloodMagicPlugin
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;
}
}
}