Fixed altar detection
This commit is contained in:
parent
37ec0582eb
commit
a10b2ece9a
|
@ -653,17 +653,16 @@ public class BloodAltar implements IFluidHandler {
|
||||||
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
||||||
IBlockState state = world.getBlockState(componentPos);
|
IBlockState state = world.getBlockState(componentPos);
|
||||||
|
|
||||||
if (altarComponent.getComponent() == EnumAltarComponent.NOTAIR && world.isAirBlock(componentPos))
|
if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) {
|
||||||
return false;
|
if (state.getBlock() instanceof IAltarComponent) {
|
||||||
|
EnumAltarComponent component = ((IAltarComponent) state.getBlock()).getType(world, state, componentPos);
|
||||||
|
if (component == null || component != altarComponent.getComponent())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (state.getBlock() instanceof IAltarComponent) {
|
if (!BloodMagicAPI.INSTANCE.getComponentStates(altarComponent.getComponent()).contains(state))
|
||||||
EnumAltarComponent component = ((IAltarComponent) state.getBlock()).getType(world, state, componentPos);
|
|
||||||
if (component == null || component != altarComponent.getComponent())
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (world.isAirBlock(componentPos))
|
||||||
|
|
||||||
EnumAltarComponent component = BloodMagicAPI.INSTANCE.getAltarComponents().get(state);
|
|
||||||
if (component == null || component != altarComponent.getComponent())
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,28 +670,24 @@ public class BloodAltar implements IFluidHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Pair<BlockPos, EnumAltarComponent> getAltarMissingBlock(World world, BlockPos worldPos, int altarTier) {
|
public static Pair<BlockPos, EnumAltarComponent> getAltarMissingBlock(World world, BlockPos worldPos, int altarTier) {
|
||||||
if (altarTier >= EnumAltarTier.MAXTIERS) {
|
if (altarTier >= EnumAltarTier.MAXTIERS)
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) {
|
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) {
|
||||||
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
||||||
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
|
IBlockState state = world.getBlockState(componentPos);
|
||||||
|
|
||||||
if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) {
|
if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) {
|
||||||
if (worldBlock.getBlock() instanceof IAltarComponent) {
|
if (state.getBlock() instanceof IAltarComponent) {
|
||||||
EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(world, worldBlock.getState(), componentPos);
|
EnumAltarComponent component = ((IAltarComponent) state.getBlock()).getType(world, state, componentPos);
|
||||||
if (component == null || component != altarComponent.getComponent()) {
|
if (component == null || component != altarComponent.getComponent())
|
||||||
return Pair.of(componentPos, altarComponent.getComponent());
|
return Pair.of(componentPos, altarComponent.getComponent());
|
||||||
}
|
|
||||||
} else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent())) {
|
|
||||||
return new ImmutablePair<BlockPos, EnumAltarComponent>(componentPos, altarComponent.getComponent());
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (world.isAirBlock(componentPos)) {
|
if (!BloodMagicAPI.INSTANCE.getComponentStates(altarComponent.getComponent()).contains(state))
|
||||||
return Pair.of(componentPos, altarComponent.getComponent());
|
return Pair.of(componentPos, altarComponent.getComponent());
|
||||||
}
|
} else if (world.isAirBlock(componentPos))
|
||||||
}
|
return Pair.of(componentPos, altarComponent.getComponent());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -2,12 +2,14 @@ package WayofTime.bloodmagic.api_impl;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
||||||
import WayofTime.bloodmagic.apiv2.IBloodMagicAPI;
|
import WayofTime.bloodmagic.apiv2.IBloodMagicAPI;
|
||||||
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
|
|
||||||
public class BloodMagicAPI implements IBloodMagicAPI {
|
public class BloodMagicAPI implements IBloodMagicAPI {
|
||||||
|
|
||||||
|
@ -15,12 +17,12 @@ public class BloodMagicAPI implements IBloodMagicAPI {
|
||||||
|
|
||||||
private final BloodMagicBlacklist blacklist;
|
private final BloodMagicBlacklist blacklist;
|
||||||
private final Map<ResourceLocation, Integer> sacrificialValues;
|
private final Map<ResourceLocation, Integer> sacrificialValues;
|
||||||
private final Map<IBlockState, EnumAltarComponent> altarComponents;
|
private final Multimap<EnumAltarComponent, IBlockState> altarComponents;
|
||||||
|
|
||||||
public BloodMagicAPI() {
|
public BloodMagicAPI() {
|
||||||
this.blacklist = new BloodMagicBlacklist();
|
this.blacklist = new BloodMagicBlacklist();
|
||||||
this.sacrificialValues = Maps.newHashMap();
|
this.sacrificialValues = Maps.newHashMap();
|
||||||
this.altarComponents = Maps.newHashMap();
|
this.altarComponents = ArrayListMultimap.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,14 +45,14 @@ public class BloodMagicAPI implements IBloodMagicAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
altarComponents.put(state, component);
|
altarComponents.put(component, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<ResourceLocation, Integer> getSacrificialValues() {
|
public Map<ResourceLocation, Integer> getSacrificialValues() {
|
||||||
return ImmutableMap.copyOf(sacrificialValues);
|
return ImmutableMap.copyOf(sacrificialValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<IBlockState, EnumAltarComponent> getAltarComponents() {
|
public List<IBlockState> getComponentStates(EnumAltarComponent component) {
|
||||||
return ImmutableMap.copyOf(altarComponents);
|
return (List<IBlockState>) altarComponents.get(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,21 +3,19 @@ package WayofTime.bloodmagic.item;
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.altar.BloodAltar;
|
import WayofTime.bloodmagic.altar.BloodAltar;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import WayofTime.bloodmagic.api.altar.AltarComponent;
|
import WayofTime.bloodmagic.api.altar.*;
|
||||||
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
|
||||||
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
|
|
||||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
|
||||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
|
import WayofTime.bloodmagic.api_impl.BloodMagicAPI;
|
||||||
import WayofTime.bloodmagic.block.BlockAltar;
|
import WayofTime.bloodmagic.block.BlockAltar;
|
||||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||||
import WayofTime.bloodmagic.util.ChatUtil;
|
import WayofTime.bloodmagic.util.ChatUtil;
|
||||||
import WayofTime.bloodmagic.util.Utils;
|
|
||||||
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
||||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
@ -111,9 +109,12 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP
|
||||||
|
|
||||||
for (AltarComponent altarComponent : tierToBuild.getAltarComponents()) {
|
for (AltarComponent altarComponent : tierToBuild.getAltarComponents()) {
|
||||||
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
||||||
Block blockForComponent = Utils.getBlockForComponent(altarComponent.getComponent());
|
if (altarComponent.getComponent() == EnumAltarComponent.NOTAIR) {
|
||||||
|
world.setBlockState(componentPos, Blocks.STONEBRICK.getDefaultState());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
world.setBlockState(componentPos, blockForComponent.getDefaultState(), 3);
|
world.setBlockState(componentPos, BloodMagicAPI.INSTANCE.getComponentStates(altarComponent.getComponent()).get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
((IBloodAltar) world.getTileEntity(pos)).checkTier();
|
((IBloodAltar) world.getTileEntity(pos)).checkTier();
|
||||||
|
@ -134,10 +135,7 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP
|
||||||
else {
|
else {
|
||||||
for (AltarComponent altarComponent : altarTier.getAltarComponents()) {
|
for (AltarComponent altarComponent : altarTier.getAltarComponents()) {
|
||||||
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
||||||
IBlockState componentState = world.getBlockState(pos);
|
|
||||||
|
|
||||||
world.setBlockToAir(componentPos);
|
world.setBlockToAir(componentPos);
|
||||||
world.notifyBlockUpdate(componentPos, componentState, componentState, 3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ public class PluginUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bring core plugin up to top
|
||||||
|
discoveredAnnotations.sort((o1, o2) -> o1.getLeft().getClass().getCanonicalName().startsWith("WayofTime") ? 1 : 0);
|
||||||
return discoveredAnnotations;
|
return discoveredAnnotations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "bloodmagic:block/BlockAlchemyArray",
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [ 10, -45, 170 ],
|
|
||||||
"translation": [ 0, 1.5, -2.75 ],
|
|
||||||
"scale": [ 0.375, 0.375, 0.375 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "bloodmagic:block/BlockBloodLight",
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [ 10, -45, 170 ],
|
|
||||||
"translation": [ 0, 1.5, -2.75 ],
|
|
||||||
"scale": [ 0.375, 0.375, 0.375 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "bloodmagic:block/BlockDimensionalPortal",
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [
|
|
||||||
10,
|
|
||||||
-45,
|
|
||||||
170
|
|
||||||
],
|
|
||||||
"translation": [
|
|
||||||
0,
|
|
||||||
1.5,
|
|
||||||
-2.75
|
|
||||||
],
|
|
||||||
"scale": [
|
|
||||||
0.375,
|
|
||||||
0.375,
|
|
||||||
0.375
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "bloodmagic:block/BlockPedestal0",
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [ 10, -45, 170 ],
|
|
||||||
"translation": [ 0, 1.5, -2.75 ],
|
|
||||||
"scale": [ 0.375, 0.375, 0.375 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "bloodmagic:block/BlockPedestal1",
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [ 10, -45, 170 ],
|
|
||||||
"translation": [ 0, 1.5, -2.75 ],
|
|
||||||
"scale": [ 0.375, 0.375, 0.375 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "bloodmagic:block/BlockPhantom",
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [ 10, -45, 170 ],
|
|
||||||
"translation": [ 0, 1.5, -2.75 ],
|
|
||||||
"scale": [ 0.375, 0.375, 0.375 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "bloodmagic:block/BlockSpectral",
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [ 10, -45, 170 ],
|
|
||||||
"translation": [ 0, 1.5, -2.75 ],
|
|
||||||
"scale": [ 0.375, 0.375, 0.375 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"bloodmagic:item/ItemModelBase",
|
|
||||||
"textures": {
|
|
||||||
"layer0":"bloodmagic:items/WeakBloodOrb"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"bloodmagic:item/ItemModelBase",
|
|
||||||
"textures": {
|
|
||||||
"layer0":"bloodmagic:items/ApprenticeBloodOrb"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"bloodmagic:item/ItemModelBase",
|
|
||||||
"textures": {
|
|
||||||
"layer0":"bloodmagic:items/ArchmageBloodOrb"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"bloodmagic:item/ItemModelBase",
|
|
||||||
"textures": {
|
|
||||||
"layer0":"bloodmagic:items/MagicianBloodOrb"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"bloodmagic:item/ItemModelBase",
|
|
||||||
"textures": {
|
|
||||||
"layer0":"bloodmagic:items/MasterBloodOrb"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"bloodmagic:item/ItemModelBase",
|
|
||||||
"textures": {
|
|
||||||
"layer0":"bloodmagic:items/TranscendentBloodOrb"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"bloodmagic:item/ItemModelBase",
|
|
||||||
"textures": {
|
|
||||||
"layer0":"bloodmagic:items/WeakBloodOrb"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"item/generated"
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"bloodmagic:item/ItemModelBase",
|
|
||||||
"textures": {
|
|
||||||
"layer0":"bloodmagic:items/SentientArmourGem_deactivated"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"bloodmagic:item/ItemModelBase",
|
|
||||||
"textures": {
|
|
||||||
"layer0":"bloodmagic:items/SentientArmourGem_activated"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"parent":"builtin/generated",
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [ 0, 90, -35 ],
|
|
||||||
"translation": [ 0, 1.25, -3.5 ],
|
|
||||||
"scale": [ 0.85, 0.85, 0.85 ]
|
|
||||||
},
|
|
||||||
"firstperson": {
|
|
||||||
"rotation": [ 0, -135, 25 ],
|
|
||||||
"translation": [ 0, 4, 2 ],
|
|
||||||
"scale": [ 1.7, 1.7, 1.7 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue