mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
added the lamp of sanctuary
This commit is contained in:
parent
ca3fca7eac
commit
71a28a67bb
10 changed files with 335 additions and 0 deletions
102
src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java
Normal file
102
src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockSpawnLamp extends BlockContainerImpl {
|
||||
|
||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F);
|
||||
|
||||
public BlockSpawnLamp() {
|
||||
super(Material.IRON, "spawn_lamp", TileEntitySpawnLamp.class, "spawn_lamp");
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
this.setLightLevel(1F);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onSpawn(LivingSpawnEvent.CheckSpawn event) {
|
||||
if (event.getSpawner() != null)
|
||||
return;
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = new BlockPos(event.getX(), event.getY(), event.getZ());
|
||||
Helper.getTileEntitiesInArea(world, pos, 48, tile -> {
|
||||
if (!(tile instanceof TileEntitySpawnLamp))
|
||||
return false;
|
||||
TileEntitySpawnLamp lamp = (TileEntitySpawnLamp) tile;
|
||||
int range = lamp.getRadius();
|
||||
if (range <= 0)
|
||||
return false;
|
||||
|
||||
BlockPos lampPos = lamp.getPos();
|
||||
if (pos.distanceSq(lampPos.getX() + 0.5F, lampPos.getY() + 0.5F, lampPos.getZ() + 0.5F) > range * range)
|
||||
return false;
|
||||
|
||||
EntityLiving entity = (EntityLiving) event.getEntityLiving();
|
||||
if (entity.getCanSpawnHere() && entity.isNotColliding()) {
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(world, lampPos, 32, lampPos);
|
||||
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 2);
|
||||
|
||||
PacketHandler.sendToAllAround(world, lampPos, 32,
|
||||
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), 15));
|
||||
}
|
||||
|
||||
event.setResult(Event.Result.DENY);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockState baseState, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
}
|
|
@ -36,4 +36,5 @@ public final class ModBlocks {
|
|||
public static final Block INFUSED_IRON = new BlockImpl("infused_iron_block", Material.IRON).setSoundType(SoundType.METAL).setHardness(3F);
|
||||
public static final Block OFFERING_TABLE = new BlockOfferingTable();
|
||||
public static final Block PICKUP_STOPPER = new BlockPickupStopper();
|
||||
public static final Block SPAWN_LAMP = new BlockSpawnLamp();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
public class TileEntitySpawnLamp extends TileEntityImpl {
|
||||
|
||||
public int getRadius() {
|
||||
return this.redstonePower * 3;
|
||||
}
|
||||
|
||||
}
|
|
@ -262,6 +262,15 @@ public class PacketParticles implements IMessage {
|
|||
world.rand.nextGaussian() * 0.005F,
|
||||
0xcc3116, 1.5F, 40, 0F, false, true);
|
||||
break;
|
||||
case 15: // Spawn lamp
|
||||
for (int i = world.rand.nextInt(5) + 5; i >= 0; i--)
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
message.posX + 0.3F + world.rand.nextFloat() * 0.4F,
|
||||
message.posY + 0.15F + world.rand.nextFloat() * 0.5F,
|
||||
message.posZ + 0.3F + world.rand.nextFloat() * 0.4F,
|
||||
0F, 0F, 0F,
|
||||
0xf4a142, 1F, 30, 0F, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "naturesaura:spawn_lamp",
|
||||
"textures": {
|
||||
"0": "naturesaura:blocks/spawn_lamp",
|
||||
"particle": "#0"
|
||||
},
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
"normal": [{}],
|
||||
"inventory": [{}]
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ tile.naturesaura.oak_generator.name=Canopy Diminisher
|
|||
tile.naturesaura.infused_iron_block.name=Infused Iron Block
|
||||
tile.naturesaura.offering_table.name=Offering Table
|
||||
tile.naturesaura.pickup_stopper.name=Item Grounder
|
||||
tile.naturesaura.spawn_lamp.name=Lamp of Sanctuary
|
||||
|
||||
item.naturesaura.eye.name=Environmental Eye
|
||||
item.naturesaura.gold_fiber.name=Brilliant Fiber
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
{
|
||||
"__comment": "Model contributed by PolarizedIons <3",
|
||||
"elements": [
|
||||
{
|
||||
"name": "Base",
|
||||
"from": [4.0, 0.0, 4.0],
|
||||
"to": [12.0, 2.0, 12.0],
|
||||
"faces": {
|
||||
"north": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 10.0, 8.0, 12.0]
|
||||
},
|
||||
"east": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 10.0, 8.0, 12.0]
|
||||
},
|
||||
"south": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 10.0, 8.0, 12.0]
|
||||
},
|
||||
"west": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 10.0, 8.0, 12.0]
|
||||
},
|
||||
"up": {
|
||||
"texture": "#0",
|
||||
"uv": [8.0, 8.0, 16.0, 16.0]
|
||||
},
|
||||
"down": {
|
||||
"texture": "#0",
|
||||
"uv": [8.0, 8.0, 16.0, 16.0]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Glass",
|
||||
"from": [4.0, 2.0, 4.0],
|
||||
"to": [12.0, 10.0, 12.0],
|
||||
"faces": {
|
||||
"north": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 2.0, 8.0, 10.0]
|
||||
},
|
||||
"east": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 2.0, 8.0, 10.0]
|
||||
},
|
||||
"south": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 2.0, 8.0, 10.0]
|
||||
},
|
||||
"west": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 2.0, 8.0, 10.0]
|
||||
},
|
||||
"up": {
|
||||
"texture": "#-1"
|
||||
},
|
||||
"down": {
|
||||
"texture": "#-1"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Lid",
|
||||
"from": [4.0, 10.0, 4.0],
|
||||
"to": [12.0, 12.0, 12.0],
|
||||
"faces": {
|
||||
"north": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 0.0, 8.0, 2.0]
|
||||
},
|
||||
"east": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 0.0, 8.0, 2.0]
|
||||
},
|
||||
"south": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 0.0, 8.0, 2.0]
|
||||
},
|
||||
"west": {
|
||||
"texture": "#0",
|
||||
"uv": [0.0, 0.0, 8.0, 2.0]
|
||||
},
|
||||
"up": {
|
||||
"texture": "#0",
|
||||
"uv": [8.0, 8.0, 16.0, 16.0]
|
||||
},
|
||||
"down": {
|
||||
"texture": "#0",
|
||||
"uv": [8.0, 8.0, 16.0, 16.0]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Hook",
|
||||
"from": [6.0, 12.0, 6.0],
|
||||
"to": [10.0, 13.0, 10.0],
|
||||
"faces": {
|
||||
"north": {
|
||||
"texture": "#0",
|
||||
"uv": [8.0, 0.0, 12.0, 2.0]
|
||||
},
|
||||
"east": {
|
||||
"texture": "#0",
|
||||
"uv": [8.0, 0.0, 12.0, 2.0]
|
||||
},
|
||||
"south": {
|
||||
"texture": "#0",
|
||||
"uv": [8.0, 0.0, 12.0, 2.0]
|
||||
},
|
||||
"west": {
|
||||
"texture": "#0",
|
||||
"uv": [8.0, 0.0, 12.0, 2.0]
|
||||
},
|
||||
"up": {
|
||||
"texture": "#0",
|
||||
"uv": [8.0, 2.0, 12.0, 6.0]
|
||||
},
|
||||
"down": {
|
||||
"texture": "#-1"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Light",
|
||||
"from": [6.0, 2.0, 6.0],
|
||||
"to": [10.0, 10.0, 10.0],
|
||||
"faces": {
|
||||
"north": {
|
||||
"texture": "#0",
|
||||
"uv": [12.0, 0.0, 16.0, 8.0]
|
||||
},
|
||||
"east": {
|
||||
"texture": "#0",
|
||||
"uv": [12.0, 0.0, 16.0, 8.0]
|
||||
},
|
||||
"south": {
|
||||
"texture": "#0",
|
||||
"uv": [12.0, 0.0, 16.0, 8.0]
|
||||
},
|
||||
"west": {
|
||||
"texture": "#0",
|
||||
"uv": [12.0, 0.0, 16.0, 8.0]
|
||||
},
|
||||
"up": {
|
||||
"texture": "#-1"
|
||||
},
|
||||
"down": {
|
||||
"texture": "#-1"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "Lamp of Sanctuary",
|
||||
"icon": "naturesaura:spawn_lamp",
|
||||
"category": "using",
|
||||
"advancement": "naturesaura:sky_ingot",
|
||||
"pages": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "The $(item)Lamp of Sanctuary$(), while being a great decorational piece, also has another very useful function: When supplied with a $(thing)redstone signal$(), it will cause any monsters in an area of up to about 48 blocks around it to $(thing)stop appearing$() altogether, no matter the light level. For this, the strength of the redstone signal determines the range. Every time a monster is ceased, a small amount of $(aura) is used."
|
||||
},
|
||||
{
|
||||
"type": "crafting",
|
||||
"text": "Creating the $(item)Lamp of Sanctuary$()$(p)$(italic)Mobproofius Lampus$()",
|
||||
"recipe": "naturesaura:spawn_lamp"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"type": "forge:ore_shaped",
|
||||
"pattern": [
|
||||
"ILI",
|
||||
"SGS",
|
||||
"ILI"
|
||||
],
|
||||
"key": {
|
||||
"I": {
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "ingotIron"
|
||||
},
|
||||
"L": {
|
||||
"item": "minecraft:glass"
|
||||
},
|
||||
"S": {
|
||||
"item": "naturesaura:sky_ingot"
|
||||
},
|
||||
"G": {
|
||||
"item": "minecraft:glowstone"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "naturesaura:spawn_lamp"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 583 B |
Loading…
Reference in a new issue