Added Redstone Mana Spreaders.

This commit is contained in:
Vasco Lavos committed 2014-04-12 18:00:17 +01:00
1 parent 19292cf171
commit bccf47a819
7 files changed
+66 -16

No files matched your search

@@ -45,6 +45,7 @@ public final class LibResources {
public static final String MODEL_ALTAR = PREFIX_MODEL + "altar.png";
public static final String MODEL_SPREADER = PREFIX_MODEL + "spreader.png";
public static final String MODEL_SPREADER_REDSTONE = PREFIX_MODEL + "spreaderRedstone.png";
public static final String MODEL_POOL = PREFIX_MODEL + "pool.png";
public static final String MODEL_PYLON_OLD = PREFIX_MODEL + "pylonOld.png";
public static final String MODEL_PYLON = PREFIX_MODEL + "pylon.png";
@@ -28,6 +28,7 @@ public class RenderSpreader implements ISimpleBlockRenderingHandler {
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
TileSpreader.staticRedstone = (metadata & 1) == 1;
TileSpreader spreader = new TileSpreader();
spreader.rotationX = -180F;
TileEntityRendererDispatcher.instance.renderTileEntityAt(spreader, 0.0D, 0.0D, 0.0D, 0.0F);
@@ -30,6 +30,8 @@ import vazkii.botania.common.block.tile.TileSpreader;
public class RenderTileSpreader extends TileEntitySpecialRenderer {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPREADER);
private static final ResourceLocation textureRs = new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE);
private static final ModelSpreader model = new ModelSpreader();
@Override
@@ -46,7 +48,7 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer {
GL11.glRotatef(spreader.rotationY, 1F, 0F, 0F);
GL11.glTranslatef(0F, 1F, 0F);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
Minecraft.getMinecraft().renderEngine.bindTexture(spreader.isRedstone() ? textureRs : texture);
GL11.glScalef(1F, -1F, -1F);
model.render();
GL11.glScalef(1F, -1F, -1F);
@@ -11,17 +11,22 @@
*/
package vazkii.botania.common.block;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@@ -36,6 +41,7 @@ import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.block.tile.TileSpreader;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
@@ -51,17 +57,35 @@ public class BlockSpreader extends BlockModContainer implements IWandable, IWand
random = new Random();
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// NO-OP
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2, List par3) {
for(int i = 0; i < 2; i++)
par3.add(new ItemStack(par1, 1, i));
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase);
TileSpreader spreader = (TileSpreader) par1World.getTileEntity(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() & 1, 1 | 2);
switch(orientation) {
case 0:
spreader.rotationY = -90F;
@@ -82,7 +106,12 @@ public class BlockSpreader extends BlockModContainer implements IWandable, IWand
break;
}
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public boolean isOpaqueCube() {
return false;
@@ -110,8 +139,9 @@ public class BlockSpreader extends BlockModContainer implements IWandable, IWand
ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem();
boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens;
if(heldItem != null && heldItem.getItem() == ModItems.twigWand)
return false;
if(heldItem != null)
if(heldItem.getItem() == ModItems.twigWand)
return false;
if(lens == null && isHeldItemLens) {
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
@@ -26,6 +26,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -56,20 +57,23 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
private static final String TAG_ROTATION_X = "rotationX";
private static final String TAG_ROTATION_Y = "rotationY";
public static boolean staticRedstone = false;
int mana;
int knownMana = -1;
public float rotationX, rotationY;
boolean added = false;
boolean requestsClientUpdate = false;
IManaReceiver receiver = null;
boolean redstoneLastTick = false;
public boolean canShootBurst = true;
public int lastBurstDeathTick = -1;
public int burstParticleTick = 0;
List<PositionProperties> lastTentativeBurst;
@Override
public boolean isFull() {
return mana >= MAX_MANA;
@@ -122,8 +126,15 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
if(needsNewBurstSimulation())
checkForReceiver();
if(!redstone)
boolean shouldShoot = !redstone;
if(isRedstone())
shouldShoot = redstone && !redstoneLastTick;
if(shouldShoot)
tryShootBurst();
redstoneLastTick = redstone;
}
@Override
@@ -203,7 +214,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
requestsClientUpdate = false;
return true;
}
for(PositionProperties props : lastTentativeBurst)
if(!props.contentsEqual(worldObj))
return true;
@@ -212,8 +223,8 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
}
public void tryShootBurst() {
if(receiver != null) {
if(canShootBurst && receiver.canRecieveManaFromBursts() && !receiver.isFull()) {
if(receiver != null || isRedstone()) {
if(isRedstone() || (canShootBurst && receiver.canRecieveManaFromBursts() && !receiver.isFull())) {
EntityManaBurst burst = getBurst(false);
if(burst != null) {
if(!worldObj.isRemote) {
@@ -227,6 +238,10 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
}
}
}
public boolean isRedstone() {
return worldObj == null ? staticRedstone : (getBlockMetadata() & 1) == 1;
}
public void checkForReceiver() {
EntityManaBurst fakeBurst = getBurst(true);
@@ -243,7 +258,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
EntityManaBurst burst = new EntityManaBurst(this, fake);
int maxMana = 160;
int color = 0x00FF00;
int color = isRedstone() ? 0xFF0000 : 0x00FF00;
int ticksBeforeManaLoss = 60;
float manaLossPerTick = 4F;
float motionModifier = 1F;
@@ -293,8 +308,8 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
}
public void renderHUD(Minecraft mc, ScaledResolution res) {
String name = ModBlocks.spreader.getLocalizedName();
int color = 0x6600FF00;
String name = StatCollector.translateToLocal(new ItemStack(ModBlocks.spreader, 1, getBlockMetadata()).getUnlocalizedName() + ".name");
int color = isRedstone() ? 0x66FF0000 : 0x6600FF00;
HUDHandler.drawSimpleManaHUD(color, knownMana, MAX_MANA, name, res);
ItemStack lens = getStackInSlot(0);
@@ -374,7 +389,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
checkForReceiver();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public ChunkCoordinates getBinding() {
if(receiver == null)
+2 -1
View File
@@ -70,7 +70,8 @@ tile.botania:livingwood2.name=Mossy Livingwood Planks
tile.botania:livingwood3.name=Framed Livingwood
tile.botania:livingwood4.name=Pattern Framed Livingwood
tile.botania:livingwood5.name=Glimmering Livingwood
tile.botania:spreader.name=Mana Spreader
tile.botania:spreader0.name=Mana Spreader
tile.botania:spreader1.name=Redstone Mana Spreader
tile.botania:pool.name=Mana Pool
tile.botania:runeAltar.name=Runic Altar
tile.botania:unstableBlock0.name=White Unstable Cube
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB