mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Working Mana Pool Minecarts!
This commit is contained in:
1 parent
6c479052aa
commit
b415f28c43
17 files changed
+194
-51
No files matched your search
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* 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 @ [Mar 17, 2015, 6:29:07 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.mana;
|
||||
|
||||
/**
|
||||
* Interface for an entity that counts as a Mana Pool Minecart
|
||||
*/
|
||||
public interface IPoolCart {
|
||||
|
||||
/**
|
||||
* Adds Mana to this cart. The mana param can be both positive or negative.
|
||||
*/
|
||||
public void addMana(int mana);
|
||||
|
||||
/**
|
||||
* Gets the amount of mana in the cart.
|
||||
*/
|
||||
public int getMana();
|
||||
|
||||
/**
|
||||
* Gets the max amount of mana the cart can store.
|
||||
*/
|
||||
public int getMaxMana();
|
||||
|
||||
}
|
||||
@@ -63,6 +63,7 @@ import vazkii.botania.client.render.block.RenderTinyPotato;
|
||||
import vazkii.botania.client.render.entity.RenderCorporeaSpark;
|
||||
import vazkii.botania.client.render.entity.RenderDoppleganger;
|
||||
import vazkii.botania.client.render.entity.RenderPixie;
|
||||
import vazkii.botania.client.render.entity.RenderPoolMinecart;
|
||||
import vazkii.botania.client.render.entity.RenderSpark;
|
||||
import vazkii.botania.client.render.item.RenderBow;
|
||||
import vazkii.botania.client.render.item.RenderFloatingFlowerItem;
|
||||
@@ -112,6 +113,7 @@ import vazkii.botania.common.entity.EntityCorporeaSpark;
|
||||
import vazkii.botania.common.entity.EntityDoppleganger;
|
||||
import vazkii.botania.common.entity.EntityEnderAirBottle;
|
||||
import vazkii.botania.common.entity.EntityPixie;
|
||||
import vazkii.botania.common.entity.EntityPoolMinecart;
|
||||
import vazkii.botania.common.entity.EntitySpark;
|
||||
import vazkii.botania.common.entity.EntityThornChakram;
|
||||
import vazkii.botania.common.entity.EntityVineBall;
|
||||
@@ -220,6 +222,7 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityThornChakram.class, new RenderSnowball(ModItems.thornChakram));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityCorporeaSpark.class, new RenderCorporeaSpark());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityEnderAirBottle.class, new RenderSnowball(ModItems.manaResource, 15));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityPoolMinecart.class, new RenderPoolMinecart());
|
||||
|
||||
ShaderHelper.initShaders();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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 @ [Mar 17, 2015, 11:17:48 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.render.entity;
|
||||
|
||||
import vazkii.botania.client.render.tile.RenderTilePool;
|
||||
import vazkii.botania.common.entity.EntityPoolMinecart;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.entity.RenderMinecart;
|
||||
import net.minecraft.entity.ai.EntityMinecartMobSpawner;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
|
||||
public class RenderPoolMinecart extends RenderMinecart {
|
||||
|
||||
@Override
|
||||
protected void func_147910_a(EntityMinecart p_147910_1_, float p_147910_2_, Block p_147910_3_, int p_147910_4_) {
|
||||
EntityPoolMinecart poolCart = (EntityPoolMinecart) p_147910_1_;
|
||||
RenderTilePool.forceManaNumber = poolCart.getMana();
|
||||
super.func_147910_a(p_147910_1_, p_147910_2_, p_147910_3_, p_147910_4_);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -43,6 +43,7 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
|
||||
|
||||
public static int forceMeta = 0;
|
||||
public static boolean forceMana = false;
|
||||
public static int forceManaNumber = -1;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
|
||||
@@ -69,7 +70,14 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
float waterLevel = (float) pool.getCurrentMana() / (float) pool.manaCap * 0.4F;
|
||||
int mana = pool.getCurrentMana();
|
||||
if(forceManaNumber > -1)
|
||||
mana = forceManaNumber;
|
||||
int cap = pool.manaCap;
|
||||
if(cap == -1)
|
||||
cap = TilePool.MAX_MANA;
|
||||
|
||||
float waterLevel = (float) mana / (float) cap * 0.4F;
|
||||
if(forceMana)
|
||||
waterLevel = 0.4F;
|
||||
|
||||
@@ -125,6 +133,7 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
|
||||
|
||||
forceMeta = 0;
|
||||
forceMana = false;
|
||||
forceManaNumber = -1;
|
||||
}
|
||||
|
||||
public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) {
|
||||
|
||||
@@ -52,6 +52,7 @@ import vazkii.botania.common.block.mana.BlockManaDetector;
|
||||
import vazkii.botania.common.block.mana.BlockManaVoid;
|
||||
import vazkii.botania.common.block.mana.BlockPool;
|
||||
import vazkii.botania.common.block.mana.BlockPrism;
|
||||
import vazkii.botania.common.block.mana.BlockPump;
|
||||
import vazkii.botania.common.block.mana.BlockRFGenerator;
|
||||
import vazkii.botania.common.block.mana.BlockRuneAltar;
|
||||
import vazkii.botania.common.block.mana.BlockSpawnerClaw;
|
||||
@@ -204,6 +205,7 @@ public final class ModBlocks {
|
||||
public static Block corporeaFunnel;
|
||||
public static Block endStoneBrick;
|
||||
public static Block mushroom;
|
||||
public static Block pump;
|
||||
|
||||
public static void init() {
|
||||
flower = new BlockModFlower();
|
||||
@@ -267,6 +269,7 @@ public final class ModBlocks {
|
||||
corporeaFunnel = new BlockCorporeaFunnel();
|
||||
endStoneBrick = new BlockEndStoneBrick();
|
||||
mushroom = new BlockModMushroom();
|
||||
pump = new BlockPump();
|
||||
|
||||
ModFluffBlocks.init();
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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 @ [Mar 17, 2015, 9:46:53 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.mana;
|
||||
|
||||
import net.minecraft.block.BlockPistonBase;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.block.BlockMod;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockPump extends BlockMod {
|
||||
|
||||
private static final int[][] ICON_ORIENTATIONS = {
|
||||
{ 4, 3, 1, 2 },
|
||||
{ 3, 4, 2, 1 },
|
||||
{ 2, 1, 4, 3 },
|
||||
{ 1, 2, 3, 4 }
|
||||
};
|
||||
|
||||
IIcon[] icons = new IIcon[5];
|
||||
|
||||
public BlockPump() {
|
||||
super(Material.rock);
|
||||
setHardness(2.0F);
|
||||
setResistance(10.0F);
|
||||
setStepSound(soundTypeStone);
|
||||
setBlockName(LibBlockNames.PUMP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
|
||||
int orientation = Math.max(2, BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase));
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, orientation, 1 | 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
for(int i = 0; i < icons.length; i++)
|
||||
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int par1, int par2) {
|
||||
return par1 < 2 ? icons[0] : icons[ICON_ORIENTATIONS[Math.max(0, par2 - 2)][par1 - 2]];
|
||||
}
|
||||
|
||||
public int getOrientation(World w, int x, int y, int z) {
|
||||
return w.getBlockMetadata(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
public void recieveMana(int mana) {
|
||||
boolean full = getCurrentMana() >= manaCap;
|
||||
|
||||
this.mana = Math.min(getCurrentMana() + mana, manaCap);
|
||||
this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap));
|
||||
if(!full)
|
||||
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
}
|
||||
|
||||
@@ -208,6 +208,8 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addBlock(ModBlocks.distributor);
|
||||
addBlock(ModBlocks.manaVoid);
|
||||
addBlock(ModBlocks.manaDetector);
|
||||
addItem(ModItems.poolMinecart);
|
||||
addBlock(ModBlocks.pump);
|
||||
addBlock(ModBlocks.rfGenerator);
|
||||
addBlock(ModBlocks.spreader);
|
||||
addBlock(ModBlocks.turntable);
|
||||
@@ -215,7 +217,6 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addItem(ModItems.lens);
|
||||
addItem(ModItems.manaGun);
|
||||
addItem(ModItems.clip);
|
||||
addItem(ModItems.poolMinecart);
|
||||
addItem(ModItems.spark);
|
||||
addItem(ModItems.sparkUpgrade);
|
||||
addItem(ModItems.corporeaSpark);
|
||||
|
||||
@@ -10,24 +10,37 @@
|
||||
*/
|
||||
package vazkii.botania.common.entity;
|
||||
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class EntityPoolMinecart extends EntityMinecart {
|
||||
|
||||
private static final int TRANSFER_RATE = 10000;
|
||||
|
||||
private boolean isBlocked = true;
|
||||
|
||||
public EntityPoolMinecart(World p_i1712_1_) {
|
||||
super(p_i1712_1_);
|
||||
}
|
||||
|
||||
public EntityPoolMinecart(World p_i1715_1_, double p_i1715_2_, double p_i1715_4_, double p_i1715_6_) {
|
||||
super(p_i1715_1_, p_i1715_2_, p_i1715_4_, p_i1715_6_);
|
||||
}
|
||||
|
||||
public EntityPoolMinecart(World p_i1715_1_, double p_i1715_2_, double p_i1715_4_, double p_i1715_6_) {
|
||||
super(p_i1715_1_, p_i1715_2_, p_i1715_4_, p_i1715_6_);
|
||||
protected void entityInit() {
|
||||
super.entityInit();
|
||||
dataWatcher.addObject(16, 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Block func_145817_o() {
|
||||
return ModBlocks.pool;
|
||||
@@ -37,16 +50,67 @@ public class EntityPoolMinecart extends EntityMinecart {
|
||||
public int getMinecartType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killMinecart(DamageSource p_94095_1_) {
|
||||
super.killMinecart(p_94095_1_);
|
||||
this.func_145778_a(Item.getItemFromBlock(ModBlocks.pool), 1, 0.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultDisplayTileOffset() {
|
||||
return 8;
|
||||
}
|
||||
public void killMinecart(DamageSource p_94095_1_) {
|
||||
super.killMinecart(p_94095_1_);
|
||||
this.func_145778_a(Item.getItemFromBlock(ModBlocks.pool), 1, 0.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultDisplayTileOffset() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveMinecartOnRail(int x, int y, int z, double par4) {
|
||||
super.moveMinecartOnRail(x, y, z, par4);
|
||||
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
int xp = x + dir.offsetX;
|
||||
int zp = z + dir.offsetZ;
|
||||
Block block = worldObj.getBlock(xp, y, zp);
|
||||
if(block == ModBlocks.pump) {
|
||||
int xp_ = xp + dir.offsetX;
|
||||
int zp_ = zp + dir.offsetZ;
|
||||
int meta = worldObj.getBlockMetadata(xp, y, zp);
|
||||
TileEntity tile = worldObj.getTileEntity(xp_, y, zp_);
|
||||
if(tile != null && tile instanceof IManaPool) {
|
||||
IManaPool pool = (IManaPool) tile;
|
||||
ForgeDirection pumpDir = ForgeDirection.getOrientation(meta);
|
||||
boolean did = false;
|
||||
|
||||
if(pumpDir == dir) { // Pool -> Cart
|
||||
int cartMana = getMana();
|
||||
int poolMana = pool.getCurrentMana();
|
||||
int transfer = Math.min(TRANSFER_RATE, poolMana);
|
||||
int actualTransfer = Math.min(TilePool.MAX_MANA - cartMana, transfer);
|
||||
if(actualTransfer > 0) {
|
||||
pool.recieveMana(-transfer);
|
||||
setMana(cartMana + actualTransfer);
|
||||
did = true;
|
||||
}
|
||||
} else if(pumpDir == dir.getOpposite() && !pool.isFull()) { // Cart -> Pool
|
||||
int cartMana = getMana();
|
||||
int transfer = Math.min(TRANSFER_RATE, cartMana);
|
||||
pool.recieveMana(transfer);
|
||||
setMana(cartMana - transfer);
|
||||
did = true;
|
||||
}
|
||||
|
||||
if(did)
|
||||
worldObj.markBlockForUpdate(xp_, y, zp_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getMana() {
|
||||
return dataWatcher.getWatchableObjectInt(16);
|
||||
}
|
||||
|
||||
public void setMana(int mana) {
|
||||
dataWatcher.updateObject(16, mana);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class ItemPoolMinecart extends ItemMod {
|
||||
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
|
||||
if(BlockRailBase.func_150051_a(p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_))) {
|
||||
if(!p_77648_3_.isRemote) {
|
||||
EntityMinecart entityminecart = new EntityPoolMinecart(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
|
||||
EntityMinecart entityminecart = new EntityPoolMinecart(p_77648_3_, p_77648_4_ + 0.5, p_77648_5_ + 0.5, p_77648_6_ + 0.5);
|
||||
|
||||
if(p_77648_1_.hasDisplayName())
|
||||
entityminecart.setMinecartName(p_77648_1_.getDisplayName());
|
||||
|
||||
@@ -76,6 +76,7 @@ public final class LibBlockNames {
|
||||
public static final String CORPOREA_FUNNEL = "corporeaFunnel";
|
||||
public static final String END_STONE_BRICK = "endStoneBrick";
|
||||
public static final String MUSHROOM = "mushroom";
|
||||
public static final String PUMP = "pump";
|
||||
|
||||
public static final String SUBTILE_PUREDAISY = "puredaisy";
|
||||
public static final String SUBTILE_MANASTAR = "manastar";
|
||||
|
||||
Reference in new issue
Block a user