mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-21 04:32:23 +00:00
Luminize Launcher and adaptation of the Luminizer code to work with any entity.
This commit is contained in:
1 parent
ae650dc65f
commit
005e860220
10 files changed
+95
-10
No files matched your search
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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 @ [Jul 17, 2015, 4:08:58 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.common.block.tile.TileLightRelay;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class BlockLightLauncher extends BlockMod {
|
||||
|
||||
public BlockLightLauncher() {
|
||||
super(Material.wood);
|
||||
setHardness(2.0F);
|
||||
setStepSound(soundTypeWood);
|
||||
setBlockName(LibBlockNames.LIGHT_LAUNCHER);
|
||||
setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
boolean powered = (meta & 8) != 0;
|
||||
|
||||
if(power && !powered) {
|
||||
pickUpEntities(world, x, y, z);
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4);
|
||||
} else if(!power && powered)
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
|
||||
}
|
||||
|
||||
public void pickUpEntities(World world, int x, int y, int z) {
|
||||
List<TileLightRelay> relays = new ArrayList();
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
TileEntity tile = world.getTileEntity(x + dir.offsetX, y, z + dir.offsetZ);
|
||||
if(tile instanceof TileLightRelay) {
|
||||
TileLightRelay relay = (TileLightRelay) tile;
|
||||
if(relay.getBinding() != null)
|
||||
relays.add(relay);
|
||||
}
|
||||
}
|
||||
|
||||
if(!relays.isEmpty()) {
|
||||
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1));
|
||||
if(!entities.isEmpty()) {
|
||||
for(EntityLivingBase entity : entities) {
|
||||
TileLightRelay relay = relays.get(world.rand.nextInt(relays.size()));
|
||||
relay.mountEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class BlockLightRelay extends BlockModContainer implements IWandable {
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) {
|
||||
((TileLightRelay) world.getTileEntity(x, y, z)).playerInteract(player);
|
||||
((TileLightRelay) world.getTileEntity(x, y, z)).mountEntity(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -237,6 +237,7 @@ public final class ModBlocks {
|
||||
public static Block felPumpkin;
|
||||
public static Block cocoon;
|
||||
public static Block lightRelay;
|
||||
public static Block lightLauncher;
|
||||
|
||||
public static void init() {
|
||||
flower = new BlockModFlower();
|
||||
@@ -315,7 +316,8 @@ public final class ModBlocks {
|
||||
felPumpkin = new BlockFelPumpkin();
|
||||
cocoon = new BlockCocoon();
|
||||
lightRelay = new BlockLightRelay();
|
||||
|
||||
lightLauncher = new BlockLightLauncher();
|
||||
|
||||
ModFluffBlocks.init();
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
|
||||
@@ -11,16 +11,20 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.wand.IWandBindable;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
@@ -38,15 +42,14 @@ public class TileLightRelay extends TileMod implements IWandBindable {
|
||||
int bindX, bindY = -1, bindZ;
|
||||
int ticksElapsed = 0;
|
||||
|
||||
public void playerInteract(EntityPlayer player) {
|
||||
if(player.ridingEntity != null || worldObj.isRemote || bindY == -1)
|
||||
public void mountEntity(EntityLivingBase e) {
|
||||
if(e.ridingEntity != null || worldObj.isRemote || bindY == -1)
|
||||
return;
|
||||
|
||||
EntityPlayerMover mover = new EntityPlayerMover(worldObj, xCoord, yCoord, zCoord, bindX, bindY, bindZ);
|
||||
worldObj.spawnEntityInWorld(mover);
|
||||
player.mountEntity(mover);
|
||||
worldObj.playSoundAtEntity(mover, "botania:lightRelay", 0.2F, (float) Math.random() * 0.3F + 0.7F);
|
||||
|
||||
e.mountEntity(mover);
|
||||
worldObj.playSoundAtEntity(mover, "botania:lightRelay", 0.2F, (float) Math.random() * 0.3F + 0.7F);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,7 +162,7 @@ public class TileLightRelay extends TileMod implements IWandBindable {
|
||||
if(ticksExisted % 30 == 0)
|
||||
worldObj.playSoundAtEntity(this, "botania:lightRelay", 0.2F, (float) Math.random() * 0.3F + 0.7F);
|
||||
|
||||
if(riddenByEntity == null) {
|
||||
if(riddenByEntity == null && !worldObj.isRemote) {
|
||||
setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -254,6 +254,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addBlock(ModBlocks.corporeaInterceptor);
|
||||
addBlock(ModBlocks.corporeaCrystalCube);
|
||||
addBlock(ModBlocks.lightRelay);
|
||||
addBlock(ModBlocks.lightLauncher);
|
||||
|
||||
// FLUFF
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class ModEntities {
|
||||
EntityRegistry.registerModEntity(EntityEnderAirBottle.class, LibEntityNames.ENDER_AIR_BOTTLE, id++, Botania.instance, 64, 10, true);
|
||||
EntityRegistry.registerModEntity(EntityPoolMinecart.class, LibEntityNames.POOL_MINECART, id++, Botania.instance, 80, 3, true);
|
||||
EntityRegistry.registerModEntity(EntityPinkWither.class, LibEntityNames.PINK_WITHER, id++, Botania.instance, 80, 3, false);
|
||||
EntityRegistry.registerModEntity(EntityPlayerMover.class, LibEntityNames.PlAYER_MOVER, id++, Botania.instance, 16, 3, true);
|
||||
EntityRegistry.registerModEntity(EntityPlayerMover.class, LibEntityNames.PLAYER_MOVER, id++, Botania.instance, 40, 3, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,6 +91,7 @@ public final class LibBlockNames {
|
||||
public static final String FEL_PUMPKIN = "felPumpkin";
|
||||
public static final String COCOON = "cocoon";
|
||||
public static final String LIGHT_RELAY = "lightRelay";
|
||||
public static final String LIGHT_LAUNCHER = "lightLauncher";
|
||||
|
||||
public static final String SUBTILE_PUREDAISY = "puredaisy";
|
||||
public static final String SUBTILE_MANASTAR = "manastar";
|
||||
|
||||
@@ -29,6 +29,6 @@ public final class LibEntityNames {
|
||||
public static final String ENDER_AIR_BOTTLE = LibResources.PREFIX_MOD + "enderAirBottle";
|
||||
public static final String POOL_MINECART = LibResources.PREFIX_MOD + "poolMinecart";
|
||||
public static final String PINK_WITHER = LibResources.PREFIX_MOD + "pinkWither";
|
||||
public static final String PlAYER_MOVER = LibResources.PREFIX_MOD + "playerMover";
|
||||
public static final String PLAYER_MOVER = LibResources.PREFIX_MOD + "playerMover";
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user