diff --git a/src/main/java/cr0s/warpdrive/WarpDrive.java b/src/main/java/cr0s/warpdrive/WarpDrive.java index 7bc1e1ea..1ac52922 100644 --- a/src/main/java/cr0s/warpdrive/WarpDrive.java +++ b/src/main/java/cr0s/warpdrive/WarpDrive.java @@ -375,12 +375,6 @@ public class WarpDrive { itemForceFieldShape = new ItemForceFieldShape("itemForceFieldShape"); itemForceFieldUpgrade = new ItemForceFieldUpgrade("itemForceFieldUpgrade"); - itemForceFieldShape = new ItemForceFieldShape(); - GameRegistry.registerItem(itemForceFieldShape, "itemForceFieldShape"); - - itemForceFieldUpgrade = new ItemForceFieldUpgrade(); - GameRegistry.registerItem(itemForceFieldUpgrade, "itemForceFieldUpgrade"); - // hull blocks blockHulls_plain = new Block[3][EnumHullPlainType.length]; blockHulls_glass = new Block[3]; @@ -472,34 +466,6 @@ public class WarpDrive { } proxy.onForgePreInitialisation(); - - if (event.getSide().isClient()) { - creativeTabWarpDrive.setBackgroundImageName("items.png"); - - MinecraftForge.EVENT_BUS.register(new RenderOverlayAir()); - MinecraftForge.EVENT_BUS.register(new RenderOverlayCamera()); - MinecraftForge.EVENT_BUS.register(new RenderOverlayLocation()); - - MinecraftForge.EVENT_BUS.register(new ClientCameraHandler()); - - // @TODO MC1.10 force field rendering - /* - RenderBlockStandard.renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(RenderBlockStandard.instance); - - RenderBlockForceField.renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(RenderBlockForceField.instance); - - RenderBlockOmnipanel.renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(RenderBlockOmnipanel.instance); - - RenderBlockShipScanner.renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(RenderBlockShipScanner.instance); - - RenderBlockTransporterBeacon.renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(RenderBlockTransporterBeacon.instance); - /**/ - } } @EventHandler diff --git a/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorLaser.java b/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorLaser.java index 5bb7d082..03a3979d 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorLaser.java +++ b/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorLaser.java @@ -2,10 +2,17 @@ package cr0s.warpdrive.block.energy; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.block.BlockAbstractContainer; +import cr0s.warpdrive.data.BlockProperties; +import cr0s.warpdrive.data.EnumValidPowered; import net.minecraft.block.material.Material; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -18,14 +25,50 @@ public class BlockEnanReactorLaser extends BlockAbstractContainer { setResistance(60.0F * 5 / 3); setUnlocalizedName("warpdrive.energy.enan_reactor_laser"); GameRegistry.registerTileEntity(TileEntityEnanReactorLaser.class, WarpDrive.PREFIX + registryName); + + setDefaultState(blockState.getBaseState() + .withProperty(BlockProperties.FACING, EnumFacing.DOWN) + .withProperty(BlockProperties.VALID_POWERED, EnumValidPowered.INVALID)); } - + + @Nonnull + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, BlockProperties.FACING, BlockProperties.VALID_POWERED); + } + + @SuppressWarnings("deprecation") + @Nonnull + @Override + public IBlockState getStateFromMeta(final int metadata) { + final int facing = (metadata & 7) < 6 ? (metadata & 7) : 0; + final EnumValidPowered enumValidPowered = EnumValidPowered.get(metadata - facing); + return getDefaultState() + .withProperty(BlockProperties.FACING, EnumFacing.getFront(facing)) + .withProperty(BlockProperties.VALID_POWERED, enumValidPowered != null ? enumValidPowered : EnumValidPowered.INVALID); + } + + @Override + public int getMetaFromState(final IBlockState blockState) { + return blockState.getValue(BlockProperties.FACING).getIndex() + + blockState.getValue(BlockProperties.VALID_POWERED).getIndex(); + } + @Nonnull @Override public TileEntity createNewTileEntity(@Nonnull final World world, final int metadata) { return new TileEntityEnanReactorLaser(); } + @Override + public void onBlockPlacedBy(final World world, final BlockPos blockPos, final IBlockState blockState, + final EntityLivingBase entityLiving, final ItemStack itemStack) { + super.onBlockPlacedBy(world, blockPos, blockState, entityLiving, itemStack); + world.setBlockState(blockPos, blockState + .withProperty(BlockProperties.FACING, EnumFacing.NORTH) + .withProperty(BlockProperties.VALID_POWERED, EnumValidPowered.INVALID)); + } + @Override public byte getTier(final ItemStack itemStack) { return 3; diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java index 3fdbda33..284c75d4 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java @@ -57,25 +57,6 @@ public class TileEntityForceField extends TileEntityAbstractBase { cache_colorMultiplierCamouflage = 0; cache_lightCamouflage = 0; } - } else if (tagCompound.hasKey("camouflageBlock")) {// legacy up to 1.7.10-1.3.38 - try { - cache_blockCamouflage = Block.getBlockFromName(tagCompound.getString("camouflageBlock")); - cache_metadataCamouflage = tagCompound.getByte("camouflageMeta"); - cache_colorMultiplierCamouflage = tagCompound.getInteger("camouflageColorMultiplier"); - cache_lightCamouflage = tagCompound.getByte("camouflageLight"); - if (Dictionary.BLOCKS_NOCAMOUFLAGE.contains(cache_blockCamouflage)) { - cache_blockCamouflage = null; - cache_metadataCamouflage = 0; - cache_colorMultiplierCamouflage = 0; - cache_lightCamouflage = 0; - } - } catch (final Exception exception) { - exception.printStackTrace(); - cache_blockCamouflage = null; - cache_metadataCamouflage = 0; - cache_colorMultiplierCamouflage = 0; - cache_lightCamouflage = 0; - } } else { cache_blockStateCamouflage = null; cache_colorMultiplierCamouflage = 0; diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java index 3405b103..9c5d6b9a 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java @@ -49,6 +49,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; @@ -821,10 +822,11 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField final Block block = vector.getBlock(worldObj); if (block == WarpDrive.blockForceFields[tier - 1]) { - final TileEntity tileEntity = worldObj.getTileEntity(vector.x, vector.y, vector.z); + final BlockPos blockPos = vector.getBlockPos(); + final TileEntity tileEntity = worldObj.getTileEntity(blockPos); if ( tileEntity instanceof TileEntityForceField && (((TileEntityForceField) tileEntity).getProjector() == this) ) { - worldObj.setBlockToAir(vector.x, vector.y, vector.z); + worldObj.setBlockToAir(blockPos); } } } diff --git a/src/main/java/cr0s/warpdrive/block/passive/BlockDecorative.java b/src/main/java/cr0s/warpdrive/block/passive/BlockDecorative.java deleted file mode 100644 index 642882a7..00000000 --- a/src/main/java/cr0s/warpdrive/block/passive/BlockDecorative.java +++ /dev/null @@ -1,78 +0,0 @@ -package cr0s.warpdrive.block.passive; - -import cr0s.warpdrive.WarpDrive; -import cr0s.warpdrive.block.BlockAbstractBase; -import cr0s.warpdrive.data.EnumDecorativeType; - -import java.util.List; - -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class BlockDecorative extends BlockAbstractBase { - - @SideOnly(Side.CLIENT) - private static IIcon[] icons; - - private static ItemStack[] itemStackCache; - - public BlockDecorative() { - super(Material.iron); - setHardness(1.5f); - setBlockName("warpdrive.decoration.decorative.plain"); - - itemStackCache = new ItemStack[EnumDecorativeType.length]; - } - - @Override - public void getSubBlocks(final Item item, final CreativeTabs creativeTabs, final List list) { - for (final EnumDecorativeType enumDecorativeType : EnumDecorativeType.values()) { - list.add(new ItemStack(item, 1, enumDecorativeType.ordinal())); - } - } - - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(final IIconRegister iconRegister) { - icons = new IIcon[EnumDecorativeType.length]; - for (final EnumDecorativeType enumDecorativeType : EnumDecorativeType.values()) { - icons[enumDecorativeType.ordinal()] = iconRegister.registerIcon("warpdrive:decoration/decorative-" + enumDecorativeType.getName()); - } - } - - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(final int side, final int damage) { - if (damage >= 0 && damage < EnumDecorativeType.length) { - return icons[damage]; - } - return icons[0]; - } - - @Override - public int damageDropped(final int damage) { - return damage; - } - - public static ItemStack getItemStack(final EnumDecorativeType enumDecorativeType) { - if (enumDecorativeType != null) { - final int damage = enumDecorativeType.ordinal(); - if (itemStackCache[damage] == null) { - itemStackCache[damage] = new ItemStack(WarpDrive.blockDecorative, 1, damage); - } - return itemStackCache[damage]; - } - return null; - } - - public static ItemStack getItemStackNoCache(final EnumDecorativeType enumDecorativeType, final int amount) { - return new ItemStack(WarpDrive.blockDecorative, amount, enumDecorativeType.ordinal()); - } -} diff --git a/src/main/java/cr0s/warpdrive/block/passive/ItemBlockDecorative.java b/src/main/java/cr0s/warpdrive/block/passive/ItemBlockDecorative.java deleted file mode 100644 index 664fc889..00000000 --- a/src/main/java/cr0s/warpdrive/block/passive/ItemBlockDecorative.java +++ /dev/null @@ -1,40 +0,0 @@ -package cr0s.warpdrive.block.passive; - -import cr0s.warpdrive.data.EnumDecorativeType; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; - -public class ItemBlockDecorative extends ItemBlock { - - public ItemBlockDecorative(final Block block) { - super(block); - setHasSubtypes(true); - setUnlocalizedName("warpdrive.decoration.decorative"); - } - - @Override - public int getMetadata(final int damage) { - return damage; - } - - @Override - public void getSubItems(final Item item, final CreativeTabs creativeTabs, final List list) { - for (final EnumDecorativeType decorativeType : EnumDecorativeType.values()) { - list.add(new ItemStack(item, 1, decorativeType.ordinal())); - } - } - - @Override - public String getUnlocalizedName(final ItemStack itemstack) { - if (itemstack == null) { - return getUnlocalizedName(); - } - return "tile.warpdrive.decoration.decorative." + EnumDecorativeType.get(itemstack.getItemDamage()).getName(); - } -} diff --git a/src/main/java/cr0s/warpdrive/client/ClientProxy.java b/src/main/java/cr0s/warpdrive/client/ClientProxy.java index 9d505042..dc94314a 100644 --- a/src/main/java/cr0s/warpdrive/client/ClientProxy.java +++ b/src/main/java/cr0s/warpdrive/client/ClientProxy.java @@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoaderRegistry; +import net.minecraftforge.common.MinecraftForge; public class ClientProxy extends CommonProxy { @@ -31,8 +32,8 @@ public class ClientProxy extends CommonProxy { ModelLoaderRegistry.registerLoader(MyCustomModelLoader.INSTANCE); // blocks - // IModelInitialisation(WarpDrive.blockShipCore); - // IModelInitialisation(WarpDrive.blockShipController); + IModelInitialisation(WarpDrive.blockShipCore); + IModelInitialisation(WarpDrive.blockShipController); IModelInitialisation(WarpDrive.blockRadar); IModelInitialisation(WarpDrive.blockWarpIsolation); @@ -70,8 +71,8 @@ public class ClientProxy extends CommonProxy { if (WarpDriveConfig.isIndustrialCraft2Loaded) { IModelInitialisation(WarpDrive.blockIC2reactorLaserMonitor); } - // IModelInitialisation(WarpDrive.blockEnanReactorCore); - // IModelInitialisation(WarpDrive.blockEnanReactorLaser); + IModelInitialisation(WarpDrive.blockEnanReactorCore); + IModelInitialisation(WarpDrive.blockEnanReactorLaser); IModelInitialisation(WarpDrive.blockEnergyBank); IModelInitialisation(WarpDrive.blockGas); IModelInitialisation(WarpDrive.blockIridium); @@ -86,18 +87,18 @@ public class ClientProxy extends CommonProxy { IModelInitialisation(WarpDrive.blockForceFieldRelays[index]); } - // IModelInitialisation(WarpDrive.blockAcceleratorController); - // IModelInitialisation(WarpDrive.blockAcceleratorControlPoint); - // IModelInitialisation(WarpDrive.blockParticlesCollider); - // IModelInitialisation(WarpDrive.blockParticlesInjector); - // IModelInitialisation(WarpDrive.blockVoidShellPlain); - // IModelInitialisation(WarpDrive.blockVoidShellGlass); - // for(byte tier = 1; tier <= 3; tier++) { - // int index = tier - 1; - // IModelInitialisation(WarpDrive.blockElectromagnetPlain[index]); - // IModelInitialisation(WarpDrive.blockElectromagnetGlass[index]); - // IModelInitialisation(WarpDrive.blockChillers[index]); - // } + IModelInitialisation(WarpDrive.blockAcceleratorController); + IModelInitialisation(WarpDrive.blockAcceleratorControlPoint); + IModelInitialisation(WarpDrive.blockParticlesCollider); + IModelInitialisation(WarpDrive.blockParticlesInjector); + IModelInitialisation(WarpDrive.blockVoidShellPlain); + IModelInitialisation(WarpDrive.blockVoidShellGlass); + for(byte tier = 1; tier <= 3; tier++) { + int index = tier - 1; + IModelInitialisation(WarpDrive.blockElectromagnetPlain[index]); + IModelInitialisation(WarpDrive.blockElectromagnetGlass[index]); + IModelInitialisation(WarpDrive.blockChillers[index]); + } IModelInitialisation(WarpDrive.blockDecorative); @@ -139,17 +140,39 @@ public class ClientProxy extends CommonProxy { IModelInitialisation(WarpDrive.itemForceFieldShape); IModelInitialisation(WarpDrive.itemForceFieldUpgrade); - // IModelInitialisation(WarpDrive.itemElectromagneticCell); + IModelInitialisation(WarpDrive.itemElectromagneticCell); - // entities + // creative tab + WarpDrive.creativeTabWarpDrive.setBackgroundImageName("items.png"); + + // generic rendering + // MinecraftForge.EVENT_BUS.register(new WarpDriveKeyBindings()); + MinecraftForge.EVENT_BUS.register(new RenderOverlayAir()); + MinecraftForge.EVENT_BUS.register(new RenderOverlayCamera()); + MinecraftForge.EVENT_BUS.register(new RenderOverlayLocation()); + + MinecraftForge.EVENT_BUS.register(new ClientCameraHandler()); + + // entity rendering // RenderingRegistry.registerEntityRenderingHandler(EntityXXX.class, RenderXXX::new); // RenderingRegistry.registerEntityRenderingHandler(EntityParticleBunch.class, new RenderEntityParticleBunch()); + // @TODO MC1.10 force field rendering + /* + RenderBlockStandard.renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(RenderBlockStandard.instance); - // MinecraftForge.EVENT_BUS.register(new WarpDriveKeyBindings()); - // MinecraftForge.EVENT_BUS.register(new RenderGameOverlay(); - // MinecraftForge.EVENT_BUS.register(new RenderOverlayAir()); - // MinecraftForge.EVENT_BUS.register(new RenderOverlayCamera()); - // MinecraftForge.EVENT_BUS.register(new RenderOverlayLocation()); + RenderBlockForceField.renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(RenderBlockForceField.instance); + + RenderBlockOmnipanel.renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(RenderBlockOmnipanel.instance); + + RenderBlockShipScanner.renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(RenderBlockShipScanner.instance); + + RenderBlockTransporterBeacon.renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(RenderBlockTransporterBeacon.instance); + /**/ } private static void IModelInitialisation(Object object) { diff --git a/src/main/java/cr0s/warpdrive/data/EnumForceFieldShape.java b/src/main/java/cr0s/warpdrive/data/EnumForceFieldShape.java index 0fc42a5a..cf1397b4 100644 --- a/src/main/java/cr0s/warpdrive/data/EnumForceFieldShape.java +++ b/src/main/java/cr0s/warpdrive/data/EnumForceFieldShape.java @@ -3,7 +3,6 @@ package cr0s.warpdrive.data; import cr0s.warpdrive.Commons; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.api.IForceFieldShape; -import cr0s.warpdrive.api.IStringSerializable; import cr0s.warpdrive.config.WarpDriveConfig; import net.minecraft.util.IStringSerializable; diff --git a/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java b/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java index 9f74b587..91fccac0 100644 --- a/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java +++ b/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java @@ -3,7 +3,6 @@ package cr0s.warpdrive.data; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.api.IForceFieldUpgrade; import cr0s.warpdrive.api.IForceFieldUpgradeEffector; -import cr0s.warpdrive.api.IStringSerializable; import cr0s.warpdrive.network.PacketHandler; import javax.annotation.Nonnull; diff --git a/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java b/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java index d5776308..db4ba7df 100644 --- a/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java +++ b/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java @@ -399,13 +399,6 @@ public class StarMapRegistry { continue; } - // Compare areas for intersection - final AxisAlignedBB aabb2 = AxisAlignedBB.getBoundingBox(registryItem.minX, registryItem.minY, registryItem.minZ, - registryItem.maxX, registryItem.maxY, registryItem.maxZ); - if (!aabb1.intersectsWith(aabb2)) { - continue; - } - // Skip missing ship cores final TileEntity tileEntity = core.getWorld().getTileEntity(new BlockPos(registryItem.x, registryItem.y, registryItem.z)); if (!(tileEntity instanceof TileEntityShipCore)) { diff --git a/src/main/java/cr0s/warpdrive/render/TileEntityForceFieldProjectorRenderer.java b/src/main/java/cr0s/warpdrive/render/TileEntityForceFieldProjectorRenderer.java index 422ce010..64e5d575 100644 --- a/src/main/java/cr0s/warpdrive/render/TileEntityForceFieldProjectorRenderer.java +++ b/src/main/java/cr0s/warpdrive/render/TileEntityForceFieldProjectorRenderer.java @@ -79,6 +79,7 @@ public class TileEntityForceFieldProjectorRenderer extends TileEntitySpecialRend // GlStateManager.disableCull(); RenderHelper.disableStandardItemLighting(); GlStateManager.enableLighting(); + // @TODO setLightmapDisabled final float wheelRotation = tileEntityForceFieldProjector.rotation_deg + partialTicks * tileEntityForceFieldProjector.rotationSpeed_degPerTick; GlStateManager.rotate(wheelRotation, 0.0F, 1.0F, 0.0F); diff --git a/src/main/resources/assets/warpdrive/blockstates/blockChunkLoader.json b/src/main/resources/assets/warpdrive/blockstates/blockChunkLoader.json index 64b0c51e..1ddcea35 100644 --- a/src/main/resources/assets/warpdrive/blockstates/blockChunkLoader.json +++ b/src/main/resources/assets/warpdrive/blockstates/blockChunkLoader.json @@ -3,7 +3,7 @@ "defaults": { "model": "minecraft:cube_all", "textures": { - "all": "warpdrive:blocks/chunkLoader" + "all": "warpdrive:blocks/chunk_loader" }, "transform": "forge:default-block" },