mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Fix alf portal states, made the api compile now!
This commit is contained in:
1 parent
e4b58e0c2d
commit
9ea899bad5
23 files changed
+173
-130
No files matched your search
@@ -13,6 +13,8 @@ package vazkii.botania.api.internal;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -131,12 +133,12 @@ public class DummyMethodHandler implements IInternalMethodHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getSubTileIconForName(String name) {
|
||||
return Blocks.red_flower.getIcon(0, 0);
|
||||
public TextureAtlasSprite getSubTileIconForName(String name) {
|
||||
return null; //todo 1.8 return Blocks.red_flower.getIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBasicSignatureIcons(String name, IIconRegister register) {
|
||||
public void registerBasicSignatureIcons(String name, TextureMap map) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ package vazkii.botania.api.internal;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -82,9 +84,10 @@ public interface IInternalMethodHandler {
|
||||
|
||||
public String getStackSubTileKey(ItemStack stack);
|
||||
|
||||
public IIcon getSubTileIconForName(String name);
|
||||
// todo 1.8 evaluate need for these two
|
||||
public TextureAtlasSprite getSubTileIconForName(String name);
|
||||
|
||||
public void registerBasicSignatureIcons(String name, IIconRegister register);
|
||||
public void registerBasicSignatureIcons(String name, TextureMap map);
|
||||
|
||||
public boolean shouldForceCheck();
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.api.lexicon.multiblock;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -39,10 +40,10 @@ public class Multiblock {
|
||||
* coords should be pivoted to the center of the structure.
|
||||
*/
|
||||
public void addComponent(MultiblockComponent component) {
|
||||
if(getComponentForLocation(component.relPos) != null)
|
||||
if(getComponentForLocation(component.getRelativePosition()) != null)
|
||||
throw new IllegalArgumentException("Location in multiblock already occupied");
|
||||
components.add(component);
|
||||
changeAxisForNewComponent(component.relPos);
|
||||
changeAxisForNewComponent(component.getRelativePosition());
|
||||
calculateCostForNewComponent(component);
|
||||
addComponentToLocationCache(component);
|
||||
}
|
||||
@@ -51,8 +52,8 @@ public class Multiblock {
|
||||
* Constructs and adds a multiblock component to this multiblock. The x y z
|
||||
* coords should be pivoted to the center of the structure.
|
||||
*/
|
||||
public void addComponent(BlockPos pos, Block block, int meta) {
|
||||
addComponent(new MultiblockComponent(pos, block, meta));
|
||||
public void addComponent(BlockPos pos, IBlockState state) {
|
||||
addComponent(new MultiblockComponent(pos, state));
|
||||
}
|
||||
|
||||
private void changeAxisForNewComponent(BlockPos pos) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
|
||||
/**
|
||||
* A multiblock component that matches any botania flower.
|
||||
@@ -21,7 +22,7 @@ import vazkii.botania.api.BotaniaAPI;
|
||||
public class FlowerComponent extends ColorSwitchingComponent {
|
||||
|
||||
public FlowerComponent(BlockPos relPos, Block block) {
|
||||
super(relPos, block);
|
||||
super(relPos, block, BotaniaStateProps.COLOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,6 +63,9 @@ public class BotaniaStateProps {
|
||||
}
|
||||
});
|
||||
|
||||
// BlockAlfPortal
|
||||
public static final PropertyEnum ALFPORTAL_STATE = PropertyEnum.create("state", AlfPortalState.class);
|
||||
|
||||
// BlockAltGrass
|
||||
public static final PropertyEnum ALTGRASS_VARIANT = PropertyEnum.create("variant", AltGrassVariant.class);
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package vazkii.botania.api.state.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum AlfPortalState implements IStringSerializable {
|
||||
OFF,
|
||||
ON_Z,
|
||||
ON_X;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -95,8 +96,8 @@ public class SubTileEntity {
|
||||
/**
|
||||
* Gets the icon for this SubTileEntity, this is a block icon.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon() {
|
||||
@SideOnly(Side.CLIENT) // todo 1.8 reevaluate need
|
||||
public TextureAtlasSprite getIcon() {
|
||||
return BotaniaAPI.internalHandler.getSubTileIconForName(getUnlocalizedName());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -183,8 +184,8 @@ public class SubTileGenerating extends SubTileEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(ArrayList<ItemStack> list) {
|
||||
ArrayList<ItemStack> drops = super.getDrops(list);
|
||||
public List<ItemStack> getDrops(List<ItemStack> list) {
|
||||
List<ItemStack> drops = super.getDrops(list);
|
||||
if(isPassiveFlower())
|
||||
populateDropStackNBTs(drops);
|
||||
return drops;
|
||||
@@ -203,8 +204,8 @@ public class SubTileGenerating extends SubTileEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, entity, stack);
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, pos, state, entity, stack);
|
||||
if(isPassiveFlower()) {
|
||||
NBTTagCompound cmp = stack.getTagCompound();
|
||||
passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS);
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
*/
|
||||
package vazkii.botania.api.subtile.signature;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
|
||||
/**
|
||||
@@ -27,12 +27,12 @@ public class BasicSignature extends SubTileSignature {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register) {
|
||||
public void registerIcons(TextureMap register) {
|
||||
BotaniaAPI.internalHandler.registerBasicSignatureIcons(name, register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconForStack(ItemStack stack) {
|
||||
public TextureAtlasSprite getIconForStack(ItemStack stack) {
|
||||
return BotaniaAPI.internalHandler.getSubTileIconForName(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ package vazkii.botania.api.subtile.signature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
/**
|
||||
* A singleton instance for a SubTileEntity, this is called for a few methods.
|
||||
@@ -27,12 +27,12 @@ public abstract class SubTileSignature {
|
||||
/**
|
||||
* Equivalent to Block.registerBlockIcons.
|
||||
*/
|
||||
public abstract void registerIcons(IIconRegister register);
|
||||
|
||||
public abstract void registerIcons(TextureMap map);
|
||||
// todo 1.8 evaluate need for these two
|
||||
/**
|
||||
* Gets the icon to display for the flower item.
|
||||
*/
|
||||
public abstract IIcon getIconForStack(ItemStack stack);
|
||||
public abstract TextureAtlasSprite getIconForStack(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Gets the display name for the flower item.
|
||||
|
||||
@@ -53,7 +53,7 @@ public class SimpleWikiProvider implements IWikiProvider {
|
||||
if(block == null)
|
||||
return null;
|
||||
|
||||
ItemStack stack = block.getPickBlock(pos, world, bPos);
|
||||
ItemStack stack = block.getPickBlock(pos, world, bPos, null);
|
||||
|
||||
if(stack == null || stack.getItem() == null)
|
||||
stack = new ItemStack(block, 1, block.getMetaFromState(world.getBlockState(bPos)));
|
||||
|
||||
@@ -126,17 +126,18 @@ public final class BaubleRenderHandler {
|
||||
int lightmapX = light % 65536;
|
||||
int lightmapY = light / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
|
||||
for(int j = 0; j < 2; j++) {
|
||||
IIcon icon = item.getIcon(stack, j);
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
ItemRenderer.renderItemIn2D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
|
||||
Color color = new Color(item.getColorFromItemStack(stack, 1));
|
||||
GlStateManager.color((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
|
||||
}
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemModel(stack); // todo 1.8
|
||||
// for(int j = 0; j < 2; j++) {
|
||||
// IIcon icon = item.getIcon(stack, j);
|
||||
// float f = icon.getMinU();
|
||||
// float f1 = icon.getMaxU();
|
||||
// float f2 = icon.getMinV();
|
||||
// float f3 = icon.getMaxV();
|
||||
// ItemRenderer.renderItemIn2D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
//
|
||||
// Color color = new Color(item.getColorFromItemStack(stack, 1));
|
||||
// GlStateManager.color((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
|
||||
// }
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
if(renderedOne)
|
||||
|
||||
@@ -79,7 +79,7 @@ public final class ContributorFancinessHandler {
|
||||
int i = Integer.parseInt(value);
|
||||
if(i < 0 || i >= 16)
|
||||
throw new NumberFormatException();
|
||||
flowerMap.put(key, ModBlocks.flower.(0, i));
|
||||
flowerMap.put(key, new ItemStack(ModBlocks.flower, 1, i));
|
||||
} catch(NumberFormatException e) {
|
||||
SubTileSignature sig = BotaniaAPI.getSignatureForName(value);
|
||||
if(sig != null)
|
||||
|
||||
@@ -37,7 +37,7 @@ public class MultiblockBlockAccess implements IBlockAccess {
|
||||
public IBlockState getBlockState(BlockPos pos) {
|
||||
MultiblockComponent comp=getComponent(pos);
|
||||
if(comp != null)
|
||||
return comp.getBlock().getStateFromMeta(comp.getMeta());
|
||||
return comp.getBlockState();
|
||||
if(hasBlockAccess)
|
||||
return originalBlockAccess.getBlockState(pos);
|
||||
return Blocks.air.getDefaultState();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.client.gui.lexicon.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.state.enums.AlfPortalState;
|
||||
import vazkii.botania.api.wand.IWandable;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.achievement.ModAchievements;
|
||||
@@ -43,7 +44,7 @@ public class BlockAlfPortal extends BlockModContainer implements IWandable, ILex
|
||||
setHardness(10F);
|
||||
setStepSound(soundTypeWood);
|
||||
setUnlocalizedName(LibBlockNames.ALF_PORTAL);
|
||||
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.POWERED, false));
|
||||
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.ALFPORTAL_STATE, AlfPortalState.OFF));
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@@ -54,17 +55,20 @@ public class BlockAlfPortal extends BlockModContainer implements IWandable, ILex
|
||||
|
||||
@Override
|
||||
public BlockState createBlockState() {
|
||||
return new BlockState(this, BotaniaStateProps.POWERED);
|
||||
return new BlockState(this, BotaniaStateProps.ALFPORTAL_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(BotaniaStateProps.POWERED, meta == 1);
|
||||
if (meta > AlfPortalState.values().length) {
|
||||
meta = 0;
|
||||
}
|
||||
return getDefaultState().withProperty(BotaniaStateProps.ALFPORTAL_STATE, AlfPortalState.values()[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return ((Boolean) state.getValue(BotaniaStateProps.POWERED)) ? 1 : 0;
|
||||
return ((AlfPortalState) state.getValue(BotaniaStateProps.ALFPORTAL_STATE)).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,7 +91,7 @@ public class BlockAlfPortal extends BlockModContainer implements IWandable, ILex
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, BlockPos pos) {
|
||||
return ((Boolean) world.getBlockState(pos).getValue(BotaniaStateProps.POWERED)) ? 0 : 15;
|
||||
return ((AlfPortalState) world.getBlockState(pos).getValue(BotaniaStateProps.ALFPORTAL_STATE)) == AlfPortalState.OFF ? 0 : 15;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.common.block.subtile.generating;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -57,7 +58,7 @@ public class SubTileDaybloom extends SubTilePassiveGenerating {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(ArrayList<ItemStack> list) {
|
||||
public List<ItemStack> getDrops(List<ItemStack> list) {
|
||||
if(isPrime())
|
||||
list.clear();
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@ public class SubTileMunchdew extends SubTileGenerating {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(ArrayList<ItemStack> list) {
|
||||
ArrayList<ItemStack> drops = super.getDrops(list);
|
||||
public List<ItemStack> getDrops(List<ItemStack> list) {
|
||||
List<ItemStack> drops = super.getDrops(list);
|
||||
if(cooldown > 0)
|
||||
ItemNBTHelper.setInt(drops.get(0), TAG_COOLDOWN, cooldown);
|
||||
return drops;
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -21,6 +22,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexicon;
|
||||
@@ -29,6 +31,10 @@ import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
|
||||
import vazkii.botania.api.recipe.ElvenPortalUpdateEvent;
|
||||
import vazkii.botania.api.recipe.IElvenItem;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.state.enums.AlfPortalState;
|
||||
import vazkii.botania.api.state.enums.LivingWoodVariant;
|
||||
import vazkii.botania.api.state.enums.PylonVariant;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
@@ -40,24 +46,28 @@ import com.google.common.base.Function;
|
||||
|
||||
public class TileAlfPortal extends TileMod implements IUpdatePlayerListBox {
|
||||
|
||||
private static final int[][] LIVINGWOOD_POSITIONS = {
|
||||
{ -1, 0, 0}, { 1, 0, 0}, { -2, 1, 0}, { 2, 1, 0}, { -2, 3, 0}, { 2, 3, 0}, { -1, 4, 0}, { 1, 4, 0}
|
||||
private static final BlockPos[] LIVINGWOOD_POSITIONS = {
|
||||
new BlockPos(-1, 0, 0), new BlockPos(1, 0, 0), new BlockPos(-2, 1, 0),
|
||||
new BlockPos(2, 1, 0), new BlockPos(-2, 3, 0), new BlockPos(2, 3, 0),
|
||||
new BlockPos(-1, 4, 0), new BlockPos(1, 4, 0)
|
||||
};
|
||||
|
||||
private static final int[][] GLIMMERING_LIVINGWOOD_POSITIONS = {
|
||||
{ -2, 2, 0 }, { 2, 2, 0 }, { 0, 4, 0 }
|
||||
private static final BlockPos[] GLIMMERING_LIVINGWOOD_POSITIONS = {
|
||||
new BlockPos(-2, 2, 0), new BlockPos(2, 2, 0), new BlockPos(0, 4, 0)
|
||||
};
|
||||
|
||||
private static final int[][] PYLON_POSITIONS = {
|
||||
{ -3, 1, 3 }, { 3, 1, 3 }
|
||||
private static final BlockPos[] PYLON_POSITIONS = {
|
||||
new BlockPos(-3, 1, 3), new BlockPos(3, 1, 3)
|
||||
};
|
||||
|
||||
private static final int[][] POOL_POSITIONS = {
|
||||
{ -3, 0, 3 }, { 3, 0, 3 }
|
||||
private static final BlockPos[] POOL_POSITIONS = {
|
||||
new BlockPos(-3, 0, 3), new BlockPos(3, 0, 3)
|
||||
};
|
||||
|
||||
private static final int[][] AIR_POSITIONS = {
|
||||
{ -1, 1, 0 }, { 0, 1, 0 }, { 1, 1, 0 }, { -1, 2, 0 }, { 0, 2, 0 }, { 1, 2, 0 }, { -1, 3, 0 }, { 0, 3, 0 }, { 1, 3, 0 }
|
||||
private static final BlockPos[] AIR_POSITIONS = {
|
||||
new BlockPos(-1, 1, 0), new BlockPos(0, 1, 0), new BlockPos(1, 1, 0),
|
||||
new BlockPos(-1, 2, 0), new BlockPos(0, 2, 0), new BlockPos(1, 2, 0),
|
||||
new BlockPos(-1, 3, 0), new BlockPos(0, 3, 0), new BlockPos(1, 3, 0)
|
||||
};
|
||||
|
||||
private static final String TAG_TICKS_OPEN = "ticksOpen";
|
||||
@@ -73,10 +83,10 @@ public class TileAlfPortal extends TileMod implements IUpdatePlayerListBox {
|
||||
private boolean closeNow = false;
|
||||
private boolean hasUnloadedParts = false;
|
||||
|
||||
private static final Function<int[], int[]> CONVERTER_X_Z = new Function<int[], int[]>() {
|
||||
private static final Function<BlockPos, BlockPos> CONVERTER_X_Z = new Function<BlockPos, BlockPos>() {
|
||||
@Override
|
||||
public int[] apply(int[] input) {
|
||||
return new int[] { input[2], input[1], input[0] };
|
||||
public BlockPos apply(BlockPos input) {
|
||||
return new BlockPos(input.getZ(), input.getY(), input.getX());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -87,39 +97,39 @@ public class TileAlfPortal extends TileMod implements IUpdatePlayerListBox {
|
||||
}
|
||||
};
|
||||
|
||||
private static final Function<int[], int[]> CONVERTER_Z_SWAP = new Function<int[], int[]>() {
|
||||
private static final Function<BlockPos, BlockPos> CONVERTER_Z_SWAP = new Function<BlockPos, BlockPos>() {
|
||||
@Override
|
||||
public int[] apply(int[] input) {
|
||||
return new int[] { input[0], input[1], -input[2] };
|
||||
public BlockPos apply(BlockPos input) {
|
||||
return new BlockPos(input.getX(), input.getY(), -input.getZ());
|
||||
}
|
||||
};
|
||||
|
||||
public static MultiblockSet makeMultiblockSet() {
|
||||
Multiblock mb = new Multiblock();
|
||||
|
||||
for(int[] l : LIVINGWOOD_POSITIONS)
|
||||
mb.addComponent(, l[0], ModBlocks.livingwood, 0);
|
||||
for(int[] g : GLIMMERING_LIVINGWOOD_POSITIONS)
|
||||
mb.addComponent(, g[0], ModBlocks.livingwood, 5);
|
||||
for(int[] p : PYLON_POSITIONS)
|
||||
mb.addComponent(, -p[0], ModBlocks.pylon, 1);
|
||||
for(int[] p : POOL_POSITIONS)
|
||||
mb.addComponent(, -p[0], ModBlocks.pool, 0);
|
||||
for(BlockPos l : LIVINGWOOD_POSITIONS)
|
||||
mb.addComponent(l.up(), ModBlocks.livingwood, 0);
|
||||
for(BlockPos g : GLIMMERING_LIVINGWOOD_POSITIONS)
|
||||
mb.addComponent(g.up(), ModBlocks.livingwood, 5);
|
||||
for(BlockPos p : PYLON_POSITIONS)
|
||||
mb.addComponent(new BlockPos(-p.getX(), p.getY() + 1, -p.getZ()), ModBlocks.pylon, 1);
|
||||
for(BlockPos p : POOL_POSITIONS)
|
||||
mb.addComponent(new BlockPos(-p.getX(), p.getY() + 1, -p.getZ()), ModBlocks.pool, 0);
|
||||
|
||||
mb.addComponent(, 0, ModBlocks.alfPortal, 0);
|
||||
mb.setRenderOffset(0, -1, 0);
|
||||
mb.addComponent(new BlockPos(0, 1, 0), ModBlocks.alfPortal, 0);
|
||||
mb.setRenderOffset(new BlockPos(0, -1, 0));
|
||||
|
||||
return mb.makeSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
int meta = getBlockMetadata();
|
||||
if(meta == 0) {
|
||||
AlfPortalState state = ((AlfPortalState) worldObj.getBlockState(getPos()).getValue(BotaniaStateProps.ALFPORTAL_STATE));
|
||||
if(state == AlfPortalState.OFF) {
|
||||
ticksOpen = 0;
|
||||
return;
|
||||
}
|
||||
int newMeta = getValidMetadata();
|
||||
AlfPortalState newState = getValidState();
|
||||
|
||||
if(!hasUnloadedParts) {
|
||||
ticksOpen++;
|
||||
@@ -132,7 +142,7 @@ public class TileAlfPortal extends TileMod implements IUpdatePlayerListBox {
|
||||
if(ticksOpen > 60) {
|
||||
ticksSinceLastItem++;
|
||||
if(ConfigHandler.elfPortalParticlesEnabled)
|
||||
blockParticle(meta);
|
||||
blockParticle(state);
|
||||
|
||||
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, aabb);
|
||||
if(!worldObj.isRemote)
|
||||
@@ -156,26 +166,26 @@ public class TileAlfPortal extends TileMod implements IUpdatePlayerListBox {
|
||||
} else closeNow = false;
|
||||
|
||||
if(closeNow) {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2);
|
||||
worldObj.setBlockState(getPos(), ModBlocks.alfPortal.getDefaultState(), 1 | 2);
|
||||
for(int i = 0; i < 36; i++)
|
||||
blockParticle(meta);
|
||||
blockParticle(state);
|
||||
closeNow = false;
|
||||
} else if(newMeta != meta) {
|
||||
if(newMeta == 0)
|
||||
} else if(newState != state) {
|
||||
if(newState == AlfPortalState.OFF)
|
||||
for(int i = 0; i < 36; i++)
|
||||
blockParticle(meta);
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2);
|
||||
blockParticle(state);
|
||||
worldObj.setBlockState(getPos(), worldObj.getBlockState(getPos()).withProperty(BotaniaStateProps.ALFPORTAL_STATE, newState), 1 | 2);
|
||||
}
|
||||
|
||||
hasUnloadedParts = false;
|
||||
}
|
||||
|
||||
private void blockParticle(int meta) {
|
||||
private void blockParticle(AlfPortalState state) {
|
||||
int i = worldObj.rand.nextInt(AIR_POSITIONS.length);
|
||||
double[] pos = new double[] {
|
||||
AIR_POSITIONS[i][0] + 0.5F, AIR_POSITIONS[i][1] + 0.5F, AIR_POSITIONS[i][2] + 0.5F
|
||||
AIR_POSITIONS[i].getX() + 0.5F, AIR_POSITIONS[i].getY() + 0.5F, AIR_POSITIONS[i].getZ() + 0.5F
|
||||
};
|
||||
if(meta == 2)
|
||||
if(state == AlfPortalState.ON_X)
|
||||
pos = CONVERTER_X_Z_FP.apply(pos);
|
||||
|
||||
float motionMul = 0.2F;
|
||||
@@ -183,11 +193,11 @@ public class TileAlfPortal extends TileMod implements IUpdatePlayerListBox {
|
||||
}
|
||||
|
||||
public boolean onWanded() {
|
||||
int meta = getBlockMetadata();
|
||||
if(meta == 0) {
|
||||
int newMeta = getValidMetadata();
|
||||
if(newMeta != 0) {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2);
|
||||
AlfPortalState state = ((AlfPortalState) worldObj.getBlockState(getPos()).getValue(BotaniaStateProps.ALFPORTAL_STATE));
|
||||
if(state == AlfPortalState.OFF) {
|
||||
AlfPortalState newState = getValidState();
|
||||
if(newState != AlfPortalState.OFF) {
|
||||
worldObj.setBlockState(getPos(), worldObj.getBlockState(getPos()).withProperty(BotaniaStateProps.ALFPORTAL_STATE, newState), 1 | 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -278,55 +288,55 @@ public class TileAlfPortal extends TileMod implements IUpdatePlayerListBox {
|
||||
ticksSinceLastItem = cmp.getInteger(TAG_TICKS_SINCE_LAST_ITEM);
|
||||
}
|
||||
|
||||
private int getValidMetadata() {
|
||||
private AlfPortalState getValidState() {
|
||||
if(checkConverter(null))
|
||||
return 1;
|
||||
return AlfPortalState.ON_Z;
|
||||
|
||||
if(checkConverter(CONVERTER_X_Z))
|
||||
return 2;
|
||||
return AlfPortalState.ON_X;
|
||||
|
||||
return 0;
|
||||
return AlfPortalState.OFF;
|
||||
}
|
||||
|
||||
private boolean checkConverter(Function<int[], int[]> baseConverter) {
|
||||
private boolean checkConverter(Function<BlockPos, BlockPos> baseConverter) {
|
||||
return checkMultipleConverters(baseConverter) || checkMultipleConverters(CONVERTER_Z_SWAP, baseConverter);
|
||||
}
|
||||
|
||||
private boolean checkMultipleConverters(Function<int[], int[]>... converters) {
|
||||
if(!check2DArray(AIR_POSITIONS, Blocks.air, -1, converters))
|
||||
private boolean checkMultipleConverters(Function<BlockPos, BlockPos>... converters) {
|
||||
if(!check2DArray(AIR_POSITIONS, Blocks.air.getDefaultState(), true, converters))
|
||||
return false;
|
||||
if(!check2DArray(LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 0, converters))
|
||||
if(!check2DArray(LIVINGWOOD_POSITIONS, ModBlocks.livingwood.getDefaultState().withProperty(BotaniaStateProps.LIVINGWOOD_VARIANT, LivingWoodVariant.DEFAULT), false, converters))
|
||||
return false;
|
||||
if(!check2DArray(GLIMMERING_LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 5, converters))
|
||||
if(!check2DArray(GLIMMERING_LIVINGWOOD_POSITIONS, ModBlocks.livingwood.getDefaultState().withProperty(BotaniaStateProps.LIVINGWOOD_VARIANT, LivingWoodVariant.GLIMMERING), false, converters))
|
||||
return false;
|
||||
if(!check2DArray(PYLON_POSITIONS, ModBlocks.pylon, 1, converters))
|
||||
if(!check2DArray(PYLON_POSITIONS, ModBlocks.pylon.getDefaultState().withProperty(BotaniaStateProps.PYLON_VARIANT, PylonVariant.NATURA), false, converters))
|
||||
return false;
|
||||
if(!check2DArray(POOL_POSITIONS, ModBlocks.pool, -1, converters))
|
||||
if(!check2DArray(POOL_POSITIONS, ModBlocks.pool.getDefaultState(), true, converters))
|
||||
return false;
|
||||
|
||||
lightPylons(converters);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void lightPylons(Function<int[], int[]>... converters) {
|
||||
private void lightPylons(Function<BlockPos, BlockPos>... converters) {
|
||||
if(ticksOpen < 50)
|
||||
return;
|
||||
|
||||
int cost = ticksOpen == 50 ? 75000 : 2;
|
||||
|
||||
for(int[] pos : PYLON_POSITIONS) {
|
||||
for(Function<int[], int[]> f : converters)
|
||||
for(BlockPos pos : PYLON_POSITIONS) {
|
||||
for(Function<BlockPos, BlockPos> f : converters)
|
||||
if(f != null)
|
||||
pos = f.apply(pos);
|
||||
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1], zCoord + pos[2]);
|
||||
TileEntity tile = worldObj.getTileEntity(getPos().add(pos));
|
||||
if(tile instanceof TilePylon) {
|
||||
TilePylon pylon = (TilePylon) tile;
|
||||
pylon.activated = true;
|
||||
pylon.centerPos = getPos();
|
||||
}
|
||||
|
||||
tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1] - 1, zCoord + pos[2]);
|
||||
tile = worldObj.getTileEntity(getPos().add(pos).down());
|
||||
if(tile instanceof TilePool) {
|
||||
TilePool pool = (TilePool) tile;
|
||||
if(pool.getCurrentMana() < cost)
|
||||
@@ -337,35 +347,31 @@ public class TileAlfPortal extends TileMod implements IUpdatePlayerListBox {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean check2DArray(int[][] positions, Block block, int meta, Function<int[], int[]>... converters) {
|
||||
for(int[] pos : positions) {
|
||||
for(Function<int[], int[]> f : converters)
|
||||
private boolean check2DArray(BlockPos[] positions, IBlockState state, boolean onlyCheckBlock, Function<BlockPos, BlockPos>... converters) {
|
||||
for(BlockPos pos : positions) {
|
||||
for(Function<BlockPos, BlockPos> f : converters)
|
||||
if(f != null)
|
||||
pos = f.apply(pos);
|
||||
|
||||
if(!checkPosition(pos, block, meta))
|
||||
if(!checkPosition(pos, state, onlyCheckBlock))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkPosition(int[] pos, Block block, int meta) {
|
||||
int x = xCoord + pos[0];
|
||||
int y = yCoord + pos[1];
|
||||
int z = zCoord + pos[2];
|
||||
if(!worldObj.blockExists(x, y, z)) {
|
||||
private boolean checkPosition(BlockPos pos, IBlockState state, boolean onlyCheckBlock) {
|
||||
BlockPos pos_ = getPos().add(pos);
|
||||
if(!worldObj.isBlockLoaded(pos_)) {
|
||||
hasUnloadedParts = true;
|
||||
return true; // Don't fuck everything up if there's a chunk unload
|
||||
}
|
||||
|
||||
Block blockat = worldObj.getBlock(x, y, z);
|
||||
if(block == Blocks.air ? blockat.isAir(worldObj, x, y, z) : blockat == block) {
|
||||
if(meta == -1)
|
||||
return true;
|
||||
IBlockState stateat = worldObj.getBlockState(pos_);
|
||||
Block blockat = stateat.getBlock();
|
||||
|
||||
int metaat = worldObj.getBlockMetadata(x, y, z);
|
||||
return meta == metaat;
|
||||
if(state.getBlock() == Blocks.air ? blockat.isAir(worldObj, pos_) : blockat == state.getBlock()) {
|
||||
return onlyCheckBlock || stateat == state;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -94,13 +94,13 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, IUpdateP
|
||||
Multiblock mb = new Multiblock();
|
||||
|
||||
for(BlockPos o : OBSIDIAN_LOCATIONS)
|
||||
mb.addComponent(o, Blocks.obsidian, 0);
|
||||
mb.addComponent(o.up(), Blocks.obsidian, 0);
|
||||
for(BlockPos p : PYLON_LOCATIONS.get(EnumFacing.Axis.X)) {
|
||||
mb.addComponent(p, ModBlocks.pylon, 0);
|
||||
mb.addComponent(p.up(), ModBlocks.pylon, 0);
|
||||
mb.addComponent(new FlowerComponent(p, ModBlocks.flower));
|
||||
}
|
||||
for(BlockPos f : FLOWER_LOCATIONS)
|
||||
mb.addComponent(new FlowerComponent(f, ModBlocks.flower));
|
||||
mb.addComponent(new FlowerComponent(f.up(), ModBlocks.flower));
|
||||
|
||||
mb.addComponent(BlockPos.ORIGIN, Blocks.lapis_block, 0);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, IUpdate
|
||||
mb.addComponent(relativePos, ModBlocks.livingrock, 0);
|
||||
|
||||
mb.addComponent(new BlockPos(0, 1, 0), ModBlocks.terraPlate, 0);
|
||||
mb.setRenderOffset(0, 1, 0);
|
||||
mb.setRenderOffset(new BlockPos(0, 1, 0));
|
||||
|
||||
return mb.makeSet();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -95,13 +97,13 @@ public class InternalMethodHandler extends DummyMethodHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getSubTileIconForName(String name) {
|
||||
public TextureAtlasSprite getSubTileIconForName(String name) {
|
||||
IIcon icon = (ConfigHandler.altFlowerTextures ? BlockSpecialFlower.iconsAlt : BlockSpecialFlower.icons).get(name);
|
||||
return icon == null ? Blocks.red_flower.getIcon(0, 0) : icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBasicSignatureIcons(String name, IIconRegister register) {
|
||||
public void registerBasicSignatureIcons(String name, TextureMap map) {
|
||||
IIcon normal = IconHelper.forName(register, name);
|
||||
IIcon alt = IconHelper.forName(register, BlockModFlower.ALT_DIR + "/" + name);
|
||||
BlockSpecialFlower.icons.put(name, normal);
|
||||
|
||||
@@ -124,14 +124,14 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
|
||||
Multiblock mb = new Multiblock();
|
||||
|
||||
for(BlockPos p : PYLON_LOCATIONS)
|
||||
mb.addComponent(p, ModBlocks.pylon, 2);
|
||||
mb.addComponent(p.up(), ModBlocks.pylon, 2);
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
for(int j = 0; j < 3; j++)
|
||||
mb.addComponent(new BeaconComponent(new BlockPos(i - 1, 0, j - 1)));
|
||||
|
||||
mb.addComponent(new BlockPos(0, 1, 0), Blocks.beacon, 0);
|
||||
mb.setRenderOffset(0, -1, 0);
|
||||
mb.setRenderOffset(new BlockPos(0, -1, 0));
|
||||
|
||||
return mb.makeSet();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user