Skip to content

Commit

Permalink
Mana Bursts that have been teleported by a Warp Lens can no longer de…
Browse files Browse the repository at this point in the history
…liver mana to receiving blocks.
  • Loading branch information
Vazkii committed Oct 22, 2016
1 parent 7fbaea8 commit 5f56dfb
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/vazkii/botania/api/mana/ILens.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
*/
package vazkii.botania.api.mana;

import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.internal.IManaBurst;

/**
* Have an Item implement this to be counted as a lens for the mana spreader.
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/vazkii/botania/api/mana/ILensEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
package vazkii.botania.api.mana;

import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
Expand Down Expand Up @@ -45,4 +46,11 @@ public interface ILensEffect {
*/
public boolean doParticles(IManaBurst burst, ItemStack stack);

/**
* Gets the amount of mana to transfer to the passed in mana receiver block.
*/
public default int getManaToTransfer(IManaBurst burst, EntityThrowable entity, ItemStack stack, IManaReceiver receiver) {
return burst.getMana();
}

}
2 changes: 1 addition & 1 deletion src/main/java/vazkii/botania/api/package-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@API(owner = "Botania", apiVersion = "84", provides = "BotaniaAPI")
@API(owner = "Botania", apiVersion = "85", provides = "BotaniaAPI")
package vazkii.botania.api;
import net.minecraftforge.fml.common.API;

Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,19 @@ protected void onImpact(@Nonnull RayTraceResult rtr) {
}

private void onRecieverImpact(IManaReceiver tile, BlockPos pos) {
ILensEffect lens = getLensInstance();
int mana = getMana();

if(lens != null) {
ItemStack stack = getSourceLens();
mana = lens.getManaToTransfer(this, this, stack, tile);
}

if(tile instanceof IManaCollector)
mana *= ((IManaCollector) tile).getManaYieldMultiplier(this);

tile.recieveMana(mana);

if(tile instanceof IThrottledPacket)
((IThrottledPacket) tile).markDispatchable();
else VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/vazkii/botania/common/item/lens/ItemLens.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import vazkii.botania.api.mana.ICompositableLens;
import vazkii.botania.api.mana.ILens;
import vazkii.botania.api.mana.ILensControl;
import vazkii.botania.api.mana.IManaReceiver;
import vazkii.botania.api.mana.IManaSpreader;
import vazkii.botania.api.mana.ITinyPlanetExcempt;
import vazkii.botania.client.core.handler.ModelHandler;
Expand Down Expand Up @@ -310,6 +311,11 @@ public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens)
return sourceLens;
}

@Override
public int getManaToTransfer(IManaBurst burst, EntityThrowable entity, ItemStack stack, IManaReceiver receiver) {
return lenses[stack.getItemDamage()].getManaToTransfer(burst, entity, stack, receiver);
}

@Override
public boolean shouldPull(ItemStack stack) {
return stack.getItemDamage() != STORM;
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/vazkii/botania/common/item/lens/Lens.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.BurstProperties;
import vazkii.botania.api.mana.IManaBlock;
import vazkii.botania.api.mana.IManaReceiver;
import vazkii.botania.api.mana.IManaSpreader;

public class Lens {
Expand All @@ -34,6 +36,9 @@ public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boole
public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) {}

public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) {}


public int getManaToTransfer(IManaBurst burst, EntityThrowable entity, ItemStack stack, IManaReceiver receiver) {
return burst.getMana();
}

}
13 changes: 12 additions & 1 deletion src/main/java/vazkii/botania/common/item/lens/LensWarp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,39 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.IManaReceiver;
import vazkii.botania.common.block.BlockPistonRelay;
import vazkii.botania.common.block.ModBlocks;

public class LensWarp extends Lens {

private static final String TAG_WARPED = "botania:warped";

@Override
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(burst.isFake() || pos.getBlockPos() == null)
return dead;

Block block = entity.worldObj.getBlockState(pos.getBlockPos()).getBlock();
if(block == ModBlocks.pistonRelay) {
BlockPistonRelay.DimWithPos key = ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.get(new BlockPistonRelay.DimWithPos(entity.worldObj.provider.getDimension(), pos.getBlockPos()));
if(key != null) {
if(key.dim == entity.worldObj.provider.getDimension()) {
entity.setPosition(key.blockPos.getX() + 0.5, key.blockPos.getY() + 0.5, key.blockPos.getZ() + 0.5);
burst.setCollidedAt(key.blockPos);

entity.getEntityData().setBoolean(TAG_WARPED, true);

return false;
}
}
}
return dead;
}

@Override
public int getManaToTransfer(IManaBurst burst, EntityThrowable entity, ItemStack stack, IManaReceiver receiver) {
return entity.getEntityData().getBoolean(TAG_WARPED) ? 0 : burst.getMana();
}

}
2 changes: 1 addition & 1 deletion src/main/resources/assets/botania/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -3156,7 +3156,7 @@ botania.page.enderEyeBlock1=MY BRAND
botania.entry.pistonRelay=Force Relay
botania.tagline.pistonRelay=Remote piston extension
botania.page.pistonRelay0=It seems that infusing &1Pistons&0 with &4Mana&0 results in some interesting adverse effects.<br>This block tears the fabric of space, relaying any piston force applied to it to the block it's bound to.<br>To bind it to a block, right click it with a &1Wand of the Forest&0, and right click on the block you want to bind it to.
botania.page.pistonRelay1=To break the block, shift-right click it with a &1Wand of the Forest&0, any other means will destroy it.<br>Furthermore, this block is highly unstable, and may create uncanny effects, care is to be taken. It is also resistant to glue, both in pulling and pushing. This allows for a "frame" like setup.
botania.page.pistonRelay1=To break the block, shift-right click it with a &1Wand of the Forest&0, any other means will destroy it.<br>Furthermore, this block is highly unstable, and may create uncanny effects, care is to be taken. It also ignores &1Sticky Pistons&0, both in pulling and pushing. This allows for a "frame" like setup.
botania.page.pistonRelay2=Infusing a &1Piston&0 with &4Mana&0.

# -- HAND OF ENDER
Expand Down

0 comments on commit 5f56dfb

Please sign in to comment.