Jump to content

[1.8]exactly What needs a item that break blocks to work on server ?


perromercenary00

Recommended Posts

good days

 

i have  a few months working on a mod, one day i decide to test it in a server and it crash  i have like 180 items betwin tools and blocks i get stressed and shit all and begin again

 

at this point i have a lot of items  3 fireguns and two bows that work well on server and a package system and a keybind system all of this works well on the server and in the client 

 

then i have this

 

this item breaks blocks has diferent modes  from 1 block to 4 blocks can be upgrade whith efficence  to break wider tunnels and uses suspension of redstone for fuel.

this is video is from the normal minecraft client and here it works perfect but when try to use the item in server it does absolutly nothing

the last time i have this same trouble was becose i forgot to override the methods in the items,  this is not the case everithing is overrided

 

jumm

 

any idea ?

what else could cause than an item works on client but not in server

Link to comment
Share on other sites

ñaaa

 

well in this moment this item is no using the keybind or the packages, whi it i have 3 guns and two bows that make use of key bind and packages  to change shoot mode an onload the clip and all o this work in server

is this one drill and there is a shears the comon factor is than this items breaks blocks  the others just spawn entityes

 

i dont wana reddo the drill coze it take like two days of coding

 

 

Link to comment
Share on other sites

ñaaa

 

If you won't provide code, we won't help you. We can't magically look at your item and tell what's wrong  ::)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

bueno

 

is that is a little messy long and full of coments in spanish.

 

package mercenarymod.items.herramientas;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import mercenarymod.materialesMercenarios;
import mercenarymod.Mercenary;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import mercenarymod.items.MercenaryModItems;
import mercenarymod.utilidades.registrarTextura;
import mercenarymod.utilidades.chat;
import mercenarymod.utilidades.util;


import net.minecraft.block.state.IBlockState;

public class taladroMercenario extends Item{

