mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
parent
90e93bdb35
commit
02de4bce7f
3 changed files with 32 additions and 13 deletions
|
@ -1,10 +1,11 @@
|
||||||
package de.ellpeck.naturesaura.blocks;
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
|
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
|
||||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||||
|
import de.ellpeck.naturesaura.misc.WorldData;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||||
|
@ -53,17 +54,15 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
|
||||||
return;
|
return;
|
||||||
IWorld world = event.getWorld();
|
IWorld world = event.getWorld();
|
||||||
BlockPos pos = new BlockPos(event.getX(), event.getY(), event.getZ());
|
BlockPos pos = new BlockPos(event.getX(), event.getY(), event.getZ());
|
||||||
Helper.getTileEntitiesInArea(world, pos, 48, tile -> {
|
WorldData data = (WorldData) IWorldData.getWorldData((World) world);
|
||||||
if (!(tile instanceof TileEntitySpawnLamp))
|
for (TileEntitySpawnLamp lamp : data.spawnLamps) {
|
||||||
return false;
|
|
||||||
TileEntitySpawnLamp lamp = (TileEntitySpawnLamp) tile;
|
|
||||||
int range = lamp.getRadius();
|
int range = lamp.getRadius();
|
||||||
if (range <= 0)
|
if (range <= 0)
|
||||||
return false;
|
continue;
|
||||||
|
|
||||||
BlockPos lampPos = lamp.getPos();
|
BlockPos lampPos = lamp.getPos();
|
||||||
if (!new AxisAlignedBB(lampPos).grow(range).contains(new Vec3d(pos)))
|
if (!new AxisAlignedBB(lampPos).grow(range).contains(new Vec3d(pos)))
|
||||||
return false;
|
continue;
|
||||||
|
|
||||||
MobEntity entity = (MobEntity) event.getEntityLiving();
|
MobEntity entity = (MobEntity) event.getEntityLiving();
|
||||||
if (entity.canSpawn(world, event.getSpawnReason()) && entity.isNotColliding(world)) {
|
if (entity.canSpawn(world, event.getSpawnReason()) && entity.isNotColliding(world)) {
|
||||||
|
@ -75,8 +74,8 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setResult(Event.Result.DENY);
|
event.setResult(Event.Result.DENY);
|
||||||
return true;
|
break;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||||
|
import de.ellpeck.naturesaura.misc.WorldData;
|
||||||
|
|
||||||
public class TileEntitySpawnLamp extends TileEntityImpl {
|
public class TileEntitySpawnLamp extends TileEntityImpl {
|
||||||
|
|
||||||
public TileEntitySpawnLamp() {
|
public TileEntitySpawnLamp() {
|
||||||
|
@ -10,6 +13,24 @@ public class TileEntitySpawnLamp extends TileEntityImpl {
|
||||||
return this.redstonePower * 3;
|
return this.redstonePower * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate() {
|
||||||
|
super.validate();
|
||||||
|
if (!this.world.isRemote) {
|
||||||
|
WorldData data = (WorldData) IWorldData.getWorldData(this.world);
|
||||||
|
data.spawnLamps.add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
super.remove();
|
||||||
|
if (!this.world.isRemote) {
|
||||||
|
WorldData data = (WorldData) IWorldData.getWorldData(this.world);
|
||||||
|
data.spawnLamps.remove(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRedstonePowerChange(int newPower) {
|
public void onRedstonePowerChange(int newPower) {
|
||||||
super.onRedstonePowerChange(newPower);
|
super.onRedstonePowerChange(newPower);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.ItemStackHandlerNA;
|
import de.ellpeck.naturesaura.blocks.tiles.ItemStackHandlerNA;
|
||||||
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
@ -23,15 +24,13 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class WorldData implements IWorldData {
|
public class WorldData implements IWorldData {
|
||||||
public final ListMultimap<ResourceLocation, Tuple<Vec3d, Integer>> effectPowders = ArrayListMultimap.create();
|
public final ListMultimap<ResourceLocation, Tuple<Vec3d, Integer>> effectPowders = ArrayListMultimap.create();
|
||||||
public final List<BlockPos> recentlyConvertedMossStones = new ArrayList<>();
|
public final List<BlockPos> recentlyConvertedMossStones = new ArrayList<>();
|
||||||
private final Map<String, ItemStackHandlerNA> enderStorages = new HashMap<>();
|
private final Map<String, ItemStackHandlerNA> enderStorages = new HashMap<>();
|
||||||
|
public final Set<TileEntitySpawnLamp> spawnLamps = new HashSet<>();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue