Skip to content

Commit

Permalink
Fix ComponentException when calling getID() on a BWBlock through Worl…
Browse files Browse the repository at this point in the history
…d.getBlock() (#270)
  • Loading branch information
ExE-Boss authored and RX14 committed Feb 26, 2017
1 parent 4872e5f commit 5b4dc92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraft.util.AxisAlignedBB;
import nova.core.block.Block;
import nova.core.block.BlockFactory;
import nova.core.component.misc.FactoryProvider;
import nova.core.entity.Entity;
import nova.core.entity.EntityFactory;
import nova.core.item.Item;
Expand Down Expand Up @@ -82,7 +83,10 @@ public Optional<Block> getBlock(Vector3D position) {
} else if (mcBlock instanceof FWBlock) {
return Optional.of(((FWBlock) mcBlock).getBlockInstance(access, position));
} else {
return Optional.of(new BWBlock(mcBlock, this, position));
BWBlock block = new BWBlock(mcBlock, this, position);
Game.blocks().get(net.minecraft.block.Block.blockRegistry.getNameForObject(block))
.ifPresent(blockFactory -> block.components.getOrAdd(new FactoryProvider(blockFactory)));
return Optional.of(block);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.minecraft.util.BlockPos;
import nova.core.block.Block;
import nova.core.block.BlockFactory;
import nova.core.component.misc.FactoryProvider;
import nova.core.entity.Entity;
import nova.core.entity.EntityFactory;
import nova.core.item.Item;
Expand Down Expand Up @@ -86,7 +87,10 @@ public Optional<Block> getBlock(Vector3D position) {
} else if (mcBlock instanceof FWBlock) {
return Optional.of(((FWBlock) mcBlock).getBlockInstance(access, position));
} else {
return Optional.of(new BWBlock(mcBlock, this, position));
BWBlock block = new BWBlock(mcBlock, this, position);
Game.blocks().get(net.minecraft.block.Block.blockRegistry.getNameForObject(block).toString())
.ifPresent(blockFactory -> block.components.getOrAdd(new FactoryProvider(blockFactory)));
return Optional.of(block);
}
}

Expand Down

0 comments on commit 5b4dc92

Please sign in to comment.