	public taladroMercenario(){
	String name = "taladroMercenario";
	setUnlocalizedName(Mercenary.MODID + "_" + name);
	GameRegistry.registerItem(this, name);
	setCreativeTab(Mercenary.herramientas);
	this.setHasSubtypes(true);
	this.maxStackSize = 1;
	this.setMaxDamage(4000);
	;}
//#####################################################################################3
/*
public void onUpdate(ItemStack taladro, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {


	if (isSelected){
	boolean enUso=false;	
	EntityPlayer playerIn=	(EntityPlayer) entityIn;
	if(!worldIn.isRemote){
	if(getBooleantag(taladro, "enable")){	
	System.out.println("enable");	

	int texturajson=getInttag(taladro, "texturajson");	
	texturajson++;	
	setInttag(taladro, "texturajson",texturajson);	

	if(texturajson >= 64){
	setBooleantag(taladro, "enable",false);	
	setInttag(taladro, "texturajson",0);

	}


	}


	}


	}//is selected
			       
    }*/
//######################################################################################3	

public ModelResourceLocation getModel(ItemStack taladro, EntityPlayer playerIn, int useRemaining){

	ModelResourceLocation modelresourcelocation= new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario", "inventory");





	int tick;
	tick=(1000-useRemaining);
	if (tick>999){tick=0;}

	//tick=tick/2;

	int ciclo=8;
    int texturajson=0;		




	boolean shoot= getBooleantag(taladro, "shoot");
    boolean reload= getBooleantag(taladro, "reload");
    boolean unload= getBooleantag(taladro, "unload");
    boolean enable= getBooleantag(taladro, "enable");
    int tipocargador=getInttag(taladro, "tipocargador");
    int tipoperforacion=getInttag(taladro, "tipoperforacion");
    int municion= getInttag(taladro, "municion");
    
    
    
    
    
  if (tick>0){texturajson=3;}


if(reload & (municion<=0) ){
tick=tick/2;

switch(tick){
default : texturajson=3;break;
case 1: case 2: case 3: texturajson=4;break;
case 4: case 5: case 6: texturajson=5;break;
case 7: case 8: case 9: texturajson=6;break;
case 10: case 11: case 12: texturajson=7;break;
case 13: case 14: case 15: texturajson=8;break;
case 16: case 17: case 18: texturajson=9;break;
            }
      }

if(shoot & (municion>0)){
switch(tick){
case 0: texturajson=0;break;
default : texturajson=2;break;
            }
          }

if( !shoot & !reload & (municion>0)){
switch(tick){
case 0: texturajson=0;break;
default : texturajson=1;break;
            }
          }



if(!enable){texturajson=0;}
    
  
    	switch(texturajson){
	    default : modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario", "inventory");break;
	    case   1: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_encendido", "inventory");break;
	    case   2: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_encendido2", "inventory");break;
	    case   3: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A00", "inventory");break;
	    case   4: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A01", "inventory");break;
	    case   5: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A02", "inventory");break;
	    case   6: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A03", "inventory");break;
	    case   7: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A04", "inventory");break;
	    case   8: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A05", "inventory");break;
	    case   9: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A06", "inventory");break;
	    
	                    }

	 	return  modelresourcelocation;	
	} 	



//######################################################################################3	
@Override
public ItemStack onItemRightClick(ItemStack taladro, World worldIn, EntityPlayer playerIn)
  {

	if ( !worldIn.isRemote ){
	boolean inicializado = getBooleantag(taladro, "inicializado");
	if (!inicializado){ 
		intialize(taladro, playerIn);

		chat.chatgr(playerIn, "Inicializada en onItemRightClick"); 
		              }      }


	  playerIn.setItemInUse(taladro, this.getMaxItemUseDuration(taladro));
	  
	  chat.chatm(playerIn, "onItemRightClick");
	  
	  return taladro;
  }
//####################################################################################3	
@Override
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack taladro)
 {
	 EntityPlayer playerIn = (EntityPlayer) entityLiving;
	 World worldIn =entityLiving.getEntityWorld();

		if ( !worldIn.isRemote ){
			boolean inicializado = getBooleantag(taladro, "inicializado");
			if (!inicializado){ 
				intialize(taladro, playerIn);
				setBooleantag(taladro, "inicializado",true);
				chat.chatgr(playerIn, "Inicializada en onEntitySwing"); 
				              }      }


	 if ( !worldIn.isRemote & (entityLiving.isSneaking()) ){
	 int tipoperforacion=getInttag(taladro, "tipoperforacion");

		int spell0 = EnchantmentHelper.getEfficiencyModifier(playerIn);
		int spell1 = EnchantmentHelper.getFortuneModifier(playerIn);

	 switch(spell0){	

	 case 0:{
	 switch(tipoperforacion){

	 default: setInttag(taladro, "tipoperforacion",1);chat.chatdp(playerIn, "Modo un blocke");break;

	 case 1:  setInttag(taladro, "tipoperforacion",2);chat.chatdp(playerIn, "Modo Dos blockes");break;

	 case 2:  setInttag(taladro, "tipoperforacion",3);setBooleantag(taladro, "izquierda",false);
	 chat.chatdp(playerIn, "Modo Cuatro blockes izquierda");break;

	 case 3:  setInttag(taladro, "tipoperforacion",4);setBooleantag(taladro, "izquierda",true);
	 chat.chatdp(playerIn, "Modo Cuatro blockes derecha");break;

	 //case 4:  setInttag(taladro, "tipoperforacion",5);chat.chatdp(playerIn, "Modo Nueve blockes");break;
	 }};break;

	 case 1:{
		 switch(tipoperforacion){

		 default: setInttag(taladro, "tipoperforacion",1);chat.chatdp(playerIn, "Modo un blocke");break;

		 case 1:  setInttag(taladro, "tipoperforacion",2);chat.chatdp(playerIn, "Modo Dos blockes");break;

		 case 2:  setInttag(taladro, "tipoperforacion",3);setBooleantag(taladro, "izquierda",false);
		 chat.chatdp(playerIn, "Modo Cuatro blockes izquierda");break;

		 case 3:  setInttag(taladro, "tipoperforacion",4);setBooleantag(taladro, "izquierda",true);
		 chat.chatdp(playerIn, "Modo Cuatro blockes derecha");break;

		 case 4:  setInttag(taladro, "tipoperforacion",5);chat.chatdp(playerIn, "Modo Nueve blockes");break;
		 }};break;

	 case 2:{
		 switch(tipoperforacion){

		 default: setInttag(taladro, "tipoperforacion",1);chat.chatdp(playerIn, "Modo un blocke");break;

		 case 1:  setInttag(taladro, "tipoperforacion",2);chat.chatdp(playerIn, "Modo Dos blockes");break;

		 case 2:  setInttag(taladro, "tipoperforacion",3);setBooleantag(taladro, "izquierda",false);
		 chat.chatdp(playerIn, "Modo Cuatro blockes izquierda");break;

		 case 3:  setInttag(taladro, "tipoperforacion",4);setBooleantag(taladro, "izquierda",true);
		 chat.chatdp(playerIn, "Modo Cuatro blockes derecha");break;

		 case 4:  setInttag(taladro, "tipoperforacion",5);chat.chatdp(playerIn, "Modo Nueve blockes");break;

		 case 5:  setInttag(taladro, "tipoperforacion",6);chat.chatdp(playerIn, "Modo Venticinco blockes");break;
		 }};break;

	 case 3:{
		 switch(tipoperforacion){

		 default: setInttag(taladro, "tipoperforacion",1);chat.chatdp(playerIn, "Modo un blocke");break;

		 case 1:  setInttag(taladro, "tipoperforacion",2);chat.chatdp(playerIn, "Modo Dos blockes");break;

		 case 2:  setInttag(taladro, "tipoperforacion",3);setBooleantag(taladro, "izquierda",false);
		 chat.chatdp(playerIn, "Modo Cuatro blockes izquierda");break;

		 case 3:  setInttag(taladro, "tipoperforacion",4);setBooleantag(taladro, "izquierda",true);
		 chat.chatdp(playerIn, "Modo Cuatro blockes derecha");break;

		 case 4:  setInttag(taladro, "tipoperforacion",5);chat.chatdp(playerIn, "Modo Nueve blockes");break;

		 case 5:  setInttag(taladro, "tipoperforacion",6);chat.chatdp(playerIn, "Modo Venticinco blockes");break;

		 case 6:  setInttag(taladro, "tipoperforacion",7);chat.chatdp(playerIn, "Modo CuarentayNueve blockes");break;
		 }};break; 


	 }//switch(spell0)


	 }



     return true;
 }
//###################################################################################3

