3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Listen to creeper igniters tag

Dieser Commit ist enthalten in:
Camotoy 2022-12-30 19:38:47 -05:00
Ursprung 3f4ed67597
Commit d835f81772
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 17 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -33,7 +33,6 @@ import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
@ -66,7 +65,7 @@ public class CreeperEntity extends MonsterEntity {
@Nonnull
@Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
if (itemInHand.asItem() == Items.FLINT_AND_STEEL) { // TODO now uses item tag
if (session.getTagCache().isCreeperIgniter(itemInHand.asItem())) {
return InteractiveTag.IGNITE_CREEPER;
} else {
return super.testMobInteraction(hand, itemInHand);
@ -76,8 +75,8 @@ public class CreeperEntity extends MonsterEntity {
@Nonnull
@Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
if (itemInHand.asItem() == Items.FLINT_AND_STEEL) {
// Ignite creeper
if (session.getTagCache().isCreeperIgniter(itemInHand.asItem())) {
// Ignite creeper - as of 1.19.3
session.playSoundEvent(SoundEvent.IGNITE, position);
return InteractionResult.SUCCESS;
} else {

Datei anzeigen

@ -58,6 +58,7 @@ public class TagCache {
/* Items */
private IntList axolotlTemptItems;
private IntList creeperIgniters;
private IntList fishes;
private IntList flowers;
private IntList foxFood;
@ -94,6 +95,7 @@ public class TagCache {
Map<String, int[]> itemTags = packet.getTags().get("minecraft:item");
this.axolotlTemptItems = IntList.of(itemTags.get("minecraft:axolotl_tempt_items"));
this.creeperIgniters = load(itemTags.get("minecraft:creeper_igniters"));
this.fishes = IntList.of(itemTags.get("minecraft:fishes"));
this.flowers = IntList.of(itemTags.get("minecraft:flowers"));
this.foxFood = IntList.of(itemTags.get("minecraft:fox_food"));
@ -108,6 +110,13 @@ public class TagCache {
}
}
private IntList load(int[] tags) {
if (tags == null) {
return IntLists.EMPTY_LIST;
}
return IntList.of(tags);
}
public void clear() {
this.leaves = IntLists.emptyList();
this.wool = IntLists.emptyList();
@ -122,6 +131,7 @@ public class TagCache {
this.requiresDiamondTool = IntLists.emptyList();
this.axolotlTemptItems = IntLists.emptyList();
this.creeperIgniters = IntLists.emptyList();
this.fishes = IntLists.emptyList();
this.flowers = IntLists.emptyList();
this.foxFood = IntLists.emptyList();
@ -133,6 +143,10 @@ public class TagCache {
return axolotlTemptItems.contains(item.javaId());
}
public boolean isCreeperIgniter(Item item) {
return creeperIgniters.contains(item.javaId());
}
public boolean isFish(GeyserItemStack itemStack) {
return fishes.contains(itemStack.getJavaId());
}