Jump to content

Xerus

Members
  • Posts

    35
  • Joined

  • Last visited

Posts posted by Xerus

  1. I have a block with a jsn file. The texture is working fine but the breaking particles are this purple-black stuff, s not working. This is my json file:

    {
        "parent": "block/cube_all",
        "textures": {       
            "down": "simpleautomation:blocks/farmerflat",
            "up":   "simpleautomation:blocks/farmerflat",
            "north":"simpleautomation:blocks/farmer",
            "south":"simpleautomation:blocks/farmer",
            "west": "simpleautomation:blocks/farmer",
            "east": "simpleautomation:blocks/farmer"
        }
    }

  2. Whenever I try to download something from the Marketplace, I get this error:

    Problems occurred while performing provisioning operation: 
    java.lang.IllegalArgumentException: Profile id _SELF_ is not registered.
    at org.eclipse.equinox.internal.p2.director.ProfileChangeRequest.createByProfileId(ProfileChangeRequest.java:46)
    at org.eclipse.equinox.p2.operations.InstallOperation.computeProfileChangeRequest(InstallOperation.java:74)
    at org.eclipse.equinox.p2.operations.ProfileChangeOperation.makeResolveJob(ProfileChangeOperation.java:165)
    at org.eclipse.equinox.p2.operations.ProfileChangeOperation.resolveModal(ProfileChangeOperation.java:113)
    at org.eclipse.epp.internal.mpc.ui.operations.ProfileChangeOperationComputer.resolveModal(ProfileChangeOperationComputer.java:378)
    at org.eclipse.epp.internal.mpc.ui.operations.ProfileChangeOperationComputer.resolve(ProfileChangeOperationComputer.java:367)
    at org.eclipse.epp.internal.mpc.ui.operations.ProfileChangeOperationComputer.resolveInstall(ProfileChangeOperationComputer.java:279)
    at org.eclipse.epp.internal.mpc.ui.operations.ProfileChangeOperationComputer.run(ProfileChangeOperationComputer.java:177)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
    

  3. I am trying to save the UUID of a player to the NBT Data of a TileEntity, and it writes it(I even checked it with NBTExplorer), but it doesn't load it on startup of the world. All other NBT Data loads in correctly.

    My Tileentity

        public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
            super.writeToNBT(nbt);
            if(!name.equals("bulkcore")) writeItems(nbt);
            writeKeys(nbt);
    return nbt;
        }
    void writeKeys(NBTTagCompound nbt){
            if(name!="bulkcore") writeItems(nbt);
            if(owner!=null) nbt.setUniqueId("owner",owner);
            nbt.setBoolean("locked",locked);
            System.out.println(nbt.getUniqueId("owner"));
            if (this.hasCustomName()) nbt.setString("CustomName", this.getCustomName());
            for(int i=0;i<keys.length;i++){
            	nbt.setInteger(keys[i],this.getField(i));
            }
    }
        public void readFromNBT(NBTTagCompound nbt) {
            super.readFromNBT(nbt);
            if(nbt.hasKey("owner")){
            	this.owner=nbt.getUniqueId("owner");
            if(nbt.hasKey("locked"))
            	this.locked=nbt.getBoolean("locked");
            }
            if(nbt.hasKey("CustomName")) this.setCustomName(nbt.getString("CustomName"));
            for(int i=0;i<keys.length;i++){
            	String key=keys[i];
                if(nbt.hasKey(key)) this.setField(i,nbt.getInteger(key));
            }
            NBTTagList list = nbt.getTagList("Items", 10);
            for (int i = 0; i < list.tagCount(); ++i) {
                NBTTagCompound stackTag = list.getCompoundTagAt(i);
                int slot = stackTag.getByte("Slot") & 255;
                this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag));
            }
        }

  4. I made a scrollable container via handleMouseInput(), but the problem is, that the Server container doesnt know that I have scrolled, sending the wrong inventoryItemstacks to the client Container, creating Ghost Stacks. Now I tried to make it via a SimpleNetworkWrapper and followed Diesiebens tutorial but the Server always receives an EmptyByteBuf...

     

    Gui:

    	private int currentScroll;
    @Override
    public void handleMouseInput() throws IOException {
            super.handleMouseInput();
            int i = Mouse.getEventDWheel();
            //int m = Mouse.getEventButton();
            if(i!=0&&this.needsScrollBars())
                scroll(i);
    }
    
    private void scroll(int wheel){
            wheel=wheel>0?1:-1;
            currentScroll=util.cap(currentScroll-wheel,0,terows()-5);
            container().scrollTo(currentScroll);
    	main.network.sendToServer(new Message(currentScroll));
    }

     

    Container:

        int scrolled=0;
    public void scrollTo(int scroll) {
    	scrolled=scroll;
            for (int y=0;y<5;++y) {
                for (int x=0;x<9;++x) {
                    this.addSlotToContainer(new Slot(te,x+(y+scroll)*9,8+x*18,18+y*18),x+y*9);
                }
            }
    }
    
    private void addSlotToContainer(Slot slot,int pos){
    	slot.slotNumber=pos;
            this.inventorySlots.set(pos,slot);
            this.inventoryItemStacks.set(pos,(ItemStack)null);
    }

     

    Message:

    public class Message implements IMessage {
    
    private int scroll;
    
    public Message(){
    }
    
    public Message(int scroll){
    	this.scroll=scroll;
    }
    
    @Override
    public void fromBytes(ByteBuf buf) {
    	if(!(buf instanceof EmptyByteBuf))
    		scroll=buf.getInt(0);
    	//scroll=Integer.getInteger(ByteBufUtils.readUTF8String(buf));
    }
    
    @Override
    public void toBytes(ByteBuf buf) {
    	buf.setInt(0,scroll);
    	//ByteBufUtils.writeUTF8String(buf,Integer.toString(scroll));
    }
    
    public static class Handler implements IMessageHandler<Message, IMessage>{
    	@Override
    	public IMessage onMessage(final Message message, MessageContext ctx) {
    		IThreadListener main=(WorldServer)ctx.getServerHandler().playerEntity.worldObj;
    		final Container c=ctx.getServerHandler().playerEntity.openContainer;
    		if(c!=null && c instanceof BulkContainer)
    		main.addScheduledTask(new Runnable(){
    			public void run() {
    				//((BulkContainer)c).scrollTo(message.scroll);
    			}
    		});
    		return null;
    	}
    
    }
    
    }

  5. yes i am

    just for completeness my gui class:

    public class FarmerGui extends BaseGui {
    
        public FarmerGui(IInventory playerInv, TEInventory te) {
        	super(new FarmerContainer(playerInv, te), playerInv, te);
        }
    
        @Override
        protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
            drawBackgroundImage("farmer");
            // fuel blueprint
        if(te.getStackInSlot(0)==null)
        	this.drawRect(26, 45, 176, 0, 16, 16);
        // seeds blueprint
            for(int i=1;i-1<te.getField(te.getFieldCount()-1);i++)
            	if(te.getStackInSlot(i)==null)
            		this.drawRect(44+18*i, 45, 176, 16, 16, 16);
            // progress bar
            int progress=te.getField(0)>0?12-(te.getField(0)*12/te.getField(1)):14;
            this.drawRect(26, 28+progress, 176, 32+progress, 14, 14-progress);
        }
        
        @Override
        protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
        	super.drawGuiContainerForegroundLayer(mouseX, mouseY);
        	// temporary debug output
        	drawString("Fuel: "+te.getField(0)+"/"+te.getField(1), 2, 2);
        }
        
    }

  6. Here you go:

    public class FarmerTE extends TEInventory implements ITickable,ISidedInventory {
        
    int fuel;
        int lastfuel;
        int yoffset;
        private static int rowslots=5;
    
        public FarmerTE() {
            super("farmer",rowslots*2+1,new String[]{"fuel","lastfuel","yoffset"});
            fuel=0;
            lastfuel=1;
            yoffset=-1;
        }
    
    private int delay=2;
    @Override
        public void update(){
    	if(worldObj.isRemote)
    		return;
    	if(delay>0){
    		delay--;
    		return;
    	}
    	delay=5;
    	BlockPos position=nextpos();
    	Block b=util.blockat(worldObj,position);
    	if(b!=null){
    		// entferne hohes Gras
    		if(util.blockat(worldObj, position.up()).equals(Blocks.TALLGRASS)) worldObj.setBlockState(position.up(),Blocks.AIR.getDefaultState());
    		// erde zu farmland
    		if((b.equals(Blocks.DIRT)||b.equals(Blocks.GRASS))&&util.blockat(worldObj, position.up()).equals(Blocks.AIR)&&useFuel()){
    			worldObj.playSound(null, position, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
    			if(!worldObj.isRemote) worldObj.setBlockState(position, Blocks.FARMLAND.getDefaultState(), 11);
    		}
    		// pflanzen/ernten
    		Block s=util.blockat(worldObj,position.up());
    		if(s.equals(Blocks.AIR)){
    			plant(position);
    		} else if(s instanceof BlockCrops){
    			if(((BlockCrops)s).isMaxAge(worldObj.getBlockState(position.up()))&&useFuel()) harvest(position,s);
    		} else if(s instanceof BlockNetherWart){
    			if(worldObj.getBlockState(position.up()).getValue(BlockNetherWart.AGE).intValue()>=3&&useFuel()) harvest(position,s);
    		}
    	}
        }
    
    private void plant(BlockPos position){
    	for(int slot=1;slot<rowslots+1;slot++){
    		ItemStack stack=this.getStackInSlot(slot);
    		if(stack!=null&&isplantable(stack)){
    			IPlantable item=(IPlantable)stack.getItem();		if(util.blockat(worldObj,position).canSustainPlant(worldObj.getBlockState(position),worldObj,position,EnumFacing.UP,item)&&useFuel()){
    			    worldObj.setBlockState(position.up(),item.getPlant(null, null));
    		    	decrStackSize(slot,1);
    		    	return;
    			}
    		}
    	}
    }
    
    private void harvest(BlockPos position,Block plant){
    	java.util.List<ItemStack> items=plant.getDrops(worldObj, position.up(), worldObj.getBlockState(position.up()), 0);
            for(ItemStack stack : items){
            	int start=rowslots+1;
            	if(isplantable(stack))
            		start=1;
            	for(int slot=start;slot<getSizeInventory();slot++){
            		ItemStack content=getStackInSlot(slot);
            		if(content==null){
            			setInventorySlotContents(slot,stack);
            			break;
            		} else if(content.getItem().equals(stack.getItem())){
            			if(content.stackSize+stack.stackSize<=64){
            				content.stackSize+=stack.stackSize;
            				setInventorySlotContents(slot,content);
            				break;
            			} else {
            				stack.stackSize-=64-content.stackSize;
            				content.stackSize=64;
            				setInventorySlotContents(slot,content);
            			}
            		}
            	}
            }
        	worldObj.setBlockToAir(position.up());
        	plant(position);
    }
    
    private boolean isplantable(ItemStack stack){
    	return stack.getItem() instanceof IPlantable;
    }
    
    private boolean useFuel(){
    	int fuelPerOperation=50;
    	if(fuel<fuelPerOperation){
    		if(getStackInSlot(0)!=null&&TileEntityFurnace.isItemFuel(getStackInSlot(0))){
    			lastfuel=TileEntityFurnace.getItemBurnTime(getStackInSlot(0));
    			fuel+=lastfuel;
    			decrStackSize(0,1);
    		}
    	}
    	if(fuel>=fuelPerOperation){
    		fuel-=fuelPerOperation;
    		return true;
    	}
    	return false;
    }
    
    private int[][] get=new int[][]{{-1,-1,-1,0,1,1,1,0},{-1,0,1,1,1,0,-1,-1}};
    private int currentblock=0;
    private BlockPos nextpos(){
    	if(currentblock==7) currentblock=0;
    	else currentblock++;
    	return pos.add(get[0][currentblock],0-yoffset,get[1][currentblock]);
    }
    
    @Override
    public boolean isItemValidForSlot(int index, ItemStack stack) {
    	if(index==0&&TileEntityFurnace.isItemFuel(stack))
    		return true;
    	if(index>0&&index<rowslots+1&&isplantable(stack))
    		return true;
    	return false;
    }
    
    @Override
    public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) {
    	return isItemValidForSlot(index, stack);
    }
    @Override
    public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
    	if(index>rowslots)
    		return true;
    	return false;
    }
    
    @Override
    public int[] getSlotsForFace(EnumFacing side) {
    	return new int[]{0,1,2,3,4,5,6,7,8,9,10};
    }
    
    @Override
    public int getField(int id) {
    	switch (id){
    	case 0: return this.fuel;
    	case 1: return this.lastfuel;
    	case 2: return this.yoffset;
    	case 3: return this.rowslots;
    	}
    	throw new RuntimeException("field "+id+" not found");
    }
    @Override
    public void setField(int id, int value) {
    	switch (id){
    	case 0: fuel=value;
    	case 1: lastfuel=value;
    	case 2: yoffset=value;
    	}
    }
    
    @Override
    public int getFieldCount() {
    	return 4;
    }
    
    }

  7. apart from the constructor, yes

    if you want it:

     

    private IInventory te;
    
        public FarmerContainer(IInventory playerInv, IInventory te) {
            this.te = te;
            //Farmer-Inventar
            this.addSlotToContainer(new CustomSlot(te, 0, 26, 45));
            int xslots=te.getField(te.getFieldCount()-1);
            for (int y = 0; y < 2; ++y) {
                for (int x = 0; x < xslots; ++x) {
                    this.addSlotToContainer(new CustomSlot(te, x + y * xslots + 1, 62 + x * 18, 45 - y * 21));
                }
            }
            //Player-Inventar
            for (int y = 0; y < 3; ++y) {
                for (int x = 0; x < 9; ++x) {
                    this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
                }
            }
            for (int x = 0; x < 9; ++x) {
                this.addSlotToContainer(new Slot(playerInv, x, 8 + x * 18, 142));
            }
        }

     

    nothing fancy

  8. it is actually this but i thought it is unnecessary:

     

    @Override
    public int getField(int id) {
    	switch (id){
    	case 0: return this.fuel;
    	case 1: return this.lastfuel;
    	case 2: return this.yoffset;
    	case 3: return this.actualslots;
    	}
    	return 0;
    }
    @Override
    public void setField(int id, int value) {
    	switch (id){
    	case 0: fuel=value;
    	case 1: lastfuel=value;
    	case 2: yoffset=value;
    	}
    }
    
    @Override
    public int getFieldCount() {
    	return 4;
    }

     

  9. Ok well now I implemented this into my container:

     

    private int fuel;
    private int lastfuelvalue;
        public void detectAndSendChanges(){
            super.detectAndSendChanges();
            for (int i = 0; i<this.listeners.size(); ++i) {
                IContainerListener listener = (IContainerListener)this.listeners.get(i);
                if (this.fuel!=this.te.getField(0)){
                	listener.sendProgressBarUpdate(this, 0, this.te.getField(0));
                }
                if (this.lastfuelvalue!=this.te.getField(1)){
                	listener.sendProgressBarUpdate(this, 1, this.te.getField(1));
                }
            }
            this.fuel=this.te.getField(0);
            this.lastfuelvalue=this.te.getField(1);
        }
        @SideOnly(Side.CLIENT)
        public void updateProgressBar(int id, int data){
            this.te.setField(id, data);
        }

     

     

    the really weird thing is, when the variable in field 0(fuel) changes and the gui is open, it kinda sets lastfuelvalue to fuel(what I dont want), but when i reopen the gui the packet is send again and it gets displayed correct. maybe i didnt explain it good but I just dont understand what mc is doing here...

    lemme show pictures:

    2016-08-14.png

    normal gui(fuel value in top left only for debug)

    2016-08-141.png

    after it used fuel while keeping the gui open

    2016-08-142.png

    after reopening the gui

     

    just want to remind: this ONLY happened after i added all this listening stuff!

     

  10. Problem 1 is solved: In short, i needed to send Server information to the client while i had an Container open - A quick look into ContainerFurnace showed the solution, using detectAndSendChanges()

     

    I have a tileentity that uses fuel to plant plants. how much fuel it has in it is displayed in a gui, that is obviously a client thing. update() gets called on both client and server, but since it only uses fuel and plants if there is space, sometimes the client uses fuel(I would conclude when it is called first) and the server too and sometimes only the server uses fuel. this then makes the gui display the wrong, client-side information.

     

     

    After implementing this, a new problem occured. Go 2 posts down to look at it.

     

    Ok I now solved the issue by simply introducing a new value for the gui and only changing it if the values from the tileentity for lastfuel and fuel are different:

        int lastfuel;
        @Override
        protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
        	if(te.getField(1)!=te.getField(0))
        		lastfuel=te.getField(1);
            ...
        }
    

    still wondering how the problem occured tho

  11. I am having some really annoying difficultied with my Tileentity, and now I've found the problem: writetonbt() is only called on server side, while readfromnbt() is called on both server and client, and this is just making madness. Have been sitting here for 2 hours trying to find a solution...

     

     

    	
    String keys = new String[]{"fuel","lastfuel","yoffset"}
    @Override
        public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
            super.writeToNBT(nbt);
            if(name!="bulkcore"){
            	NBTTagList list = new NBTTagList();
            for (int i = 0; i < this.getSizeInventory(); ++i) {
                if (this.getStackInSlot(i) != null) {
                    NBTTagCompound stackTag = new NBTTagCompound();
                    stackTag.setByte("Slot", (byte) i);
                    this.getStackInSlot(i).writeToNBT(stackTag);
                    list.appendTag(stackTag);
                }
            }
            nbt.setTag("Items", list);
            }
            if (this.hasCustomName()) nbt.setString("CustomName", this.getCustomName());
            for(int i=0;i<keys.length;i++){
            	nbt.setInteger(keys[i],this.getField(i));
            }
        	System.out.println(keys[0]+" written to "+nbt.getInteger("fuel"));
    	return nbt;
        }
    
        @Override
        public void readFromNBT(NBTTagCompound nbt) {
            super.readFromNBT(nbt);
            NBTTagList list = nbt.getTagList("Items", 10);
            for (int i = 0; i < list.tagCount(); ++i) {
                NBTTagCompound stackTag = list.getCompoundTagAt(i);
                int slot = stackTag.getByte("Slot") & 255;
                this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag));
            }
            if (nbt.hasKey("CustomName")) this.setCustomName(nbt.getString("CustomName"));
            for(int i=0;i<keys.length;i++){
            	String key=keys[i];
                if(nbt.hasKey(key)) this.setField(i,nbt.getInteger(key));
            }
        	System.out.println(keys[0]+" read to "+nbt.getInteger("fuel"));
        }
    

     

    notice these sysout commands?

    the console outputs of these:

    [21:06:09] [server thread/INFO] [sTDOUT]: [com.xerus.simpleautomation.te.TEInventory:readFromNBT:77]: fuel read to 50

    [21:06:15] [Client thread/INFO] [sTDOUT]: [com.xerus.simpleautomation.te.TEInventory:readFromNBT:77]: fuel read to 0

    ...

    [21:07:06] [server thread/INFO] [sTDOUT]: [com.xerus.simpleautomation.te.TEInventory:writeToNBT:59]: fuel written to 50

     

    and now my gui displays the client value while my tileentity is using a bit of both...

     

  12. I want to setup gradle portable but when I try to run it offline by

    gradlew eclipse --offline

    (yes i ran it online before and I have the .gradle folder) the following problem occurs. Can I fix it by moving a file somewhere?

     

    A problem occurred configuring root project 'SimpleAutomation'.

    > Could not resolve all dependencies for configuration ':classpath'.

      > Could not resolve net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT.

        Required by:

            :SimpleAutomation:unspecified

          > No cached version of net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT available for offline mode.

     

    What I know:

    • This is a dependency by build.gradle(line 11)
    • This file exists at GRADLE_USER_HOME\caches\modules-2\files-2.1\net.minecraftforge.gradle\ForgeGradle\2.2-SNAPSHOT

×
×
  • Create New...

Important Information

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