public static EnumFacing playerRotation(EntityPlayer playerIn){

 double rotation=playerIn.getRotationYawHead();

 if (rotation >= -180){;}
 if (rotation <  -180){rotation=180+(rotation+180);}

 if (rotation <=  180){;}
 if (rotation >   180){rotation=(-180)+(rotation-180);}

 //chat.chatda(playerIn, "rotation="+playerIn.getRotationYawHead() );		 
 //chat.chatr(playerIn, "rotation="+rotation );

 if ( rotation > -45 & rotation < 45 ){
	 //chat.chatr(playerIn, "=sur=" );
	 return EnumFacing.SOUTH;	 }

 if ( rotation < -135 | rotation > 135 ){
	 //chat.chatr(playerIn, "=Norte=" );
	 return EnumFacing.NORTH;}

 if ( rotation > 45 & rotation < 135 ){
	 //chat.chatr(playerIn, "=oeste=" );
	 return EnumFacing.WEST;}

 if ( rotation < -45 & rotation > -135 ){
	 //chat.chatr(playerIn, "=este=" );
	 return EnumFacing.EAST;}


 return EnumFacing.NORTH;

}

//###################################################################################3
 public static ArrayList<BlockPos> areaAfectada(World worldIn, EntityPlayer playerIn, ItemStack taladro){

	 BlockPos b=null;
	 ArrayList<BlockPos> salida = new ArrayList<BlockPos>();
	 int bx=0,by=0,bz=0;
	 int tipoperforacion=getInttag(taladro, "tipoperforacion");
	 boolean izquierda=getBooleantag(taladro, "izquierda");		 

	 MovingObjectPosition mop = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(6, 1.0F);

	 		if(mop != null)
	 		{
	 			b=	mop.getBlockPos();
	 			bx=b.getX(); 
	 			by=b.getY();	
	 			bz=b.getZ();
	 		}	
	 		EnumFacing sid=	mop.sideHit;

	 		salida.add(b);

	 switch(tipoperforacion){		

	 case 2:{


		 if ( (sid.equals(EnumFacing.UP)) ) {

			 EnumFacing lado= playerRotation(playerIn); 

			 if (lado.equals(EnumFacing.NORTH)){salida.add(b.south());}
			 if (lado.equals(EnumFacing.SOUTH)){salida.add(b.north());}
			 if (lado.equals(EnumFacing.EAST)){salida.add(b.west());}
			 if (lado.equals(EnumFacing.WEST)){salida.add(b.east());}

		 }

		 if ( (sid.equals(EnumFacing.DOWN))  ) {

			 EnumFacing lado= playerRotation(playerIn); 

			 if (lado.equals(EnumFacing.NORTH)){salida.add(b.north());}
			 if (lado.equals(EnumFacing.SOUTH)){salida.add(b.south());}
			 if (lado.equals(EnumFacing.EAST)){salida.add(b.east());}
			 if (lado.equals(EnumFacing.WEST)){salida.add(b.west());}

		 }

		 if ( (sid.equals(EnumFacing.EAST))|(sid.equals(EnumFacing.WEST))|(sid.equals(EnumFacing.NORTH))|(sid.equals(EnumFacing.SOUTH))  ) {
		 salida.add(b.down());}


	        };break;


	 case 3: case 4: { 		

	        if (sid.equals(EnumFacing.NORTH)){
	        	salida.add(b.down());
	        	if(izquierda){
	        	salida.add(b.west());	
	        	salida.add(b.west().down());	
	        	}else{
		        salida.add(b.east());	
		        salida.add(b.east().down());	
	        	}                            }

	        if (sid.equals(EnumFacing.SOUTH)){
	        	salida.add(b.down());
	        	if(izquierda){
	        	salida.add(b.east());	
	        	salida.add(b.east().down());	
	        	}else{
		        salida.add(b.west());	
		        salida.add(b.west().down());	
	        	}                            }

	        if (sid.equals(EnumFacing.EAST)){
	        	salida.add(b.down());
	        	if(izquierda){
	        	salida.add(b.north());	
	        	salida.add(b.north().down());	
	        	}else{
		        salida.add(b.south());	
		        salida.add(b.south().down());	
	        	}                            }

	        if (sid.equals(EnumFacing.WEST)){
	        	salida.add(b.down());
	        	if(izquierda){
	        	salida.add(b.south());	
	        	salida.add(b.south().down());	
	        	}else{
		        salida.add(b.north());	
		        salida.add(b.north().down());	
	        	}                            }

	        
	        	
	        	
				 if ( (sid.equals(EnumFacing.DOWN)) ) {

					 EnumFacing lado= playerRotation(playerIn); 

					 if(izquierda){
						 if (lado.equals(EnumFacing.NORTH)){ salida.add(b.north());salida.add(b.east());salida.add(b.east().north() );}
						 if (lado.equals(EnumFacing.SOUTH)){ salida.add(b.south());salida.add(b.west());salida.add(b.west().south() );}
						 if (lado.equals(EnumFacing.EAST)){  salida.add(b.east());salida.add(b.south());salida.add(b.east().south() );}
						 if (lado.equals(EnumFacing.WEST)){  salida.add(b.west());salida.add(b.north());salida.add(b.west().north() );}


					 }else{
						 if (lado.equals(EnumFacing.NORTH)){ salida.add(b.north());salida.add(b.west());salida.add(b.west().north() );}
						 if (lado.equals(EnumFacing.SOUTH)){ salida.add(b.south());salida.add(b.east());salida.add(b.east().south() );}
						 if (lado.equals(EnumFacing.EAST)){  salida.add(b.east());salida.add(b.north());salida.add(b.east().north() );}
						 if (lado.equals(EnumFacing.WEST)){  salida.add(b.west());salida.add(b.south());salida.add(b.west().south() );}
					 }

					                                   }


				 	if ( (sid.equals(EnumFacing.UP)) ) {

					 EnumFacing lado= playerRotation(playerIn); 


					 if(izquierda){//romper ala derecha
						 if (lado.equals(EnumFacing.NORTH)){ salida.add(b.south());salida.add(b.east());salida.add(b.east().south() );}
						 if (lado.equals(EnumFacing.SOUTH)){ salida.add(b.north());salida.add(b.west());salida.add(b.west().north() );}
						 if (lado.equals(EnumFacing.EAST)){  salida.add(b.west());salida.add(b.south());salida.add(b.west().south() );}
						 if (lado.equals(EnumFacing.WEST)){  salida.add(b.east());salida.add(b.north());salida.add(b.east().north() );}
						  }else{
						if (lado.equals(EnumFacing.NORTH)){ salida.add(b.south());salida.add(b.west());salida.add(b.west().south() );}
						if (lado.equals(EnumFacing.SOUTH)){ salida.add(b.north());salida.add(b.east());salida.add(b.east().north() );}
						if (lado.equals(EnumFacing.EAST)){  salida.add(b.west());salida.add(b.north());salida.add(b.west().north() );}
						if (lado.equals(EnumFacing.WEST)){  salida.add(b.east());salida.add(b.south());salida.add(b.east().south() );}
					           } }

					    		        
			        };break; //case 3: 4:
	        
	 case 5:{ 

	        if ( (sid.equals(EnumFacing.NORTH)) | (sid.equals(EnumFacing.SOUTH)) ){
	        	salida.add(b.up());
	        	salida.add(b.down());
	        	
	        	salida.add(b.west());	
	        	salida.add(b.west().down());	
	        	salida.add(b.west().up());
	        
	        	salida.add(b.east());	
	        	salida.add(b.east().down());	
	        	salida.add(b.east().up());
	                                         }


	        if ( (sid.equals(EnumFacing.EAST)) | (sid.equals(EnumFacing.WEST)) ){
	        	salida.add(b.up());
	        	salida.add(b.down());
	        	
	        	salida.add(b.north());	
	        	salida.add(b.north().down());	
	        	salida.add(b.north().up());
	        
	        	salida.add(b.south());	
	        	salida.add(b.south().down());	
	        	salida.add(b.south().up());
	                                         }

	        if ( (sid.equals(EnumFacing.UP)) | (sid.equals(EnumFacing.DOWN)) ){
	        	salida.add(b.east());
	        	salida.add(b.west());
	        	
	        	salida.add(b.north());	
	        	salida.add(b.north().east());	
	        	salida.add(b.north().west());
	        
	        	salida.add(b.south());	
	        	salida.add(b.south().east());	
	        	salida.add(b.south().west());
	                                         }			 

	                };break;//case 5:
        
	             
	        		 case 6:{  //  5x5
	 	                chat.chatdp(playerIn, "AQui");	        			 
	        			 int x=b.getX(),y=b.getY(),z=b.getZ();
	        			 int a=2;
	        			 int xmin=x-a, xmax=x+a,ymin=y-a, ymax=y+a,zmin=z-a, zmax=z+a;
	        			 BlockPos b6=b;
	        			 
	        			 if ( (sid.equals(EnumFacing.NORTH)) | (sid.equals(EnumFacing.SOUTH)) ){
	        					
	        		        	
	        		        	for (int dx=xmin ; dx<= xmax ; dx++){
	        		        	for (int dy=ymin ; dy<= ymax ; dy++){
	        		        	//for (int dz=zmin ; dz<= zmax ; dz++){
	        		        	
	        		        	b6=new BlockPos(dx,dy,z);	
	        		        	salida.add(b6);	
	        		        		
	        		        	}} }
	        		     
	        			 if ( (sid.equals(EnumFacing.EAST)) | (sid.equals(EnumFacing.WEST)) ){
	        					
	        		        	
	        		        	//for (int dx=xmin ; dx<= xmax ; dx++){
	        		        	for (int dy=ymin ; dy<= ymax ; dy++){
	        		        	for (int dz=zmin ; dz<= zmax ; dz++){
	        		        	
	        		        	b6=new BlockPos(x,dy,dz);	
	        		        	salida.add(b6);	
	        		        		
	        		        	}} }
	        		        
	        			 if ( (sid.equals(EnumFacing.UP)) | (sid.equals(EnumFacing.DOWN)) ){
	        					
	        		        	
	        		        	for (int dx=xmin ; dx<= xmax ; dx++){
	        		        	//for (int dy=ymin ; dy<= ymax ; dy++){
	        		        	for (int dz=zmin ; dz<= zmax ; dz++){
	        		        	
	        		        	b6=new BlockPos(dx,y,dz);	
	        		        	salida.add(b6);	
	        		        		
	        		        	}} }  
	        		        
	                
	        		 };break;//case 6:
	                
	                
	        		 
	        		 case 7:{  //  7x7
		 	                chat.chatdp(playerIn, "AQui");	        			 
		        			 int x=b.getX(),y=b.getY(),z=b.getZ();
		        			 int a=3;
		        			 int xmin=x-a, xmax=x+a,ymin=y-a, ymax=y+a,zmin=z-a, zmax=z+a;
		        			 BlockPos b6=b;
		        			 
		        			 if ( (sid.equals(EnumFacing.NORTH)) | (sid.equals(EnumFacing.SOUTH)) ){
		        					
		        		        	
		        		        	for (int dx=xmin ; dx<= xmax ; dx++){
		        		        	for (int dy=ymin ; dy<= ymax ; dy++){
		        		        	//for (int dz=zmin ; dz<= zmax ; dz++){
		        		        	
		        		        	b6=new BlockPos(dx,dy,z);	
		        		        	salida.add(b6);	
		        		        		
		        		        	}} }
		        		     
		        			 if ( (sid.equals(EnumFacing.EAST)) | (sid.equals(EnumFacing.WEST)) ){
		        					
		        		        	
		        		        	//for (int dx=xmin ; dx<= xmax ; dx++){
		        		        	for (int dy=ymin ; dy<= ymax ; dy++){
		        		        	for (int dz=zmin ; dz<= zmax ; dz++){
		        		        	
		        		        	b6=new BlockPos(x,dy,dz);	
		        		        	salida.add(b6);	
		        		        		
		        		        	}} }
		        		        
		        			 if ( (sid.equals(EnumFacing.UP)) | (sid.equals(EnumFacing.DOWN)) ){
		        					
		        		        	
		        		        	for (int dx=xmin ; dx<= xmax ; dx++){
		        		        	//for (int dy=ymin ; dy<= ymax ; dy++){
		        		        	for (int dz=zmin ; dz<= zmax ; dz++){
		        		        	
		        		        	b6=new BlockPos(dx,y,dz);	
		        		        	salida.add(b6);	
		        		        		
		        		        	}} }  
		        		        
		                
		        		 };break;//case 7:
		                
	        		 
	                

	                         }//switch(tipoperforacion)


	 return salida;




 }
