Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

bug chest help me

Comments in 'Plugin Development' started by tigerza118, Feb 9, 2016.

  1. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    Hello, I have bedwars plugin I've made sure that everything goes smoothly. But errors in the opening of the chest was found in minecraft v.0.13 is enough time to open the chest, but no problems have piled chest open and close minecraft game is stopped immediately and open the chest, not 0.14. at all The code below (php5) help me fix this problem thanks.

    PHP:
    public function onEntityDamage(EntityDamageEvent $event)
        {
            if (
    $event instanceof EntityDamageByEntityEvent) {
                if ((
    $Victim $event->getEntity()) && ($Player $event->getDamager())) {
                    if (
    $Player instanceof Human) {
                        
    $Level $Player->getLevel();
                        if (
    $Victim instanceof Villager) {
                            
    $Type = ($Level->getFolderName() == $this->plugin->lobby_name) ? 0;
                            
    $X round($Victim->getX() - 0.5);
                            
    $Z round($Victim->getZ() - 0.5);
                            if (
    $Level->getBlockIdAt($X0$Z) != 54) {
                                
    $Level->setBlock(new Vector3($X0$Z), Block::get(54), truetrue);
                                
    $chest = new Chest($Level->getChunk($X >> 4$Z >> 4true), new Compound(false, array(new Int("x"$X), new Int("y"0), new Int("z"$Z), new String("id"Tile::CHEST))), $this->plugin);
                                
    $Level->addTile($chest);
                            } else 
    $chest $Level->getTile(new Vector3($X0$Z));
                            if (
    $Level->getBlockIdAt($X1$Z) != 54)
                                
    $Level->setBlock(new Vector3($X1$Z), Block::get(0), truetrue);
                            
    $chest = new BuyingInventory($Level->getTile(new Vector3($X0$Z)), $Player);
                            
    $contents = [];
                            switch (
    $Type) {
                                case 
    0:
                                    foreach (
    $this->plugin->buys_Values as $Buy_Value)
                                        
    $contents [] = Item::get($Buy_Value[0], 01);
                                    break;
                                case 
    1:
                                    if (
    $this->plugin->status == 0) {
                                        foreach (
    $this->plugin->mapList as $Map)
                                            
    $contents [] = Item::get(35$Map[0], ($Map[4] == 0) ? 99 $Map[4]);
                                    } else {
                                        
    $contents [] = Item::get(34501);
                                        foreach (
    $this->plugin->game->teams as $Name => $Team)
                                            
    $contents [] = Item::get(35$this->plugin->getTeamDataByName($Name), (count($Team->players) == 0) ? 99 count($Team->players));
                                    }
                                    break;
                            }
                            
    $chest->setContents($contents);
                            
    $this->plugin->setState("buying_chest"$Player$chest);
                            
    $this->plugin->setState("buying_type"$Player$Type);
                            
    $this->plugin->setState("buying_menu"$Player, -1);
                            
    $Player->addWindow($chest);
                            
    $event->setCancelled(true);
                        } elseif (
    $Victim instanceof Human) {
                            if (
    $Level->getFolderName() == $this->plugin->lobby_name) {
                                
    $event->setCancelled(true);
                                return;
                            }
                            if ((!
    $this->plugin->game) || ($this->plugin->game->level_name != $Level->getFolderName())) return;
                            
    $event->setCancelled($this->plugin->game->getTeamByPlayer($Player) == $this->plugin->game->getTeamByPlayer($Victim));
                            
    $HandItem $Player->getInventory()->getItemInHand();
                            switch (
    $HandItem->getId()) {
                                case 
    259:
                                    
    $Victim->setOnFire(5);
                                    
    $event->setKnockBack(0);
                                    break;
                                case 
    280:
                                    
    $event->setKnockBack(0.6);
                                    break;
                            }
                            if (
    $Victim->getHealth() - $event->getFinalDamage() <= 0) {
                                
    $this->plugin->game->popupInfo2->playersData[strtolower($Player->getName())][1] += $this->plugin->game->popupInfo2->playersData[strtolower($Victim->getName())][1];
                                
    $this->plugin->game->popupInfo2->playersData[strtolower($Victim->getName())][1] = 0;
                            }
                        } elseif (
    $Victim instanceof Villager) {
                            
    $Level $Victim->getLevel();
                            if (
    $Level->getFolderName() == $this->plugin->lobby_name) {
                                
    $event->setCancelled(true);
                                return;
                            }
                            if ((!
    $this->plugin->game) || ($this->plugin->game->level_name != $Level->getFolderName()))
                                return;
                            
    $event->setCancelled(true);
                        }
                    }
                }
            } else if ((
    $Player $event->getEntity()) instanceof Entity) {
                
    $Level $Player->getLevel();
                if ((!
    $this->plugin->game) || ($this->plugin->game->level_name != $Level->getFolderName()))
                    return;
                
    $X $Player->getFloorX();
                
    $Y $Player->getFloorY() - 1;
                
    $Z $Player->getFloorZ();
                
    $Block $Level->getBlock(new Vector3($X$Y$Z));
                if (
    $Block->getId() == 133) {
                    
    $event->setCancelled(true);
                }
            }
        }
















    and   









    public function 
    onTransaction(InventoryTransactionEvent $event)
        {
            
    $Transaction $event->getTransaction();
            
    $Player null;
            
    $BuyingTile null;
            
    $BuyingInv null;
            foreach (
    $Transaction->getInventories() as $inv) {
                if (
    $inv instanceof PlayerInventory)
                    
    $Player $inv->getHolder();
                elseif ((
    $inv instanceof BuyingInventory) || ($inv instanceof ChestInventory))
                    
    $BuyingInv $inv;
            }
            if ((!
    $Player) || (!$BuyingInv))
                return;
            if (
    $this->plugin->getState("buying_chest"$Playernull) == null)
                return;
            
    $Level $Player->getLevel();
            
    $BuyingTile $BuyingInv->getHolder();
            
    $added = [];
            foreach (
    $Transaction->getTransactions() as $t) {
                foreach (
    $this->traderInvTransaction($t) as $nt)
                    
    $added [] = $nt;
            }
            
    $event->setCancelled(true);
            
    $X $BuyingTile->getX();
            
    $Y $BuyingTile->getY();
            
    $Z $BuyingTile->getZ();
            
    $Slot $added[0]->getSlot();
            
    $SourceItem $added[0]->getSourceItem();
            
    $TargetItem $added[0]->getTargetItem();
            switch (
    $this->plugin->getState("buying_type"$Playernull)) {
                case 
    0:
                    if (
    $Y == 0) {
                        if (
    $Level->getBlockIdAt($X$Y 1$Z) != 54) {
                            
    $Level->setBlock(new Vector3($X$Y 1$Z), Block::get(54), truetrue);
                            
    $chest = new Chest($Level->getChunk($X >> 4$Z >> 4true), new Compound(false, array(new Int("x"$X), new Int("y"$Y 1), new Int("z"$Z), new String("id"Tile::CHEST))), $this->plugin);
                            
    $Level->addTile($chest);
                        } else 
    $chest $Level->getTile(new Vector3($X$Y 1$Z));
                        if (
    $Level->getBlockIdAt($X$Y 2$Z) != 54)
                        
    $chest = new BuyingInventory($chest$Player);
                        
    $contents = [];
                        foreach (
    $this->plugin->buys_Values[$Slot][1] as $j => $buy)
                            
    $contents [] = Item::get($buy[1], $buy[2], $buy[3]);
                        
    $chest->setContents($contents);
                        
    $this->plugin->setState("buying_chest"$Player$chest);
                        
    $this->plugin->setState("buying_menu"$Player$Slot);
                        
    $Player->addWindow($chest);
                    } else {
                        
    $this->plugin->game->Buy($Player$this->plugin->getState("buying_menu"$Player, -1), $Slot);
                    }
                    break;
                case 
    1:
                    
    $this->plugin->SelectTeam($Player$Slot 1$TargetItem);
                    break;
                case 
    2:
                    
    $Item $BuyingInv->getItem($Slot);
                    if (((
    $i array_search($Item->getId(), [336265266])) !== false) && ($t $this->plugin->spawner_gives[["b""i""g"][$i]])) {
                        if (!isset(
    $this->plugin->game->popupInfo2->playersData[strtolower($Player->getName())][1])) {
                            
    $this->plugin->game->popupInfo2->playersData[strtolower($Player->getName())][0] = TextFormat::GREEN;
                            
    $this->plugin->game->popupInfo2->playersData[strtolower($Player->getName())][1] = 0;
                        }
                        
    $this->plugin->game->popupInfo2->playersData[strtolower($Player->getName())][1] += $Item->getCount() * $t;
                        
    $BuyingInv->clear($Slot);
                    } else 
    $event->setCancelled(false);
                    break;
            }
        }













    Last edited: Feb 9, 2016
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Do you even english? Please use a Translator when not knowing english (well), so we can at least understand you a bit..
  3. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    I have the same problem as for my Bedwars :(
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    The Problem is, that MCPE 0.14.0 closes all chests that are more than around 30 blocks away! You have to make the tile near the player!
    PocketKiller likes this.
  5. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    I english, we english, we all english
  6. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Now to a real answer -.-"
    in 0.14 it won't open because Compound has to be CompoundTag. And more. The plugin is made for 0.11 to 0.13.
    0.13 Has the bug that the tile is ways too far away
    Like he said.
    PocketKiller likes this.
  7. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    sorry i am bad eng -/-
  8. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    *modify Hello, I have bedwars plugin I've made sure that everything goes smoothly. But errors in the opening of the chest was found in minecraft v.0.13 is enough time to open the chest, but no problems have piled chest open and close minecraft game is stopped immediately and open the chest, not 0.14. at all The code below (php5) help me fix this problem thanks.
  9. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    guys, if you still dont know.... ill translate.
    Upon chest open, the game crashes
    simples.
    i speak fluent "Broken English"
    Last edited: Feb 9, 2016
  10. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Instead send a new post, you can also use 'Edit' button.
    TheDeibo likes this.

Share This Page

Advertisement