Code cleanup

This commit is contained in:
Unknown 2018-07-18 12:25:26 +02:00 committed by unknown
parent d075b6f1ef
commit f20d2c20ac
92 changed files with 287 additions and 238 deletions

View file

@ -641,7 +641,8 @@ public class Commons {
public static void writeNBTToFile(final String fileName, final NBTTagCompound tagCompound) {
if (WarpDrive.isDev) {
WarpDrive.logger.info(String.format("writeNBTToFile %s" + fileName));
WarpDrive.logger.info(String.format("writeNBTToFile %s",
fileName));
}
try {

View file

@ -9,11 +9,13 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
public interface IItemBase {
// wrapper for Forge ItemExpireEvent
void onEntityExpireEvent(final EntityItem entityItem, final ItemStack itemStack);
@Nonnull
@SideOnly(Side.CLIENT)
ModelResourceLocation getModelResourceLocation(final ItemStack itemStack);
// wrapper for Forge ItemExpireEvent
void onEntityExpireEvent(final EntityItem entityItem, final ItemStack itemStack);
@Nonnull
@SideOnly(Side.CLIENT)
ModelResourceLocation getModelResourceLocation(final ItemStack itemStack);
void modelInitialisation();
}

View file

@ -14,6 +14,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class Particle {
protected final String registryName;
protected int color;

View file

@ -17,6 +17,7 @@ public class WarpDriveText extends TextComponentBase {
public WarpDriveText(@Nullable final Style style, @Nonnull final String translationKey, final Object... args) {
super();
ITextComponent textComponent = new TextComponentTranslation(translationKey, args);
if (style != null) {
textComponent.setStyle(style);

View file

@ -165,7 +165,7 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
}
@Override
public boolean rotateBlock(final World world, @Nonnull final BlockPos blockPos, final EnumFacing axis) {
public boolean rotateBlock(final World world, @Nonnull final BlockPos blockPos, @Nonnull final EnumFacing axis) {
// already handled by vanilla
return super.rotateBlock(world, blockPos, axis);
}

View file

@ -88,21 +88,21 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
public void onBlockUpdateDetected() {
}
protected <T extends Comparable<T>, V extends T> void updateBlockState(final IBlockState blockState_in, IProperty<T> property, V value) {
protected <T extends Comparable<T>, V extends T> void updateBlockState(final IBlockState blockState_in, final IProperty<T> property, final V value) {
IBlockState blockState = blockState_in;
if (blockState == null) {
blockState = world.getBlockState(pos);
}
try {
if (property != null) {
blockState = blockState.withProperty(property, value);
if (property != null) {
if (!blockState.getProperties().containsKey(property)) {
WarpDrive.logger.error(String.format("Unable to update block state due to missing property in %s: %s calling updateBlockState(%s, %s, %s)",
blockState.getBlock(), this, blockState_in, property, value));
return;
}
if (getBlockMetadata() != blockState.getBlock().getMetaFromState(blockState)) {
world.setBlockState(pos, blockState, 2);
}
} catch (Exception exception) {
exception.printStackTrace();
WarpDrive.logger.error(String.format("Exception in %s", this));
blockState = blockState.withProperty(property, value);
}
if (getBlockMetadata() != blockState.getBlock().getMetaFromState(blockState)) {
world.setBlockState(pos, blockState, 2);
}
}
@ -111,15 +111,19 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
if (blockState_old == null) {
blockState_old = world.getBlockState(pos);
}
try {
final int metadata_old = blockState_old.getBlock().getMetaFromState(blockState_old);
final int metadata_new = blockState_new.getBlock().getMetaFromState(blockState_new);
if (metadata_old != metadata_new) {
world.setBlockState(pos, blockState_new, 2);
}
} catch (Exception exception) {
exception.printStackTrace();
WarpDrive.logger.error(String.format("Exception in %s", this));
final Block block_old = blockState_old.getBlock();
final Block block_new = blockState_new.getBlock();
if (block_new != block_old) {
WarpDrive.logger.error(String.format("Unable to update block state from %s to %s: %s calling updateBlockState(%s, %s)",
block_old, block_new, this, blockState_in, blockState_new));
return;
}
final int metadata_old = block_old.getMetaFromState(blockState_old);
final int metadata_new = block_new.getMetaFromState(blockState_new);
if (metadata_old != metadata_new) {
world.setBlockState(pos, blockState_new, 2);
}
}
@ -145,7 +149,7 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, @Nonnull IBlockState blockStateOld, @Nonnull IBlockState blockStateNew) {
public boolean shouldRefresh(final World world, final BlockPos pos, @Nonnull final IBlockState blockStateOld, @Nonnull final IBlockState blockStateNew) {
return blockStateOld.getBlock() != blockStateNew.getBlock();
}

View file

@ -12,7 +12,7 @@ import net.minecraft.entity.EntityLiving.SpawnPlacementType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
public class BlockAbstractAccelerator extends BlockAbstractBase implements IBlockBase {
public abstract class BlockAbstractAccelerator extends BlockAbstractBase implements IBlockBase {
public final EnumTier enumTier;

View file

@ -13,6 +13,7 @@ public class ItemBlockAirShield extends ItemBlockAbstractBase {
public ItemBlockAirShield(final Block block) {
super(block);
setHasSubtypes(true);
}

View file

@ -294,8 +294,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
}
// consume power
final int energyCost = TREE_FARM_ENERGY_PER_WET_SPOT;
isPowered = laserMedium_consumeExactly(energyCost, false);
isPowered = laserMedium_consumeExactly(TREE_FARM_ENERGY_PER_WET_SPOT, false);
if (!isPowered) {
delayTargetTicks = TREE_FARM_LOW_POWER_DELAY_TICKS;
updateBlockState(blockState, BlockLaserTreeFarm.MODE, EnumLaserTreeFarmMode.FARMING_LOW_POWER);
@ -410,7 +409,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
final Block block = itemBlock.getBlock();
plant = block.getStateForPlacement(world, blockPosPlant, EnumFacing.UP,
0.5F, 0.0F, 0.5F, metadata,
null, EnumHand.MAIN_HAND);
null, EnumHand.MAIN_HAND); // @TODO use fake player to place sapling
} else {
plant = plantable.getPlant(world, blockPosPlant);
}
@ -462,8 +461,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
}
// consume power
final int energyCost = TREE_FARM_ENERGY_PER_SAPLING;
isPowered = laserMedium_consumeExactly(energyCost, false);
isPowered = laserMedium_consumeExactly(TREE_FARM_ENERGY_PER_SAPLING, false);
if (!isPowered) {
delayTargetTicks = TREE_FARM_LOW_POWER_DELAY_TICKS;
updateBlockState(blockState, BlockLaserTreeFarm.MODE, EnumLaserTreeFarmMode.PLANTING_LOW_POWER);

View file

@ -61,13 +61,6 @@ public class BlockAbstractLamp extends BlockAbstractBase {
return blockState.getValue(BlockProperties.FACING).getIndex();
}
@SideOnly(Side.CLIENT)
@Override
public void modelInitialisation() {
Item item = Item.getItemFromBlock(this);
ClientProxy.modelInitialisation(item);
}
@SuppressWarnings("deprecation")
@SideOnly(Side.CLIENT)
@Override

View file

@ -15,6 +15,7 @@ public class ItemBlockDecorative extends ItemBlockAbstractBase {
public ItemBlockDecorative(final Block block) {
super(block);
setHasSubtypes(true);
}
@ -24,10 +25,13 @@ public class ItemBlockDecorative extends ItemBlockAbstractBase {
public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) {
final int damage = itemStack.getItemDamage();
if (damage < 0 || damage > EnumDecorativeType.length) {
throw new IllegalArgumentException(String.format("Invalid damage %d for %s", damage, itemStack.getItem()));
throw new IllegalArgumentException(String.format("Invalid damage %d for %s",
damage, itemStack.getItem()));
}
ResourceLocation resourceLocation = getRegistryName();
final String variant = String.format("type=%s", EnumDecorativeType.get( itemStack.getItemDamage() ).getName());
final ResourceLocation resourceLocation = getRegistryName();
assert resourceLocation != null;
final String variant = String.format("type=%s",
EnumDecorativeType.get( itemStack.getItemDamage() ).getName());
return new ModelResourceLocation(resourceLocation, variant);
}

View file

@ -15,6 +15,7 @@ public class ItemBlockGas extends ItemBlockAbstractBase {
public ItemBlockGas(final Block block) {
super(block);
setHasSubtypes(true);
}
@ -24,10 +25,13 @@ public class ItemBlockGas extends ItemBlockAbstractBase {
public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) {
final int damage = itemStack.getItemDamage();
if (damage < 0 || damage > EnumGasColor.length) {
throw new IllegalArgumentException(String.format("Invalid damage %d for %s", damage, itemStack.getItem()));
throw new IllegalArgumentException(String.format("Invalid damage %d for %s",
damage, itemStack.getItem()));
}
ResourceLocation resourceLocation = getRegistryName();
String variant = String.format("color=%s", EnumGasColor.get( itemStack.getItemDamage() ).getUnlocalizedName());
final ResourceLocation resourceLocation = getRegistryName();
assert resourceLocation != null;
final String variant = String.format("color=%s",
EnumGasColor.get( itemStack.getItemDamage() ).getUnlocalizedName());
return new ModelResourceLocation(resourceLocation, variant);
}
}

View file

@ -1,30 +1,45 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractBase;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumTier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.item.EnumRarity;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockWarpIsolation extends BlockAbstractBase {
public BlockWarpIsolation(final String registryName) {
super(registryName, Material.IRON);
public BlockWarpIsolation(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier, Material.IRON);
setHardness(3.5F);
setUnlocalizedName("warpdrive.detection.warp_isolation");
}
@Nullable
@Override
public ItemBlock createItemBlock() {
return new ItemBlockWarpIsolation(this);
}
@Override
public EnumRarity getRarity(final ItemStack itemStack, final EnumRarity rarity) {
return EnumRarity.UNCOMMON;
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull final ItemStack itemStack, @Nullable World world,
@Nonnull final List<String> list, @Nullable final ITooltipFlag advancedItemTooltips) {
super.addInformation(itemStack, world, list, advancedItemTooltips);
Commons.addTooltip(list, new TextComponentTranslation(getUnlocalizedName() + ".formatted_tooltip",
WarpDriveConfig.RADAR_MIN_ISOLATION_BLOCKS,
Math.round(WarpDriveConfig.RADAR_MIN_ISOLATION_EFFECT * 100.0D),
WarpDriveConfig.RADAR_MAX_ISOLATION_BLOCKS,
Math.round(WarpDriveConfig.RADAR_MAX_ISOLATION_EFFECT * 100.0D),
WarpDriveConfig.RADAR_MAX_ISOLATION_RANGE + 1).getFormattedText());
}
}

View file

@ -1,42 +0,0 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.ItemBlockAbstractBase;
import cr0s.warpdrive.config.WarpDriveConfig;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemBlockWarpIsolation extends ItemBlockAbstractBase {
public ItemBlockWarpIsolation(final Block block) {
super(block);
setMaxDamage(0);
}
// Item overrides
@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull final ItemStack itemStack, @Nullable World world,
@Nonnull final List<String> list, @Nullable final ITooltipFlag advancedItemTooltips) {
super.addInformation(itemStack, world, list, advancedItemTooltips);
Commons.addTooltip(list, new TextComponentTranslation(getUnlocalizedName(itemStack) + ".formatted_tooltip",
WarpDriveConfig.RADAR_MIN_ISOLATION_BLOCKS,
Math.round(WarpDriveConfig.RADAR_MIN_ISOLATION_EFFECT * 100.0D),
WarpDriveConfig.RADAR_MAX_ISOLATION_BLOCKS,
Math.round(WarpDriveConfig.RADAR_MAX_ISOLATION_EFFECT * 100.0D),
WarpDriveConfig.RADAR_MAX_ISOLATION_RANGE + 1).getFormattedText());
}
}

View file

@ -152,8 +152,7 @@ public class BlockCapacitor extends BlockAbstractContainer implements IExplosion
@SideOnly(Side.CLIENT)
@Override
public void modelInitialisation() {
final Item item = Item.getItemFromBlock(this);
ClientProxy.modelInitialisation(item);
super.modelInitialisation();
// register (smart) baked model
final ResourceLocation registryName = getRegistryName();

View file

@ -167,8 +167,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
@SideOnly(Side.CLIENT)
@Override
public void modelInitialisation() {
final Item item = Item.getItemFromBlock(this);
ClientProxy.modelInitialisation(item);
super.modelInitialisation();
// register camouflage
for (final Integer integer : FREQUENCY.getAllowedValues()) {

View file

@ -118,8 +118,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
@SideOnly(Side.CLIENT)
@Override
public void modelInitialisation() {
final Item item = Item.getItemFromBlock(this);
ClientProxy.modelInitialisation(item);
super.modelInitialisation();
// Bind our TESR to our tile entity
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityForceFieldProjector.class, new TileEntityForceFieldProjectorRenderer());

View file

@ -23,6 +23,7 @@ public class ItemBlockHullSlab extends ItemBlockHull {
public ItemBlockHullSlab(final Block blockSlab) {
super(blockSlab);
this.blockSlab = blockSlab;
}

View file

@ -82,8 +82,7 @@ public class BlockTransporterBeacon extends BlockAbstractContainer {
@SideOnly(Side.CLIENT)
@Override
public void modelInitialisation() {
final Item item = Item.getItemFromBlock(this);
ClientProxy.modelInitialisation(item);
super.modelInitialisation();
// Bind our TESR to our tile entity
// @TODO ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTransporterBeacon.class, new TileEntityForceFieldProjectorRenderer());

View file

@ -66,6 +66,7 @@ public class BlockTransporterScanner extends BlockAbstractBase {
return false;
}
@SuppressWarnings("deprecation")
@Override
public boolean isSideSolid(final IBlockState blockState, @Nonnull final IBlockAccess blockAccess, @Nonnull final BlockPos blockPos, final EnumFacing side) {
return side == EnumFacing.DOWN;

View file

@ -32,16 +32,11 @@ public class ItemBlockTransporterBeacon extends ItemBlockAbstractBase implements
public ItemBlockTransporterBeacon(final Block block) {
super(block);
setMaxStackSize(1);
setMaxDamage(100 * 8);
}
@Nonnull
@Override
public String getUnlocalizedName(final ItemStack itemstack) {
return getUnlocalizedName();
}
private static String getTransporterName(final ItemStack itemStack) {
if (!(itemStack.getItem() instanceof ItemBlockTransporterBeacon)) {
return "";

View file

@ -9,6 +9,7 @@ import net.minecraft.util.math.BlockPos.MutableBlockPos;
import net.minecraft.world.IBlockAccess;
class JumpGateScanner {
// inputs
private IBlockAccess blockAccess;
private int minX, minY, minZ;

View file

@ -11,6 +11,7 @@ import net.minecraft.util.math.BlockPos.MutableBlockPos;
import net.minecraft.world.IBlockAccess;
class ShipScanner {
// inputs
private IBlockAccess blockAccess;
private int minX, minY, minZ;

View file

@ -1488,6 +1488,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
if ( tagCompound.hasKey("scanners", Constants.NBT.TAG_LIST)
&& tagCompound.hasKey("containments", Constants.NBT.TAG_LIST)) {
final NBTTagList tagListScanners = (NBTTagList) tagCompound.getTag("scanners");
assert tagListScanners != null;
final ArrayList<BlockPos> vScanners = new ArrayList<>(tagListScanners.tagCount());
for (int indexScanner = 0; indexScanner < tagListScanners.tagCount(); indexScanner++) {
final BlockPos vScanner = Commons.createBlockPosFromNBT(tagListScanners.getCompoundTagAt(indexScanner));
@ -1495,6 +1496,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
}
final NBTTagList tagListContainments = (NBTTagList) tagCompound.getTag("containments");
assert tagListContainments != null;
final ArrayList<BlockPos> vContainments = new ArrayList<>(tagListContainments.tagCount());
for (int indexContainment = 0; indexContainment < tagListContainments.tagCount(); indexContainment++) {
final BlockPos vContainment = Commons.createBlockPosFromNBT(tagListContainments.getCompoundTagAt(indexContainment));

View file

@ -83,7 +83,8 @@ public class ClientProxy extends CommonProxy {
} else if (object == null) {
WarpDrive.logger.info("Ignoring null object ModelInitialisation...");
} else {
throw new RuntimeException("Invalid object " + object);
throw new RuntimeException(String.format("Invalid object %s",
object));
}
}
@ -110,7 +111,7 @@ public class ClientProxy extends CommonProxy {
NonNullList<ItemStack> listItemStacks = NonNullList.create();
assert item.getCreativeTab() != null;
item.getSubItems(item.getCreativeTab(), listItemStacks);
for (ItemStack itemStack : listItemStacks) {
for (final ItemStack itemStack : listItemStacks) {
ModelResourceLocation modelResourceLocation;
if (item instanceof IItemBase) {
modelResourceLocation = ((IItemBase) item).getModelResourceLocation(itemStack);

View file

@ -15,6 +15,7 @@ public abstract class CreativeTabAbstractBase extends CreativeTabs {
public CreativeTabAbstractBase(final String label, final long period) {
super(label);
this.period = period;
}

View file

@ -11,6 +11,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class SirenSound extends MovingSound {
float range;
float x, y, z;

View file

@ -19,6 +19,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
public class CommandDebug extends AbstractCommand {
@Nonnull
@Override
public String getName()
{
@ -30,10 +31,10 @@ public class CommandDebug extends AbstractCommand {
{
return 2;
}
@Nonnull
@Override
public String getUsage(@Nonnull final ICommandSender commandSender)
{
public String getUsage(@Nonnull final ICommandSender commandSender) {
return "/" + getName() + " <dimension> <x> <y> <z> <blockId> <Metadata> <action><action>...\n"
+ "dimension: 0/world, 2/space, 3/hyperspace\n"
+ "coordinates: x,y,z\n"

View file

@ -41,6 +41,7 @@ public class CommandEntity extends AbstractCommand {
private static final Style styleFactor = new Style().setColor(TextFormatting.DARK_GRAY);
private static final Style styleName = new Style().setColor(TextFormatting.LIGHT_PURPLE);
@Nonnull
@Override
public String getName() {
return "wentity";
@ -51,6 +52,7 @@ public class CommandEntity extends AbstractCommand {
return 2;
}
@Nonnull
@Override
public String getUsage(@Nonnull final ICommandSender commandSender) {
return "/" + getName() + " <radius> <filter> <kill?>"

View file

@ -26,7 +26,7 @@ public class CommandFind extends AbstractCommand {
public void execute(@Nonnull final MinecraftServer server, @Nonnull final ICommandSender commandSender, @Nonnull final String[] args) {
// parse arguments
//noinspection StatementWithEmptyBody
String nameToken = "";
String nameToken;
if (args.length == 0) {
Commons.addChatMessage(commandSender, new TextComponentString(getUsage(commandSender)));
return;

View file

@ -11,11 +11,13 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
public class CommandInvisible extends AbstractCommand {
@Override
public int getRequiredPermissionLevel() {
return 4;
}
@Nonnull
@Override
public String getName() {
return "invisible";
@ -46,6 +48,7 @@ public class CommandInvisible extends AbstractCommand {
player.setInvisible(!player.isInvisible());
}
@Nonnull
@Override
public String getUsage(@Nonnull final ICommandSender commandSender) {
return "/invisible [player]";

View file

@ -10,6 +10,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.TextComponentTranslation;
public class CommandReload extends AbstractCommand {
@Override
public int getRequiredPermissionLevel() {
return 2;

View file

@ -22,11 +22,13 @@ import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.WorldServer;
public class CommandSpace extends AbstractCommand {
@Override
public int getRequiredPermissionLevel() {
return 2;
}
@Nonnull
@Override
public String getName() {
return "space";
@ -209,6 +211,7 @@ public class CommandSpace extends AbstractCommand {
}
}
@Nonnull
@Override
public String getUsage(@Nonnull final ICommandSender commandSender) {
return "/space (<playerName>) ([overworld|nether|end|theend|space|hyper|hyperspace|<dimensionId>])";

View file

@ -27,10 +27,10 @@ public class CompatForgeMultipart implements IBlockTransformer {
public static boolean register() {
try {
final Class forgeMultipart_helper = Class.forName("codechicken.multipart.MultipartHelper");
final Class<?> forgeMultipart_helper = Class.forName("codechicken.multipart.MultipartHelper");
methodMultipartHelper_createTileFromNBT = forgeMultipart_helper.getDeclaredMethod("createTileFromNBT", World.class, NBTTagCompound.class);
methodMultipartHelper_sendDescPacket = forgeMultipart_helper.getDeclaredMethod("sendDescPacket", World.class, TileEntity.class);
final Class forgeMultipart_tileMultipart = Class.forName("codechicken.multipart.TileMultipart");
final Class<?> forgeMultipart_tileMultipart = Class.forName("codechicken.multipart.TileMultipart");
methodTileMultipart_onChunkLoad = forgeMultipart_tileMultipart.getDeclaredMethod("onChunkLoad");
classBlockMultipart = Class.forName("codechicken.multipart.BlockMultipart");
@ -125,7 +125,8 @@ public class CompatForgeMultipart implements IBlockTransformer {
rot = rotWRCBEstate;
break;
default:
WarpDrive.logger.error(String.format("Ignoring part of ForgeMultipart with unknown id: ", nbtPart));
WarpDrive.logger.error(String.format("Ignoring part of ForgeMultipart with unknown id: %d",
nbtPart));
break;
}
// actual rotation
@ -171,7 +172,8 @@ public class CompatForgeMultipart implements IBlockTransformer {
}
nbtTileEntity.setTag("parts", nbtNewParts);
} else {
WarpDrive.logger.error(String.format("Ignoring ForgeMultipart with no 'parts': ", nbtTileEntity));
WarpDrive.logger.error(String.format("Ignoring ForgeMultipart with no 'parts': %d",
nbtTileEntity));
}
return metadata;

View file

@ -84,7 +84,7 @@ public class Dictionary {
+ "- SkipMining: this block is ignored from mining (default: bedrock).\n"
+ "- StopMining: this block will prevent mining through it (default: command/creative, bedrock, force fields).\n"
+ "- PlaceEarliest: this block will be removed last and placed first (default: ship hull and projectors).\n"
+ "- PlaceEarlier: this block will be placed fairly soon (default: forcefield blocks).\n"
+ "- PlaceEarlier: this block will be placed fairly soon (default: force field blocks).\n"
+ "- PlaceNormal: this block will be removed and placed with non-tile entities.\n"
+ "- PlaceLater: this block will be placed fairly late (default: IC2 Reactor core).\n"
+ "- PlaceLatest: this block will be removed first and placed last (default: IC2 Reactor chamber).\n"

View file

@ -252,16 +252,17 @@ public class Recipes {
if (WarpDriveConfig.isComputerCraftLoaded) {
redstoneOrModem = WarpDriveConfig.getItemStackOrFire("computercraft:cable", 1); // Wired modem
}
// if (OreDictionary.doesOreNameExist("circuitPrimitive") && !OreDictionary.getOres("circuitPrimitive").isEmpty()) { // Gregtech
Object oreCircuitOrHeavyPressurePlate = Blocks.HEAVY_WEIGHTED_PRESSURE_PLATE;
int outputFactor = 1;
if (OreDictionary.doesOreNameExist("oc:materialCU") && !OreDictionary.getOres("oc:materialCU").isEmpty()) {
oreCircuitOrHeavyPressurePlate = "oc:materialCU"; // Control circuit is 5 redstone, 5 gold ingot, 3 paper
outputFactor = 2;
} else if (OreDictionary.doesOreNameExist("circuitBasic") && !OreDictionary.getOres("circuitBasic").isEmpty()) {// comes with IndustrialCraft2
} else if (OreDictionary.doesOreNameExist("circuitBasic") && !OreDictionary.getOres("circuitBasic").isEmpty()) {// comes with IndustrialCraft2, GregTech, ICBM-Classic
oreCircuitOrHeavyPressurePlate = "circuitBasic";
outputFactor = 2;
}
String oreSlimeOrTinOrLead = "slimeball";
// Computer interface: double output with Soldering alloy
if (OreDictionary.doesOreNameExist("ingotSolderingAlloy") && !OreDictionary.getOres("ingotSolderingAlloy").isEmpty()) {
@ -1232,7 +1233,7 @@ public class Recipes {
// Warp helmet
WarpDrive.register(new ShapedOreRecipe(groupTools,
new ItemStack(WarpDrive.itemWarpArmor[3]), false, "ggg", "gig", "wcw",
WarpDrive.itemWarpArmor[3], false, "ggg", "gig", "wcw",
'i', Items.IRON_HELMET,
'w', Blocks.WOOL,
'g', "blockGlass",
@ -1240,7 +1241,7 @@ public class Recipes {
// Warp chestplate
WarpDrive.register(new ShapedOreRecipe(groupTools,
new ItemStack(WarpDrive.itemWarpArmor[2]), false, "gcg", "wiw", "GmG",
WarpDrive.itemWarpArmor[2], false, "gcg", "wiw", "GmG",
'i', Items.IRON_CHESTPLATE,
'w', Blocks.WOOL,
'g', "blockHull3_glass",
@ -1250,7 +1251,7 @@ public class Recipes {
// Warp Leggings
WarpDrive.register(new ShapedOreRecipe(groupTools,
new ItemStack(WarpDrive.itemWarpArmor[1]), false, "gig", "m m", "w w",
WarpDrive.itemWarpArmor[1], false, "gig", "m m", "w w",
'i', Items.IRON_LEGGINGS,
'm', ItemComponent.getItemStack(EnumComponentType.MOTOR),
'w', Blocks.WOOL,
@ -1258,7 +1259,7 @@ public class Recipes {
// Warp boots
WarpDrive.register(new ShapedOreRecipe(groupTools,
new ItemStack(WarpDrive.itemWarpArmor[0]), false, "wiw", "r r", " ",
WarpDrive.itemWarpArmor[0], false, "wiw", "r r", " ",
'i', Items.IRON_BOOTS,
'w', Blocks.WOOL,
'r', rubberOrLeather));

View file

@ -29,11 +29,11 @@ public abstract class AbstractStructureInstance extends WorldGenerator {
}
value = Double.parseDouble(entry.getValue());
} catch (final NumberFormatException exception) {
throw new RuntimeException("Invalid expression '" + entry.getValue() + "'"
+ (stringValue.equalsIgnoreCase(entry.getValue()) ? "" : " in '" + entry.getValue() + "'")
+ " for variable " + entry.getKey()
+ " in deployable structure " + structure.name
+ ": a numeric value is expected. Check the related XML configuration file...");
throw new RuntimeException(String.format("Invalid expression '%s'%s for variable %s in deployable structure %s: a numeric value is expected. Check the related XML configuration file...",
entry.getValue(),
(stringValue.equalsIgnoreCase(entry.getValue()) ? "" : " in '" + entry.getValue() + "'"),
entry.getKey(),
structure.name));
}
variables.put(entry.getKey(), value);

View file

@ -30,7 +30,8 @@ public class MetaOrb extends Orb {
final List<Element> listMetaShells = XmlFileManager.getChildrenElementByTagName(element, "metaShell");
if (listMetaShells.size() > 1) {
throw new InvalidXmlException("Too many metaShell defined in structure " + getFullName() + ". Maximum is 1.");
throw new InvalidXmlException(String.format("Too many metaShell defined in structure %s. Maximum is 1.",
getFullName()));
}
if (listMetaShells.size() == 1) {
metaShell = new MetaShell(getFullName());

View file

@ -43,12 +43,14 @@ public class StructureManager extends XmlFileManager {
protected void parseRootElement(final String location, final Element elementStructure) throws InvalidXmlException, SAXException, IOException {
final String group = elementStructure.getAttribute("group");
if (group.isEmpty()) {
throw new InvalidXmlException(String.format("%s is missing a group attribute!", location));
throw new InvalidXmlException(String.format("%s is missing a group attribute!",
location));
}
final String name = elementStructure.getAttribute("name");
if (name.isEmpty()) {
throw new InvalidXmlException(String.format("%s is missing a name attribute!", location));
throw new InvalidXmlException(String.format("%s is missing a name attribute!",
location));
}
WarpDrive.logger.info(String.format("- found Structure %s:%s", group, name));

View file

@ -15,6 +15,7 @@ import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
@IFMLLoadingPlugin.TransformerExclusions(value = "cr0s.warpdrive.core.")
@IFMLLoadingPlugin.SortingIndex(value = 1001) // > 1000 to work with srg names
public class FMLLoadingPlugin implements IFMLLoadingPlugin, IFMLCallHook {
public static File location;
public static final Logger logger = LogManager.getLogger("WarpDriveCore");
private boolean debugLog = false;

View file

@ -14,8 +14,10 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public class MyDummyModContainer extends DummyModContainer {
public MyDummyModContainer() {
super(new ModMetadata());
final ModMetadata meta = getMetadata();
meta.modId = "WarpDriveCore";
meta.name = "WarpDriveCore";

View file

@ -6,6 +6,7 @@ public class DamageAsphyxia extends DamageSource {
public DamageAsphyxia() {
super("warpdrive.asphyxia");
setDamageBypassesArmor();
setDamageIsAbsolute();
}

View file

@ -6,6 +6,7 @@ public class DamageCold extends DamageSource {
public DamageCold() {
super("warpdrive.cold");
setDamageBypassesArmor();
setDamageIsAbsolute();
}

View file

@ -18,6 +18,7 @@ public class DamageIrradiation extends DamageSource {
public DamageIrradiation() {
super("warpdrive.irradiation");
setDamageBypassesArmor();
setDamageIsAbsolute();
}

View file

@ -6,6 +6,7 @@ public class DamageLaser extends DamageSource {
public DamageLaser() {
super("warpdrive.laser");
setDamageBypassesArmor();
setDamageIsAbsolute();
}

View file

@ -6,6 +6,7 @@ public class DamageShock extends DamageSource {
public DamageShock() {
super("warpdrive.shock");
setDamageBypassesArmor();
setDamageIsAbsolute();
}

View file

@ -6,6 +6,7 @@ public class DamageTeleportation extends DamageSource {
public DamageTeleportation() {
super("warpdrive.teleportation");
setDamageBypassesArmor();
}

View file

@ -6,6 +6,7 @@ public class DamageWarm extends DamageSource {
public DamageWarm() {
super("warpdrive.warm");
setDamageBypassesArmor();
setDamageIsAbsolute();
}

View file

@ -107,16 +107,19 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
// get identity
id = elementCelestialObject.getAttribute("id");
if (id.isEmpty()) {
throw new InvalidXmlException(String.format("Celestial object %s is missing an id attribute!", location));
throw new InvalidXmlException(String.format("Celestial object %s is missing an id attribute!",
location));
}
WarpDrive.logger.info(String.format("- found Celestial object %s", id));
WarpDrive.logger.info(String.format("- found Celestial object %s",
id));
// get optional parent element, defaulting to parent defined by element hierarchy
parentId = parentElementId;
final List<Element> listParents = XmlFileManager.getChildrenElementByTagName(elementCelestialObject,"parent");
if (listParents.size() > 1) {
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one parent element", id));
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one parent element",
id));
}
if (listParents.size() == 1) {
final Element elementParent = listParents.get(0);
@ -130,7 +133,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
// get required center element
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementParent, "center");
if (listElements.size() != 1) {
throw new InvalidXmlException(String.format("Celestial object %s parent requires exactly one center element", id));
throw new InvalidXmlException(String.format("Celestial object %s parent requires exactly one center element",
id));
}
final Element elementCenter = listElements.get(0);
parentCenterX = Integer.parseInt(elementCenter.getAttribute("x"));
@ -141,7 +145,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
{
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementCelestialObject, "size");
if (listElements.size() != 1) {
throw new InvalidXmlException(String.format("Celestial object %s requires exactly one size element", id));
throw new InvalidXmlException(String.format("Celestial object %s requires exactly one size element",
id));
}
final Element elementSize = listElements.get(0);
borderRadiusX = Integer.parseInt(elementSize.getAttribute("x")) / 2;
@ -152,7 +157,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
{
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementCelestialObject, "name");
if (listElements.size() > 1) {
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one name element", id));
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one name element",
id));
}
if (listElements.size() == 1) {
final Element elementName = listElements.get(0);
@ -166,7 +172,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
{
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementCelestialObject, "description");
if (listElements.size() > 1) {
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one description element", id));
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one description element",
id));
}
if (listElements.size() == 1) {
final Element elementName = listElements.get(0);
@ -180,7 +187,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
{
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementCelestialObject, "nbt");
if (listElements.size() > 1) {
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one nbt element", id));
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one nbt element",
id));
}
tagCompound = null;
if (listElements.size() == 1) {
@ -190,7 +198,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
try {
tagCompound = (NBTTagCompound) JsonToNBT.getTagFromJson(stringNBT);
} catch (final NBTException exception) {
throw new InvalidXmlException(String.format("Invalid nbt for Celestial object %s", id));
throw new InvalidXmlException(String.format("Invalid nbt for Celestial object %s",
id));
}
}
}
@ -199,7 +208,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
// get optional dimension element
final List<Element> listDimensions = XmlFileManager.getChildrenElementByTagName(elementCelestialObject, "dimension");
if (listDimensions.size() > 1) {
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one dimension element", id));
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one dimension element",
id));
}
if (listDimensions.size() == 0) {
isVirtual = true;
@ -223,7 +233,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
{
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementDimension, "provider");
if (listElements.size() > 1) {
throw new InvalidXmlException(String.format("Celestial object %s dimension can only have up to one provider element", id));
throw new InvalidXmlException(String.format("Celestial object %s dimension can only have up to one provider element",
id));
}
if (listElements.size() == 1) {
final Element element = listElements.get(0);
@ -236,7 +247,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
// get required center element
final List<Element> listCenters = XmlFileManager.getChildrenElementByTagName(elementDimension, "center");
if (listCenters.size() != 1) {
throw new InvalidXmlException(String.format("Celestial object %s dimension requires exactly one center element", id));
throw new InvalidXmlException(String.format("Celestial object %s dimension requires exactly one center element",
id));
}
final Element elementCenter = listCenters.get(0);
dimensionCenterX = Integer.parseInt(elementCenter.getAttribute("x"));
@ -249,7 +261,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
final List<Element> listGenerates = XmlFileManager.getChildrenElementByTagName(elementDimension, "generate");
for (int indexElement = 0; indexElement < listGenerates.size(); indexElement++) {
final Element elementGenerate = listGenerates.get(indexElement);
final String locationGenerate = String.format("Celestial object %s generate %d/%d", id, indexElement + 1, listGenerates.size());
final String locationGenerate = String.format("Celestial object %s generate %d/%d",
id, indexElement + 1, listGenerates.size());
parseGenerateElement(locationGenerate, elementGenerate);
}
@ -260,7 +273,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
// get optional skybox element
final List<Element> listSkyboxes = XmlFileManager.getChildrenElementByTagName(elementCelestialObject, "skybox");
if (listSkyboxes.size() > 1) {
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one skybox element", id));
throw new InvalidXmlException(String.format("Celestial object %s can only have up to one skybox element",
id));
}
if (listSkyboxes.isEmpty()) {
backgroundColor = new ColorData(0.0F , 0.0F , 0.0F );
@ -302,7 +316,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
private float getFloat(final String locationParent, final Element elementParent, final String tagName, final float value) throws InvalidXmlException {
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementParent, tagName);
if (listElements.size() > 1) {
throw new InvalidXmlException(String.format("%s can only have up to one %s element", locationParent, tagName));
throw new InvalidXmlException(String.format("%s can only have up to one %s element",
locationParent, tagName));
}
if (listElements.isEmpty()) {
return value;
@ -317,7 +332,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
private ColorData getColorData(final String locationParent, final Element elementParent, final String tagName, final float red, final float green, final float blue) throws InvalidXmlException {
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementParent, tagName);
if (listElements.size() > 1) {
throw new InvalidXmlException(String.format("%s can only have up to one %s element", locationParent, tagName));
throw new InvalidXmlException(String.format("%s can only have up to one %s element",
locationParent, tagName));
}
if (listElements.isEmpty()) {
return new ColorData(red, green, blue);
@ -777,7 +793,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
alpha = Commons.clamp(0.0F, 1.0F, Float.parseFloat(elementRender.getAttribute("alpha")));
} catch (final Exception exception) {
exception.printStackTrace();
WarpDrive.logger.error(String.format("Exception while parsing Render element RGBA attributes at %s", location));
WarpDrive.logger.error(String.format("Exception while parsing Render element RGBA attributes at %s",
location));
red = 0.5F;
green = 0.5F;
blue = 0.5F;
@ -799,7 +816,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
try {
periodU = Commons.clampMantisse(0.001D, 1000000.0D, Double.parseDouble(stringPeriodU));
} catch (final NumberFormatException exception) {
throw new InvalidXmlException(String.format("Invalid periodU attribute '%s' at %s", stringPeriodU, location));
throw new InvalidXmlException(String.format("Invalid periodU attribute '%s' at %s",
stringPeriodU, location));
}
}
@ -809,7 +827,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
try {
periodV = Commons.clampMantisse(0.001D, 1000000.0D, Double.parseDouble(stringPeriodV));
} catch (final NumberFormatException exception) {
throw new InvalidXmlException(String.format("Invalid periodV attribute '%s' at %s", stringPeriodV, location));
throw new InvalidXmlException(String.format("Invalid periodV attribute '%s' at %s",
stringPeriodV, location));
}
}

View file

@ -2,7 +2,6 @@ package cr0s.warpdrive.data;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.InvalidXmlException;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.config.XmlFileManager;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.fml.relauncher.Side;

View file

@ -147,6 +147,9 @@ public class CloakManager {
@SuppressWarnings("unused") // Core mod
@SideOnly(Side.CLIENT)
public static boolean WorldClient_invalidateRegionAndSetBlock_setBlockState(final BlockPos blockPos, final IBlockState blockState, final int flags) {
final World world = Minecraft.getMinecraft().world;
assert world != null;
if (blockState.getBlock() != Blocks.AIR) {
for (final CloakedArea area : cloaks) {
if (area.isBlockWithinArea(blockPos)) {
@ -157,12 +160,12 @@ public class CloakManager {
if (WarpDrive.isDev && WarpDriveConfig.LOGGING_CLOAKING) {
WarpDrive.logger.info("CloakManager player is outside");
}
return Minecraft.getMinecraft().world.setBlockState(blockPos, area.blockStateFog, flags);
return world.setBlockState(blockPos, area.blockStateFog, flags);
}
}
}
}
return Minecraft.getMinecraft().world.setBlockState(blockPos, blockState, flags);
return world.setBlockState(blockPos, blockState, flags);
}
@SuppressWarnings("unused") // Core mod

View file

@ -218,6 +218,7 @@ public class CloakedArea {
public void clientCloak() {
assert Commons.isSafeThread();
final EntityPlayerSP player = Minecraft.getMinecraft().player;
assert player != null;
// Hide the blocks within area
if (WarpDriveConfig.LOGGING_CLOAKING) { WarpDrive.logger.info("Refreshing cloaked blocks..."); }
@ -249,6 +250,7 @@ public class CloakedArea {
@SideOnly(Side.CLIENT)
public void clientDecloak() {
final World world = Minecraft.getMinecraft().world;
assert world != null;
world.markBlockRangeForRenderUpdate(
minX - 1, Math.max( 0, minY - 1), minZ - 1,
maxX + 1, Math.min(255, maxY + 1), maxZ + 1);

View file

@ -155,7 +155,8 @@ public class EntityFXRegistry {
}
private static void printRegistry(final String trigger) {
WarpDrive.logger.info(String.format("AbstractEntityFX REGISTRY (%d entries after %d):", REGISTRY.size(), trigger));
WarpDrive.logger.info(String.format("AbstractEntityFX REGISTRY (%d entries after %s):",
REGISTRY.size(), trigger));
for (final Entry<Integer, CopyOnWriteArraySet<WeakReference<AbstractEntityFX>>> entryRegistryItems : REGISTRY.entrySet()) {
final StringBuilder message = new StringBuilder();

View file

@ -6,6 +6,7 @@ import java.util.HashMap;
import net.minecraft.util.IStringSerializable;
public enum EnumDisabledInputOutput implements IStringSerializable {
DISABLED ("disabled", 0),
INPUT ("input" , 1),
OUTPUT ("output" , 2);

View file

@ -6,6 +6,7 @@ import javax.annotation.Nonnull;
import java.util.HashMap;
public enum EnumForceFieldState implements IStringSerializable {
NOT_CONNECTED ("not_connected" , 0.1F ),
CONNECTED_NOT_POWERED ("connected_not_powered", 0.5F ),
CONNECTED_OFFLINE ("connected_offline" , 2.5F ),

View file

@ -217,7 +217,7 @@ public enum EnumForceFieldUpgrade implements IStringSerializable, IForceFieldUpg
entity.fallDistance = 0.0F;
entity.addVelocity(v3Motion.x, v3Motion.y, v3Motion.z);
// pass through forcefield
// pass through force field
if (distanceCollision <= distanceEntity) {
if (entity instanceof EntityLivingBase) {
entity.setPositionAndUpdate(
@ -250,7 +250,7 @@ public enum EnumForceFieldUpgrade implements IStringSerializable, IForceFieldUpg
entity.fallDistance = 0.0F;
entity.addVelocity(v3Motion.x, v3Motion.y, v3Motion.z);
// pass through forcefield
// pass through force field
if (distanceCollision >= distanceEntity) {
if (entity instanceof EntityLivingBase) {
entity.setPositionAndUpdate(

View file

@ -6,18 +6,19 @@ import javax.annotation.Nonnull;
import java.util.HashMap;
public enum EnumGasColor implements IStringSerializable {
BLUE ("blue"),
RED ("red"),
GREEN ("green"),
YELLOW ("yellow"),
DARK ("dark"),
DARKNESS ("darkness"),
WHITE ("white"),
MILK ("milk"),
ORANGE ("orange"),
SIREN ("siren"),
GRAY ("gray"),
VIOLET ("violet");
BLUE ("blue"),
RED ("red"),
GREEN ("green"),
YELLOW ("yellow"),
DARK ("dark"),
DARKNESS ("darkness"),
WHITE ("white"),
MILK ("milk"),
ORANGE ("orange"),
SIREN ("siren"),
GRAY ("gray"),
VIOLET ("violet");
private final String unlocalizedName;

View file

@ -6,13 +6,14 @@ import javax.annotation.Nonnull;
import java.util.HashMap;
public enum EnumLaserTreeFarmMode implements IStringSerializable {
INACTIVE ("inactive"),
FARMING_LOW_POWER ("farming_low_power"),
FARMING_POWERED ("farming_powered"),
SCANNING_LOW_POWER ("scanning_low_power"),
SCANNING_POWERED ("scanning_powered"),
PLANTING_LOW_POWER ("planting_low_power"),
PLANTING_POWERED ("planting_powered");
INACTIVE ("inactive"),
FARMING_LOW_POWER ("farming_low_power"),
FARMING_POWERED ("farming_powered"),
SCANNING_LOW_POWER ("scanning_low_power"),
SCANNING_POWERED ("scanning_powered"),
PLANTING_LOW_POWER ("planting_low_power"),
PLANTING_POWERED ("planting_powered");
private final String unlocalizedName;

View file

@ -6,11 +6,12 @@ import javax.annotation.Nonnull;
import java.util.HashMap;
public enum EnumMiningLaserMode implements IStringSerializable {
INACTIVE ("inactive"),
SCANNING_LOW_POWER ("scanning_low_power"),
SCANNING_POWERED ("scanning_powered"),
MINING_LOW_POWER ("mining_low_power"),
MINING_POWERED ("mining_powered");
INACTIVE ("inactive"),
SCANNING_LOW_POWER ("scanning_low_power"),
SCANNING_POWERED ("scanning_powered"),
MINING_LOW_POWER ("mining_low_power"),
MINING_POWERED ("mining_powered");
private final String unlocalizedName;

View file

@ -6,6 +6,7 @@ import javax.annotation.Nonnull;
import java.util.HashMap;
public enum EnumRadarMode implements IStringSerializable {
INACTIVE ("inactive"),
ACTIVE ("active"),
SCANNING ("scanning");

View file

@ -6,6 +6,7 @@ import java.util.HashMap;
import net.minecraft.util.IStringSerializable;
public enum EnumSirenType implements IStringSerializable {
INDUSTRIAL("industrial", 0),
RAID ("raid" , 4);

View file

@ -6,6 +6,7 @@ import java.util.HashMap;
import net.minecraft.util.IStringSerializable;
public enum EnumValidPowered implements IStringSerializable {
INVALID("invalid", 6),
VALID ("valid" , 0),
POWERED("powered", 8);

View file

@ -12,6 +12,7 @@ import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraftforge.common.DimensionManager;
public class GlobalPosition {
public final int dimensionId;
public final int x, y, z;

View file

@ -22,6 +22,7 @@ import net.minecraft.util.EnumFacing;
@SuppressWarnings("WeakerAccess")
public class Vector3 implements Cloneable {
public double x;
public double y;
public double z;

View file

@ -45,6 +45,7 @@ public class EntityParticleBunch extends Entity {
public EntityParticleBunch(final World world) {
super(world);
if (WarpDriveConfig.LOGGING_ACCELERATOR) {
WarpDrive.logger.info(String.format("%s created in dimension %s",
this, Commons.format(world)));
@ -53,6 +54,7 @@ public class EntityParticleBunch extends Entity {
public EntityParticleBunch(final World world, final double x, final double y, final double z) {
super(world);
this.posX = x + 0.5D;
this.posY = y + 0.5D;
this.posZ = z + 0.5D;

View file

@ -230,6 +230,7 @@ public class ChunkHandler {
updateTick(event.world);
}
@SuppressWarnings("ConstantConditions")
public static void onBlockUpdated(final World world, final int x, final int y, final int z) {
if (!world.isRemote) {
final ChunkData chunkData = getChunkData(world, x, y, z);

View file

@ -45,7 +45,7 @@ public class ModelBakeEventHandler {
bakedModelNew = entry.getValue().newInstance();
bakedModelNew.setResourceLocation(entry.getKey());
bakedModelNew.setOriginalBakedModel(bakedModelExisting);
} catch (Exception exception) {
} catch (final Exception exception) {
exception.printStackTrace();
WarpDrive.logger.error(String.format("Failed to instantiate bake model calls for %s, using class %s",
entry.getKey(), entry.getValue()));

View file

@ -25,6 +25,7 @@ public class ItemAbstractBase extends Item implements IItemBase {
public ItemAbstractBase(final String registryName) {
super();
setRegistryName(registryName);
setCreativeTab(WarpDrive.creativeTabMain);
WarpDrive.register(this);

View file

@ -15,6 +15,7 @@ public class ItemAirTank extends ItemAbstractBase implements IAirContainerItem {
public ItemAirTank(final byte tier, final String registryName) {
super(registryName);
this.tier = tier;
setMaxDamage(capacities[tier]);
setMaxStackSize(1);

View file

@ -33,6 +33,7 @@ public class ItemElectromagneticCell extends ItemAbstractBase implements IPartic
public ItemElectromagneticCell(final String registryName) {
super(registryName);
setMaxDamage(0);
setMaxStackSize(1);
setUnlocalizedName("warpdrive.atomic.electromagnetic_cell");

View file

@ -34,6 +34,7 @@ public class ItemForceFieldShape extends ItemAbstractBase {
public ItemForceFieldShape(final String registryName) {
super(registryName);
setHasSubtypes(true);
setUnlocalizedName("warpdrive.force_field.shape");

View file

@ -16,7 +16,6 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
@ -34,6 +33,7 @@ public class ItemForceFieldUpgrade extends ItemAbstractBase {
public ItemForceFieldUpgrade(final String registryName) {
super(registryName);
setHasSubtypes(true);
setUnlocalizedName("warpdrive.force_field.upgrade");

View file

@ -20,6 +20,7 @@ public class ItemIC2reactorLaserFocus extends ItemAbstractBase implements IReact
public ItemIC2reactorLaserFocus(final String registryName) {
super(registryName);
setMaxDamage(WarpDriveConfig.IC2_REACTOR_MAX_HEAT_STORED);
setUnlocalizedName("warpdrive.energy.IC2reactorLaserFocus");
}

View file

@ -27,6 +27,7 @@ public class ItemShipToken extends ItemAbstractBase {
public ItemShipToken(final String registryName) {
super(registryName);
setHasSubtypes(true);
setUnlocalizedName("warpdrive.tool.ship_token");
setCreativeTab(WarpDrive.creativeTabMain);
@ -95,6 +96,7 @@ public class ItemShipToken extends ItemAbstractBase {
itemStack.setTagCompound(new NBTTagCompound());
}
final NBTTagCompound tagCompound = itemStack.getTagCompound();
assert tagCompound != null;
tagCompound.setString("shipName", schematicName);
}
@ -104,6 +106,7 @@ public class ItemShipToken extends ItemAbstractBase {
@Nonnull final List<String> list, @Nullable final ITooltipFlag advancedItemTooltips) {
super.addInformation(itemStack, world, list, advancedItemTooltips);
Commons.addTooltip(list, new TextComponentTranslation("item.warpdrive.tool.ship_token.tooltip.usage", getSchematicName(itemStack)).getFormattedText());
Commons.addTooltip(list, new TextComponentTranslation("item.warpdrive.tool.ship_token.tooltip.usage",
getSchematicName(itemStack)).getFormattedText());
}
}

View file

@ -46,6 +46,7 @@ public class ItemTuningDriver extends ItemAbstractBase implements IWarpTool {
public ItemTuningDriver(final String registryName) {
super(registryName);
setMaxDamage(0);
setCreativeTab(WarpDrive.creativeTabMain);
setMaxStackSize(1);
@ -108,6 +109,7 @@ public class ItemTuningDriver extends ItemAbstractBase implements IWarpTool {
return -1;
}
final NBTTagCompound tagCompound = itemStack.getTagCompound();
assert tagCompound != null;
if (tagCompound.hasKey(IVideoChannel.VIDEO_CHANNEL_TAG)) {
return tagCompound.getInteger(IVideoChannel.VIDEO_CHANNEL_TAG);
}

View file

@ -1,12 +1,10 @@
package cr0s.warpdrive.item;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBeamFrequency;
import cr0s.warpdrive.api.IControlChannel;
import cr0s.warpdrive.api.IVideoChannel;
import cr0s.warpdrive.api.IWarpTool;
import cr0s.warpdrive.api.WarpDriveText;
import cr0s.warpdrive.block.energy.BlockCapacitor;
import cr0s.warpdrive.data.SoundEvents;
@ -41,6 +39,7 @@ public class ItemTuningFork extends ItemAbstractBase implements IWarpTool {
public ItemTuningFork(final String registryName) {
super(registryName);
setMaxDamage(0);
setMaxStackSize(1);
setUnlocalizedName("warpdrive.tool.tuning_fork");
@ -137,17 +136,13 @@ public class ItemTuningFork extends ItemAbstractBase implements IWarpTool {
getControlChannel(itemStackHeld)));
world.playSound(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, SoundEvents.DING, SoundCategory.PLAYERS, 0.1F, 1F, false);
} else if (hasBeamFrequency) {
} else {
// assert hasBeamFrequency;
((IBeamFrequency)tileEntity).setBeamFrequency(getBeamFrequency(itemStackHeld));
Commons.addChatMessage(entityPlayer, new TextComponentTranslation("warpdrive.beam_frequency.set",
tileEntity.getBlockType().getLocalizedName(),
getBeamFrequency(itemStackHeld)));
world.playSound(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, SoundEvents.DING, SoundCategory.PLAYERS, 0.1F, 1F, false);
} else {
WarpDrive.logger.error(String.format("Invalid state, please contact the mod authors\nof %s %s\nand %s",
itemStackHeld, itemStackHeld.getItem().getRegistryName(), tileEntity));
Commons.addChatMessage(entityPlayer, new WarpDriveText(Commons.styleWarning, "warpdrive.error.internal_check_console"));
}
return EnumActionResult.SUCCESS;
}

View file

@ -17,6 +17,7 @@ public class ItemWarpArmor extends ItemArmor implements IBreathingHelmet {
public ItemWarpArmor(final String registryName, final ArmorMaterial armorMaterial, final int renderIndex, final EntityEquipmentSlot entityEquipmentSlot) {
super(armorMaterial, renderIndex, entityEquipmentSlot);
setUnlocalizedName("warpdrive.armor." + suffixes[entityEquipmentSlot.getIndex()]);
setRegistryName(registryName);
setCreativeTab(WarpDrive.creativeTabMain);

View file

@ -38,19 +38,6 @@ public class MessageBeamEffect implements IMessage, IMessageHandler<MessageBeamE
this.age = age;
}
public MessageBeamEffect(
final double sourceX, final double sourceY, final double sourceZ,
final double targetX, final double targetY, final double targetZ,
final float red, final float green, final float blue,
final int age, final int energy) {
this.source = new Vector3(sourceX, sourceY, sourceZ);
this.target = new Vector3(targetX, targetY, targetZ);
this.red = red;
this.green = green;
this.blue = blue;
this.age = age;
}
@Override
public void fromBytes(final ByteBuf buffer) {
double x = buffer.readDouble();

View file

@ -105,6 +105,7 @@ public class MessageCloak implements IMessage, IMessageHandler<MessageCloak, IMe
}
final EntityPlayerSP player = Minecraft.getMinecraft().player;
assert player != null;
if ( cloakMessage.minX <= player.posX && (cloakMessage.maxX + 1) > player.posX
&& cloakMessage.minY <= player.posY && (cloakMessage.maxY + 1) > player.posY
&& cloakMessage.minZ <= player.posZ && (cloakMessage.maxZ + 1) > player.posZ) {

View file

@ -77,9 +77,7 @@ public class PacketHandler {
final List<EntityPlayerMP> playerEntityList = world.getMinecraftServer().getPlayerList().getPlayers();
final int dimensionId = world.provider.getDimension();
final int radius_square = radius * radius;
for (int index = 0; index < playerEntityList.size(); index++) {
final EntityPlayerMP entityPlayerMP = playerEntityList.get(index);
for (final EntityPlayerMP entityPlayerMP : playerEntityList) {
if (entityPlayerMP.dimension == dimensionId) {
if ( v3Source.distanceTo_square(entityPlayerMP) < radius_square
|| v3Target.distanceTo_square(entityPlayerMP) < radius_square ) {
@ -142,9 +140,7 @@ public class PacketHandler {
// check both ends to send packet
final List<EntityPlayerMP> playerEntityList = world.getMinecraftServer().getPlayerList().getPlayers();
final int radius_square = radius * radius;
for (int index = 0; index < playerEntityList.size(); index++) {
final EntityPlayerMP entityPlayerMP = playerEntityList.get(index);
for (final EntityPlayerMP entityPlayerMP : playerEntityList) {
if ( globalPositionLocal != null
&& globalPositionLocal.distance2To(entityPlayerMP) < radius_square ) {
simpleNetworkManager.sendTo(messageTransporterEffectLocal, entityPlayerMP);
@ -209,6 +205,11 @@ public class PacketHandler {
public static void revealEntityToPlayer(final Entity entity, final EntityPlayerMP entityPlayerMP) {
try {
if (entityPlayerMP.connection == null) {
WarpDrive.logger.warn(String.format("Unable to reveal entity %s to player %s: no connection",
entity, entityPlayerMP));
return;
}
final Packet packet = getPacketForThisEntity(entity);
if (packet == null) {
WarpDrive.logger.error(String.format("Unable to reveal entity %s to player %s: null packet",

View file

@ -109,11 +109,11 @@ public class ClientCameraHandler {
}
public static void zoom() {
final Minecraft mc = Minecraft.getMinecraft();
zoomIndex = (zoomIndex + 1) % 4;
refreshViewPoint();
if (WarpDriveConfig.LOGGING_CAMERA) {
final Minecraft mc = Minecraft.getMinecraft();
assert mc.player != null;
mc.player.sendChatMessage("changed to fovSetting " + mc.gameSettings.fovSetting + " mouseSensitivity " + mc.gameSettings.mouseSensitivity);
}
}

View file

@ -23,9 +23,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import javax.annotation.Nullable;
import java.util.ArrayList;
public final class EntityCamera extends EntityLivingBase {
// entity coordinates (x, y, z) are dynamically changed by player
@ -55,6 +52,7 @@ public final class EntityCamera extends EntityLivingBase {
public EntityCamera(final World world, final int x, final int y, final int z, final EntityPlayer player) {
super(world);
posX = x;
posY = y;
posZ = z;

View file

@ -35,6 +35,7 @@ public class EntityFXBeam extends Particle {
final float red, final float green, final float blue,
final int age) {
super(world, position.x, position.y, position.z, 0.0D, 0.0D, 0.0D);
this.setRBGColorF(red, green, blue);
this.setSize(0.02F, 0.02F);
this.canCollide = false;

View file

@ -25,6 +25,7 @@ public class EntityFXBoundingBox extends Particle {
public EntityFXBoundingBox(final World world, final Vector3 position, final Vector3 min, final Vector3 max,
final float red, final float green, final float blue, final int age) {
super(world, position.x, position.y, position.z, 0.0D, 0.0D, 0.0D);
this.setRBGColorF(red, green, blue);
this.setSize(0.02F, 0.02F);
this.canCollide = false;

View file

@ -22,6 +22,7 @@ public class EntityFXDot extends AbstractEntityFX {
final Vector3 v3Motion, final Vector3 v3Acceleration, final double friction,
final int age) {
super(world, v3Position.x, v3Position.y, v3Position.z, 0.0D, 0.0D, 0.0D);
this.setSize(0.02F, 0.02F);
this.canCollide = false;
this.motionX = v3Motion.x;

View file

@ -31,6 +31,7 @@ public class EntityFXEnergizing extends AbstractEntityFX {
final float red, final float green, final float blue,
final int age, final float radius) {
super(world, position.x, position.y, position.z, 0.0D, 0.0D, 0.0D);
setRBGColorF(red, green, blue);
setSize(0.02F, 0.02F);
canCollide = false;

View file

@ -8,17 +8,18 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class RenderBlank extends IRenderHandler {
private static RenderBlank INSTANCE = null;
public static RenderBlank getInstance() {
if (INSTANCE == null) {
INSTANCE = new RenderBlank();
}
return INSTANCE;
}
@SideOnly(Side.CLIENT)
@Override
public void render(final float partialTicks, final WorldClient world, final Minecraft mc) {
}
private static RenderBlank INSTANCE = null;
public static RenderBlank getInstance() {
if (INSTANCE == null) {
INSTANCE = new RenderBlank();
}
return INSTANCE;
}
@SideOnly(Side.CLIENT)
@Override
public void render(final float partialTicks, final WorldClient world, final Minecraft mc) {
}
}

View file

@ -6,6 +6,7 @@ public class BiomeSpace extends Biome {
public BiomeSpace(final BiomeProperties biomeProperties) {
super(biomeProperties);
this.decorator.treesPerChunk = 0;
//this.temperature = 1F;
this.decorator.flowersPerChunk = 0;

View file

@ -46,6 +46,7 @@ import net.minecraft.world.World;
*/
public final class EntitySphereGen extends Entity {
public int xCoord;
public int yCoord;
public int zCoord;
@ -77,6 +78,7 @@ public final class EntitySphereGen extends Entity {
public EntitySphereGen(final World world, final int x, final int y, final int z,
final OrbInstance orbInstance, final boolean replace) {
super(world);
this.xCoord = x;
this.posX = x;
this.yCoord = y;

View file

@ -36,6 +36,7 @@ public final class EntityStarCore extends Entity {
public EntityStarCore(final World world, final int x, final int y, final int z, final int radius) {
super(world);
this.xCoord = x;
this.posX = x;
this.yCoord = y;

View file

@ -23,6 +23,7 @@ public class SpaceChunkProvider extends ChunkGeneratorOverworld {
public SpaceChunkProvider(final World world, final long seed) {
super(world, seed, false, null);
rand = new Random(seed);
this.world = world;
}

View file

@ -15,6 +15,7 @@ public class SpaceTeleporter extends Teleporter {
public SpaceTeleporter(final WorldServer worldServer, final int orientation, final int x, final int y, final int z) {
super(worldServer);
this.orientation = orientation;
this.x = x;
this.y = y;