//###################################################################################3
public static ArrayList<BlockPos> arearompible(World worldIn, EntityPlayer playerIn, ItemStack taladro,ArrayList<BlockPos> b){

	 int lb=b.size();
	 ArrayList<BlockPos> salida = new ArrayList<BlockPos>();
	 salida.clear();

	 for (int db=0 ; db < lb ; db++){

	if ( (hardenessb( worldIn,playerIn, b.get(db))) > -1){
		salida.add( b.get(db) );	                     } 

	                                }

	return salida;
} 
//#########################################################################################/
 public static void romper(World worldIn,EntityPlayer playerIn,ItemStack taladro,ArrayList<BlockPos> b) {  

 if (!worldIn.isRemote){
	 int lb=b.size();

 for (int db=0 ; db < lb ; db++){
	 worldIn.destroyBlock(b.get(db), true); 
                                }
 taladro.damageItem(1, playerIn);
                      }

 } 
//#########################################################################################/ 
 public static int[] coordenadas(World worldIn,EntityPlayer playerIn,int distancia) {  

 int bx=0;	 int by=0;	 int bz=0;

 BlockPos b=null;

 MovingObjectPosition mop = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(distancia, 1.0F);

 		if(mop != null)
 		{
 			b=	mop.getBlockPos();
 			bx=b.getX(); 
 			by=b.getY();	
 			bz=b.getZ();
 		}	
 		EnumFacing sid=	mop.sideHit;

 int [] salida=new int[5];	
 salida[0]=bx;salida[1]=by;salida[2]=bz;salida[3]=0;
 return salida;

 }
