-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e14fc4
commit 04bf3f4
Showing
8 changed files
with
250 additions
and
1 deletion.
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
src/main/java/com/gmail/pharaun/gregtania/botania/GTItemLens.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/** | ||
* 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 @ [Jan 31, 2014, 3:02:58 PM (GMT)] | ||
* Modified by Codewarrior0 | ||
*/ | ||
package com.gmail.pharaun.gregtania.botania; | ||
|
||
import cpw.mods.fml.common.registry.GameRegistry; | ||
import net.minecraft.client.renderer.texture.IIconRegister; | ||
import net.minecraft.entity.projectile.EntityThrowable; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.IIcon; | ||
import net.minecraft.util.MovingObjectPosition; | ||
import vazkii.botania.api.internal.IManaBurst; | ||
import vazkii.botania.api.mana.BurstProperties; | ||
import vazkii.botania.api.mana.ILensControl; | ||
import vazkii.botania.api.mana.IManaSpreader; | ||
import vazkii.botania.api.mana.ITinyPlanetExcempt; | ||
|
||
public class GTItemLens extends Item implements ILensControl, ITinyPlanetExcempt { | ||
|
||
private final LensIridiumBore BORE_LENS; | ||
static IIcon iconIridiumBoreGlass; | ||
|
||
public GTItemLens() { | ||
super(); | ||
setUnlocalizedName("lensIridiumBore"); | ||
GameRegistry.registerItem(this, "lensIridiumBore"); | ||
setMaxStackSize(1); | ||
setHasSubtypes(true); | ||
BORE_LENS = new LensIridiumBore(); | ||
} | ||
|
||
@Override | ||
public void registerIcons(IIconRegister par1IconRegister) { | ||
iconIridiumBoreGlass = par1IconRegister.registerIcon("gregtania:lensIridiumBoreGlass"); | ||
this.itemIcon = par1IconRegister.registerIcon("gregtania:lensIridiumBore"); | ||
} | ||
|
||
@Override | ||
public void apply(ItemStack stack, BurstProperties props) { | ||
BORE_LENS.apply(stack, props); | ||
} | ||
|
||
@Override | ||
public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { | ||
EntityThrowable entity = (EntityThrowable) burst; | ||
return BORE_LENS.collideBurst(burst, entity, pos, isManaBlock, dead, stack); | ||
} | ||
|
||
@Override | ||
public void updateBurst(IManaBurst burst, ItemStack stack) { | ||
EntityThrowable entity = (EntityThrowable) burst; | ||
BORE_LENS.updateBurst(burst, entity, stack); | ||
|
||
} | ||
|
||
|
||
|
||
@Override | ||
public int getLensColor(ItemStack stack) { | ||
return 0xFFFFFF; | ||
} | ||
|
||
@Override | ||
public boolean requiresMultipleRenderPasses() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public IIcon getIconFromDamageForRenderPass(int par1, int par2) { | ||
return par2 == 1 ? itemIcon : iconIridiumBoreGlass; | ||
} | ||
|
||
@Override | ||
public boolean doParticles(IManaBurst burst, ItemStack stack) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean canCombineLenses(ItemStack itemStack, ItemStack itemStack1) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ItemStack getCompositeLens(ItemStack stack) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens) { | ||
return sourceLens; | ||
} | ||
|
||
@Override | ||
public boolean shouldPull(ItemStack stack) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isControlLens(ItemStack stack) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { | ||
return BORE_LENS.allowBurstShooting(stack, spreader, redstone); | ||
} | ||
|
||
@Override | ||
public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { | ||
BORE_LENS.onControlledSpreaderTick(stack, spreader, redstone); | ||
} | ||
|
||
@Override | ||
public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { | ||
BORE_LENS.onControlledSpreaderPulse(stack, spreader, redstone); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/main/java/com/gmail/pharaun/gregtania/botania/LensIridiumBore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.gmail.pharaun.gregtania.botania; | ||
|
||
/** | ||
* 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 @ [Jan 24, 2015, 4:36:20 PM (GMT)] | ||
* Modified by Codewarrior0 | ||
*/ | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.item.EntityItem; | ||
import net.minecraft.entity.projectile.EntityThrowable; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.ChunkCoordinates; | ||
import net.minecraft.util.MovingObjectPosition; | ||
import net.minecraft.world.World; | ||
import vazkii.botania.api.internal.IManaBurst; | ||
import vazkii.botania.api.mana.IManaBlock; | ||
import vazkii.botania.common.block.ModBlocks; | ||
import vazkii.botania.common.core.handler.ConfigHandler; | ||
import vazkii.botania.common.item.ModItems; | ||
import vazkii.botania.common.item.lens.ItemLens; | ||
import vazkii.botania.common.item.lens.Lens; | ||
|
||
public class LensIridiumBore extends Lens { | ||
|
||
@Override | ||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { | ||
World world = entity.worldObj; | ||
int x = pos.blockX; | ||
int y = pos.blockY; | ||
int z = pos.blockZ; | ||
Block block = world.getBlock(x, y, z); | ||
int meta = world.getBlockMetadata(x, y, z); | ||
ItemStack composite = ((ItemLens) ModItems.lens).getCompositeLens(stack); | ||
boolean warp = composite != null && composite.getItem() == ModItems.lens && composite.getItemDamage() == ItemLens.WARP; | ||
|
||
if(warp && (block == ModBlocks.pistonRelay || block == Blocks.piston || block == Blocks.piston_extension || block == Blocks.piston_head)) | ||
return false; | ||
|
||
int harvestLevel = 999; | ||
|
||
TileEntity tile = world.getTileEntity(x, y, z); | ||
|
||
float hardness = block.getBlockHardness(world, x, y, z); | ||
int neededHarvestLevel = block.getHarvestLevel(meta); | ||
int mana = burst.getMana(); | ||
|
||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); | ||
if((coords.posX != x || coords.posY != y || coords.posZ != z) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && (burst.isFake() || mana >= 24)) { | ||
List<ItemStack> items = new ArrayList(); | ||
|
||
items.addAll(block.getDrops(world, x, y, z, meta, 0)); | ||
|
||
if(!burst.hasAlreadyCollidedAt(x, y, z)) { | ||
if(!burst.isFake() && !entity.worldObj.isRemote) { | ||
world.setBlockToAir(x, y, z); | ||
if(ConfigHandler.blockBreakParticles) | ||
entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); | ||
|
||
boolean offBounds = coords.posY < 0; | ||
boolean doWarp = warp && !offBounds; | ||
int dropX = doWarp ? coords.posX : x; | ||
int dropY = doWarp ? coords.posY : y; | ||
int dropZ = doWarp ? coords.posZ : z; | ||
|
||
for(ItemStack stack_ : items) | ||
world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_)); | ||
|
||
burst.setMana(mana - 24); | ||
} | ||
} | ||
|
||
dead = false; | ||
} | ||
|
||
return dead; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+2.97 KB
src/main/resources/assets/gregtania/textures/items/lensIridiumBore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.81 KB
src/main/resources/assets/gregtania/textures/items/lensIridiumBoreGlass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.