mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-25 06:24:27 +00:00
Added the Rannuncarpus.
This commit is contained in:
1 parent
ef79fcdd95
commit
b0883701bc
6 files changed
+170
-1
No files matched your search
@@ -71,6 +71,7 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid
|
||||
LibBlockNames.SUBTILE_EXOFLAME,
|
||||
LibBlockNames.SUBTILE_AGRICARNATION,
|
||||
LibBlockNames.SUBTILE_HOPPERHOCK,
|
||||
LibBlockNames.SUBTILE_RANNUNCARPUS,
|
||||
LibBlockNames.SUBTILE_TANGLEBERRIE,
|
||||
LibBlockNames.SUBTILE_JIYUULIA
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ import vazkii.botania.common.block.subtile.functional.SubTileHeiseiDream;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileHopperhock;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileJadedAmaranthus;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileJiyuulia;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileRannuncarpus;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileTangleberrie;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileTigerseye;
|
||||
import vazkii.botania.common.block.subtile.functional.SubtileOrechid;
|
||||
@@ -137,6 +138,7 @@ public final class ModBlocks {
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HOPPERHOCK, SubTileHopperhock.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TANGLEBERRIE, SubTileTangleberrie.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_JIYUULIA, SubTileJiyuulia.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_RANNUNCARPUS, SubTileRannuncarpus.class);
|
||||
}
|
||||
|
||||
private static void registerMultiparts() {
|
||||
|
||||
@@ -11,6 +11,166 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.subtile.functional;
|
||||
|
||||
public class SubTileRannuncarpus {
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemReed;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import vazkii.botania.common.core.helper.ObfuscationHelper;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
|
||||
int cooldown = 0;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if(cooldown > 0) {
|
||||
cooldown--;
|
||||
return;
|
||||
}
|
||||
|
||||
BlockData filter = getUnderlyingBlock();
|
||||
|
||||
boolean scanned = false;
|
||||
List<ChunkCoordinates> validPositions = new ArrayList();
|
||||
|
||||
int range = 2;
|
||||
int rangePlace = mana > 0 ? 8 : 6;
|
||||
int rangePlaceY = 6;
|
||||
|
||||
int x = supertile.xCoord;
|
||||
int y = supertile.yCoord;
|
||||
int z = supertile.zCoord;
|
||||
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - 3, z - range, x + range + 1, y + 3, z + range + 1));
|
||||
for(EntityItem item : items) {
|
||||
if(item.age < 60)
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
Item stackItem = stack.getItem();
|
||||
if(stackItem instanceof ItemBlock || stackItem instanceof ItemReed) {
|
||||
if(!scanned) {
|
||||
for(int i = -rangePlace; i < rangePlace; i++)
|
||||
for(int j = -rangePlaceY; j < rangePlaceY; j++)
|
||||
for(int l = -rangePlace; l < rangePlace; l++) {
|
||||
int xp = x + i;
|
||||
int yp = y + j;
|
||||
int zp = z + l;
|
||||
Block blockAbove = supertile.getWorldObj().getBlock(xp, yp + 1, zp);
|
||||
|
||||
if(filter.equals(supertile.getWorldObj(), xp, yp, zp) && (blockAbove.isAir(supertile.getWorldObj(), xp, yp + 1, zp) || blockAbove.isReplaceable(supertile.getWorldObj(), xp, yp + 1, zp)))
|
||||
validPositions.add(new ChunkCoordinates(xp, yp + 1, zp));
|
||||
}
|
||||
|
||||
scanned = true;
|
||||
}
|
||||
|
||||
|
||||
if(!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) {
|
||||
Block blockToPlace = null;
|
||||
if(stackItem instanceof ItemBlock)
|
||||
blockToPlace = ((ItemBlock) stackItem).field_150939_a;
|
||||
else if(stackItem instanceof ItemReed)
|
||||
blockToPlace = ReflectionHelper.getPrivateValue(ItemReed.class, (ItemReed) stackItem, LibObfuscation.REED_ITEM);
|
||||
|
||||
if(blockToPlace != null) {
|
||||
ChunkCoordinates coords = validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size()));
|
||||
if(blockToPlace.canPlaceBlockAt(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) {
|
||||
supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, blockToPlace, stack.getItemDamage(), 1 | 2);
|
||||
supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(blockToPlace) + (stack.getItemDamage() << 12));
|
||||
validPositions.remove(coords);
|
||||
|
||||
if(!supertile.getWorldObj().isRemote) {
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
item.setDead();
|
||||
}
|
||||
|
||||
cooldown = 10;
|
||||
if(mana > 1)
|
||||
mana--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlockData getUnderlyingBlock() {
|
||||
return new BlockData(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord - 2, supertile.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
super.renderHUD(mc, res);
|
||||
|
||||
BlockData filter = getUnderlyingBlock();
|
||||
ItemStack recieverStack = new ItemStack(Item.getItemFromBlock(filter.block), 1, filter.meta);
|
||||
int color = 0x66000000 | getColor();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
if(recieverStack != null && recieverStack.getItem() != null) {
|
||||
String stackName = recieverStack.getDisplayName();
|
||||
int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2;
|
||||
int x = res.getScaledWidth() / 2 - width;
|
||||
int y = res.getScaledHeight() / 2 + 30;
|
||||
|
||||
mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color);
|
||||
new RenderItem().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMana() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0xFFB27F;
|
||||
}
|
||||
|
||||
static class BlockData {
|
||||
|
||||
Block block;
|
||||
int meta;
|
||||
|
||||
public BlockData(World world, int x, int y, int z) {
|
||||
block = world.getBlock(x, y, z);
|
||||
meta = world.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
public boolean equals(BlockData data) {
|
||||
return block == data.block && meta == data.meta;
|
||||
}
|
||||
|
||||
public boolean equals(World world, int x, int y, int z) {
|
||||
return equals(new BlockData(world, x, y, z));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,4 +56,5 @@ public final class LibBlockNames {
|
||||
public static final String SUBTILE_HOPPERHOCK = "hopperhock";
|
||||
public static final String SUBTILE_TANGLEBERRIE = "tangleberrie";
|
||||
public static final String SUBTILE_JIYUULIA = "jiyuulia";
|
||||
public static final String SUBTILE_RANNUNCARPUS = "rannuncarpus";
|
||||
}
|
||||
@@ -34,4 +34,7 @@ public final class LibObfuscation {
|
||||
|
||||
// Entity
|
||||
public static final String[] IS_IMMUNE_TO_FIRE = new String[] { "isImmuneToFire", "field_70178_ae", "ag" };
|
||||
|
||||
// ItemReed
|
||||
public static final String[] REED_ITEM = new String[] { "field_150935_a", "a" };
|
||||
}
|
||||
@@ -169,6 +169,8 @@ tile.botania:flower.tangleberrie.reference=No frying pans allowed
|
||||
tile.botania:flower.jiyuulia.name=Jiyuulia
|
||||
tile.botania:flower.jiyuulia.reference=Flügel der Freiheit
|
||||
# TRANSLATE THAT VEXATOS
|
||||
tile.botania:flower.rannuncarpus.name=Rannuncarpus
|
||||
tile.botania:flower.rannuncarpus.reference=That's handy
|
||||
|
||||
# ITEM NAMES
|
||||
item.botania:lexicon.name=Lexica Botania
|
||||
|
||||
Reference in new issue
Block a user