//#########################################################################################/ 
	 public static BlockPos coordenadasb(World worldIn,EntityPlayer playerIn,int distancia) {  

	 BlockPos b=null;
	 MovingObjectPosition mop = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(distancia, 1.0F);

	 		if(mop != null)
	 		{
	 			b=	mop.getBlockPos();
	 		}	
	 				 return b;

	 }

//####################################################################################3
 public static int hardenessb(World worldIn,EntityPlayer playerIn, BlockPos b){

	 IBlockState bls0=worldIn.getBlockState(b);

	 Block blk0=bls0.getBlock();
	 int hard=(int)blk0.getBlockHardness(worldIn, b);
	 Material mt = blk0.getMaterial();

	  if (mt != Material.grass & 
	     mt != Material.ground & 
	     mt != Material.clay & 
	     mt != Material.rock &
	     mt != Material.coral &
	     mt != Material.cactus &
	     mt != Material.craftedSnow &
	     mt != Material.gourd &
	     mt != Material.iron &
	     mt != Material.sand &
	     mt != Material.snow  ){hard=-1;}


 return hard;
 }

	//####################################################################################3
 public static int lamasdura(World worldIn,EntityPlayer playerIn, ArrayList<BlockPos> bl ){

	 int harder=-1;
	 int hard=-1;

		 int lb=bl.size();


	 for (int db=0 ; db < lb ; db++){
		 hard=hardenessb(worldIn,playerIn, bl.get(db));

		 if (hard>harder){harder=hard;}


	                                }
	                      

 return harder;
 }

 //####################################################################################3
 @Override
 public void onUsingTick(ItemStack taladro, EntityPlayer playerIn, int count)
 {

	 int tick;
	 tick=(1000-count);
	 int ciclo=8;

	 int ticksnesesarios=getInttag(taladro, "ticksnesesarios");
	 int municion= getInttag(taladro, "municion");
	 boolean reload = getBooleantag(taladro, "reload");
	 boolean shoot = getBooleantag(taladro, "shoot");	



	 if (tick > 0){		 
	 if (  ((tick % 4) ==0) | (tick==1) ) {		 
	 World worldIn = playerIn.getEntityWorld();
	 if ( (!worldIn.isRemote) ){



	 if ( !reload & ((tick==1 ) | ((tick%4)==0)) ){
		 //chat.chatm(playerIn, "tick="+tick);

		 if (shoot){worldIn.playSoundAtEntity(playerIn, "modmercenario:taladromercenario03", 0.6F, 0.6F );}
		 else{
		 if (municion>0){	 
			 worldIn.playSoundAtEntity(playerIn, "modmercenario:taladromercenario01", 1.1F, 1.1F );
			 }          }

		       	                          } 


	 if ( reload & (tick==1 ) ){
		 //chat.chatm(playerIn, "reload tick="+tick);
		 worldIn.playSoundAtEntity(playerIn, "modmercenario:suspencionderedstoneActivada", 0.6F, 0.6F );
		 }


	 }}}


	 if ( ((municion==0) | (tick>4)) & ((tick >= ticksnesesarios) & (!reload)) )
	 {playerIn.stopUsingItem();}



 }
