mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Multiblock framework.
This commit is contained in:
1 parent
f3926ff1ae
commit
6815e281eb
10 files changed
+235
-1
No files matched your search
@@ -189,5 +189,9 @@ public class DummyMethodHandler implements IInternalMethodHandler {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWorldElapsedTicks() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -105,5 +105,7 @@ public interface IInternalMethodHandler {
|
||||
public boolean isBuildcraftPipe(TileEntity tile);
|
||||
|
||||
public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m);
|
||||
|
||||
public long getWorldElapsedTicks();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Jun 27, 2015, 7:20:09 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.lexicon.multiblock;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.Botania;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A multiblock component that switches through the 16 colors of the
|
||||
* minecraft spectrum. This can be used for flowers, for example.
|
||||
*/
|
||||
public class ColorSwitchingComponent extends MultiblockComponent {
|
||||
|
||||
public ColorSwitchingComponent(ChunkCoordinates relPos, Block block) {
|
||||
super(relPos, block, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMeta() {
|
||||
return (int) (BotaniaAPI.internalHandler.getWorldElapsedTicks() / 20) % 16;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Jun 27, 2015, 2:37:22 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.lexicon.multiblock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Mult;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
/**
|
||||
* This class describes a Mutiblock object. It's used to display a
|
||||
* multiblock in the lexicon and to show the player in a ghost-like
|
||||
* look in the world.
|
||||
*/
|
||||
public class Multiblock {
|
||||
|
||||
public List<MultiblockComponent> components = new ArrayList();
|
||||
|
||||
/**
|
||||
* Adds a multiblock component to this multiblock. The component's x y z
|
||||
* coords should be pivoted to the center of the structure.
|
||||
*/
|
||||
public void addComponent(MultiblockComponent component) {
|
||||
components.add(component);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(int x, int y, int z, Block block, int meta) {
|
||||
components.add(new MultiblockComponent(new ChunkCoordinates(x, y, z), block, meta));
|
||||
}
|
||||
|
||||
public List<MultiblockComponent> getComponents() {
|
||||
return components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates this multiblock by the angle passed in. For the best results, use
|
||||
* only multiples of pi/2.
|
||||
*/
|
||||
public void rotate(double angle) {
|
||||
for(MultiblockComponent comp : getComponents())
|
||||
comp.rotate(angle);
|
||||
}
|
||||
|
||||
public Multiblock copy() {
|
||||
Multiblock mb = new Multiblock();
|
||||
for(MultiblockComponent comp : getComponents())
|
||||
mb.addComponent(comp.copy());
|
||||
|
||||
return mb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a length 4 array of all the rotations multiple of pi/2 required
|
||||
* to render this multiblock in the world relevant to the 4 cardinal
|
||||
* orientations.
|
||||
*/
|
||||
public Multiblock[] createRotations() {
|
||||
Multiblock[] blocks = new Multiblock[4];
|
||||
blocks[0] = this;
|
||||
blocks[1] = blocks[0].copy();
|
||||
blocks[1].rotate(Math.PI / 2);
|
||||
blocks[2] = blocks[1].copy();
|
||||
blocks[2].rotate(Math.PI / 2);
|
||||
blocks[3] = blocks[2].copy();
|
||||
blocks[3].rotate(Math.PI / 2);
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Jun 27, 2015, 2:42:32 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.lexicon.multiblock;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A component of a multiblock, the normal one
|
||||
* is just a block.
|
||||
*/
|
||||
public class MultiblockComponent {
|
||||
|
||||
public ChunkCoordinates relPos;
|
||||
public final Block block;
|
||||
public final int meta;
|
||||
|
||||
public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta) {
|
||||
this.relPos = relPos;
|
||||
this.block = block;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public ChunkCoordinates getRelativePosition() {
|
||||
return relPos;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public int getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void rotate(double angle) {
|
||||
int x = relPos.posX;
|
||||
int z = relPos.posZ;
|
||||
double sin = Math.sin(angle);
|
||||
double cos = Math.cos(angle);
|
||||
|
||||
double xn = x * cos - z * sin;
|
||||
double zn = x * sin + z * cos;
|
||||
relPos = new ChunkCoordinates((int) xn, relPos.posY, (int) zn);
|
||||
}
|
||||
|
||||
public MultiblockComponent copy() {
|
||||
return new MultiblockComponent(relPos, block, meta);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@API(owner = "Botania", apiVersion = "53", provides = "BotaniaAPI")
|
||||
@API(owner = "Botania", apiVersion = "54", provides = "BotaniaAPI")
|
||||
package vazkii.botania.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Jun 27, 2015, 3:11:36 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
import vazkii.botania.api.lexicon.multiblock.MultiblockComponent;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
|
||||
public final class ModMultiblocks {
|
||||
|
||||
public static Multiblock[] enchanter;
|
||||
|
||||
public static void init() {
|
||||
enchanter = TileEnchanter.makeMultiblockInstance();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,8 +28,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.lexicon.multiblock.ColorSwitchingComponent;
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.spark.ISparkAttachable;
|
||||
import vazkii.botania.api.mana.spark.ISparkEntity;
|
||||
@@ -76,6 +79,19 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
|
||||
private static final int[][] FLOWER_LOCATIONS = new int[][] {
|
||||
{ -1, 0, -1 }, { 1, 0, -1 }, { -1, 0, 1 }, { 1, 0, 1 }
|
||||
};
|
||||
|
||||
public static Multiblock[] makeMultiblockInstance() {
|
||||
Multiblock mb = new Multiblock();
|
||||
|
||||
for(int[] o : OBSIDIAN_LOCATIONS)
|
||||
mb.addComponent(o[0], o[1], o[2], Blocks.obsidian, 0);
|
||||
for(int[] p : PYLON_LOCATIONS[0]) {
|
||||
mb.addComponent(p[0], p[1], p[2], ModBlocks.pylon, 0);
|
||||
mb.addComponent(new ColorSwitchingComponent(new ChunkCoordinates(p[0], p[1] -1, p[2]), ModBlocks.flower));
|
||||
}
|
||||
|
||||
return mb.createRotations();
|
||||
}
|
||||
|
||||
public void onWanded(EntityPlayer player, ItemStack wand) {
|
||||
if(stage != 0 || itemToEnchant == null || !itemToEnchant.isItemEnchantable())
|
||||
|
||||
@@ -211,4 +211,9 @@ public class InternalMethodHandler extends DummyMethodHandler {
|
||||
public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) {
|
||||
ItemLokiRing.breakOnAllCursors(player, item, stack, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWorldElapsedTicks() {
|
||||
return Botania.proxy.getWorldElapsedTicks();
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import vazkii.botania.api.lexicon.LexiconPage;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.achievement.ModAchievements;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.ModMultiblocks;
|
||||
import vazkii.botania.common.block.subtile.generating.SubTileNarslimmus;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
|
||||
import vazkii.botania.common.brew.ModBrews;
|
||||
@@ -94,6 +95,7 @@ public class CommonProxy {
|
||||
ModElvenTradeRecipes.init();
|
||||
ModBrewRecipes.init();
|
||||
ModAchievements.init();
|
||||
ModMultiblocks.init();
|
||||
|
||||
ChestGenHandler.init();
|
||||
|
||||
|
||||
Reference in new issue
Block a user