use of javax.annotation.ParametersAreNonnullByDefault in project OpenModularTurrets by OpenModularTurretsTeam.
the class BlazingClayProjectile method onHitBlock.
@Override
@ParametersAreNonnullByDefault
public void onHitBlock(IBlockState hitBlock, BlockPos pos) {
if (hitBlock.getBlock() instanceof BlockAbstractTurretHead) {
return;
}
if (!hitBlock.getMaterial().isSolid()) {
// Go through non solid block
return;
}
if (!getEntityWorld().isRemote) {
AxisAlignedBB axis = new AxisAlignedBB(this.posX - 5, this.posY - 5, this.posZ - 5, this.posX + 5, this.posY + 5, this.posZ + 5);
List<EntityLivingBase> targets = getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, axis);
int damage = ConfigHandler.getIncendiaryTurretSettings().getDamage();
for (Entity mob : targets) {
if (mob instanceof EntityPlayer) {
if (canDamagePlayer((EntityPlayer) mob)) {
mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
mob.hurtResistantTime = 0;
mob.setFire(5);
playSound();
}
} else {
mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
mob.hurtResistantTime = 0;
mob.setFire(5);
playSound();
}
}
this.setDead();
}
}
use of javax.annotation.ParametersAreNonnullByDefault in project RecurrentComplex by Ivorforce.
the class CommandGenerateStructure method execute.
@Override
@ParametersAreNonnullByDefault
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args, "mirror", "select");
String structureID = parameters.get().first().require();
Structure<?> structure = parameters.rc().structure().require();
WorldServer world = parameters.mc("dimension").dimension(server, sender).require();
AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(null);
GenerationType generationType = parameters.rc("gen").generationType(structure).require();
BlockSurfacePos pos = parameters.surfacePos("x", "z", sender.getPosition(), false).require();
String seed = parameters.get("seed").first().optional().orElse(null);
boolean select = parameters.has("select");
Placer placer = generationType.placer();
StructureGenerator<?> generator = new StructureGenerator<>(structure).world(world).generationInfo(generationType).seed(RCStrings.seed(seed)).structureID(structureID).randomPosition(pos, placer).fromCenter(true).transform(transform);
Optional<StructureBoundingBox> boundingBox = generator.boundingBox();
if (!boundingBox.isPresent())
throw ServerTranslations.commandException("commands.strucGen.noPlace");
if (structure instanceof GenericStructure && world == sender.getEntityWorld()) {
GenericStructure genericStructureInfo = (GenericStructure) structure;
BlockPos lowerCoord = StructureBoundingBoxes.min(boundingBox.get());
OperationRegistry.queueOperation(new OperationGenerateStructure(genericStructureInfo, generationType.id(), generator.transform(), lowerCoord, false).withSeed(seed).withStructureID(structureID).prepare(world), sender);
} else {
if (generator.generate() == null)
throw ServerTranslations.commandException("commands.strucGen.noPlace");
}
if (select) {
SelectionOwner owner = RCCommands.getSelectionOwner(sender, null, false);
owner.setSelection(RCBlockAreas.from(boundingBox.get()));
}
}
use of javax.annotation.ParametersAreNonnullByDefault in project RecurrentComplex by Ivorforce.
the class ItemInventoryGenComponentTag method getSubItems.
@Override
@ParametersAreNonnullByDefault
public void getSubItems(Item item, CreativeTabs creativeTabs, NonNullList<ItemStack> list) {
super.getSubItems(item, creativeTabs, list);
for (String key : GenericItemCollectionRegistry.INSTANCE.ids()) {
ItemStack stack = new ItemStack(item);
setComponentKey(stack, key);
list.add(stack);
}
}
use of javax.annotation.ParametersAreNonnullByDefault in project RecurrentComplex by Ivorforce.
the class BlockScript method getPickBlock.
@Nonnull
@Override
@ParametersAreNonnullByDefault
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
TileEntity tileEntity = world.getTileEntity(pos);
NBTTagCompound compound = new NBTTagCompound();
((TileEntityBlockScript) tileEntity).writeSyncedNBT(compound);
ItemStack returnStack = new ItemStack(Item.getItemFromBlock(this));
returnStack.setTagInfo("scriptInfo", compound);
return returnStack;
}
use of javax.annotation.ParametersAreNonnullByDefault in project FlareBot by FlareBot.
the class GuildWrapperLoader method load.
@Override
@ParametersAreNonnullByDefault
public GuildWrapper load(String id) {
long start = System.currentTimeMillis();
ResultSet set = CassandraController.execute("SELECT data FROM " + FlareBotManager.instance().GUILD_DATA_TABLE + " WHERE guild_id = '" + id + "'");
GuildWrapper wrapper;
Row row = set != null ? set.one() : null;
String json = null;
JSONConfig data;
try {
if (row != null) {
json = row.getString("data");
if (json.isEmpty() || json.equalsIgnoreCase("null")) {
return new GuildWrapper(id);
}
data = new JSONConfig(parser.parse(json).getAsJsonObject(), '.', ALLOWED_SPECIAL_CHARACTERS);
if (data.getLong("dataVersion").isPresent() && data.getLong("dataVersion").getAsLong() == 0)
data = firstMigration(data);
wrapper = FlareBot.GSON.fromJson(data.getObject().toString(), GuildWrapper.class);
} else
return new GuildWrapper(id);
} catch (Exception e) {
if (json == null) {
FlareBot.LOGGER.error(Markers.TAG_DEVELOPER, "Failed to load GuildWrapper!!\n" + "Guild ID: " + id + "\n" + "Guild JSON: " + (row != null ? row.getString("data") : "New guild data!") + "\n" + "Error: " + e.getMessage(), e);
return null;
}
try {
data = new JSONConfig(parser.parse(json).getAsJsonObject(), '.', ALLOWED_SPECIAL_CHARACTERS);
} catch (Exception e1) {
FlareBot.LOGGER.error(Markers.TAG_DEVELOPER, "Failed to load GuildWrapper!!\n" + "Guild ID: " + id + "\n" + "Guild JSON: " + json + "\n" + "Error: " + e.getMessage(), e);
throw new IllegalArgumentException("Invalid JSON! '" + json + "'", e1);
}
if (!data.getLong("dataVersion").isPresent()) {
try {
data = firstMigration(data);
} catch (Exception e1) {
FlareBot.LOGGER.error(Markers.TAG_DEVELOPER, "Failed to load GuildWrapper!!\n" + "Guild ID: " + id + "\n" + "Guild JSON: " + json + "\n" + "Error: " + e.getMessage(), e);
throw new IllegalArgumentException("Invalid JSON! '" + json + "'", e1);
}
data.set("dataVersion", 1);
}
long version = data.getLong("dataVersion").getAsLong();
if (version != GuildWrapper.DATA_VERSION) {
// Migrations
}
json = data.getObject().toString();
try {
wrapper = FlareBot.GSON.fromJson(json, GuildWrapper.class);
} catch (Exception e1) {
FlareBot.LOGGER.error(Markers.TAG_DEVELOPER, "Failed to load GuildWrapper!!\n" + "Guild ID: " + id + "\n" + "Guild JSON: " + json + "\n" + "Error: " + e1.getMessage(), e1);
return null;
}
}
long total = (System.currentTimeMillis() - start);
loadTimes.add(total);
if (total >= 200) {
Constants.getImportantLogChannel().sendMessage(MessageUtils.getEmbed().setColor(new Color(166, 0, 255)).setTitle("Long guild load time!", null).setDescription("Guild " + id + " loaded!").addField("Time", "Millis: " + System.currentTimeMillis() + "\nTime: " + LocalDateTime.now().toString(), false).addField("Load time", total + "ms", false).build()).queue();
}
return wrapper;
}
Aggregations