//####################################################################################3	 
 @Override
 public void onPlayerStoppedUsing(ItemStack taladro, World worldIn, EntityPlayer playerIn, int timeLeft)
 {


	 int tick;
	 tick=1000-timeLeft;
	 int ciclo=8;

	 if(!worldIn.isRemote){

		 boolean unload = getBooleantag(taladro, "unload");
		 boolean shoot = getBooleantag(taladro, "shoot");
		 boolean reload = getBooleantag(taladro, "reload");
		 boolean enable = getBooleantag(taladro, "enable");
		 boolean habilitado=true;
		 int municion= getInttag(taladro, "municion");
		 int municionmaxima = getInttag(taladro, "municionmaxima");
		 int ticksnesesarios= getInttag(taladro, "ticksnesesarios");
		 int tipoperforacion=getInttag(taladro, "tipoperforacion");

		 ArrayList<BlockPos> bl = new ArrayList<BlockPos>();bl.clear();
		 ArrayList<BlockPos> bl0 = new ArrayList<BlockPos>();bl0.clear();
		 bl=areaAfectada(worldIn, playerIn, taladro);
		 BlockPos b=bl.get(0);

		 chat.chatm(playerIn, "shoot"+shoot );
		 chat.chatm(playerIn, "reload"+ reload);
		 chat.chatm(playerIn, "enable"+enable );
		 chat.chatm(playerIn, "municion"+municion );
		 chat.chatm(playerIn, "municionmaxima"+municionmaxima );
		 chat.chatm(playerIn, "ticksnesesarios"+ticksnesesarios );
		 chat.chatm(playerIn, "tipoperforacion"+ tipoperforacion);
		 //chat.chatm(playerIn, ""+ );



		 //recargar
		 if (habilitado & reload & (tick>=30)){
			 if( playerIn.inventory.hasItem(MercenaryModItems.suspensionderedstoneActivada) )
			 {
//Municion Maxima Bug				
			setInttag(taladro, "municion", 256 );//municionmaxima

			playerIn.inventory.consumeInventoryItem(MercenaryModItems.suspensionderedstoneActivada);	 
			playerIn.inventory.addItemStackToInventory(new ItemStack(Items.glass_bottle,1,0) );

			setBooleantag(taladro, "reload",false);
			habilitado=false;	 
			 }
		 }


		 //mandar a recargar si esta vacia
		 if (habilitado & !reload & !shoot & (municion<=0) ){
			 if( playerIn.inventory.hasItem(MercenaryModItems.suspensionderedstoneActivada) )
			 {
			setBooleantag(taladro, "reload",true);
			setBooleantag(taladro, "enable",true);
			habilitado=false;	 
			 }
			 else
			 {chat.chatm(playerIn, "No hay suspencion de redstone activada para recargar este taladro");}	 
			 	 }


		 //mandar a romper
		 if (habilitado & !reload & !shoot & (municion>0) ){

			 if ( (hardenessb(worldIn,playerIn, b)) > (-1) ){


				 bl0=arearompible(worldIn, playerIn, taladro,bl);
				 int lamasdura=lamasdura(worldIn, playerIn, bl0 );
				 int lamasdura0=lamasdura;					 
				 int [] bb = new int[5];
				 bb[0]=b.getX();
				 bb[1]=b.getY();
				 bb[2]=b.getZ();

				 if (lamasdura > 4 & lamasdura < 21 ){lamasdura0=lamasdura*2;}

				 setInttag(taladro, "ticksnesesarios", (lamasdura0*2) );

				 setInttag(taladro, "dureza", lamasdura);
				 setBooleantag(taladro, "shoot", enable);
				 setBooleantag(taladro, "enable",true);
				 setBooleantag(taladro, "reload",false);
				 setBooleantag(taladro, "unload",false);
				 setIntArraytag(taladro, "coordenadas", bb);
				 habilitado=false; 
			                                          }    }

		 //romper
		 if (habilitado & !reload & shoot & (municion>0) & (tick>=ticksnesesarios) ){
		 //prueba

			 int [] coor0 = getIntArraytag(taladro, "coordenadas");

			 if(coor0[0]==b.getX()){
			 if(coor0[1]==b.getY()){
			 if(coor0[2]==b.getZ()){

			 bl0=arearompible(worldIn, playerIn, taladro,bl);
			 romper(worldIn, playerIn, taladro, bl0);
			 int dureza=(getInttag(taladro, "dureza") /4 )+2 ;
			 municion=municion-dureza;


			 }}}


		 setBooleantag(taladro, "shoot", false);
		 setBooleantag(taladro, "enable",true);
		 setBooleantag(taladro, "reload",false);
		 setBooleantag(taladro, "unload",false);
		 setInttag(taladro, "municion", municion);
		 //romper(worldIn, playerIn,taladro, bl);
		 habilitado=false; 	 
		 }


		 if (habilitado){
			 setBooleantag(taladro, "shoot", false);
			 setBooleantag(taladro, "enable",true);
			 setBooleantag(taladro, "reload",false);
			 setBooleantag(taladro, "unload",false);
			 setInttag(taladro, "ticksnesesarios", 0 );
			 setInttag(taladro, "dureza", -1);
			  
		                }


	 }//is ! remote



 }
