Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
Как я понял, ты хочешь сделать интеграцию с каким-то модом.Asd1995sse написал(а):Ну а если мод не установлен, то мой мод крашнет игру, мне нужно чтобы он не запустился.
package AsdIC2mod;
import java.io.File;
import AsdIC2mod.Blocks.Ic2TestBlock;
import AsdIC2mod.Lang.AsdLang;
import net.minecraft.block.Block;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.Configuration;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod (modid = "AsdIC2mod|Energy", name = "AsdIC2mod|Energy", version="1.6.4_3.3.5", dependencies = "after:IC2;after:BuildCraft|Energy")
@NetworkMod (clientSideRequired = true, serverSideRequired = true, versionBounds = "1.0.0")
public class AsdCoreEC{
public final static String MODID = "AsdIC2mod|Energy";
@Instance("AsdIC2mod|Energy")
public static AsdCoreEC instance;
public static Item WolfIngot;
public static int WolfIngotID;
public static Block TestBlock;
public static int TestBlockID;
@Init
public void load(FMLInitializationEvent event){
TestBlock = new Ic2TestBlock(TestBlockID).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("TestBlock").setHardness(15.0F).setResistance(5.0F);
GameRegistry.registerBlock(TestBlock);
AsdLang.getInstance().registerItemName(TestBlock, "TestBlock.01");
WolfIngot = new WolfIngot(WolfIngotID, 64).setUnlocalizedName("WolfIngot");
AsdLang.getInstance().registerItemName(WolfIngot, "Items.WolfIngot");
}
@PreInit
public void preLoad(FMLPreInitializationEvent event)
{
Configuration config = new Configuration(new File(event.getModConfigurationDirectory(),"Asd"));
config.load();
TestBlockID = config.getBlock("TestBlock", 2778).getInt();
WolfIngotID = config.getItem("WolfIngot", 2570).getInt();
config.save();
}
@PostInit
public void postLoad(FMLPostInitializationEvent event)
{
}
}
Да я понял это!Dragon2488 написал(а):ПОНИМАЕШЬ, 4096 - МАКСИМАЛЬНЫЙ РАЗМЕР МАССИВА БЛОКОВ. А 32000 - МАКСИМАЛЬНЫЙ РАЗМЕР МАССИВА ПРЕДМЕТОВ.
public boolean isMultiBlockStructure(World world, int x, int y, int z){
if (checkNorth(world, x, y, z))/*North*/
return true;
if (checkEast(world, x, y, z))/*East*/
return true;
if (checkSouth(world, x, y, z))/*South*/
return true;
if (checkWest(world, x, y, z))/*West*/
return true;
return false;
}
private static boolean checkNorth(World world, int x, int y, int z)
{
if(world.getBlockId(x+0, y+0, z+-1) == 4)
{
if(world.getBlockId(x+0, y+1, z+0) == 666)
{
if(world.getBlockId(x+0, y+1, z+-1) == 1)
{
if(world.getBlockId(x+1, y+0, z+0) == 5)
{
if(world.getBlockId(x+1, y+0, z+-1) == 4)
{
if(world.getBlockId(x+1, y+1, z+0) == 2)
{
if(world.getBlockId(x+1, y+1, z+-1) == 1)
{
return true;
}
}
}
}
}
}
}
return false;
}
private static boolean checkEast(World world, int x, int y, int z)
{
if(world.getBlockId(x+1, y+0, z+0) == 4)
{
if(world.getBlockId(x+0, y+1, z+0) == 666)
{
if(world.getBlockId(x+1, y+1, z+0) == 1)
{
if(world.getBlockId(x+0, y+0, z+1) == 5)
{
if(world.getBlockId(x+1, y+0, z+1) == 4)
{
if(world.getBlockId(x+0, y+1, z+1) == 2)
{
if(world.getBlockId(x+1, y+1, z+1) == 1)
{
return true;
}
}
}
}
}
}
}
return false;
}
private static boolean checkSouth(World world, int x, int y, int z)
{
if(world.getBlockId(x+0, y+0, z+1) == 4)
{
if(world.getBlockId(x+0, y+1, z+0) == 666)
{
if(world.getBlockId(x+0, y+1, z+1) == 1)
{
if(world.getBlockId(x+-1, y+0, z+0) == 5)
{
if(world.getBlockId(x+-1, y+0, z+1) == 4)
{
if(world.getBlockId(x+-1, y+1, z+0) == 2)
{
if(world.getBlockId(x+-1, y+1, z+1) == 1)
{
return true;
}
}
}
}
}
}
}
return false;
}
private static boolean checkWest(World world, int x, int y, int z)
{
if(world.getBlockId(x+-1, y+0, z+0) == 4)
{
if(world.getBlockId(x+0, y+1, z+0) == 666)
{
if(world.getBlockId(x+-1, y+1, z+0) == 1)
{
if(world.getBlockId(x+0, y+0, z+-1) == 5)
{
if(world.getBlockId(x+-1, y+0, z+-1) == 4)
{
if(world.getBlockId(x+0, y+1, z+-1) == 2)
{
if(world.getBlockId(x+-1, y+1, z+-1) == 1)
{
return true;
}
}
}
}
}
}
}
return false;
}
package asdic2mod.ec;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
public abstract class AsdTileMultiBlock extends TileEntity implements IInventory, INetworkedObject, IOwnable{
private ItemStack[] inv;
private boolean hasMaster, isMaster;
private int masterX, masterY, masterZ;
@Override
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
if (hasMaster()) {
if (isMaster()) {
doMultiBlockStuff();
}
} else {
// Constantly check if structure is formed until it is.
if (checkMultiBlockForm())
setupStructure();
}
}
}
/**
* Stuff the multiblock will do when formed
*/
public abstract void doMultiBlockStuff();
/**
* Check that structure is properly formed
*/
public abstract boolean checkMultiBlockForm();
/**
* Setup all the blocks in the structure
*/
public abstract void setupStructure();
/**
* Reset method to be run when the master is gone or tells them to
*/
public void reset() {
masterX = 0;
masterY = 0;
masterZ = 0;
hasMaster = false;
isMaster = false;
}
public abstract void resetStructure();
/**
* Check that the master exists
*/
public boolean checkForMaster() {
TileEntity tile = worldObj.getBlockTileEntity(masterX, masterY, masterZ);
return (tile != null && (tile instanceof AsdTileMultiBlock));
}
/**
* Reset all the parts of the structure
*/
public AsdTileMultiBlock(){
inv = new ItemStack[9];
}
@Override
public int getSizeInventory() {
return inv.length;
}
@Override
public ItemStack getStackInSlot(int slot) {
return inv[slot];
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
inv[slot] = stack;
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
stack.stackSize = getInventoryStackLimit();
}
}
@Override
public ItemStack decrStackSize(int slot, int amt) {
ItemStack stack = getStackInSlot(slot);
if (stack != null) {
if (stack.stackSize <= amt) {
setInventorySlotContents(slot, null);
} else {
stack = stack.splitStack(amt);
if (stack.stackSize == 0) {
setInventorySlotContents(slot, null);
}
}
}
return stack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
ItemStack stack = getStackInSlot(slot);
if (stack != null) {
setInventorySlotContents(slot, null);
}
return stack;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this &&
player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
}
@Override
public void openChest() {}
@Override
public void closeChest() {}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
NBTTagList tagList = tagCompound.getTagList("Inventory");
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i);
byte slot = tag.getByte("Slot");
if (slot >= 0 && slot < inv.length) {
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
}
}
@Override
public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < inv.length; i++) {
ItemStack stack = inv[i];
if (stack != null) {
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) i);
stack.writeToNBT(tag);
itemList.appendTag(tag);
}
}
tagCompound.setTag("Inventory", itemList);
}
@Override
public String getInvName() {
return "tco.tileentitytiny";
}
public boolean hasMaster() {
return hasMaster;
}
public boolean isMaster() {
return isMaster;
}
public void setMasterCoords(int x, int y, int z) {
masterX = x;
masterY = y;
masterZ = z;
}
public void setHasMaster(boolean bool) {
hasMaster = bool;
}
public void setIsMaster(boolean bool) {
isMaster = bool;
}
}
package asdic2mod.blocks;
import asdic2mod.AsdCore;
import asdic2mod.ec.BlockM;
import asdic2mod.ec.TileIc2Block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
public class Ic2TestBlock extends BlockM{
public Ic2TestBlock(int blockID) {
super(blockID,Material.rock);
this.setCreativeTab(AsdCore.tabasd);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon("AsdIC2mod:Testblock");
setTextureName(":Testblock");
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileIc2Block();
}
}
package asdic2mod.ec;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.block.BlockContainer;
import asdic2mod.AsdCore;
import asdic2mod.AsdCoreEC;
import asdic2mod.util.GuiHandler;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class TileIc2Block extends AsdTileMultiBlock{
@Override
public void doMultiBlockStuff() {
// Sets diamond block 6 blocks above the master
int ttt;
if (worldObj.isAirBlock(xCoord, yCoord + 6, zCoord))worldObj.setBlock(xCoord, yCoord + 6, zCoord, Block.blockGold.blockID);
}
@Override
public boolean checkMultiBlockForm() {
int i = 0;
// Scan a 3x3x3 area, starting with the bottom left corner
for (int x = xCoord - 1; x < xCoord + 2; x++)
for (int y = yCoord; y < yCoord + 3; y++)
for (int z = zCoord - 1; z < zCoord + 2; z++) {
TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
// Make sure tile isn't null, is an instance of the same Tile, and isn't already a part of a multiblock (if ours is already part of one)
if (tile != null && (tile instanceof TileIc2Block)) {
if (this.isMaster()) {
if (((TileIc2Block)tile).hasMaster())
i++;
} else if (!((TileIc2Block)tile).hasMaster())
i++;
}
}
// check if there are 26 blocks present ((3*3*3) - 1) and check that center block is empty
return i > 25 && worldObj.isAirBlock(xCoord, yCoord + 1, zCoord);
}
@Override
public void setupStructure() {
for (int x = xCoord - 1; x < xCoord + 2; x++)
for (int y = yCoord; y < yCoord + 3; y++)
for (int z = zCoord - 1; z < zCoord + 2; z++) {
TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
// Check if block is bottom center block
boolean master = (x == xCoord && y == yCoord && z == zCoord);
if (tile != null && (tile instanceof TileIc2Block)) {
((TileIc2Block) tile).setMasterCoords(xCoord, yCoord, zCoord);
((TileIc2Block) tile).setHasMaster(true);
((TileIc2Block) tile).setIsMaster(master);
}
}
}
@Override
public void resetStructure() {
for (int x = xCoord - 1; x < xCoord + 2; x++)
for (int y = yCoord; y < yCoord + 3; y++)
for (int z = zCoord - 1; z < zCoord + 2; z++) {
TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
if (tile != null && (tile instanceof AsdTileMultiBlock))
((AsdTileMultiBlock) tile).reset();
}
}
@Override
public World getWorld() {
// TODO Auto-generated method stub
return null;
}
@Override
public void writePacketData(DataOutputStream var1) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void readPacketData(DataInputStream var1) throws IOException {
// TODO Auto-generated method stub
}
@Override
public String getOwner() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isInvNameLocalized() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
// TODO Auto-generated method stub
return false;
}
}
package asdic2mod.ec;
import asdic2mod.AsdCore;
import asdic2mod.AsdCoreEC;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockM extends BlockContainer {
private static Material material;
public BlockM(int blockID, Material rock) {
super(blockID, Material.rock);
this.setResistance(4.5F);
this.setHardness(2.0F);
this.setStepSound(soundStoneFootstep);
this.setTickRandomly(true);
this.setCreativeTab(AsdCore.tabasd);
}
public void onNeighborBlockChange(World world, int x, int y, int z, int block) {
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile != null && tile instanceof AsdTileMultiBlock) {
AsdTileMultiBlock multiBlock = (AsdTileMultiBlock) tile;
if (multiBlock.hasMaster()) {
if (multiBlock.isMaster()) {
if (!multiBlock.checkMultiBlockForm())
multiBlock.resetStructure();
} else {
if (!multiBlock.checkForMaster()) {
multiBlock.reset();
world.markBlockForUpdate(x, y, z);
}
}
}
}
super.onNeighborBlockChange(world, x, y, z, block);
}
@Override
public TileEntity createNewTileEntity(World world) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int metadata, float what, float these, float are) {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking()) {
return false;
}
//code to open gui explained later
player.openGui(AsdCoreEC.instance, 0, world, x, y, z);
return true;
}
}
Учебник по установке форджа 1.7 листайAsd1995sse написал(а):Если исходники майна и форджа не видны, то что делать? Я про 1.7
coblestonedamage = new CoblestoneDamage(здесь?).setBlockName("coblestonedamage").setCreativeTab(tabasd);
GameRegistry.registerBlock(coblestonedamage, "coblestonedamage");
GameRegistry.addBiome(биом);