Skip to content

Commit aff0c6d

Browse files
committed
spit out disc when done
1 parent f39b739 commit aff0c6d

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/main/java/fn10/musicexpansion/blocks/entity/DiscBurnerBlockEntity.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package fn10.musicexpansion.blocks.entity;
22

33
import java.util.Iterator;
4-
import java.util.Map;
5-
4+
import fn10.musicexpansion.MusicExpanded;
65
import fn10.musicexpansion.blocks.DiscBurnerBlock;
76
import fn10.musicexpansion.menu.DiscBurnerMenu;
87
import fn10.musicexpansion.reg.MusicExpandedAudio;
@@ -13,7 +12,6 @@
1312
import net.minecraft.core.NonNullList;
1413
import net.minecraft.nbt.CompoundTag;
1514
import net.minecraft.network.chat.Component;
16-
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
1715
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
1816
import net.minecraft.server.level.ServerPlayer;
1917
import net.minecraft.sounds.SoundSource;
@@ -23,8 +21,10 @@
2321
import net.minecraft.world.inventory.AbstractContainerMenu;
2422
import net.minecraft.world.inventory.ContainerData;
2523
import net.minecraft.world.inventory.SimpleContainerData;
24+
import net.minecraft.world.item.Item;
2625
import net.minecraft.world.item.ItemStack;
2726
import net.minecraft.world.level.Level;
27+
import net.minecraft.world.level.block.Block;
2828
import net.minecraft.world.level.block.entity.BaseContainerBlockEntity;
2929
import net.minecraft.world.level.block.state.BlockState;
3030
import net.minecraft.world.level.storage.ValueInput;
@@ -82,7 +82,8 @@ protected void saveAdditional(ValueOutput output) {
8282
ContainerHelper.saveAllItems(output, inventory);
8383
TypedOutputList<ItemStack> list = output.list("burningCurrently", ItemStack.CODEC);
8484
burningCurrently.forEach(stack -> {
85-
list.add(stack);
85+
if (!stack.isEmpty())
86+
list.add(stack);
8687
});
8788

8889
super.saveAdditional(output);
@@ -109,11 +110,6 @@ public CompoundTag getUpdateTag(HolderLookup.Provider registryLookup) {
109110
return saveWithoutMetadata(registryLookup);
110111
}
111112

112-
@Override
113-
public ClientboundBlockEntityDataPacket getUpdatePacket() {
114-
return ClientboundBlockEntityDataPacket.create(this);
115-
}
116-
117113
public static void tick(Level world, BlockPos blockPos, BlockState blockState, DiscBurnerBlockEntity entity) {
118114
if (world.isClientSide())
119115
return;
@@ -151,16 +147,16 @@ public static void tick(Level world, BlockPos blockPos, BlockState blockState, D
151147
entity.isBurning = true;
152148
world.playSound(null, blockPos, MusicExpandedAudio.DISC_BURNER_START, SoundSource.BLOCKS);
153149
} else {
154-
// MusicExpanded.LOGGER.info("Lets see if " + input1.toString() + " is " +
155-
// entity.burningCurrently.get(0).toString());
156-
// MusicExpanded.LOGGER.info("Lets see if " + input2.toString() + " is " +
157-
// entity.burningCurrently.get(1).toString());
158150
if (!(ItemStack.matches(entity.burningCurrently.get(0), input1)
159151
&& ItemStack.matches(entity.burningCurrently.get(1), input2))) {
160152
entity.isBurning = false;
161153
entity.stoppedSound = false;
162154
}
163155
entity.burnTime--;
156+
if (entity.burnTime <= 0) {
157+
Block.popResource(world, blockPos, entity.inventory.get(0));
158+
entity.inventory.set(0, ItemStack.EMPTY);
159+
}
164160
entity.data.set(0, entity.burnTime);
165161
}
166162
} else if (entity.isBurning) {

0 commit comments

Comments
 (0)