//########################################################################3
  
//########################################################################3	 
 @Override
 public ItemStack onItemUseFinish(ItemStack taladro, World worldIn, EntityPlayer playerIn)
 {

	 if(!worldIn.isRemote){

		 setBooleantag(taladro, "shoot", false);
		 setBooleantag(taladro, "enable",true);
		 setBooleantag(taladro, "reload",false);
		 setBooleantag(taladro, "unload",false);


	         }//is ! remote
      return taladro;
 }
//########################################################################3
 @Override
 public int getMaxItemUseDuration(ItemStack taladro)
 {
     return 1000;
 }

 @Override
 public EnumAction getItemUseAction(ItemStack taladro)
 {

     return EnumAction.NONE;
 }





//#########################################################################3 

public static void intialize(ItemStack taladro, EntityPlayer playerIn){

	//System.out.println("#\n#\n#\n Incializacion");

	int mm=0;	int tp=0;
	switch(taladro.getMetadata()){
	default: mm=0;break;
	case 0: case 1: case 2: mm=20;tp=1;break;
	case 3: case 4: case 5: mm=32;tp=2;break;
	case 6: case 7: case 8: mm=128;tp=3;break;
	                           }

	int m=0;
	switch(taladro.getMetadata()){
	default: m=0;break;
	case 0: case 3: case 6: m=0;break;
	case 1: case 4: case 7: m=mm/2;break;
	case 2: case 5: case 8: m=mm;break;
	                           }

	int [] array = new int[5];
	array[0]=0;array[1]=0;array[2]=0;array[3]=0;

	setInttag(taladro, "texturajson", 0);
	setInttag(taladro, "municion", 0);
	setInttag(taladro, "municionmaxima", 256);
	setInttag(taladro, "ticksnesesarios", 0);
	setInttag(taladro, "tipomunicion", 0);
	setInttag(taladro, "dureza", 0);

	setInttag(taladro, "tipoperforacion", 1);
	setIntArraytag(taladro,"coordenadas",array);

	setBooleantag(taladro, "izquierda",false);
	setBooleantag(taladro, "reload", false);
	setBooleantag(taladro, "shoot", false);
	setBooleantag(taladro, "unload", false);
	setFloattag(taladro, "strength", 0.0F);
	setBooleantag(taladro, "enable", true);
	setBooleantag(taladro, "inicializado", true);


}

//#########################################################################3
public static float getFloattag(ItemStack item, String tag){	

	NBTTagCompound etiquetas = item.getTagCompound();
	if (etiquetas == null){ 
		etiquetas = new NBTTagCompound();
		item.setTagCompound(etiquetas);
		return 999.9F;
	                      }

	float ex=etiquetas.getFloat(tag); 
	return ex;

}

//#########################################################################3

public static void setFloattag(ItemStack item, String tag, float value){


	NBTTagCompound etiquetas = item.getTagCompound();
	if (etiquetas == null){ 
	etiquetas = new NBTTagCompound();
	                      }

	etiquetas.setFloat(tag, value);
	item.setTagCompound(etiquetas);

}

//#########################################################################3

public static int[] getIntArraytag(ItemStack item, String tag){	

	int[] array = new int[5];

		NBTTagCompound etiquetas = item.getTagCompound();
		if (etiquetas == null){ 
			etiquetas = new NBTTagCompound();
			item.setTagCompound(etiquetas);
			array[0]=9999;
			return array;
		                      }

		array=etiquetas.getIntArray(tag); 
		return array;

}

//#########################################################################3

public static void setIntArraytag(ItemStack item, String tag, int[] value){

	NBTTagCompound etiquetas = item.getTagCompound();
	if (etiquetas == null){ 
	etiquetas = new NBTTagCompound();
	                      }

	etiquetas.setIntArray(tag, value);
	item.setTagCompound(etiquetas);

}



//#########################################################################3

public static int getInttag(ItemStack item, String tag){	

		NBTTagCompound etiquetas = item.getTagCompound();
		if (etiquetas == null){ 
			etiquetas = new NBTTagCompound();
			item.setTagCompound(etiquetas);
			return 9999;
		                      }

		int ex=etiquetas.getInteger(tag); 
		return ex;

}

//#########################################################################3

