-
Recently Browsing
No registered users viewing this page.
-
Posts
-
By ThisIsNotOriginal · Posted
when i run it the game gets terminated and doesnt give me a log except the one i provided -
By ThisIsNotOriginal · Posted
idk where that is this si the only file it shows me -
could you send the latest.log or the debug.log files?
-
By keepercreeper22 · Posted
my server file seems to get stuck on unloading dimension one, i can easily share if someone would reply with there disco bandicam 2021-03-03 18-49-20-637.mp4 rd i can figure it out quick, it might even be done by the time i get answer. -
Finally it is working. Thank you so much for the hints and for pointing me to the right direction @Draco18s. I'm going to share a functional version. Although it is not finished, I think it can help someone who has the same issue. public class BlockShop extends Block { public BlockShop() { super(AbstractBlock.Properties .create(Material.BARRIER) .hardnessAndResistance(-1) ); } @Override public ActionResultType onBlockActivated( BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { if (!world.isRemote) { // Server side BlockState signState = world.getBlockState(pos.down()); if (signState != null) { Block blockSign = signState.getBlock(); if (blockSign == Blocks.OAK_SIGN) { Item item = blockSign.getBlock().asItem(); TileEntity te = world.getTileEntity(pos.down()); SignTileEntity signTe = (SignTileEntity)te; CompoundNBT nbt = signTe.getUpdateTag(); String sellId = ""; int price = -1; int quantity = -1; try { sellId = ITextComponent.Serializer .getComponentFromJson(nbt.getString("Text2")) .getString(); price = Integer.parseInt(ITextComponent.Serializer .getComponentFromJson(nbt.getString("Text3")) .getString() ); quantity = Integer.parseInt(ITextComponent.Serializer .getComponentFromJson(nbt.getString("Text4")) .getString() ); } catch (NumberFormatException e) { e.printStackTrace(System.err); } buyItem(player, world, sellId, price, quantity); } } } return ActionResultType.CONSUME; } private void buyItem(PlayerEntity player, World world, String itemId, int price, int quantity) { PlayerInventory inv = player.inventory; ItemStack creditStack = InitItems.CREDIT_ITEM.get().getDefaultInstance(); ItemStack itemStack = ItemStack.EMPTY; if (itemId.contains("blueberry")) itemStack = InitItems.FRESISUIS_BLUEBERRY.get().getDefaultInstance(); else if (itemId.contains("lemon")) itemStack = InitItems.FRESISUIS_LEMON.get().getDefaultInstance(); else if (itemId.contains("lime")) itemStack = InitItems.FRESISUIS_LIME.get().getDefaultInstance(); else if (itemId.contains("orange")) itemStack = InitItems.FRESISUIS_ORANGE.get().getDefaultInstance(); else if (itemId.contains("strawberry")) itemStack = InitItems.FRESISUIS_STRAWBERRY.get().getDefaultInstance(); else if (itemId.contains("suppository")) itemStack = InitItems.GLOWING_SUPPOSITORY.get().getDefaultInstance(); // TODO: check if space is available before removing coins int initialCoins = inv.count(creditStack.getItem()); if (!itemStack.isEmpty() && initialCoins >= price) { int freeSlotIndex = inv.getFirstEmptyStack(); // TODO: replace by <append to firstItemStack> itemStack.setCount(quantity); int toPay = price; while (toPay > 0) { int coinSlotIndex = inv.findSlotMatchingUnusedItem(creditStack); ItemStack coinSlot = inv.getStackInSlot(coinSlotIndex); int amount = Math.min(coinSlot.getCount(), toPay); coinSlot.setCount(coinSlot.getCount() - amount); player.replaceItemInInventory(coinSlotIndex, coinSlot); toPay -= amount; } player.replaceItemInInventory(freeSlotIndex, itemStack); } } }
-
-
Topics
-
Who's Online (See full list)