mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
The light gem will now emit light
This commit is contained in:
parent
01a16fb92d
commit
e8b2b13a38
2 changed files with 65 additions and 1 deletions
|
@ -0,0 +1,64 @@
|
|||
package com.minelittlepony.unicopia.spell;
|
||||
|
||||
import com.minelittlepony.util.PosHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SpellLight extends GenericSpell {
|
||||
|
||||
private BlockPos lastPos;
|
||||
private ICaster<?> source;
|
||||
|
||||
public SpellLight() {
|
||||
super("light", 0xF7FACB, SpellAffinity.GOOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(ICaster<?> caster) {
|
||||
this.source = caster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDead() {
|
||||
super.setDead();
|
||||
|
||||
if (lastPos != null) {
|
||||
source.getWorld().checkLight(lastPos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(ICaster<?> source) {
|
||||
this.source = source;
|
||||
|
||||
BlockPos pos = source.getOrigin().down();
|
||||
|
||||
World world = source.getWorld();
|
||||
|
||||
if (lastPos != null && !lastPos.equals(pos)) {
|
||||
world.checkLight(lastPos);
|
||||
}
|
||||
|
||||
lastPos = pos;
|
||||
|
||||
|
||||
int light = world.getLightFor(EnumSkyBlock.BLOCK, pos);
|
||||
|
||||
if (light < 8) {
|
||||
world.setLightFor(EnumSkyBlock.BLOCK, pos, 8);
|
||||
world.notifyLightSet(pos);
|
||||
world.checkLight(pos.up());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void resetLight(BlockPos pos) {
|
||||
|
||||
}
|
||||
}
|
|
@ -46,7 +46,7 @@ public class SpellRegistry {
|
|||
registerSpell(SpellDarkness::new);
|
||||
registerSpell(SpellFlame::new);
|
||||
registerSpell(SpellSiphon::new);
|
||||
registerSpell(GenericSpell.factory("light", 0xF7FACB, SpellAffinity.GOOD));
|
||||
registerSpell(SpellLight::new);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
Loading…
Reference in a new issue