public static void setInttag(ItemStack item, String tag, int value){

	NBTTagCompound etiquetas = item.getTagCompound();
	if (etiquetas == null){ 
	etiquetas = new NBTTagCompound();
	                      }

	etiquetas.setInteger(tag, value);
	item.setTagCompound(etiquetas);

}
//#########################################################################3

	public static Boolean getBooleantag(ItemStack item, String tag){	

		NBTTagCompound etiquetas = item.getTagCompound();
		if (etiquetas == null){ 
                etiquetas = new NBTTagCompound();
			item.setTagCompound(etiquetas);
			return false;
		                      }

		boolean ex=etiquetas.getBoolean(tag); 
	    
		return ex;

}

//#########################################################################3

	public static void setBooleantag(ItemStack item, String tag, boolean value){


		NBTTagCompound etiquetas = item.getTagCompound();
		if (etiquetas == null){ 
			etiquetas = item.getTagCompound();
		                      }

		etiquetas.setBoolean(tag, value);
		item.setTagCompound(etiquetas);

}	
//#########################################################################3

public int getItemEnchantability()
{
    return 1;
}
    
//#########################################################################3	
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack taladro, EntityPlayer playerIn, List list, boolean aBoolean)
{


	int municion =getInttag(taladro, "municion");		
	if((municion>9998)||(municion<0)){  
	intialize(taladro, playerIn);       }


	String lore="RedStone="+municion;	
	String lore0="";
	String lore1="Uses solution of redstone activated";
	String lore2="Hold LeftShift + LeftClick to Change hole size";


	//getInttag(taladro, "tipocargador");taladro.getMetadata()
	switch(getInttag(taladro, "tipoperforacion")){
	case 1: lore0="current mode one Block";break;
	case 2: lore0="current mode two Blocks";break;
	case 3: lore0="current mode four Blocks left";break;
	case 4: lore0="current mode four Blocks Rigth";break;
	case 5: lore0="current mode nine  Blocks";break;
	case 6: lore0="current mode twentyFive Blocks";break;
	case 7: lore0="current mode FourtyNine Blocks";break;
	}
	  list.add(lore);
      list.add(lore0);
      list.add(lore1);
      list.add(lore2);
   
}    
//#########################################################################3   

}
[!code]

i have a little trouble whit something i call switch animation to try and minimize that bug  i set mi code to write nbttags only in onstop using, http://www.minecraftforge.net/forum/index.php/topic,28710.msg148126.html#msg148126 

this code check if there is redstone in the drill but the name of nbtag is called internaly "municion"
the method to break blocks is called romper() //line646 and only is called when (!worldIn.isremote) and i belibe the trouble has to be whith thath

Link to comment
Share on other sites

First up, please clean up your code. The indentation is all over the place.

 

Then, you reference Minecraft inside your areaAfectada method, which will crash a server in an instant when called! Use the player parameter for your rayTrace instead.

The rayTrace method is client-side, too.

So copy the method in your item, add an entity parameter to it and replace every reference of "this" with that entity parameter.

The getPosition called in rayTrace is client-only as well, so copy that and add that entity parameter, too.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I create my mod pack,yesterday my mod pack is fine but i add one mod and error. I'm delete this mmod but minecraft is still stop on CONFIG_LOAD then I tried to delete config and restart it but again. If you can pleace help me. https://imgur.com/ngZBzuv
    • game crashes before even opening (log:https://mclo.gs/M8xvX7c)
    • I have created a custom entity that extends "TamableAnimal", but I am wanting to have it spawn in the ocean. I have it spawning right now, but it spawns way too frequently even with weight set to 1. I am guessing it is because it is rolling in the spawn pool of land animals since TameableAnimal extends Animal and is different than WaterAnimal, and since no land animals spawn in the ocean it just fills every inch up with my custom entity. I have followed basic tutorials for spawning entities with Forge, but I feel like I am missing something about how to change what spawn pool this custom entity ends up in. Is it possible to change that or do I need to refactor it to be based off of WaterAnimal to get those spawn? My biome modifier JSON file: { "type": "forge:add_spawns", "biomes": "#minecraft:is_ocean", "spawners": { "type": "darwinsmysticalmounts:water_animal", "weight": 20, "minCount": 1, "maxCount": 1 } } My client event: event.register(ModEntityTypes.WATER_ANIMAL.get(), SpawnPlacements.Type.NO_RESTRICTIONS, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, WaterWyvernEntity::checkCustomWaterAnimalSpawnRules, SpawnPlacementRegisterEvent.Operation.REPLACE); And the actual custom spawn rule that makes it spawn in the water: public static boolean checkCustomWaterAnimalSpawnRules(EntityType<WaterAnimalEntity> pAnimal, LevelAccessor pLevel, MobSpawnType pSpawnType, BlockPos pPos, RandomSource pRandom) { return pPos.getY() > pLevel.getSeaLevel() - 16 && pLevel.getFluidState(pPos.below()).is(FluidTags.WATER); }  
    • Starting today, I am unable to load my modded minecraft world. Forge crash log initially said it was a specific mod called Doggy Talents, which I disabled. Then it blamed JEI, and when that was disabled it blamed another mod so I assume it's something more than a specific mod. Minecraft launcher log claims "Exit Code 1". Nothing had changed since last night when it was working fine Forge Log: https://pastebin.com/S1GiBGVJ Client Log: https://pastebin.com/aLwuGUNL  
    • I am using AMD, yes. I downloaded the website's drivers and am still having the issue. I also used the Cleanup Utility just in case. 
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.