refactor: Flattened the runestone blocks
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package electroblob.wizardry.block;
|
||||
|
||||
import electroblob.wizardry.api.IElemental;
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.registry.WizardryTabs;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -11,7 +12,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class BlockCrystal extends Block {
|
||||
public class BlockCrystal extends Block implements IElemental {
|
||||
|
||||
private static final EnumMap<Element, MapColor> map_colours = new EnumMap<>(Element.class);
|
||||
|
||||
@@ -26,6 +27,9 @@ public class BlockCrystal extends Block {
|
||||
map_colours.put(Element.HEALING, MapColor.YELLOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getElement() { return element; }
|
||||
|
||||
private final Element element;
|
||||
|
||||
public BlockCrystal(Element element) {
|
||||
|
||||
@@ -5,24 +5,15 @@ import electroblob.wizardry.registry.WizardryTabs;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class BlockRunestone extends Block {
|
||||
|
||||
public static final PropertyEnum<Element> ELEMENT = PropertyEnum.create("element", Element.class,
|
||||
Arrays.copyOfRange(Element.values(), 1, Element.values().length)); // Everything except MAGIC
|
||||
|
||||
private static final EnumMap<Element, MapColor> map_colours = new EnumMap<>(Element.class);
|
||||
|
||||
static {
|
||||
@@ -34,54 +25,24 @@ public class BlockRunestone extends Block {
|
||||
map_colours.put(Element.SORCERY, MapColor.GRAY);
|
||||
map_colours.put(Element.HEALING, MapColor.YELLOW_STAINED_HARDENED_CLAY);
|
||||
}
|
||||
|
||||
public BlockRunestone(Material material){
|
||||
|
||||
private final Element element;
|
||||
|
||||
public BlockRunestone(Material material, Element element) {
|
||||
super(material);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(ELEMENT, Element.FIRE));
|
||||
this.setCreativeTab(WizardryTabs.WIZARDRY);
|
||||
this.setCreativeTab(WizardryTabs.WIZARDRY);
|
||||
this.setHardness(1.5F);
|
||||
this.setResistance(10.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state){
|
||||
return state.getValue(ELEMENT).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapColor getMapColor(IBlockState state, IBlockAccess world, BlockPos pos){
|
||||
return map_colours.get(state.getProperties().get(ELEMENT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> items){
|
||||
if(this.getCreativeTab() == tab){
|
||||
for(Element element : Arrays.copyOfRange(Element.values(), 1, Element.values().length)){
|
||||
items.add(new ItemStack(this, 1, element.ordinal()));
|
||||
}
|
||||
}
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
public Element getElement() { return element; }
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer(){
|
||||
public MapColor getMapColor(IBlockState state, IBlockAccess world, BlockPos pos) { return map_colours.get(element); }
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.CUTOUT; // Required to shade parts of the block faces differently to others
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int metadata){
|
||||
Element element = Element.values()[metadata];
|
||||
if(!ELEMENT.getAllowedValues().contains(element)) return this.getDefaultState();
|
||||
return this.getDefaultState().withProperty(ELEMENT, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state){
|
||||
return state.getValue(ELEMENT).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState(){
|
||||
return new BlockStateContainer(this, ELEMENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
-43
@@ -1,5 +1,6 @@
|
||||
package electroblob.wizardry.block;
|
||||
|
||||
import electroblob.wizardry.api.IElemental;
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.registry.WizardryTabs;
|
||||
import electroblob.wizardry.tileentity.TileEntityShrineCore;
|
||||
@@ -8,28 +9,20 @@ import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class BlockPedestal extends Block implements ITileEntityProvider {
|
||||
|
||||
public static final PropertyEnum<Element> ELEMENT = PropertyEnum.create("element", Element.class,
|
||||
Arrays.copyOfRange(Element.values(), 1, Element.values().length)); // Everything except MAGIC
|
||||
public class BlockRunestonePedestal extends Block implements ITileEntityProvider, IElemental {
|
||||
|
||||
// A 'natural' pedestal is one that was generated as part of a structure, is unbreakable and has a tileentity
|
||||
public static final PropertyBool NATURAL = PropertyBool.create("natural");
|
||||
@@ -46,80 +39,66 @@ public class BlockPedestal extends Block implements ITileEntityProvider {
|
||||
map_colours.put(Element.HEALING, MapColor.YELLOW_STAINED_HARDENED_CLAY);
|
||||
}
|
||||
|
||||
public BlockPedestal(Material material){
|
||||
private final Element element;
|
||||
|
||||
public BlockRunestonePedestal(Material material, Element element) {
|
||||
super(material);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(ELEMENT, Element.FIRE).withProperty(NATURAL, false));
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(NATURAL, false));
|
||||
this.setCreativeTab(WizardryTabs.WIZARDRY);
|
||||
this.setHardness(1.5F);
|
||||
this.setResistance(10.0F);
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state){
|
||||
return state.getValue(ELEMENT).ordinal(); // Ignore the NATURAL state here, it's unobtainable
|
||||
public Element getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapColor getMapColor(IBlockState state, IBlockAccess world, BlockPos pos){
|
||||
return map_colours.get(state.getProperties().get(ELEMENT));
|
||||
public MapColor getMapColor(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return map_colours.get(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> items){
|
||||
// Ignore the NATURAL state here, it's unobtainable
|
||||
if(this.getCreativeTab() == tab){
|
||||
for(Element element : Arrays.copyOfRange(Element.values(), 1, Element.values().length)){
|
||||
items.add(new ItemStack(this, 1, element.ordinal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer(){
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.CUTOUT; // Required to shade parts of the block faces differently to others
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState state, World world, BlockPos pos){
|
||||
public float getBlockHardness(IBlockState state, World world, BlockPos pos) {
|
||||
return state.getValue(NATURAL) ? -1 : super.getBlockHardness(state, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance(World world, BlockPos pos, @Nullable Entity exploder, Explosion explosion){
|
||||
public float getExplosionResistance(World world, BlockPos pos, @Nullable Entity exploder, Explosion explosion) {
|
||||
return world.getBlockState(pos).getValue(NATURAL) ? 6000000.0F : super.getExplosionResistance(world, pos, exploder, explosion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state){
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return state.getValue(NATURAL); // Only naturally-generated pedestals have a (shrine core) tile entity
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta){
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityShrineCore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int metadata){
|
||||
boolean natural = false;
|
||||
if(metadata > ELEMENT.getAllowedValues().size()){
|
||||
natural = true;
|
||||
metadata -= ELEMENT.getAllowedValues().size();
|
||||
}
|
||||
Element element = Element.values()[metadata];
|
||||
if(!ELEMENT.getAllowedValues().contains(element)) return this.getDefaultState().withProperty(NATURAL, natural);
|
||||
return this.getDefaultState().withProperty(ELEMENT, element).withProperty(NATURAL, natural);
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(NATURAL, meta == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state){
|
||||
return state.getValue(ELEMENT).ordinal() + (state.getValue(NATURAL) ? ELEMENT.getAllowedValues().size() : 0);
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(NATURAL) ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState(){
|
||||
return new BlockStateContainer(this, ELEMENT, NATURAL);
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, NATURAL);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
package electroblob.wizardry.client.model;
|
||||
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import electroblob.wizardry.block.BlockCrystal;
|
||||
import electroblob.wizardry.block.BlockPedestal;
|
||||
import electroblob.wizardry.block.BlockRunestone;
|
||||
import electroblob.wizardry.block.BlockRunestonePedestal;
|
||||
import electroblob.wizardry.item.IMultiTexturedItem;
|
||||
import electroblob.wizardry.item.ItemBlockMultiTextured;
|
||||
import electroblob.wizardry.item.ItemCrystal;
|
||||
import electroblob.wizardry.item.ItemSpectralDust;
|
||||
import electroblob.wizardry.registry.WizardryBlocks;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
@@ -50,17 +46,6 @@ public final class WizardryModels {
|
||||
@SubscribeEvent
|
||||
public static void register(ModelRegistryEvent event){
|
||||
|
||||
// ItemBlocks
|
||||
ModelLoader.setCustomStateMapper(WizardryBlocks.runestone, new StateMap.Builder()
|
||||
.withName(BlockRunestone.ELEMENT).withSuffix("_runestone").build());
|
||||
ItemBlockMultiTextured runestoneItem = (ItemBlockMultiTextured)Item.getItemFromBlock(WizardryBlocks.runestone);
|
||||
registerMultiTexturedModel(runestoneItem);
|
||||
|
||||
ModelLoader.setCustomStateMapper(WizardryBlocks.runestone_pedestal, new StateMap.Builder()
|
||||
.withName(BlockPedestal.ELEMENT).ignore(BlockPedestal.NATURAL).withSuffix("_runestone_pedestal").build()); // Don't care about NATURAL property
|
||||
ItemBlockMultiTextured pedestalItem = (ItemBlockMultiTextured)Item.getItemFromBlock(WizardryBlocks.runestone_pedestal);
|
||||
registerMultiTexturedModel(pedestalItem);
|
||||
|
||||
ModelLoader.setCustomStateMapper(WizardryBlocks.gilded_wood, new StateMap.Builder()
|
||||
.withName(BlockPlanks.VARIANT).withSuffix("_gilded_wood").build());
|
||||
ItemBlockMultiTextured gildedWoodItem = (ItemBlockMultiTextured)Item.getItemFromBlock(WizardryBlocks.gilded_wood);
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package electroblob.wizardry.item;
|
||||
|
||||
import electroblob.wizardry.api.IElemental;
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.registry.WizardryTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
/** Note that in 1.13, <i>the flattening</i> will make this class redundant, much like ItemCoal, which is probably its
|
||||
* closest analog in vanilla. */
|
||||
public class ItemCrystal extends Item {
|
||||
public class ItemCrystal extends Item implements IElemental {
|
||||
|
||||
public ItemCrystal(){
|
||||
private final Element element;
|
||||
|
||||
public ItemCrystal(Element element) {
|
||||
super();
|
||||
this.setMaxDamage(0);
|
||||
this.setCreativeTab(WizardryTabs.WIZARDRY);
|
||||
}
|
||||
this.setMaxDamage(0);
|
||||
this.setCreativeTab(WizardryTabs.WIZARDRY);
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getElement() { return element; }
|
||||
}
|
||||
|
||||
@@ -68,7 +68,21 @@ public final class WizardryBlocks {
|
||||
public static final Block permafrost = placeholder();
|
||||
|
||||
public static final Block runestone = placeholder();
|
||||
public static final Block runestone_pedestal = placeholder();
|
||||
public static final Block fire_runestone = placeholder();
|
||||
public static final Block ice_runestone = placeholder();
|
||||
public static final Block lightning_runestone = placeholder();
|
||||
public static final Block necromancy_runestone = placeholder();
|
||||
public static final Block earth_runestone = placeholder();
|
||||
public static final Block sorcery_runestone = placeholder();
|
||||
public static final Block healing_runestone = placeholder();
|
||||
|
||||
public static final Block fire_runestone_pedestal = placeholder();
|
||||
public static final Block ice_runestone_pedestal = placeholder();
|
||||
public static final Block lightning_runestone_pedestal = placeholder();
|
||||
public static final Block necromancy_runestone_pedestal = placeholder();
|
||||
public static final Block earth_runestone_pedestal = placeholder();
|
||||
public static final Block healing_runestone_pedestal = placeholder();
|
||||
public static final Block sorcery_runestone_pedestal = placeholder();
|
||||
|
||||
public static final Block gilded_wood = placeholder();
|
||||
|
||||
@@ -140,8 +154,21 @@ public final class WizardryBlocks {
|
||||
registerBlock(registry, "crystal_flower_pot", new BlockCrystalFlowerPot());
|
||||
registerBlock(registry, "permafrost", new BlockPermafrost());
|
||||
|
||||
registerBlock(registry, "runestone", new BlockRunestone(Material.ROCK));
|
||||
registerBlock(registry, "runestone_pedestal", new BlockPedestal(Material.ROCK));
|
||||
registerBlock(registry, "fire_runestone", new BlockRunestone(Material.ROCK, Element.FIRE));
|
||||
registerBlock(registry, "ice_runestone", new BlockRunestone(Material.ROCK, Element.ICE));
|
||||
registerBlock(registry, "lightning_runestone", new BlockRunestone(Material.ROCK, Element.LIGHTNING));
|
||||
registerBlock(registry, "necromancy_runestone", new BlockRunestone(Material.ROCK, Element.NECROMANCY));
|
||||
registerBlock(registry, "earth_runestone", new BlockRunestone(Material.ROCK, Element.EARTH));
|
||||
registerBlock(registry, "sorcery_runestone", new BlockRunestone(Material.ROCK, Element.SORCERY));
|
||||
registerBlock(registry, "healing_runestone", new BlockRunestone(Material.ROCK, Element.HEALING));
|
||||
|
||||
registerBlock(registry, "fire_runestone_pedestal", new BlockRunestonePedestal(Material.ROCK, Element.FIRE));
|
||||
registerBlock(registry, "ice_runestone_pedestal", new BlockRunestonePedestal(Material.ROCK, Element.ICE));
|
||||
registerBlock(registry, "lightning_runestone_pedestal", new BlockRunestonePedestal(Material.ROCK, Element.LIGHTNING));
|
||||
registerBlock(registry, "necromancy_runestone_pedestal", new BlockRunestonePedestal(Material.ROCK, Element.NECROMANCY));
|
||||
registerBlock(registry, "earth_runestone_pedestal", new BlockRunestonePedestal(Material.ROCK, Element.EARTH));
|
||||
registerBlock(registry, "healing_runestone_pedestal", new BlockRunestonePedestal(Material.ROCK, Element.HEALING));
|
||||
registerBlock(registry, "sorcery_runestone_pedestal", new BlockRunestonePedestal(Material.ROCK, Element.SORCERY));
|
||||
|
||||
registerBlock(registry, "gilded_wood", new BlockGildedWood());
|
||||
|
||||
|
||||
@@ -569,8 +569,14 @@ public final class WizardryItems {
|
||||
registerItemBlock(registry, WizardryBlocks.sorcery_crystal_block);
|
||||
registerItemBlock(registry, WizardryBlocks.healing_crystal_block);
|
||||
|
||||
registerMultiTexturedItemBlock(registry, WizardryBlocks.runestone, false, elements);
|
||||
registerMultiTexturedItemBlock(registry, WizardryBlocks.runestone_pedestal, false, elements);
|
||||
registerItemBlock(registry, WizardryBlocks.fire_runestone);
|
||||
registerItemBlock(registry, WizardryBlocks.ice_runestone);
|
||||
registerItemBlock(registry, WizardryBlocks.lightning_runestone);
|
||||
registerItemBlock(registry, WizardryBlocks.necromancy_runestone);
|
||||
registerItemBlock(registry, WizardryBlocks.earth_runestone);
|
||||
registerItemBlock(registry, WizardryBlocks.sorcery_runestone);
|
||||
registerItemBlock(registry, WizardryBlocks.healing_runestone);
|
||||
|
||||
registerMultiTexturedItemBlock(registry, WizardryBlocks.gilded_wood, true, woodTypes);
|
||||
|
||||
registerItemBlock(registry, WizardryBlocks.oak_bookshelf);
|
||||
@@ -592,14 +598,14 @@ public final class WizardryItems {
|
||||
|
||||
// Items
|
||||
|
||||
registerItem(registry, "magic_crystal", new ItemCrystal());
|
||||
registerItem(registry, "earth_crystal", new ItemCrystal());
|
||||
registerItem(registry, "fire_crystal", new ItemCrystal());
|
||||
registerItem(registry, "healing_crystal", new ItemCrystal());
|
||||
registerItem(registry, "ice_crystal", new ItemCrystal());
|
||||
registerItem(registry, "lightning_crystal", new ItemCrystal());
|
||||
registerItem(registry, "necromancy_crystal", new ItemCrystal());
|
||||
registerItem(registry, "sorcery_crystal", new ItemCrystal());
|
||||
registerItem(registry, "magic_crystal", new ItemCrystal(Element.MAGIC));
|
||||
registerItem(registry, "earth_crystal", new ItemCrystal(Element.EARTH));
|
||||
registerItem(registry, "fire_crystal", new ItemCrystal(Element.FIRE));
|
||||
registerItem(registry, "healing_crystal", new ItemCrystal(Element.HEALING));
|
||||
registerItem(registry, "ice_crystal", new ItemCrystal(Element.ICE));
|
||||
registerItem(registry, "lightning_crystal", new ItemCrystal(Element.LIGHTNING));
|
||||
registerItem(registry, "necromancy_crystal", new ItemCrystal(Element.NECROMANCY));
|
||||
registerItem(registry, "sorcery_crystal", new ItemCrystal(Element.SORCERY));
|
||||
|
||||
registerItem(registry, "crystal_shard", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
|
||||
registerItem(registry, "grand_crystal", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package electroblob.wizardry.tileentity;
|
||||
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import electroblob.wizardry.block.BlockPedestal;
|
||||
import electroblob.wizardry.api.IElemental;
|
||||
import electroblob.wizardry.block.BlockRunestonePedestal;
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.entity.living.EntityEvilWizard;
|
||||
import electroblob.wizardry.entity.living.EntityWizard;
|
||||
import electroblob.wizardry.packet.PacketConquerShrine;
|
||||
@@ -101,7 +103,8 @@ public class TileEntityShrineCore extends TileEntity implements ITickable {
|
||||
}
|
||||
|
||||
wizard.setLocationAndAngles(x1, y1 + 0.5, z1, 0, 0);
|
||||
wizard.setElement(world.getBlockState(pos).getValue(BlockPedestal.ELEMENT));
|
||||
wizard.setElement(world.getBlockState(pos).getBlock() instanceof IElemental
|
||||
? ((IElemental) world.getBlockState(pos).getBlock()).getElement() : Element.MAGIC);
|
||||
wizard.onInitialSpawn(world.getDifficultyForLocation(pos), null);
|
||||
wizard.hasStructure = true;
|
||||
|
||||
@@ -144,9 +147,8 @@ public class TileEntityShrineCore extends TileEntity implements ITickable {
|
||||
WizardryPacketHandler.net.sendToAllAround(new PacketConquerShrine.Message(this.pos),
|
||||
new NetworkRegistry.TargetPoint(this.world.provider.getDimension(), x, y, z, 64));
|
||||
|
||||
if(world.getBlockState(pos).getBlock() == WizardryBlocks.runestone_pedestal){
|
||||
world.setBlockState(pos, WizardryBlocks.runestone_pedestal.getDefaultState()
|
||||
.withProperty(BlockPedestal.ELEMENT, world.getBlockState(pos).getValue(BlockPedestal.ELEMENT)));
|
||||
if(world.getBlockState(pos).getBlock() instanceof BlockRunestonePedestal){
|
||||
world.setBlockState(pos, world.getBlockState(pos).getBlock().getDefaultState());
|
||||
}else{
|
||||
Wizardry.logger.warn("What's going on?! A shrine core is being conquered but the block at its position is not a runestone pedestal!");
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import electroblob.wizardry.block.BlockRunestone;
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.entity.living.EntityRemnant;
|
||||
import electroblob.wizardry.integration.antiqueatlas.WizardryAntiqueAtlasIntegration;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||
@@ -17,6 +18,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.template.ITemplateProcessor;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -58,9 +60,10 @@ public class WorldGenObelisk extends WorldGenSurfaceStructure {
|
||||
public void spawnStructure(Random random, World world, BlockPos origin, Template template, PlacementSettings settings, ResourceLocation structureFile){
|
||||
|
||||
final Element element = Element.values()[1 + random.nextInt(Element.values().length-1)];
|
||||
Block runeStone = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Wizardry.MODID, element.getName().toLowerCase() + "_runestone"));
|
||||
|
||||
ITemplateProcessor processor = (w, p, i) -> i.blockState.getBlock() instanceof BlockRunestone ? new Template.BlockInfo(
|
||||
i.pos, i.blockState.withProperty(BlockRunestone.ELEMENT, element), i.tileentityData) : i;
|
||||
i.pos, runeStone.getDefaultState(), i.tileentityData) : i;
|
||||
|
||||
template.addBlocksToWorld(world, origin, processor, settings, 2 | 16);
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package electroblob.wizardry.worldgen;
|
||||
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import electroblob.wizardry.block.BlockPedestal;
|
||||
import electroblob.wizardry.block.BlockRunestonePedestal;
|
||||
import electroblob.wizardry.block.BlockRunestone;
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.integration.antiqueatlas.WizardryAntiqueAtlasIntegration;
|
||||
import electroblob.wizardry.registry.WizardryBlocks;
|
||||
import electroblob.wizardry.spell.ArcaneLock;
|
||||
import electroblob.wizardry.tileentity.TileEntityShrineCore;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -15,6 +16,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.template.ITemplateProcessor;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -50,9 +52,10 @@ public class WorldGenShrine extends WorldGenSurfaceStructure {
|
||||
public void spawnStructure(Random random, World world, BlockPos origin, Template template, PlacementSettings settings, ResourceLocation structureFile){
|
||||
|
||||
final Element element = Element.values()[1 + random.nextInt(Element.values().length-1)];
|
||||
Block runeStone = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Wizardry.MODID, element.getName().toLowerCase() + "_runestone"));
|
||||
|
||||
ITemplateProcessor processor = (w, p, i) -> i.blockState.getBlock() instanceof BlockRunestone ? new Template.BlockInfo(
|
||||
i.pos, i.blockState.withProperty(BlockRunestone.ELEMENT, element), i.tileentityData) : i;
|
||||
i.pos, runeStone.getDefaultState(), i.tileentityData) : i;
|
||||
|
||||
template.addBlocksToWorld(world, origin, processor, settings, 2 | 16);
|
||||
|
||||
@@ -65,8 +68,8 @@ public class WorldGenShrine extends WorldGenSurfaceStructure {
|
||||
|
||||
if(entry.getValue().equals(CORE_DATA_BLOCK_TAG)){
|
||||
// This bit could have been done with a template processor, but we also need to link the chest and lock it
|
||||
world.setBlockState(entry.getKey(), WizardryBlocks.runestone_pedestal.getDefaultState()
|
||||
.withProperty(BlockPedestal.ELEMENT, element).withProperty(BlockPedestal.NATURAL, true));
|
||||
world.setBlockState(entry.getKey(), ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Wizardry.MODID, element.getName().toLowerCase()
|
||||
+ "_runestone_pedestal")).getDefaultState().withProperty(BlockRunestonePedestal.NATURAL, true));
|
||||
|
||||
TileEntity core = world.getTileEntity(entry.getKey());
|
||||
TileEntity container = world.getTileEntity(entry.getKey().up());
|
||||
|
||||
Reference in New Issue
Block a user