use of stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage in project MorePlanets by SteveKunG.
the class BlockBlackHoleStorage method randomDisplayTick.
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityBlackHoleStorage) {
TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
if (!storage.disableBlackHole) {
for (int i = 0; i < 16; i++) {
double x = pos.getX() + rand.nextFloat() - 0.5D;
double y = pos.getY() + 0.5D;
double z = pos.getZ() + rand.nextFloat();
double motionX = rand.nextDouble() - 0.5D;
double motionZ = rand.nextDouble() - 0.5D;
MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, x + 0.5D, y, z, motionX, 1.0D, 0.0D);
MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, x + 0.5D, y, z + 0.0D, 0.0D, 1.0D, motionZ);
}
}
}
}
use of stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage in project MorePlanets by SteveKunG.
the class BlockBlackHoleStorage method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return true;
} else {
TileEntity tile = world.getTileEntity(pos);
int slot = player.inventory.currentItem;
if (tile instanceof TileEntityBlackHoleStorage) {
TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
FluidActionResult result = FluidUtil.interactWithFluidHandler(player.inventory.getCurrentItem(), storage.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null), player);
if (result.isSuccess()) {
player.inventory.setInventorySlotContents(slot, result.result);
if (player.inventoryContainer != null) {
player.inventoryContainer.detectAndSendChanges();
}
return true;
} else {
if (player.getGameProfile().getId().toString().equals(storage.ownerUUID)) {
if (player.isSneaking() && storage.fluidTank.getFluidAmount() > 0) {
Random rand = world.rand;
storage.drainExp(player);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.1F, 0.5F * ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.8F));
} else {
player.openGui(MorePlanetsCore.MOD_ID, -1, world, pos.getX(), pos.getY(), pos.getZ());
}
} else {
JsonUtil json = new JsonUtil();
player.sendMessage(json.text(GCCoreUtil.translate("gui.bh_storage_not_owner.message")).setStyle(json.red()));
}
}
}
return true;
}
}
use of stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage in project MorePlanets by SteveKunG.
the class PacketSimpleMP method handleServerSide.
@Override
public void handleServerSide(EntityPlayer player) {
EntityPlayerMP playerMP = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
World world = player.world;
TileEntity tile;
BlockPos pos;
String type;
switch(this.type) {
case S_FIRE_EXTINGUISH:
pos = (BlockPos) this.data.get(0);
world.playSound(null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
world.setBlockToAir(pos);
break;
case S_RESPAWN_PLAYER_NETHER:
if (world instanceof WorldServer) {
WorldServer worldOld = (WorldServer) world;
WorldServer worldNew = WorldDimensionHelper.getStartWorld(worldOld);
BlockPos spawnPos = worldNew.getTopSolidOrLiquidBlock(worldNew.getSpawnPoint());
TeleportUtil.setWarpDimension(playerMP, worldNew, spawnPos.getX(), spawnPos.getY(), spawnPos.getZ(), WorldUtil.getProviderForNameServer(WorldTickEventHandler.startedDimensionData.planetToBack).getDimension(), true);
player.respawnPlayer();
player.closeScreen();
}
break;
case S_BLACK_HOLE_STORAGE_OPTION:
tile = world.getTileEntity((BlockPos) this.data.get(0));
type = (String) this.data.get(1);
if (tile instanceof TileEntityBlackHoleStorage) {
TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
switch(type) {
case "disable":
storage.disableBlackHole = !storage.disableBlackHole;
break;
case "collect_mode":
storage.modeInt++;
storage.modeInt %= 3;
switch(storage.modeInt) {
case 0:
storage.collectMode = "item";
break;
case 1:
storage.collectMode = "xp";
break;
case 2:
storage.collectMode = "item_and_xp";
break;
}
break;
case "use_hopper":
storage.useHopper = !storage.useHopper;
break;
}
}
break;
case S_SHIELD_VISIBLE:
tile = world.getTileEntity((BlockPos) this.data.get(0));
if (tile instanceof TileEntityShieldGenerator) {
TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
shield.setBubbleVisible((boolean) this.data.get(1));
}
break;
case S_ENABLE_SHIELD:
tile = world.getTileEntity((BlockPos) this.data.get(0));
if (tile instanceof TileEntityShieldGenerator) {
TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
shield.enableShield = !shield.enableShield;
}
break;
case S_ENABLE_SHIELD_DAMAGE:
tile = world.getTileEntity((BlockPos) this.data.get(0));
if (tile instanceof TileEntityShieldGenerator) {
TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
shield.enableDamage = !shield.enableDamage;
}
break;
case S_SHIELD_GENERATOR_OPTION:
tile = world.getTileEntity((BlockPos) this.data.get(0));
int value = (int) this.data.get(1);
type = (String) this.data.get(2);
if (tile instanceof TileEntityShieldGenerator) {
TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
switch(type) {
case "damage":
shield.shieldDamage = value;
break;
case "size":
shield.maxShieldSize = value;
break;
}
}
break;
case S_SWITCH_SHIELD_GENERATOR_GUI:
tile = player.world.getTileEntity((BlockPos) this.data.get(0));
boolean isConfig = (boolean) this.data.get(1);
if (tile instanceof TileEntityShieldGenerator) {
TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
PacketSimpleMP.openShieldGeneratorConfig(playerMP, shield, isConfig);
}
break;
default:
break;
}
}
use of stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage in project MorePlanets by SteveKunG.
the class RenderBlackHoleStorage method renderItem.
@Override
public void renderItem(ItemStack itemStack, ItemCameraTransforms.TransformType type) {
ClientRegisterHelper.registerTileEntityItemStackRendering(new TileEntityBlackHoleStorage());
GlStateManager.enableBlend();
}
use of stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage in project MorePlanets by SteveKunG.
the class BlockBlackHoleStorage method harvestBlock.
@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack heldStack) {
player.addExhaustion(0.025F);
if (tile instanceof TileEntityBlackHoleStorage) {
ItemStack itemStack = new ItemStack(this);
NBTTagCompound nbt = new NBTTagCompound();
TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
ItemStackHelper.saveAllItems(nbt, storage.inventory);
nbt.setBoolean("Disable", storage.disableBlackHole);
nbt.setBoolean("Hopper", storage.useHopper);
nbt.setString("Mode", storage.collectMode);
if (storage.fluidTank.getFluid() != null) {
NBTTagCompound fluidNbt = new NBTTagCompound();
fluidNbt.setString("FluidName", "xpjuice");
fluidNbt.setInteger("Amount", storage.fluidTank.getFluidAmount());
nbt.setTag("XpFluid", fluidNbt);
}
itemStack.setTagCompound(nbt);
Block.spawnAsEntity(world, pos, itemStack);
}
}
Aggregations